New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ejson-shell-parser

Package Overview
Dependencies
Maintainers
31
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ejson-shell-parser - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

3

dist/declarations/src/index.d.ts

@@ -1,2 +0,3 @@

import { Options } from './options';
import { Options, ParseMode } from './options';
export { ParseMode };
export default function parse(input: string, options?: Partial<Options>): any;

@@ -5,4 +5,4 @@ export declare const GLOBALS: {

export declare const GLOBAL_FUNCTIONS: readonly string[];
export declare function getScopeFunction(key: string): Function;
export declare function getScopeFunction(key: string, withNew: boolean): Function;
export declare function isMethodWhitelisted(member: string, property: string): boolean;
export declare function getClass(member: string): Math | DateConstructor;

@@ -69,7 +69,6 @@ 'use strict';

function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);

@@ -93,3 +92,3 @@ }

if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
_construct = Reflect.construct.bind();
} else {

@@ -150,3 +149,47 @@ _construct = function _construct(Parent, args, Class) {

var SCOPE = {
var SCOPE_CALL = {
Date: function (_Date) {
function Date() {
return _Date.apply(this, arguments);
}
Date.toString = function () {
return _Date.toString();
};
return Date;
}(function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return Date.apply(void 0, _toConsumableArray(args));
})
};
var SCOPE_NEW = {
Date: function (_Date2) {
function Date() {
return _Date2.apply(this, arguments);
}
Date.toString = function () {
return _Date2.toString();
};
return Date;
}(function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return _construct(Date, _toConsumableArray(args));
})
};
var SCOPE_ANY = {
RegExp: RegExp,

@@ -160,2 +203,6 @@ Binary: function Binary(buffer, subType) {

UUID: function UUID(u) {
if (u === undefined) {
return new bson__namespace.UUID().toBinary();
}
return new bson__namespace.Binary(Buffer.from(u.replace(/-/g, ''), 'hex'), 4);

@@ -189,5 +236,17 @@ },

Int64: NumberLong,
Map: function Map(arr) {
return new bson__namespace.Map(arr);
},
Map: function (_Map) {
function Map(_x) {
return _Map.apply(this, arguments);
}
Map.toString = function () {
return _Map.toString();
};
return Map;
}(function (arr) {
var _Map2;
return new ((_Map2 = bson__namespace.Map) !== null && _Map2 !== void 0 ? _Map2 : Map)(arr);
}),
MaxKey: function MaxKey() {

@@ -200,6 +259,6 @@ return new bson__namespace.MaxKey();

ObjectID: function ObjectID(i) {
return new bson__namespace.ObjectID(i);
return new bson__namespace.ObjectId(i);
},
ObjectId: function ObjectId(i) {
return new bson__namespace.ObjectID(i);
return new bson__namespace.ObjectId(i);
},

@@ -210,3 +269,3 @@ Symbol: function Symbol(i) {

Timestamp: function Timestamp(low, high) {
if (typeof low === 'number' && typeof high === 'number') {
if (typeof low === 'number' && typeof high === 'number' || high !== undefined) {
// https://www.mongodb.com/docs/manual/reference/bson-types/#timestamps

@@ -220,7 +279,7 @@ // reverse the order to match the legacy shell

return new bson__namespace.Timestamp(low, high);
return new bson__namespace.Timestamp(low);
},
ISODate: function ISODate() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}

@@ -232,23 +291,3 @@

return _construct(Date, _toConsumableArray(args));
},
Date: function (_Date) {
function Date() {
return _Date.apply(this, arguments);
}
Date.toString = function () {
return _Date.toString();
};
return Date;
}(function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return _construct(Date, _toConsumableArray(args));
})
}
};

@@ -347,6 +386,10 @@ var GLOBALS = Object.freeze({

};
var GLOBAL_FUNCTIONS = Object.freeze(Object.keys(SCOPE));
function getScopeFunction(key) {
if (SCOPE[key]) {
return SCOPE[key];
var GLOBAL_FUNCTIONS = Object.freeze([].concat(_toConsumableArray(Object.keys(SCOPE_ANY)), _toConsumableArray(Object.keys(SCOPE_NEW)), _toConsumableArray(Object.keys(SCOPE_CALL))));
function getScopeFunction(key, withNew) {
if (withNew && SCOPE_NEW[key]) {
return SCOPE_NEW[key];
} else if (!withNew && SCOPE_CALL[key]) {
return SCOPE_CALL[key];
} else if (SCOPE_ANY[key]) {
return SCOPE_ANY[key];
}

@@ -564,3 +607,3 @@

var memberExpression = function memberExpression(node) {
var memberExpression = function memberExpression(node, withNew) {
switch (node.callee.type) {

@@ -570,3 +613,3 @@ case 'Identifier':

// Handing <Constructor>() and new <Constructor>() cases
var callee = getScopeFunction(node.callee.name);
var callee = getScopeFunction(node.callee.name, withNew);
var args = node.arguments.map(function (arg) {

@@ -629,4 +672,6 @@ return walk(arg);

case 'CallExpression':
return memberExpression(node, false);
case 'NewExpression':
return memberExpression(node);
return memberExpression(node, true);

@@ -686,3 +731,3 @@ case 'ObjectExpression':

var ParseMode;
exports.ParseMode = void 0;

@@ -693,3 +738,3 @@ (function (ParseMode) {

ParseMode["Loose"] = "loose";
})(ParseMode || (ParseMode = {}));
})(exports.ParseMode || (exports.ParseMode = {}));

@@ -712,9 +757,9 @@ var StrictOptions = {

switch (mode) {
case ParseMode.Strict:
case exports.ParseMode.Strict:
return StrictOptions;
case ParseMode.Extended:
case exports.ParseMode.Extended:
return ExtendedOptions;
case ParseMode.Loose:
case exports.ParseMode.Loose:
return LooseOptions;

@@ -725,7 +770,7 @@ }

var DefaultOptions = _objectSpread2({
mode: ParseMode.Strict
mode: exports.ParseMode.Strict
}, StrictOptions);
function buildOptions(options) {
return _objectSpread2(_objectSpread2(_objectSpread2({}, DefaultOptions), getModeOptions(options && options.mode || ParseMode.Strict)), options);
return _objectSpread2(_objectSpread2(_objectSpread2({}, DefaultOptions), getModeOptions(options && options.mode || exports.ParseMode.Strict)), options);
}

@@ -749,7 +794,8 @@

}
function parse(input, options) {
var parsedOptions = buildOptions(options);
var _buildAST = buildAST("(".concat(input, ")")),
var _buildAST = buildAST( // Wrapping input into brackets with newlines so that parser can correctly
// process an expression and handle possible trailing comments
"(\n".concat(input, "\n)")),
hasComments = _buildAST.hasComments,

@@ -756,0 +802,0 @@ ast = _buildAST.ast;

@@ -69,7 +69,6 @@ 'use strict';

function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);

@@ -93,3 +92,3 @@ }

if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
_construct = Reflect.construct.bind();
} else {

@@ -150,3 +149,47 @@ _construct = function _construct(Parent, args, Class) {

var SCOPE = {
var SCOPE_CALL = {
Date: function (_Date) {
function Date() {
return _Date.apply(this, arguments);
}
Date.toString = function () {
return _Date.toString();
};
return Date;
}(function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return Date.apply(void 0, _toConsumableArray(args));
})
};
var SCOPE_NEW = {
Date: function (_Date2) {
function Date() {
return _Date2.apply(this, arguments);
}
Date.toString = function () {
return _Date2.toString();
};
return Date;
}(function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return _construct(Date, _toConsumableArray(args));
})
};
var SCOPE_ANY = {
RegExp: RegExp,

@@ -160,2 +203,6 @@ Binary: function Binary(buffer, subType) {

UUID: function UUID(u) {
if (u === undefined) {
return new bson__namespace.UUID().toBinary();
}
return new bson__namespace.Binary(Buffer.from(u.replace(/-/g, ''), 'hex'), 4);

@@ -189,5 +236,17 @@ },

Int64: NumberLong,
Map: function Map(arr) {
return new bson__namespace.Map(arr);
},
Map: function (_Map) {
function Map(_x) {
return _Map.apply(this, arguments);
}
Map.toString = function () {
return _Map.toString();
};
return Map;
}(function (arr) {
var _Map2;
return new ((_Map2 = bson__namespace.Map) !== null && _Map2 !== void 0 ? _Map2 : Map)(arr);
}),
MaxKey: function MaxKey() {

@@ -200,6 +259,6 @@ return new bson__namespace.MaxKey();

ObjectID: function ObjectID(i) {
return new bson__namespace.ObjectID(i);
return new bson__namespace.ObjectId(i);
},
ObjectId: function ObjectId(i) {
return new bson__namespace.ObjectID(i);
return new bson__namespace.ObjectId(i);
},

@@ -210,3 +269,3 @@ Symbol: function Symbol(i) {

Timestamp: function Timestamp(low, high) {
if (typeof low === 'number' && typeof high === 'number') {
if (typeof low === 'number' && typeof high === 'number' || high !== undefined) {
// https://www.mongodb.com/docs/manual/reference/bson-types/#timestamps

@@ -220,7 +279,7 @@ // reverse the order to match the legacy shell

return new bson__namespace.Timestamp(low, high);
return new bson__namespace.Timestamp(low);
},
ISODate: function ISODate() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}

@@ -232,23 +291,3 @@

return _construct(Date, _toConsumableArray(args));
},
Date: function (_Date) {
function Date() {
return _Date.apply(this, arguments);
}
Date.toString = function () {
return _Date.toString();
};
return Date;
}(function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return _construct(Date, _toConsumableArray(args));
})
}
};

@@ -347,6 +386,10 @@ var GLOBALS = Object.freeze({

};
var GLOBAL_FUNCTIONS = Object.freeze(Object.keys(SCOPE));
function getScopeFunction(key) {
if (SCOPE[key]) {
return SCOPE[key];
var GLOBAL_FUNCTIONS = Object.freeze([].concat(_toConsumableArray(Object.keys(SCOPE_ANY)), _toConsumableArray(Object.keys(SCOPE_NEW)), _toConsumableArray(Object.keys(SCOPE_CALL))));
function getScopeFunction(key, withNew) {
if (withNew && SCOPE_NEW[key]) {
return SCOPE_NEW[key];
} else if (!withNew && SCOPE_CALL[key]) {
return SCOPE_CALL[key];
} else if (SCOPE_ANY[key]) {
return SCOPE_ANY[key];
}

@@ -564,3 +607,3 @@

var memberExpression = function memberExpression(node) {
var memberExpression = function memberExpression(node, withNew) {
switch (node.callee.type) {

@@ -570,3 +613,3 @@ case 'Identifier':

// Handing <Constructor>() and new <Constructor>() cases
var callee = getScopeFunction(node.callee.name);
var callee = getScopeFunction(node.callee.name, withNew);
var args = node.arguments.map(function (arg) {

@@ -629,4 +672,6 @@ return walk(arg);

case 'CallExpression':
return memberExpression(node, false);
case 'NewExpression':
return memberExpression(node);
return memberExpression(node, true);

@@ -686,3 +731,3 @@ case 'ObjectExpression':

var ParseMode;
exports.ParseMode = void 0;

@@ -693,3 +738,3 @@ (function (ParseMode) {

ParseMode["Loose"] = "loose";
})(ParseMode || (ParseMode = {}));
})(exports.ParseMode || (exports.ParseMode = {}));

@@ -712,9 +757,9 @@ var StrictOptions = {

switch (mode) {
case ParseMode.Strict:
case exports.ParseMode.Strict:
return StrictOptions;
case ParseMode.Extended:
case exports.ParseMode.Extended:
return ExtendedOptions;
case ParseMode.Loose:
case exports.ParseMode.Loose:
return LooseOptions;

@@ -725,7 +770,7 @@ }

var DefaultOptions = _objectSpread2({
mode: ParseMode.Strict
mode: exports.ParseMode.Strict
}, StrictOptions);
function buildOptions(options) {
return _objectSpread2(_objectSpread2(_objectSpread2({}, DefaultOptions), getModeOptions(options && options.mode || ParseMode.Strict)), options);
return _objectSpread2(_objectSpread2(_objectSpread2({}, DefaultOptions), getModeOptions(options && options.mode || exports.ParseMode.Strict)), options);
}

@@ -749,7 +794,8 @@

}
function parse(input, options) {
var parsedOptions = buildOptions(options);
var _buildAST = buildAST("(".concat(input, ")")),
var _buildAST = buildAST( // Wrapping input into brackets with newlines so that parser can correctly
// process an expression and handle possible trailing comments
"(\n".concat(input, "\n)")),
hasComments = _buildAST.hasComments,

@@ -756,0 +802,0 @@ ast = _buildAST.ast;

@@ -45,7 +45,6 @@ import { parse as parse$1 } from 'acorn';

function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);

@@ -69,3 +68,3 @@ }

if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
_construct = Reflect.construct.bind();
} else {

@@ -126,3 +125,47 @@ _construct = function _construct(Parent, args, Class) {

var SCOPE = {
var SCOPE_CALL = {
Date: function (_Date) {
function Date() {
return _Date.apply(this, arguments);
}
Date.toString = function () {
return _Date.toString();
};
return Date;
}(function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return Date.apply(void 0, _toConsumableArray(args));
})
};
var SCOPE_NEW = {
Date: function (_Date2) {
function Date() {
return _Date2.apply(this, arguments);
}
Date.toString = function () {
return _Date2.toString();
};
return Date;
}(function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return _construct(Date, _toConsumableArray(args));
})
};
var SCOPE_ANY = {
RegExp: RegExp,

@@ -136,2 +179,6 @@ Binary: function Binary(buffer, subType) {

UUID: function UUID(u) {
if (u === undefined) {
return new bson.UUID().toBinary();
}
return new bson.Binary(Buffer.from(u.replace(/-/g, ''), 'hex'), 4);

@@ -165,5 +212,17 @@ },

Int64: NumberLong,
Map: function Map(arr) {
return new bson.Map(arr);
},
Map: function (_Map) {
function Map(_x) {
return _Map.apply(this, arguments);
}
Map.toString = function () {
return _Map.toString();
};
return Map;
}(function (arr) {
var _Map2;
return new ((_Map2 = bson.Map) !== null && _Map2 !== void 0 ? _Map2 : Map)(arr);
}),
MaxKey: function MaxKey() {

@@ -176,6 +235,6 @@ return new bson.MaxKey();

ObjectID: function ObjectID(i) {
return new bson.ObjectID(i);
return new bson.ObjectId(i);
},
ObjectId: function ObjectId(i) {
return new bson.ObjectID(i);
return new bson.ObjectId(i);
},

@@ -186,3 +245,3 @@ Symbol: function Symbol(i) {

Timestamp: function Timestamp(low, high) {
if (typeof low === 'number' && typeof high === 'number') {
if (typeof low === 'number' && typeof high === 'number' || high !== undefined) {
// https://www.mongodb.com/docs/manual/reference/bson-types/#timestamps

@@ -196,7 +255,7 @@ // reverse the order to match the legacy shell

return new bson.Timestamp(low, high);
return new bson.Timestamp(low);
},
ISODate: function ISODate() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}

@@ -208,23 +267,3 @@

return _construct(Date, _toConsumableArray(args));
},
Date: function (_Date) {
function Date() {
return _Date.apply(this, arguments);
}
Date.toString = function () {
return _Date.toString();
};
return Date;
}(function () {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
// casting our arguments as an empty array because we don't know
// the length of our arguments, and should allow users to pass what
// they want as date arguments
return _construct(Date, _toConsumableArray(args));
})
}
};

@@ -323,6 +362,10 @@ var GLOBALS = Object.freeze({

};
var GLOBAL_FUNCTIONS = Object.freeze(Object.keys(SCOPE));
function getScopeFunction(key) {
if (SCOPE[key]) {
return SCOPE[key];
var GLOBAL_FUNCTIONS = Object.freeze([].concat(_toConsumableArray(Object.keys(SCOPE_ANY)), _toConsumableArray(Object.keys(SCOPE_NEW)), _toConsumableArray(Object.keys(SCOPE_CALL))));
function getScopeFunction(key, withNew) {
if (withNew && SCOPE_NEW[key]) {
return SCOPE_NEW[key];
} else if (!withNew && SCOPE_CALL[key]) {
return SCOPE_CALL[key];
} else if (SCOPE_ANY[key]) {
return SCOPE_ANY[key];
}

@@ -540,3 +583,3 @@

var memberExpression = function memberExpression(node) {
var memberExpression = function memberExpression(node, withNew) {
switch (node.callee.type) {

@@ -546,3 +589,3 @@ case 'Identifier':

// Handing <Constructor>() and new <Constructor>() cases
var callee = getScopeFunction(node.callee.name);
var callee = getScopeFunction(node.callee.name, withNew);
var args = node.arguments.map(function (arg) {

@@ -605,4 +648,6 @@ return walk(arg);

case 'CallExpression':
return memberExpression(node, false);
case 'NewExpression':
return memberExpression(node);
return memberExpression(node, true);

@@ -721,7 +766,8 @@ case 'ObjectExpression':

}
function parse(input, options) {
var parsedOptions = buildOptions(options);
var _buildAST = buildAST("(".concat(input, ")")),
var _buildAST = buildAST( // Wrapping input into brackets with newlines so that parser can correctly
// process an expression and handle possible trailing comments
"(\n".concat(input, "\n)")),
hasComments = _buildAST.hasComments,

@@ -739,2 +785,2 @@ ast = _buildAST.ast;

export { parse as default };
export { ParseMode, parse as default };
{
"name": "ejson-shell-parser",
"version": "1.2.3",
"version": "1.2.4",
"main": "dist/ejson-shell-parser.cjs.js",

@@ -5,0 +5,0 @@ "module": "dist/ejson-shell-parser.esm.js",

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc