Socket
Socket
Sign inDemoInstall

memfs

Package Overview
Dependencies
2
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.9.4 to 2.10.0

lib/constants.d.ts

17

lib/index.js
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};

@@ -10,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -1,15 +0,12 @@

'use strict';
// The whole point behind this internal module is to allow Node.js to no
// longer be forced to treat every error message change as a semver-major
// change. The NodeError classes here all expose a `code` property whose
// value statically and permanently identifies the error. While the error
// message may change, the code should not.
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
const kCode = typeof Symbol === 'undefined' ? '_kCode' : Symbol('code');
const messages = {}; // new Map();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var kCode = typeof Symbol === 'undefined' ? '_kCode' : Symbol('code');
var messages = {};
// Lazily loaded
var assert = null;

@@ -19,61 +16,42 @@ var util = null;

function makeNodeError(Base) {
return function (_Base) {
_inherits(NodeError, _Base);
function NodeError(key) {
_classCallCheck(this, NodeError);
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var _this = _possibleConstructorReturn(this, (NodeError.__proto__ || Object.getPrototypeOf(NodeError)).call(this, message(key, args)));
_this.code = key;
_this[kCode] = key;
_this.name = _get(NodeError.prototype.__proto__ || Object.getPrototypeOf(NodeError.prototype), 'name', _this) + ' [' + _this[kCode] + ']';
return _this;
return class NodeError extends Base {
constructor(key, ...args) {
super(message(key, args));
this.code = key;
this[kCode] = key;
this.name = `${super.name} [${this[kCode]}]`;
}
return NodeError;
}(Base);
};
}
var AssertionError = function (_Error) {
_inherits(AssertionError, _Error);
function AssertionError(options) {
_classCallCheck(this, AssertionError);
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object' || options === null) {
class AssertionError extends Error {
constructor(options) {
if (typeof options !== 'object' || options === null) {
throw new exports.TypeError('ERR_INVALID_ARG_TYPE', 'options', 'object');
}
if (options.message) {
var _this2 = _possibleConstructorReturn(this, (AssertionError.__proto__ || Object.getPrototypeOf(AssertionError)).call(this, options.message));
super(options.message);
} else {
if (util === null) util = require('util');
var _this2 = _possibleConstructorReturn(this, (AssertionError.__proto__ || Object.getPrototypeOf(AssertionError)).call(this, util.inspect(options.actual).slice(0, 128) + ' ' + (options.operator + ' ' + util.inspect(options.expected).slice(0, 128))));
super(`${util.inspect(options.actual).slice(0, 128)} ` +
`${options.operator} ${util.inspect(options.expected).slice(0, 128)}`);
}
_this2.generatedMessage = !options.message;
_this2.name = 'AssertionError [ERR_ASSERTION]';
_this2.code = 'ERR_ASSERTION';
_this2.actual = options.actual;
_this2.expected = options.expected;
_this2.operator = options.operator;
Error.captureStackTrace(_this2, options.stackStartFunction);
return _possibleConstructorReturn(_this2);
this.generatedMessage = !options.message;
this.name = 'AssertionError [ERR_ASSERTION]';
this.code = 'ERR_ASSERTION';
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
Error.captureStackTrace(this, options.stackStartFunction);
}
}
return AssertionError;
}(Error);
function message(key, args) {
if (assert === null) assert = require('assert');
assert.strictEqual(typeof key === 'undefined' ? 'undefined' : _typeof(key), 'string');
var msg = messages[key];
assert(msg, 'An invalid error message key was used: ' + key + '.');
var fmt = void 0;
assert.strictEqual(typeof key, 'string');
// const msg = messages.get(key);
const msg = messages[key];
assert(msg, `An invalid error message key was used: ${key}.`);
let fmt;
if (typeof msg === 'function') {

@@ -84,3 +62,4 @@ fmt = msg;

fmt = util.format;
if (args === undefined || args.length === 0) return msg;
if (args === undefined || args.length === 0)
return msg;
args.unshift(msg);

@@ -91,2 +70,4 @@ }

// Utility function for registering the error codes. Only used here. Exported
// *only* to allow for testing.
function E(sym, val) {

@@ -97,9 +78,23 @@ messages[sym] = typeof val === 'function' ? val : String(val);

module.exports = exports = {
message: message,
message,
Error: makeNodeError(Error),
TypeError: makeNodeError(TypeError),
RangeError: makeNodeError(RangeError),
AssertionError: AssertionError,
E: E };
AssertionError,
E // This is exported only to facilitate testing.
};
// To declare an error message, use the E(sym, val) function above. The sym
// must be an upper case string. The val can be either a function or a string.
// The return value of the function must be a string.
// Examples:
// E('EXAMPLE_KEY1', 'This is the error value');
// E('EXAMPLE_KEY2', (a, b) => return `${a} ${b}`);
//
// Once an error code has been assigned, the code itself MUST NOT change and
// any given error code must never be reused to identify a different error.
//
// Any error code added here should also be added to the documentation
//
// Note: Please try to keep these in alphabetical order
E('ERR_ARG_NOT_ITERABLE', '%s must be iterable');

@@ -109,46 +104,50 @@ E('ERR_ASSERTION', '%s');

E('ERR_CHILD_CLOSED_BEFORE_REPLY', 'Child closed before reply received');
E('ERR_CONSOLE_WRITABLE_STREAM', 'Console expects a writable stream instance for %s');
E('ERR_CONSOLE_WRITABLE_STREAM',
'Console expects a writable stream instance for %s');
E('ERR_CPU_USAGE', 'Unable to obtain cpu usage %s');
E('ERR_DNS_SET_SERVERS_FAILED', function (err, servers) {
return 'c-ares failed to set servers: "' + err + '" [' + servers + ']';
});
E('ERR_DNS_SET_SERVERS_FAILED', (err, servers) =>
`c-ares failed to set servers: "${err}" [${servers}]`);
E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value');
E('ERR_ENCODING_NOT_SUPPORTED', function (enc) {
return 'The "' + enc + '" encoding is not supported';
});
E('ERR_ENCODING_INVALID_ENCODED_DATA', function (enc) {
return 'The encoded data was not valid for encoding ' + enc;
});
E('ERR_HTTP_HEADERS_SENT', 'Cannot render headers after they are sent to the client');
E('ERR_ENCODING_NOT_SUPPORTED',
(enc) => `The "${enc}" encoding is not supported`);
E('ERR_ENCODING_INVALID_ENCODED_DATA',
(enc) => `The encoded data was not valid for encoding ${enc}`);
E('ERR_HTTP_HEADERS_SENT',
'Cannot render headers after they are sent to the client');
E('ERR_HTTP_INVALID_STATUS_CODE', 'Invalid status code: %s');
E('ERR_HTTP_TRAILER_INVALID', 'Trailers are invalid with this transfer encoding');
E('ERR_HTTP_TRAILER_INVALID',
'Trailers are invalid with this transfer encoding');
E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range');
E('ERR_INVALID_ARG_TYPE', invalidArgType);
E('ERR_INVALID_ARRAY_LENGTH', function (name, len, actual) {
assert.strictEqual(typeof actual === 'undefined' ? 'undefined' : _typeof(actual), 'number');
return 'The array "' + name + '" (length ' + actual + ') must be of length ' + len + '.';
});
E('ERR_INVALID_ARRAY_LENGTH',
(name, len, actual) => {
assert.strictEqual(typeof actual, 'number');
return `The array "${name}" (length ${actual}) must be of length ${len}.`;
});
E('ERR_INVALID_BUFFER_SIZE', 'Buffer size must be a multiple of %s');
E('ERR_INVALID_CALLBACK', 'Callback must be a function');
E('ERR_INVALID_CHAR', 'Invalid character in %s');
E('ERR_INVALID_CURSOR_POS', 'Cannot set cursor row without setting its column');
E('ERR_INVALID_CURSOR_POS',
'Cannot set cursor row without setting its column');
E('ERR_INVALID_FD', '"fd" must be a positive integer: %s');
E('ERR_INVALID_FILE_URL_HOST', 'File URL host must be "localhost" or empty on %s');
E('ERR_INVALID_FILE_URL_HOST',
'File URL host must be "localhost" or empty on %s');
E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s');
E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent');
E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s');
E('ERR_INVALID_OPT_VALUE', function (name, value) {
return 'The value "' + String(value) + '" is invalid for option "' + name + '"';
});
E('ERR_INVALID_OPT_VALUE_ENCODING', function (value) {
return 'The value "' + String(value) + '" is invalid for option "encoding"';
});
E('ERR_INVALID_REPL_EVAL_CONFIG', 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL');
E('ERR_INVALID_SYNC_FORK_INPUT', 'Asynchronous forks do not support Buffer, Uint8Array or string input: %s');
E('ERR_INVALID_OPT_VALUE',
(name, value) => {
return `The value "${String(value)}" is invalid for option "${name}"`;
});
E('ERR_INVALID_OPT_VALUE_ENCODING',
(value) => `The value "${String(value)}" is invalid for option "encoding"`);
E('ERR_INVALID_REPL_EVAL_CONFIG',
'Cannot specify both "breakEvalOnSigint" and "eval" for REPL');
E('ERR_INVALID_SYNC_FORK_INPUT',
'Asynchronous forks do not support Buffer, Uint8Array or string input: %s');
E('ERR_INVALID_THIS', 'Value of "this" must be of type %s');
E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple');
E('ERR_INVALID_URL', 'Invalid URL: %s');
E('ERR_INVALID_URL_SCHEME', function (expected) {
return 'The URL must be ' + oneOf(expected, 'scheme');
});
E('ERR_INVALID_URL_SCHEME',
(expected) => `The URL must be ${oneOf(expected, 'scheme')}`);
E('ERR_IPC_CHANNEL_CLOSED', 'Channel closed');

@@ -167,3 +166,4 @@ E('ERR_IPC_DISCONNECTED', 'IPC channel is already disconnected');

E('ERR_SOCKET_BAD_PORT', 'Port should be > 0 and < 65536');
E('ERR_SOCKET_BAD_TYPE', 'Bad socket type specified. Valid types are: udp4, udp6');
E('ERR_SOCKET_BAD_TYPE',
'Bad socket type specified. Valid types are: udp4, udp6');
E('ERR_SOCKET_CANNOT_SEND', 'Unable to send data');

@@ -175,12 +175,15 @@ E('ERR_SOCKET_CLOSED', 'Socket is closed');

E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode');
E('ERR_TLS_CERT_ALTNAME_INVALID', 'Hostname/IP does not match certificate\'s altnames: %s');
E('ERR_TLS_DH_PARAM_SIZE', function (size) {
return 'DH parameter size ' + size + ' is less than 2048';
});
E('ERR_TLS_CERT_ALTNAME_INVALID',
'Hostname/IP does not match certificate\'s altnames: %s');
E('ERR_TLS_DH_PARAM_SIZE', (size) =>
`DH parameter size ${size} is less than 2048`);
E('ERR_TLS_HANDSHAKE_TIMEOUT', 'TLS handshake timeout');
E('ERR_TLS_RENEGOTIATION_FAILED', 'Failed to renegotiate');
E('ERR_TLS_REQUIRED_SERVER_NAME', '"servername" is required parameter for Server.addContext');
E('ERR_TLS_REQUIRED_SERVER_NAME',
'"servername" is required parameter for Server.addContext');
E('ERR_TLS_SESSION_ATTACK', 'TSL session renegotiation attack detected');
E('ERR_TRANSFORM_ALREADY_TRANSFORMING', 'Calling transform done when still transforming');
E('ERR_TRANSFORM_WITH_LENGTH_0', 'Calling transform done when writableState.length != 0');
E('ERR_TRANSFORM_ALREADY_TRANSFORMING',
'Calling transform done when still transforming');
E('ERR_TRANSFORM_WITH_LENGTH_0',
'Calling transform done when writableState.length != 0');
E('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s');

@@ -190,8 +193,11 @@ E('ERR_UNKNOWN_SIGNAL', 'Unknown signal: %s');

E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type');
E('ERR_V8BREAKITERATOR', 'Full ICU data not installed. ' + 'See https://github.com/nodejs/node/wiki/Intl');
E('ERR_V8BREAKITERATOR', 'Full ICU data not installed. ' +
'See https://github.com/nodejs/node/wiki/Intl');
function invalidArgType(name, expected, actual) {
assert(name, 'name is required');
var determiner = void 0;
// determiner: 'must be' or 'must not be'
let determiner;
if (expected.includes('not ')) {

@@ -204,17 +210,17 @@ determiner = 'must not be';

var msg = void 0;
let msg;
if (Array.isArray(name)) {
var names = name.map(function (val) {
return '"' + val + '"';
}).join(', ');
msg = 'The ' + names + ' arguments ' + determiner + ' ' + oneOf(expected, 'type');
var names = name.map((val) => `"${val}"`).join(', ');
msg = `The ${names} arguments ${determiner} ${oneOf(expected, 'type')}`;
} else if (name.includes(' argument')) {
msg = 'The ' + name + ' ' + determiner + ' ' + oneOf(expected, 'type');
// for the case like 'first argument'
msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
} else {
var type = name.includes('.') ? 'property' : 'argument';
msg = 'The "' + name + '" ' + type + ' ' + determiner + ' ' + oneOf(expected, 'type');
const type = name.includes('.') ? 'property' : 'argument';
msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
}
// if actual value received, output it
if (arguments.length >= 3) {
msg += '. Received type ' + (actual !== null ? typeof actual === 'undefined' ? 'undefined' : _typeof(actual) : 'null');
msg += `. Received type ${actual !== null ? typeof actual : 'null'}`;
}

@@ -224,26 +230,20 @@ return msg;

function missingArgs() {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
function missingArgs(...args) {
assert(args.length > 0, 'At least one arg needs to be specified');
var msg = 'The ';
var len = args.length;
args = args.map(function (a) {
return '"' + a + '"';
});
let msg = 'The ';
const len = args.length;
args = args.map((a) => `"${a}"`);
switch (len) {
case 1:
msg += args[0] + ' argument';
msg += `${args[0]} argument`;
break;
case 2:
msg += args[0] + ' and ' + args[1] + ' arguments';
msg += `${args[0]} and ${args[1]} arguments`;
break;
default:
msg += args.slice(0, len - 1).join(', ');
msg += ', and ' + args[len - 1] + ' arguments';
msg += `, and ${args[len - 1]} arguments`;
break;
}
return msg + ' must be specified';
return `${msg} must be specified`;
}

@@ -255,16 +255,15 @@

if (Array.isArray(expected)) {
var len = expected.length;
const len = expected.length;
assert(len > 0, 'At least one expected value needs to be specified');
expected = expected.map(function (i) {
return String(i);
});
expected = expected.map((i) => String(i));
if (len > 2) {
return 'one of ' + thing + ' ' + expected.slice(0, len - 1).join(', ') + ', or ' + expected[len - 1];
return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
expected[len - 1];
} else if (len === 2) {
return 'one of ' + thing + ' ' + expected[0] + ' or ' + expected[1];
return `one of ${thing} ${expected[0]} or ${expected[1]}`;
} else {
return 'of ' + thing + ' ' + expected[0];
return `of ${thing} ${expected[0]}`;
}
} else {
return 'of ' + thing + ' ' + String(expected);
return `of ${thing} ${String(expected)}`;
}

@@ -277,4 +276,4 @@ }

} else {
return '"' + name + '" is outside of buffer bounds';
return `"${name}" is outside of buffer bounds`;
}
}
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

{
"name": "memfs",
"version": "2.9.4",
"version": "2.10.0",
"description": "In-memory file-system with Node's fs API.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib"
],
"keywords": [

@@ -31,22 +35,17 @@ "fs",

"devDependencies": {
"@types/jest": "23.3.1",
"@types/node": "9.6.31",
"cpy-cli": "2.0.0",
"jest": "21.2.1",
"jest-tap-reporter": "1.9.0",
"ts-jest": "23.0.0",
"typescript": "2.9.2",
"ts-node": "7.0.0",
"babel-cli": "6.26.0",
"babel-preset-es2015": "6.24.1",
"gulp": "3.9.1",
"gulp-typescript": "4.0.2",
"semantic-release": "15.6.2",
"@types/node": "9.6.22",
"@types/jest": "23.1.4",
"mol-conventional-changelog": "1.4.0",
"rimraf": "2.6.2",
"mol-conventional-changelog": "1.4.0"
"semantic-release": "15.9.14",
"ts-jest": "23.1.4",
"ts-node": "7.0.1",
"typescript": "3.0.3"
},
"scripts": {
"clean": "rimraf lib types",
"build": "npm run build-ts && npm run build-js",
"build-ts": "gulp build-ts",
"build-js": "babel src --out-dir lib",
"build": "tsc -p . && cpy src/internal lib/internal",
"test": "jest",

@@ -53,0 +52,0 @@ "test:coverage": "jest --coverage",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc