Comparing version 2.0.1 to 2.1.0
@@ -1,2 +0,2 @@ | ||
const repeats = [1000, 5000, 10000, 50000, 100000, 500000]; | ||
const repeats = [1000, 5000, 10000, 50000, 100000, 500000/*, 1000000, 5000000*/]; | ||
@@ -3,0 +3,0 @@ exports.test = (name, benchmark) => { |
# hashIt CHANGELOG | ||
#### 2.1.0 | ||
* Overall speed improvement by an average of 18.74% (35.27% improvement on complex objects) | ||
#### 2.0.1 | ||
@@ -4,0 +7,0 @@ * More speed improvements |
@@ -109,3 +109,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
while (++index < length) { | ||
if (hashIt(arguments.length <= index - 1 + 0 ? undefined : arguments[index - 1 + 0]) !== hashIt(arguments.length <= index + 0 ? undefined : arguments[index + 0])) { | ||
if (hashIt(arguments.length <= index - 1 ? undefined : arguments[index - 1]) !== hashIt(arguments.length <= index ? undefined : arguments[index])) { | ||
return false; | ||
@@ -175,8 +175,13 @@ } | ||
}); | ||
exports.replacer = exports.getStringifiedValueWithRecursion = exports.getStringifiedValue = exports.getIntegerHashValue = undefined; | ||
exports.getStringifiedValueWithRecursion = exports.getStringifiedValue = exports.tryCatch = exports.stringify = exports.getIntegerHashValue = exports.REPLACER = exports.getRecursiveStackValue = exports.getValueForStringification = exports.getStringifiedValueByObjectClass = exports.prependTypeToString = exports.getIterablePairs = exports.getObjectType = exports.arrayBufferToString = undefined; | ||
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 _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; }; // external dependencies | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
// constants | ||
// toString | ||
var _prune = __webpack_require__(3); | ||
@@ -186,2 +191,4 @@ | ||
var _constants = __webpack_require__(5); | ||
var _toString = __webpack_require__(4); | ||
@@ -191,9 +198,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var HTML_ELEMENT_REGEXP = /\[object (HTML(.*)Element)\]/; | ||
var MATH_OBJECT = ['E', 'LN2', 'LN10', 'LOG2E', 'LOG10E', 'PI', 'SQRT1_2', 'SQRT2'].reduce(function (mathObject, property) { | ||
return _extends({}, mathObject, _defineProperty({}, property, Math[property])); | ||
}, {}); | ||
/** | ||
@@ -205,4 +205,4 @@ * get the string value of the buffer passed | ||
*/ | ||
var arrayBufferToString = function arrayBufferToString(buffer) { | ||
if (typeof Uint16Array === 'undefined') { | ||
var arrayBufferToString = exports.arrayBufferToString = function arrayBufferToString(buffer) { | ||
if ((typeof Uint16Array === 'undefined' ? 'undefined' : _typeof(Uint16Array)) === _constants.UNDEFINED_TYPEOF) { | ||
return ''; | ||
@@ -221,4 +221,4 @@ } | ||
*/ | ||
var getObjectType = function getObjectType(type) { | ||
return type.substring(8, type.length - 1); | ||
var getObjectType = exports.getObjectType = function getObjectType(type) { | ||
return type.slice(8, -1); | ||
}; | ||
@@ -233,3 +233,3 @@ | ||
*/ | ||
var getIterablePairs = function getIterablePairs(iterable, type) { | ||
var getIterablePairs = exports.getIterablePairs = function getIterablePairs(iterable, type) { | ||
var pairs = [getObjectType(type)]; | ||
@@ -251,55 +251,46 @@ | ||
*/ | ||
var prependTypeToString = function prependTypeToString(string, type) { | ||
var prependTypeToString = exports.prependTypeToString = function prependTypeToString(string, type) { | ||
return getObjectType(type) + ' ' + string; | ||
}; | ||
var getStringifiedValueByObjectClass = function getStringifiedValueByObjectClass(object) { | ||
var getStringifiedValueByObjectClass = exports.getStringifiedValueByObjectClass = function getStringifiedValueByObjectClass(object) { | ||
var type = (0, _toString.toString)(object); | ||
switch (type) { | ||
case _toString.ARRAY: | ||
case _toString.OBJECT: | ||
case _toString.ARGUMENTS: | ||
return object; | ||
if (type === _constants.ARRAY || type === _constants.OBJECT || type === _constants.ARGUMENTS) { | ||
return object; | ||
} | ||
case _toString.ERROR: | ||
case _toString.NULL: | ||
case _toString.REGEXP: | ||
return prependTypeToString(object, type); | ||
if (type === _constants.ERROR || type === _constants.REGEXP || object === null) { | ||
return prependTypeToString(object, type); | ||
} | ||
case _toString.DATE: | ||
return prependTypeToString(object.valueOf(), type); | ||
if (type === _constants.DATE) { | ||
return prependTypeToString(object.valueOf(), type); | ||
} | ||
case _toString.PROMISE: | ||
case _toString.WEAKMAP: | ||
case _toString.WEAKSET: | ||
return prependTypeToString('NOT_ENUMERABLE', type); | ||
if (type === _constants.MAP || type === _constants.SET) { | ||
return getIterablePairs(object, type); | ||
} | ||
case _toString.MAP: | ||
case _toString.SET: | ||
return getIterablePairs(object, type); | ||
if (type === _constants.PROMISE || type === _constants.WEAKMAP || type === _constants.WEAKSET) { | ||
return prependTypeToString('NOT_ENUMERABLE', type); | ||
} | ||
case _toString.ARRAY_BUFFER: | ||
return prependTypeToString(arrayBufferToString(object), type); | ||
if (type === _constants.ARRAY_BUFFER) { | ||
return prependTypeToString(arrayBufferToString(object), type); | ||
} | ||
case _toString.DATA_VIEW: | ||
return prependTypeToString(arrayBufferToString(object.buffer), type); | ||
if (type === _constants.DATA_VIEW) { | ||
return prependTypeToString(arrayBufferToString(object.buffer), type); | ||
} | ||
case _toString.FLOAT_32_ARRAY: | ||
case _toString.FLOAT_64_ARRAY: | ||
case _toString.INT_8_ARRAY: | ||
case _toString.INT_16_ARRAY: | ||
case _toString.INT_32_ARRAY: | ||
case _toString.UINT_8_ARRAY: | ||
case _toString.UINT_8_CLAMPED_ARRAY: | ||
case _toString.UINT_16_ARRAY: | ||
case _toString.UINT_32_ARRAY: | ||
return prependTypeToString(object.join(','), type); | ||
if (type === _constants.FLOAT_32_ARRAY || type === _constants.FLOAT_64_ARRAY || type === _constants.INT_8_ARRAY || type === _constants.INT_16_ARRAY || type === _constants.INT_32_ARRAY || type === _constants.UINT_8_ARRAY || type === _constants.UINT_8_CLAMPED_ARRAY || type === _constants.UINT_16_ARRAY || type === _constants.UINT_32_ARRAY) { | ||
return prependTypeToString(object.join(','), type); | ||
} | ||
case _toString.MATH: | ||
return MATH_OBJECT; | ||
if (type === _constants.MATH) { | ||
return _constants.MATH_OBJECT; | ||
} | ||
default: | ||
return HTML_ELEMENT_REGEXP.test(type) ? 'HTMLElement ' + object.textContent : object; | ||
} | ||
return _constants.HTML_ELEMENT_REGEXP.test(type) ? 'HTMLElement ' + object.textContent : object; | ||
}; | ||
@@ -317,21 +308,22 @@ | ||
*/ | ||
var getValueForStringification = function getValueForStringification(object) { | ||
switch (typeof object === 'undefined' ? 'undefined' : _typeof(object)) { | ||
case _toString.STRING_TYPEOF: | ||
case _toString.NUMBER_TYPEOF: | ||
return object; | ||
var getValueForStringification = exports.getValueForStringification = function getValueForStringification(object) { | ||
var type = typeof object === 'undefined' ? 'undefined' : _typeof(object); | ||
case _toString.BOOLEAN_TYPEOF: | ||
case _toString.UNDEFINED_TYPEOF: | ||
return prependTypeToString(object, (0, _toString.toString)(object)); | ||
if (type === _constants.STRING_TYPEOF || type === _constants.NUMBER_TYPEOF) { | ||
return object; | ||
} | ||
case _toString.FUNCTION_TYPEOF: | ||
return (0, _toString.toFunctionString)(object, (0, _toString.toString)(object) === _toString.GENERATOR); | ||
if (type === _constants.BOOLEAN_TYPEOF || type === _constants.UNDEFINED_TYPEOF) { | ||
return prependTypeToString(object, (0, _toString.toString)(object)); | ||
} | ||
case _toString.SYMBOL_TYPEOF: | ||
return object.toString(); | ||
if (type === _constants.FUNCTION_TYPEOF) { | ||
return (0, _toString.toFunctionString)(object, (0, _toString.toString)(object) === _constants.GENERATOR); | ||
} | ||
default: | ||
return getStringifiedValueByObjectClass(object); | ||
if (type === _constants.SYMBOL_TYPEOF) { | ||
return object.toString(); | ||
} | ||
return getStringifiedValueByObjectClass(object); | ||
}; | ||
@@ -350,3 +342,3 @@ | ||
*/ | ||
var getRecursiveStackValue = function getRecursiveStackValue(value, type, stack, index, recursiveCounter) { | ||
var getRecursiveStackValue = exports.getRecursiveStackValue = function getRecursiveStackValue(value, type, stack, index, recursiveCounter) { | ||
if (!value) { | ||
@@ -375,3 +367,8 @@ return prependTypeToString(value, type); | ||
*/ | ||
var REPLACER = function (stack, undefined, recursiveCounter, index) { | ||
var REPLACER = exports.REPLACER = function () { | ||
var stack = void 0, | ||
recursiveCounter = void 0, | ||
index = void 0, | ||
type = void 0; | ||
return function (key, value) { | ||
@@ -385,56 +382,31 @@ if (!key) { | ||
var type = (0, _toString.toString)(value); | ||
type = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) { | ||
case _toString.STRING_TYPEOF: | ||
case _toString.NUMBER_TYPEOF: | ||
case _toString.BOOLEAN_TYPEOF: | ||
return value; | ||
if (type === _constants.STRING_TYPEOF || type === _constants.NUMBER_TYPEOF || type === _constants.BOOLEAN_TYPEOF) { | ||
return value; | ||
} | ||
case _toString.UNDEFINED_TYPEOF: | ||
case _toString.FUNCTION_TYPEOF: | ||
return getValueForStringification(value); | ||
if (type === _constants.UNDEFINED_TYPEOF || type === _constants.FUNCTION_TYPEOF) { | ||
return getValueForStringification(value); | ||
} | ||
case _toString.SYMBOL_TYPEOF: | ||
return value.toString(); | ||
if (type === _constants.SYMBOL_TYPEOF) { | ||
return value.toString(); | ||
} | ||
default: | ||
switch (type) { | ||
case _toString.ARRAY: | ||
case _toString.OBJECT: | ||
return getRecursiveStackValue(value, type, stack, index, ++recursiveCounter); | ||
type = (0, _toString.toString)(value); | ||
case _toString.ARGUMENTS: | ||
return value; | ||
if (type === _constants.ARRAY || type === _constants.OBJECT) { | ||
return getRecursiveStackValue(value, type, stack, index, ++recursiveCounter); | ||
} | ||
case _toString.DATE: | ||
case _toString.FUNCTION: | ||
case _toString.MAP: | ||
case _toString.SET: | ||
case _toString.PROMISE: | ||
case _toString.REGEXP: | ||
case _toString.NULL: | ||
case _toString.ARRAY_BUFFER: | ||
case _toString.DATA_VIEW: | ||
case _toString.FLOAT_32_ARRAY: | ||
case _toString.FLOAT_64_ARRAY: | ||
case _toString.GENERATOR: | ||
case _toString.INT_8_ARRAY: | ||
case _toString.INT_16_ARRAY: | ||
case _toString.INT_32_ARRAY: | ||
case _toString.ERROR: | ||
case _toString.MATH: | ||
case _toString.UINT_8_ARRAY: | ||
case _toString.UINT_8_CLAMPED_ARRAY: | ||
case _toString.UINT_16_ARRAY: | ||
case _toString.UINT_32_ARRAY: | ||
case _toString.UNDEFINED: | ||
case _toString.WEAKMAP: | ||
case _toString.WEAKSET: | ||
return getValueForStringification(value); | ||
if (type === _constants.ARGUMENTS) { | ||
return value; | ||
} | ||
default: | ||
return value; | ||
} | ||
if (type === _constants.DATE || type === _constants.MAP || type === _constants.SET || type === _constants.PROMISE || type === _constants.REGEXP || value === null || type === _constants.ERROR || type === _constants.GENERATOR || type === _constants.WEAKMAP || type === _constants.WEAKSET || type === _constants.MATH || type === _constants.ARRAY_BUFFER || type === _constants.DATA_VIEW || type === _constants.FLOAT_32_ARRAY || type === _constants.FLOAT_64_ARRAY || type === _constants.INT_8_ARRAY || type === _constants.INT_16_ARRAY || type === _constants.INT_32_ARRAY || type === _constants.UINT_8_ARRAY || type === _constants.UINT_8_CLAMPED_ARRAY || type === _constants.UINT_16_ARRAY || type === _constants.UINT_32_ARRAY) { | ||
return getValueForStringification(value); | ||
} | ||
return value; | ||
}; | ||
@@ -450,3 +422,3 @@ }(); | ||
*/ | ||
var getIntegerHashValue = function getIntegerHashValue(string) { | ||
var getIntegerHashValue = exports.getIntegerHashValue = function getIntegerHashValue(string) { | ||
if (!string) { | ||
@@ -474,3 +446,3 @@ return 0; | ||
*/ | ||
var stringify = function stringify(value) { | ||
var stringify = exports.stringify = function stringify(value) { | ||
return JSON.stringify(value, REPLACER); | ||
@@ -480,12 +452,2 @@ }; | ||
/** | ||
* perform json.prune on the value | ||
* | ||
* @param {*} value | ||
* @returns {string} | ||
*/ | ||
var prune = function prune(value) { | ||
return _prune2.default.prune(value); | ||
}; | ||
/** | ||
* move try/catch to standalone function as any function that contains a try/catch | ||
@@ -497,7 +459,7 @@ * is not optimized (this allows optimization for as much as possible) | ||
*/ | ||
var tryCatch = function tryCatch(value) { | ||
var tryCatch = exports.tryCatch = function tryCatch(value) { | ||
try { | ||
return stringify(value, REPLACER); | ||
return stringify(value); | ||
} catch (exception) { | ||
return prune(value); | ||
return _prune2.default.prune(value); | ||
} | ||
@@ -513,6 +475,6 @@ }; | ||
*/ | ||
var getStringifiedValue = function getStringifiedValue(object) { | ||
var getStringifiedValue = exports.getStringifiedValue = function getStringifiedValue(object) { | ||
var valueForStringification = getValueForStringification(object); | ||
if (typeof valueForStringification === 'string') { | ||
if ((typeof valueForStringification === 'undefined' ? 'undefined' : _typeof(valueForStringification)) === _constants.STRING_TYPEOF) { | ||
return valueForStringification; | ||
@@ -531,6 +493,6 @@ } | ||
*/ | ||
var getStringifiedValueWithRecursion = function getStringifiedValueWithRecursion(object) { | ||
var getStringifiedValueWithRecursion = exports.getStringifiedValueWithRecursion = function getStringifiedValueWithRecursion(object) { | ||
var valueForStringification = getValueForStringification(object); | ||
if (typeof valueForStringification === 'string') { | ||
if ((typeof valueForStringification === 'undefined' ? 'undefined' : _typeof(valueForStringification)) === _constants.STRING_TYPEOF) { | ||
return valueForStringification; | ||
@@ -541,7 +503,2 @@ } | ||
}; | ||
exports.getIntegerHashValue = getIntegerHashValue; | ||
exports.getStringifiedValue = getStringifiedValue; | ||
exports.getStringifiedValueWithRecursion = getStringifiedValueWithRecursion; | ||
exports.replacer = REPLACER; | ||
@@ -560,4 +517,9 @@ /***/ }, | ||
// constants | ||
var _toString = __webpack_require__(4); | ||
var _constants = __webpack_require__(5); | ||
/* | ||
@@ -569,16 +531,2 @@ This is a heavily modified and reduced version of JSON.prune provided by Canop | ||
var DEFAULT_MAX_DEPTH = 6; | ||
var DEFAULT_ARRAY_MAX_LENGTH = 50; | ||
var DEFAULT_PRUNED_VALUE = '*Recursive'; | ||
var ESCAPABLE = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
var META = { // table of character substitutions | ||
'\b': '\\b', | ||
'\t': '\\t', | ||
'\n': '\\n', | ||
'\f': '\\f', | ||
'\r': '\\r', | ||
'"': '\\"', | ||
'\\': '\\\\' | ||
}; | ||
var seen = void 0; | ||
@@ -607,8 +555,8 @@ | ||
var quote = function quote(string) { | ||
ESCAPABLE.lastIndex = 0; | ||
_constants.ESCAPABLE.lastIndex = 0; | ||
var c = void 0; | ||
return !ESCAPABLE.test(string) ? '"' + string + '"' : '"' + string.replace(ESCAPABLE, function (a) { | ||
c = META[a]; | ||
return !_constants.ESCAPABLE.test(string) ? '"' + string + '"' : '"' + string.replace(_constants.ESCAPABLE, function (a) { | ||
c = _constants.META[a]; | ||
@@ -630,66 +578,65 @@ return (0, _toString.toString)(c) === _toString.STRING ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); | ||
var value = holder[key], | ||
type = typeof value === 'undefined' ? 'undefined' : _typeof(value), | ||
partial = [], | ||
v = void 0; | ||
switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) { | ||
case 'string': | ||
return quote(value); | ||
if (type === _constants.STRING_TYPEOF) { | ||
return quote(value); | ||
} | ||
case 'boolean': | ||
case 'null': | ||
case 'number': | ||
case 'undefined': | ||
return '' + value; | ||
if (type === _constants.BOOLEAN_TYPEOF || type === _constants.NUMBER_TYPEOF || type === _constants.UNDEFINED_TYPEOF) { | ||
return '' + value; | ||
} | ||
case 'function': | ||
return (0, _toString.toFunctionString)(value); | ||
if (type === _constants.FUNCTION_TYPEOF) { | ||
return (0, _toString.toFunctionString)(value); | ||
} | ||
case 'object': | ||
if (!value) { | ||
return '' + value; | ||
} | ||
if (!value) { | ||
return '' + value; | ||
} | ||
var index = seen.indexOf(value); | ||
var index = seen.indexOf(value); | ||
if (depthDecr <= 0 || !!~index) { | ||
return DEFAULT_PRUNED_VALUE + '-' + index; | ||
} | ||
if (depthDecr <= 0 || !!~index) { | ||
return _constants.DEFAULT_PRUNED_VALUE + '-' + index; | ||
} | ||
switch ((0, _toString.toString)(value)) { | ||
case _toString.ARRAY: | ||
seen.push(value); | ||
type = (0, _toString.toString)(value); | ||
var length = Math.min(value.length, DEFAULT_ARRAY_MAX_LENGTH); | ||
if (type === _toString.ARRAY) { | ||
seen.push(value); | ||
var _index = -1; | ||
var length = Math.min(value.length, _constants.DEFAULT_ARRAY_MAX_LENGTH); | ||
while (++_index < length) { | ||
partial[_index] = pruneString(_index, value, depthDecr - 1); | ||
} | ||
var _index = -1; | ||
v = '[' + partial.join(',') + ']'; | ||
while (++_index < length) { | ||
partial[_index] = pruneString(_index, value, depthDecr - 1); | ||
} | ||
return v; | ||
v = '[' + partial.join(',') + ']'; | ||
case _toString.DATE: | ||
return '' + value.valueOf(); | ||
return v; | ||
} | ||
default: | ||
seen.push(value); | ||
if (type === _toString.DATE) { | ||
return '' + value.valueOf(); | ||
} | ||
forEachEnumerableOwnProperty(value, function (k) { | ||
try { | ||
v = pruneString(k, value, depthDecr - 1); | ||
seen.push(value); | ||
if (v) { | ||
partial.push(quote(k) + ':' + v); | ||
} | ||
} catch (exception) { | ||
// this try/catch due to forbidden accessors on some objects | ||
} | ||
}); | ||
forEachEnumerableOwnProperty(value, function (k) { | ||
try { | ||
v = pruneString(k, value, depthDecr - 1); | ||
return '{' + partial.join(',') + '}'; | ||
if (v) { | ||
partial.push(quote(k) + ':' + v); | ||
} | ||
} | ||
} catch (exception) { | ||
// this try/catch due to forbidden accessors on some objects | ||
} | ||
}); | ||
return '{' + partial.join(',') + '}'; | ||
}; | ||
@@ -699,3 +646,3 @@ | ||
'': value | ||
}, DEFAULT_MAX_DEPTH); | ||
}, _constants.DEFAULT_MAX_DEPTH); | ||
}; | ||
@@ -717,6 +664,61 @@ | ||
}); | ||
var objectToString = Object.prototype.toString; | ||
/** | ||
* create the fake function args array for the stringified function | ||
* | ||
* @param {number} length | ||
* @returns {string} | ||
*/ | ||
var getFunctionArgs = exports.getFunctionArgs = function getFunctionArgs(length) { | ||
var string = '', | ||
index = -1; | ||
while (++index < length) { | ||
string += 'arg,'; | ||
} | ||
return string.slice(0, -1); | ||
}; | ||
/** | ||
* get the generic string value of the function passed | ||
* | ||
* @param {function} fn | ||
* @param {boolean} isGenerator=false | ||
* @returns {string} | ||
*/ | ||
var toFunctionString = exports.toFunctionString = function toFunctionString(fn) { | ||
var isGenerator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
return 'function' + (isGenerator ? '*' : '') + ' ' + (fn.name || 'anonymous') + '(' + getFunctionArgs(fn.length) + '){}'; | ||
}; | ||
/** | ||
* get the toString value of object | ||
* | ||
* @param {*} object | ||
* @returns {string} | ||
*/ | ||
var toString = exports.toString = function toString(object) { | ||
return objectToString.call(object); | ||
}; | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var ARGUMENTS = exports.ARGUMENTS = '[object Arguments]'; | ||
var ARRAY = exports.ARRAY = '[object Array]'; | ||
var ARRAY_BUFFER = exports.ARRAY_BUFFER = '[object ArrayBuffer]'; | ||
var BOOLEAN = exports.BOOLEAN = '[object Boolean]'; | ||
var DATA_VIEW = exports.DATA_VIEW = '[object DataView]'; | ||
@@ -727,3 +729,2 @@ var DATE = exports.DATE = '[object Date]'; | ||
var FLOAT_64_ARRAY = exports.FLOAT_64_ARRAY = '[object Float64Array]'; | ||
var FUNCTION = exports.FUNCTION = '[object Function]'; | ||
var GENERATOR = exports.GENERATOR = '[object GeneratorFunction]'; | ||
@@ -735,4 +736,2 @@ var INT_8_ARRAY = exports.INT_8_ARRAY = '[object Int8Array]'; | ||
var MATH = exports.MATH = '[object Math]'; | ||
var NULL = exports.NULL = '[object Null]'; | ||
var NUMBER = exports.NUMBER = '[object Number]'; | ||
var OBJECT = exports.OBJECT = '[object Object]'; | ||
@@ -747,3 +746,2 @@ var PROMISE = exports.PROMISE = '[object Promise]'; | ||
var UINT_32_ARRAY = exports.UINT_32_ARRAY = '[object Uint32Array]'; | ||
var UNDEFINED = exports.UNDEFINED = '[object Undefined]'; | ||
var WEAKMAP = exports.WEAKMAP = '[object WeakMap]'; | ||
@@ -759,26 +757,20 @@ var WEAKSET = exports.WEAKSET = '[object WeakSet]'; | ||
var objectToString = Object.prototype.toString; | ||
/** | ||
* get the generic string value of the function passed | ||
* | ||
* @param {function} fn | ||
* @param {boolean} isGenerator=false | ||
* @returns {string} | ||
*/ | ||
var toFunctionString = exports.toFunctionString = function toFunctionString(fn) { | ||
var isGenerator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
return 'function' + (isGenerator ? '*' : '') + ' ' + (fn.name || 'anonymous') + '(' + new Array(fn.length + 1).join(',arg').slice(1) + '){}'; | ||
var DEFAULT_MAX_DEPTH = exports.DEFAULT_MAX_DEPTH = 6; | ||
var DEFAULT_ARRAY_MAX_LENGTH = exports.DEFAULT_ARRAY_MAX_LENGTH = 50; | ||
var DEFAULT_PRUNED_VALUE = exports.DEFAULT_PRUNED_VALUE = '*Recursive'; | ||
var ESCAPABLE = exports.ESCAPABLE = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
var META = exports.META = { // table of character substitutions | ||
'\b': '\\b', | ||
'\t': '\\t', | ||
'\n': '\\n', | ||
'\f': '\\f', | ||
'\r': '\\r', | ||
'"': '\\"', | ||
'\\': '\\\\' | ||
}; | ||
/** | ||
* get the toString value of object | ||
* | ||
* @param {*} object | ||
* @returns {string} | ||
*/ | ||
var toString = exports.toString = function toString(object) { | ||
return objectToString.call(object); | ||
}; | ||
var HTML_ELEMENT_REGEXP = exports.HTML_ELEMENT_REGEXP = /\[object (HTML(.*)Element)\]/; | ||
var MATH_OBJECT = exports.MATH_OBJECT = ['E', 'LN2', 'LN10', 'LOG2E', 'LOG10E', 'PI', 'SQRT1_2', 'SQRT2'].reduce(function (mathObject, property) { | ||
return _extends({}, mathObject, _defineProperty({}, property, Math[property])); | ||
}, {}); | ||
@@ -785,0 +777,0 @@ /***/ } |
@@ -1,1 +0,1 @@ | ||
!(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("hashIt",[],t):"object"==typeof exports?exports.hashIt=t():e.hashIt=t()})(this,(function(){return (function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)})([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),o=function(e){var t=(0,r.getStringifiedValue)(e);return(0,r.getIntegerHashValue)(t)},u=o(void 0),c=o(null),a=o([]),i=o(new Map),s=o(0),f=o({}),A=o(new Set),R=o("");o.isEqual=function(){var e=arguments.length;if(1===e)throw new Error("isEqual requires at least two objects to be passed for comparison.");for(var t=0;++t<e;)if(o(arguments.length<=t-1+0?void 0:arguments[t-1+0])!==o(arguments.length<=t+0?void 0:arguments[t+0]))return!1;return!0},o.isEmpty=function(e){var t=o(e);return t===u||t===c||t===a||t===i||t===s||t===f||t===A||t===R},o.isNull=function(e){return o(e)===c},o.isUndefined=function(e){return o(e)===u},o.withRecursion=function(e){var t=(0,r.getStringifiedValueWithRecursion)(e);return(0,r.getIntegerHashValue)(t)},t.default=o,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(t,"__esModule",{value:!0}),t.replacer=t.getStringifiedValueWithRecursion=t.getStringifiedValue=t.getIntegerHashValue=void 0;var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=n(3),i=r(a),s=n(4),f=/\[object (HTML(.*)Element)\]/,A=["E","LN2","LN10","LOG2E","LOG10E","PI","SQRT1_2","SQRT2"].reduce((function(e,t){return c({},e,o({},t,Math[t]))}),{}),R=function(e){return"undefined"==typeof Uint16Array?"":String.fromCharCode.apply(null,new Uint16Array(e))},l=function(e){return e.substring(8,e.length-1)},E=function(e,t){var n=[l(t)];return e.forEach((function(e,t){n.push([t,e])})),n},_=function(e,t){return l(t)+" "+e},T=function(e){var t=(0,s.toString)(e);switch(t){case s.ARRAY:case s.OBJECT:case s.ARGUMENTS:return e;case s.ERROR:case s.NULL:case s.REGEXP:return _(e,t);case s.DATE:return _(e.valueOf(),t);case s.PROMISE:case s.WEAKMAP:case s.WEAKSET:return _("NOT_ENUMERABLE",t);case s.MAP:case s.SET:return E(e,t);case s.ARRAY_BUFFER:return _(R(e),t);case s.DATA_VIEW:return _(R(e.buffer),t);case s.FLOAT_32_ARRAY:case s.FLOAT_64_ARRAY:case s.INT_8_ARRAY:case s.INT_16_ARRAY:case s.INT_32_ARRAY:case s.UINT_8_ARRAY:case s.UINT_8_CLAMPED_ARRAY:case s.UINT_16_ARRAY:case s.UINT_32_ARRAY:return _(e.join(","),t);case s.MATH:return A;default:return f.test(t)?"HTMLElement "+e.textContent:e}},d=function(e){switch("undefined"==typeof e?"undefined":u(e)){case s.STRING_TYPEOF:case s.NUMBER_TYPEOF:return e;case s.BOOLEAN_TYPEOF:case s.UNDEFINED_TYPEOF:return _(e,(0,s.toString)(e));case s.FUNCTION_TYPEOF:return(0,s.toFunctionString)(e,(0,s.toString)(e)===s.GENERATOR);case s.SYMBOL_TYPEOF:return e.toString();default:return T(e)}},b=function(e,t,n,r,o){return e?o>255?"Undefined undefined":(r=n.indexOf(e),~r?"*Recursive-"+r:(n.push(e),e)):_(e,t)},O=(function(e,t,n,r){return function(t,o){if(!t)return e=[o],n=0,o;var c=(0,s.toString)(o);switch("undefined"==typeof o?"undefined":u(o)){case s.STRING_TYPEOF:case s.NUMBER_TYPEOF:case s.BOOLEAN_TYPEOF:return o;case s.UNDEFINED_TYPEOF:case s.FUNCTION_TYPEOF:return d(o);case s.SYMBOL_TYPEOF:return o.toString();default:switch(c){case s.ARRAY:case s.OBJECT:return b(o,c,e,r,++n);case s.ARGUMENTS:return o;case s.DATE:case s.FUNCTION:case s.MAP:case s.SET:case s.PROMISE:case s.REGEXP:case s.NULL:case s.ARRAY_BUFFER:case s.DATA_VIEW:case s.FLOAT_32_ARRAY:case s.FLOAT_64_ARRAY:case s.GENERATOR:case s.INT_8_ARRAY:case s.INT_16_ARRAY:case s.INT_32_ARRAY:case s.ERROR:case s.MATH:case s.UINT_8_ARRAY:case s.UINT_8_CLAMPED_ARRAY:case s.UINT_16_ARRAY:case s.UINT_32_ARRAY:case s.UNDEFINED:case s.WEAKMAP:case s.WEAKSET:return d(o);default:return o}}}})(),N=function(e){if(!e)return 0;for(var t=e.length,n=5381,r=-1;++r<t;)n=(n<<5)+n+e.charCodeAt(r);return n>>>0},p=function(e){return JSON.stringify(e,O)},y=function(e){return i.default.prune(e)},S=function(e){try{return p(e,O)}catch(t){return y(e)}},g=function(e){var t=d(e);return"string"==typeof t?t:p(t)},Y=function(e){var t=d(e);return"string"==typeof t?t:S(d(e))};t.getIntegerHashValue=N,t.getStringifiedValue=g,t.getStringifiedValueWithRecursion=Y,t.replacer=O},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=n(4),u=6,c=50,a="*Recursive",i=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},f=void 0,A=function(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n)},R=function(e){i.lastIndex=0;var t=void 0;return i.test(e)?'"'+e.replace(i,(function(e){return t=s[e],(0,o.toString)(t)===o.STRING?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}))+'"':'"'+e+'"'},l=function(e){f=[];var t=function n(e,t,u){var i=t[e],s=[],l=void 0;switch("undefined"==typeof i?"undefined":r(i)){case"string":return R(i);case"boolean":case"null":case"number":case"undefined":return""+i;case"function":return(0,o.toFunctionString)(i);case"object":if(!i)return""+i;var E=f.indexOf(i);if(u<=0||~E)return a+"-"+E;switch((0,o.toString)(i)){case o.ARRAY:f.push(i);for(var _=Math.min(i.length,c),T=-1;++T<_;)s[T]=n(T,i,u-1);return l="["+s.join(",")+"]";case o.DATE:return""+i.valueOf();default:return f.push(i),A(i,(function(e){try{l=n(e,i,u-1),l&&s.push(R(e)+":"+l)}catch(t){}})),"{"+s.join(",")+"}"}}};return t("",{"":e},u)};t.default={prune:l},e.exports=t.default},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=(t.ARGUMENTS="[object Arguments]",t.ARRAY="[object Array]",t.ARRAY_BUFFER="[object ArrayBuffer]",t.BOOLEAN="[object Boolean]",t.DATA_VIEW="[object DataView]",t.DATE="[object Date]",t.ERROR="[object Error]",t.FLOAT_32_ARRAY="[object Float32Array]",t.FLOAT_64_ARRAY="[object Float64Array]",t.FUNCTION="[object Function]",t.GENERATOR="[object GeneratorFunction]",t.INT_8_ARRAY="[object Int8Array]",t.INT_16_ARRAY="[object Int16Array]",t.INT_32_ARRAY="[object Int32Array]",t.MAP="[object Map]",t.MATH="[object Math]",t.NULL="[object Null]",t.NUMBER="[object Number]",t.OBJECT="[object Object]",t.PROMISE="[object Promise]",t.REGEXP="[object RegExp]",t.SET="[object Set]",t.STRING="[object String]",t.UINT_8_ARRAY="[object Uint8Array]",t.UINT_8_CLAMPED_ARRAY="[object Uint8ClampedArray]",t.UINT_16_ARRAY="[object Uint16Array]",t.UINT_32_ARRAY="[object Uint32Array]",t.UNDEFINED="[object Undefined]",t.WEAKMAP="[object WeakMap]",t.WEAKSET="[object WeakSet]",t.BOOLEAN_TYPEOF="boolean",t.FUNCTION_TYPEOF="function",t.NUMBER_TYPEOF="number",t.STRING_TYPEOF="string",t.SYMBOL_TYPEOF="symbol",t.UNDEFINED_TYPEOF="undefined",Object.prototype.toString);t.toFunctionString=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"function"+(t?"*":"")+" "+(e.name||"anonymous")+"("+new Array(e.length+1).join(",arg").slice(1)+"){}"},t.toString=function(e){return n.call(e)}}])})); | ||
!(function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("hashIt",[],e):"object"==typeof exports?exports.hashIt=e():t.hashIt=e()})(this,(function(){return (function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)})([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),o=function(t){var e=(0,r.getStringifiedValue)(t);return(0,r.getIntegerHashValue)(e)},i=o(void 0),u=o(null),f=o([]),A=o(new Map),c=o(0),E=o({}),a=o(new Set),R=o("");o.isEqual=function(){var t=arguments.length;if(1===t)throw new Error("isEqual requires at least two objects to be passed for comparison.");for(var e=0;++e<t;)if(o(arguments.length<=e-1?void 0:arguments[e-1])!==o(arguments.length<=e?void 0:arguments[e]))return!1;return!0},o.isEmpty=function(t){var e=o(t);return e===i||e===u||e===f||e===A||e===c||e===E||e===a||e===R},o.isNull=function(t){return o(t)===u},o.isUndefined=function(t){return o(t)===i},o.withRecursion=function(t){var e=(0,r.getStringifiedValueWithRecursion)(t);return(0,r.getIntegerHashValue)(e)},e.default=o,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.getStringifiedValueWithRecursion=e.getStringifiedValue=e.tryCatch=e.stringify=e.getIntegerHashValue=e.REPLACER=e.getRecursiveStackValue=e.getValueForStringification=e.getStringifiedValueByObjectClass=e.prependTypeToString=e.getIterablePairs=e.getObjectType=e.arrayBufferToString=void 0;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=n(3),u=r(i),f=n(5),A=n(4),c=e.arrayBufferToString=function(t){return("undefined"==typeof Uint16Array?"undefined":o(Uint16Array))===f.UNDEFINED_TYPEOF?"":String.fromCharCode.apply(null,new Uint16Array(t))},E=e.getObjectType=function(t){return t.slice(8,-1)},a=e.getIterablePairs=function(t,e){var n=[E(e)];return t.forEach((function(t,e){n.push([e,t])})),n},R=e.prependTypeToString=function(t,e){return E(e)+" "+t},T=e.getStringifiedValueByObjectClass=function(t){var e=(0,A.toString)(t);return e===f.ARRAY||e===f.OBJECT||e===f.ARGUMENTS?t:e===f.ERROR||e===f.REGEXP||null===t?R(t,e):e===f.DATE?R(t.valueOf(),e):e===f.MAP||e===f.SET?a(t,e):e===f.PROMISE||e===f.WEAKMAP||e===f.WEAKSET?R("NOT_ENUMERABLE",e):e===f.ARRAY_BUFFER?R(c(t),e):e===f.DATA_VIEW?R(c(t.buffer),e):e===f.FLOAT_32_ARRAY||e===f.FLOAT_64_ARRAY||e===f.INT_8_ARRAY||e===f.INT_16_ARRAY||e===f.INT_32_ARRAY||e===f.UINT_8_ARRAY||e===f.UINT_8_CLAMPED_ARRAY||e===f.UINT_16_ARRAY||e===f.UINT_32_ARRAY?R(t.join(","),e):e===f.MATH?f.MATH_OBJECT:f.HTML_ELEMENT_REGEXP.test(e)?"HTMLElement "+t.textContent:t},_=e.getValueForStringification=function(t){var e="undefined"==typeof t?"undefined":o(t);return e===f.STRING_TYPEOF||e===f.NUMBER_TYPEOF?t:e===f.BOOLEAN_TYPEOF||e===f.UNDEFINED_TYPEOF?R(t,(0,A.toString)(t)):e===f.FUNCTION_TYPEOF?(0,A.toFunctionString)(t,(0,A.toString)(t)===f.GENERATOR):e===f.SYMBOL_TYPEOF?t.toString():T(t)},l=e.getRecursiveStackValue=function(t,e,n,r,o){return t?o>255?"Undefined undefined":(r=n.indexOf(t),~r?"*Recursive-"+r:(n.push(t),t)):R(t,e)},d=e.REPLACER=(function(){var t=void 0,e=void 0,n=void 0,r=void 0;return function(i,u){return i?(r="undefined"==typeof u?"undefined":o(u),r===f.STRING_TYPEOF||r===f.NUMBER_TYPEOF||r===f.BOOLEAN_TYPEOF?u:r===f.UNDEFINED_TYPEOF||r===f.FUNCTION_TYPEOF?_(u):r===f.SYMBOL_TYPEOF?u.toString():(r=(0,A.toString)(u),r===f.ARRAY||r===f.OBJECT?l(u,r,t,n,++e):r===f.ARGUMENTS?u:r===f.DATE||r===f.MAP||r===f.SET||r===f.PROMISE||r===f.REGEXP||null===u||r===f.ERROR||r===f.GENERATOR||r===f.WEAKMAP||r===f.WEAKSET||r===f.MATH||r===f.ARRAY_BUFFER||r===f.DATA_VIEW||r===f.FLOAT_32_ARRAY||r===f.FLOAT_64_ARRAY||r===f.INT_8_ARRAY||r===f.INT_16_ARRAY||r===f.INT_32_ARRAY||r===f.UINT_8_ARRAY||r===f.UINT_8_CLAMPED_ARRAY||r===f.UINT_16_ARRAY||r===f.UINT_32_ARRAY?_(u):u)):(t=[u],e=0,u)}})(),s=(e.getIntegerHashValue=function(t){if(!t)return 0;for(var e=t.length,n=5381,r=-1;++r<e;)n=(n<<5)+n+t.charCodeAt(r);return n>>>0},e.stringify=function(t){return JSON.stringify(t,d)}),O=e.tryCatch=function(t){try{return s(t)}catch(e){return u.default.prune(t)}};e.getStringifiedValue=function(t){var e=_(t);return("undefined"==typeof e?"undefined":o(e))===f.STRING_TYPEOF?e:s(e)},e.getStringifiedValueWithRecursion=function(t){var e=_(t);return("undefined"==typeof e?"undefined":o(e))===f.STRING_TYPEOF?e:O(_(t))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=n(4),i=n(5),u=void 0,f=function(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n)},A=function(t){i.ESCAPABLE.lastIndex=0;var e=void 0;return i.ESCAPABLE.test(t)?'"'+t.replace(i.ESCAPABLE,(function(t){return e=i.META[t],(0,o.toString)(e)===o.STRING?e:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)}))+'"':'"'+t+'"'},c=function(t){u=[];var e=function t(e,n,c){var E=n[e],a="undefined"==typeof E?"undefined":r(E),R=[],T=void 0;if(a===i.STRING_TYPEOF)return A(E);if(a===i.BOOLEAN_TYPEOF||a===i.NUMBER_TYPEOF||a===i.UNDEFINED_TYPEOF)return""+E;if(a===i.FUNCTION_TYPEOF)return(0,o.toFunctionString)(E);if(!E)return""+E;var _=u.indexOf(E);if(c<=0||~_)return i.DEFAULT_PRUNED_VALUE+"-"+_;if(a=(0,o.toString)(E),a===o.ARRAY){u.push(E);for(var l=Math.min(E.length,i.DEFAULT_ARRAY_MAX_LENGTH),d=-1;++d<l;)R[d]=t(d,E,c-1);return T="["+R.join(",")+"]"}return a===o.DATE?""+E.valueOf():(u.push(E),f(E,(function(e){try{T=t(e,E,c-1),T&&R.push(A(e)+":"+T)}catch(t){}})),"{"+R.join(",")+"}")};return e("",{"":t},i.DEFAULT_MAX_DEPTH)};e.default={prune:c},t.exports=e.default},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=Object.prototype.toString,r=e.getFunctionArgs=function(t){for(var e="",n=-1;++n<t;)e+="arg,";return e.slice(0,-1)};e.toFunctionString=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"function"+(e?"*":"")+" "+(t.name||"anonymous")+"("+r(t.length)+"){}"},e.toString=function(t){return n.call(t)}},function(t,e){"use strict";function n(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}Object.defineProperty(e,"__esModule",{value:!0});var r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e.ARGUMENTS="[object Arguments]",e.ARRAY="[object Array]",e.ARRAY_BUFFER="[object ArrayBuffer]",e.DATA_VIEW="[object DataView]",e.DATE="[object Date]",e.ERROR="[object Error]",e.FLOAT_32_ARRAY="[object Float32Array]",e.FLOAT_64_ARRAY="[object Float64Array]",e.GENERATOR="[object GeneratorFunction]",e.INT_8_ARRAY="[object Int8Array]",e.INT_16_ARRAY="[object Int16Array]",e.INT_32_ARRAY="[object Int32Array]",e.MAP="[object Map]",e.MATH="[object Math]",e.OBJECT="[object Object]",e.PROMISE="[object Promise]",e.REGEXP="[object RegExp]",e.SET="[object Set]",e.STRING="[object String]",e.UINT_8_ARRAY="[object Uint8Array]",e.UINT_8_CLAMPED_ARRAY="[object Uint8ClampedArray]",e.UINT_16_ARRAY="[object Uint16Array]",e.UINT_32_ARRAY="[object Uint32Array]",e.WEAKMAP="[object WeakMap]",e.WEAKSET="[object WeakSet]",e.BOOLEAN_TYPEOF="boolean",e.FUNCTION_TYPEOF="function",e.NUMBER_TYPEOF="number",e.STRING_TYPEOF="string",e.SYMBOL_TYPEOF="symbol",e.UNDEFINED_TYPEOF="undefined",e.DEFAULT_MAX_DEPTH=6,e.DEFAULT_ARRAY_MAX_LENGTH=50,e.DEFAULT_PRUNED_VALUE="*Recursive",e.ESCAPABLE=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e.META={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},e.HTML_ELEMENT_REGEXP=/\[object (HTML(.*)Element)\]/,e.MATH_OBJECT=["E","LN2","LN10","LOG2E","LOG10E","PI","SQRT1_2","SQRT2"].reduce((function(t,e){return r({},t,n({},e,Math[e]))}),{})}])})); |
@@ -46,3 +46,3 @@ 'use strict'; | ||
while (++index < length) { | ||
if (hashIt(arguments.length <= index - 1 + 0 ? undefined : arguments[index - 1 + 0]) !== hashIt(arguments.length <= index + 0 ? undefined : arguments[index + 0])) { | ||
if (hashIt(arguments.length <= index - 1 ? undefined : arguments[index - 1]) !== hashIt(arguments.length <= index ? undefined : arguments[index])) { | ||
return false; | ||
@@ -49,0 +49,0 @@ } |
114
lib/prune.js
@@ -9,4 +9,9 @@ 'use strict'; | ||
// constants | ||
var _toString = require('./toString'); | ||
var _constants = require('./constants'); | ||
/* | ||
@@ -18,16 +23,2 @@ This is a heavily modified and reduced version of JSON.prune provided by Canop | ||
var DEFAULT_MAX_DEPTH = 6; | ||
var DEFAULT_ARRAY_MAX_LENGTH = 50; | ||
var DEFAULT_PRUNED_VALUE = '*Recursive'; | ||
var ESCAPABLE = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | ||
var META = { // table of character substitutions | ||
'\b': '\\b', | ||
'\t': '\\t', | ||
'\n': '\\n', | ||
'\f': '\\f', | ||
'\r': '\\r', | ||
'"': '\\"', | ||
'\\': '\\\\' | ||
}; | ||
var seen = void 0; | ||
@@ -56,8 +47,8 @@ | ||
var quote = function quote(string) { | ||
ESCAPABLE.lastIndex = 0; | ||
_constants.ESCAPABLE.lastIndex = 0; | ||
var c = void 0; | ||
return !ESCAPABLE.test(string) ? '"' + string + '"' : '"' + string.replace(ESCAPABLE, function (a) { | ||
c = META[a]; | ||
return !_constants.ESCAPABLE.test(string) ? '"' + string + '"' : '"' + string.replace(_constants.ESCAPABLE, function (a) { | ||
c = _constants.META[a]; | ||
@@ -79,66 +70,65 @@ return (0, _toString.toString)(c) === _toString.STRING ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); | ||
var value = holder[key], | ||
type = typeof value === 'undefined' ? 'undefined' : _typeof(value), | ||
partial = [], | ||
v = void 0; | ||
switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) { | ||
case 'string': | ||
return quote(value); | ||
if (type === _constants.STRING_TYPEOF) { | ||
return quote(value); | ||
} | ||
case 'boolean': | ||
case 'null': | ||
case 'number': | ||
case 'undefined': | ||
return '' + value; | ||
if (type === _constants.BOOLEAN_TYPEOF || type === _constants.NUMBER_TYPEOF || type === _constants.UNDEFINED_TYPEOF) { | ||
return '' + value; | ||
} | ||
case 'function': | ||
return (0, _toString.toFunctionString)(value); | ||
if (type === _constants.FUNCTION_TYPEOF) { | ||
return (0, _toString.toFunctionString)(value); | ||
} | ||
case 'object': | ||
if (!value) { | ||
return '' + value; | ||
} | ||
if (!value) { | ||
return '' + value; | ||
} | ||
var index = seen.indexOf(value); | ||
var index = seen.indexOf(value); | ||
if (depthDecr <= 0 || !!~index) { | ||
return DEFAULT_PRUNED_VALUE + '-' + index; | ||
} | ||
if (depthDecr <= 0 || !!~index) { | ||
return _constants.DEFAULT_PRUNED_VALUE + '-' + index; | ||
} | ||
switch ((0, _toString.toString)(value)) { | ||
case _toString.ARRAY: | ||
seen.push(value); | ||
type = (0, _toString.toString)(value); | ||
var length = Math.min(value.length, DEFAULT_ARRAY_MAX_LENGTH); | ||
if (type === _toString.ARRAY) { | ||
seen.push(value); | ||
var _index = -1; | ||
var length = Math.min(value.length, _constants.DEFAULT_ARRAY_MAX_LENGTH); | ||
while (++_index < length) { | ||
partial[_index] = pruneString(_index, value, depthDecr - 1); | ||
} | ||
var _index = -1; | ||
v = '[' + partial.join(',') + ']'; | ||
while (++_index < length) { | ||
partial[_index] = pruneString(_index, value, depthDecr - 1); | ||
} | ||
return v; | ||
v = '[' + partial.join(',') + ']'; | ||
case _toString.DATE: | ||
return '' + value.valueOf(); | ||
return v; | ||
} | ||
default: | ||
seen.push(value); | ||
if (type === _toString.DATE) { | ||
return '' + value.valueOf(); | ||
} | ||
forEachEnumerableOwnProperty(value, function (k) { | ||
try { | ||
v = pruneString(k, value, depthDecr - 1); | ||
seen.push(value); | ||
if (v) { | ||
partial.push(quote(k) + ':' + v); | ||
} | ||
} catch (exception) { | ||
// this try/catch due to forbidden accessors on some objects | ||
} | ||
}); | ||
forEachEnumerableOwnProperty(value, function (k) { | ||
try { | ||
v = pruneString(k, value, depthDecr - 1); | ||
return '{' + partial.join(',') + '}'; | ||
if (v) { | ||
partial.push(quote(k) + ':' + v); | ||
} | ||
} | ||
} catch (exception) { | ||
// this try/catch due to forbidden accessors on some objects | ||
} | ||
}); | ||
return '{' + partial.join(',') + '}'; | ||
}; | ||
@@ -148,3 +138,3 @@ | ||
'': value | ||
}, DEFAULT_MAX_DEPTH); | ||
}, _constants.DEFAULT_MAX_DEPTH); | ||
}; | ||
@@ -151,0 +141,0 @@ |
@@ -6,42 +6,21 @@ 'use strict'; | ||
}); | ||
var ARGUMENTS = exports.ARGUMENTS = '[object Arguments]'; | ||
var ARRAY = exports.ARRAY = '[object Array]'; | ||
var ARRAY_BUFFER = exports.ARRAY_BUFFER = '[object ArrayBuffer]'; | ||
var BOOLEAN = exports.BOOLEAN = '[object Boolean]'; | ||
var DATA_VIEW = exports.DATA_VIEW = '[object DataView]'; | ||
var DATE = exports.DATE = '[object Date]'; | ||
var ERROR = exports.ERROR = '[object Error]'; | ||
var FLOAT_32_ARRAY = exports.FLOAT_32_ARRAY = '[object Float32Array]'; | ||
var FLOAT_64_ARRAY = exports.FLOAT_64_ARRAY = '[object Float64Array]'; | ||
var FUNCTION = exports.FUNCTION = '[object Function]'; | ||
var GENERATOR = exports.GENERATOR = '[object GeneratorFunction]'; | ||
var INT_8_ARRAY = exports.INT_8_ARRAY = '[object Int8Array]'; | ||
var INT_16_ARRAY = exports.INT_16_ARRAY = '[object Int16Array]'; | ||
var INT_32_ARRAY = exports.INT_32_ARRAY = '[object Int32Array]'; | ||
var MAP = exports.MAP = '[object Map]'; | ||
var MATH = exports.MATH = '[object Math]'; | ||
var NULL = exports.NULL = '[object Null]'; | ||
var NUMBER = exports.NUMBER = '[object Number]'; | ||
var OBJECT = exports.OBJECT = '[object Object]'; | ||
var PROMISE = exports.PROMISE = '[object Promise]'; | ||
var REGEXP = exports.REGEXP = '[object RegExp]'; | ||
var SET = exports.SET = '[object Set]'; | ||
var STRING = exports.STRING = '[object String]'; | ||
var UINT_8_ARRAY = exports.UINT_8_ARRAY = '[object Uint8Array]'; | ||
var UINT_8_CLAMPED_ARRAY = exports.UINT_8_CLAMPED_ARRAY = '[object Uint8ClampedArray]'; | ||
var UINT_16_ARRAY = exports.UINT_16_ARRAY = '[object Uint16Array]'; | ||
var UINT_32_ARRAY = exports.UINT_32_ARRAY = '[object Uint32Array]'; | ||
var UNDEFINED = exports.UNDEFINED = '[object Undefined]'; | ||
var WEAKMAP = exports.WEAKMAP = '[object WeakMap]'; | ||
var WEAKSET = exports.WEAKSET = '[object WeakSet]'; | ||
var objectToString = Object.prototype.toString; | ||
var BOOLEAN_TYPEOF = exports.BOOLEAN_TYPEOF = 'boolean'; | ||
var FUNCTION_TYPEOF = exports.FUNCTION_TYPEOF = 'function'; | ||
var NUMBER_TYPEOF = exports.NUMBER_TYPEOF = 'number'; | ||
var STRING_TYPEOF = exports.STRING_TYPEOF = 'string'; | ||
var SYMBOL_TYPEOF = exports.SYMBOL_TYPEOF = 'symbol'; | ||
var UNDEFINED_TYPEOF = exports.UNDEFINED_TYPEOF = 'undefined'; | ||
/** | ||
* create the fake function args array for the stringified function | ||
* | ||
* @param {number} length | ||
* @returns {string} | ||
*/ | ||
var getFunctionArgs = exports.getFunctionArgs = function getFunctionArgs(length) { | ||
var string = '', | ||
index = -1; | ||
var objectToString = Object.prototype.toString; | ||
while (++index < length) { | ||
string += 'arg,'; | ||
} | ||
return string.slice(0, -1); | ||
}; | ||
/** | ||
@@ -57,3 +36,3 @@ * get the generic string value of the function passed | ||
return 'function' + (isGenerator ? '*' : '') + ' ' + (fn.name || 'anonymous') + '(' + new Array(fn.length + 1).join(',arg').slice(1) + '){}'; | ||
return 'function' + (isGenerator ? '*' : '') + ' ' + (fn.name || 'anonymous') + '(' + getFunctionArgs(fn.length) + '){}'; | ||
}; | ||
@@ -60,0 +39,0 @@ |
239
lib/utils.js
@@ -6,8 +6,13 @@ 'use strict'; | ||
}); | ||
exports.replacer = exports.getStringifiedValueWithRecursion = exports.getStringifiedValue = exports.getIntegerHashValue = undefined; | ||
exports.getStringifiedValueWithRecursion = exports.getStringifiedValue = exports.tryCatch = exports.stringify = exports.getIntegerHashValue = exports.REPLACER = exports.getRecursiveStackValue = exports.getValueForStringification = exports.getStringifiedValueByObjectClass = exports.prependTypeToString = exports.getIterablePairs = exports.getObjectType = exports.arrayBufferToString = undefined; | ||
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 _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; }; // external dependencies | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
// constants | ||
// toString | ||
var _prune = require('./prune'); | ||
@@ -17,2 +22,4 @@ | ||
var _constants = require('./constants'); | ||
var _toString = require('./toString'); | ||
@@ -22,9 +29,2 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var HTML_ELEMENT_REGEXP = /\[object (HTML(.*)Element)\]/; | ||
var MATH_OBJECT = ['E', 'LN2', 'LN10', 'LOG2E', 'LOG10E', 'PI', 'SQRT1_2', 'SQRT2'].reduce(function (mathObject, property) { | ||
return _extends({}, mathObject, _defineProperty({}, property, Math[property])); | ||
}, {}); | ||
/** | ||
@@ -36,4 +36,4 @@ * get the string value of the buffer passed | ||
*/ | ||
var arrayBufferToString = function arrayBufferToString(buffer) { | ||
if (typeof Uint16Array === 'undefined') { | ||
var arrayBufferToString = exports.arrayBufferToString = function arrayBufferToString(buffer) { | ||
if ((typeof Uint16Array === 'undefined' ? 'undefined' : _typeof(Uint16Array)) === _constants.UNDEFINED_TYPEOF) { | ||
return ''; | ||
@@ -52,4 +52,4 @@ } | ||
*/ | ||
var getObjectType = function getObjectType(type) { | ||
return type.substring(8, type.length - 1); | ||
var getObjectType = exports.getObjectType = function getObjectType(type) { | ||
return type.slice(8, -1); | ||
}; | ||
@@ -64,3 +64,3 @@ | ||
*/ | ||
var getIterablePairs = function getIterablePairs(iterable, type) { | ||
var getIterablePairs = exports.getIterablePairs = function getIterablePairs(iterable, type) { | ||
var pairs = [getObjectType(type)]; | ||
@@ -82,55 +82,46 @@ | ||
*/ | ||
var prependTypeToString = function prependTypeToString(string, type) { | ||
var prependTypeToString = exports.prependTypeToString = function prependTypeToString(string, type) { | ||
return getObjectType(type) + ' ' + string; | ||
}; | ||
var getStringifiedValueByObjectClass = function getStringifiedValueByObjectClass(object) { | ||
var getStringifiedValueByObjectClass = exports.getStringifiedValueByObjectClass = function getStringifiedValueByObjectClass(object) { | ||
var type = (0, _toString.toString)(object); | ||
switch (type) { | ||
case _toString.ARRAY: | ||
case _toString.OBJECT: | ||
case _toString.ARGUMENTS: | ||
return object; | ||
if (type === _constants.ARRAY || type === _constants.OBJECT || type === _constants.ARGUMENTS) { | ||
return object; | ||
} | ||
case _toString.ERROR: | ||
case _toString.NULL: | ||
case _toString.REGEXP: | ||
return prependTypeToString(object, type); | ||
if (type === _constants.ERROR || type === _constants.REGEXP || object === null) { | ||
return prependTypeToString(object, type); | ||
} | ||
case _toString.DATE: | ||
return prependTypeToString(object.valueOf(), type); | ||
if (type === _constants.DATE) { | ||
return prependTypeToString(object.valueOf(), type); | ||
} | ||
case _toString.PROMISE: | ||
case _toString.WEAKMAP: | ||
case _toString.WEAKSET: | ||
return prependTypeToString('NOT_ENUMERABLE', type); | ||
if (type === _constants.MAP || type === _constants.SET) { | ||
return getIterablePairs(object, type); | ||
} | ||
case _toString.MAP: | ||
case _toString.SET: | ||
return getIterablePairs(object, type); | ||
if (type === _constants.PROMISE || type === _constants.WEAKMAP || type === _constants.WEAKSET) { | ||
return prependTypeToString('NOT_ENUMERABLE', type); | ||
} | ||
case _toString.ARRAY_BUFFER: | ||
return prependTypeToString(arrayBufferToString(object), type); | ||
if (type === _constants.ARRAY_BUFFER) { | ||
return prependTypeToString(arrayBufferToString(object), type); | ||
} | ||
case _toString.DATA_VIEW: | ||
return prependTypeToString(arrayBufferToString(object.buffer), type); | ||
if (type === _constants.DATA_VIEW) { | ||
return prependTypeToString(arrayBufferToString(object.buffer), type); | ||
} | ||
case _toString.FLOAT_32_ARRAY: | ||
case _toString.FLOAT_64_ARRAY: | ||
case _toString.INT_8_ARRAY: | ||
case _toString.INT_16_ARRAY: | ||
case _toString.INT_32_ARRAY: | ||
case _toString.UINT_8_ARRAY: | ||
case _toString.UINT_8_CLAMPED_ARRAY: | ||
case _toString.UINT_16_ARRAY: | ||
case _toString.UINT_32_ARRAY: | ||
return prependTypeToString(object.join(','), type); | ||
if (type === _constants.FLOAT_32_ARRAY || type === _constants.FLOAT_64_ARRAY || type === _constants.INT_8_ARRAY || type === _constants.INT_16_ARRAY || type === _constants.INT_32_ARRAY || type === _constants.UINT_8_ARRAY || type === _constants.UINT_8_CLAMPED_ARRAY || type === _constants.UINT_16_ARRAY || type === _constants.UINT_32_ARRAY) { | ||
return prependTypeToString(object.join(','), type); | ||
} | ||
case _toString.MATH: | ||
return MATH_OBJECT; | ||
if (type === _constants.MATH) { | ||
return _constants.MATH_OBJECT; | ||
} | ||
default: | ||
return HTML_ELEMENT_REGEXP.test(type) ? 'HTMLElement ' + object.textContent : object; | ||
} | ||
return _constants.HTML_ELEMENT_REGEXP.test(type) ? 'HTMLElement ' + object.textContent : object; | ||
}; | ||
@@ -148,21 +139,22 @@ | ||
*/ | ||
var getValueForStringification = function getValueForStringification(object) { | ||
switch (typeof object === 'undefined' ? 'undefined' : _typeof(object)) { | ||
case _toString.STRING_TYPEOF: | ||
case _toString.NUMBER_TYPEOF: | ||
return object; | ||
var getValueForStringification = exports.getValueForStringification = function getValueForStringification(object) { | ||
var type = typeof object === 'undefined' ? 'undefined' : _typeof(object); | ||
case _toString.BOOLEAN_TYPEOF: | ||
case _toString.UNDEFINED_TYPEOF: | ||
return prependTypeToString(object, (0, _toString.toString)(object)); | ||
if (type === _constants.STRING_TYPEOF || type === _constants.NUMBER_TYPEOF) { | ||
return object; | ||
} | ||
case _toString.FUNCTION_TYPEOF: | ||
return (0, _toString.toFunctionString)(object, (0, _toString.toString)(object) === _toString.GENERATOR); | ||
if (type === _constants.BOOLEAN_TYPEOF || type === _constants.UNDEFINED_TYPEOF) { | ||
return prependTypeToString(object, (0, _toString.toString)(object)); | ||
} | ||
case _toString.SYMBOL_TYPEOF: | ||
return object.toString(); | ||
if (type === _constants.FUNCTION_TYPEOF) { | ||
return (0, _toString.toFunctionString)(object, (0, _toString.toString)(object) === _constants.GENERATOR); | ||
} | ||
default: | ||
return getStringifiedValueByObjectClass(object); | ||
if (type === _constants.SYMBOL_TYPEOF) { | ||
return object.toString(); | ||
} | ||
return getStringifiedValueByObjectClass(object); | ||
}; | ||
@@ -181,3 +173,3 @@ | ||
*/ | ||
var getRecursiveStackValue = function getRecursiveStackValue(value, type, stack, index, recursiveCounter) { | ||
var getRecursiveStackValue = exports.getRecursiveStackValue = function getRecursiveStackValue(value, type, stack, index, recursiveCounter) { | ||
if (!value) { | ||
@@ -206,3 +198,8 @@ return prependTypeToString(value, type); | ||
*/ | ||
var REPLACER = function (stack, undefined, recursiveCounter, index) { | ||
var REPLACER = exports.REPLACER = function () { | ||
var stack = void 0, | ||
recursiveCounter = void 0, | ||
index = void 0, | ||
type = void 0; | ||
return function (key, value) { | ||
@@ -216,56 +213,31 @@ if (!key) { | ||
var type = (0, _toString.toString)(value); | ||
type = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) { | ||
case _toString.STRING_TYPEOF: | ||
case _toString.NUMBER_TYPEOF: | ||
case _toString.BOOLEAN_TYPEOF: | ||
return value; | ||
if (type === _constants.STRING_TYPEOF || type === _constants.NUMBER_TYPEOF || type === _constants.BOOLEAN_TYPEOF) { | ||
return value; | ||
} | ||
case _toString.UNDEFINED_TYPEOF: | ||
case _toString.FUNCTION_TYPEOF: | ||
return getValueForStringification(value); | ||
if (type === _constants.UNDEFINED_TYPEOF || type === _constants.FUNCTION_TYPEOF) { | ||
return getValueForStringification(value); | ||
} | ||
case _toString.SYMBOL_TYPEOF: | ||
return value.toString(); | ||
if (type === _constants.SYMBOL_TYPEOF) { | ||
return value.toString(); | ||
} | ||
default: | ||
switch (type) { | ||
case _toString.ARRAY: | ||
case _toString.OBJECT: | ||
return getRecursiveStackValue(value, type, stack, index, ++recursiveCounter); | ||
type = (0, _toString.toString)(value); | ||
case _toString.ARGUMENTS: | ||
return value; | ||
if (type === _constants.ARRAY || type === _constants.OBJECT) { | ||
return getRecursiveStackValue(value, type, stack, index, ++recursiveCounter); | ||
} | ||
case _toString.DATE: | ||
case _toString.FUNCTION: | ||
case _toString.MAP: | ||
case _toString.SET: | ||
case _toString.PROMISE: | ||
case _toString.REGEXP: | ||
case _toString.NULL: | ||
case _toString.ARRAY_BUFFER: | ||
case _toString.DATA_VIEW: | ||
case _toString.FLOAT_32_ARRAY: | ||
case _toString.FLOAT_64_ARRAY: | ||
case _toString.GENERATOR: | ||
case _toString.INT_8_ARRAY: | ||
case _toString.INT_16_ARRAY: | ||
case _toString.INT_32_ARRAY: | ||
case _toString.ERROR: | ||
case _toString.MATH: | ||
case _toString.UINT_8_ARRAY: | ||
case _toString.UINT_8_CLAMPED_ARRAY: | ||
case _toString.UINT_16_ARRAY: | ||
case _toString.UINT_32_ARRAY: | ||
case _toString.UNDEFINED: | ||
case _toString.WEAKMAP: | ||
case _toString.WEAKSET: | ||
return getValueForStringification(value); | ||
if (type === _constants.ARGUMENTS) { | ||
return value; | ||
} | ||
default: | ||
return value; | ||
} | ||
if (type === _constants.DATE || type === _constants.MAP || type === _constants.SET || type === _constants.PROMISE || type === _constants.REGEXP || value === null || type === _constants.ERROR || type === _constants.GENERATOR || type === _constants.WEAKMAP || type === _constants.WEAKSET || type === _constants.MATH || type === _constants.ARRAY_BUFFER || type === _constants.DATA_VIEW || type === _constants.FLOAT_32_ARRAY || type === _constants.FLOAT_64_ARRAY || type === _constants.INT_8_ARRAY || type === _constants.INT_16_ARRAY || type === _constants.INT_32_ARRAY || type === _constants.UINT_8_ARRAY || type === _constants.UINT_8_CLAMPED_ARRAY || type === _constants.UINT_16_ARRAY || type === _constants.UINT_32_ARRAY) { | ||
return getValueForStringification(value); | ||
} | ||
return value; | ||
}; | ||
@@ -281,3 +253,3 @@ }(); | ||
*/ | ||
var getIntegerHashValue = function getIntegerHashValue(string) { | ||
var getIntegerHashValue = exports.getIntegerHashValue = function getIntegerHashValue(string) { | ||
if (!string) { | ||
@@ -305,3 +277,3 @@ return 0; | ||
*/ | ||
var stringify = function stringify(value) { | ||
var stringify = exports.stringify = function stringify(value) { | ||
return JSON.stringify(value, REPLACER); | ||
@@ -311,12 +283,2 @@ }; | ||
/** | ||
* perform json.prune on the value | ||
* | ||
* @param {*} value | ||
* @returns {string} | ||
*/ | ||
var prune = function prune(value) { | ||
return _prune2.default.prune(value); | ||
}; | ||
/** | ||
* move try/catch to standalone function as any function that contains a try/catch | ||
@@ -328,7 +290,7 @@ * is not optimized (this allows optimization for as much as possible) | ||
*/ | ||
var tryCatch = function tryCatch(value) { | ||
var tryCatch = exports.tryCatch = function tryCatch(value) { | ||
try { | ||
return stringify(value, REPLACER); | ||
return stringify(value); | ||
} catch (exception) { | ||
return prune(value); | ||
return _prune2.default.prune(value); | ||
} | ||
@@ -344,6 +306,6 @@ }; | ||
*/ | ||
var getStringifiedValue = function getStringifiedValue(object) { | ||
var getStringifiedValue = exports.getStringifiedValue = function getStringifiedValue(object) { | ||
var valueForStringification = getValueForStringification(object); | ||
if (typeof valueForStringification === 'string') { | ||
if ((typeof valueForStringification === 'undefined' ? 'undefined' : _typeof(valueForStringification)) === _constants.STRING_TYPEOF) { | ||
return valueForStringification; | ||
@@ -362,6 +324,6 @@ } | ||
*/ | ||
var getStringifiedValueWithRecursion = function getStringifiedValueWithRecursion(object) { | ||
var getStringifiedValueWithRecursion = exports.getStringifiedValueWithRecursion = function getStringifiedValueWithRecursion(object) { | ||
var valueForStringification = getValueForStringification(object); | ||
if (typeof valueForStringification === 'string') { | ||
if ((typeof valueForStringification === 'undefined' ? 'undefined' : _typeof(valueForStringification)) === _constants.STRING_TYPEOF) { | ||
return valueForStringification; | ||
@@ -371,7 +333,2 @@ } | ||
return tryCatch(getValueForStringification(object)); | ||
}; | ||
exports.getIntegerHashValue = getIntegerHashValue; | ||
exports.getStringifiedValue = getStringifiedValue; | ||
exports.getStringifiedValueWithRecursion = getStringifiedValueWithRecursion; | ||
exports.replacer = REPLACER; | ||
}; |
@@ -30,26 +30,29 @@ { | ||
"devDependencies": { | ||
"ava": "0.16.0", | ||
"ava": "^0.17.0", | ||
"babel": "6.5.2", | ||
"babel-cli": "6.16.0", | ||
"babel-eslint": "7.0.0", | ||
"babel-loader": "6.2.5", | ||
"babel-cli": "^6.18.0", | ||
"babel-eslint": "^7.1.1", | ||
"babel-loader": "^6.2.10", | ||
"babel-plugin-add-module-exports": "0.2.1", | ||
"babel-plugin-transform-runtime": "6.15.0", | ||
"babel-polyfill": "6.16.0", | ||
"babel-polyfill": "^6.20.0", | ||
"babel-preset-latest": "6.16.0", | ||
"babel-preset-react": "6.16.0", | ||
"babel-preset-stage-2": "6.17.0", | ||
"babel-register": "6.16.3", | ||
"babel-preset-stage-2": "^6.18.0", | ||
"babel-register": "^6.18.0", | ||
"babel-runtime": "^6.11.6", | ||
"eslint": "3.8.1", | ||
"benchmark": "^2.1.2", | ||
"eslint": "^3.12.2", | ||
"eslint-friendly-formatter": "2.0.6", | ||
"eslint-loader": "1.6.0", | ||
"html-webpack-plugin": "2.24.0", | ||
"eslint-loader": "^1.6.1", | ||
"html-webpack-plugin": "^2.24.1", | ||
"in-publish": "2.0.0", | ||
"jsdom": "9.8.0", | ||
"jsdom": "^9.8.3", | ||
"nyc": "^10.0.0", | ||
"optimize-js-plugin": "0.0.4", | ||
"react": "15.3.2", | ||
"react-dom": "15.3.2", | ||
"react": "^15.4.1", | ||
"react-dom": "^15.4.1", | ||
"sinon": "1.17.6", | ||
"webpack": "1.13.2", | ||
"webpack": "^1.14.0", | ||
"webpack-dashboard": "^0.2.0", | ||
"webpack-dev-server": "1.16.2" | ||
@@ -74,15 +77,17 @@ }, | ||
"benchmark:watch": "onchange -i 'src/**/*.js' -- npm run benchmark", | ||
"build": "NODE_ENV=development ./node_modules/webpack/bin/webpack.js --progress --colors", | ||
"build-minified": "NODE_ENV=production ./node_modules/webpack/bin/webpack.js --progress --colors --config=webpack.config.minified.js", | ||
"compile-for-publish": "npm run lint && npm run test && npm run transpile && npm run dist", | ||
"dev": "NODE_ENV=development ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress --colors --config=webpack.config.dev.js", | ||
"dev-production": "NODE_ENV=production ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress --colors --config=webpack.config.dev.js", | ||
"build": "NODE_ENV=development webpack --progress --colors", | ||
"build-minified": "NODE_ENV=production webpack --progress --colors --config=webpack.config.minified.js", | ||
"dev": "NODE_ENV=development webpack-dashboard -p 3456 -- webpack-dev-server --colors --config=webpack.config.dev.js", | ||
"dev-production": "NODE_ENV=production webpack-dev-server --progress --colors --config=webpack.config.dev.js", | ||
"dist": "npm run build && npm run build-minified", | ||
"lint": "NODE_ENV=test ./node_modules/eslint/bin/eslint.js src", | ||
"prepublish": "in-publish && npm run compile-for-publish || in-install", | ||
"test": "NODE_ENV=test ava --no-cache", | ||
"lint": "NODE_ENV=test eslint src", | ||
"prepublish": "in-publish && npm run prepublish:compile || echo ''", | ||
"prepublish:compile": "npm run lint && npm run test:coverage && npm run transpile && npm run dist", | ||
"start": "npm run dev", | ||
"test": "NODE_ENV=test ava --no-cache --verbose", | ||
"test:coverage": "nyc npm test", | ||
"test:watch": "NODE_ENV=test ava --verbose --watch", | ||
"transpile": "./node_modules/babel-cli/lib/babel/index.js -d lib/ src/" | ||
"transpile": "babel src --out-dir lib" | ||
}, | ||
"version": "2.0.1" | ||
"version": "2.1.0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
413450
26
28
1358