first commit
This commit is contained in:
13
app_vue/node_modules/hash-sum/.editorconfig
generated
vendored
Normal file
13
app_vue/node_modules/hash-sum/.editorconfig
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
1
app_vue/node_modules/hash-sum/.jshintignore
generated
vendored
Normal file
1
app_vue/node_modules/hash-sum/.jshintignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
21
app_vue/node_modules/hash-sum/.jshintrc
generated
vendored
Normal file
21
app_vue/node_modules/hash-sum/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"sub": true,
|
||||
"validthis": true,
|
||||
"undef": true,
|
||||
"trailing": true,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"strict": true,
|
||||
"immed": true,
|
||||
"expr": true,
|
||||
"latedef": "nofunc",
|
||||
"quotmark": "single",
|
||||
"indent": 2,
|
||||
"node": true
|
||||
}
|
15
app_vue/node_modules/hash-sum/changelog.markdown
generated
vendored
Normal file
15
app_vue/node_modules/hash-sum/changelog.markdown
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# 2.0.0
|
||||
|
||||
- Now takes into account result of calling `valueOf` functions when they exist
|
||||
|
||||
# 1.0.2 Quick Sort
|
||||
|
||||
- Sorts object keys so that property order doesn't affect outcome
|
||||
|
||||
# 1.0.1 Perfect Circle
|
||||
|
||||
- Guard against circular references
|
||||
|
||||
# 1.0.0 IPO
|
||||
|
||||
- Initial Public Release
|
69
app_vue/node_modules/hash-sum/hash-sum.js
generated
vendored
Normal file
69
app_vue/node_modules/hash-sum/hash-sum.js
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
|
||||
function pad (hash, len) {
|
||||
while (hash.length < len) {
|
||||
hash = '0' + hash;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
function fold (hash, text) {
|
||||
var i;
|
||||
var chr;
|
||||
var len;
|
||||
if (text.length === 0) {
|
||||
return hash;
|
||||
}
|
||||
for (i = 0, len = text.length; i < len; i++) {
|
||||
chr = text.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0;
|
||||
}
|
||||
return hash < 0 ? hash * -2 : hash;
|
||||
}
|
||||
|
||||
function foldObject (hash, o, seen) {
|
||||
return Object.keys(o).sort().reduce(foldKey, hash);
|
||||
function foldKey (hash, key) {
|
||||
return foldValue(hash, o[key], key, seen);
|
||||
}
|
||||
}
|
||||
|
||||
function foldValue (input, value, key, seen) {
|
||||
var hash = fold(fold(fold(input, key), toString(value)), typeof value);
|
||||
if (value === null) {
|
||||
return fold(hash, 'null');
|
||||
}
|
||||
if (value === undefined) {
|
||||
return fold(hash, 'undefined');
|
||||
}
|
||||
if (typeof value === 'object' || typeof value === 'function') {
|
||||
if (seen.indexOf(value) !== -1) {
|
||||
return fold(hash, '[Circular]' + key);
|
||||
}
|
||||
seen.push(value);
|
||||
|
||||
var objHash = foldObject(hash, value, seen)
|
||||
|
||||
if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
|
||||
return objHash;
|
||||
}
|
||||
|
||||
try {
|
||||
return fold(objHash, String(value.valueOf()))
|
||||
} catch (err) {
|
||||
return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
|
||||
}
|
||||
}
|
||||
return fold(hash, value.toString());
|
||||
}
|
||||
|
||||
function toString (o) {
|
||||
return Object.prototype.toString.call(o);
|
||||
}
|
||||
|
||||
function sum (o) {
|
||||
return pad(foldValue(0, o, '', []).toString(16), 8);
|
||||
}
|
||||
|
||||
module.exports = sum;
|
20
app_vue/node_modules/hash-sum/license
generated
vendored
Normal file
20
app_vue/node_modules/hash-sum/license
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2014 Nicolas Bevacqua
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
app_vue/node_modules/hash-sum/package.json
generated
vendored
Normal file
28
app_vue/node_modules/hash-sum/package.json
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "hash-sum",
|
||||
"description": "Blazing fast unique hash generator",
|
||||
"version": "2.0.0",
|
||||
"homepage": "https://github.com/bevacqua/hash-sum",
|
||||
"authors": [
|
||||
"Nicolas Bevacqua <nicolasbevacqua@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/bevacqua/hash-sum.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/bevacqua/hash-sum/issues"
|
||||
},
|
||||
"main": "hash-sum.js",
|
||||
"scripts": {
|
||||
"test": "jshint . && tape test.js"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"jshint": "2.5.0",
|
||||
"jshint-stylish": "0.2.0",
|
||||
"lodash": "4.17.11",
|
||||
"tape": "3.0.3"
|
||||
}
|
||||
}
|
74
app_vue/node_modules/hash-sum/readme.md
generated
vendored
Normal file
74
app_vue/node_modules/hash-sum/readme.md
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
# hash-sum
|
||||
|
||||
> blazing fast unique hash generator
|
||||
|
||||
# install
|
||||
|
||||
```shell
|
||||
npm i hash-sum -S
|
||||
```
|
||||
|
||||
# features
|
||||
|
||||
- no dependencies
|
||||
- minimal footprint
|
||||
- works in all of node.js, io.js, and the browser
|
||||
- hashes functions based on their source code
|
||||
- produces different hashes for different object types
|
||||
- support for circular references in objects
|
||||
- ignores property assignment order
|
||||
|
||||
# `sum(value)`
|
||||
|
||||
yields a four-byte hexadecimal hash based off of `value`.
|
||||
|
||||
```
|
||||
# creates unique hashes
|
||||
00a34759 from: [ 0, 1, 2, 3 ]
|
||||
a8996f0c from: { '0': 0, '1': 1, '2': 2, '3': 3 }
|
||||
5b4c2116 from: { '0': 0, '1': 1, '2': 2, '3': 3, length: 4 }
|
||||
2c937c45 from: { url: 12 }
|
||||
31d55010 from: { headers: 12 }
|
||||
2d2e11bc from: { headers: 122 }
|
||||
ec99d958 from: { headers: '122' }
|
||||
18c00eee from: { headers: { accept: 'text/plain' } }
|
||||
6cb332c8 from: { payload: [ 0, 1, 2, 3 ], headers: [ { a: 'b' } ] }
|
||||
12ff55db from: { a: [Function: a] }
|
||||
46f806d2 from: { b: [Function: b] }
|
||||
0660d9c4 from: { b: [Function: b] }
|
||||
6c95fc65 from: function () {}
|
||||
2941766e from: function (a) {}
|
||||
294f8def from: function (b) {}
|
||||
2d9c0cb8 from: function (a) { return a;}
|
||||
ed5c63fc from: function (a) {return a;}
|
||||
bba68bf6 from: ''
|
||||
2d27667d from: 'null'
|
||||
774b96ed from: 'false'
|
||||
2d2a1684 from: 'true'
|
||||
8daa1a0c from: '0'
|
||||
8daa1a0a from: '1'
|
||||
e38f07cc from: 'void 0'
|
||||
6037ea1a from: 'undefined'
|
||||
9b7df12e from: null
|
||||
3c206f76 from: false
|
||||
01e34ba8 from: true
|
||||
8a8f9624 from: Infinity
|
||||
0315bf8f from: -Infinity
|
||||
64a48b16 from: NaN
|
||||
1a96284a from: 0
|
||||
1a96284b from: 1
|
||||
29172c1a from: undefined
|
||||
59322f29 from: {}
|
||||
095b3a22 from: { a: {}, b: {} }
|
||||
63be56dd from: { valueOf: [Function: valueOf] }
|
||||
63be4f5c from: { valueOf: [Function: valueOf] }
|
||||
5d844489 from: []
|
||||
ba0bfa14 from: 2019-06-28T21:24:31.215Z
|
||||
49324d16 from: 2019-06-28T03:00:00.000Z
|
||||
434c9188 from: 1988-06-09T03:00:00.000Z
|
||||
ce1b5e44 from: global
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
80
app_vue/node_modules/hash-sum/test.js
generated
vendored
Normal file
80
app_vue/node_modules/hash-sum/test.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
var test = require('tape');
|
||||
var sum = require('./');
|
||||
|
||||
test('creates unique hashes', function (t) {
|
||||
var cases = [];
|
||||
|
||||
test_case([0,1,2,3]);
|
||||
test_case({0:0,1:1,2:2,3:3});
|
||||
test_case({0:0,1:1,2:2,3:3,length:4});
|
||||
test_case({url:12});
|
||||
test_case({headers:12});
|
||||
test_case({headers:122});
|
||||
test_case({headers:'122'});
|
||||
test_case({headers:{accept:'text/plain'}});
|
||||
test_case({payload:[0,1,2,3],headers:[{a:'b'}]});
|
||||
test_case({a:function () {}});
|
||||
test_case({b:function () {}});
|
||||
test_case({b:function (a) {}});
|
||||
test_case(function () {});
|
||||
test_case(function (a) {});
|
||||
test_case(function (b) {});
|
||||
test_case(function (a) { return a;});
|
||||
test_case(function (a) {return a;});
|
||||
test_case('', '\'\'');
|
||||
test_case('null', '\'null\'');
|
||||
test_case('false', '\'false\'');
|
||||
test_case('true', '\'true\'');
|
||||
test_case('0', '\'0\'');
|
||||
test_case('1', '\'1\'');
|
||||
test_case('void 0', '\'void 0\'');
|
||||
test_case('undefined', '\'undefined\'');
|
||||
test_case(null);
|
||||
test_case(false);
|
||||
test_case(true);
|
||||
test_case(Infinity);
|
||||
test_case(-Infinity);
|
||||
test_case(NaN);
|
||||
test_case(0);
|
||||
test_case(1);
|
||||
test_case(void 0);
|
||||
test_case({});
|
||||
test_case({a:{},b:{}});
|
||||
test_case({valueOf(){return 1}});
|
||||
test_case({valueOf(){return 2}});
|
||||
test_case([]);
|
||||
test_case(new Date());
|
||||
test_case(new Date(2019, 5, 28));
|
||||
test_case(new Date(1988, 5, 9));
|
||||
test_case(global, 'global');
|
||||
|
||||
const uniqCases = _.uniqBy(cases, 'hash')
|
||||
_.uniqBy(cases, 'hash').forEach(function (expected) {
|
||||
var matches = _.filter(cases, { hash: expected.hash })
|
||||
t.equal(matches.length, 1, expected.hash + ': ' + _.map(matches, 'value').join(' '))
|
||||
})
|
||||
|
||||
t.end();
|
||||
|
||||
function test_case(value, name) {
|
||||
var hash = sum(value);
|
||||
cases.push({ value, hash });
|
||||
console.log('%s from:', hash, name || value);
|
||||
}
|
||||
});
|
||||
|
||||
test('hashes clash if same properties', function (t) {
|
||||
equals(function () {}, function () {});
|
||||
equals(function (a) {}, function (a) {});
|
||||
equals({a:'1'},{a:'1'});
|
||||
equals({a:'1',b:1},{b:1,a:'1'});
|
||||
equals({valueOf(){return 1}},{valueOf(){return 1}});
|
||||
t.end();
|
||||
|
||||
function equals (a, b) {
|
||||
t.equal(sum(a), sum(b));
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user