Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ejson

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ejson - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

403

bundle.js

@@ -1,101 +0,18 @@

var EJSON =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
var EJSON;EJSON =
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Base64, Meteor) {
/* provided dependency */ var Base64 = __webpack_require__(2)["Base64"];
/* provided dependency */ var Meteor = __webpack_require__(3);
Object.defineProperty(exports, "__esModule", {
Object.defineProperty(exports, "__esModule", ({
value: true
});
}));
exports.EJSON = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _utils = __webpack_require__(1);

@@ -154,15 +71,3 @@ /**

exports.EJSON = EJSON;
var customTypes = {};
var hasOwn = function hasOwn(obj, prop) {
return {}.hasOwnProperty.call(obj, prop);
};
var isArguments = function isArguments(obj) {
return obj != null && hasOwn(obj, 'callee');
};
var isInfOrNan = function isInfOrNan(obj) {
return Number.isNaN(obj) || obj === Infinity || obj === -Infinity;
}; // Add a custom type, using a method of your choice to get to and
var customTypes = new Map(); // Add a custom type, using a method of your choice to get to and
// from a basic JSON-able representation. The factory argument

@@ -192,9 +97,8 @@ // is a function of JSON-able --> your object

EJSON.addType = function (name, factory) {
if (hasOwn(customTypes, name)) {
if (customTypes.has(name)) {
throw new Error("Type ".concat(name, " already present"));
}
customTypes[name] = factory;
customTypes.set(name, factory);
};

@@ -205,3 +109,3 @@

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$date') && Object.keys(obj).length === 1;
return (0, _utils.hasOwn)(obj, '$date') && (0, _utils.lengthOf)(obj) === 1;
},

@@ -222,3 +126,3 @@ matchObject: function matchObject(obj) {

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$regexp') && hasOwn(obj, '$flags') && Object.keys(obj).length === 2;
return (0, _utils.hasOwn)(obj, '$regexp') && (0, _utils.hasOwn)(obj, '$flags') && (0, _utils.lengthOf)(obj) === 2;
},

@@ -243,5 +147,5 @@ matchObject: function matchObject(obj) {

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$InfNaN') && Object.keys(obj).length === 1;
return (0, _utils.hasOwn)(obj, '$InfNaN') && (0, _utils.lengthOf)(obj) === 1;
},
matchObject: isInfOrNan,
matchObject: _utils.isInfOrNaN,
toJSONValue: function toJSONValue(obj) {

@@ -268,6 +172,6 @@ var sign;

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$binary') && Object.keys(obj).length === 1;
return (0, _utils.hasOwn)(obj, '$binary') && (0, _utils.lengthOf)(obj) === 1;
},
matchObject: function matchObject(obj) {
return typeof Uint8Array !== 'undefined' && obj instanceof Uint8Array || obj && hasOwn(obj, '$Uint8ArrayPolyfill');
return typeof Uint8Array !== 'undefined' && obj instanceof Uint8Array || obj && (0, _utils.hasOwn)(obj, '$Uint8ArrayPolyfill');
},

@@ -285,3 +189,3 @@ toJSONValue: function toJSONValue(obj) {

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$escape') && Object.keys(obj).length === 1;
return (0, _utils.hasOwn)(obj, '$escape') && (0, _utils.lengthOf)(obj) === 1;
},

@@ -292,3 +196,3 @@ matchObject: function matchObject(obj) {

if (obj) {
var keyCount = Object.keys(obj).length;
var keyCount = (0, _utils.lengthOf)(obj);

@@ -306,3 +210,3 @@ if (keyCount === 1 || keyCount === 2) {

var newObj = {};
Object.keys(obj).forEach(function (key) {
(0, _utils.keysOf)(obj).forEach(function (key) {
newObj[key] = EJSON.toJSONValue(obj[key]);

@@ -316,3 +220,3 @@ });

var newObj = {};
Object.keys(obj.$escape).forEach(function (key) {
(0, _utils.keysOf)(obj.$escape).forEach(function (key) {
newObj[key] = EJSON.fromJSONValue(obj.$escape[key]);

@@ -325,3 +229,3 @@ });

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$type') && hasOwn(obj, '$value') && Object.keys(obj).length === 2;
return (0, _utils.hasOwn)(obj, '$type') && (0, _utils.hasOwn)(obj, '$value') && (0, _utils.lengthOf)(obj) === 2;
},

@@ -344,7 +248,7 @@ matchObject: function matchObject(obj) {

if (!hasOwn(customTypes, typeName)) {
if (!customTypes.has(typeName)) {
throw new Error("Custom EJSON type ".concat(typeName, " is not defined"));
}
var converter = customTypes[typeName];
var converter = customTypes.get(typeName);
return Meteor._noYieldsAllowed(function () {

@@ -357,7 +261,8 @@ return converter(obj.$value);

EJSON._isCustomType = function (obj) {
return obj && typeof obj.toJSONValue === 'function' && typeof obj.typeName === 'function' && hasOwn(customTypes, obj.typeName());
return obj && (0, _utils.isFunction)(obj.toJSONValue) && (0, _utils.isFunction)(obj.typeName) && customTypes.has(obj.typeName());
};
EJSON._getTypes = function () {
return customTypes;
var isOriginal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
return isOriginal ? customTypes : (0, _utils.convertMapToObject)(customTypes);
};

@@ -397,3 +302,3 @@

if (_typeof(obj) !== 'object') {
if (!(0, _utils.isObject)(obj)) {
return obj;

@@ -403,6 +308,6 @@ } // Iterate over array or object structure.

Object.keys(obj).forEach(function (key) {
(0, _utils.keysOf)(obj).forEach(function (key) {
var value = obj[key];
if (_typeof(value) !== 'object' && value !== undefined && !isInfOrNan(value)) {
if (!(0, _utils.isObject)(value) && value !== undefined && !(0, _utils.isInfOrNaN)(value)) {
return; // continue

@@ -442,3 +347,3 @@ }

if (_typeof(item) === 'object') {
if ((0, _utils.isObject)(item)) {
newItem = EJSON.clone(item);

@@ -456,4 +361,4 @@ adjustTypesToJSONValue(newItem);

var fromJSONValueHelper = function fromJSONValueHelper(value) {
if (_typeof(value) === 'object' && value !== null) {
var keys = Object.keys(value);
if ((0, _utils.isObject)(value) && value !== null) {
var keys = (0, _utils.keysOf)(value);

@@ -491,10 +396,10 @@ if (keys.length <= 2 && keys.every(function (k) {

if (_typeof(obj) !== 'object') {
if (!(0, _utils.isObject)(obj)) {
return obj;
}
Object.keys(obj).forEach(function (key) {
(0, _utils.keysOf)(obj).forEach(function (key) {
var value = obj[key];
if (_typeof(value) === 'object') {
if ((0, _utils.isObject)(value)) {
var changed = fromJSONValueHelper(value);

@@ -525,3 +430,3 @@

if (changed === item && _typeof(item) === 'object') {
if (changed === item && (0, _utils.isObject)(item)) {
changed = EJSON.clone(item);

@@ -549,3 +454,3 @@ adjustTypesFromJSONValue(changed);

EJSON.stringify = function (item, options) {
EJSON.stringify = (0, _utils.handleError)(function (item, options) {
var serialized;

@@ -555,3 +460,3 @@ var json = EJSON.toJSONValue(item);

if (options && (options.canonical || options.indent)) {
var canonicalStringify = __webpack_require__(3);
var canonicalStringify = __webpack_require__(4);

@@ -564,3 +469,3 @@ serialized = canonicalStringify(json, options);

return serialized;
};
});
/**

@@ -573,3 +478,2 @@ * @summary Parse a string into an EJSON value. Throws an error if the string

EJSON.parse = function (item) {

@@ -627,3 +531,3 @@ if (typeof item !== 'string') {

if (!(_typeof(a) === 'object' && _typeof(b) === 'object')) {
if (!((0, _utils.isObject)(a) && (0, _utils.isObject)(b))) {
return false;

@@ -650,7 +554,7 @@ }

if (typeof a.equals === 'function') {
if ((0, _utils.isFunction)(a.equals)) {
return a.equals(b, options);
}
if (typeof b.equals === 'function') {
if ((0, _utils.isFunction)(b.equals)) {
return b.equals(a, options);

@@ -691,4 +595,4 @@ }

var ret;
var aKeys = Object.keys(a);
var bKeys = Object.keys(b);
var aKeys = (0, _utils.keysOf)(a);
var bKeys = (0, _utils.keysOf)(b);

@@ -716,3 +620,3 @@ if (keyOrderSensitive) {

ret = aKeys.every(function (key) {
if (!hasOwn(b, key)) {
if (!(0, _utils.hasOwn)(b, key)) {
return false;

@@ -742,3 +646,3 @@ }

if (_typeof(v) !== 'object') {
if (!(0, _utils.isObject)(v)) {
return v;

@@ -772,15 +676,11 @@ }

if (Array.isArray(v)) {
return v.map(function (value) {
return EJSON.clone(value);
});
return v.map(EJSON.clone);
}
if (isArguments(v)) {
return Array.from(v).map(function (value) {
return EJSON.clone(value);
});
if ((0, _utils.isArguments)(v)) {
return Array.from(v).map(EJSON.clone);
} // handle general user-defined typed Objects if they have a clone method
if (typeof v.clone === 'function') {
if ((0, _utils.isFunction)(v.clone)) {
return v.clone();

@@ -796,3 +696,3 @@ } // handle other custom types

ret = {};
Object.keys(v).forEach(function (key) {
(0, _utils.keysOf)(v).forEach(function (key) {
ret[key] = EJSON.clone(v[key]);

@@ -815,14 +715,117 @@ });

EJSON.newBinary = Base64.newBinary;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)["Base64"], __webpack_require__(2)))
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
/***/ (function(__unused_webpack_module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
Object.defineProperty(exports, "__esModule", ({
value: true
});
}));
exports.handleError = exports.checkError = exports.isInfOrNaN = exports.isArguments = exports.convertMapToObject = exports.hasOwn = exports.lengthOf = exports.keysOf = exports.isObject = exports.isFunction = void 0;
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var isFunction = function isFunction(fn) {
return typeof fn === 'function';
};
exports.isFunction = isFunction;
var isObject = function isObject(fn) {
return _typeof(fn) === 'object';
};
exports.isObject = isObject;
var keysOf = function keysOf(obj) {
return Object.keys(obj);
};
exports.keysOf = keysOf;
var lengthOf = function lengthOf(obj) {
return Object.keys(obj).length;
};
exports.lengthOf = lengthOf;
var hasOwn = function hasOwn(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
};
exports.hasOwn = hasOwn;
var convertMapToObject = function convertMapToObject(map) {
return Array.from(map).reduce(function (acc, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
// reassign to not create new object
acc[key] = value;
return acc;
}, {});
};
exports.convertMapToObject = convertMapToObject;
var isArguments = function isArguments(obj) {
return obj != null && hasOwn(obj, 'callee');
};
exports.isArguments = isArguments;
var isInfOrNaN = function isInfOrNaN(obj) {
return Number.isNaN(obj) || obj === Infinity || obj === -Infinity;
};
exports.isInfOrNaN = isInfOrNaN;
var checkError = {
maxStack: function maxStack(msgError) {
return new RegExp('Maximum call stack size exceeded', 'g').test(msgError);
}
};
exports.checkError = checkError;
var handleError = function handleError(fn) {
return function () {
try {
return fn.apply(this, arguments);
} catch (error) {
var isMaxStack = checkError.maxStack(error.message);
if (isMaxStack) {
throw new Error('Converting circular structure to JSON');
}
throw error;
}
};
};
exports.handleError = handleError;
/***/ }),
/* 2 */
/***/ (function(__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.Base64 = void 0;

@@ -868,17 +871,18 @@ // Base 64 encoding

var d = null;
array.forEach(function (elm, i) {
switch (i % 3) {
for (var _i2 = 0; _i2 < array.length; _i2++) {
switch (_i2 % 3) {
case 0:
a = elm >> 2 & 0x3F;
b = (elm & 0x03) << 4;
a = array[_i2] >> 2 & 0x3F;
b = (array[_i2] & 0x03) << 4;
break;
case 1:
b = b | elm >> 4 & 0xF;
c = (elm & 0xF) << 2;
b = b | array[_i2] >> 4 & 0xF;
c = (array[_i2] & 0xF) << 2;
break;
case 2:
c = c | elm >> 6 & 0x03;
d = elm & 0x3F;
c = c | array[_i2] >> 6 & 0x03;
d = array[_i2] & 0x3F;
answer.push(getChar(a));

@@ -894,3 +898,3 @@ answer.push(getChar(b));

}
});
}

@@ -924,3 +928,3 @@ if (a != null) {

for (var _i2 = 0; _i2 < len; _i2++) {
for (var _i3 = 0; _i3 < len; _i3++) {
ret.push(0);

@@ -953,7 +957,7 @@ }

for (var _i3 = 0; _i3 < str.length; _i3++) {
var c = str.charAt(_i3);
for (var _i4 = 0; _i4 < str.length; _i4++) {
var c = str.charAt(_i4);
var v = getVal(c);
switch (_i3 % 4) {
switch (_i4 % 4) {
case 0:

@@ -1006,6 +1010,5 @@ if (v < 0) {

/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
/* 3 */
/***/ (function(module) {
"use strict";

@@ -1025,14 +1028,13 @@

/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
/* 4 */
/***/ (function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
Object.defineProperty(exports, "__esModule", ({
value: true
});
exports["default"] = void 0;
}));
exports.default = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -1162,6 +1164,37 @@ // Based on json2.js from https://github.com/douglascrockford/JSON-js

var _default = canonicalStringify;
exports["default"] = _default;
exports.default = _default;
module.exports = exports.default;
/***/ })
/******/ ])["EJSON"];
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })()
.EJSON;
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(Base64, Meteor) {
/* provided dependency */ var Base64 = __webpack_require__(2)["Base64"];
/* provided dependency */ var Meteor = __webpack_require__(3);
Object.defineProperty(exports, "__esModule", {
Object.defineProperty(exports, "__esModule", ({
value: true
});
}));
exports.EJSON = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _utils = __webpack_require__(1);

@@ -154,15 +71,3 @@ /**

exports.EJSON = EJSON;
var customTypes = {};
var hasOwn = function hasOwn(obj, prop) {
return {}.hasOwnProperty.call(obj, prop);
};
var isArguments = function isArguments(obj) {
return obj != null && hasOwn(obj, 'callee');
};
var isInfOrNan = function isInfOrNan(obj) {
return Number.isNaN(obj) || obj === Infinity || obj === -Infinity;
}; // Add a custom type, using a method of your choice to get to and
var customTypes = new Map(); // Add a custom type, using a method of your choice to get to and
// from a basic JSON-able representation. The factory argument

@@ -192,9 +97,8 @@ // is a function of JSON-able --> your object

EJSON.addType = function (name, factory) {
if (hasOwn(customTypes, name)) {
if (customTypes.has(name)) {
throw new Error("Type ".concat(name, " already present"));
}
customTypes[name] = factory;
customTypes.set(name, factory);
};

@@ -205,3 +109,3 @@

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$date') && Object.keys(obj).length === 1;
return (0, _utils.hasOwn)(obj, '$date') && (0, _utils.lengthOf)(obj) === 1;
},

@@ -222,3 +126,3 @@ matchObject: function matchObject(obj) {

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$regexp') && hasOwn(obj, '$flags') && Object.keys(obj).length === 2;
return (0, _utils.hasOwn)(obj, '$regexp') && (0, _utils.hasOwn)(obj, '$flags') && (0, _utils.lengthOf)(obj) === 2;
},

@@ -243,5 +147,5 @@ matchObject: function matchObject(obj) {

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$InfNaN') && Object.keys(obj).length === 1;
return (0, _utils.hasOwn)(obj, '$InfNaN') && (0, _utils.lengthOf)(obj) === 1;
},
matchObject: isInfOrNan,
matchObject: _utils.isInfOrNaN,
toJSONValue: function toJSONValue(obj) {

@@ -268,6 +172,6 @@ var sign;

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$binary') && Object.keys(obj).length === 1;
return (0, _utils.hasOwn)(obj, '$binary') && (0, _utils.lengthOf)(obj) === 1;
},
matchObject: function matchObject(obj) {
return typeof Uint8Array !== 'undefined' && obj instanceof Uint8Array || obj && hasOwn(obj, '$Uint8ArrayPolyfill');
return typeof Uint8Array !== 'undefined' && obj instanceof Uint8Array || obj && (0, _utils.hasOwn)(obj, '$Uint8ArrayPolyfill');
},

@@ -285,3 +189,3 @@ toJSONValue: function toJSONValue(obj) {

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$escape') && Object.keys(obj).length === 1;
return (0, _utils.hasOwn)(obj, '$escape') && (0, _utils.lengthOf)(obj) === 1;
},

@@ -292,3 +196,3 @@ matchObject: function matchObject(obj) {

if (obj) {
var keyCount = Object.keys(obj).length;
var keyCount = (0, _utils.lengthOf)(obj);

@@ -306,3 +210,3 @@ if (keyCount === 1 || keyCount === 2) {

var newObj = {};
Object.keys(obj).forEach(function (key) {
(0, _utils.keysOf)(obj).forEach(function (key) {
newObj[key] = EJSON.toJSONValue(obj[key]);

@@ -316,3 +220,3 @@ });

var newObj = {};
Object.keys(obj.$escape).forEach(function (key) {
(0, _utils.keysOf)(obj.$escape).forEach(function (key) {
newObj[key] = EJSON.fromJSONValue(obj.$escape[key]);

@@ -325,3 +229,3 @@ });

matchJSONValue: function matchJSONValue(obj) {
return hasOwn(obj, '$type') && hasOwn(obj, '$value') && Object.keys(obj).length === 2;
return (0, _utils.hasOwn)(obj, '$type') && (0, _utils.hasOwn)(obj, '$value') && (0, _utils.lengthOf)(obj) === 2;
},

@@ -344,7 +248,7 @@ matchObject: function matchObject(obj) {

if (!hasOwn(customTypes, typeName)) {
if (!customTypes.has(typeName)) {
throw new Error("Custom EJSON type ".concat(typeName, " is not defined"));
}
var converter = customTypes[typeName];
var converter = customTypes.get(typeName);
return Meteor._noYieldsAllowed(function () {

@@ -357,7 +261,8 @@ return converter(obj.$value);

EJSON._isCustomType = function (obj) {
return obj && typeof obj.toJSONValue === 'function' && typeof obj.typeName === 'function' && hasOwn(customTypes, obj.typeName());
return obj && (0, _utils.isFunction)(obj.toJSONValue) && (0, _utils.isFunction)(obj.typeName) && customTypes.has(obj.typeName());
};
EJSON._getTypes = function () {
return customTypes;
var isOriginal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
return isOriginal ? customTypes : (0, _utils.convertMapToObject)(customTypes);
};

@@ -397,3 +302,3 @@

if (_typeof(obj) !== 'object') {
if (!(0, _utils.isObject)(obj)) {
return obj;

@@ -403,6 +308,6 @@ } // Iterate over array or object structure.

Object.keys(obj).forEach(function (key) {
(0, _utils.keysOf)(obj).forEach(function (key) {
var value = obj[key];
if (_typeof(value) !== 'object' && value !== undefined && !isInfOrNan(value)) {
if (!(0, _utils.isObject)(value) && value !== undefined && !(0, _utils.isInfOrNaN)(value)) {
return; // continue

@@ -442,3 +347,3 @@ }

if (_typeof(item) === 'object') {
if ((0, _utils.isObject)(item)) {
newItem = EJSON.clone(item);

@@ -456,4 +361,4 @@ adjustTypesToJSONValue(newItem);

var fromJSONValueHelper = function fromJSONValueHelper(value) {
if (_typeof(value) === 'object' && value !== null) {
var keys = Object.keys(value);
if ((0, _utils.isObject)(value) && value !== null) {
var keys = (0, _utils.keysOf)(value);

@@ -491,10 +396,10 @@ if (keys.length <= 2 && keys.every(function (k) {

if (_typeof(obj) !== 'object') {
if (!(0, _utils.isObject)(obj)) {
return obj;
}
Object.keys(obj).forEach(function (key) {
(0, _utils.keysOf)(obj).forEach(function (key) {
var value = obj[key];
if (_typeof(value) === 'object') {
if ((0, _utils.isObject)(value)) {
var changed = fromJSONValueHelper(value);

@@ -525,3 +430,3 @@

if (changed === item && _typeof(item) === 'object') {
if (changed === item && (0, _utils.isObject)(item)) {
changed = EJSON.clone(item);

@@ -549,3 +454,3 @@ adjustTypesFromJSONValue(changed);

EJSON.stringify = function (item, options) {
EJSON.stringify = (0, _utils.handleError)(function (item, options) {
var serialized;

@@ -555,3 +460,3 @@ var json = EJSON.toJSONValue(item);

if (options && (options.canonical || options.indent)) {
var canonicalStringify = __webpack_require__(3);
var canonicalStringify = __webpack_require__(4);

@@ -564,3 +469,3 @@ serialized = canonicalStringify(json, options);

return serialized;
};
});
/**

@@ -573,3 +478,2 @@ * @summary Parse a string into an EJSON value. Throws an error if the string

EJSON.parse = function (item) {

@@ -627,3 +531,3 @@ if (typeof item !== 'string') {

if (!(_typeof(a) === 'object' && _typeof(b) === 'object')) {
if (!((0, _utils.isObject)(a) && (0, _utils.isObject)(b))) {
return false;

@@ -650,7 +554,7 @@ }

if (typeof a.equals === 'function') {
if ((0, _utils.isFunction)(a.equals)) {
return a.equals(b, options);
}
if (typeof b.equals === 'function') {
if ((0, _utils.isFunction)(b.equals)) {
return b.equals(a, options);

@@ -691,4 +595,4 @@ }

var ret;
var aKeys = Object.keys(a);
var bKeys = Object.keys(b);
var aKeys = (0, _utils.keysOf)(a);
var bKeys = (0, _utils.keysOf)(b);

@@ -716,3 +620,3 @@ if (keyOrderSensitive) {

ret = aKeys.every(function (key) {
if (!hasOwn(b, key)) {
if (!(0, _utils.hasOwn)(b, key)) {
return false;

@@ -742,3 +646,3 @@ }

if (_typeof(v) !== 'object') {
if (!(0, _utils.isObject)(v)) {
return v;

@@ -772,15 +676,11 @@ }

if (Array.isArray(v)) {
return v.map(function (value) {
return EJSON.clone(value);
});
return v.map(EJSON.clone);
}
if (isArguments(v)) {
return Array.from(v).map(function (value) {
return EJSON.clone(value);
});
if ((0, _utils.isArguments)(v)) {
return Array.from(v).map(EJSON.clone);
} // handle general user-defined typed Objects if they have a clone method
if (typeof v.clone === 'function') {
if ((0, _utils.isFunction)(v.clone)) {
return v.clone();

@@ -796,3 +696,3 @@ } // handle other custom types

ret = {};
Object.keys(v).forEach(function (key) {
(0, _utils.keysOf)(v).forEach(function (key) {
ret[key] = EJSON.clone(v[key]);

@@ -815,14 +715,117 @@ });

EJSON.newBinary = Base64.newBinary;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(1)["Base64"], __webpack_require__(2)))
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
/***/ (function(__unused_webpack_module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
Object.defineProperty(exports, "__esModule", ({
value: true
});
}));
exports.handleError = exports.checkError = exports.isInfOrNaN = exports.isArguments = exports.convertMapToObject = exports.hasOwn = exports.lengthOf = exports.keysOf = exports.isObject = exports.isFunction = void 0;
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var isFunction = function isFunction(fn) {
return typeof fn === 'function';
};
exports.isFunction = isFunction;
var isObject = function isObject(fn) {
return _typeof(fn) === 'object';
};
exports.isObject = isObject;
var keysOf = function keysOf(obj) {
return Object.keys(obj);
};
exports.keysOf = keysOf;
var lengthOf = function lengthOf(obj) {
return Object.keys(obj).length;
};
exports.lengthOf = lengthOf;
var hasOwn = function hasOwn(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
};
exports.hasOwn = hasOwn;
var convertMapToObject = function convertMapToObject(map) {
return Array.from(map).reduce(function (acc, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
// reassign to not create new object
acc[key] = value;
return acc;
}, {});
};
exports.convertMapToObject = convertMapToObject;
var isArguments = function isArguments(obj) {
return obj != null && hasOwn(obj, 'callee');
};
exports.isArguments = isArguments;
var isInfOrNaN = function isInfOrNaN(obj) {
return Number.isNaN(obj) || obj === Infinity || obj === -Infinity;
};
exports.isInfOrNaN = isInfOrNaN;
var checkError = {
maxStack: function maxStack(msgError) {
return new RegExp('Maximum call stack size exceeded', 'g').test(msgError);
}
};
exports.checkError = checkError;
var handleError = function handleError(fn) {
return function () {
try {
return fn.apply(this, arguments);
} catch (error) {
var isMaxStack = checkError.maxStack(error.message);
if (isMaxStack) {
throw new Error('Converting circular structure to JSON');
}
throw error;
}
};
};
exports.handleError = handleError;
/***/ }),
/* 2 */
/***/ (function(__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.Base64 = void 0;

@@ -868,17 +871,18 @@ // Base 64 encoding

var d = null;
array.forEach(function (elm, i) {
switch (i % 3) {
for (var _i2 = 0; _i2 < array.length; _i2++) {
switch (_i2 % 3) {
case 0:
a = elm >> 2 & 0x3F;
b = (elm & 0x03) << 4;
a = array[_i2] >> 2 & 0x3F;
b = (array[_i2] & 0x03) << 4;
break;
case 1:
b = b | elm >> 4 & 0xF;
c = (elm & 0xF) << 2;
b = b | array[_i2] >> 4 & 0xF;
c = (array[_i2] & 0xF) << 2;
break;
case 2:
c = c | elm >> 6 & 0x03;
d = elm & 0x3F;
c = c | array[_i2] >> 6 & 0x03;
d = array[_i2] & 0x3F;
answer.push(getChar(a));

@@ -894,3 +898,3 @@ answer.push(getChar(b));

}
});
}

@@ -924,3 +928,3 @@ if (a != null) {

for (var _i2 = 0; _i2 < len; _i2++) {
for (var _i3 = 0; _i3 < len; _i3++) {
ret.push(0);

@@ -953,7 +957,7 @@ }

for (var _i3 = 0; _i3 < str.length; _i3++) {
var c = str.charAt(_i3);
for (var _i4 = 0; _i4 < str.length; _i4++) {
var c = str.charAt(_i4);
var v = getVal(c);
switch (_i3 % 4) {
switch (_i4 % 4) {
case 0:

@@ -1006,6 +1010,5 @@ if (v < 0) {

/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
/* 3 */
/***/ (function(module) {
"use strict";

@@ -1025,14 +1028,13 @@

/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
/* 4 */
/***/ (function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
Object.defineProperty(exports, "__esModule", ({
value: true
});
exports["default"] = void 0;
}));
exports.default = void 0;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

@@ -1162,6 +1164,37 @@ // Based on json2.js from https://github.com/douglascrockford/JSON-js

var _default = canonicalStringify;
exports["default"] = _default;
exports.default = _default;
module.exports = exports.default;
/***/ })
/******/ ])["EJSON"];
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })()
.EJSON;
{
"name": "ejson",
"version": "2.2.0",
"version": "2.2.1",
"description": "EJSON - Extended and Extensible JSON library from Meteor made compatible for Nodejs and Browserify",

@@ -26,13 +26,13 @@ "main": "index.js",

"devDependencies": {
"@babel/core": "~7.4.3",
"@babel/preset-env": "~7.4.3",
"assume": "~2.2.0",
"babel-loader": "~8.0.5",
"@babel/core": "~7.12.10",
"@babel/preset-env": "~7.12.10",
"assume": "~2.3.0",
"babel-loader": "~8.2.0",
"babel-plugin-add-module-exports": "~1.0.2",
"babel-plugin-import-to-require": "~1.0.0",
"mocha": "~6.1.0",
"mocha": "~8.2.1",
"pre-commit": "~1.2.0",
"webpack": "~4.30.0",
"webpack-cli": "~3.3.0"
"webpack": "~5.10.2",
"webpack-cli": "~4.2.0"
}
}
# ejson
[![Version npm](https://img.shields.io/npm/v/ejson.svg?style=flat-square)](https://www.npmjs.com/package/ejson)[![Build Status](https://img.shields.io/travis/primus/ejson/master.svg?style=flat-square)](https://travis-ci.org/primus/ejson)[![Dependencies](https://img.shields.io/david/primus/ejson.svg?style=flat-square)](https://david-dm.org/primus/ejson)[![Coverage Status](https://img.shields.io/coveralls/primus/ejson/master.svg?style=flat-square)](https://coveralls.io/r/primus/ejson?branch=master)[![IRC channel](https://img.shields.io/badge/IRC-irc.freenode.net%23primus-00a8ff.svg?style=flat-square)](https://webchat.freenode.net/?channels=primus)
[![Version npm](https://img.shields.io/npm/v/ejson.svg?style=flat-square)](https://www.npmjs.com/package/ejson)[![Build Status](https://img.shields.io/github/workflow/status/primus/ejson/CI/master?label=CI&style=flat-square)](https://github.com/primus/ejson/actions?query=workflow%3ACI+branch%3Amaster)[![Dependencies](https://img.shields.io/david/primus/ejson.svg?style=flat-square)](https://david-dm.org/primus/ejson)[![Coverage Status](https://img.shields.io/coveralls/primus/ejson/master.svg?style=flat-square)](https://coveralls.io/r/primus/ejson?branch=master)[![IRC channel](https://img.shields.io/badge/IRC-irc.freenode.net%23primus-00a8ff.svg?style=flat-square)](https://webchat.freenode.net/?channels=primus)

@@ -5,0 +5,0 @@ `ejson` is an extension of JSON to support more types. It supports all JSON-safe

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