正在显示
20 个修改的文件
包含
1361 行增加
和
0 行删除
node_modules/.bin/uuid
0 → 120000
1 | +../node-uuid/bin/uuid |
node_modules/node-uuid/.npmignore
0 → 100644
node_modules/node-uuid/LICENSE.md
0 → 100644
1 | +The MIT License (MIT) | ||
2 | + | ||
3 | +Copyright (c) 2010-2012 Robert Kieffer | ||
4 | + | ||
5 | +Permission is hereby granted, free of charge, to any person obtaining a copy | ||
6 | +of this software and associated documentation files (the "Software"), to deal | ||
7 | +in the Software without restriction, including without limitation the rights | ||
8 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
9 | +copies of the Software, and to permit persons to whom the Software is | ||
10 | +furnished to do so, subject to the following conditions: | ||
11 | + | ||
12 | +The above copyright notice and this permission notice shall be included in all | ||
13 | +copies or substantial portions of the Software. | ||
14 | + | ||
15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
18 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
20 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
21 | +SOFTWARE. |
node_modules/node-uuid/README.md
0 → 100644
node_modules/node-uuid/benchmark/README.md
0 → 100644
1 | +# node-uuid Benchmarks | ||
2 | + | ||
3 | +### Results | ||
4 | + | ||
5 | +To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark | ||
6 | + | ||
7 | +### Run them yourself | ||
8 | + | ||
9 | +node-uuid comes with some benchmarks to measure performance of generating UUIDs. These can be run using node.js. node-uuid is being benchmarked against some other uuid modules, that are available through npm namely `uuid` and `uuid-js`. | ||
10 | + | ||
11 | +To prepare and run the benchmark issue; | ||
12 | + | ||
13 | +``` | ||
14 | +npm install uuid uuid-js | ||
15 | +node benchmark/benchmark.js | ||
16 | +``` | ||
17 | + | ||
18 | +You'll see an output like this one: | ||
19 | + | ||
20 | +``` | ||
21 | +# v4 | ||
22 | +nodeuuid.v4(): 854700 uuids/second | ||
23 | +nodeuuid.v4('binary'): 788643 uuids/second | ||
24 | +nodeuuid.v4('binary', buffer): 1336898 uuids/second | ||
25 | +uuid(): 479386 uuids/second | ||
26 | +uuid('binary'): 582072 uuids/second | ||
27 | +uuidjs.create(4): 312304 uuids/second | ||
28 | + | ||
29 | +# v1 | ||
30 | +nodeuuid.v1(): 938086 uuids/second | ||
31 | +nodeuuid.v1('binary'): 683060 uuids/second | ||
32 | +nodeuuid.v1('binary', buffer): 1644736 uuids/second | ||
33 | +uuidjs.create(1): 190621 uuids/second | ||
34 | +``` | ||
35 | + | ||
36 | +* The `uuid()` entries are for Nikhil Marathe's [uuid module](https://bitbucket.org/nikhilm/uuidjs) which is a wrapper around the native libuuid library. | ||
37 | +* The `uuidjs()` entries are for Patrick Negri's [uuid-js module](https://github.com/pnegri/uuid-js) which is a pure javascript implementation based on [UUID.js](https://github.com/LiosK/UUID.js) by LiosK. | ||
38 | + | ||
39 | +If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file: | ||
40 | + | ||
41 | +``` | ||
42 | +for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done; | ||
43 | +``` | ||
44 | + | ||
45 | +If you're interested in how performance varies between different node versions, you can issue the above command multiple times. | ||
46 | + | ||
47 | +You can then use the shell script `bench.sh` provided in this directory to calculate the averages over all benchmark runs and draw a nice plot: | ||
48 | + | ||
49 | +``` | ||
50 | +(cd benchmark/ && ./bench.sh) | ||
51 | +``` | ||
52 | + | ||
53 | +This assumes you have [gnuplot](http://www.gnuplot.info/) and [ImageMagick](http://www.imagemagick.org/) installed. You'll find a nice `bench.png` graph in the `benchmark/` directory then. |
node_modules/node-uuid/benchmark/bench.gnu
0 → 100644
1 | +#!/opt/local/bin/gnuplot -persist | ||
2 | +# | ||
3 | +# | ||
4 | +# G N U P L O T | ||
5 | +# Version 4.4 patchlevel 3 | ||
6 | +# last modified March 2011 | ||
7 | +# System: Darwin 10.8.0 | ||
8 | +# | ||
9 | +# Copyright (C) 1986-1993, 1998, 2004, 2007-2010 | ||
10 | +# Thomas Williams, Colin Kelley and many others | ||
11 | +# | ||
12 | +# gnuplot home: http://www.gnuplot.info | ||
13 | +# faq, bugs, etc: type "help seeking-assistance" | ||
14 | +# immediate help: type "help" | ||
15 | +# plot window: hit 'h' | ||
16 | +set terminal postscript eps noenhanced defaultplex \ | ||
17 | + leveldefault color colortext \ | ||
18 | + solid linewidth 1.2 butt noclip \ | ||
19 | + palfuncparam 2000,0.003 \ | ||
20 | + "Helvetica" 14 | ||
21 | +set output 'bench.eps' | ||
22 | +unset clip points | ||
23 | +set clip one | ||
24 | +unset clip two | ||
25 | +set bar 1.000000 front | ||
26 | +set border 31 front linetype -1 linewidth 1.000 | ||
27 | +set xdata | ||
28 | +set ydata | ||
29 | +set zdata | ||
30 | +set x2data | ||
31 | +set y2data | ||
32 | +set timefmt x "%d/%m/%y,%H:%M" | ||
33 | +set timefmt y "%d/%m/%y,%H:%M" | ||
34 | +set timefmt z "%d/%m/%y,%H:%M" | ||
35 | +set timefmt x2 "%d/%m/%y,%H:%M" | ||
36 | +set timefmt y2 "%d/%m/%y,%H:%M" | ||
37 | +set timefmt cb "%d/%m/%y,%H:%M" | ||
38 | +set boxwidth | ||
39 | +set style fill empty border | ||
40 | +set style rectangle back fc lt -3 fillstyle solid 1.00 border lt -1 | ||
41 | +set style circle radius graph 0.02, first 0, 0 | ||
42 | +set dummy x,y | ||
43 | +set format x "% g" | ||
44 | +set format y "% g" | ||
45 | +set format x2 "% g" | ||
46 | +set format y2 "% g" | ||
47 | +set format z "% g" | ||
48 | +set format cb "% g" | ||
49 | +set angles radians | ||
50 | +unset grid | ||
51 | +set key title "" | ||
52 | +set key outside left top horizontal Right noreverse enhanced autotitles columnhead nobox | ||
53 | +set key noinvert samplen 4 spacing 1 width 0 height 0 | ||
54 | +set key maxcolumns 2 maxrows 0 | ||
55 | +unset label | ||
56 | +unset arrow | ||
57 | +set style increment default | ||
58 | +unset style line | ||
59 | +set style line 1 linetype 1 linewidth 2.000 pointtype 1 pointsize default pointinterval 0 | ||
60 | +unset style arrow | ||
61 | +set style histogram clustered gap 2 title offset character 0, 0, 0 | ||
62 | +unset logscale | ||
63 | +set offsets graph 0.05, 0.15, 0, 0 | ||
64 | +set pointsize 1.5 | ||
65 | +set pointintervalbox 1 | ||
66 | +set encoding default | ||
67 | +unset polar | ||
68 | +unset parametric | ||
69 | +unset decimalsign | ||
70 | +set view 60, 30, 1, 1 | ||
71 | +set samples 100, 100 | ||
72 | +set isosamples 10, 10 | ||
73 | +set surface | ||
74 | +unset contour | ||
75 | +set clabel '%8.3g' | ||
76 | +set mapping cartesian | ||
77 | +set datafile separator whitespace | ||
78 | +unset hidden3d | ||
79 | +set cntrparam order 4 | ||
80 | +set cntrparam linear | ||
81 | +set cntrparam levels auto 5 | ||
82 | +set cntrparam points 5 | ||
83 | +set size ratio 0 1,1 | ||
84 | +set origin 0,0 | ||
85 | +set style data points | ||
86 | +set style function lines | ||
87 | +set xzeroaxis linetype -2 linewidth 1.000 | ||
88 | +set yzeroaxis linetype -2 linewidth 1.000 | ||
89 | +set zzeroaxis linetype -2 linewidth 1.000 | ||
90 | +set x2zeroaxis linetype -2 linewidth 1.000 | ||
91 | +set y2zeroaxis linetype -2 linewidth 1.000 | ||
92 | +set ticslevel 0.5 | ||
93 | +set mxtics default | ||
94 | +set mytics default | ||
95 | +set mztics default | ||
96 | +set mx2tics default | ||
97 | +set my2tics default | ||
98 | +set mcbtics default | ||
99 | +set xtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 | ||
100 | +set xtics norangelimit | ||
101 | +set xtics () | ||
102 | +set ytics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 | ||
103 | +set ytics autofreq norangelimit | ||
104 | +set ztics border in scale 1,0.5 nomirror norotate offset character 0, 0, 0 | ||
105 | +set ztics autofreq norangelimit | ||
106 | +set nox2tics | ||
107 | +set noy2tics | ||
108 | +set cbtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0 | ||
109 | +set cbtics autofreq norangelimit | ||
110 | +set title "" | ||
111 | +set title offset character 0, 0, 0 font "" norotate | ||
112 | +set timestamp bottom | ||
113 | +set timestamp "" | ||
114 | +set timestamp offset character 0, 0, 0 font "" norotate | ||
115 | +set rrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] ) | ||
116 | +set autoscale rfixmin | ||
117 | +set autoscale rfixmax | ||
118 | +set trange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] ) | ||
119 | +set autoscale tfixmin | ||
120 | +set autoscale tfixmax | ||
121 | +set urange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) | ||
122 | +set autoscale ufixmin | ||
123 | +set autoscale ufixmax | ||
124 | +set vrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) | ||
125 | +set autoscale vfixmin | ||
126 | +set autoscale vfixmax | ||
127 | +set xlabel "" | ||
128 | +set xlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate | ||
129 | +set x2label "" | ||
130 | +set x2label offset character 0, 0, 0 font "" textcolor lt -1 norotate | ||
131 | +set xrange [ * : * ] noreverse nowriteback # (currently [-0.150000:3.15000] ) | ||
132 | +set autoscale xfixmin | ||
133 | +set autoscale xfixmax | ||
134 | +set x2range [ * : * ] noreverse nowriteback # (currently [0.00000:3.00000] ) | ||
135 | +set autoscale x2fixmin | ||
136 | +set autoscale x2fixmax | ||
137 | +set ylabel "" | ||
138 | +set ylabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 | ||
139 | +set y2label "" | ||
140 | +set y2label offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 | ||
141 | +set yrange [ 0.00000 : 1.90000e+06 ] noreverse nowriteback # (currently [:] ) | ||
142 | +set autoscale yfixmin | ||
143 | +set autoscale yfixmax | ||
144 | +set y2range [ * : * ] noreverse nowriteback # (currently [0.00000:1.90000e+06] ) | ||
145 | +set autoscale y2fixmin | ||
146 | +set autoscale y2fixmax | ||
147 | +set zlabel "" | ||
148 | +set zlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate | ||
149 | +set zrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] ) | ||
150 | +set autoscale zfixmin | ||
151 | +set autoscale zfixmax | ||
152 | +set cblabel "" | ||
153 | +set cblabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270 | ||
154 | +set cbrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] ) | ||
155 | +set autoscale cbfixmin | ||
156 | +set autoscale cbfixmax | ||
157 | +set zero 1e-08 | ||
158 | +set lmargin -1 | ||
159 | +set bmargin -1 | ||
160 | +set rmargin -1 | ||
161 | +set tmargin -1 | ||
162 | +set pm3d explicit at s | ||
163 | +set pm3d scansautomatic | ||
164 | +set pm3d interpolate 1,1 flush begin noftriangles nohidden3d corners2color mean | ||
165 | +set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB | ||
166 | +set palette rgbformulae 7, 5, 15 | ||
167 | +set colorbox default | ||
168 | +set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front bdefault | ||
169 | +set loadpath | ||
170 | +set fontpath | ||
171 | +set fit noerrorvariables | ||
172 | +GNUTERM = "aqua" | ||
173 | +plot 'bench_results.txt' using 2:xticlabel(1) w lp lw 2, '' using 3:xticlabel(1) w lp lw 2, '' using 4:xticlabel(1) w lp lw 2, '' using 5:xticlabel(1) w lp lw 2, '' using 6:xticlabel(1) w lp lw 2, '' using 7:xticlabel(1) w lp lw 2, '' using 8:xticlabel(1) w lp lw 2, '' using 9:xticlabel(1) w lp lw 2 | ||
174 | +# EOF |
node_modules/node-uuid/benchmark/bench.sh
0 → 100755
1 | +#!/bin/bash | ||
2 | + | ||
3 | +# for a given node version run: | ||
4 | +# for i in {0..9}; do node benchmark.js >> bench_0.6.2.log; done; | ||
5 | + | ||
6 | +PATTERNS=('nodeuuid.v1()' "nodeuuid.v1('binary'," 'nodeuuid.v4()' "nodeuuid.v4('binary'," "uuid()" "uuid('binary')" 'uuidjs.create(1)' 'uuidjs.create(4)' '140byte') | ||
7 | +FILES=(node_uuid_v1_string node_uuid_v1_buf node_uuid_v4_string node_uuid_v4_buf libuuid_v4_string libuuid_v4_binary uuidjs_v1_string uuidjs_v4_string 140byte_es) | ||
8 | +INDICES=(2 3 2 3 2 2 2 2 2) | ||
9 | +VERSIONS=$( ls bench_*.log | sed -e 's/^bench_\([0-9\.]*\)\.log/\1/' | tr "\\n" " " ) | ||
10 | +TMPJOIN="tmp_join" | ||
11 | +OUTPUT="bench_results.txt" | ||
12 | + | ||
13 | +for I in ${!FILES[*]}; do | ||
14 | + F=${FILES[$I]} | ||
15 | + P=${PATTERNS[$I]} | ||
16 | + INDEX=${INDICES[$I]} | ||
17 | + echo "version $F" > $F | ||
18 | + for V in $VERSIONS; do | ||
19 | + (VAL=$( grep "$P" bench_$V.log | LC_ALL=en_US awk '{ sum += $'$INDEX' } END { print sum/NR }' ); echo $V $VAL) >> $F | ||
20 | + done | ||
21 | + if [ $I == 0 ]; then | ||
22 | + cat $F > $TMPJOIN | ||
23 | + else | ||
24 | + join $TMPJOIN $F > $OUTPUT | ||
25 | + cp $OUTPUT $TMPJOIN | ||
26 | + fi | ||
27 | + rm $F | ||
28 | +done | ||
29 | + | ||
30 | +rm $TMPJOIN | ||
31 | + | ||
32 | +gnuplot bench.gnu | ||
33 | +convert -density 200 -resize 800x560 -flatten bench.eps bench.png | ||
34 | +rm bench.eps |
1 | +/* | ||
2 | +Test performance of native C UUID generation | ||
3 | + | ||
4 | +To Compile: cc -luuid benchmark-native.c -o benchmark-native | ||
5 | +*/ | ||
6 | + | ||
7 | +#include <stdio.h> | ||
8 | +#include <unistd.h> | ||
9 | +#include <sys/time.h> | ||
10 | +#include <uuid/uuid.h> | ||
11 | + | ||
12 | +int main() { | ||
13 | + uuid_t myid; | ||
14 | + char buf[36+1]; | ||
15 | + int i; | ||
16 | + struct timeval t; | ||
17 | + double start, finish; | ||
18 | + | ||
19 | + gettimeofday(&t, NULL); | ||
20 | + start = t.tv_sec + t.tv_usec/1e6; | ||
21 | + | ||
22 | + int n = 2e5; | ||
23 | + for (i = 0; i < n; i++) { | ||
24 | + uuid_generate(myid); | ||
25 | + uuid_unparse(myid, buf); | ||
26 | + } | ||
27 | + | ||
28 | + gettimeofday(&t, NULL); | ||
29 | + finish = t.tv_sec + t.tv_usec/1e6; | ||
30 | + double dur = finish - start; | ||
31 | + | ||
32 | + printf("%d uuids/sec", (int)(n/dur)); | ||
33 | + return 0; | ||
34 | +} |
1 | +try { | ||
2 | + var nodeuuid = require('../uuid'); | ||
3 | +} catch (e) { | ||
4 | + console.error('node-uuid require failed - skipping tests'); | ||
5 | +} | ||
6 | + | ||
7 | +try { | ||
8 | + var uuid = require('uuid'); | ||
9 | +} catch (e) { | ||
10 | + console.error('uuid require failed - skipping tests'); | ||
11 | +} | ||
12 | + | ||
13 | +try { | ||
14 | + var uuidjs = require('uuid-js'); | ||
15 | +} catch (e) { | ||
16 | + console.error('uuid-js require failed - skipping tests'); | ||
17 | +} | ||
18 | + | ||
19 | +var N = 5e5; | ||
20 | + | ||
21 | +function rate(msg, t) { | ||
22 | + console.log(msg + ': ' + | ||
23 | + (N / (Date.now() - t) * 1e3 | 0) + | ||
24 | + ' uuids/second'); | ||
25 | +} | ||
26 | + | ||
27 | +console.log('# v4'); | ||
28 | + | ||
29 | +// node-uuid - string form | ||
30 | +if (nodeuuid) { | ||
31 | + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4(); | ||
32 | + rate('nodeuuid.v4() - using node.js crypto RNG', t); | ||
33 | + | ||
34 | + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4({rng: nodeuuid.mathRNG}); | ||
35 | + rate('nodeuuid.v4() - using Math.random() RNG', t); | ||
36 | + | ||
37 | + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary'); | ||
38 | + rate('nodeuuid.v4(\'binary\')', t); | ||
39 | + | ||
40 | + var buffer = new nodeuuid.BufferClass(16); | ||
41 | + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary', buffer); | ||
42 | + rate('nodeuuid.v4(\'binary\', buffer)', t); | ||
43 | +} | ||
44 | + | ||
45 | +// libuuid - string form | ||
46 | +if (uuid) { | ||
47 | + for (var i = 0, t = Date.now(); i < N; i++) uuid(); | ||
48 | + rate('uuid()', t); | ||
49 | + | ||
50 | + for (var i = 0, t = Date.now(); i < N; i++) uuid('binary'); | ||
51 | + rate('uuid(\'binary\')', t); | ||
52 | +} | ||
53 | + | ||
54 | +// uuid-js - string form | ||
55 | +if (uuidjs) { | ||
56 | + for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(4); | ||
57 | + rate('uuidjs.create(4)', t); | ||
58 | +} | ||
59 | + | ||
60 | +// 140byte.es | ||
61 | +for (var i = 0, t = Date.now(); i < N; i++) 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(s,r){r=Math.random()*16|0;return (s=='x'?r:r&0x3|0x8).toString(16)}); | ||
62 | +rate('140byte.es_v4', t); | ||
63 | + | ||
64 | +console.log(''); | ||
65 | +console.log('# v1'); | ||
66 | + | ||
67 | +// node-uuid - v1 string form | ||
68 | +if (nodeuuid) { | ||
69 | + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1(); | ||
70 | + rate('nodeuuid.v1()', t); | ||
71 | + | ||
72 | + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary'); | ||
73 | + rate('nodeuuid.v1(\'binary\')', t); | ||
74 | + | ||
75 | + var buffer = new nodeuuid.BufferClass(16); | ||
76 | + for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary', buffer); | ||
77 | + rate('nodeuuid.v1(\'binary\', buffer)', t); | ||
78 | +} | ||
79 | + | ||
80 | +// uuid-js - v1 string form | ||
81 | +if (uuidjs) { | ||
82 | + for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(1); | ||
83 | + rate('uuidjs.create(1)', t); | ||
84 | +} |
node_modules/node-uuid/bin/uuid
0 → 100755
1 | +#!/usr/bin/env node | ||
2 | + | ||
3 | +var path = require('path'); | ||
4 | +var uuid = require(path.join(__dirname, '..')); | ||
5 | + | ||
6 | +var arg = process.argv[2]; | ||
7 | + | ||
8 | +if ('--help' === arg) { | ||
9 | + console.log('\n USAGE: uuid [version] [options]\n\n'); | ||
10 | + console.log(' options:\n'); | ||
11 | + console.log(' --help Display this message and exit\n'); | ||
12 | + process.exit(0); | ||
13 | +} | ||
14 | + | ||
15 | +if (null == arg) { | ||
16 | + console.log(uuid()); | ||
17 | + process.exit(0); | ||
18 | +} | ||
19 | + | ||
20 | +if ('v1' !== arg && 'v4' !== arg) { | ||
21 | + console.error('Version must be RFC4122 version 1 or version 4, denoted as "v1" or "v4"'); | ||
22 | + process.exit(1); | ||
23 | +} | ||
24 | + | ||
25 | +console.log(uuid[arg]()); | ||
26 | +process.exit(0); |
node_modules/node-uuid/bower.json
0 → 100644
1 | +{ | ||
2 | + "name": "node-uuid", | ||
3 | + "version": "1.4.7", | ||
4 | + "homepage": "https://github.com/broofa/node-uuid", | ||
5 | + "authors": [ | ||
6 | + "Robert Kieffer <robert@broofa.com>" | ||
7 | + ], | ||
8 | + "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", | ||
9 | + "main": "uuid.js", | ||
10 | + "keywords": [ | ||
11 | + "uuid", | ||
12 | + "gid", | ||
13 | + "rfc4122" | ||
14 | + ], | ||
15 | + "license": "MIT", | ||
16 | + "ignore": [ | ||
17 | + "**/.*", | ||
18 | + "node_modules", | ||
19 | + "bower_components", | ||
20 | + "test", | ||
21 | + "tests" | ||
22 | + ] | ||
23 | +} |
node_modules/node-uuid/component.json
0 → 100644
1 | +{ | ||
2 | + "name": "node-uuid", | ||
3 | + "repo": "broofa/node-uuid", | ||
4 | + "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", | ||
5 | + "version": "1.4.7", | ||
6 | + "author": "Robert Kieffer <robert@broofa.com>", | ||
7 | + "contributors": [ | ||
8 | + { | ||
9 | + "name": "Christoph Tavan <dev@tavan.de>", | ||
10 | + "github": "https://github.com/ctavan" | ||
11 | + } | ||
12 | + ], | ||
13 | + "keywords": [ | ||
14 | + "uuid", | ||
15 | + "guid", | ||
16 | + "rfc4122" | ||
17 | + ], | ||
18 | + "dependencies": {}, | ||
19 | + "development": {}, | ||
20 | + "main": "uuid.js", | ||
21 | + "scripts": [ | ||
22 | + "uuid.js" | ||
23 | + ], | ||
24 | + "license": "MIT" | ||
25 | +} |
node_modules/node-uuid/lib/sha1-browser.js
0 → 100644
1 | +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | ||
2 | +/* SHA-1 (FIPS 180-4) implementation in JavaScript (c) Chris Veness 2002-2016 */ | ||
3 | +/* MIT Licence */ | ||
4 | +/* www.movable-type.co.uk/scripts/sha1.html */ | ||
5 | +/* */ | ||
6 | +/* - see http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html */ | ||
7 | +/* http://csrc.nist.gov/groups/ST/toolkit/examples.html */ | ||
8 | +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | ||
9 | + | ||
10 | +'use strict'; | ||
11 | + | ||
12 | +function f(s, x, y, z) { | ||
13 | + switch (s) { | ||
14 | + case 0: return (x & y) ^ (~x & z); // Ch() | ||
15 | + case 1: return x ^ y ^ z; // Parity() | ||
16 | + case 2: return (x & y) ^ (x & z) ^ (y & z); // Maj() | ||
17 | + case 3: return x ^ y ^ z; // Parity() | ||
18 | + } | ||
19 | +} | ||
20 | + | ||
21 | +function ROTL(x, n) { | ||
22 | + return (x<<n) | (x>>>(32-n)); | ||
23 | +} | ||
24 | + | ||
25 | +var Sha1 = {}; | ||
26 | + | ||
27 | +Sha1.hash = function(msg, options) { | ||
28 | + var defaults = { msgFormat: 'string', outFormat: 'hex' }; | ||
29 | + var opt = Object.assign(defaults, options); | ||
30 | + | ||
31 | + switch (opt.msgFormat) { | ||
32 | + default: // default is to convert string to UTF-8, as SHA only deals with byte-streams | ||
33 | + case 'string': msg = Sha1.utf8Encode(msg); break; | ||
34 | + case 'hex-bytes':msg = Sha1.hexBytesToString(msg); break; // mostly for running tests | ||
35 | + } | ||
36 | + | ||
37 | + // constants [4.2.1] | ||
38 | + var K = [ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 ]; | ||
39 | + | ||
40 | + // initial hash value [5.3.1] | ||
41 | + var H = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; | ||
42 | + | ||
43 | + // PREPROCESSING [6.1.1] | ||
44 | + | ||
45 | + msg += String.fromCharCode(0x80); // add trailing '1' bit (+ 0's padding) to string [5.1.1] | ||
46 | + | ||
47 | + // convert string msg into 512-bit/16-integer blocks arrays of ints [5.2.1] | ||
48 | + var l = msg.length/4 + 2; // length (in 32-bit integers) of msg + 1 + appended length | ||
49 | + var N = Math.ceil(l/16); // number of 16-integer-blocks required to hold 'l' ints | ||
50 | + var M = new Array(N); | ||
51 | + | ||
52 | + for (var i=0; i<N; i++) { | ||
53 | + M[i] = new Array(16); | ||
54 | + for (var j=0; j<16; j++) { // encode 4 chars per integer, big-endian encoding | ||
55 | + M[i][j] = (msg.charCodeAt(i*64+j*4)<<24) | (msg.charCodeAt(i*64+j*4+1)<<16) | | ||
56 | + (msg.charCodeAt(i*64+j*4+2)<<8) | (msg.charCodeAt(i*64+j*4+3)); | ||
57 | + } // note running off the end of msg is ok 'cos bitwise ops on NaN return 0 | ||
58 | + } | ||
59 | + // add length (in bits) into final pair of 32-bit integers (big-endian) [5.1.1] | ||
60 | + // note: most significant word would be (len-1)*8 >>> 32, but since JS converts | ||
61 | + // bitwise-op args to 32 bits, we need to simulate this by arithmetic operators | ||
62 | + M[N-1][14] = ((msg.length-1)*8) / Math.pow(2, 32); M[N-1][14] = Math.floor(M[N-1][14]); | ||
63 | + M[N-1][15] = ((msg.length-1)*8) & 0xffffffff; | ||
64 | + | ||
65 | + // HASH COMPUTATION [6.1.2] | ||
66 | + | ||
67 | + for (var i=0; i<N; i++) { | ||
68 | + var W = new Array(80); | ||
69 | + | ||
70 | + // 1 - prepare message schedule 'W' | ||
71 | + for (var t=0; t<16; t++) W[t] = M[i][t]; | ||
72 | + for (var t=16; t<80; t++) W[t] = ROTL(W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1); | ||
73 | + | ||
74 | + // 2 - initialise five working variables a, b, c, d, e with previous hash value | ||
75 | + var a = H[0], b = H[1], c = H[2], d = H[3], e = H[4]; | ||
76 | + | ||
77 | + // 3 - main loop (use JavaScript '>>> 0' to emulate UInt32 variables) | ||
78 | + for (var t=0; t<80; t++) { | ||
79 | + var s = Math.floor(t/20); // seq for blocks of 'f' functions and 'K' constants | ||
80 | + var T = (ROTL(a,5) + f(s,b,c,d) + e + K[s] + W[t]) >>> 0; | ||
81 | + e = d; | ||
82 | + d = c; | ||
83 | + c = ROTL(b, 30) >>> 0; | ||
84 | + b = a; | ||
85 | + a = T; | ||
86 | + } | ||
87 | + | ||
88 | + // 4 - compute the new intermediate hash value (note 'addition modulo 2^32' JavaScript | ||
89 | + // '>>> 0' coerces to unsigned UInt32 which achieves modulo 2^32 addition) | ||
90 | + H[0] = (H[0]+a) >>> 0; | ||
91 | + H[1] = (H[1]+b) >>> 0; | ||
92 | + H[2] = (H[2]+c) >>> 0; | ||
93 | + H[3] = (H[3]+d) >>> 0; | ||
94 | + H[4] = (H[4]+e) >>> 0; | ||
95 | + } | ||
96 | + | ||
97 | + // convert H0..H4 to hex strings (with leading zeros) | ||
98 | + for (var h=0; h<H.length; h++) H[h] = ('00000000'+H[h].toString(16)).slice(-8); | ||
99 | + | ||
100 | + // concatenate H0..H4, with separator if required | ||
101 | + var separator = opt.outFormat=='hex-w' ? ' ' : ''; | ||
102 | + | ||
103 | + return H.join(separator); | ||
104 | +}; | ||
105 | + | ||
106 | +Sha1.utf8Encode = function(str) { | ||
107 | + return unescape(encodeURIComponent(str)); | ||
108 | +}; | ||
109 | + | ||
110 | +Sha1.hexBytesToString = function(hexStr) { | ||
111 | + hexStr = hexStr.replace(' ', ''); // allow space-separated groups | ||
112 | + var str = ''; | ||
113 | + for (var i=0; i<hexStr.length; i+=2) { | ||
114 | + str += String.fromCharCode(parseInt(hexStr.slice(i, i+2), 16)); | ||
115 | + } | ||
116 | + return str; | ||
117 | +}; | ||
118 | + | ||
119 | + | ||
120 | +module.exports = Sha1; // CommonJs export |
node_modules/node-uuid/package.json
0 → 100644
1 | +{ | ||
2 | + "_args": [ | ||
3 | + [ | ||
4 | + { | ||
5 | + "raw": "node-uuid", | ||
6 | + "scope": null, | ||
7 | + "escapedName": "node-uuid", | ||
8 | + "name": "node-uuid", | ||
9 | + "rawSpec": "", | ||
10 | + "spec": "latest", | ||
11 | + "type": "tag" | ||
12 | + }, | ||
13 | + "/Users/fzy/project/koa2_Sequelize_project" | ||
14 | + ] | ||
15 | + ], | ||
16 | + "_from": "node-uuid@latest", | ||
17 | + "_id": "node-uuid@1.4.8", | ||
18 | + "_inCache": true, | ||
19 | + "_location": "/node-uuid", | ||
20 | + "_nodeVersion": "6.9.2", | ||
21 | + "_npmOperationalInternal": { | ||
22 | + "host": "packages-12-west.internal.npmjs.com", | ||
23 | + "tmp": "tmp/node-uuid-1.4.8.tgz_1490142638297_0.6400028455536813" | ||
24 | + }, | ||
25 | + "_npmUser": { | ||
26 | + "name": "broofa", | ||
27 | + "email": "robert@broofa.com" | ||
28 | + }, | ||
29 | + "_npmVersion": "4.3.0", | ||
30 | + "_phantomChildren": {}, | ||
31 | + "_requested": { | ||
32 | + "raw": "node-uuid", | ||
33 | + "scope": null, | ||
34 | + "escapedName": "node-uuid", | ||
35 | + "name": "node-uuid", | ||
36 | + "rawSpec": "", | ||
37 | + "spec": "latest", | ||
38 | + "type": "tag" | ||
39 | + }, | ||
40 | + "_requiredBy": [ | ||
41 | + "#DEV:/", | ||
42 | + "#USER" | ||
43 | + ], | ||
44 | + "_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", | ||
45 | + "_shasum": "b040eb0923968afabf8d32fb1f17f1167fdab907", | ||
46 | + "_shrinkwrap": null, | ||
47 | + "_spec": "node-uuid", | ||
48 | + "_where": "/Users/fzy/project/koa2_Sequelize_project", | ||
49 | + "author": { | ||
50 | + "name": "Robert Kieffer", | ||
51 | + "email": "robert@broofa.com" | ||
52 | + }, | ||
53 | + "bin": { | ||
54 | + "uuid": "./bin/uuid" | ||
55 | + }, | ||
56 | + "bugs": { | ||
57 | + "url": "https://github.com/broofa/node-uuid/issues" | ||
58 | + }, | ||
59 | + "contributors": [ | ||
60 | + { | ||
61 | + "name": "AJ ONeal", | ||
62 | + "email": "coolaj86@gmail.com" | ||
63 | + }, | ||
64 | + { | ||
65 | + "name": "Christoph Tavan", | ||
66 | + "email": "dev@tavan.de" | ||
67 | + } | ||
68 | + ], | ||
69 | + "dependencies": {}, | ||
70 | + "deprecated": "Use uuid module instead", | ||
71 | + "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.", | ||
72 | + "devDependencies": { | ||
73 | + "nyc": "^2.2.0" | ||
74 | + }, | ||
75 | + "directories": {}, | ||
76 | + "dist": { | ||
77 | + "shasum": "b040eb0923968afabf8d32fb1f17f1167fdab907", | ||
78 | + "tarball": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz" | ||
79 | + }, | ||
80 | + "gitHead": "6f0f31b997cd6bec7919223e8897454350ed820f", | ||
81 | + "homepage": "https://github.com/broofa/node-uuid", | ||
82 | + "installable": true, | ||
83 | + "keywords": [ | ||
84 | + "guid", | ||
85 | + "rfc4122", | ||
86 | + "uuid" | ||
87 | + ], | ||
88 | + "lib": ".", | ||
89 | + "licenses": [ | ||
90 | + { | ||
91 | + "type": "MIT", | ||
92 | + "url": "https://raw.github.com/broofa/node-uuid/master/LICENSE.md" | ||
93 | + } | ||
94 | + ], | ||
95 | + "main": "./uuid.js", | ||
96 | + "maintainers": [ | ||
97 | + { | ||
98 | + "name": "broofa", | ||
99 | + "email": "robert@broofa.com" | ||
100 | + } | ||
101 | + ], | ||
102 | + "name": "node-uuid", | ||
103 | + "optionalDependencies": {}, | ||
104 | + "readme": "# node-uuid\n\nDEPRECATED: Use the `uuid` package instead. See\n\n* On NPM: https://www.npmjs.com/package/uuid\n* On Github: https://github.com/kelektiv/node-uuid\n\n(Yes, the github project is still called \"node-uuid\". We merged the two projects. Sorry for the confusion.)\n", | ||
105 | + "readmeFilename": "README.md", | ||
106 | + "repository": { | ||
107 | + "type": "git", | ||
108 | + "url": "git+https://github.com/broofa/node-uuid.git" | ||
109 | + }, | ||
110 | + "scripts": { | ||
111 | + "coverage": "nyc npm test && nyc report", | ||
112 | + "test": "node test/test.js" | ||
113 | + }, | ||
114 | + "url": "http://github.com/broofa/node-uuid", | ||
115 | + "version": "1.4.8" | ||
116 | +} |
node_modules/node-uuid/test/compare_v1.js
0 → 100644
1 | +var assert = require('assert'), | ||
2 | + nodeuuid = require('../uuid'), | ||
3 | + uuidjs = require('uuid-js'), | ||
4 | + libuuid = require('uuid').generate, | ||
5 | + util = require('util'), | ||
6 | + exec = require('child_process').exec, | ||
7 | + os = require('os'); | ||
8 | + | ||
9 | +// On Mac Os X / macports there's only the ossp-uuid package that provides uuid | ||
10 | +// On Linux there's uuid-runtime which provides uuidgen | ||
11 | +var uuidCmd = os.type() === 'Darwin' ? 'uuid -1' : 'uuidgen -t'; | ||
12 | + | ||
13 | +function compare(ids) { | ||
14 | + console.log(ids); | ||
15 | + for (var i = 0; i < ids.length; i++) { | ||
16 | + var id = ids[i].split('-'); | ||
17 | + id = [id[2], id[1], id[0]].join(''); | ||
18 | + ids[i] = id; | ||
19 | + } | ||
20 | + var sorted = ([].concat(ids)).sort(); | ||
21 | + | ||
22 | + if (sorted.toString() !== ids.toString()) { | ||
23 | + console.log('Warning: sorted !== ids'); | ||
24 | + } else { | ||
25 | + console.log('everything in order!'); | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +// Test time order of v1 uuids | ||
30 | +var ids = []; | ||
31 | +while (ids.length < 10e3) ids.push(nodeuuid.v1()); | ||
32 | + | ||
33 | +var max = 10; | ||
34 | +console.log('node-uuid:'); | ||
35 | +ids = []; | ||
36 | +for (var i = 0; i < max; i++) ids.push(nodeuuid.v1()); | ||
37 | +compare(ids); | ||
38 | + | ||
39 | +console.log(''); | ||
40 | +console.log('uuidjs:'); | ||
41 | +ids = []; | ||
42 | +for (var i = 0; i < max; i++) ids.push(uuidjs.create(1).toString()); | ||
43 | +compare(ids); | ||
44 | + | ||
45 | +console.log(''); | ||
46 | +console.log('libuuid:'); | ||
47 | +ids = []; | ||
48 | +var count = 0; | ||
49 | +var last = function() { | ||
50 | + compare(ids); | ||
51 | +} | ||
52 | +var cb = function(err, stdout, stderr) { | ||
53 | + ids.push(stdout.substring(0, stdout.length-1)); | ||
54 | + count++; | ||
55 | + if (count < max) { | ||
56 | + return next(); | ||
57 | + } | ||
58 | + last(); | ||
59 | +}; | ||
60 | +var next = function() { | ||
61 | + exec(uuidCmd, cb); | ||
62 | +}; | ||
63 | +next(); |
node_modules/node-uuid/test/test.html
0 → 100644
1 | +<html> | ||
2 | + <head> | ||
3 | + <style> | ||
4 | + div { | ||
5 | + font-family: monospace; | ||
6 | + font-size: 8pt; | ||
7 | + } | ||
8 | + div.log {color: #444;} | ||
9 | + div.warn {color: #550;} | ||
10 | + div.error {color: #800; font-weight: bold;} | ||
11 | + </style> | ||
12 | + <script src="../uuid.js"></script> | ||
13 | + </head> | ||
14 | + <body> | ||
15 | + <script src="./test.js"></script> | ||
16 | + </body> | ||
17 | +</html> |
node_modules/node-uuid/test/test.js
0 → 100644
1 | +if (!this.uuid) { | ||
2 | + // node.js | ||
3 | + uuid = require('../uuid'); | ||
4 | + if (!/_rb/.test(uuid._rng.toString())) { | ||
5 | + throw new Error("should use crypto for node.js"); | ||
6 | + } | ||
7 | +} | ||
8 | + | ||
9 | +// | ||
10 | +// x-platform log/assert shims | ||
11 | +// | ||
12 | + | ||
13 | +function _log(msg, type) { | ||
14 | + type = type || 'log'; | ||
15 | + | ||
16 | + if (typeof(document) != 'undefined') { | ||
17 | + document.write('<div class="' + type + '">' + msg.replace(/\n/g, '<br />') + '</div>'); | ||
18 | + } | ||
19 | + if (typeof(console) != 'undefined') { | ||
20 | + var color = { | ||
21 | + log: '\033[39m', | ||
22 | + warn: '\033[33m', | ||
23 | + error: '\033[31m' | ||
24 | + }; | ||
25 | + console[type](color[type] + msg + color.log); | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +function log(msg) {_log(msg, 'log');} | ||
30 | +function warn(msg) {_log(msg, 'warn');} | ||
31 | +function error(msg) {_log(msg, 'error');} | ||
32 | + | ||
33 | +function assert(res, msg) { | ||
34 | + if (!res) { | ||
35 | + error('FAIL: ' + msg); | ||
36 | + } else { | ||
37 | + log('Pass: ' + msg); | ||
38 | + } | ||
39 | +} | ||
40 | + | ||
41 | +// | ||
42 | +// Unit tests | ||
43 | +// | ||
44 | + | ||
45 | +// Verify ordering of v1 ids created with explicit times | ||
46 | +var TIME = 1321644961388; // 2011-11-18 11:36:01.388-08:00 | ||
47 | + | ||
48 | +function compare(name, ids) { | ||
49 | + ids = ids.map(function(id) { | ||
50 | + return id.split('-').reverse().join('-'); | ||
51 | + }).sort(); | ||
52 | + var sorted = ([].concat(ids)).sort(); | ||
53 | + | ||
54 | + assert(sorted.toString() == ids.toString(), name + ' have expected order'); | ||
55 | +} | ||
56 | + | ||
57 | +// Verify ordering of v1 ids created using default behavior | ||
58 | +compare('uuids with current time', [ | ||
59 | + uuid.v1(), | ||
60 | + uuid.v1(), | ||
61 | + uuid.v1(), | ||
62 | + uuid.v1(), | ||
63 | + uuid.v1() | ||
64 | +]); | ||
65 | + | ||
66 | +// Verify ordering of v1 ids created with explicit times | ||
67 | +compare('uuids with time option', [ | ||
68 | + uuid.v1({msecs: TIME - 10*3600*1000}), | ||
69 | + uuid.v1({msecs: TIME - 1}), | ||
70 | + uuid.v1({msecs: TIME}), | ||
71 | + uuid.v1({msecs: TIME + 1}), | ||
72 | + uuid.v1({msecs: TIME + 28*24*3600*1000}) | ||
73 | +]); | ||
74 | + | ||
75 | +assert( | ||
76 | + uuid.v1({msecs: TIME}) != uuid.v1({msecs: TIME}), | ||
77 | + 'IDs created at same msec are different' | ||
78 | +); | ||
79 | + | ||
80 | +// Verify throw if too many ids created | ||
81 | +var thrown = false; | ||
82 | +try { | ||
83 | + uuid.v1({msecs: TIME, nsecs: 10000}); | ||
84 | +} catch (e) { | ||
85 | + thrown = true; | ||
86 | +} | ||
87 | +assert(thrown, 'Exception thrown when > 10K ids created in 1 ms'); | ||
88 | + | ||
89 | +// Verify clock regression bumps clockseq | ||
90 | +var uidt = uuid.v1({msecs: TIME}); | ||
91 | +var uidtb = uuid.v1({msecs: TIME - 1}); | ||
92 | +assert( | ||
93 | + parseInt(uidtb.split('-')[3], 16) - parseInt(uidt.split('-')[3], 16) === 1, | ||
94 | + 'Clock regression by msec increments the clockseq' | ||
95 | +); | ||
96 | + | ||
97 | +// Verify clock regression bumps clockseq | ||
98 | +var uidtn = uuid.v1({msecs: TIME, nsecs: 10}); | ||
99 | +var uidtnb = uuid.v1({msecs: TIME, nsecs: 9}); | ||
100 | +assert( | ||
101 | + parseInt(uidtnb.split('-')[3], 16) - parseInt(uidtn.split('-')[3], 16) === 1, | ||
102 | + 'Clock regression by nsec increments the clockseq' | ||
103 | +); | ||
104 | + | ||
105 | +// Verify explicit options produce expected id | ||
106 | +var id = uuid.v1({ | ||
107 | + msecs: 1321651533573, | ||
108 | + nsecs: 5432, | ||
109 | + clockseq: 0x385c, | ||
110 | + node: [ 0x61, 0xcd, 0x3c, 0xbb, 0x32, 0x10 ] | ||
111 | +}); | ||
112 | +assert(id == 'd9428888-122b-11e1-b85c-61cd3cbb3210', 'Explicit options produce expected id'); | ||
113 | + | ||
114 | +// Verify adjacent ids across a msec boundary are 1 time unit apart | ||
115 | +var u0 = uuid.v1({msecs: TIME, nsecs: 9999}); | ||
116 | +var u1 = uuid.v1({msecs: TIME + 1, nsecs: 0}); | ||
117 | + | ||
118 | +var before = u0.split('-')[0], after = u1.split('-')[0]; | ||
119 | +var dt = parseInt(after, 16) - parseInt(before, 16); | ||
120 | +assert(dt === 1, 'Ids spanning 1ms boundary are 100ns apart'); | ||
121 | + | ||
122 | +// | ||
123 | +// Test parse/unparse | ||
124 | +// | ||
125 | + | ||
126 | +id = '00112233445566778899aabbccddeeff'; | ||
127 | +assert(uuid.unparse(uuid.parse(id.substr(0,10))) == | ||
128 | + '00112233-4400-0000-0000-000000000000', 'Short parse'); | ||
129 | +assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) == | ||
130 | + '00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse'); | ||
131 | + | ||
132 | +// | ||
133 | +// Perf tests | ||
134 | +// | ||
135 | + | ||
136 | +var generators = { | ||
137 | + v1: uuid.v1, | ||
138 | + v4: uuid.v4 | ||
139 | +}; | ||
140 | + | ||
141 | +var UUID_FORMAT = { | ||
142 | + v1: /[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i, | ||
143 | + v4: /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i | ||
144 | +}; | ||
145 | + | ||
146 | +var N = 1e4; | ||
147 | + | ||
148 | +// Get %'age an actual value differs from the ideal value | ||
149 | +function divergence(actual, ideal) { | ||
150 | + return Math.round(100*100*(actual - ideal)/ideal)/100; | ||
151 | +} | ||
152 | + | ||
153 | +function rate(msg, t) { | ||
154 | + log(msg + ': ' + (N / (Date.now() - t) * 1e3 | 0) + ' uuids\/second'); | ||
155 | +} | ||
156 | + | ||
157 | +for (var version in generators) { | ||
158 | + var counts = {}, max = 0; | ||
159 | + var generator = generators[version]; | ||
160 | + var format = UUID_FORMAT[version]; | ||
161 | + | ||
162 | + log('\nSanity check ' + N + ' ' + version + ' uuids'); | ||
163 | + for (var i = 0, ok = 0; i < N; i++) { | ||
164 | + id = generator(); | ||
165 | + if (!format.test(id)) { | ||
166 | + throw Error(id + ' is not a valid UUID string'); | ||
167 | + } | ||
168 | + | ||
169 | + if (id != uuid.unparse(uuid.parse(id))) { | ||
170 | + assert(fail, id + ' is not a valid id'); | ||
171 | + } | ||
172 | + | ||
173 | + // Count digits for our randomness check | ||
174 | + if (version == 'v4') { | ||
175 | + var digits = id.replace(/-/g, '').split(''); | ||
176 | + for (var j = digits.length-1; j >= 0; j--) { | ||
177 | + var c = digits[j]; | ||
178 | + max = Math.max(max, counts[c] = (counts[c] || 0) + 1); | ||
179 | + } | ||
180 | + } | ||
181 | + } | ||
182 | + | ||
183 | + // Check randomness for v4 UUIDs | ||
184 | + if (version == 'v4') { | ||
185 | + // Limit that we get worried about randomness. (Purely empirical choice, this!) | ||
186 | + var limit = 2*100*Math.sqrt(1/N); | ||
187 | + | ||
188 | + log('\nChecking v4 randomness. Distribution of Hex Digits (% deviation from ideal)'); | ||
189 | + | ||
190 | + for (var i = 0; i < 16; i++) { | ||
191 | + var c = i.toString(16); | ||
192 | + var bar = '', n = counts[c], p = Math.round(n/max*100|0); | ||
193 | + | ||
194 | + // 1-3,5-8, and D-F: 1:16 odds over 30 digits | ||
195 | + var ideal = N*30/16; | ||
196 | + if (i == 4) { | ||
197 | + // 4: 1:1 odds on 1 digit, plus 1:16 odds on 30 digits | ||
198 | + ideal = N*(1 + 30/16); | ||
199 | + } else if (i >= 8 && i <= 11) { | ||
200 | + // 8-B: 1:4 odds on 1 digit, plus 1:16 odds on 30 digits | ||
201 | + ideal = N*(1/4 + 30/16); | ||
202 | + } else { | ||
203 | + // Otherwise: 1:16 odds on 30 digits | ||
204 | + ideal = N*30/16; | ||
205 | + } | ||
206 | + var d = divergence(n, ideal); | ||
207 | + | ||
208 | + // Draw bar using UTF squares (just for grins) | ||
209 | + var s = n/max*50 | 0; | ||
210 | + while (s--) bar += '='; | ||
211 | + | ||
212 | + assert(Math.abs(d) < limit, c + ' |' + bar + '| ' + counts[c] + ' (' + d + '% < ' + limit + '%)'); | ||
213 | + } | ||
214 | + } | ||
215 | +} | ||
216 | + | ||
217 | +// Perf tests | ||
218 | +for (var version in generators) { | ||
219 | + log('\nPerformance testing ' + version + ' UUIDs'); | ||
220 | + var generator = generators[version]; | ||
221 | + var buf = new uuid.BufferClass(16); | ||
222 | + | ||
223 | + for (var i = 0, t = Date.now(); i < N; i++) generator(); | ||
224 | + rate('uuid.' + version + '()', t); | ||
225 | + | ||
226 | + for (var i = 0, t = Date.now(); i < N; i++) generator('binary'); | ||
227 | + rate('uuid.' + version + '(\'binary\')', t); | ||
228 | + | ||
229 | + for (var i = 0, t = Date.now(); i < N; i++) generator('binary', buf); | ||
230 | + rate('uuid.' + version + '(\'binary\', buffer)', t); | ||
231 | +} |
node_modules/node-uuid/uuid.js
0 → 100644
1 | +// uuid.js | ||
2 | +// | ||
3 | +// Copyright (c) 2010-2012 Robert Kieffer | ||
4 | +// MIT License - http://opensource.org/licenses/mit-license.php | ||
5 | + | ||
6 | +/*global window, require, define */ | ||
7 | +(function(_window) { | ||
8 | + 'use strict'; | ||
9 | + | ||
10 | + // Unique ID creation requires a high quality random # generator. We feature | ||
11 | + // detect to determine the best RNG source, normalizing to a function that | ||
12 | + // returns 128-bits of randomness, since that's what's usually required | ||
13 | + var _rng, _mathRNG, _nodeRNG, _whatwgRNG, _previousRoot; | ||
14 | + | ||
15 | + function setupBrowser() { | ||
16 | + // Allow for MSIE11 msCrypto | ||
17 | + var _crypto = _window.crypto || _window.msCrypto; | ||
18 | + | ||
19 | + if (!_rng && _crypto && _crypto.getRandomValues) { | ||
20 | + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto | ||
21 | + // | ||
22 | + // Moderately fast, high quality | ||
23 | + try { | ||
24 | + var _rnds8 = new Uint8Array(16); | ||
25 | + _whatwgRNG = _rng = function whatwgRNG() { | ||
26 | + _crypto.getRandomValues(_rnds8); | ||
27 | + return _rnds8; | ||
28 | + }; | ||
29 | + _rng(); | ||
30 | + } catch(e) {} | ||
31 | + } | ||
32 | + | ||
33 | + if (!_rng) { | ||
34 | + // Math.random()-based (RNG) | ||
35 | + // | ||
36 | + // If all else fails, use Math.random(). It's fast, but is of unspecified | ||
37 | + // quality. | ||
38 | + var _rnds = new Array(16); | ||
39 | + _mathRNG = _rng = function() { | ||
40 | + for (var i = 0, r; i < 16; i++) { | ||
41 | + if ((i & 0x03) === 0) { r = Math.random() * 0x100000000; } | ||
42 | + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; | ||
43 | + } | ||
44 | + | ||
45 | + return _rnds; | ||
46 | + }; | ||
47 | + if ('undefined' !== typeof console && console.warn) { | ||
48 | + console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()"); | ||
49 | + } | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + function setupNode() { | ||
54 | + // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html | ||
55 | + // | ||
56 | + // Moderately fast, high quality | ||
57 | + if ('function' === typeof require) { | ||
58 | + try { | ||
59 | + var _rb = require('crypto').randomBytes; | ||
60 | + _nodeRNG = _rng = _rb && function() {return _rb(16);}; | ||
61 | + _rng(); | ||
62 | + } catch(e) {} | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | + if (_window) { | ||
67 | + setupBrowser(); | ||
68 | + } else { | ||
69 | + setupNode(); | ||
70 | + } | ||
71 | + | ||
72 | + // Buffer class to use | ||
73 | + var BufferClass = ('function' === typeof Buffer) ? Buffer : Array; | ||
74 | + | ||
75 | + // Maps for number <-> hex string conversion | ||
76 | + var _byteToHex = []; | ||
77 | + var _hexToByte = {}; | ||
78 | + for (var i = 0; i < 256; i++) { | ||
79 | + _byteToHex[i] = (i + 0x100).toString(16).substr(1); | ||
80 | + _hexToByte[_byteToHex[i]] = i; | ||
81 | + } | ||
82 | + | ||
83 | + // **`parse()` - Parse a UUID into it's component bytes** | ||
84 | + function parse(s, buf, offset) { | ||
85 | + var i = (buf && offset) || 0, ii = 0; | ||
86 | + | ||
87 | + buf = buf || []; | ||
88 | + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { | ||
89 | + if (ii < 16) { // Don't overflow! | ||
90 | + buf[i + ii++] = _hexToByte[oct]; | ||
91 | + } | ||
92 | + }); | ||
93 | + | ||
94 | + // Zero out remaining bytes if string was short | ||
95 | + while (ii < 16) { | ||
96 | + buf[i + ii++] = 0; | ||
97 | + } | ||
98 | + | ||
99 | + return buf; | ||
100 | + } | ||
101 | + | ||
102 | + // **`unparse()` - Convert UUID byte array (ala parse()) into a string** | ||
103 | + function unparse(buf, offset) { | ||
104 | + var i = offset || 0, bth = _byteToHex; | ||
105 | + return bth[buf[i++]] + bth[buf[i++]] + | ||
106 | + bth[buf[i++]] + bth[buf[i++]] + '-' + | ||
107 | + bth[buf[i++]] + bth[buf[i++]] + '-' + | ||
108 | + bth[buf[i++]] + bth[buf[i++]] + '-' + | ||
109 | + bth[buf[i++]] + bth[buf[i++]] + '-' + | ||
110 | + bth[buf[i++]] + bth[buf[i++]] + | ||
111 | + bth[buf[i++]] + bth[buf[i++]] + | ||
112 | + bth[buf[i++]] + bth[buf[i++]]; | ||
113 | + } | ||
114 | + | ||
115 | + // **`v1()` - Generate time-based UUID** | ||
116 | + // | ||
117 | + // Inspired by https://github.com/LiosK/UUID.js | ||
118 | + // and http://docs.python.org/library/uuid.html | ||
119 | + | ||
120 | + // random #'s we need to init node and clockseq | ||
121 | + var _seedBytes = _rng(); | ||
122 | + | ||
123 | + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) | ||
124 | + var _nodeId = [ | ||
125 | + _seedBytes[0] | 0x01, | ||
126 | + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] | ||
127 | + ]; | ||
128 | + | ||
129 | + // Per 4.2.2, randomize (14 bit) clockseq | ||
130 | + var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; | ||
131 | + | ||
132 | + // Previous uuid creation time | ||
133 | + var _lastMSecs = 0, _lastNSecs = 0; | ||
134 | + | ||
135 | + // See https://github.com/broofa/node-uuid for API details | ||
136 | + function v1(options, buf, offset) { | ||
137 | + var i = buf && offset || 0; | ||
138 | + var b = buf || []; | ||
139 | + | ||
140 | + options = options || {}; | ||
141 | + | ||
142 | + var clockseq = (options.clockseq != null) ? options.clockseq : _clockseq; | ||
143 | + | ||
144 | + // UUID timestamps are 100 nano-second units since the Gregorian epoch, | ||
145 | + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so | ||
146 | + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' | ||
147 | + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. | ||
148 | + var msecs = (options.msecs != null) ? options.msecs : new Date().getTime(); | ||
149 | + | ||
150 | + // Per 4.2.1.2, use count of uuid's generated during the current clock | ||
151 | + // cycle to simulate higher resolution clock | ||
152 | + var nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1; | ||
153 | + | ||
154 | + // Time since last uuid creation (in msecs) | ||
155 | + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; | ||
156 | + | ||
157 | + // Per 4.2.1.2, Bump clockseq on clock regression | ||
158 | + if (dt < 0 && options.clockseq == null) { | ||
159 | + clockseq = clockseq + 1 & 0x3fff; | ||
160 | + } | ||
161 | + | ||
162 | + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new | ||
163 | + // time interval | ||
164 | + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { | ||
165 | + nsecs = 0; | ||
166 | + } | ||
167 | + | ||
168 | + // Per 4.2.1.2 Throw error if too many uuids are requested | ||
169 | + if (nsecs >= 10000) { | ||
170 | + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); | ||
171 | + } | ||
172 | + | ||
173 | + _lastMSecs = msecs; | ||
174 | + _lastNSecs = nsecs; | ||
175 | + _clockseq = clockseq; | ||
176 | + | ||
177 | + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch | ||
178 | + msecs += 12219292800000; | ||
179 | + | ||
180 | + // `time_low` | ||
181 | + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; | ||
182 | + b[i++] = tl >>> 24 & 0xff; | ||
183 | + b[i++] = tl >>> 16 & 0xff; | ||
184 | + b[i++] = tl >>> 8 & 0xff; | ||
185 | + b[i++] = tl & 0xff; | ||
186 | + | ||
187 | + // `time_mid` | ||
188 | + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; | ||
189 | + b[i++] = tmh >>> 8 & 0xff; | ||
190 | + b[i++] = tmh & 0xff; | ||
191 | + | ||
192 | + // `time_high_and_version` | ||
193 | + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version | ||
194 | + b[i++] = tmh >>> 16 & 0xff; | ||
195 | + | ||
196 | + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) | ||
197 | + b[i++] = clockseq >>> 8 | 0x80; | ||
198 | + | ||
199 | + // `clock_seq_low` | ||
200 | + b[i++] = clockseq & 0xff; | ||
201 | + | ||
202 | + // `node` | ||
203 | + var node = options.node || _nodeId; | ||
204 | + for (var n = 0; n < 6; n++) { | ||
205 | + b[i + n] = node[n]; | ||
206 | + } | ||
207 | + | ||
208 | + return buf ? buf : unparse(b); | ||
209 | + } | ||
210 | + | ||
211 | + // **`v4()` - Generate random UUID** | ||
212 | + | ||
213 | + // See https://github.com/broofa/node-uuid for API details | ||
214 | + function v4(options, buf, offset) { | ||
215 | + // Deprecated - 'format' argument, as supported in v1.2 | ||
216 | + var i = buf && offset || 0; | ||
217 | + | ||
218 | + if (typeof(options) === 'string') { | ||
219 | + buf = (options === 'binary') ? new BufferClass(16) : null; | ||
220 | + options = null; | ||
221 | + } | ||
222 | + options = options || {}; | ||
223 | + | ||
224 | + var rnds = options.random || (options.rng || _rng)(); | ||
225 | + | ||
226 | + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` | ||
227 | + rnds[6] = (rnds[6] & 0x0f) | 0x40; | ||
228 | + rnds[8] = (rnds[8] & 0x3f) | 0x80; | ||
229 | + | ||
230 | + // Copy bytes to buffer, if provided | ||
231 | + if (buf) { | ||
232 | + for (var ii = 0; ii < 16; ii++) { | ||
233 | + buf[i + ii] = rnds[ii]; | ||
234 | + } | ||
235 | + } | ||
236 | + | ||
237 | + return buf || unparse(rnds); | ||
238 | + } | ||
239 | + | ||
240 | + // Export public API | ||
241 | + var uuid = v4; | ||
242 | + uuid.v1 = v1; | ||
243 | + uuid.v4 = v4; | ||
244 | + uuid.parse = parse; | ||
245 | + uuid.unparse = unparse; | ||
246 | + uuid.BufferClass = BufferClass; | ||
247 | + uuid._rng = _rng; | ||
248 | + uuid._mathRNG = _mathRNG; | ||
249 | + uuid._nodeRNG = _nodeRNG; | ||
250 | + uuid._whatwgRNG = _whatwgRNG; | ||
251 | + | ||
252 | + if (('undefined' !== typeof module) && module.exports) { | ||
253 | + // Publish as node.js module | ||
254 | + module.exports = uuid; | ||
255 | + } else if (typeof define === 'function' && define.amd) { | ||
256 | + // Publish as AMD module | ||
257 | + define(function() {return uuid;}); | ||
258 | + | ||
259 | + | ||
260 | + } else { | ||
261 | + // Publish as global (in browsers) | ||
262 | + _previousRoot = _window.uuid; | ||
263 | + | ||
264 | + // **`noConflict()` - (browser only) to reset global 'uuid' var** | ||
265 | + uuid.noConflict = function() { | ||
266 | + _window.uuid = _previousRoot; | ||
267 | + return uuid; | ||
268 | + }; | ||
269 | + | ||
270 | + _window.uuid = uuid; | ||
271 | + } | ||
272 | +})('undefined' !== typeof window ? window : null); |
node_modules/node-uuid/v3.js
0 → 100644
1 | +var rng = require('./lib/rng'); | ||
2 | +var bytesToUuid = require('./lib/bytesToUuid'); | ||
3 | + | ||
4 | +function v3(name, namespaceUuid, buf, offset) { | ||
5 | + var i = buf && offset || 0; | ||
6 | + | ||
7 | + if (typeof(name) != 'string) { | ||
8 | + throw TypeError('name must be defined') | ||
9 | + } | ||
10 | + if (typeof(namespaceUuid) != 'string) { | ||
11 | + throw TypeError('name must be defined') | ||
12 | + } | ||
13 | + | ||
14 | + if (typeof(options) == 'string') { | ||
15 | + buf = options == 'binary' ? new Array(16) : null; | ||
16 | + options = null; | ||
17 | + } | ||
18 | + options = options || {}; | ||
19 | + | ||
20 | + var rnds = options.random || (options.rng || rng)(); | ||
21 | + | ||
22 | + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` | ||
23 | + rnds[6] = (rnds[6] & 0x0f) | 0x40; | ||
24 | + rnds[8] = (rnds[8] & 0x3f) | 0x80; | ||
25 | + | ||
26 | + // Copy bytes to buffer, if provided | ||
27 | + if (buf) { | ||
28 | + for (var ii = 0; ii < 16; ++ii) { | ||
29 | + buf[i + ii] = rnds[ii]; | ||
30 | + } | ||
31 | + } | ||
32 | + | ||
33 | + return buf || bytesToUuid(rnds); | ||
34 | +} | ||
35 | + | ||
36 | +exports.namespace = function(uuid) { | ||
37 | + // Parse namespace uuid | ||
38 | + var namespaceBytes = (uuid).match(/([0-9a-f][0-9a-f])/gi).map(function(s) { | ||
39 | + return parseInt(s, 16); | ||
40 | + }); | ||
41 | + | ||
42 | + return function(name) { | ||
43 | + var bytes = [].concat(namespaceBytes); | ||
44 | + | ||
45 | + var utf8String = unescape(encodeURIComponent(s)) | ||
46 | + for (var i = 0; i < utf8String.length; i++) { | ||
47 | + bytes.push(utf8String.charCodeAt(i)); | ||
48 | + } | ||
49 | + | ||
50 | + var hash = md5(bytes); | ||
51 | + } | ||
52 | +} | ||
53 | + | ||
54 | +module.exports = v4; |
@@ -36,6 +36,7 @@ | @@ -36,6 +36,7 @@ | ||
36 | "jsonwebtoken": "^7.4.2", | 36 | "jsonwebtoken": "^7.4.2", |
37 | "koa-cors": "0.0.16", | 37 | "koa-cors": "0.0.16", |
38 | "moment": "^2.18.1", | 38 | "moment": "^2.18.1", |
39 | + "node-uuid": "^1.4.8", | ||
39 | "nodemon": "^1.8.1", | 40 | "nodemon": "^1.8.1", |
40 | "objectid": "^3.2.1", | 41 | "objectid": "^3.2.1", |
41 | "request": "^2.81.0", | 42 | "request": "^2.81.0", |
-
请 注册 或 登录 后发表评论