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 4.0.5 to 4.1.0

index.d.ts

7

CHANGELOG.md

@@ -1,3 +0,8 @@

# hashIt CHANGELOG
# hash-it CHANGELOG
## 4.1.0
- Add TypeScript definitions
- Significant speed improvements
## 4.0.5

@@ -4,0 +9,0 @@

101

dist/hash-it.js

@@ -96,6 +96,6 @@ (function (global, factory) {

var _SELF_TAGS, _TOSTRING_TAGS, _TYPEDARRAY_TAGS, _UNPARSEABLE_TAGS;
/**
* @constant {boolean} HAS_BUFFER_FROM_SUPPORT
*/
var HAS_BUFFER_FROM_SUPPORT = typeof Buffer !== 'undefined' && typeof Buffer.from === 'function';

@@ -154,5 +154,3 @@ /**

// external dependencies
var SEPARATOR = '|';
var charCodeAt = String.prototype.charCodeAt;
var FUNCTION_NAME_REGEX = /^\s*function\s*([^(]*)/i;
var toString = Object.prototype.toString;

@@ -171,3 +169,3 @@ var keys = Object.keys;

function getFunctionName(fn) {
return fn.name || (fn.toString().match(/^\s*function\s*([^\(]*)/i) || [])[1] || 'anonymous';
return fn.name || (fn.toString().match(FUNCTION_NAME_REGEX) || [])[1] || 'anonymous';
}

@@ -193,3 +191,3 @@ /**

while (index--) {
charCode = charCodeAt.call(string, index);
charCode = string.charCodeAt(index);
hashA = hashA * 33 ^ charCode;

@@ -262,3 +260,3 @@ hashB = hashB * 33 ^ charCode;

function shouldSortPair(pairA, pairB) {
return shouldSort(pairA[0], pairB[0]);
return pairA[0] > pairB[0];
}

@@ -279,6 +277,6 @@ /**

for (var index = 0; index < array.length; index++) {
for (var index = 0; index < array.length; ++index) {
value = array[index];
for (subIndex = index - 1; ~subIndex && fn(array[subIndex], value); subIndex--) {
for (subIndex = index - 1; ~subIndex && fn(array[subIndex], value); --subIndex) {
array[subIndex + 1] = array[subIndex];

@@ -302,31 +300,29 @@ }

function getSortedIterablePairs(iterable, cache, keys) {
function getSortedIterable(iterable, cache, keys) {
var isMap = typeof iterable.get === 'function';
var pairs = [];
var entries = [];
if (isMap) {
iterable.forEach(function (value, key) {
// eslint-disable-next-line no-use-before-define
pairs.push([stringify(key, cache, keys), stringify(value, cache, keys)]);
entries.push([// eslint-disable-next-line no-use-before-define
stringify(key, cache, keys), // eslint-disable-next-line no-use-before-define
stringify(value, cache, keys)]);
});
sort(entries, shouldSortPair);
} else {
iterable.forEach(function (value) {
// eslint-disable-next-line no-use-before-define
pairs.push([stringify(value, cache, keys)]);
entries.push(stringify(value, cache, keys));
});
sort(entries, shouldSort);
}
sort(pairs, shouldSortPair);
var length = pairs.length;
var lastIndex = length - 1;
var _final = '[';
var pair;
var _final = getFunctionName(iterable.constructor) + "|[";
for (var index = 0; index < length; index++) {
pair = pairs[index];
_final += isMap ? '[' + pair[0] + ',' + pair[1] + ']' : pair[0];
_final += index === lastIndex ? ']' : ',';
for (var index = 0, length = entries.length, entry; index < length; ++index) {
entry = entries[index];
_final += "" + (index ? ',' : '') + (isMap ? "[" + entry[0] + "," + entry[1] + "]" : entry);
}
return getFunctionName(iterable.constructor) + SEPARATOR + _final;
return _final + "]";
}

@@ -348,3 +344,3 @@ /**

for (var index = 0; index < objectKeys.length; index++) {
for (var index = 0; index < objectKeys.length; ++index) {
key = objectKeys[index];

@@ -429,3 +425,3 @@ newObject[key] = object[key];

for (var index = 0; index < children.length; index++) {
for (var index = 0; index < children.length; ++index) {
innerHTML += children[index].outerHTML;

@@ -449,3 +445,3 @@ }

function getCutoffIndex(array, value) {
for (var index = 0; index < array.length; index++) {
for (var index = 0; index < array.length; ++index) {
if (array[index] === value) {

@@ -475,7 +471,7 @@ return index + 1;

if (type === 'string' || PRIMITIVE_TAGS[type]) {
return type + SEPARATOR + value;
return type + "|" + value;
}
if (value === null) {
return 'null' + SEPARATOR + value;
return "null|" + value;
}

@@ -495,15 +491,15 @@ }

if (TOSTRING_TAGS[tag]) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + value.toString();
return OBJECT_CLASS_MAP[tag] + "|" + value.toString();
}
if (ITERABLE_TAGS[tag]) {
return getSortedIterablePairs(value, cache, keys);
return getSortedIterable(value, cache, keys);
}
if (tag === OBJECT_CLASS_TYPE_MAP.DATE) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + value.getTime();
return OBJECT_CLASS_MAP[tag] + "|" + value.getTime();
}
if (tag === OBJECT_CLASS_TYPE_MAP.ERROR) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + value.stack;
return OBJECT_CLASS_MAP[tag] + "|" + value.stack;
}

@@ -516,23 +512,23 @@

if (UNPARSEABLE_TAGS[tag]) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + 'NOT_ENUMERABLE';
return OBJECT_CLASS_MAP[tag] + "|NOT_ENUMERABLE";
}
if (HTML_ELEMENT_REGEXP.test(tag) || SVG_ELEMENT_REGEXP.test(tag)) {
return tag.slice(8, -1) + SEPARATOR + value.outerHTML;
return tag.slice(8, -1) + "|" + value.outerHTML;
}
if (tag === OBJECT_CLASS_TYPE_MAP.DOCUMENTFRAGMENT) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedDocumentFragment(value);
return OBJECT_CLASS_MAP[tag] + "|" + getStringifiedDocumentFragment(value);
}
if (TYPEDARRAY_TAGS[tag]) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + value.join(',');
return OBJECT_CLASS_MAP[tag] + "|" + value.join(',');
}
if (tag === OBJECT_CLASS_TYPE_MAP.ARRAYBUFFER) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedArrayBuffer(value);
return OBJECT_CLASS_MAP[tag] + "|" + getStringifiedArrayBuffer(value);
}
if (tag === OBJECT_CLASS_TYPE_MAP.DATAVIEW) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedArrayBuffer(value.buffer);
return OBJECT_CLASS_MAP[tag] + "|" + getStringifiedArrayBuffer(value.buffer);
}

@@ -577,4 +573,3 @@

if (valueCutoff !== 0) {
var ref = keys.slice(0, valueCutoff).join('.') || '.';
return "[~" + ref + "]";
return "[~" + (keys.slice(0, valueCutoff).join('.') || '.') + "]";
}

@@ -657,11 +652,7 @@

hash.is.all = curry(function () {
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
objects[_key] = arguments[_key];
}
hash.is.all = curry(function (objectBasis) {
var isEqual = hash.is(objectBasis);
var isEqual = hash.is(objects.shift());
for (var index = 0; index < objects.length; index++) {
if (!isEqual(objects[index])) {
for (var index = 1; index < arguments.length; ++index) {
if (!isEqual(arguments[index])) {
return false;

@@ -683,11 +674,7 @@ }

hash.is.any = curry(function () {
for (var _len2 = arguments.length, objects = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
objects[_key2] = arguments[_key2];
}
hash.is.any = curry(function (objectBasis) {
var isEqual = hash.is(objectBasis);
var isEqual = hash.is(objects.shift());
for (var index = 0; index < objects.length; index++) {
if (isEqual(objects[index])) {
for (var index = 1; index < arguments.length; index++) {
if (isEqual(arguments[index])) {
return true;

@@ -694,0 +681,0 @@ }

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).hashIt={})}(this,(function(t){"use strict";var e,n,r,o,u="function"==typeof Symbol?Symbol("curriable placeholder"):60881;function i(t,e){var n="number"==typeof e?e:t.length,r=function(t,e){return function n(r){return function(){var o,i=r.length,f=arguments,a=f.length,c=[],l=0,s=e;if(i)for(var A=-1;++A<i;)c[A]=o=r[A]===u&&l<a?f[l++]:r[A],o!==u&&--s;if(l<a)for(;l<a;)c[c.length]=o=f[l],o!==u&&l<e&&--s,++l;return s>0?n(c):t.apply(this,c)}}([])}(t,n);return r.arity=n,r.fn=t,r}i.__=u,i.isPlaceholder=function(t){return t===u},i.uncurry=function(t){return t.fn};var f="undefined"!=typeof Buffer&&"function"==typeof Buffer.from,a="function"==typeof Uint16Array,c=/\[object (HTML(.*)Element)\]/,l=/\[object (SVG(.*)Element)\]/,s=["Arguments","Array","ArrayBuffer","Boolean","DataView","Date","DocumentFragment","Error","Event","Float32Array","Float64Array","Function","Generator","GeneratorFunction","HTMLElement","Int8Array","Int16Array","Int32Array","Map","Null","Number","Object","Promise","RegExp","Set","String","Symbol","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","Undefined","WeakMap","WeakSet","Window"].reduce((function(t,e){return t["[object "+e+"]"]=e,t}),{}),A=Object.keys(s).reduce((function(t,e){return t[s[e].toUpperCase()]=e,t}),{}),y={"[object Map]":!0,"[object Set]":!0},p={boolean:!0,function:!0,number:!0,string:!0,undefined:!0},h=((e={})[A.ARGUMENTS]=!0,e[A.ARRAY]=!0,e),d=((n={})[A.REGEXP]=!0,n[A.SYMBOL]=!0,n),R=((r={})[A.FLOAT32ARRAY]=!0,r[A.FLOAT64ARRAY]=!0,r[A.INT8ARRAY]=!0,r[A.INT16ARRAY]=!0,r[A.INT32ARRAY]=!0,r[A.UINT8ARRAY]=!0,r[A.UINT8CLAMPEDARRAY]=!0,r[A.UINT16ARRAY]=!0,r[A.UINT32ARRAY]=!0,r),b=((o={})[A.GENERATOR]=!0,o[A.PROMISE]=!0,o[A.WEAKMAP]=!0,o[A.WEAKSET]=!0,o),g=String.prototype.charCodeAt,E=Object.prototype.toString,v=Object.keys;function T(t,e){return t>e}function m(t,e){return T(t[0],e[0])}function S(t,e){for(var n,r,o=0;o<t.length;o++){for(r=t[o],n=o-1;~n&&e(t[n],r);n--)t[n+1]=t[n];t[n+1]=r}return t}function N(t){for(var e,n=S(v(t),T),r={},o=0;o<n.length;o++)r[e=n[o]]=t[e];return r}function M(t){return String.fromCharCode.apply(null,new Uint16Array(t))}function U(t){return Buffer.from(t).toString("utf8")}function j(){return""}var O=f?U:a?M:j;function I(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return n+1;return 0}function P(t,e,n,r){if(void 0===r){var o=typeof t;if("string"===o||p[o])return o+"|"+t;if(null===t)return"null|"+t}var u,i=r||E.call(t);return h[i]?t:i===A.OBJECT?N(t):d[i]?s[i]+"|"+t.toString():y[i]?function(t,e,n){var r="function"==typeof t.get,o=[];r?t.forEach((function(t,r){o.push([Y(r,e,n),Y(t,e,n)])})):t.forEach((function(t){o.push([Y(t,e,n)])})),S(o,m);for(var u,i,f=o.length,a=f-1,c="[",l=0;l<f;l++)u=o[l],c+=r?"["+u[0]+","+u[1]+"]":u[0],c+=l===a?"]":",";return((i=t.constructor).name||(i.toString().match(/^\s*function\s*([^\(]*)/i)||[])[1]||"anonymous")+"|"+c}(t,e,n):i===A.DATE?s[i]+"|"+t.getTime():i===A.ERROR?s[i]+"|"+t.stack:i===A.EVENT?{bubbles:(u=t).bubbles,cancelBubble:u.cancelBubble,cancelable:u.cancelable,composed:u.composed,currentTarget:u.currentTarget,defaultPrevented:u.defaultPrevented,eventPhase:u.eventPhase,isTrusted:u.isTrusted,returnValue:u.returnValue,target:u.target,type:u.type}:b[i]?s[i]+"|NOT_ENUMERABLE":c.test(i)||l.test(i)?i.slice(8,-1)+"|"+t.outerHTML:i===A.DOCUMENTFRAGMENT?s[i]+"|"+function(t){for(var e=t.children,n="",r=0;r<e.length;r++)n+=e[r].outerHTML;return n}(t):R[i]?s[i]+"|"+t.join(","):i===A.ARRAYBUFFER?s[i]+"|"+O(t):i===A.DATAVIEW?s[i]+"|"+O(t.buffer):t}function Y(t,e,n){if(!t||"object"!=typeof t)return P(t,e,n);var r=E.call(t);return r===A.DATE||r===A.REGEXP?P(t,e,n,r):JSON.stringify(t,function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=[]),function(n,r){if("object"==typeof r)if(t.length){var o=I(t,this);0===o?t.push(this):(t.splice(o),e.splice(o)),e.push(n);var u=I(t,r);if(0!==u)return"[~"+(e.slice(0,u).join(".")||".")+"]";t.push(r)}else t[0]=r,e[0]=n;return n&&this[n]instanceof Date?P(this[n],t,e,A.DATE):P(r,t,e)}}(e,n))}function B(t){return function(t){for(var e,n=t.length,r=5381,o=52711;n--;)r=33*r^(e=g.call(t,n)),o=33*o^e;return 4096*(r>>>0)+(o>>>0)}(Y(t))}B.is=i((function(t,e){return B(t)===B(e)})),B.is.all=i((function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];for(var r=B.is(e.shift()),o=0;o<e.length;o++)if(!r(e[o]))return!1;return!0}),2),B.is.any=i((function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];for(var r=B.is(e.shift()),o=0;o<e.length;o++)if(r(e[o]))return!0;return!1}),2),B.is.not=i((function(t,e){return B(t)!==B(e)})),t.default=B,t.hash=B,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).hashIt={})}(this,(function(e){"use strict";var t,n,r,u,o="function"==typeof Symbol?Symbol("curriable placeholder"):60881;function i(e,t){var n="number"==typeof t?t:e.length,r=function(e,t){return function n(r){return function(){var u,i=r.length,f=arguments,a=f.length,c=[],l=0,s=t;if(i)for(var A=-1;++A<i;)c[A]=u=r[A]===o&&l<a?f[l++]:r[A],u!==o&&--s;if(l<a)for(;l<a;)c[c.length]=u=f[l],u!==o&&l<t&&--s,++l;return s>0?n(c):e.apply(this,c)}}([])}(e,n);return r.arity=n,r.fn=e,r}i.__=o,i.isPlaceholder=function(e){return e===o},i.uncurry=function(e){return e.fn};var f="undefined"!=typeof Buffer&&"function"==typeof Buffer.from,a="function"==typeof Uint16Array,c=/\[object (HTML(.*)Element)\]/,l=/\[object (SVG(.*)Element)\]/,s=["Arguments","Array","ArrayBuffer","Boolean","DataView","Date","DocumentFragment","Error","Event","Float32Array","Float64Array","Function","Generator","GeneratorFunction","HTMLElement","Int8Array","Int16Array","Int32Array","Map","Null","Number","Object","Promise","RegExp","Set","String","Symbol","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","Undefined","WeakMap","WeakSet","Window"].reduce((function(e,t){return e["[object "+t+"]"]=t,e}),{}),A=Object.keys(s).reduce((function(e,t){return e[s[t].toUpperCase()]=t,e}),{}),p={"[object Map]":!0,"[object Set]":!0},y={boolean:!0,function:!0,number:!0,string:!0,undefined:!0},h=((t={})[A.ARGUMENTS]=!0,t[A.ARRAY]=!0,t),d=((n={})[A.REGEXP]=!0,n[A.SYMBOL]=!0,n),R=((r={})[A.FLOAT32ARRAY]=!0,r[A.FLOAT64ARRAY]=!0,r[A.INT8ARRAY]=!0,r[A.INT16ARRAY]=!0,r[A.INT32ARRAY]=!0,r[A.UINT8ARRAY]=!0,r[A.UINT8CLAMPEDARRAY]=!0,r[A.UINT16ARRAY]=!0,r[A.UINT32ARRAY]=!0,r),b=((u={})[A.GENERATOR]=!0,u[A.PROMISE]=!0,u[A.WEAKMAP]=!0,u[A.WEAKSET]=!0,u),E=/^\s*function\s*([^(]*)/i,g=Object.prototype.toString,T=Object.keys;function v(e,t){return e>t}function m(e,t){return e[0]>t[0]}function S(e,t){for(var n,r,u=0;u<e.length;++u){for(r=e[u],n=u-1;~n&&t(e[n],r);--n)e[n+1]=e[n];e[n+1]=r}return e}function N(e,t,n){var r="function"==typeof e.get,u=[];r?(e.forEach((function(e,r){u.push([B(r,t,n),B(e,t,n)])})),S(u,m)):(e.forEach((function(e){u.push(B(e,t,n))})),S(u,v));for(var o,i,f=((o=e.constructor).name||(o.toString().match(E)||[])[1]||"anonymous")+"|[",a=0,c=u.length;a<c;++a)i=u[a],f+=(a?",":"")+(r?"["+i[0]+","+i[1]+"]":i);return f+"]"}function M(e){for(var t,n=S(T(e),v),r={},u=0;u<n.length;++u)r[t=n[u]]=e[t];return r}function U(e){return String.fromCharCode.apply(null,new Uint16Array(e))}function j(e){return Buffer.from(e).toString("utf8")}function O(){return""}var I=f?j:a?U:O;function P(e,t){for(var n=0;n<e.length;++n)if(e[n]===t)return n+1;return 0}function Y(e,t,n,r){if(void 0===r){var u=typeof e;if("string"===u||y[u])return u+"|"+e;if(null===e)return"null|"+e}var o,i=r||g.call(e);return h[i]?e:i===A.OBJECT?M(e):d[i]?s[i]+"|"+e.toString():p[i]?N(e,t,n):i===A.DATE?s[i]+"|"+e.getTime():i===A.ERROR?s[i]+"|"+e.stack:i===A.EVENT?{bubbles:(o=e).bubbles,cancelBubble:o.cancelBubble,cancelable:o.cancelable,composed:o.composed,currentTarget:o.currentTarget,defaultPrevented:o.defaultPrevented,eventPhase:o.eventPhase,isTrusted:o.isTrusted,returnValue:o.returnValue,target:o.target,type:o.type}:b[i]?s[i]+"|NOT_ENUMERABLE":c.test(i)||l.test(i)?i.slice(8,-1)+"|"+e.outerHTML:i===A.DOCUMENTFRAGMENT?s[i]+"|"+function(e){for(var t=e.children,n="",r=0;r<t.length;++r)n+=t[r].outerHTML;return n}(e):R[i]?s[i]+"|"+e.join(","):i===A.ARRAYBUFFER?s[i]+"|"+I(e):i===A.DATAVIEW?s[i]+"|"+I(e.buffer):e}function B(e,t,n){if(!e||"object"!=typeof e)return Y(e,t,n);var r=g.call(e);return r===A.DATE||r===A.REGEXP?Y(e,t,n,r):JSON.stringify(e,function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),function(n,r){if("object"==typeof r)if(e.length){var u=P(e,this);0===u?e.push(this):(e.splice(u),t.splice(u)),t.push(n);var o=P(e,r);if(0!==o)return"[~"+(t.slice(0,o).join(".")||".")+"]";e.push(r)}else e[0]=r,t[0]=n;return n&&this[n]instanceof Date?Y(this[n],e,t,A.DATE):Y(r,e,t)}}(t,n))}function D(e){return function(e){for(var t,n=e.length,r=5381,u=52711;n--;)r=33*r^(t=e.charCodeAt(n)),u=33*u^t;return 4096*(r>>>0)+(u>>>0)}(B(e))}D.is=i((function(e,t){return D(e)===D(t)})),D.is.all=i((function(e){for(var t=D.is(e),n=1;n<arguments.length;++n)if(!t(arguments[n]))return!1;return!0}),2),D.is.any=i((function(e){for(var t=D.is(e),n=1;n<arguments.length;n++)if(t(arguments[n]))return!0;return!1}),2),D.is.not=i((function(e,t){return D(e)!==D(t)})),e.default=D,e.hash=D,Object.defineProperty(e,"__esModule",{value:!0})}));
var _SELF_TAGS, _TOSTRING_TAGS, _TYPEDARRAY_TAGS, _UNPARSEABLE_TAGS;
/**
* @constant {string} CIRCULAR_VALUE
*/
export var CIRCULAR_VALUE = '~';
/**
* @constant {boolean} HAS_BUFFER_FROM_SUPPORT
*/
export var HAS_BUFFER_FROM_SUPPORT = typeof Buffer !== 'undefined' && typeof Buffer.from === 'function';

@@ -31,3 +26,3 @@ /**

export var OBJECT_CLASSES = ['Arguments', 'Array', 'ArrayBuffer', 'Boolean', 'DataView', 'Date', 'DocumentFragment', 'Error', 'Event', 'Float32Array', 'Float64Array', 'Function', 'Generator', 'GeneratorFunction', 'HTMLElement', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Null', 'Number', 'Object', 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'Undefined', 'WeakMap', 'WeakSet', 'Window'];
var OBJECT_CLASSES = ['Arguments', 'Array', 'ArrayBuffer', 'Boolean', 'DataView', 'Date', 'DocumentFragment', 'Error', 'Event', 'Float32Array', 'Float64Array', 'Function', 'Generator', 'GeneratorFunction', 'HTMLElement', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Null', 'Number', 'Object', 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'Undefined', 'WeakMap', 'WeakSet', 'Window'];
/**

@@ -34,0 +29,0 @@ * @constant {Object} OBJECT_CLASS_MAP

@@ -41,11 +41,7 @@ // external dependencies

hash.is.all = curry(function () {
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
objects[_key] = arguments[_key];
}
hash.is.all = curry(function (objectBasis) {
var isEqual = hash.is(objectBasis);
var isEqual = hash.is(objects.shift());
for (var index = 0; index < objects.length; index++) {
if (!isEqual(objects[index])) {
for (var index = 1; index < arguments.length; ++index) {
if (!isEqual(arguments[index])) {
return false;

@@ -67,11 +63,7 @@ }

hash.is.any = curry(function () {
for (var _len2 = arguments.length, objects = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
objects[_key2] = arguments[_key2];
}
hash.is.any = curry(function (objectBasis) {
var isEqual = hash.is(objectBasis);
var isEqual = hash.is(objects.shift());
for (var index = 0; index < objects.length; index++) {
if (isEqual(objects[index])) {
for (var index = 1; index < arguments.length; index++) {
if (isEqual(arguments[index])) {
return true;

@@ -78,0 +70,0 @@ }

@@ -1,6 +0,3 @@

// external dependencies
// constants
import { HAS_BUFFER_FROM_SUPPORT, HAS_UINT16ARRAY_SUPPORT, HTML_ELEMENT_REGEXP, ITERABLE_TAGS, OBJECT_CLASS_MAP, OBJECT_CLASS_TYPE_MAP, PRIMITIVE_TAGS, SELF_TAGS, SVG_ELEMENT_REGEXP, TOSTRING_TAGS, TYPEDARRAY_TAGS, UNPARSEABLE_TAGS } from './constants';
var SEPARATOR = '|';
var charCodeAt = String.prototype.charCodeAt;
var FUNCTION_NAME_REGEX = /^\s*function\s*([^(]*)/i;
var toString = Object.prototype.toString;

@@ -19,3 +16,3 @@ var keys = Object.keys;

export function getFunctionName(fn) {
return fn.name || (fn.toString().match(/^\s*function\s*([^\(]*)/i) || [])[1] || 'anonymous';
return fn.name || (fn.toString().match(FUNCTION_NAME_REGEX) || [])[1] || 'anonymous';
}

@@ -41,3 +38,3 @@ /**

while (index--) {
charCode = charCodeAt.call(string, index);
charCode = string.charCodeAt(index);
hashA = hashA * 33 ^ charCode;

@@ -110,3 +107,3 @@ hashB = hashB * 33 ^ charCode;

export function shouldSortPair(pairA, pairB) {
return shouldSort(pairA[0], pairB[0]);
return pairA[0] > pairB[0];
}

@@ -127,6 +124,6 @@ /**

for (var index = 0; index < array.length; index++) {
for (var index = 0; index < array.length; ++index) {
value = array[index];
for (subIndex = index - 1; ~subIndex && fn(array[subIndex], value); subIndex--) {
for (subIndex = index - 1; ~subIndex && fn(array[subIndex], value); --subIndex) {
array[subIndex + 1] = array[subIndex];

@@ -150,31 +147,29 @@ }

export function getSortedIterablePairs(iterable, cache, keys) {
export function getSortedIterable(iterable, cache, keys) {
var isMap = typeof iterable.get === 'function';
var pairs = [];
var entries = [];
if (isMap) {
iterable.forEach(function (value, key) {
// eslint-disable-next-line no-use-before-define
pairs.push([stringify(key, cache, keys), stringify(value, cache, keys)]);
entries.push([// eslint-disable-next-line no-use-before-define
stringify(key, cache, keys), // eslint-disable-next-line no-use-before-define
stringify(value, cache, keys)]);
});
sort(entries, shouldSortPair);
} else {
iterable.forEach(function (value) {
// eslint-disable-next-line no-use-before-define
pairs.push([stringify(value, cache, keys)]);
entries.push(stringify(value, cache, keys));
});
sort(entries, shouldSort);
}
sort(pairs, shouldSortPair);
var length = pairs.length;
var lastIndex = length - 1;
var _final = '[';
var pair;
var _final = getFunctionName(iterable.constructor) + "|[";
for (var index = 0; index < length; index++) {
pair = pairs[index];
_final += isMap ? '[' + pair[0] + ',' + pair[1] + ']' : pair[0];
_final += index === lastIndex ? ']' : ',';
for (var index = 0, length = entries.length, entry; index < length; ++index) {
entry = entries[index];
_final += "" + (index ? ',' : '') + (isMap ? "[" + entry[0] + "," + entry[1] + "]" : entry);
}
return getFunctionName(iterable.constructor) + SEPARATOR + _final;
return _final + "]";
}

@@ -196,3 +191,3 @@ /**

for (var index = 0; index < objectKeys.length; index++) {
for (var index = 0; index < objectKeys.length; ++index) {
key = objectKeys[index];

@@ -277,3 +272,3 @@ newObject[key] = object[key];

for (var index = 0; index < children.length; index++) {
for (var index = 0; index < children.length; ++index) {
innerHTML += children[index].outerHTML;

@@ -297,3 +292,3 @@ }

export function getCutoffIndex(array, value) {
for (var index = 0; index < array.length; index++) {
for (var index = 0; index < array.length; ++index) {
if (array[index] === value) {

@@ -323,7 +318,7 @@ return index + 1;

if (type === 'string' || PRIMITIVE_TAGS[type]) {
return type + SEPARATOR + value;
return type + "|" + value;
}
if (value === null) {
return 'null' + SEPARATOR + value;
return "null|" + value;
}

@@ -343,15 +338,15 @@ }

if (TOSTRING_TAGS[tag]) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + value.toString();
return OBJECT_CLASS_MAP[tag] + "|" + value.toString();
}
if (ITERABLE_TAGS[tag]) {
return getSortedIterablePairs(value, cache, keys);
return getSortedIterable(value, cache, keys);
}
if (tag === OBJECT_CLASS_TYPE_MAP.DATE) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + value.getTime();
return OBJECT_CLASS_MAP[tag] + "|" + value.getTime();
}
if (tag === OBJECT_CLASS_TYPE_MAP.ERROR) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + value.stack;
return OBJECT_CLASS_MAP[tag] + "|" + value.stack;
}

@@ -364,23 +359,23 @@

if (UNPARSEABLE_TAGS[tag]) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + 'NOT_ENUMERABLE';
return OBJECT_CLASS_MAP[tag] + "|NOT_ENUMERABLE";
}
if (HTML_ELEMENT_REGEXP.test(tag) || SVG_ELEMENT_REGEXP.test(tag)) {
return tag.slice(8, -1) + SEPARATOR + value.outerHTML;
return tag.slice(8, -1) + "|" + value.outerHTML;
}
if (tag === OBJECT_CLASS_TYPE_MAP.DOCUMENTFRAGMENT) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedDocumentFragment(value);
return OBJECT_CLASS_MAP[tag] + "|" + getStringifiedDocumentFragment(value);
}
if (TYPEDARRAY_TAGS[tag]) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + value.join(',');
return OBJECT_CLASS_MAP[tag] + "|" + value.join(',');
}
if (tag === OBJECT_CLASS_TYPE_MAP.ARRAYBUFFER) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedArrayBuffer(value);
return OBJECT_CLASS_MAP[tag] + "|" + getStringifiedArrayBuffer(value);
}
if (tag === OBJECT_CLASS_TYPE_MAP.DATAVIEW) {
return OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedArrayBuffer(value.buffer);
return OBJECT_CLASS_MAP[tag] + "|" + getStringifiedArrayBuffer(value.buffer);
}

@@ -425,4 +420,3 @@

if (valueCutoff !== 0) {
var ref = keys.slice(0, valueCutoff).join('.') || '.';
return "[~" + ref + "]";
return "[~" + (keys.slice(0, valueCutoff).join('.') || '.') + "]";
}

@@ -429,0 +423,0 @@

"use strict";
exports.__esModule = true;
exports.UNPARSEABLE_TAGS = exports.TYPEDARRAY_TAGS = exports.TOSTRING_TAGS = exports.SELF_TAGS = exports.PRIMITIVE_TAGS = exports.ITERABLE_TAGS = exports.OBJECT_CLASS_TYPE_MAP = exports.OBJECT_CLASS_MAP = exports.OBJECT_CLASSES = exports.SVG_ELEMENT_REGEXP = exports.HTML_ELEMENT_REGEXP = exports.HAS_UINT16ARRAY_SUPPORT = exports.HAS_BUFFER_FROM_SUPPORT = exports.CIRCULAR_VALUE = void 0;
exports.UNPARSEABLE_TAGS = exports.TYPEDARRAY_TAGS = exports.TOSTRING_TAGS = exports.SELF_TAGS = exports.PRIMITIVE_TAGS = exports.ITERABLE_TAGS = exports.OBJECT_CLASS_TYPE_MAP = exports.OBJECT_CLASS_MAP = exports.SVG_ELEMENT_REGEXP = exports.HTML_ELEMENT_REGEXP = exports.HAS_UINT16ARRAY_SUPPORT = exports.HAS_BUFFER_FROM_SUPPORT = void 0;

@@ -9,10 +9,4 @@ var _SELF_TAGS, _TOSTRING_TAGS, _TYPEDARRAY_TAGS, _UNPARSEABLE_TAGS;

/**
* @constant {string} CIRCULAR_VALUE
*/
var CIRCULAR_VALUE = '~';
/**
* @constant {boolean} HAS_BUFFER_FROM_SUPPORT
*/
exports.CIRCULAR_VALUE = CIRCULAR_VALUE;
var HAS_BUFFER_FROM_SUPPORT = typeof Buffer !== 'undefined' && typeof Buffer.from === 'function';

@@ -47,3 +41,2 @@ /**

exports.OBJECT_CLASSES = OBJECT_CLASSES;
var OBJECT_CLASS_MAP = OBJECT_CLASSES.reduce(function (objectClasses, type) {

@@ -50,0 +43,0 @@ objectClasses["[object " + type + "]"] = type;

@@ -50,11 +50,7 @@ "use strict";

hash.is.all = (0, _curriable.curry)(function () {
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
objects[_key] = arguments[_key];
}
hash.is.all = (0, _curriable.curry)(function (objectBasis) {
var isEqual = hash.is(objectBasis);
var isEqual = hash.is(objects.shift());
for (var index = 0; index < objects.length; index++) {
if (!isEqual(objects[index])) {
for (var index = 1; index < arguments.length; ++index) {
if (!isEqual(arguments[index])) {
return false;

@@ -76,11 +72,7 @@ }

hash.is.any = (0, _curriable.curry)(function () {
for (var _len2 = arguments.length, objects = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
objects[_key2] = arguments[_key2];
}
hash.is.any = (0, _curriable.curry)(function (objectBasis) {
var isEqual = hash.is(objectBasis);
var isEqual = hash.is(objects.shift());
for (var index = 0; index < objects.length; index++) {
if (isEqual(objects[index])) {
for (var index = 1; index < arguments.length; index++) {
if (isEqual(arguments[index])) {
return true;

@@ -87,0 +79,0 @@ }

@@ -10,3 +10,3 @@ "use strict";

exports.sort = sort;
exports.getSortedIterablePairs = getSortedIterablePairs;
exports.getSortedIterable = getSortedIterable;
exports.getSortedObject = getSortedObject;

@@ -25,6 +25,3 @@ exports.getStringifiedArrayBufferFallback = getStringifiedArrayBufferFallback;

// external dependencies
// constants
var SEPARATOR = '|';
var charCodeAt = String.prototype.charCodeAt;
var FUNCTION_NAME_REGEX = /^\s*function\s*([^(]*)/i;
var toString = Object.prototype.toString;

@@ -43,3 +40,3 @@ var keys = Object.keys;

function getFunctionName(fn) {
return fn.name || (fn.toString().match(/^\s*function\s*([^\(]*)/i) || [])[1] || 'anonymous';
return fn.name || (fn.toString().match(FUNCTION_NAME_REGEX) || [])[1] || 'anonymous';
}

@@ -66,3 +63,3 @@ /**

while (index--) {
charCode = charCodeAt.call(string, index);
charCode = string.charCodeAt(index);
hashA = hashA * 33 ^ charCode;

@@ -138,3 +135,3 @@ hashB = hashB * 33 ^ charCode;

function shouldSortPair(pairA, pairB) {
return shouldSort(pairA[0], pairB[0]);
return pairA[0] > pairB[0];
}

@@ -156,6 +153,6 @@ /**

for (var index = 0; index < array.length; index++) {
for (var index = 0; index < array.length; ++index) {
value = array[index];
for (subIndex = index - 1; ~subIndex && fn(array[subIndex], value); subIndex--) {
for (subIndex = index - 1; ~subIndex && fn(array[subIndex], value); --subIndex) {
array[subIndex + 1] = array[subIndex];

@@ -180,31 +177,29 @@ }

function getSortedIterablePairs(iterable, cache, keys) {
function getSortedIterable(iterable, cache, keys) {
var isMap = typeof iterable.get === 'function';
var pairs = [];
var entries = [];
if (isMap) {
iterable.forEach(function (value, key) {
// eslint-disable-next-line no-use-before-define
pairs.push([stringify(key, cache, keys), stringify(value, cache, keys)]);
entries.push([// eslint-disable-next-line no-use-before-define
stringify(key, cache, keys), // eslint-disable-next-line no-use-before-define
stringify(value, cache, keys)]);
});
sort(entries, shouldSortPair);
} else {
iterable.forEach(function (value) {
// eslint-disable-next-line no-use-before-define
pairs.push([stringify(value, cache, keys)]);
entries.push(stringify(value, cache, keys));
});
sort(entries, shouldSort);
}
sort(pairs, shouldSortPair);
var length = pairs.length;
var lastIndex = length - 1;
var _final = '[';
var pair;
var _final = getFunctionName(iterable.constructor) + "|[";
for (var index = 0; index < length; index++) {
pair = pairs[index];
_final += isMap ? '[' + pair[0] + ',' + pair[1] + ']' : pair[0];
_final += index === lastIndex ? ']' : ',';
for (var index = 0, length = entries.length, entry; index < length; ++index) {
entry = entries[index];
_final += "" + (index ? ',' : '') + (isMap ? "[" + entry[0] + "," + entry[1] + "]" : entry);
}
return getFunctionName(iterable.constructor) + SEPARATOR + _final;
return _final + "]";
}

@@ -227,3 +222,3 @@ /**

for (var index = 0; index < objectKeys.length; index++) {
for (var index = 0; index < objectKeys.length; ++index) {
key = objectKeys[index];

@@ -315,3 +310,3 @@ newObject[key] = object[key];

for (var index = 0; index < children.length; index++) {
for (var index = 0; index < children.length; ++index) {
innerHTML += children[index].outerHTML;

@@ -336,3 +331,3 @@ }

function getCutoffIndex(array, value) {
for (var index = 0; index < array.length; index++) {
for (var index = 0; index < array.length; ++index) {
if (array[index] === value) {

@@ -363,7 +358,7 @@ return index + 1;

if (type === 'string' || _constants.PRIMITIVE_TAGS[type]) {
return type + SEPARATOR + value;
return type + "|" + value;
}
if (value === null) {
return 'null' + SEPARATOR + value;
return "null|" + value;
}

@@ -383,15 +378,15 @@ }

if (_constants.TOSTRING_TAGS[tag]) {
return _constants.OBJECT_CLASS_MAP[tag] + SEPARATOR + value.toString();
return _constants.OBJECT_CLASS_MAP[tag] + "|" + value.toString();
}
if (_constants.ITERABLE_TAGS[tag]) {
return getSortedIterablePairs(value, cache, keys);
return getSortedIterable(value, cache, keys);
}
if (tag === _constants.OBJECT_CLASS_TYPE_MAP.DATE) {
return _constants.OBJECT_CLASS_MAP[tag] + SEPARATOR + value.getTime();
return _constants.OBJECT_CLASS_MAP[tag] + "|" + value.getTime();
}
if (tag === _constants.OBJECT_CLASS_TYPE_MAP.ERROR) {
return _constants.OBJECT_CLASS_MAP[tag] + SEPARATOR + value.stack;
return _constants.OBJECT_CLASS_MAP[tag] + "|" + value.stack;
}

@@ -404,23 +399,23 @@

if (_constants.UNPARSEABLE_TAGS[tag]) {
return _constants.OBJECT_CLASS_MAP[tag] + SEPARATOR + 'NOT_ENUMERABLE';
return _constants.OBJECT_CLASS_MAP[tag] + "|NOT_ENUMERABLE";
}
if (_constants.HTML_ELEMENT_REGEXP.test(tag) || _constants.SVG_ELEMENT_REGEXP.test(tag)) {
return tag.slice(8, -1) + SEPARATOR + value.outerHTML;
return tag.slice(8, -1) + "|" + value.outerHTML;
}
if (tag === _constants.OBJECT_CLASS_TYPE_MAP.DOCUMENTFRAGMENT) {
return _constants.OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedDocumentFragment(value);
return _constants.OBJECT_CLASS_MAP[tag] + "|" + getStringifiedDocumentFragment(value);
}
if (_constants.TYPEDARRAY_TAGS[tag]) {
return _constants.OBJECT_CLASS_MAP[tag] + SEPARATOR + value.join(',');
return _constants.OBJECT_CLASS_MAP[tag] + "|" + value.join(',');
}
if (tag === _constants.OBJECT_CLASS_TYPE_MAP.ARRAYBUFFER) {
return _constants.OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedArrayBuffer(value);
return _constants.OBJECT_CLASS_MAP[tag] + "|" + getStringifiedArrayBuffer(value);
}
if (tag === _constants.OBJECT_CLASS_TYPE_MAP.DATAVIEW) {
return _constants.OBJECT_CLASS_MAP[tag] + SEPARATOR + getStringifiedArrayBuffer(value.buffer);
return _constants.OBJECT_CLASS_MAP[tag] + "|" + getStringifiedArrayBuffer(value.buffer);
}

@@ -466,4 +461,3 @@

if (valueCutoff !== 0) {
var ref = keys.slice(0, valueCutoff).join('.') || '.';
return "[~" + ref + "]";
return "[~" + (keys.slice(0, valueCutoff).join('.') || '.') + "]";
}

@@ -470,0 +464,0 @@

@@ -44,3 +44,2 @@ {

"eslint": "^5.12.0",
"eslint-config-rapid7": "^3.1.0",
"eslint-friendly-formatter": "4.0.1",

@@ -115,3 +114,3 @@ "eslint-loader": "^2.1.1",

},
"version": "4.0.5",
"version": "4.1.0",
"dependencies": {

@@ -118,0 +117,0 @@ "curriable": "^1.1.0"

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