Skip to content

Commit

Permalink
fix: use internal buffer instead of global Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema committed Jan 8, 2024
1 parent eac1ce2 commit d5a6398
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions 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';
Expand Down
1 change: 1 addition & 0 deletions 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';

Expand Down
7 changes: 6 additions & 1 deletion 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';
Expand Down Expand Up @@ -60,7 +61,11 @@ interface SwapFile {
export class NodeFileSystemWritableFileStream extends WritableStream implements IFileSystemWritableFileStream {
protected readonly swap: SwapFile;

constructor(protected readonly fs: NodeFsaFs, protected readonly path: string, keepExistingData: boolean) {
constructor(
protected readonly fs: NodeFsaFs,
protected readonly path: string,
keepExistingData: boolean,
) {
const swap: SwapFile = { handle: undefined, path: '', offset: 0 };
super({
async start() {
Expand Down
2 changes: 1 addition & 1 deletion 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';
Expand Down
1 change: 1 addition & 0 deletions 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';
Expand Down
1 change: 0 additions & 1 deletion src/webfs/index.ts
@@ -1,5 +1,4 @@
(<any>self).process = require('process/browser');
(<any>self).Buffer = require('buffer').Buffer;

import { FsaNodeFs, FsaNodeSyncAdapterWorker } from '../fsa-to-node';
import { FsaNodeSyncWorker } from '../../src/fsa-to-node/worker/FsaNodeSyncWorker';
Expand Down

0 comments on commit d5a6398

Please sign in to comment.