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.3 to 4.0.4

5

CHANGELOG.md
# hashIt CHANGELOG
## 4.0.4
- Improve speed of complex objects (Objects, Arrays, Maps, Sets)
- Fix security issue with old version of `webpack-dev-server`
## 4.0.3

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

1401

dist/hash-it.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.hashIt = {})));
}(this, (function (exports) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.hashIt = {}));
}(this, function (exports) { 'use strict';
/**
* @constant {Symbol} __ the value to be used as a placeholder
*/
var __ = typeof Symbol === 'function' ? Symbol('curriable placeholder') : 0xedd1;
/**
* @constant __ placeholder used when parameters are skipped
*/
var __ = typeof Symbol === 'function' ? Symbol('curriable placeholder') : 0xedd1;
/**
* @function recursiveCurry
*
* @description
* recursively curry over the arguments until all have been resolved
*
* @param fn the function to curry
* @param arity the length of the function to curry until
* @param args the existing arguments
* @returns the result of the function call
*/
var recursiveCurry = function (fn, arity, args) {
return function () {
var length = args.length;
var newArgs = arguments;
var newArgsLength = newArgs.length;
var combined = [];
var newArgsIndex = 0;
var remaining = arity;
var value;
if (length) {
for (var index = 0; index < length; index++) {
value = combined[index] =
args[index] === __ && newArgsIndex < newArgsLength
? newArgs[newArgsIndex++]
: args[index];
if (value !== __) {
--remaining;
}
}
}
if (newArgsIndex < newArgsLength) {
for (; newArgsIndex < newArgsLength; newArgsIndex++) {
value = newArgs[newArgsIndex];
combined.push(value);
if (value !== __ && newArgsIndex < arity) {
--remaining;
}
}
}
return remaining > 0
? recursiveCurry(fn, arity, combined)
: fn.apply(this, combined);
};
};
/**
* @function getArgs
*
* @description
* get the complete args with previous placeholders being filled in
*
* @param {Arguments} originalArgs the arguments from the previous run
* @param {Arguments} nextArgs the arguments from the next run
* @returns {Array<*>} the complete list of args
*/
var getArgs = function getArgs(originalArgs, nextArgs) {
var args = new Array(originalArgs.length);
// utils
/**
* @function curry
*
* @description
* get the method passed as a curriable method based on its parameters
*
* @param fn the method to make curriable
* @param arity the arity of the curried method
* @returns the fn passed as a curried function
*/
var curry = function (fn, arity) {
if (arity === void 0) { arity = fn.length; }
var curried = recursiveCurry(fn, arity, []);
curried.arity = arity;
curried.fn = fn;
return curried;
};
curry.__ = __;
/**
* @function uncurry
*
* @description
* return a function that is the non-curried version of the fn passed
*
* @param curried the curried function to uncurry
* @returns the original fn
*/
var uncurry = function (curried) { return curried.fn; };
curry.uncurry = uncurry;
var nextArgsIndex = 0;
/**
* @function first
*
* @description
* get the first n number of items from the array as a new array (faster than native splice)
*
* @param {Array<any>} array the array to get the items from
* @param {number} length the length to limit the size to
* @returns {Array<any>} the array limited in size
*/
var first = function first(array, length) {
var newArray = new Array(length);
for (var index = 0; index < originalArgs.length; index++) {
args[index] = originalArgs[index] === __ && nextArgsIndex < nextArgs.length ? nextArgs[nextArgsIndex++] : originalArgs[index];
}
if (nextArgsIndex < nextArgs.length) {
for (; nextArgsIndex < nextArgs.length; nextArgsIndex++) {
args.push(nextArgs[nextArgsIndex]);
for (var index = 0; index < length; index++) {
newArray[index] = array[index];
}
}
return args;
};
return newArray;
};
/**
* @function getCircularValue
*
* @description
* create a method that will get a placeholder for the circular value based
* on the value saved in the cache for it
*
* @param {any} key the key of the object to stringify
* @param {any} value the value of the object at key
* @param {number} refCount the index of the ref
* @returns {string} the circular value
*/
/**
* @function hasPlaceholder
*
* @description
* determine if any of the arguments are placeholders
*
* @param {Arguments} args the args passed to the function
* @param {number} arity the arity of the function
* @returns {boolean} are any of the args placeholders
*/
var hasPlaceholder = function hasPlaceholder(args, arity) {
for (var index = 0; index < arity; index++) {
if (args[index] === __) {
return true;
var getCircularValue = function getCircularValue(key, value, refCount) {
return "[ref-" + refCount + "]";
};
/**
* @function indexOf
*
* @description
* get the index of the value in the array (faster than native indexOf)
*
* @param {Array<any>} array the array to get the index of the value at
* @param {any} value the value to match
* @returns {number} the index of the value in array
*/
var indexOf = function indexOf(array, value) {
for (var index = 0; index < array.length; index++) {
if (array[index] === value) {
return index;
}
}
}
return false;
};
return -1;
};
/**
* @function createReplacer
*
* @description
* create a replacer method that handles circular values
*
* @param {function} [replacer] a custom replacer to use for non-circular values
* @param {function} [circularReplacer] a custom replacer to use for circular methods
* @returns {any} the value to stringify
*/
// utils
var createReplacer = function createReplacer(replacer, circularReplacer) {
var getCircularReplacer = circularReplacer || getCircularValue;
var hasReplacer = typeof replacer === 'function';
var cache = [],
locationOfThis,
locationOfValue;
return function (key, value) {
if (cache.length) {
locationOfThis = indexOf(cache, this);
/**
* @function curry
*
* @description
* get the method passed as a curriable method based on its parameters
*
* @param {function} fn the method to make curriable
* @param {number} [arity=fn.length] the arity of the curried method
* @returns {function(...Array<any>): any} the fn passed as a curried function
*/
function curry(fn) {
var arity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fn.length;
if (~locationOfThis) {
cache = first(cache, locationOfThis + 1);
} else {
cache[cache.length] = this;
}
function curried() {
var args = arguments;
locationOfValue = indexOf(cache, value);
return args.length >= arity && !hasPlaceholder(args, arity) ? fn.apply(this, args) : function () {
return curried.apply(this, getArgs(args, arguments));
if (~locationOfValue) {
return getCircularReplacer.call(this, key, value, locationOfValue);
}
} else {
cache[0] = value;
}
return hasReplacer ? replacer.call(this, key, value) : value;
};
}
};
curried.arity = arity;
curried.fn = fn;
// utils
/**
* @function stringify
*
* @description
* strinigifer that handles circular values
*
* @param {any} value the value to stringify
* @param {function} [replacer] a custom replacer function for stringifying standard values
* @param {number} [indent] the number of spaces to indent the output by
* @param {function} [circularReplacer] a custom replacer function for stringifying circular values
* @returns {string} the stringified output
*/
return curried;
}
curry.__ = __;
/**
* @function uncurry
*
* @description
* return a function that is the non-curried version of the fn passed
*
* @param {function} curried the curried function to uncurry
* @returns {function} the original fn
*/
function uncurry(curried) {
return curried.fn;
}
curry.uncurry = uncurry;
/**
* @function first
*
* @description
* get the first n number of items from the array as a new array (faster than native splice)
*
* @param {Array<any>} array the array to get the items from
* @param {number} length the length to limit the size to
* @returns {Array<any>} the array limited in size
*/
var first = function first(array, length) {
var newArray = new Array(length);
for (var index = 0; index < length; index++) {
newArray[index] = array[index];
function stringify(value, replacer, indent, circularReplacer) {
return JSON.stringify(value, createReplacer(replacer, circularReplacer), indent);
}
return newArray;
};
/**
* @function getCircularValue
*
* @description
* create a method that will get a placeholder for the circular value based
* on the value saved in the cache for it
*
* @param {any} key the key of the object to stringify
* @param {any} value the value of the object at key
* @param {number} refCount the index of the ref
* @returns {string} the circular value
*/
var _SELF_TAGS, _TOSTRING_TAGS, _TYPEDARRAY_TAGS, _UNPARSEABLE_TAGS;
var getCircularValue = function getCircularValue(key, value, refCount) {
return "[ref-" + refCount + "]";
};
/**
* @function indexOf
*
* @description
* get the index of the value in the array (faster than native indexOf)
*
* @param {Array<any>} array the array to get the index of the value at
* @param {any} value the value to match
* @returns {number} the index of the value in array
*/
/**
* @constant {string} CIRCULAR_VALUE
*/
var CIRCULAR_VALUE = '~';
/**
* @constant {boolean} HAS_BUFFER_FROM_SUPPORT
*/
var indexOf = function indexOf(array, value) {
for (var index = 0; index < array.length; index++) {
if (array[index] === value) {
return index;
}
}
var HAS_BUFFER_FROM_SUPPORT = typeof Buffer !== 'undefined' && typeof Buffer.from === 'function';
/**
* @constant {boolean} HAS_UINT16ARRAY_SUPPORT
*/
return -1;
};
/**
* @function createReplacer
*
* @description
* create a replacer method that handles circular values
*
* @param {function} [replacer] a custom replacer to use for non-circular values
* @param {function} [circularReplacer] a custom replacer to use for circular methods
* @returns {any} the value to stringify
*/
var HAS_UINT16ARRAY_SUPPORT = typeof Uint16Array === 'function';
/**
* @constant {RegExp} HTML_ELEMENT_REGEXP
*/
var createReplacer = function createReplacer(replacer, circularReplacer) {
var getCircularReplacer = circularReplacer || getCircularValue;
var hasReplacer = typeof replacer === 'function';
var cache = [],
locationOfThis,
locationOfValue;
return function (key, value) {
if (cache.length) {
locationOfThis = indexOf(cache, this);
var HTML_ELEMENT_REGEXP = /\[object (HTML(.*)Element)\]/;
/**
* @constant {RegExp} SVG_ELEMENT_REGEXP
*/
if (~locationOfThis) {
cache = first(cache, locationOfThis + 1);
} else {
cache[cache.length] = this;
}
var SVG_ELEMENT_REGEXP = /\[object (SVG(.*)Element)\]/;
/**
* @constant {Array<string>} OBJECT_CLASSES
*/
locationOfValue = indexOf(cache, value);
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'];
/**
* @constant {Object} OBJECT_CLASS_MAP
*/
if (~locationOfValue) {
return getCircularReplacer.call(this, key, value, locationOfValue);
}
} else {
cache[0] = value;
}
var OBJECT_CLASS_MAP = OBJECT_CLASSES.reduce(function (objectClasses, type) {
objectClasses["[object " + type + "]"] = type;
return objectClasses;
}, {});
/**
* @constant {Object} OBJECT_CLASS_TYPE_MAP
*/
return hasReplacer ? replacer.call(this, key, value) : value;
var OBJECT_CLASS_TYPE_MAP = Object.keys(OBJECT_CLASS_MAP).reduce(function (objectClassTypes, objectClass) {
objectClassTypes[OBJECT_CLASS_MAP[objectClass].toUpperCase()] = objectClass;
return objectClassTypes;
}, {});
var ITERABLE_TAGS = {
'[object Map]': true,
'[object Set]': true
};
};
var PRIMITIVE_TAGS = {
boolean: true,
function: true,
number: true,
string: true,
undefined: true
};
var SELF_TAGS = (_SELF_TAGS = {}, _SELF_TAGS[OBJECT_CLASS_TYPE_MAP.ARGUMENTS] = true, _SELF_TAGS[OBJECT_CLASS_TYPE_MAP.ARRAY] = true, _SELF_TAGS);
var TOSTRING_TAGS = (_TOSTRING_TAGS = {}, _TOSTRING_TAGS[OBJECT_CLASS_TYPE_MAP.REGEXP] = true, _TOSTRING_TAGS[OBJECT_CLASS_TYPE_MAP.SYMBOL] = true, _TOSTRING_TAGS);
var TYPEDARRAY_TAGS = (_TYPEDARRAY_TAGS = {}, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.FLOAT32ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.FLOAT64ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.INT8ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.INT16ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.INT32ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.UINT8ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.UINT8CLAMPEDARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.UINT16ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.UINT32ARRAY] = true, _TYPEDARRAY_TAGS);
var UNPARSEABLE_TAGS = (_UNPARSEABLE_TAGS = {}, _UNPARSEABLE_TAGS[OBJECT_CLASS_TYPE_MAP.GENERATOR] = true, _UNPARSEABLE_TAGS[OBJECT_CLASS_TYPE_MAP.PROMISE] = true, _UNPARSEABLE_TAGS[OBJECT_CLASS_TYPE_MAP.WEAKMAP] = true, _UNPARSEABLE_TAGS[OBJECT_CLASS_TYPE_MAP.WEAKSET] = true, _UNPARSEABLE_TAGS);
// utils
/**
* @function stringify
*
* @description
* strinigifer that handles circular values
*
* @param {any} value the value to stringify
* @param {function} [replacer] a custom replacer function for stringifying standard values
* @param {number} [indent] the number of spaces to indent the output by
* @param {function} [circularReplacer] a custom replacer function for stringifying circular values
* @returns {string} the stringified output
*/
// external dependencies
var charCodeAt = String.prototype.charCodeAt;
var toString = Object.prototype.toString;
var keys = Object.keys;
/**
* @function getFunctionName
*
* @description
* get the name of the function based on a series of fallback attempts
*
* @param {function} fn the function to test
* @returns {string} the function name
*/
function stringify(value, replacer, indent, circularReplacer) {
return JSON.stringify(value, createReplacer(replacer, circularReplacer), indent);
}
var getFunctionName = function getFunctionName(fn) {
return fn.name || (fn.toString().match(/^\s*function\s*([^\(]*)/i) || [])[1] || 'anonymous';
};
/**
* @function getCircularValue
*
* @description
* get the value used when circular references are found
*
* @returns {string} the value for stringification
*/
var _SELF_TAGS, _TOSTRING_TAGS, _TYPEDARRAY_TAGS, _UNPARSEABLE_TAGS;
var getCircularValue$1 = function getCircularValue() {
return CIRCULAR_VALUE;
};
/**
* @function getIntegerHashValue
*
* @description
* based on string passed, get the integer hash value
* through bitwise operation (based on spinoff of dbj2
* with enhancements for reduced collisions)
*
* @param {string} string the string to get the hash value for
* @returns {number} the hash value
*/
/**
* @constant {string} CIRCULAR_VALUE
*/
var CIRCULAR_VALUE = '~';
/**
* @constant {boolean} HAS_BUFFER_FROM_SUPPORT
*/
var getIntegerHashValue = function getIntegerHashValue(string) {
var index = string.length,
hashA = 5381,
hashB = 52711,
charCode;
var HAS_BUFFER_FROM_SUPPORT = typeof Buffer !== 'undefined' && typeof Buffer.from === 'function';
/**
* @constant {boolean} HAS_UINT16ARRAY_SUPPORT
*/
while (index--) {
charCode = charCodeAt.call(string, index);
hashA = hashA * 33 ^ charCode;
hashB = hashB * 33 ^ charCode;
}
var HAS_UINT16ARRAY_SUPPORT = typeof Uint16Array === 'function';
/**
* @constant {RegExp} HTML_ELEMENT_REGEXP
*/
return (hashA >>> 0) * 4096 + (hashB >>> 0);
};
/**
* @function getSortedEvent
*
* @description
* get the event object sorted by its properties
*
* @param {boolean} bubbles does the event bubble up through the DOM
* @param {function} alias to stopPropagation
* @param {boolean} cancelable is the event cancelable
* @param {boolean} composed can the event bubble across the boundary to shadow DOM
* @param {HTMLElement} [currentTarget] registered target for the event
* @param {boolean} defaultPrevented has preventDefault been called on the event
* @param {string} eventPhase the phase of the event flow being processed
* @param {boolean} isTrusted was the event initiated by the browser
* @param {HTMLElement} [target] the target with which the event was dispatched
* @param {number} timeStamp the time at which the event was created
* @param {string} type the name of the event
* @returns {Object} the event object with all properties sorted
*/
var HTML_ELEMENT_REGEXP = /\[object (HTML(.*)Element)\]/;
/**
* @constant {RegExp} SVG_ELEMENT_REGEXP
*/
var getSortedEvent = function getSortedEvent(_ref) {
var bubbles = _ref.bubbles,
cancelBubble = _ref.cancelBubble,
cancelable = _ref.cancelable,
composed = _ref.composed,
currentTarget = _ref.currentTarget,
defaultPrevented = _ref.defaultPrevented,
eventPhase = _ref.eventPhase,
isTrusted = _ref.isTrusted,
returnValue = _ref.returnValue,
target = _ref.target,
type = _ref.type;
return {
bubbles: bubbles,
cancelBubble: cancelBubble,
cancelable: cancelable,
composed: composed,
currentTarget: currentTarget,
defaultPrevented: defaultPrevented,
eventPhase: eventPhase,
isTrusted: isTrusted,
returnValue: returnValue,
target: target,
type: type
};
};
/**
* @function shouldSort
*
* @description
* get the sort result based on the two values to compare
*
* @param {string} valueA the first value to compare
* @param {string} valueB the second value to compare
* @returns {boolean} should the value be sorted
*/
var SVG_ELEMENT_REGEXP = /\[object (SVG(.*)Element)\]/;
/**
* @constant {Array<string>} OBJECT_CLASSES
*/
var shouldSort = function shouldSort(valueA, valueB) {
return valueA > valueB;
};
/**
* @function shouldSortPair
*
* @description
* get the sort result based on the two pairs to compare
*
* @param {Object} pairA the first pair to compare
* @param {Object} pairB the second pair to compare
* @returns {boolean} should the value be sorted
*/
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'];
/**
* @constant {Object} OBJECT_CLASS_MAP
*/
var shouldSortPair = function shouldSortPair(pairA, pairB) {
return shouldSort(pairA[0], pairB[0]);
};
/**
* @function getPrefixedValue
*
* @description
* get the value prefixed by the tag
*
* @param {string} tag the object tag
* @param {any} value the value to stringify
* @returns {string} the prefixed stringified value
*/
var OBJECT_CLASS_MAP = OBJECT_CLASSES.reduce(function (objectClasses, type) {
objectClasses["[object " + type + "]"] = type;
return objectClasses;
}, {});
/**
* @constant {Object} OBJECT_CLASS_TYPE_MAP
*/
var getPrefixedValue = function getPrefixedValue(tag, value) {
return tag + "|" + value;
};
/**
* @function sort
*
* @description
* sort the array based on the fn passed
*
* @param {Array<any>} array the array to sort
* @param {function} fn the sorting function
* @returns {Array<any>} the sorted array
*/
var OBJECT_CLASS_TYPE_MAP = Object.keys(OBJECT_CLASS_MAP).reduce(function (objectClassTypes, objectClass) {
objectClassTypes[OBJECT_CLASS_MAP[objectClass].toUpperCase()] = objectClass;
return objectClassTypes;
}, {});
var ITERABLE_TAGS = {
'[object Map]': true,
'[object Set]': true
};
var PRIMITIVE_TAGS = {
boolean: true,
function: true,
number: true,
string: true,
undefined: true
};
var SELF_TAGS = (_SELF_TAGS = {}, _SELF_TAGS[OBJECT_CLASS_TYPE_MAP.ARGUMENTS] = true, _SELF_TAGS[OBJECT_CLASS_TYPE_MAP.ARRAY] = true, _SELF_TAGS);
var TOSTRING_TAGS = (_TOSTRING_TAGS = {}, _TOSTRING_TAGS[OBJECT_CLASS_TYPE_MAP.REGEXP] = true, _TOSTRING_TAGS[OBJECT_CLASS_TYPE_MAP.SYMBOL] = true, _TOSTRING_TAGS);
var TYPEDARRAY_TAGS = (_TYPEDARRAY_TAGS = {}, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.FLOAT32ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.FLOAT64ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.INT8ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.INT16ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.INT32ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.UINT8ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.UINT8CLAMPEDARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.UINT16ARRAY] = true, _TYPEDARRAY_TAGS[OBJECT_CLASS_TYPE_MAP.UINT32ARRAY] = true, _TYPEDARRAY_TAGS);
var UNPARSEABLE_TAGS = (_UNPARSEABLE_TAGS = {}, _UNPARSEABLE_TAGS[OBJECT_CLASS_TYPE_MAP.GENERATOR] = true, _UNPARSEABLE_TAGS[OBJECT_CLASS_TYPE_MAP.PROMISE] = true, _UNPARSEABLE_TAGS[OBJECT_CLASS_TYPE_MAP.WEAKMAP] = true, _UNPARSEABLE_TAGS[OBJECT_CLASS_TYPE_MAP.WEAKSET] = true, _UNPARSEABLE_TAGS);
var sort = function sort(array, fn) {
var subIndex, value;
// external dependencies
var charCodeAt = String.prototype.charCodeAt;
var toString = Object.prototype.toString;
var keys = Object.keys;
/**
* @function getFunctionName
*
* @description
* get the name of the function based on a series of fallback attempts
*
* @param {function} fn the function to test
* @returns {string} the function name
*/
for (var index = 0; index < array.length; index++) {
value = array[index];
var getFunctionName = function getFunctionName(fn) {
return fn.name || (fn.toString().match(/^\s*function\s*([^\(]*)/i) || [])[1] || 'anonymous';
};
/**
* @function getCircularValue
*
* @description
* get the value used when circular references are found
*
* @returns {string} the value for stringification
*/
for (subIndex = index - 1; ~subIndex && fn(array[subIndex], value); subIndex--) {
array[subIndex + 1] = array[subIndex];
}
var getCircularValue$1 = function getCircularValue() {
return CIRCULAR_VALUE;
};
/**
* @function getIntegerHashValue
*
* @description
* based on string passed, get the integer hash value
* through bitwise operation (based on spinoff of dbj2
* with enhancements for reduced collisions)
*
* @param {string} string the string to get the hash value for
* @returns {number} the hash value
*/
array[subIndex + 1] = value;
}
var getIntegerHashValue = function getIntegerHashValue(string) {
var index = string.length,
hashA = 5381,
hashB = 52711,
charCode;
return array;
};
/**
* @function getIterablePairs
*
* @description
* get the pairs in the iterable for stringification
*
* @param {Map|Set} iterable the iterable to get the pairs for
* @returns {Array<{key: string, value: any}>} the pairs
*/
while (index--) {
charCode = charCodeAt.call(string, index);
hashA = hashA * 33 ^ charCode;
hashB = hashB * 33 ^ charCode;
}
var getSortedIterablePairs = function getSortedIterablePairs(iterable) {
var isMap = typeof iterable.get === 'function';
var pairs = [];
iterable.forEach(function (value, key) {
// eslint-disable-next-line no-use-before-define
pairs.push(isMap ? [stringify$1(key), stringify$1(value)] : [stringify$1(value)]);
});
sort(pairs, shouldSortPair);
var finalPairs = new Array(iterable.size);
var pair;
return (hashA >>> 0) * 4096 + (hashB >>> 0);
};
/**
* @function getSortedEvent
*
* @description
* get the event object sorted by its properties
*
* @param {boolean} bubbles does the event bubble up through the DOM
* @param {function} alias to stopPropagation
* @param {boolean} cancelable is the event cancelable
* @param {boolean} composed can the event bubble across the boundary to shadow DOM
* @param {HTMLElement} [currentTarget] registered target for the event
* @param {boolean} defaultPrevented has preventDefault been called on the event
* @param {string} eventPhase the phase of the event flow being processed
* @param {boolean} isTrusted was the event initiated by the browser
* @param {HTMLElement} [target] the target with which the event was dispatched
* @param {number} timeStamp the time at which the event was created
* @param {string} type the name of the event
* @returns {Object} the event object with all properties sorted
*/
for (var index = 0; index < iterable.size; index++) {
pair = pairs[index];
finalPairs[index] = isMap ? "[" + pair[0] + "," + pair[1] + "]" : pair[0];
}
var getSortedEvent = function getSortedEvent(_ref) {
var bubbles = _ref.bubbles,
cancelBubble = _ref.cancelBubble,
cancelable = _ref.cancelable,
composed = _ref.composed,
currentTarget = _ref.currentTarget,
defaultPrevented = _ref.defaultPrevented,
eventPhase = _ref.eventPhase,
isTrusted = _ref.isTrusted,
returnValue = _ref.returnValue,
target = _ref.target,
type = _ref.type;
return {
bubbles: bubbles,
cancelBubble: cancelBubble,
cancelable: cancelable,
composed: composed,
currentTarget: currentTarget,
defaultPrevented: defaultPrevented,
eventPhase: eventPhase,
isTrusted: isTrusted,
returnValue: returnValue,
target: target,
type: type
return getPrefixedValue(getFunctionName(iterable.constructor), "[" + finalPairs.join(',') + "]");
};
};
/**
* @function shouldSort
*
* @description
* get the sort result based on the two values to compare
*
* @param {string} valueA the first value to compare
* @param {string} valueB the second value to compare
* @returns {boolean} should the value be sorted
*/
/**
* @function getSortedObject
*
* @description
* get the object with the keys sorted
*
* @param {Object} object the object to sort
* @returns {Object} the sorted object
*/
var shouldSort = function shouldSort(valueA, valueB) {
return valueA > valueB;
};
/**
* @function shouldSortPair
*
* @description
* get the sort result based on the two pairs to compare
*
* @param {Object} pairA the first pair to compare
* @param {Object} pairB the second pair to compare
* @returns {boolean} should the value be sorted
*/
var getSortedObject = function getSortedObject(object) {
var objectKeys = sort(keys(object), shouldSort);
var newObject = {};
var key;
var shouldSortPair = function shouldSortPair(pairA, pairB) {
return shouldSort(pairA[0], pairB[0]);
};
/**
* @function getPrefixedValue
*
* @description
* get the value prefixed by the tag
*
* @param {string} tag the object tag
* @param {any} value the value to stringify
* @returns {string} the prefixed stringified value
*/
var getPrefixedValue = function getPrefixedValue(tag, value) {
return tag + "|" + value;
};
/**
* @function sort
*
* @description
* sort the array based on the fn passed
*
* @param {Array<any>} array the array to sort
* @param {function} fn the sorting function
* @returns {Array<any>} the sorted array
*/
var sort = function sort(array, fn) {
var subIndex, value;
for (var index = 0; index < array.length; index++) {
value = array[index];
for (subIndex = index - 1; ~subIndex && fn(array[subIndex], value); subIndex--) {
array[subIndex + 1] = array[subIndex];
for (var index = 0; index < objectKeys.length; index++) {
key = objectKeys[index];
newObject[key] = object[key];
}
array[subIndex + 1] = value;
}
return newObject;
};
/**
* @function getStringifiedArrayBufferFallback
*
* @description
* get the string value of the buffer passed based on a Buffer
*
* @param {ArrayBuffer} buffer the array buffer to convert
* @returns {string} the stringified buffer
*/
return array;
};
/**
* @function getIterablePairs
*
* @description
* get the pairs in the iterable for stringification
*
* @param {Map|Set} iterable the iterable to get the pairs for
* @returns {Array<{key: string, value: any}>} the pairs
*/
var getStringifiedArrayBufferFallback = function getStringifiedArrayBufferFallback(buffer) {
return String.fromCharCode.apply(null, new Uint16Array(buffer));
};
/**
* @function getStringifiedArrayBufferModern
*
* @description
* get the string value of the buffer passed based on a Uint16Array
*
* @param {ArrayBuffer} buffer the array buffer to convert
* @returns {string} the stringified buffer
*/
var getSortedIterablePairs = function getSortedIterablePairs(iterable) {
var isMap = typeof iterable.get === 'function';
var pairs = [];
iterable.forEach(function (value, key) {
// eslint-disable-next-line no-use-before-define
pairs.push(isMap ? [stringify$1(key), stringify$1(value)] : [stringify$1(value)]);
});
sort(pairs, shouldSortPair);
var finalPairs = new Array(iterable.size);
var pair;
var getStringifiedArrayBufferModern = function getStringifiedArrayBufferModern(buffer) {
return Buffer.from(buffer).toString('utf8');
};
/**
* @function getStringifiedArrayBufferNoSupport
*
* @description
* return a placeholder when no arraybuffer support exists
*
* @returns {string} the placeholder
*/
for (var index = 0; index < iterable.size; index++) {
pair = pairs[index];
finalPairs[index] = isMap ? "[" + pair[0] + "," + pair[1] + "]" : pair[0];
}
var getStringifiedArrayBufferNoSupport = function getStringifiedArrayBufferNoSupport() {
return '';
};
/**
* @function getStringifiedArrayBuffer
*
* @description
* get the string value of the buffer passed
*
* @param {ArrayBuffer} buffer the array buffer to convert
* @returns {string} the stringified buffer
*/
return getPrefixedValue(getFunctionName(iterable.constructor), "[" + finalPairs.join(',') + "]");
};
/**
* @function getSortedObject
*
* @description
* get the object with the keys sorted
*
* @param {Object} object the object to sort
* @returns {Object} the sorted object
*/
var getStringifiedArrayBuffer = function () {
if (HAS_BUFFER_FROM_SUPPORT) {
return getStringifiedArrayBufferModern;
}
var getSortedObject = function getSortedObject(object) {
var objectKeys = sort(keys(object), shouldSort);
var newObject = {};
var key;
if (HAS_UINT16ARRAY_SUPPORT) {
return getStringifiedArrayBufferFallback;
}
for (var index = 0; index < objectKeys.length; index++) {
key = objectKeys[index];
newObject[key] = object[key];
}
return getStringifiedArrayBufferNoSupport;
}();
/**
* @function getStringifiedDocumentFragment
*
* @description
* build a string based on all the fragment's children
*
* @param {DocumentFragment} fragment the fragment to stringify
* @returns {string} the stringified fragment
*/
return newObject;
};
/**
* @function getStringifiedArrayBufferFallback
*
* @description
* get the string value of the buffer passed based on a Buffer
*
* @param {ArrayBuffer} buffer the array buffer to convert
* @returns {string} the stringified buffer
*/
var getStringifiedDocumentFragment = function getStringifiedDocumentFragment(fragment) {
var children = fragment.children;
var innerHTML = '';
var getStringifiedArrayBufferFallback = function getStringifiedArrayBufferFallback(buffer) {
return String.fromCharCode.apply(null, new Uint16Array(buffer));
};
/**
* @function getStringifiedArrayBufferModern
*
* @description
* get the string value of the buffer passed based on a Uint16Array
*
* @param {ArrayBuffer} buffer the array buffer to convert
* @returns {string} the stringified buffer
*/
for (var index = 0; index < children.length; index++) {
innerHTML += children[index].outerHTML;
}
var getStringifiedArrayBufferModern = function getStringifiedArrayBufferModern(buffer) {
return Buffer.from(buffer).toString('utf8');
};
/**
* @function getStringifiedArrayBufferNoSupport
*
* @description
* return a placeholder when no arraybuffer support exists
*
* @returns {string} the placeholder
*/
return innerHTML;
};
/**
* @function indexOf
*
* @description
* get the index of the value in the array (faster than native indexOf)
*
* @param {Array<any>} array the array to get the index of the value at
* @param {any} value the value to match
* @returns {number} the index of the value in array
*/
var getStringifiedArrayBufferNoSupport = function getStringifiedArrayBufferNoSupport() {
return '';
};
/**
* @function getStringifiedArrayBuffer
*
* @description
* get the string value of the buffer passed
*
* @param {ArrayBuffer} buffer the array buffer to convert
* @returns {string} the stringified buffer
*/
var indexOf$1 = function indexOf(array, value) {
for (var index = 0; index < array.length; index++) {
if (array[index] === value) {
return index;
}
}
var getStringifiedArrayBuffer = function () {
return HAS_BUFFER_FROM_SUPPORT ? getStringifiedArrayBufferModern : HAS_UINT16ARRAY_SUPPORT ? getStringifiedArrayBufferFallback : getStringifiedArrayBufferNoSupport;
}();
/**
* @function getStringifiedDocumentFragment
*
* @description
* build a string based on all the fragment's children
*
* @param {DocumentFragment} fragment the fragment to stringify
* @returns {string} the stringified fragment
*/
return -1;
};
/**
* @function getNormalizedValue
*
* @description
* get the value normalized for stringification
*
* @param {any} value the value to normalize
* @param {WeakMap|Object} sortedCache the cache of sorted objects
* @param {string} [passedTag] the previously-calculated tag
* @returns {any} the normalized value
*/
var getStringifiedDocumentFragment = function getStringifiedDocumentFragment(fragment) {
var children = fragment.children;
var innerHTML = '';
var getNormalizedValue = function getNormalizedValue(value, sortedCache, passedTag) {
if (passedTag === void 0) {
var type = typeof value;
for (var index = 0; index < children.length; index++) {
// eslint-disable-next-line no-use-before-define
innerHTML += children[index].outerHTML;
}
if (type === 'string') {
return value;
}
return innerHTML;
};
/**
* @function indexOf
*
* @description
* get the index of the value in the array (faster than native indexOf)
*
* @param {Array<any>} array the array to get the index of the value at
* @param {any} value the value to match
* @returns {number} the index of the value in array
*/
if (PRIMITIVE_TAGS[type]) {
return getPrefixedValue(type, value);
}
var indexOf$1 = function indexOf(array, value) {
for (var index = 0; index < array.length; index++) {
if (array[index] === value) {
return index;
if (value === null) {
return getPrefixedValue('null', value);
}
}
}
return -1;
};
/**
* @function getNormalizedValue
*
* @description
* get the value normalized for stringification
*
* @param {any} value the value to normalize
* @param {WeakMap|Object} sortedCache the cache of sorted objects
* @returns {any} the normalized value
*/
var tag = passedTag || toString.call(value);
var getNormalizedValue = function getNormalizedValue(value, sortedCache) {
var type = typeof value;
if (SELF_TAGS[tag]) {
return value;
}
if (type === 'string') {
return value;
}
if (tag === OBJECT_CLASS_TYPE_MAP.OBJECT) {
if (~indexOf$1(sortedCache, value)) {
return CIRCULAR_VALUE;
}
if (PRIMITIVE_TAGS[type]) {
return getPrefixedValue(type, value);
}
sortedCache.push(value);
return getSortedObject(value, sortedCache);
}
if (value === null) {
return getPrefixedValue('null', value);
}
if (TOSTRING_TAGS[tag]) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], value.toString());
}
var tag = toString.call(value);
if (ITERABLE_TAGS[tag]) {
if (~indexOf$1(sortedCache, value)) {
return CIRCULAR_VALUE;
}
if (SELF_TAGS[tag]) {
return value;
}
sortedCache.push(value);
return getSortedIterablePairs(value);
}
if (tag === OBJECT_CLASS_TYPE_MAP.OBJECT) {
if (~indexOf$1(sortedCache, value)) {
return CIRCULAR_VALUE;
if (tag === OBJECT_CLASS_TYPE_MAP.DATE) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], value.getTime());
}
sortedCache.push(value);
return getSortedObject(value, sortedCache);
}
if (tag === OBJECT_CLASS_TYPE_MAP.ERROR) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], value.stack);
}
if (TOSTRING_TAGS[tag]) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], value.toString());
}
if (tag === OBJECT_CLASS_TYPE_MAP.EVENT) {
return getSortedEvent(value);
}
if (ITERABLE_TAGS[tag]) {
if (~indexOf$1(sortedCache, value)) {
return CIRCULAR_VALUE;
if (UNPARSEABLE_TAGS[tag]) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], 'NOT_ENUMERABLE');
}
sortedCache.push(value);
return getSortedIterablePairs(value);
}
if (HTML_ELEMENT_REGEXP.test(tag) || SVG_ELEMENT_REGEXP.test(tag)) {
return getPrefixedValue(tag.slice(8, -1), value.outerHTML);
}
if (tag === OBJECT_CLASS_TYPE_MAP.DATE) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], value.getTime());
}
if (tag === OBJECT_CLASS_TYPE_MAP.DOCUMENTFRAGMENT) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], getStringifiedDocumentFragment(value));
}
if (tag === OBJECT_CLASS_TYPE_MAP.ERROR) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], value.stack);
}
if (TYPEDARRAY_TAGS[tag]) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], value.join(','));
}
if (tag === OBJECT_CLASS_TYPE_MAP.EVENT) {
return getSortedEvent(value);
}
if (tag === OBJECT_CLASS_TYPE_MAP.ARRAYBUFFER) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], getStringifiedArrayBuffer(value));
}
if (UNPARSEABLE_TAGS[tag]) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], 'NOT_ENUMERABLE');
}
if (tag === OBJECT_CLASS_TYPE_MAP.DATAVIEW) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], getStringifiedArrayBuffer(value.buffer));
}
if (HTML_ELEMENT_REGEXP.test(tag) || SVG_ELEMENT_REGEXP.test(tag)) {
return getPrefixedValue(tag.slice(8, -1), value.outerHTML);
}
return value;
};
/**
* @function replacer
*
* @description
* create the replacer function used for stringification
*
* @param {WeakSet|Object} sortedCache the cache to use for sorting objects
* @returns {function(key: string, value: any)} function getting the normalized value
*/
if (tag === OBJECT_CLASS_TYPE_MAP.DOCUMENTFRAGMENT) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], getStringifiedDocumentFragment(value));
}
var createReplacer$1 = function createReplacer(sortedCache) {
return function (key, value) {
return getNormalizedValue(value, sortedCache);
};
};
/**
* @function stringify
*
* @description
* stringify the value based on the options passed
*
* @param {any} value the value to stringify
* @returns {string} the stringified value
*/
if (TYPEDARRAY_TAGS[tag]) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], value.join(','));
}
function stringify$1(value) {
if (!value || typeof value !== 'object') {
return getNormalizedValue(value);
}
if (tag === OBJECT_CLASS_TYPE_MAP.ARRAYBUFFER) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], getStringifiedArrayBuffer(value));
var tag = toString.call(value);
return tag === OBJECT_CLASS_TYPE_MAP.DATE || tag === OBJECT_CLASS_TYPE_MAP.REGEXP ? getNormalizedValue(value, void 0, tag) : stringify(value, createReplacer$1([]), null, getCircularValue$1);
}
if (tag === OBJECT_CLASS_TYPE_MAP.DATAVIEW) {
return getPrefixedValue(OBJECT_CLASS_MAP[tag], getStringifiedArrayBuffer(value.buffer));
}
// external dependencies
/**
* @function hash
*
* @description
* hash the value passed to a unique, consistent hash value
*
* @param {any} value the value to hash
* @returns {number} the object hash
*/
return value;
};
/**
* @function replacer
*
* @description
* create the replacer function used for stringification
*
* @param {WeakSet|Object} sortedCache the cache to use for sorting objects
* @returns {function(key: string, value: any)} function getting the normalized value
*/
var createReplacer$1 = function createReplacer(sortedCache) {
return function (key, value) {
return getNormalizedValue(value, sortedCache);
var hash = function hash(value) {
return getIntegerHashValue(stringify$1(value));
};
};
/**
* @function stringify
*
* @description
* stringify the value based on the options passed
*
* @param {any} value the value to stringify
* @returns {string} the stringified value
*/
/**
* @function hash.is
*
* @description
* create a comparator for the first object passed to determine if the second is equal
*
* @param {any} object the object to test against
* @returns {function(any): boolean} the method to test against the object
*/
function stringify$1(value) {
return typeof value === 'object' && value && !(value instanceof RegExp || value instanceof Date) ? stringify(value, createReplacer$1([]), null, getCircularValue$1) : getNormalizedValue(value);
}
hash.is = curry(function (object, otherObject) {
return hash(object) === hash(otherObject);
});
/**
* @function hash.is.all
*
* @description
* determine if all of the objects passed are equal in value to the first
*
* @param {...Array<any>} objects the objects to test for equality
* @returns {boolean} are the objects equal
*/
// external dependencies
/**
* @function hash
*
* @description
* hash the value passed to a unique, consistent hash value
*
* @param {any} value the value to hash
* @returns {number} the object hash
*/
hash.is.all = curry(function () {
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
objects[_key] = arguments[_key];
}
var hash = function hash(value) {
return getIntegerHashValue(stringify$1(value));
};
/**
* @function hash.is
*
* @description
* create a comparator for the first object passed to determine if the second is equal
*
* @param {any} object the object to test against
* @returns {function(any): boolean} the method to test against the object
*/
var isEqual = hash.is(objects.shift());
hash.is = curry(function (object, otherObject) {
return hash(object) === hash(otherObject);
});
/**
* @function hash.is.all
*
* @description
* determine if all of the objects passed are equal in value to the first
*
* @param {...Array<any>} objects the objects to test for equality
* @returns {boolean} are the objects equal
*/
for (var index = 0; index < objects.length; index++) {
if (!isEqual(objects[index])) {
return false;
}
}
hash.is.all = curry(function () {
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
objects[_key] = arguments[_key];
}
return true;
}, 2);
/**
* @function hash.is.any
*
* @description
* determine if any of the objects passed are equal in value to the first
*
* @param {...Array<any>} objects the objects to test for equality
* @returns {boolean} are the objects equal
*/
var isEqual = hash.is(objects.shift());
for (var index = 0; index < objects.length; index++) {
if (!isEqual(objects[index])) {
return false;
hash.is.any = curry(function () {
for (var _len2 = arguments.length, objects = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
objects[_key2] = arguments[_key2];
}
}
return true;
}, 2);
/**
* @function hash.is.any
*
* @description
* determine if any of the objects passed are equal in value to the first
*
* @param {...Array<any>} objects the objects to test for equality
* @returns {boolean} are the objects equal
*/
var isEqual = hash.is(objects.shift());
hash.is.any = curry(function () {
for (var _len2 = arguments.length, objects = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
objects[_key2] = arguments[_key2];
}
var isEqual = hash.is(objects.shift());
for (var index = 0; index < objects.length; index++) {
if (isEqual(objects[index])) {
return true;
for (var index = 0; index < objects.length; index++) {
if (isEqual(objects[index])) {
return true;
}
}
}
return false;
}, 2);
/**
* @function hash.is.not
*
* @description
* create a comparator for the first object passed to determine if the second is not equal
*
* @param {any} object the object to test against
* @returns {function(any): boolean} the method to test against the object
*/
return false;
}, 2);
/**
* @function hash.is.not
*
* @description
* create a comparator for the first object passed to determine if the second is not equal
*
* @param {any} object the object to test against
* @returns {function(any): boolean} the method to test against the object
*/
hash.is.not = curry(function (object, otherObject) {
return hash(object) !== hash(otherObject);
});
hash.is.not = curry(function (object, otherObject) {
return hash(object) !== hash(otherObject);
});
exports.hash = hash;
exports.default = hash;
exports.hash = hash;
exports.default = hash;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));
//# sourceMappingURL=hash-it.js.map

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

!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.hashIt={})}(this,function(n){"use strict";var o="function"==typeof Symbol?Symbol("curriable placeholder"):60881;function r(r){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:r.length;function e(){var n=arguments;return n.length>=t&&!function(n,r){for(var t=0;t<r;t++)if(n[t]===o)return!0;return!1}(n,t)?r.apply(this,n):function(){return e.apply(this,function(n,r){for(var t=new Array(n.length),e=0,u=0;u<n.length;u++)t[u]=n[u]===o&&e<r.length?r[e++]:n[u];if(e<r.length)for(;e<r.length;e++)t.push(r[e]);return t}(n,arguments))}}return e.arity=t,e.fn=r,e}r.__=o,r.uncurry=function(n){return n.fn};var t,e,u,f,a=function(n,r,t){return"[ref-"+t+"]"},c=function(n,r){for(var t=0;t<n.length;t++)if(n[t]===r)return t;return-1},i=function(t,n){var e,u,o=n||a,f="function"==typeof t,i=[];return function(n,r){if(i.length){if(~(e=c(i,this))?i=function(n,r){for(var t=new Array(r),e=0;e<r;e++)t[e]=n[e];return t}(i,e+1):i[i.length]=this,~(u=c(i,r)))return o.call(this,n,r,u)}else i[0]=r;return f?t.call(this,n,r):r}};var l="undefined"!=typeof Buffer&&"function"==typeof Buffer.from,s="function"==typeof Uint16Array,A=/\[object (HTML(.*)Element)\]/,y=/\[object (SVG(.*)Element)\]/,h=["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(n,r){return n["[object "+r+"]"]=r,n},{}),p=Object.keys(h).reduce(function(n,r){return n[h[r].toUpperCase()]=r,n},{}),g={"[object Map]":!0,"[object Set]":!0},R={boolean:!0,function:!0,number:!0,string:!0,undefined:!0},d=((t={})[p.ARGUMENTS]=!0,t[p.ARRAY]=!0,t),b=((e={})[p.REGEXP]=!0,e[p.SYMBOL]=!0,e),v=((u={})[p.FLOAT32ARRAY]=!0,u[p.FLOAT64ARRAY]=!0,u[p.INT8ARRAY]=!0,u[p.INT16ARRAY]=!0,u[p.INT32ARRAY]=!0,u[p.UINT8ARRAY]=!0,u[p.UINT8CLAMPEDARRAY]=!0,u[p.UINT16ARRAY]=!0,u[p.UINT32ARRAY]=!0,u),E=((f={})[p.GENERATOR]=!0,f[p.PROMISE]=!0,f[p.WEAKMAP]=!0,f[p.WEAKSET]=!0,f),T=String.prototype.charCodeAt,m=Object.prototype.toString,S=Object.keys,N=function(){return"~"},M=function(n,r){return r<n},U=function(n,r){return M(n[0],r[0])},O=function(n,r){return n+"|"+r},j=function(n,r){for(var t,e,u=0;u<n.length;u++){for(e=n[u],t=u-1;~t&&r(n[t],e);t--)n[t+1]=n[t];n[t+1]=e}return n},I=l?function(n){return Buffer.from(n).toString("utf8")}:s?function(n){return String.fromCharCode.apply(null,new Uint16Array(n))}:function(){return""},Y=function(n,r){for(var t=0;t<n.length;t++)if(n[t]===r)return t;return-1},B=function(n,r){var t=typeof n;if("string"===t)return n;if(R[t])return O(t,n);if(null===n)return O("null",n);var e,u=m.call(n);return d[u]?n:u===p.OBJECT?~Y(r,n)?"~":(r.push(n),function(n){for(var r,t=j(S(n),M),e={},u=0;u<t.length;u++)e[r=t[u]]=n[r];return e}(n)):b[u]?O(h[u],n.toString()):g[u]?~Y(r,n)?"~":(r.push(n),function(n){var t="function"==typeof n.get,e=[];n.forEach(function(n,r){e.push(t?[P(r),P(n)]:[P(n)])}),j(e,U);for(var r,u,o=new Array(n.size),f=0;f<n.size;f++)r=e[f],o[f]=t?"["+r[0]+","+r[1]+"]":r[0];return O((u=n.constructor).name||(u.toString().match(/^\s*function\s*([^\(]*)/i)||[])[1]||"anonymous","["+o.join(",")+"]")}(n)):u===p.DATE?O(h[u],n.getTime()):u===p.ERROR?O(h[u],n.stack):u===p.EVENT?{bubbles:(e=n).bubbles,cancelBubble:e.cancelBubble,cancelable:e.cancelable,composed:e.composed,currentTarget:e.currentTarget,defaultPrevented:e.defaultPrevented,eventPhase:e.eventPhase,isTrusted:e.isTrusted,returnValue:e.returnValue,target:e.target,type:e.type}:E[u]?O(h[u],"NOT_ENUMERABLE"):A.test(u)||y.test(u)?O(u.slice(8,-1),n.outerHTML):u===p.DOCUMENTFRAGMENT?O(h[u],function(n){for(var r=n.children,t="",e=0;e<r.length;e++)t+=r[e].outerHTML;return t}(n)):v[u]?O(h[u],n.join(",")):u===p.ARRAYBUFFER?O(h[u],I(n)):u===p.DATAVIEW?O(h[u],I(n.buffer)):n},F=function(t){return function(n,r){return B(r,t)}};function P(n){return"object"==typeof n&&n&&!(n instanceof RegExp||n instanceof Date)?(r=n,t=F([]),e=null,u=N,JSON.stringify(r,i(t,u),e)):B(n);var r,t,e,u}var L=function(n){return function(n){for(var r,t=n.length,e=5381,u=52711;t--;)e=33*e^(r=T.call(n,t)),u=33*u^r;return 4096*(e>>>0)+(u>>>0)}(P(n))};(L.is=r(function(n,r){return L(n)===L(r)})).all=r(function(){for(var n=arguments.length,r=new Array(n),t=0;t<n;t++)r[t]=arguments[t];for(var e=L.is(r.shift()),u=0;u<r.length;u++)if(!e(r[u]))return!1;return!0},2),L.is.any=r(function(){for(var n=arguments.length,r=new Array(n),t=0;t<n;t++)r[t]=arguments[t];for(var e=L.is(r.shift()),u=0;u<r.length;u++)if(e(r[u]))return!0;return!1},2),L.is.not=r(function(n,r){return L(n)!==L(r)}),n.hash=L,n.default=L,Object.defineProperty(n,"__esModule",{value:!0})});
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((r=r||self).hashIt={})}(this,function(r){"use strict";var s="function"==typeof Symbol?Symbol("curriable placeholder"):60881,A=function(a,c,l){return function(){var r,n=l.length,t=arguments,e=t.length,u=[],o=0,f=c;if(n)for(var i=0;i<n;i++)(r=u[i]=l[i]===s&&o<e?t[o++]:l[i])!==s&&--f;if(o<e)for(;o<e;o++)r=t[o],u.push(r),r!==s&&o<c&&--f;return 0<f?A(a,c,u):a.apply(this,u)}},n=function(r,n){void 0===n&&(n=r.length);var t=A(r,n,[]);return t.arity=n,t.fn=r,t};n.__=s;n.uncurry=function(r){return r.fn};var t,e,u,o,a=function(r,n,t){return"[ref-"+t+"]"},c=function(r,n){for(var t=0;t<r.length;t++)if(r[t]===n)return t;return-1},f=function(t,r){var e,u,o=r||a,f="function"==typeof t,i=[];return function(r,n){if(i.length){if(~(e=c(i,this))?i=function(r,n){for(var t=new Array(n),e=0;e<n;e++)t[e]=r[e];return t}(i,e+1):i[i.length]=this,~(u=c(i,n)))return o.call(this,r,n,u)}else i[0]=n;return f?t.call(this,r,n):n}};var i="undefined"!=typeof Buffer&&"function"==typeof Buffer.from,l="function"==typeof Uint16Array,y=/\[object (HTML(.*)Element)\]/,h=/\[object (SVG(.*)Element)\]/,p=["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(r,n){return r["[object "+n+"]"]=n,r},{}),d=Object.keys(p).reduce(function(r,n){return r[p[n].toUpperCase()]=n,r},{}),R={"[object Map]":!0,"[object Set]":!0},g={boolean:!0,function:!0,number:!0,string:!0,undefined:!0},v=((t={})[d.ARGUMENTS]=!0,t[d.ARRAY]=!0,t),b=((e={})[d.REGEXP]=!0,e[d.SYMBOL]=!0,e),E=((u={})[d.FLOAT32ARRAY]=!0,u[d.FLOAT64ARRAY]=!0,u[d.INT8ARRAY]=!0,u[d.INT16ARRAY]=!0,u[d.INT32ARRAY]=!0,u[d.UINT8ARRAY]=!0,u[d.UINT8CLAMPEDARRAY]=!0,u[d.UINT16ARRAY]=!0,u[d.UINT32ARRAY]=!0,u),T=((o={})[d.GENERATOR]=!0,o[d.PROMISE]=!0,o[d.WEAKMAP]=!0,o[d.WEAKSET]=!0,o),m=String.prototype.charCodeAt,S=Object.prototype.toString,N=Object.keys,M=function(){return"~"},U=function(r,n){return n<r},O=function(r,n){return U(r[0],n[0])},j=function(r,n){return r+"|"+n},I=function(r,n){for(var t,e,u=0;u<r.length;u++){for(e=r[u],t=u-1;~t&&n(r[t],e);t--)r[t+1]=r[t];r[t+1]=e}return r},Y=i?function(r){return Buffer.from(r).toString("utf8")}:l?function(r){return String.fromCharCode.apply(null,new Uint16Array(r))}:function(){return""},B=function(r,n){for(var t=0;t<r.length;t++)if(r[t]===n)return t;return-1},P=function(r,n,t){if(void 0===t){var e=typeof r;if("string"===e)return r;if(g[e])return j(e,r);if(null===r)return j("null",r)}var u,o=t||S.call(r);return v[o]?r:o===d.OBJECT?~B(n,r)?"~":(n.push(r),function(r){for(var n,t=I(N(r),U),e={},u=0;u<t.length;u++)e[n=t[u]]=r[n];return e}(r)):b[o]?j(p[o],r.toString()):R[o]?~B(n,r)?"~":(n.push(r),function(r){var t="function"==typeof r.get,e=[];r.forEach(function(r,n){e.push(t?[L(n),L(r)]:[L(r)])}),I(e,O);for(var n,u,o=new Array(r.size),f=0;f<r.size;f++)n=e[f],o[f]=t?"["+n[0]+","+n[1]+"]":n[0];return j((u=r.constructor).name||(u.toString().match(/^\s*function\s*([^\(]*)/i)||[])[1]||"anonymous","["+o.join(",")+"]")}(r)):o===d.DATE?j(p[o],r.getTime()):o===d.ERROR?j(p[o],r.stack):o===d.EVENT?{bubbles:(u=r).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}:T[o]?j(p[o],"NOT_ENUMERABLE"):y.test(o)||h.test(o)?j(o.slice(8,-1),r.outerHTML):o===d.DOCUMENTFRAGMENT?j(p[o],function(r){for(var n=r.children,t="",e=0;e<n.length;e++)t+=n[e].outerHTML;return t}(r)):E[o]?j(p[o],r.join(",")):o===d.ARRAYBUFFER?j(p[o],Y(r)):o===d.DATAVIEW?j(p[o],Y(r.buffer)):r},F=function(t){return function(r,n){return P(n,t)}};function L(r){if(!r||"object"!=typeof r)return P(r);var n,t,e,u,o=S.call(r);return o===d.DATE||o===d.REGEXP?P(r,void 0,o):(n=r,t=F([]),e=null,u=M,JSON.stringify(n,f(t,u),e))}var C=function(r){return function(r){for(var n,t=r.length,e=5381,u=52711;t--;)e=33*e^(n=m.call(r,t)),u=33*u^n;return 4096*(e>>>0)+(u>>>0)}(L(r))};(C.is=n(function(r,n){return C(r)===C(n)})).all=n(function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];for(var e=C.is(n.shift()),u=0;u<n.length;u++)if(!e(n[u]))return!1;return!0},2),C.is.any=n(function(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++)n[t]=arguments[t];for(var e=C.is(n.shift()),u=0;u<n.length;u++)if(e(n[u]))return!0;return!1},2),C.is.not=n(function(r,n){return C(r)!==C(n)}),r.hash=C,r.default=C,Object.defineProperty(r,"__esModule",{value:!0})});

@@ -272,3 +272,11 @@ // external dependencies

export var getStringifiedArrayBuffer = function () {
return HAS_BUFFER_FROM_SUPPORT ? getStringifiedArrayBufferModern : HAS_UINT16ARRAY_SUPPORT ? getStringifiedArrayBufferFallback : getStringifiedArrayBufferNoSupport;
if (HAS_BUFFER_FROM_SUPPORT) {
return getStringifiedArrayBufferModern;
}
if (HAS_UINT16ARRAY_SUPPORT) {
return getStringifiedArrayBufferFallback;
}
return getStringifiedArrayBufferNoSupport;
}();

@@ -290,3 +298,2 @@ /**

for (var index = 0; index < children.length; index++) {
// eslint-disable-next-line no-use-before-define
innerHTML += children[index].outerHTML;

@@ -325,21 +332,24 @@ }

* @param {WeakMap|Object} sortedCache the cache of sorted objects
* @param {string} [passedTag] the previously-calculated tag
* @returns {any} the normalized value
*/
export var getNormalizedValue = function getNormalizedValue(value, sortedCache) {
var type = typeof value;
export var getNormalizedValue = function getNormalizedValue(value, sortedCache, passedTag) {
if (passedTag === void 0) {
var type = typeof value;
if (type === 'string') {
return value;
}
if (type === 'string') {
return value;
}
if (PRIMITIVE_TAGS[type]) {
return getPrefixedValue(type, value);
}
if (PRIMITIVE_TAGS[type]) {
return getPrefixedValue(type, value);
}
if (value === null) {
return getPrefixedValue('null', value);
if (value === null) {
return getPrefixedValue('null', value);
}
}
var tag = toString.call(value);
var tag = passedTag || toString.call(value);

@@ -436,3 +446,8 @@ if (SELF_TAGS[tag]) {

export function stringify(value) {
return typeof value === 'object' && value && !(value instanceof RegExp || value instanceof Date) ? fastStringify(value, createReplacer([]), null, getCircularValue) : getNormalizedValue(value);
if (!value || typeof value !== 'object') {
return getNormalizedValue(value);
}
var tag = toString.call(value);
return tag === OBJECT_CLASS_TYPE_MAP.DATE || tag === OBJECT_CLASS_TYPE_MAP.REGEXP ? getNormalizedValue(value, void 0, tag) : fastStringify(value, createReplacer([]), null, getCircularValue);
}

@@ -321,3 +321,11 @@ "use strict";

var getStringifiedArrayBuffer = function () {
return _constants.HAS_BUFFER_FROM_SUPPORT ? getStringifiedArrayBufferModern : _constants.HAS_UINT16ARRAY_SUPPORT ? getStringifiedArrayBufferFallback : getStringifiedArrayBufferNoSupport;
if (_constants.HAS_BUFFER_FROM_SUPPORT) {
return getStringifiedArrayBufferModern;
}
if (_constants.HAS_UINT16ARRAY_SUPPORT) {
return getStringifiedArrayBufferFallback;
}
return getStringifiedArrayBufferNoSupport;
}();

@@ -342,3 +350,2 @@ /**

for (var index = 0; index < children.length; index++) {
// eslint-disable-next-line no-use-before-define
innerHTML += children[index].outerHTML;

@@ -380,2 +387,3 @@ }

* @param {WeakMap|Object} sortedCache the cache of sorted objects
* @param {string} [passedTag] the previously-calculated tag
* @returns {any} the normalized value

@@ -387,18 +395,20 @@ */

var getNormalizedValue = function getNormalizedValue(value, sortedCache) {
var type = typeof value;
var getNormalizedValue = function getNormalizedValue(value, sortedCache, passedTag) {
if (passedTag === void 0) {
var type = typeof value;
if (type === 'string') {
return value;
}
if (type === 'string') {
return value;
}
if (_constants.PRIMITIVE_TAGS[type]) {
return getPrefixedValue(type, value);
}
if (_constants.PRIMITIVE_TAGS[type]) {
return getPrefixedValue(type, value);
}
if (value === null) {
return getPrefixedValue('null', value);
if (value === null) {
return getPrefixedValue('null', value);
}
}
var tag = toString.call(value);
var tag = passedTag || toString.call(value);

@@ -501,3 +511,8 @@ if (_constants.SELF_TAGS[tag]) {

function stringify(value) {
return typeof value === 'object' && value && !(value instanceof RegExp || value instanceof Date) ? (0, _fastStringify.default)(value, createReplacer([]), null, getCircularValue) : getNormalizedValue(value);
if (!value || typeof value !== 'object') {
return getNormalizedValue(value);
}
var tag = toString.call(value);
return tag === _constants.OBJECT_CLASS_TYPE_MAP.DATE || tag === _constants.OBJECT_CLASS_TYPE_MAP.REGEXP ? getNormalizedValue(value, void 0, tag) : (0, _fastStringify.default)(value, createReplacer([]), null, getCircularValue);
}

@@ -28,17 +28,17 @@ {

"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.0.0",
"ava": "^1.0.0-rc.1",
"@babel/runtime": "^7.2.0",
"ava": "^1.0.1",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.0",
"babel-loader": "^8.0.5",
"benchmark": "^2.1.4",
"browser-env": "^3.2.5",
"eslint": "^5.7.0",
"eslint": "^5.12.0",
"eslint-config-rapid7": "^3.1.0",

@@ -53,16 +53,16 @@ "eslint-friendly-formatter": "4.0.1",

"nyc": "^13.1.0",
"object-hash": "^1.3.0",
"object-hash": "^1.3.1",
"optimize-js-plugin": "^0.0.4",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"rimraf": "^2.6.2",
"rollup": "^0.66.6",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"rimraf": "^2.6.3",
"rollup": "^1.0.2",
"rollup-plugin-babel": "^4.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-uglify": "^6.0.0",
"sinon": "7.0.0",
"sinon": "7.2.2",
"uuid": "^3.3.2",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "3.1.9"
"webpack": "^4.28.3",
"webpack-cli": "^3.2.0",
"webpack-dev-server": "3.1.14"
},

@@ -116,3 +116,3 @@ "homepage": "https://github.com/planttheidea/hash-it#readme",

},
"version": "4.0.3",
"version": "4.0.4",
"dependencies": {

@@ -119,0 +119,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