Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: replace fast-extend with native Object.assign
  • Loading branch information
G-Rath committed Feb 16, 2020
1 parent 7d3b132 commit 934f1f3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -23,7 +23,6 @@
"url": "https://github.com/streamich/memfs.git"
},
"dependencies": {
"fast-extend": "1.0.2",
"fs-monkey": "0.3.3"
},
"devDependencies": {
Expand Down
19 changes: 9 additions & 10 deletions src/volume.ts
Expand Up @@ -12,7 +12,6 @@ import { constants } from './constants';
import { EventEmitter } from 'events';
import { TEncodingExtended, TDataOut, assertEncoding, strToEncoding, ENCODING_UTF8 } from './encoding';
import * as errors from './internal/errors';
const { extend } = require('fast-extend');
import util = require('util');
import createPromisesApi from './promises';

Expand Down Expand Up @@ -215,10 +214,10 @@ function getOptions<T extends IOptions>(defaults: T, options?: T | string): T {
const tipeof = typeof options;
switch (tipeof) {
case 'string':
opts = extend({}, defaults, { encoding: options as string });
opts = Object.assign({}, defaults, { encoding: options as string });
break;
case 'object':
opts = extend({}, defaults, options);
opts = Object.assign({}, defaults, options);
break;
default:
throw TypeError(ERRSTR_OPTS(tipeof));
Expand Down Expand Up @@ -339,8 +338,8 @@ const mkdirDefaults: IMkdirOptions = {
recursive: false,
};
const getMkdirOptions = (options): IMkdirOptions => {
if (typeof options === 'number') return extend({}, mkdirDefaults, { mode: options });
return extend({}, mkdirDefaults, options);
if (typeof options === 'number') return Object.assign({}, mkdirDefaults, { mode: options });
return Object.assign({}, mkdirDefaults, options);
};

// Options for `fs.rmdir` and `fs.rmdirSync`
Expand All @@ -351,7 +350,7 @@ const rmdirDefaults: IRmdirOptions = {
recursive: false,
};
const getRmdirOptions = (options): IRmdirOptions => {
return extend({}, rmdirDefaults, options);
return Object.assign({}, rmdirDefaults, options);
};

// Options for `fs.readdir` and `fs.readdirSync`
Expand All @@ -372,7 +371,7 @@ export interface IStatOptions {
const statDefaults: IStatOptions = {
bigint: false,
};
const getStatOptions: (options?: any) => IStatOptions = (options = {}) => extend({}, statDefaults, options);
const getStatOptions: (options?: any) => IStatOptions = (options = {}) => Object.assign({}, statDefaults, options);
const getStatOptsAndCb: (options: any, callback?: TCallback<Stats>) => [IStatOptions, TCallback<Stats>] = (
options,
callback?,
Expand Down Expand Up @@ -579,7 +578,7 @@ export class Volume {
}

constructor(props = {}) {
this.props = extend({ Node, Link, File }, props);
this.props = Object.assign({ Node, Link, File }, props);

const root = this.createLink();
root.setNode(this.createNode(true));
Expand Down Expand Up @@ -2228,7 +2227,7 @@ function FsReadStream(vol, path, options) {
this._vol = vol;

// a little bit bigger buffer and water marks by default
options = extend({}, getOptions(options, {}));
options = Object.assign({}, getOptions(options, {}));
if (options.highWaterMark === undefined) options.highWaterMark = 64 * 1024;

Readable.call(this, options);
Expand Down Expand Up @@ -2390,7 +2389,7 @@ function FsWriteStream(vol, path, options) {
if (!(this instanceof FsWriteStream)) return new (FsWriteStream as any)(vol, path, options);

this._vol = vol;
options = extend({}, getOptions(options, {}));
options = Object.assign({}, getOptions(options, {}));

Writable.call(this, options);

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom", "es2015.promise"],
"lib": ["ES2017", "dom"],
"module": "commonjs",
"removeComments": false,
"noImplicitAny": false,
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Expand Up @@ -2183,11 +2183,6 @@ fast-deep-equal@^2.0.1:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=

fast-extend@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/fast-extend/-/fast-extend-1.0.2.tgz#3b8a5b09cbc8ff3d6d47eaf397398c0a643e441b"
integrity sha512-XXA9RmlPatkFKUzqVZAFth18R4Wo+Xug/S+C7YlYA3xrXwfPlW3dqNwOb4hvQo7wZJ2cNDYhrYuPzVOfHy5/uQ==

fast-glob@^2.2.6:
version "2.2.7"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d"
Expand Down

0 comments on commit 934f1f3

Please sign in to comment.