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

hash-it

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-it - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

3

CHANGELOG.md
# hashIt CHANGELOG
#### 2.0.1
* More speed improvements
#### 2.0.0

@@ -4,0 +7,0 @@ * Use JSON.stringify with replacer as default, without try/catch

189

dist/hash-it.js

@@ -210,2 +210,13 @@ (function webpackUniversalModuleDefinition(root, factory) {

/**
* strip away [object and ] from return of toString()
* to get the object class
*
* @param {string} type
* @returns {string}
*/
var getObjectType = function getObjectType(type) {
return type.substring(8, type.length - 1);
};
/**
* get the key,value pairs for maps and sets

@@ -228,13 +239,2 @@ *

/**
* strip away [object and ] from return of toString()
* to get the object class
*
* @param {string} type
* @returns {string}
*/
var getObjectType = function getObjectType(type) {
return type.replace(/^\[object (.+)\]$/, '$1');
};
/**
* prepend type to string value

@@ -250,2 +250,53 @@ *

var getStringifiedValueByObjectClass = function getStringifiedValueByObjectClass(object) {
var type = (0, _toString.toString)(object);
switch (type) {
case _toString.ARRAY:
case _toString.OBJECT:
case _toString.ARGUMENTS:
return object;
case _toString.ERROR:
case _toString.NULL:
case _toString.REGEXP:
return prependTypeToString(object, type);
case _toString.DATE:
return prependTypeToString(object.valueOf(), type);
case _toString.PROMISE:
case _toString.WEAKMAP:
case _toString.WEAKSET:
return prependTypeToString('NOT_ENUMERABLE', type);
case _toString.MAP:
case _toString.SET:
return getIterablePairs(object, type);
case _toString.ARRAY_BUFFER:
return prependTypeToString(arrayBufferToString(object), type);
case _toString.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);
case _toString.MATH:
return MATH_OBJECT;
default:
return HTML_ELEMENT_REGEXP.test(type) ? 'HTMLElement ' + object.textContent : object;
}
};
/**

@@ -262,4 +313,2 @@ * get the string value for the object used for stringification

var getValueForStringification = function getValueForStringification(object) {
var type = (0, _toString.toString)(object);
switch (typeof object === 'undefined' ? 'undefined' : _typeof(object)) {

@@ -272,58 +321,44 @@ case _toString.STRING_TYPEOF:

case _toString.UNDEFINED_TYPEOF:
return prependTypeToString(object, type);
return prependTypeToString(object, (0, _toString.toString)(object));
case _toString.FUNCTION_TYPEOF:
return (0, _toString.toFunctionString)(object, type === _toString.GENERATOR);
return (0, _toString.toFunctionString)(object, (0, _toString.toString)(object) === _toString.GENERATOR);
case _toString.SYMBOL_TYPEOF:
return object.toString();
default:
switch (type) {
case _toString.ARRAY:
case _toString.OBJECT:
case _toString.ARGUMENTS:
return object;
return getStringifiedValueByObjectClass(object);
}
};
case _toString.ERROR:
case _toString.NULL:
case _toString.REGEXP:
return prependTypeToString(object, type);
/**
* get the value either from the recursive storage stack
* or itself after being added to that stack
*
* @param {*} value
* @param {string} type
* @param {Array<*>} stack
* @param {number} index
* @param {number} recursiveCounter
* @returns {*}
*/
var getRecursiveStackValue = function getRecursiveStackValue(value, type, stack, index, recursiveCounter) {
if (!value) {
return prependTypeToString(value, type);
}
case _toString.DATE:
return prependTypeToString(object.valueOf(), type);
if (recursiveCounter > 255) {
return 'Undefined undefined';
}
case _toString.SYMBOL:
return object.toString();
index = stack.indexOf(value);
case _toString.PROMISE:
case _toString.WEAKMAP:
case _toString.WEAKSET:
return prependTypeToString('NOT_ENUMERABLE', type);
if (!~index) {
stack.push(value);
case _toString.MAP:
case _toString.SET:
return getIterablePairs(object, type);
return value;
}
case _toString.ARRAY_BUFFER:
return prependTypeToString(arrayBufferToString(object), type);
case _toString.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);
case _toString.MATH:
return MATH_OBJECT;
default:
return HTML_ELEMENT_REGEXP.test(type) ? 'HTMLElement ' + object.textContent : object;
}
}
return '*Recursive-' + index;
};

@@ -356,2 +391,5 @@

case _toString.SYMBOL_TYPEOF:
return value.toString();
default:

@@ -361,20 +399,4 @@ switch (type) {

case _toString.OBJECT:
if (!value) {
return prependTypeToString(value, type);
}
return getRecursiveStackValue(value, type, stack, index, ++recursiveCounter);
if (++recursiveCounter > 255) {
return 'Undefined undefined';
}
index = stack.indexOf(value);
if (!~index) {
stack.push(value);
return value;
}
return '*Recursive-' + index;
case _toString.ARGUMENTS:

@@ -400,3 +422,2 @@ return value;

case _toString.MATH:
case _toString.SYMBOL:
case _toString.UINT_8_ARRAY:

@@ -442,2 +463,8 @@ case _toString.UINT_8_CLAMPED_ARRAY:

/**
* perform JSON.stringify on the value with the custom REPLACER
*
* @param {*} value
* @returns {string}
*/
var stringify = function stringify(value) {

@@ -447,2 +474,8 @@ return JSON.stringify(value, REPLACER);

/**
* perform json.prune on the value
*
* @param {*} value
* @returns {string}
*/
var prune = function prune(value) {

@@ -693,3 +726,2 @@ return _prune2.default.prune(value);

var STRING = exports.STRING = '[object String]';
var SYMBOL = exports.SYMBOL = '[object Symbol]';
var UINT_8_ARRAY = exports.UINT_8_ARRAY = '[object Uint8Array]';

@@ -707,2 +739,3 @@ var UINT_8_CLAMPED_ARRAY = exports.UINT_8_CLAMPED_ARRAY = '[object Uint8ClampedArray]';

var STRING_TYPEOF = exports.STRING_TYPEOF = 'string';
var SYMBOL_TYPEOF = exports.SYMBOL_TYPEOF = 'symbol';
var UNDEFINED_TYPEOF = exports.UNDEFINED_TYPEOF = 'undefined';

@@ -709,0 +742,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(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)})([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),o=function(e){var t=(0,n.getStringifiedValue)(e);return(0,n.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,n.getStringifiedValueWithRecursion)(e);return(0,n.getIntegerHashValue)(t)},t.default=o,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,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 r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},a=r(3),i=n(a),s=r(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,t){var r=[E(t)];return e.forEach((function(e,t){r.push([t,e])})),r},E=function(e){return e.replace(/^\[object (.+)\]$/,"$1")},_=function(e,t){return E(t)+" "+e},d=function(e){var t=(0,s.toString)(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,t);case s.FUNCTION_TYPEOF:return(0,s.toFunctionString)(e,t===s.GENERATOR);default: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.SYMBOL:return e.toString();case s.PROMISE:case s.WEAKMAP:case s.WEAKSET:return _("NOT_ENUMERABLE",t);case s.MAP:case s.SET:return l(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}}},T=(function(e,t,r,n){return function(t,o){if(!t)return e=[o],r=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);default:switch(c){case s.ARRAY:case s.OBJECT:return o?++r>255?"Undefined undefined":(n=e.indexOf(o),~n?"*Recursive-"+n:(e.push(o),o)):_(o,c);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.SYMBOL: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}}}})(),b=function(e){if(!e)return 0;for(var t=e.length,r=5381,n=-1;++n<t;)r=(r<<5)+r+e.charCodeAt(n);return r>>>0},p=function(e){return JSON.stringify(e,T)},N=function(e){return i.default.prune(e)},O=function(e){try{return p(e,T)}catch(t){return N(e)}},y=function(e){var t=d(e);return"string"==typeof t?t:p(t)},S=function(e){var t=d(e);return"string"==typeof t?t:O(d(e))};t.getIntegerHashValue=b,t.getStringifiedValue=y,t.getStringifiedValueWithRecursion=S,t.replacer=T},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="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=r(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 r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r)},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 r(e,t,u){var i=t[e],s=[],l=void 0;switch("undefined"==typeof i?"undefined":n(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),d=-1;++d<_;)s[d]=r(d,i,u-1);return l="["+s.join(",")+"]";case o.DATE:return""+i.valueOf();default:return f.push(i),A(i,(function(e){try{l=r(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 r=(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.SYMBOL="[object Symbol]",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.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 r.call(e)}}])}));
!(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)}}])}));

@@ -29,3 +29,2 @@ 'use strict';

var STRING = exports.STRING = '[object String]';
var SYMBOL = exports.SYMBOL = '[object Symbol]';
var UINT_8_ARRAY = exports.UINT_8_ARRAY = '[object Uint8Array]';

@@ -43,2 +42,3 @@ var UINT_8_CLAMPED_ARRAY = exports.UINT_8_CLAMPED_ARRAY = '[object Uint8ClampedArray]';

var STRING_TYPEOF = exports.STRING_TYPEOF = 'string';
var SYMBOL_TYPEOF = exports.SYMBOL_TYPEOF = 'symbol';
var UNDEFINED_TYPEOF = exports.UNDEFINED_TYPEOF = 'undefined';

@@ -45,0 +45,0 @@

@@ -42,2 +42,13 @@ 'use strict';

/**
* strip away [object and ] from return of toString()
* to get the object class
*
* @param {string} type
* @returns {string}
*/
var getObjectType = function getObjectType(type) {
return type.substring(8, type.length - 1);
};
/**
* get the key,value pairs for maps and sets

@@ -60,13 +71,2 @@ *

/**
* strip away [object and ] from return of toString()
* to get the object class
*
* @param {string} type
* @returns {string}
*/
var getObjectType = function getObjectType(type) {
return type.replace(/^\[object (.+)\]$/, '$1');
};
/**
* prepend type to string value

@@ -82,2 +82,53 @@ *

var getStringifiedValueByObjectClass = function getStringifiedValueByObjectClass(object) {
var type = (0, _toString.toString)(object);
switch (type) {
case _toString.ARRAY:
case _toString.OBJECT:
case _toString.ARGUMENTS:
return object;
case _toString.ERROR:
case _toString.NULL:
case _toString.REGEXP:
return prependTypeToString(object, type);
case _toString.DATE:
return prependTypeToString(object.valueOf(), type);
case _toString.PROMISE:
case _toString.WEAKMAP:
case _toString.WEAKSET:
return prependTypeToString('NOT_ENUMERABLE', type);
case _toString.MAP:
case _toString.SET:
return getIterablePairs(object, type);
case _toString.ARRAY_BUFFER:
return prependTypeToString(arrayBufferToString(object), type);
case _toString.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);
case _toString.MATH:
return MATH_OBJECT;
default:
return HTML_ELEMENT_REGEXP.test(type) ? 'HTMLElement ' + object.textContent : object;
}
};
/**

@@ -94,4 +145,2 @@ * get the string value for the object used for stringification

var getValueForStringification = function getValueForStringification(object) {
var type = (0, _toString.toString)(object);
switch (typeof object === 'undefined' ? 'undefined' : _typeof(object)) {

@@ -104,58 +153,44 @@ case _toString.STRING_TYPEOF:

case _toString.UNDEFINED_TYPEOF:
return prependTypeToString(object, type);
return prependTypeToString(object, (0, _toString.toString)(object));
case _toString.FUNCTION_TYPEOF:
return (0, _toString.toFunctionString)(object, type === _toString.GENERATOR);
return (0, _toString.toFunctionString)(object, (0, _toString.toString)(object) === _toString.GENERATOR);
case _toString.SYMBOL_TYPEOF:
return object.toString();
default:
switch (type) {
case _toString.ARRAY:
case _toString.OBJECT:
case _toString.ARGUMENTS:
return object;
return getStringifiedValueByObjectClass(object);
}
};
case _toString.ERROR:
case _toString.NULL:
case _toString.REGEXP:
return prependTypeToString(object, type);
/**
* get the value either from the recursive storage stack
* or itself after being added to that stack
*
* @param {*} value
* @param {string} type
* @param {Array<*>} stack
* @param {number} index
* @param {number} recursiveCounter
* @returns {*}
*/
var getRecursiveStackValue = function getRecursiveStackValue(value, type, stack, index, recursiveCounter) {
if (!value) {
return prependTypeToString(value, type);
}
case _toString.DATE:
return prependTypeToString(object.valueOf(), type);
if (recursiveCounter > 255) {
return 'Undefined undefined';
}
case _toString.SYMBOL:
return object.toString();
index = stack.indexOf(value);
case _toString.PROMISE:
case _toString.WEAKMAP:
case _toString.WEAKSET:
return prependTypeToString('NOT_ENUMERABLE', type);
if (!~index) {
stack.push(value);
case _toString.MAP:
case _toString.SET:
return getIterablePairs(object, type);
return value;
}
case _toString.ARRAY_BUFFER:
return prependTypeToString(arrayBufferToString(object), type);
case _toString.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);
case _toString.MATH:
return MATH_OBJECT;
default:
return HTML_ELEMENT_REGEXP.test(type) ? 'HTMLElement ' + object.textContent : object;
}
}
return '*Recursive-' + index;
};

@@ -188,2 +223,5 @@

case _toString.SYMBOL_TYPEOF:
return value.toString();
default:

@@ -193,20 +231,4 @@ switch (type) {

case _toString.OBJECT:
if (!value) {
return prependTypeToString(value, type);
}
return getRecursiveStackValue(value, type, stack, index, ++recursiveCounter);
if (++recursiveCounter > 255) {
return 'Undefined undefined';
}
index = stack.indexOf(value);
if (!~index) {
stack.push(value);
return value;
}
return '*Recursive-' + index;
case _toString.ARGUMENTS:

@@ -232,3 +254,2 @@ return value;

case _toString.MATH:
case _toString.SYMBOL:
case _toString.UINT_8_ARRAY:

@@ -274,2 +295,8 @@ case _toString.UINT_8_CLAMPED_ARRAY:

/**
* perform JSON.stringify on the value with the custom REPLACER
*
* @param {*} value
* @returns {string}
*/
var stringify = function stringify(value) {

@@ -279,2 +306,8 @@ return JSON.stringify(value, REPLACER);

/**
* perform json.prune on the value
*
* @param {*} value
* @returns {string}
*/
var prune = function prune(value) {

@@ -281,0 +314,0 @@ return _prune2.default.prune(value);

@@ -43,8 +43,8 @@ {

"babel-runtime": "^6.11.6",
"eslint": "3.7.1",
"eslint": "3.8.1",
"eslint-friendly-formatter": "2.0.6",
"eslint-loader": "1.5.0",
"html-webpack-plugin": "2.22.0",
"eslint-loader": "1.6.0",
"html-webpack-plugin": "2.24.0",
"in-publish": "2.0.0",
"jsdom": "9.6.0",
"jsdom": "9.8.0",
"optimize-js-plugin": "0.0.4",

@@ -86,3 +86,3 @@ "react": "15.3.2",

},
"version": "2.0.0"
"version": "2.0.1"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc