From 6bb8767c7eca321e70bfb7dae0fa1fd8ef78e320 Mon Sep 17 00:00:00 2001 From: jorenbroekema Date: Mon, 8 Jan 2024 12:58:30 +0100 Subject: [PATCH] fix: use internal buffer instead of global Buffer --- src/fsa-to-node/FsaNodeFs.ts | 1 + src/node-to-fsa/NodeFileSystemSyncAccessHandle.ts | 1 + src/node-to-fsa/NodeFileSystemWritableFileStream.ts | 1 + src/node.ts | 2 +- src/node/util.ts | 1 + src/webfs/index.ts | 1 - 6 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/fsa-to-node/FsaNodeFs.ts b/src/fsa-to-node/FsaNodeFs.ts index 2cb97aea0..a46852f50 100644 --- a/src/fsa-to-node/FsaNodeFs.ts +++ b/src/fsa-to-node/FsaNodeFs.ts @@ -1,5 +1,6 @@ import * as optHelpers from '../node/options'; import * as util from '../node/util'; +import { Buffer } from '../internal/buffer'; import { FsPromises } from '../node/FsPromises'; import { pathToLocation, testDirectoryIsWritable } from './util'; import { ERRSTR, MODE } from '../node/constants'; diff --git a/src/node-to-fsa/NodeFileSystemSyncAccessHandle.ts b/src/node-to-fsa/NodeFileSystemSyncAccessHandle.ts index 1405cd516..67fb2cc0d 100644 --- a/src/node-to-fsa/NodeFileSystemSyncAccessHandle.ts +++ b/src/node-to-fsa/NodeFileSystemSyncAccessHandle.ts @@ -1,4 +1,5 @@ import { assertCanWrite } from './util'; +import { Buffer } from '../internal/buffer'; import type { FileSystemReadWriteOptions, IFileSystemSyncAccessHandle } from '../fsa/types'; import type { NodeFsaContext, NodeFsaFs } from './types'; diff --git a/src/node-to-fsa/NodeFileSystemWritableFileStream.ts b/src/node-to-fsa/NodeFileSystemWritableFileStream.ts index c34a77ade..d9381ce18 100644 --- a/src/node-to-fsa/NodeFileSystemWritableFileStream.ts +++ b/src/node-to-fsa/NodeFileSystemWritableFileStream.ts @@ -1,3 +1,4 @@ +import { Buffer } from '../internal/buffer'; import type { Data, FileSystemWritableFileStreamParams, IFileSystemWritableFileStream } from '../fsa/types'; import type { IFileHandle } from '../node/types/misc'; import type { NodeFsaFs } from './types'; diff --git a/src/node.ts b/src/node.ts index 95b1d7f20..c54191537 100644 --- a/src/node.ts +++ b/src/node.ts @@ -1,5 +1,5 @@ import process from './process'; -import { bufferAllocUnsafe, bufferFrom } from './internal/buffer'; +import { Buffer, bufferAllocUnsafe, bufferFrom } from './internal/buffer'; import { constants, S } from './constants'; import { Volume } from './volume'; import { EventEmitter } from 'events'; diff --git a/src/node/util.ts b/src/node/util.ts index c97254bec..26eae1157 100644 --- a/src/node/util.ts +++ b/src/node/util.ts @@ -1,5 +1,6 @@ import { ERRSTR, FLAGS } from './constants'; import * as errors from '../internal/errors'; +import { Buffer } from '../internal/buffer'; import type { FsCallbackApi } from './types'; import type * as misc from './types/misc'; import { ENCODING_UTF8, TEncodingExtended } from '../encoding'; diff --git a/src/webfs/index.ts b/src/webfs/index.ts index c4fc2b61b..928d84c14 100644 --- a/src/webfs/index.ts +++ b/src/webfs/index.ts @@ -1,5 +1,4 @@ (self).process = require('process/browser'); -(self).Buffer = require('buffer').Buffer; import { FsaNodeFs, FsaNodeSyncAdapterWorker } from '../fsa-to-node'; import { FsaNodeSyncWorker } from '../../src/fsa-to-node/worker/FsaNodeSyncWorker';