ai 1.1.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +10 -24
- package/dist/ai-stream.d.ts +18 -0
- package/dist/ai-stream.js +132 -0
- package/dist/ai-stream.mjs +13 -0
- package/dist/anthropic-stream.d.ts +5 -0
- package/dist/anthropic-stream.js +133 -0
- package/dist/anthropic-stream.mjs +8 -0
- package/dist/chunk-265FSSO4.mjs +91 -0
- package/dist/chunk-2L3ZO4UM.mjs +45 -0
- package/dist/chunk-GT4HKF2X.mjs +33 -0
- package/dist/chunk-JGDC3BXD.mjs +22 -0
- package/dist/chunk-NK2CVBLI.mjs +38 -0
- package/dist/chunk-PEYAHBDF.mjs +43 -0
- package/dist/chunk-TJMME6CL.mjs +24 -0
- package/dist/huggingface-stream.d.ts +5 -0
- package/dist/huggingface-stream.js +121 -0
- package/dist/huggingface-stream.mjs +8 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +278 -0
- package/dist/index.mjs +35 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.js +12 -0
- package/dist/index.test.mjs +10 -0
- package/dist/langchain-stream.d.ts +12 -0
- package/dist/langchain-stream.js +102 -0
- package/dist/langchain-stream.mjs +8 -0
- package/dist/openai-stream.d.ts +5 -0
- package/dist/openai-stream.js +144 -0
- package/dist/openai-stream.mjs +8 -0
- package/dist/streaming-text-response.d.ts +17 -0
- package/dist/streaming-text-response.js +75 -0
- package/dist/streaming-text-response.mjs +9 -0
- package/package.json +78 -29
- package/react/dist/chunk-5PP6W52J.mjs +202 -0
- package/react/dist/chunk-6EH3SWMP.mjs +55 -0
- package/react/dist/chunk-PW6HSU2N.mjs +154 -0
- package/react/dist/index.d.ts +3 -0
- package/react/dist/index.js +424 -0
- package/react/dist/index.mjs +12 -0
- package/react/dist/types-f862f74a.d.ts +123 -0
- package/react/dist/use-chat.d.ts +42 -0
- package/react/dist/use-chat.js +276 -0
- package/react/dist/use-chat.mjs +8 -0
- package/react/dist/use-completion.d.ts +47 -0
- package/react/dist/use-completion.js +229 -0
- package/react/dist/use-completion.mjs +8 -0
- package/svelte/dist/chunk-6USBQIV6.mjs +177 -0
- package/svelte/dist/chunk-BQ64GHZ3.mjs +136 -0
- package/svelte/dist/chunk-CENOSGDG.mjs +493 -0
- package/svelte/dist/index.d.ts +4 -0
- package/svelte/dist/index.js +808 -0
- package/svelte/dist/index.mjs +11 -0
- package/svelte/dist/types-f862f74a.d.ts +123 -0
- package/svelte/dist/use-chat.d.ts +39 -0
- package/svelte/dist/use-chat.js +680 -0
- package/svelte/dist/use-chat.mjs +7 -0
- package/svelte/dist/use-completion.d.ts +38 -0
- package/svelte/dist/use-completion.js +640 -0
- package/svelte/dist/use-completion.mjs +7 -0
- package/.npmignore +0 -15
- package/.travis.yml +0 -4
- package/README.md +0 -21
- package/bin/ai.js +0 -22
- package/index.js +0 -37
- package/node_modules/request/.npmignore +0 -2
- package/node_modules/request/.travis.yml +0 -12
- package/node_modules/request/CHANGELOG.md +0 -954
- package/node_modules/request/LICENSE +0 -55
- package/node_modules/request/README.md +0 -421
- package/node_modules/request/index.js +0 -166
- package/node_modules/request/lib/cookies.js +0 -40
- package/node_modules/request/lib/copy.js +0 -8
- package/node_modules/request/lib/debug.js +0 -7
- package/node_modules/request/lib/getSafe.js +0 -34
- package/node_modules/request/lib/optional.js +0 -5
- package/node_modules/request/node_modules/aws-sign2/LICENSE +0 -55
- package/node_modules/request/node_modules/aws-sign2/README.md +0 -4
- package/node_modules/request/node_modules/aws-sign2/index.js +0 -202
- package/node_modules/request/node_modules/aws-sign2/package.json +0 -47
- package/node_modules/request/node_modules/forever-agent/LICENSE +0 -55
- package/node_modules/request/node_modules/forever-agent/README.md +0 -4
- package/node_modules/request/node_modules/forever-agent/index.js +0 -119
- package/node_modules/request/node_modules/forever-agent/package.json +0 -46
- package/node_modules/request/node_modules/form-data/License +0 -19
- package/node_modules/request/node_modules/form-data/Readme.md +0 -175
- package/node_modules/request/node_modules/form-data/lib/form_data.js +0 -351
- package/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +0 -3
- package/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1646
- package/node_modules/request/node_modules/form-data/node_modules/async/component.json +0 -11
- package/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +0 -1123
- package/node_modules/request/node_modules/form-data/node_modules/async/package.json +0 -60
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +0 -132
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +0 -186
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +0 -2
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +0 -7
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +0 -154
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +0 -99
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +0 -42
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +0 -6
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +0 -38
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +0 -21
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +0 -14
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +0 -48
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +0 -15
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +0 -18
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +0 -13
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +0 -13
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +0 -7
- package/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +0 -61
- package/node_modules/request/node_modules/form-data/node_modules/mime/LICENSE +0 -19
- package/node_modules/request/node_modules/form-data/node_modules/mime/README.md +0 -66
- package/node_modules/request/node_modules/form-data/node_modules/mime/mime.js +0 -114
- package/node_modules/request/node_modules/form-data/node_modules/mime/package.json +0 -59
- package/node_modules/request/node_modules/form-data/node_modules/mime/test.js +0 -84
- package/node_modules/request/node_modules/form-data/node_modules/mime/types/mime.types +0 -1588
- package/node_modules/request/node_modules/form-data/node_modules/mime/types/node.types +0 -77
- package/node_modules/request/node_modules/form-data/package.json +0 -80
- package/node_modules/request/node_modules/hawk/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/Makefile +0 -10
- package/node_modules/request/node_modules/hawk/README.md +0 -625
- package/node_modules/request/node_modules/hawk/example/usage.js +0 -78
- package/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
- package/node_modules/request/node_modules/hawk/images/logo.png +0 -0
- package/node_modules/request/node_modules/hawk/index.js +0 -1
- package/node_modules/request/node_modules/hawk/lib/browser.js +0 -507
- package/node_modules/request/node_modules/hawk/lib/client.js +0 -371
- package/node_modules/request/node_modules/hawk/lib/crypto.js +0 -118
- package/node_modules/request/node_modules/hawk/lib/index.js +0 -15
- package/node_modules/request/node_modules/hawk/lib/server.js +0 -523
- package/node_modules/request/node_modules/hawk/lib/utils.js +0 -183
- package/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/boom/README.md +0 -6
- package/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
- package/node_modules/request/node_modules/hawk/node_modules/boom/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +0 -207
- package/node_modules/request/node_modules/hawk/node_modules/boom/package.json +0 -64
- package/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +0 -245
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +0 -6
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +0 -68
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +0 -65
- package/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +0 -101
- package/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -33
- package/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -10
- package/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +0 -436
- package/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
- package/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -132
- package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +0 -585
- package/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +0 -70
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -86
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +0 -1078
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +0 -18
- package/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +0 -5
- package/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +0 -24
- package/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +0 -11
- package/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +0 -68
- package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +0 -16
- package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +0 -25
- package/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +0 -1
- package/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +0 -409
- package/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +0 -65
- package/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +0 -359
- package/node_modules/request/node_modules/hawk/package.json +0 -70
- package/node_modules/request/node_modules/hawk/test/browser.js +0 -817
- package/node_modules/request/node_modules/hawk/test/client.js +0 -206
- package/node_modules/request/node_modules/hawk/test/crypto.js +0 -86
- package/node_modules/request/node_modules/hawk/test/index.js +0 -316
- package/node_modules/request/node_modules/hawk/test/message.js +0 -246
- package/node_modules/request/node_modules/hawk/test/readme.js +0 -98
- package/node_modules/request/node_modules/hawk/test/server.js +0 -686
- package/node_modules/request/node_modules/hawk/test/uri.js +0 -456
- package/node_modules/request/node_modules/hawk/test/utils.js +0 -120
- package/node_modules/request/node_modules/http-signature/.dir-locals.el +0 -6
- package/node_modules/request/node_modules/http-signature/.npmignore +0 -7
- package/node_modules/request/node_modules/http-signature/LICENSE +0 -18
- package/node_modules/request/node_modules/http-signature/README.md +0 -75
- package/node_modules/request/node_modules/http-signature/http_signing.md +0 -296
- package/node_modules/request/node_modules/http-signature/lib/index.js +0 -25
- package/node_modules/request/node_modules/http-signature/lib/parser.js +0 -304
- package/node_modules/request/node_modules/http-signature/lib/signer.js +0 -179
- package/node_modules/request/node_modules/http-signature/lib/util.js +0 -249
- package/node_modules/request/node_modules/http-signature/lib/verify.js +0 -42
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +0 -2
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +0 -19
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +0 -50
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +0 -27
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +0 -267
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +0 -36
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +0 -317
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +0 -20
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +0 -63
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +0 -172
- package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +0 -296
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +0 -126
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +0 -196
- package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +0 -38
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +0 -71
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +0 -24
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/README +0 -82
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +0 -298
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +0 -245
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +0 -1485
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +0 -944
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +0 -36
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +0 -129
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +0 -839
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/float.json +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/int.json +0 -13
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/psinfo.json +0 -104
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/struct.json +0 -19
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.fail.js +0 -39
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.float.js +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.int.js +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.psinfo.js +0 -17
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.struct.js +0 -18
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.typedef.js +0 -15
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/typedef.json +0 -14
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.rfloat.js +0 -767
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.wfloat.js +0 -753
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.64.js +0 -638
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.rint.js +0 -101
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wbounds.js +0 -53
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wint.js +0 -92
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.64.js +0 -451
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.roundtrip.js +0 -81
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.ruint.js +0 -95
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.wuint.js +0 -156
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicr.js +0 -50
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicw.js +0 -44
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.char.js +0 -42
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.endian.js +0 -45
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.oldwrite.js +0 -28
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.readSize.js +0 -128
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.structw.js +0 -28
- package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.writeStruct.js +0 -31
- package/node_modules/request/node_modules/http-signature/package.json +0 -54
- package/node_modules/request/node_modules/json-stringify-safe/LICENSE +0 -27
- package/node_modules/request/node_modules/json-stringify-safe/README.md +0 -49
- package/node_modules/request/node_modules/json-stringify-safe/package.json +0 -51
- package/node_modules/request/node_modules/json-stringify-safe/stringify.js +0 -39
- package/node_modules/request/node_modules/json-stringify-safe/test.js +0 -128
- package/node_modules/request/node_modules/mime-types/.npmignore +0 -14
- package/node_modules/request/node_modules/mime-types/.travis.yml +0 -12
- package/node_modules/request/node_modules/mime-types/LICENSE +0 -22
- package/node_modules/request/node_modules/mime-types/Makefile +0 -9
- package/node_modules/request/node_modules/mime-types/README.md +0 -101
- package/node_modules/request/node_modules/mime-types/SOURCES.md +0 -17
- package/node_modules/request/node_modules/mime-types/component.json +0 -16
- package/node_modules/request/node_modules/mime-types/lib/custom.json +0 -27
- package/node_modules/request/node_modules/mime-types/lib/index.js +0 -75
- package/node_modules/request/node_modules/mime-types/lib/mime.json +0 -3317
- package/node_modules/request/node_modules/mime-types/lib/node.json +0 -55
- package/node_modules/request/node_modules/mime-types/package.json +0 -69
- package/node_modules/request/node_modules/node-uuid/.npmignore +0 -2
- package/node_modules/request/node_modules/node-uuid/LICENSE.md +0 -2
- package/node_modules/request/node_modules/node-uuid/README.md +0 -207
- package/node_modules/request/node_modules/node-uuid/benchmark/README.md +0 -53
- package/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +0 -174
- package/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +0 -34
- package/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +0 -34
- package/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +0 -84
- package/node_modules/request/node_modules/node-uuid/component.json +0 -18
- package/node_modules/request/node_modules/node-uuid/package.json +0 -54
- package/node_modules/request/node_modules/node-uuid/test/compare_v1.js +0 -63
- package/node_modules/request/node_modules/node-uuid/test/test.html +0 -17
- package/node_modules/request/node_modules/node-uuid/test/test.js +0 -228
- package/node_modules/request/node_modules/node-uuid/uuid.js +0 -245
- package/node_modules/request/node_modules/oauth-sign/LICENSE +0 -55
- package/node_modules/request/node_modules/oauth-sign/README.md +0 -4
- package/node_modules/request/node_modules/oauth-sign/index.js +0 -43
- package/node_modules/request/node_modules/oauth-sign/package.json +0 -49
- package/node_modules/request/node_modules/oauth-sign/test.js +0 -49
- package/node_modules/request/node_modules/qs/.jshintignore +0 -1
- package/node_modules/request/node_modules/qs/.jshintrc +0 -10
- package/node_modules/request/node_modules/qs/.npmignore +0 -18
- package/node_modules/request/node_modules/qs/.travis.yml +0 -4
- package/node_modules/request/node_modules/qs/LICENSE +0 -28
- package/node_modules/request/node_modules/qs/Makefile +0 -8
- package/node_modules/request/node_modules/qs/Readme.md +0 -120
- package/node_modules/request/node_modules/qs/index.js +0 -1
- package/node_modules/request/node_modules/qs/lib/index.js +0 -15
- package/node_modules/request/node_modules/qs/lib/parse.js +0 -151
- package/node_modules/request/node_modules/qs/lib/stringify.js +0 -52
- package/node_modules/request/node_modules/qs/lib/utils.js +0 -131
- package/node_modules/request/node_modules/qs/package.json +0 -61
- package/node_modules/request/node_modules/qs/test/parse.js +0 -236
- package/node_modules/request/node_modules/qs/test/stringify.js +0 -123
- package/node_modules/request/node_modules/stringstream/.npmignore +0 -15
- package/node_modules/request/node_modules/stringstream/.travis.yml +0 -4
- package/node_modules/request/node_modules/stringstream/LICENSE.txt +0 -4
- package/node_modules/request/node_modules/stringstream/README.md +0 -38
- package/node_modules/request/node_modules/stringstream/example.js +0 -27
- package/node_modules/request/node_modules/stringstream/package.json +0 -48
- package/node_modules/request/node_modules/stringstream/stringstream.js +0 -102
- package/node_modules/request/node_modules/tough-cookie/.jshintrc +0 -70
- package/node_modules/request/node_modules/tough-cookie/.npmignore +0 -3
- package/node_modules/request/node_modules/tough-cookie/.travis.yml +0 -8
- package/node_modules/request/node_modules/tough-cookie/LICENSE +0 -78
- package/node_modules/request/node_modules/tough-cookie/README.md +0 -412
- package/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +0 -239
- package/node_modules/request/node_modules/tough-cookie/lib/cookie.js +0 -1107
- package/node_modules/request/node_modules/tough-cookie/lib/memstore.js +0 -123
- package/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +0 -69
- package/node_modules/request/node_modules/tough-cookie/lib/store.js +0 -37
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +0 -20
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +0 -176
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +0 -87
- package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +0 -528
- package/node_modules/request/node_modules/tough-cookie/package.json +0 -67
- package/node_modules/request/node_modules/tough-cookie/public-suffix.txt +0 -5229
- package/node_modules/request/node_modules/tough-cookie/test.js +0 -1625
- package/node_modules/request/node_modules/tunnel-agent/.jshintrc +0 -5
- package/node_modules/request/node_modules/tunnel-agent/LICENSE +0 -55
- package/node_modules/request/node_modules/tunnel-agent/README.md +0 -4
- package/node_modules/request/node_modules/tunnel-agent/index.js +0 -236
- package/node_modules/request/node_modules/tunnel-agent/package.json +0 -46
- package/node_modules/request/package.json +0 -77
- package/node_modules/request/request.js +0 -1428
- package/test/fixtures/github-response.json +0 -1367
- package/test/index.js +0 -55
@@ -1,84 +0,0 @@
|
|
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
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "node-uuid",
|
3
|
-
"repo": "broofa/node-uuid",
|
4
|
-
"description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.",
|
5
|
-
"version": "1.4.0",
|
6
|
-
"author": "Robert Kieffer <robert@broofa.com>",
|
7
|
-
"contributors": [
|
8
|
-
{"name": "Christoph Tavan <dev@tavan.de>", "github": "https://github.com/ctavan"}
|
9
|
-
],
|
10
|
-
"keywords": ["uuid", "guid", "rfc4122"],
|
11
|
-
"dependencies": {},
|
12
|
-
"development": {},
|
13
|
-
"main": "uuid.js",
|
14
|
-
"scripts": [
|
15
|
-
"uuid.js"
|
16
|
-
],
|
17
|
-
"license": "MIT"
|
18
|
-
}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "node-uuid",
|
3
|
-
"description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.",
|
4
|
-
"url": "http://github.com/broofa/node-uuid",
|
5
|
-
"keywords": [
|
6
|
-
"uuid",
|
7
|
-
"guid",
|
8
|
-
"rfc4122"
|
9
|
-
],
|
10
|
-
"author": {
|
11
|
-
"name": "Robert Kieffer",
|
12
|
-
"email": "robert@broofa.com"
|
13
|
-
},
|
14
|
-
"contributors": [
|
15
|
-
{
|
16
|
-
"name": "Christoph Tavan",
|
17
|
-
"email": "dev@tavan.de"
|
18
|
-
}
|
19
|
-
],
|
20
|
-
"lib": ".",
|
21
|
-
"main": "./uuid.js",
|
22
|
-
"repository": {
|
23
|
-
"type": "git",
|
24
|
-
"url": "https://github.com/broofa/node-uuid.git"
|
25
|
-
},
|
26
|
-
"version": "1.4.1",
|
27
|
-
"readme": "# node-uuid\n\nSimple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.\n\nFeatures:\n\n* Generate RFC4122 version 1 or version 4 UUIDs\n* Runs in node.js and all browsers.\n* Registered as a [ComponentJS](https://github.com/component/component) [component](https://github.com/component/component/wiki/Components) ('broofa/node-uuid').\n* Cryptographically strong random # generation on supporting platforms\n* 1.1K minified and gzip'ed (Want something smaller? Check this [crazy shit](https://gist.github.com/982883) out! )\n* [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html)\n\n## Getting Started\n\nInstall it in your browser:\n\n```html\n<script src=\"uuid.js\"></script>\n```\n\nOr in node.js:\n\n```\nnpm install node-uuid\n```\n\n```javascript\nvar uuid = require('node-uuid');\n```\n\nThen create some ids ...\n\n```javascript\n// Generate a v1 (time-based) id\nuuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'\n\n// Generate a v4 (random) id\nuuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'\n```\n\n## API\n\n### uuid.v1([`options` [, `buffer` [, `offset`]]])\n\nGenerate and return a RFC4122 v1 (timestamp-based) UUID.\n\n* `options` - (Object) Optional uuid state to apply. Properties may include:\n\n * `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.\n * `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.\n * `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.\n * `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2.\n\n* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.\n* `offset` - (Number) Starting index in `buffer` at which to begin writing.\n\nReturns `buffer`, if specified, otherwise the string form of the UUID\n\nNotes:\n\n1. The randomly generated node id is only guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.)\n\nExample: Generate string UUID with fully-specified options\n\n```javascript\nuuid.v1({\n node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],\n clockseq: 0x1234,\n msecs: new Date('2011-11-01').getTime(),\n nsecs: 5678\n}); // -> \"710b962e-041c-11e1-9234-0123456789ab\"\n```\n\nExample: In-place generation of two binary IDs\n\n```javascript\n// Generate two ids in an array\nvar arr = new Array(32); // -> []\nuuid.v1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15]\nuuid.v1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 15]\n\n// Optionally use uuid.unparse() to get stringify the ids\nuuid.unparse(buffer); // -> '02a2ce90-1432-11e1-8558-0b488e4fc115'\nuuid.unparse(buffer, 16) // -> '02a31cb0-1432-11e1-8558-0b488e4fc115'\n```\n\n### uuid.v4([`options` [, `buffer` [, `offset`]]])\n\nGenerate and return a RFC4122 v4 UUID.\n\n* `options` - (Object) Optional uuid state to apply. Properties may include:\n\n * `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of randomly generated values\n * `rng` - (Function) Random # generator to use. Set to one of the built-in generators - `uuid.mathRNG` (all platforms), `uuid.nodeRNG` (node.js only), `uuid.whatwgRNG` (WebKit only) - or a custom function that returns an array[16] of byte values.\n\n* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.\n* `offset` - (Number) Starting index in `buffer` at which to begin writing.\n\nReturns `buffer`, if specified, otherwise the string form of the UUID\n\nExample: Generate string UUID with fully-specified options\n\n```javascript\nuuid.v4({\n random: [\n 0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,\n 0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36\n ]\n});\n// -> \"109156be-c4fb-41ea-b1b4-efe1671c5836\"\n```\n\nExample: Generate two IDs in a single buffer\n\n```javascript\nvar buffer = new Array(32); // (or 'new Buffer' in node.js)\nuuid.v4(null, buffer, 0);\nuuid.v4(null, buffer, 16);\n```\n\n### uuid.parse(id[, buffer[, offset]])\n### uuid.unparse(buffer[, offset])\n\nParse and unparse UUIDs\n\n * `id` - (String) UUID(-like) string\n * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used\n * `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0\n\nExample parsing and unparsing a UUID string\n\n```javascript\nvar bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> <Buffer 79 7f f0 43 11 eb 11 e1 80 d6 51 09 98 75 5d 10>\nvar string = uuid.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10'\n```\n\n### uuid.noConflict()\n\n(Browsers only) Set `uuid` property back to it's previous value.\n\nReturns the node-uuid object.\n\nExample:\n\n```javascript\nvar myUuid = uuid.noConflict();\nmyUuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'\n```\n\n## Deprecated APIs\n\nSupport for the following v1.2 APIs is available in v1.3, but is deprecated and will be removed in the next major version.\n\n### uuid([format [, buffer [, offset]]])\n\nuuid() has become uuid.v4(), and the `format` argument is now implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is assumed to be binary).\n\n### uuid.BufferClass\n\nThe class of container created when generating binary uuid data if no buffer argument is specified. This is expected to go away, with no replacement API.\n\n## Testing\n\nIn node.js\n\n```\n> cd test\n> node test.js\n```\n\nIn Browser\n\n```\nopen test/test.html\n```\n\n### Benchmarking\n\nRequires node.js\n\n```\nnpm install uuid uuid-js\nnode benchmark/benchmark.js\n```\n\nFor a more complete discussion of node-uuid performance, please see the `benchmark/README.md` file, and the [benchmark wiki](https://github.com/broofa/node-uuid/wiki/Benchmark)\n\nFor browser performance [checkout the JSPerf tests](http://jsperf.com/node-uuid-performance).\n\n## Release notes\n\n### 1.4.0\n\n* Improved module context detection\n* Removed public RNG functions\n\n### 1.3.2\n\n* Improve tests and handling of v1() options (Issue #24)\n* Expose RNG option to allow for perf testing with different generators\n\n### 1.3.0\n\n* Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!\n* Support for node.js crypto API\n* De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code\n",
|
28
|
-
"readmeFilename": "README.md",
|
29
|
-
"bugs": {
|
30
|
-
"url": "https://github.com/broofa/node-uuid/issues"
|
31
|
-
},
|
32
|
-
"_id": "node-uuid@1.4.1",
|
33
|
-
"dist": {
|
34
|
-
"shasum": "39aef510e5889a3dca9c895b506c73aae1bac048",
|
35
|
-
"tarball": "http://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz"
|
36
|
-
},
|
37
|
-
"_from": "node-uuid@~1.4.0",
|
38
|
-
"_npmVersion": "1.3.6",
|
39
|
-
"_npmUser": {
|
40
|
-
"name": "broofa",
|
41
|
-
"email": "robert@broofa.com"
|
42
|
-
},
|
43
|
-
"maintainers": [
|
44
|
-
{
|
45
|
-
"name": "broofa",
|
46
|
-
"email": "robert@broofa.com"
|
47
|
-
}
|
48
|
-
],
|
49
|
-
"directories": {},
|
50
|
-
"_shasum": "39aef510e5889a3dca9c895b506c73aae1bac048",
|
51
|
-
"_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz",
|
52
|
-
"homepage": "https://github.com/broofa/node-uuid",
|
53
|
-
"scripts": {}
|
54
|
-
}
|
@@ -1,63 +0,0 @@
|
|
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();
|
@@ -1,17 +0,0 @@
|
|
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>
|
@@ -1,228 +0,0 @@
|
|
1
|
-
if (!this.uuid) {
|
2
|
-
// node.js
|
3
|
-
uuid = require('../uuid');
|
4
|
-
}
|
5
|
-
|
6
|
-
//
|
7
|
-
// x-platform log/assert shims
|
8
|
-
//
|
9
|
-
|
10
|
-
function _log(msg, type) {
|
11
|
-
type = type || 'log';
|
12
|
-
|
13
|
-
if (typeof(document) != 'undefined') {
|
14
|
-
document.write('<div class="' + type + '">' + msg.replace(/\n/g, '<br />') + '</div>');
|
15
|
-
}
|
16
|
-
if (typeof(console) != 'undefined') {
|
17
|
-
var color = {
|
18
|
-
log: '\033[39m',
|
19
|
-
warn: '\033[33m',
|
20
|
-
error: '\033[31m'
|
21
|
-
};
|
22
|
-
console[type](color[type] + msg + color.log);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
function log(msg) {_log(msg, 'log');}
|
27
|
-
function warn(msg) {_log(msg, 'warn');}
|
28
|
-
function error(msg) {_log(msg, 'error');}
|
29
|
-
|
30
|
-
function assert(res, msg) {
|
31
|
-
if (!res) {
|
32
|
-
error('FAIL: ' + msg);
|
33
|
-
} else {
|
34
|
-
log('Pass: ' + msg);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
//
|
39
|
-
// Unit tests
|
40
|
-
//
|
41
|
-
|
42
|
-
// Verify ordering of v1 ids created with explicit times
|
43
|
-
var TIME = 1321644961388; // 2011-11-18 11:36:01.388-08:00
|
44
|
-
|
45
|
-
function compare(name, ids) {
|
46
|
-
ids = ids.map(function(id) {
|
47
|
-
return id.split('-').reverse().join('-');
|
48
|
-
}).sort();
|
49
|
-
var sorted = ([].concat(ids)).sort();
|
50
|
-
|
51
|
-
assert(sorted.toString() == ids.toString(), name + ' have expected order');
|
52
|
-
}
|
53
|
-
|
54
|
-
// Verify ordering of v1 ids created using default behavior
|
55
|
-
compare('uuids with current time', [
|
56
|
-
uuid.v1(),
|
57
|
-
uuid.v1(),
|
58
|
-
uuid.v1(),
|
59
|
-
uuid.v1(),
|
60
|
-
uuid.v1()
|
61
|
-
]);
|
62
|
-
|
63
|
-
// Verify ordering of v1 ids created with explicit times
|
64
|
-
compare('uuids with time option', [
|
65
|
-
uuid.v1({msecs: TIME - 10*3600*1000}),
|
66
|
-
uuid.v1({msecs: TIME - 1}),
|
67
|
-
uuid.v1({msecs: TIME}),
|
68
|
-
uuid.v1({msecs: TIME + 1}),
|
69
|
-
uuid.v1({msecs: TIME + 28*24*3600*1000})
|
70
|
-
]);
|
71
|
-
|
72
|
-
assert(
|
73
|
-
uuid.v1({msecs: TIME}) != uuid.v1({msecs: TIME}),
|
74
|
-
'IDs created at same msec are different'
|
75
|
-
);
|
76
|
-
|
77
|
-
// Verify throw if too many ids created
|
78
|
-
var thrown = false;
|
79
|
-
try {
|
80
|
-
uuid.v1({msecs: TIME, nsecs: 10000});
|
81
|
-
} catch (e) {
|
82
|
-
thrown = true;
|
83
|
-
}
|
84
|
-
assert(thrown, 'Exception thrown when > 10K ids created in 1 ms');
|
85
|
-
|
86
|
-
// Verify clock regression bumps clockseq
|
87
|
-
var uidt = uuid.v1({msecs: TIME});
|
88
|
-
var uidtb = uuid.v1({msecs: TIME - 1});
|
89
|
-
assert(
|
90
|
-
parseInt(uidtb.split('-')[3], 16) - parseInt(uidt.split('-')[3], 16) === 1,
|
91
|
-
'Clock regression by msec increments the clockseq'
|
92
|
-
);
|
93
|
-
|
94
|
-
// Verify clock regression bumps clockseq
|
95
|
-
var uidtn = uuid.v1({msecs: TIME, nsecs: 10});
|
96
|
-
var uidtnb = uuid.v1({msecs: TIME, nsecs: 9});
|
97
|
-
assert(
|
98
|
-
parseInt(uidtnb.split('-')[3], 16) - parseInt(uidtn.split('-')[3], 16) === 1,
|
99
|
-
'Clock regression by nsec increments the clockseq'
|
100
|
-
);
|
101
|
-
|
102
|
-
// Verify explicit options produce expected id
|
103
|
-
var id = uuid.v1({
|
104
|
-
msecs: 1321651533573,
|
105
|
-
nsecs: 5432,
|
106
|
-
clockseq: 0x385c,
|
107
|
-
node: [ 0x61, 0xcd, 0x3c, 0xbb, 0x32, 0x10 ]
|
108
|
-
});
|
109
|
-
assert(id == 'd9428888-122b-11e1-b85c-61cd3cbb3210', 'Explicit options produce expected id');
|
110
|
-
|
111
|
-
// Verify adjacent ids across a msec boundary are 1 time unit apart
|
112
|
-
var u0 = uuid.v1({msecs: TIME, nsecs: 9999});
|
113
|
-
var u1 = uuid.v1({msecs: TIME + 1, nsecs: 0});
|
114
|
-
|
115
|
-
var before = u0.split('-')[0], after = u1.split('-')[0];
|
116
|
-
var dt = parseInt(after, 16) - parseInt(before, 16);
|
117
|
-
assert(dt === 1, 'Ids spanning 1ms boundary are 100ns apart');
|
118
|
-
|
119
|
-
//
|
120
|
-
// Test parse/unparse
|
121
|
-
//
|
122
|
-
|
123
|
-
id = '00112233445566778899aabbccddeeff';
|
124
|
-
assert(uuid.unparse(uuid.parse(id.substr(0,10))) ==
|
125
|
-
'00112233-4400-0000-0000-000000000000', 'Short parse');
|
126
|
-
assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) ==
|
127
|
-
'00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse');
|
128
|
-
|
129
|
-
//
|
130
|
-
// Perf tests
|
131
|
-
//
|
132
|
-
|
133
|
-
var generators = {
|
134
|
-
v1: uuid.v1,
|
135
|
-
v4: uuid.v4
|
136
|
-
};
|
137
|
-
|
138
|
-
var UUID_FORMAT = {
|
139
|
-
v1: /[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,
|
140
|
-
v4: /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i
|
141
|
-
};
|
142
|
-
|
143
|
-
var N = 1e4;
|
144
|
-
|
145
|
-
// Get %'age an actual value differs from the ideal value
|
146
|
-
function divergence(actual, ideal) {
|
147
|
-
return Math.round(100*100*(actual - ideal)/ideal)/100;
|
148
|
-
}
|
149
|
-
|
150
|
-
function rate(msg, t) {
|
151
|
-
log(msg + ': ' + (N / (Date.now() - t) * 1e3 | 0) + ' uuids\/second');
|
152
|
-
}
|
153
|
-
|
154
|
-
for (var version in generators) {
|
155
|
-
var counts = {}, max = 0;
|
156
|
-
var generator = generators[version];
|
157
|
-
var format = UUID_FORMAT[version];
|
158
|
-
|
159
|
-
log('\nSanity check ' + N + ' ' + version + ' uuids');
|
160
|
-
for (var i = 0, ok = 0; i < N; i++) {
|
161
|
-
id = generator();
|
162
|
-
if (!format.test(id)) {
|
163
|
-
throw Error(id + ' is not a valid UUID string');
|
164
|
-
}
|
165
|
-
|
166
|
-
if (id != uuid.unparse(uuid.parse(id))) {
|
167
|
-
assert(fail, id + ' is not a valid id');
|
168
|
-
}
|
169
|
-
|
170
|
-
// Count digits for our randomness check
|
171
|
-
if (version == 'v4') {
|
172
|
-
var digits = id.replace(/-/g, '').split('');
|
173
|
-
for (var j = digits.length-1; j >= 0; j--) {
|
174
|
-
var c = digits[j];
|
175
|
-
max = Math.max(max, counts[c] = (counts[c] || 0) + 1);
|
176
|
-
}
|
177
|
-
}
|
178
|
-
}
|
179
|
-
|
180
|
-
// Check randomness for v4 UUIDs
|
181
|
-
if (version == 'v4') {
|
182
|
-
// Limit that we get worried about randomness. (Purely empirical choice, this!)
|
183
|
-
var limit = 2*100*Math.sqrt(1/N);
|
184
|
-
|
185
|
-
log('\nChecking v4 randomness. Distribution of Hex Digits (% deviation from ideal)');
|
186
|
-
|
187
|
-
for (var i = 0; i < 16; i++) {
|
188
|
-
var c = i.toString(16);
|
189
|
-
var bar = '', n = counts[c], p = Math.round(n/max*100|0);
|
190
|
-
|
191
|
-
// 1-3,5-8, and D-F: 1:16 odds over 30 digits
|
192
|
-
var ideal = N*30/16;
|
193
|
-
if (i == 4) {
|
194
|
-
// 4: 1:1 odds on 1 digit, plus 1:16 odds on 30 digits
|
195
|
-
ideal = N*(1 + 30/16);
|
196
|
-
} else if (i >= 8 && i <= 11) {
|
197
|
-
// 8-B: 1:4 odds on 1 digit, plus 1:16 odds on 30 digits
|
198
|
-
ideal = N*(1/4 + 30/16);
|
199
|
-
} else {
|
200
|
-
// Otherwise: 1:16 odds on 30 digits
|
201
|
-
ideal = N*30/16;
|
202
|
-
}
|
203
|
-
var d = divergence(n, ideal);
|
204
|
-
|
205
|
-
// Draw bar using UTF squares (just for grins)
|
206
|
-
var s = n/max*50 | 0;
|
207
|
-
while (s--) bar += '=';
|
208
|
-
|
209
|
-
assert(Math.abs(d) < limit, c + ' |' + bar + '| ' + counts[c] + ' (' + d + '% < ' + limit + '%)');
|
210
|
-
}
|
211
|
-
}
|
212
|
-
}
|
213
|
-
|
214
|
-
// Perf tests
|
215
|
-
for (var version in generators) {
|
216
|
-
log('\nPerformance testing ' + version + ' UUIDs');
|
217
|
-
var generator = generators[version];
|
218
|
-
var buf = new uuid.BufferClass(16);
|
219
|
-
|
220
|
-
for (var i = 0, t = Date.now(); i < N; i++) generator();
|
221
|
-
rate('uuid.' + version + '()', t);
|
222
|
-
|
223
|
-
for (var i = 0, t = Date.now(); i < N; i++) generator('binary');
|
224
|
-
rate('uuid.' + version + '(\'binary\')', t);
|
225
|
-
|
226
|
-
for (var i = 0, t = Date.now(); i < N; i++) generator('binary', buf);
|
227
|
-
rate('uuid.' + version + '(\'binary\', buffer)', t);
|
228
|
-
}
|