Comparing version 1.2.0 to 1.2.1
# hashIt CHANGELOG | ||
#### 1.2.1 | ||
* Calculation of Math hashCode now uses properties | ||
* Fix README | ||
#### 1.2.0 | ||
@@ -4,0 +8,0 @@ * Add hashIt.isEqual method to test for equality |
@@ -118,2 +118,3 @@ var hashIt = | ||
var HTML_ELEMENT_REGEXP = /\[object (HTML(.*)Element)\]/; | ||
var MATH_PROPERTIES = ['E', 'LN2', 'LN10', 'LOG2E', 'LOG10E', 'PI', 'SQRT1_2', 'SQRT2']; | ||
@@ -238,2 +239,12 @@ /** | ||
case _toString.types.MATH: | ||
var mathObject = {}; | ||
MATH_PROPERTIES.forEach(function (prop) { | ||
mathObject[prop] = object[prop]; | ||
}); | ||
return { | ||
v: mathObject | ||
}; | ||
case _toString.types.PROMISE: | ||
@@ -240,0 +251,0 @@ case _toString.types.WEAKMAP: |
@@ -1,1 +0,1 @@ | ||
var hashIt=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),o=function(e){return(0,n.getIntegerHashValue)((0,n.stringify)(e))};o.isEqual=function(){var e=arguments.length;if(1===e)throw new Error("isEqual requires at least two objects to be passed for comparison.");for(var t=0;++t<e;)if(o(arguments.length<=t-1+0?void 0:arguments[t-1+0])!==o(arguments.length<=t+0?void 0:arguments[t+0]))return!1;return!0},t.default=o,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0,t.stringify=t.replacer=t.getIntegerHashValue=void 0;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},s=r(3),c=n(s),u=r(4),a=/\[object (HTML(.*)Element)\]/,i=function(e){return"undefined"==typeof Uint16Array?"":String.fromCharCode.apply(null,new Uint16Array(e))},A=function(e){return e.replace(/^\[object (.+)\]$/,"$1")},f=function(e,t){return t+" "+e},y=function(e){var t=(0,u.toString)(e),r=A(t),n=function(){switch(t){case u.types.ARRAY_BUFFER:return{v:f(i(e),r)};case u.types.DATA_VIEW:return{v:f(i(e.buffer),r)};case u.types.FLOAT_32_ARRAY:case u.types.FLOAT_64_ARRAY:case u.types.INT_8_ARRAY:case u.types.INT_16_ARRAY:case u.types.INT_32_ARRAY:case u.types.UINT_8_ARRAY:case u.types.UINT_8_CLAMPED_ARRAY:case u.types.UINT_16_ARRAY:case u.types.UINT_32_ARRAY:return{v:r+" ["+e.join(",")+"]"};case u.types.DATE:return{v:f(e.valueOf(),r)};case u.types.FUNCTION:return{v:(0,u.toFunctionString)(e)};case u.types.GENERATOR:return{v:(0,u.toFunctionString)(e,!0)};case u.types.ERROR:case u.types.NULL:case u.types.NUMBER:case u.types.REGEXP:case u.types.UNDEFINED:return{v:f(e,r)};case u.types.MAP:case u.types.SET:var n=[r];return e.forEach(function(e,t){n.push([t,e])}),{v:n};case u.types.OBJECT:return{v:e?e:f(e,r)};case u.types.SYMBOL:return{v:e.toString()};case u.types.MATH:case u.types.PROMISE:case u.types.WEAKMAP:case u.types.WEAKSET:return{v:r+"--NOT_ENUMERABLE"};default:return{v:a.test(t)?"HTMLElement "+e.textContent:e}}}();if("object"===("undefined"==typeof n?"undefined":o(n)))return n.v},p=function(e,t,r,n){return function(t,o){if(""===t)return e=[o],r=0,o;var s=(0,u.toString)(o);switch(s){case u.types.ARRAY_BUFFER:case u.types.DATA_VIEW:case u.types.DATE:case u.types.FLOAT_32_ARRAY:case u.types.FLOAT_64_ARRAY:case u.types.FUNCTION:case u.types.GENERATOR:case u.types.INT_8_ARRAY:case u.types.INT_16_ARRAY:case u.types.INT_32_ARRAY:case u.types.ERROR:case u.types.MAP:case u.types.MATH:case u.types.NULL:case u.types.PROMISE:case u.types.REGEXP:case u.types.SET:case u.types.SYMBOL:case u.types.UINT_8_ARRAY:case u.types.UINT_8_CLAMPED_ARRAY:case u.types.UINT_16_ARRAY:case u.types.UINT_32_ARRAY:case u.types.UNDEFINED:case u.types.WEAKMAP:case u.types.WEAKSET:return y(o);case u.types.ARRAY:case u.types.OBJECT:return o?++r>255?"Undefined undefined":(n=e.indexOf(o),~n?"*Recursive-"+n:(e.push(o),o)):f(o,s);default:return o}}}(),R=function(e){if(!e)return 0;for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return t>>>0},_=function(e){try{return JSON.stringify(e,p)}catch(t){return c.default.prune(e)}},l=function(e){var t=y(e);return _(t)};t.getIntegerHashValue=R,t.replacer=p,t.stringify=l},function(e,t,r){"use strict";t.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=r(4),s=6,c=50,u="*Recursive",a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},A=void 0,f=function(e,t){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r)},y=function(e){a.lastIndex=0;var t=void 0;return a.test(e)?'"'+e.replace(a,function(e){return t=i[e],(0,o.toString)(t)===o.types.STRING?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'},p=function(e){A=[];var t=function r(e,t,s){var a=t[e],i=[],p=void 0;switch("undefined"==typeof a?"undefined":n(a)){case"string":return y(a);case"boolean":case"null":case"number":case"undefined":return""+a;case"function":return(0,o.toFunctionString)(a);case"object":if(!a)return""+a;var R=A.indexOf(a);if(s<=0||~R)return u+"-"+R;switch((0,o.toString)(a)){case o.types.ARRAY:A.push(a);for(var _=Math.min(a.length,c),l=-1;++l<_;)i[l]=r(l,a,s-1);return p="["+i.join(",")+"]";case o.types.DATE:return""+a.valueOf();default:return A.push(a),f(a,function(e){try{p=r(e,a,s-1),p&&i.push(y(e)+":"+p)}catch(t){}}),"{"+i.join(",")+"}"}}};return t("",{"":e},s)};t.default={prune:p},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0;var r="[object Array]",n="[object ArrayBuffer]",o="[object Boolean]",s="[object DataView]",c="[object Date]",u="[object Error]",a="[object Float32Array]",i="[object Float64Array]",A="[object Function]",f="[object GeneratorFunction]",y="[object Int8Array]",p="[object Int16Array]",R="[object Int32Array]",_="[object Map]",l="[object Math]",E="[object Null]",b="[object Number]",T="[object Object]",d="[object Promise]",N="[object RegExp]",v="[object Set]",I="[object String]",j="[object Symbol]",S="[object Uint8Array]",O="[object Uint8ClampedArray]",Y="[object Uint16Array]",g="[object Uint32Array]",U="[object Undefined]",M="[object WeakMap]",h="[object WeakSet]",F="[object Window]",m={ARRAY:r,ARRAY_BUFFER:n,BOOLEAN:o,DATA_VIEW:s,DATE:c,ERROR:u,FLOAT_32_ARRAY:a,FLOAT_64_ARRAY:i,FUNCTION:A,GENERATOR:f,INT_8_ARRAY:y,INT_16_ARRAY:p,INT_32_ARRAY:R,MAP:_,MATH:l,NULL:E,NUMBER:b,OBJECT:T,PROMISE:d,REGEXP:N,SET:v,STRING:I,SYMBOL:j,UINT_8_ARRAY:S,UINT_8_CLAMPED_ARRAY:O,UINT_16_ARRAY:Y,UINT_32_ARRAY:g,UNDEFINED:U,WEAKMAP:M,WEAKSET:h,WINDOW:F},L=function(e){var t=!(arguments.length<=1||void 0===arguments[1])&&arguments[1];return"function"+(t?"*":"")+" "+(e.name||"anonymous")+"("+new Array(e.length+1).join(",arg").slice(1)+"){}"},D=function(e){return Object.prototype.toString.call(e)};t.toFunctionString=L,t.toString=D,t.types=m}]); | ||
var hashIt=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),o=function(e){return(0,n.getIntegerHashValue)((0,n.stringify)(e))};o.isEqual=function(){var e=arguments.length;if(1===e)throw new Error("isEqual requires at least two objects to be passed for comparison.");for(var t=0;++t<e;)if(o(arguments.length<=t-1+0?void 0:arguments[t-1+0])!==o(arguments.length<=t+0?void 0:arguments[t+0]))return!1;return!0},t.default=o,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0,t.stringify=t.replacer=t.getIntegerHashValue=void 0;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},s=r(3),c=n(s),u=r(4),a=/\[object (HTML(.*)Element)\]/,i=["E","LN2","LN10","LOG2E","LOG10E","PI","SQRT1_2","SQRT2"],A=function(e){return"undefined"==typeof Uint16Array?"":String.fromCharCode.apply(null,new Uint16Array(e))},f=function(e){return e.replace(/^\[object (.+)\]$/,"$1")},y=function(e,t){return t+" "+e},p=function(e){var t=(0,u.toString)(e),r=f(t),n=function(){switch(t){case u.types.ARRAY_BUFFER:return{v:y(A(e),r)};case u.types.DATA_VIEW:return{v:y(A(e.buffer),r)};case u.types.FLOAT_32_ARRAY:case u.types.FLOAT_64_ARRAY:case u.types.INT_8_ARRAY:case u.types.INT_16_ARRAY:case u.types.INT_32_ARRAY:case u.types.UINT_8_ARRAY:case u.types.UINT_8_CLAMPED_ARRAY:case u.types.UINT_16_ARRAY:case u.types.UINT_32_ARRAY:return{v:r+" ["+e.join(",")+"]"};case u.types.DATE:return{v:y(e.valueOf(),r)};case u.types.FUNCTION:return{v:(0,u.toFunctionString)(e)};case u.types.GENERATOR:return{v:(0,u.toFunctionString)(e,!0)};case u.types.ERROR:case u.types.NULL:case u.types.NUMBER:case u.types.REGEXP:case u.types.UNDEFINED:return{v:y(e,r)};case u.types.MAP:case u.types.SET:var n=[r];return e.forEach(function(e,t){n.push([t,e])}),{v:n};case u.types.OBJECT:return{v:e?e:y(e,r)};case u.types.SYMBOL:return{v:e.toString()};case u.types.MATH:var o={};return i.forEach(function(t){o[t]=e[t]}),{v:o};case u.types.PROMISE:case u.types.WEAKMAP:case u.types.WEAKSET:return{v:r+"--NOT_ENUMERABLE"};default:return{v:a.test(t)?"HTMLElement "+e.textContent:e}}}();if("object"===("undefined"==typeof n?"undefined":o(n)))return n.v},R=function(e,t,r,n){return function(t,o){if(""===t)return e=[o],r=0,o;var s=(0,u.toString)(o);switch(s){case u.types.ARRAY_BUFFER:case u.types.DATA_VIEW:case u.types.DATE:case u.types.FLOAT_32_ARRAY:case u.types.FLOAT_64_ARRAY:case u.types.FUNCTION:case u.types.GENERATOR:case u.types.INT_8_ARRAY:case u.types.INT_16_ARRAY:case u.types.INT_32_ARRAY:case u.types.ERROR:case u.types.MAP:case u.types.MATH:case u.types.NULL:case u.types.PROMISE:case u.types.REGEXP:case u.types.SET:case u.types.SYMBOL:case u.types.UINT_8_ARRAY:case u.types.UINT_8_CLAMPED_ARRAY:case u.types.UINT_16_ARRAY:case u.types.UINT_32_ARRAY:case u.types.UNDEFINED:case u.types.WEAKMAP:case u.types.WEAKSET:return p(o);case u.types.ARRAY:case u.types.OBJECT:return o?++r>255?"Undefined undefined":(n=e.indexOf(o),~n?"*Recursive-"+n:(e.push(o),o)):y(o,s);default:return o}}}(),_=function(e){if(!e)return 0;for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return t>>>0},l=function(e){try{return JSON.stringify(e,R)}catch(t){return c.default.prune(e)}},E=function(e){var t=p(e);return l(t)};t.getIntegerHashValue=_,t.replacer=R,t.stringify=E},function(e,t,r){"use strict";t.__esModule=!0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=r(4),s=6,c=50,u="*Recursive",a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},A=void 0,f=function(e,t){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r)},y=function(e){a.lastIndex=0;var t=void 0;return a.test(e)?'"'+e.replace(a,function(e){return t=i[e],(0,o.toString)(t)===o.types.STRING?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'},p=function(e){A=[];var t=function r(e,t,s){var a=t[e],i=[],p=void 0;switch("undefined"==typeof a?"undefined":n(a)){case"string":return y(a);case"boolean":case"null":case"number":case"undefined":return""+a;case"function":return(0,o.toFunctionString)(a);case"object":if(!a)return""+a;var R=A.indexOf(a);if(s<=0||~R)return u+"-"+R;switch((0,o.toString)(a)){case o.types.ARRAY:A.push(a);for(var _=Math.min(a.length,c),l=-1;++l<_;)i[l]=r(l,a,s-1);return p="["+i.join(",")+"]";case o.types.DATE:return""+a.valueOf();default:return A.push(a),f(a,function(e){try{p=r(e,a,s-1),p&&i.push(y(e)+":"+p)}catch(t){}}),"{"+i.join(",")+"}"}}};return t("",{"":e},s)};t.default={prune:p},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0;var r="[object Array]",n="[object ArrayBuffer]",o="[object Boolean]",s="[object DataView]",c="[object Date]",u="[object Error]",a="[object Float32Array]",i="[object Float64Array]",A="[object Function]",f="[object GeneratorFunction]",y="[object Int8Array]",p="[object Int16Array]",R="[object Int32Array]",_="[object Map]",l="[object Math]",E="[object Null]",b="[object Number]",T="[object Object]",d="[object Promise]",N="[object RegExp]",v="[object Set]",I="[object String]",j="[object Symbol]",S="[object Uint8Array]",O="[object Uint8ClampedArray]",Y="[object Uint16Array]",g="[object Uint32Array]",U="[object Undefined]",h="[object WeakMap]",M="[object WeakSet]",F="[object Window]",L={ARRAY:r,ARRAY_BUFFER:n,BOOLEAN:o,DATA_VIEW:s,DATE:c,ERROR:u,FLOAT_32_ARRAY:a,FLOAT_64_ARRAY:i,FUNCTION:A,GENERATOR:f,INT_8_ARRAY:y,INT_16_ARRAY:p,INT_32_ARRAY:R,MAP:_,MATH:l,NULL:E,NUMBER:b,OBJECT:T,PROMISE:d,REGEXP:N,SET:v,STRING:I,SYMBOL:j,UINT_8_ARRAY:S,UINT_8_CLAMPED_ARRAY:O,UINT_16_ARRAY:Y,UINT_32_ARRAY:g,UNDEFINED:U,WEAKMAP:h,WEAKSET:M,WINDOW:F},m=function(e){var t=!(arguments.length<=1||void 0===arguments[1])&&arguments[1];return"function"+(t?"*":"")+" "+(e.name||"anonymous")+"("+new Array(e.length+1).join(",arg").slice(1)+"){}"},D=function(e){return Object.prototype.toString.call(e)};t.toFunctionString=m,t.toString=D,t.types=L}]); |
@@ -17,2 +17,3 @@ 'use strict'; | ||
var HTML_ELEMENT_REGEXP = /\[object (HTML(.*)Element)\]/; | ||
var MATH_PROPERTIES = ['E', 'LN2', 'LN10', 'LOG2E', 'LOG10E', 'PI', 'SQRT1_2', 'SQRT2']; | ||
@@ -137,2 +138,12 @@ /** | ||
case _toString.types.MATH: | ||
var mathObject = {}; | ||
MATH_PROPERTIES.forEach(function (prop) { | ||
mathObject[prop] = object[prop]; | ||
}); | ||
return { | ||
v: mathObject | ||
}; | ||
case _toString.types.PROMISE: | ||
@@ -139,0 +150,0 @@ case _toString.types.WEAKMAP: |
@@ -44,3 +44,3 @@ { | ||
"babel-runtime": "^6.11.6", | ||
"eslint": "3.1.1", | ||
"eslint": "3.2.0", | ||
"eslint-friendly-formatter": "2.0.6", | ||
@@ -51,4 +51,4 @@ "eslint-loader": "1.5.0", | ||
"jsdom": "^9.4.1", | ||
"react": "15.2.1", | ||
"react-dom": "15.2.1", | ||
"react": "15.3.0", | ||
"react-dom": "15.3.0", | ||
"sinon": "^1.17.5", | ||
@@ -85,3 +85,3 @@ "webpack": "1.13.1", | ||
}, | ||
"version": "1.2.0" | ||
"version": "1.2.1" | ||
} |
@@ -42,10 +42,6 @@ # hashIt | ||
Well ... sadly, no, there are a few exceptions. | ||
* `Math` | ||
* It's not a constructor (really just a parent for methods), so there are no values to hash | ||
* `Promise` | ||
* There is no way to obtain the values contained within due to its asynchronous nature | ||
* `WeakMap` | ||
* `WeakMap` / `WeakSet` | ||
* The spec explicitly forbids iteration over them, so the unique values cannot be discovered | ||
* `WeakSet` | ||
* Same as `WeakMap` | ||
@@ -68,4 +64,5 @@ In each of these cases, no matter what the values of the object, they will always yield the same hash result, which is unique to each object type. If you have any ideas about how these can be uniquely hashed, I welcome them! | ||
* `Int32Array` | ||
* `HTMLElement` (based on `innerHTML`, includes all sub-types, e.g. `HTMLAnchorElement`, `HTMLDivElement`, etc) | ||
* `HTMLElement` (based on `textContent`, includes all sub-types, e.g. `HTMLAnchorElement`, `HTMLDivElement`, etc) | ||
* `Map` | ||
* `Math` (based on `E`, `LN2`, `LN10`, `LOG2E`, `LOG10E`, `PI`, `SQRT1_2`, and `SQRT2`) | ||
* `Null` | ||
@@ -72,0 +69,0 @@ * `Number` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68491
1003
128