ai 1.1.0 → 2.0.0
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-EZJ7FC5E.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,60 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "async",
|
3
|
-
"description": "Higher-order functions and common patterns for asynchronous code",
|
4
|
-
"main": "./lib/async",
|
5
|
-
"author": {
|
6
|
-
"name": "Caolan McMahon"
|
7
|
-
},
|
8
|
-
"version": "0.9.0",
|
9
|
-
"repository": {
|
10
|
-
"type": "git",
|
11
|
-
"url": "https://github.com/caolan/async.git"
|
12
|
-
},
|
13
|
-
"bugs": {
|
14
|
-
"url": "https://github.com/caolan/async/issues"
|
15
|
-
},
|
16
|
-
"licenses": [
|
17
|
-
{
|
18
|
-
"type": "MIT",
|
19
|
-
"url": "https://github.com/caolan/async/raw/master/LICENSE"
|
20
|
-
}
|
21
|
-
],
|
22
|
-
"devDependencies": {
|
23
|
-
"nodeunit": ">0.0.0",
|
24
|
-
"uglify-js": "1.2.x",
|
25
|
-
"nodelint": ">0.0.0"
|
26
|
-
},
|
27
|
-
"jam": {
|
28
|
-
"main": "lib/async.js",
|
29
|
-
"include": [
|
30
|
-
"lib/async.js",
|
31
|
-
"README.md",
|
32
|
-
"LICENSE"
|
33
|
-
]
|
34
|
-
},
|
35
|
-
"scripts": {
|
36
|
-
"test": "nodeunit test/test-async.js"
|
37
|
-
},
|
38
|
-
"homepage": "https://github.com/caolan/async",
|
39
|
-
"_id": "async@0.9.0",
|
40
|
-
"dist": {
|
41
|
-
"shasum": "ac3613b1da9bed1b47510bb4651b8931e47146c7",
|
42
|
-
"tarball": "http://registry.npmjs.org/async/-/async-0.9.0.tgz"
|
43
|
-
},
|
44
|
-
"_from": "async@~0.9.0",
|
45
|
-
"_npmVersion": "1.4.3",
|
46
|
-
"_npmUser": {
|
47
|
-
"name": "caolan",
|
48
|
-
"email": "caolan.mcmahon@gmail.com"
|
49
|
-
},
|
50
|
-
"maintainers": [
|
51
|
-
{
|
52
|
-
"name": "caolan",
|
53
|
-
"email": "caolan@caolanmcmahon.com"
|
54
|
-
}
|
55
|
-
],
|
56
|
-
"directories": {},
|
57
|
-
"_shasum": "ac3613b1da9bed1b47510bb4651b8931e47146c7",
|
58
|
-
"_resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz",
|
59
|
-
"readme": "ERROR: No README data found!"
|
60
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Debuggable Limited <felix@debuggable.com>
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
@@ -1,132 +0,0 @@
|
|
1
|
-
# combined-stream [](https://travis-ci.org/felixge/node-combined-stream)
|
2
|
-
|
3
|
-
A stream that emits multiple other streams one after another.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
``` bash
|
8
|
-
npm install combined-stream
|
9
|
-
```
|
10
|
-
|
11
|
-
## Usage
|
12
|
-
|
13
|
-
Here is a simple example that shows how you can use combined-stream to combine
|
14
|
-
two files into one:
|
15
|
-
|
16
|
-
``` javascript
|
17
|
-
var CombinedStream = require('combined-stream');
|
18
|
-
var fs = require('fs');
|
19
|
-
|
20
|
-
var combinedStream = CombinedStream.create();
|
21
|
-
combinedStream.append(fs.createReadStream('file1.txt'));
|
22
|
-
combinedStream.append(fs.createReadStream('file2.txt'));
|
23
|
-
|
24
|
-
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
25
|
-
```
|
26
|
-
|
27
|
-
While the example above works great, it will pause all source streams until
|
28
|
-
they are needed. If you don't want that to happen, you can set `pauseStreams`
|
29
|
-
to `false`:
|
30
|
-
|
31
|
-
``` javascript
|
32
|
-
var CombinedStream = require('combined-stream');
|
33
|
-
var fs = require('fs');
|
34
|
-
|
35
|
-
var combinedStream = CombinedStream.create({pauseStreams: false});
|
36
|
-
combinedStream.append(fs.createReadStream('file1.txt'));
|
37
|
-
combinedStream.append(fs.createReadStream('file2.txt'));
|
38
|
-
|
39
|
-
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
40
|
-
```
|
41
|
-
|
42
|
-
However, what if you don't have all the source streams yet, or you don't want
|
43
|
-
to allocate the resources (file descriptors, memory, etc.) for them right away?
|
44
|
-
Well, in that case you can simply provide a callback that supplies the stream
|
45
|
-
by calling a `next()` function:
|
46
|
-
|
47
|
-
``` javascript
|
48
|
-
var CombinedStream = require('combined-stream');
|
49
|
-
var fs = require('fs');
|
50
|
-
|
51
|
-
var combinedStream = CombinedStream.create();
|
52
|
-
combinedStream.append(function(next) {
|
53
|
-
next(fs.createReadStream('file1.txt'));
|
54
|
-
});
|
55
|
-
combinedStream.append(function(next) {
|
56
|
-
next(fs.createReadStream('file2.txt'));
|
57
|
-
});
|
58
|
-
|
59
|
-
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
60
|
-
```
|
61
|
-
|
62
|
-
## API
|
63
|
-
|
64
|
-
### CombinedStream.create([options])
|
65
|
-
|
66
|
-
Returns a new combined stream object. Available options are:
|
67
|
-
|
68
|
-
* `maxDataSize`
|
69
|
-
* `pauseStreams`
|
70
|
-
|
71
|
-
The effect of those options is described below.
|
72
|
-
|
73
|
-
### combinedStream.pauseStreams = `true`
|
74
|
-
|
75
|
-
Whether to apply back pressure to the underlaying streams. If set to `false`,
|
76
|
-
the underlaying streams will never be paused. If set to `true`, the
|
77
|
-
underlaying streams will be paused right after being appended, as well as when
|
78
|
-
`delayedStream.pipe()` wants to throttle.
|
79
|
-
|
80
|
-
### combinedStream.maxDataSize = `2 * 1024 * 1024`
|
81
|
-
|
82
|
-
The maximum amount of bytes (or characters) to buffer for all source streams.
|
83
|
-
If this value is exceeded, `combinedStream` emits an `'error'` event.
|
84
|
-
|
85
|
-
### combinedStream.dataSize = `0`
|
86
|
-
|
87
|
-
The amount of bytes (or characters) currently buffered by `combinedStream`.
|
88
|
-
|
89
|
-
### combinedStream.append(stream)
|
90
|
-
|
91
|
-
Appends the given `stream` to the combinedStream object. If `pauseStreams` is
|
92
|
-
set to `true, this stream will also be paused right away.
|
93
|
-
|
94
|
-
`streams` can also be a function that takes one parameter called `next`. `next`
|
95
|
-
is a function that must be invoked in order to provide the `next` stream, see
|
96
|
-
example above.
|
97
|
-
|
98
|
-
Regardless of how the `stream` is appended, combined-stream always attaches an
|
99
|
-
`'error'` listener to it, so you don't have to do that manually.
|
100
|
-
|
101
|
-
Special case: `stream` can also be a String or Buffer.
|
102
|
-
|
103
|
-
### combinedStream.write(data)
|
104
|
-
|
105
|
-
You should not call this, `combinedStream` takes care of piping the appended
|
106
|
-
streams into itself for you.
|
107
|
-
|
108
|
-
### combinedStream.resume()
|
109
|
-
|
110
|
-
Causes `combinedStream` to start drain the streams it manages. The function is
|
111
|
-
idempotent, and also emits a `'resume'` event each time which usually goes to
|
112
|
-
the stream that is currently being drained.
|
113
|
-
|
114
|
-
### combinedStream.pause();
|
115
|
-
|
116
|
-
If `combinedStream.pauseStreams` is set to `false`, this does nothing.
|
117
|
-
Otherwise a `'pause'` event is emitted, this goes to the stream that is
|
118
|
-
currently being drained, so you can use it to apply back pressure.
|
119
|
-
|
120
|
-
### combinedStream.end();
|
121
|
-
|
122
|
-
Sets `combinedStream.writable` to false, emits an `'end'` event, and removes
|
123
|
-
all streams from the queue.
|
124
|
-
|
125
|
-
### combinedStream.destroy();
|
126
|
-
|
127
|
-
Same as `combinedStream.end()`, except it emits a `'close'` event instead of
|
128
|
-
`'end'`.
|
129
|
-
|
130
|
-
## License
|
131
|
-
|
132
|
-
combined-stream is licensed under the MIT license.
|
@@ -1,186 +0,0 @@
|
|
1
|
-
var util = require('util');
|
2
|
-
var Stream = require('stream').Stream;
|
3
|
-
var DelayedStream = require('delayed-stream');
|
4
|
-
|
5
|
-
module.exports = CombinedStream;
|
6
|
-
function CombinedStream() {
|
7
|
-
this.writable = false;
|
8
|
-
this.readable = true;
|
9
|
-
this.dataSize = 0;
|
10
|
-
this.maxDataSize = 2 * 1024 * 1024;
|
11
|
-
this.pauseStreams = true;
|
12
|
-
|
13
|
-
this._released = false;
|
14
|
-
this._streams = [];
|
15
|
-
this._currentStream = null;
|
16
|
-
}
|
17
|
-
util.inherits(CombinedStream, Stream);
|
18
|
-
|
19
|
-
CombinedStream.create = function(options) {
|
20
|
-
var combinedStream = new this();
|
21
|
-
|
22
|
-
options = options || {};
|
23
|
-
for (var option in options) {
|
24
|
-
combinedStream[option] = options[option];
|
25
|
-
}
|
26
|
-
|
27
|
-
return combinedStream;
|
28
|
-
};
|
29
|
-
|
30
|
-
CombinedStream.isStreamLike = function(stream) {
|
31
|
-
return (typeof stream !== 'function')
|
32
|
-
&& (typeof stream !== 'string')
|
33
|
-
&& (typeof stream !== 'boolean')
|
34
|
-
&& (typeof stream !== 'number')
|
35
|
-
&& (!Buffer.isBuffer(stream));
|
36
|
-
};
|
37
|
-
|
38
|
-
CombinedStream.prototype.append = function(stream) {
|
39
|
-
var isStreamLike = CombinedStream.isStreamLike(stream);
|
40
|
-
|
41
|
-
if (isStreamLike) {
|
42
|
-
if (!(stream instanceof DelayedStream)) {
|
43
|
-
stream.on('data', this._checkDataSize.bind(this));
|
44
|
-
|
45
|
-
stream = DelayedStream.create(stream, {
|
46
|
-
maxDataSize: Infinity,
|
47
|
-
pauseStream: this.pauseStreams,
|
48
|
-
});
|
49
|
-
}
|
50
|
-
|
51
|
-
this._handleErrors(stream);
|
52
|
-
|
53
|
-
if (this.pauseStreams) {
|
54
|
-
stream.pause();
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
this._streams.push(stream);
|
59
|
-
return this;
|
60
|
-
};
|
61
|
-
|
62
|
-
CombinedStream.prototype.pipe = function(dest, options) {
|
63
|
-
Stream.prototype.pipe.call(this, dest, options);
|
64
|
-
this.resume();
|
65
|
-
return dest;
|
66
|
-
};
|
67
|
-
|
68
|
-
CombinedStream.prototype._getNext = function() {
|
69
|
-
this._currentStream = null;
|
70
|
-
var stream = this._streams.shift();
|
71
|
-
|
72
|
-
|
73
|
-
if (typeof stream == 'undefined') {
|
74
|
-
this.end();
|
75
|
-
return;
|
76
|
-
}
|
77
|
-
|
78
|
-
if (typeof stream !== 'function') {
|
79
|
-
this._pipeNext(stream);
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
|
83
|
-
var getStream = stream;
|
84
|
-
getStream(function(stream) {
|
85
|
-
var isStreamLike = CombinedStream.isStreamLike(stream);
|
86
|
-
if (isStreamLike) {
|
87
|
-
stream.on('data', this._checkDataSize.bind(this));
|
88
|
-
this._handleErrors(stream);
|
89
|
-
}
|
90
|
-
|
91
|
-
this._pipeNext(stream);
|
92
|
-
}.bind(this));
|
93
|
-
};
|
94
|
-
|
95
|
-
CombinedStream.prototype._pipeNext = function(stream) {
|
96
|
-
this._currentStream = stream;
|
97
|
-
|
98
|
-
var isStreamLike = CombinedStream.isStreamLike(stream);
|
99
|
-
if (isStreamLike) {
|
100
|
-
stream.on('end', this._getNext.bind(this))
|
101
|
-
stream.pipe(this, {end: false});
|
102
|
-
return;
|
103
|
-
}
|
104
|
-
|
105
|
-
var value = stream;
|
106
|
-
this.write(value);
|
107
|
-
this._getNext();
|
108
|
-
};
|
109
|
-
|
110
|
-
CombinedStream.prototype._handleErrors = function(stream) {
|
111
|
-
var self = this;
|
112
|
-
stream.on('error', function(err) {
|
113
|
-
self._emitError(err);
|
114
|
-
});
|
115
|
-
};
|
116
|
-
|
117
|
-
CombinedStream.prototype.write = function(data) {
|
118
|
-
this.emit('data', data);
|
119
|
-
};
|
120
|
-
|
121
|
-
CombinedStream.prototype.pause = function() {
|
122
|
-
if (!this.pauseStreams) {
|
123
|
-
return;
|
124
|
-
}
|
125
|
-
|
126
|
-
this.emit('pause');
|
127
|
-
};
|
128
|
-
|
129
|
-
CombinedStream.prototype.resume = function() {
|
130
|
-
if (!this._released) {
|
131
|
-
this._released = true;
|
132
|
-
this.writable = true;
|
133
|
-
this._getNext();
|
134
|
-
}
|
135
|
-
|
136
|
-
this.emit('resume');
|
137
|
-
};
|
138
|
-
|
139
|
-
CombinedStream.prototype.end = function() {
|
140
|
-
this._reset();
|
141
|
-
this.emit('end');
|
142
|
-
};
|
143
|
-
|
144
|
-
CombinedStream.prototype.destroy = function() {
|
145
|
-
this._reset();
|
146
|
-
this.emit('close');
|
147
|
-
};
|
148
|
-
|
149
|
-
CombinedStream.prototype._reset = function() {
|
150
|
-
this.writable = false;
|
151
|
-
this._streams = [];
|
152
|
-
this._currentStream = null;
|
153
|
-
};
|
154
|
-
|
155
|
-
CombinedStream.prototype._checkDataSize = function() {
|
156
|
-
this._updateDataSize();
|
157
|
-
if (this.dataSize <= this.maxDataSize) {
|
158
|
-
return;
|
159
|
-
}
|
160
|
-
|
161
|
-
var message =
|
162
|
-
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
|
163
|
-
this._emitError(new Error(message));
|
164
|
-
};
|
165
|
-
|
166
|
-
CombinedStream.prototype._updateDataSize = function() {
|
167
|
-
this.dataSize = 0;
|
168
|
-
|
169
|
-
var self = this;
|
170
|
-
this._streams.forEach(function(stream) {
|
171
|
-
if (!stream.dataSize) {
|
172
|
-
return;
|
173
|
-
}
|
174
|
-
|
175
|
-
self.dataSize += stream.dataSize;
|
176
|
-
});
|
177
|
-
|
178
|
-
if (this._currentStream && this._currentStream.dataSize) {
|
179
|
-
this.dataSize += this._currentStream.dataSize;
|
180
|
-
}
|
181
|
-
};
|
182
|
-
|
183
|
-
CombinedStream.prototype._emitError = function(err) {
|
184
|
-
this._reset();
|
185
|
-
this.emit('error', err);
|
186
|
-
};
|
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Debuggable Limited <felix@debuggable.com>
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
@@ -1,154 +0,0 @@
|
|
1
|
-
# delayed-stream
|
2
|
-
|
3
|
-
Buffers events from a stream until you are ready to handle them.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
``` bash
|
8
|
-
npm install delayed-stream
|
9
|
-
```
|
10
|
-
|
11
|
-
## Usage
|
12
|
-
|
13
|
-
The following example shows how to write a http echo server that delays its
|
14
|
-
response by 1000 ms.
|
15
|
-
|
16
|
-
``` javascript
|
17
|
-
var DelayedStream = require('delayed-stream');
|
18
|
-
var http = require('http');
|
19
|
-
|
20
|
-
http.createServer(function(req, res) {
|
21
|
-
var delayed = DelayedStream.create(req);
|
22
|
-
|
23
|
-
setTimeout(function() {
|
24
|
-
res.writeHead(200);
|
25
|
-
delayed.pipe(res);
|
26
|
-
}, 1000);
|
27
|
-
});
|
28
|
-
```
|
29
|
-
|
30
|
-
If you are not using `Stream#pipe`, you can also manually release the buffered
|
31
|
-
events by calling `delayedStream.resume()`:
|
32
|
-
|
33
|
-
``` javascript
|
34
|
-
var delayed = DelayedStream.create(req);
|
35
|
-
|
36
|
-
setTimeout(function() {
|
37
|
-
// Emit all buffered events and resume underlaying source
|
38
|
-
delayed.resume();
|
39
|
-
}, 1000);
|
40
|
-
```
|
41
|
-
|
42
|
-
## Implementation
|
43
|
-
|
44
|
-
In order to use this meta stream properly, here are a few things you should
|
45
|
-
know about the implementation.
|
46
|
-
|
47
|
-
### Event Buffering / Proxying
|
48
|
-
|
49
|
-
All events of the `source` stream are hijacked by overwriting the `source.emit`
|
50
|
-
method. Until node implements a catch-all event listener, this is the only way.
|
51
|
-
|
52
|
-
However, delayed-stream still continues to emit all events it captures on the
|
53
|
-
`source`, regardless of whether you have released the delayed stream yet or
|
54
|
-
not.
|
55
|
-
|
56
|
-
Upon creation, delayed-stream captures all `source` events and stores them in
|
57
|
-
an internal event buffer. Once `delayedStream.release()` is called, all
|
58
|
-
buffered events are emitted on the `delayedStream`, and the event buffer is
|
59
|
-
cleared. After that, delayed-stream merely acts as a proxy for the underlaying
|
60
|
-
source.
|
61
|
-
|
62
|
-
### Error handling
|
63
|
-
|
64
|
-
Error events on `source` are buffered / proxied just like any other events.
|
65
|
-
However, `delayedStream.create` attaches a no-op `'error'` listener to the
|
66
|
-
`source`. This way you only have to handle errors on the `delayedStream`
|
67
|
-
object, rather than in two places.
|
68
|
-
|
69
|
-
### Buffer limits
|
70
|
-
|
71
|
-
delayed-stream provides a `maxDataSize` property that can be used to limit
|
72
|
-
the amount of data being buffered. In order to protect you from bad `source`
|
73
|
-
streams that don't react to `source.pause()`, this feature is enabled by
|
74
|
-
default.
|
75
|
-
|
76
|
-
## API
|
77
|
-
|
78
|
-
### DelayedStream.create(source, [options])
|
79
|
-
|
80
|
-
Returns a new `delayedStream`. Available options are:
|
81
|
-
|
82
|
-
* `pauseStream`
|
83
|
-
* `maxDataSize`
|
84
|
-
|
85
|
-
The description for those properties can be found below.
|
86
|
-
|
87
|
-
### delayedStream.source
|
88
|
-
|
89
|
-
The `source` stream managed by this object. This is useful if you are
|
90
|
-
passing your `delayedStream` around, and you still want to access properties
|
91
|
-
on the `source` object.
|
92
|
-
|
93
|
-
### delayedStream.pauseStream = true
|
94
|
-
|
95
|
-
Whether to pause the underlaying `source` when calling
|
96
|
-
`DelayedStream.create()`. Modifying this property afterwards has no effect.
|
97
|
-
|
98
|
-
### delayedStream.maxDataSize = 1024 * 1024
|
99
|
-
|
100
|
-
The amount of data to buffer before emitting an `error`.
|
101
|
-
|
102
|
-
If the underlaying source is emitting `Buffer` objects, the `maxDataSize`
|
103
|
-
refers to bytes.
|
104
|
-
|
105
|
-
If the underlaying source is emitting JavaScript strings, the size refers to
|
106
|
-
characters.
|
107
|
-
|
108
|
-
If you know what you are doing, you can set this property to `Infinity` to
|
109
|
-
disable this feature. You can also modify this property during runtime.
|
110
|
-
|
111
|
-
### delayedStream.maxDataSize = 1024 * 1024
|
112
|
-
|
113
|
-
The amount of data to buffer before emitting an `error`.
|
114
|
-
|
115
|
-
If the underlaying source is emitting `Buffer` objects, the `maxDataSize`
|
116
|
-
refers to bytes.
|
117
|
-
|
118
|
-
If the underlaying source is emitting JavaScript strings, the size refers to
|
119
|
-
characters.
|
120
|
-
|
121
|
-
If you know what you are doing, you can set this property to `Infinity` to
|
122
|
-
disable this feature.
|
123
|
-
|
124
|
-
### delayedStream.dataSize = 0
|
125
|
-
|
126
|
-
The amount of data buffered so far.
|
127
|
-
|
128
|
-
### delayedStream.readable
|
129
|
-
|
130
|
-
An ECMA5 getter that returns the value of `source.readable`.
|
131
|
-
|
132
|
-
### delayedStream.resume()
|
133
|
-
|
134
|
-
If the `delayedStream` has not been released so far, `delayedStream.release()`
|
135
|
-
is called.
|
136
|
-
|
137
|
-
In either case, `source.resume()` is called.
|
138
|
-
|
139
|
-
### delayedStream.pause()
|
140
|
-
|
141
|
-
Calls `source.pause()`.
|
142
|
-
|
143
|
-
### delayedStream.pipe(dest)
|
144
|
-
|
145
|
-
Calls `delayedStream.resume()` and then proxies the arguments to `source.pipe`.
|
146
|
-
|
147
|
-
### delayedStream.release()
|
148
|
-
|
149
|
-
Emits and clears all events that have been buffered up so far. This does not
|
150
|
-
resume the underlaying source, use `delayedStream.resume()` instead.
|
151
|
-
|
152
|
-
## License
|
153
|
-
|
154
|
-
delayed-stream is licensed under the MIT license.
|
@@ -1,99 +0,0 @@
|
|
1
|
-
var Stream = require('stream').Stream;
|
2
|
-
var util = require('util');
|
3
|
-
|
4
|
-
module.exports = DelayedStream;
|
5
|
-
function DelayedStream() {
|
6
|
-
this.source = null;
|
7
|
-
this.dataSize = 0;
|
8
|
-
this.maxDataSize = 1024 * 1024;
|
9
|
-
this.pauseStream = true;
|
10
|
-
|
11
|
-
this._maxDataSizeExceeded = false;
|
12
|
-
this._released = false;
|
13
|
-
this._bufferedEvents = [];
|
14
|
-
}
|
15
|
-
util.inherits(DelayedStream, Stream);
|
16
|
-
|
17
|
-
DelayedStream.create = function(source, options) {
|
18
|
-
var delayedStream = new this();
|
19
|
-
|
20
|
-
options = options || {};
|
21
|
-
for (var option in options) {
|
22
|
-
delayedStream[option] = options[option];
|
23
|
-
}
|
24
|
-
|
25
|
-
delayedStream.source = source;
|
26
|
-
|
27
|
-
var realEmit = source.emit;
|
28
|
-
source.emit = function() {
|
29
|
-
delayedStream._handleEmit(arguments);
|
30
|
-
return realEmit.apply(source, arguments);
|
31
|
-
};
|
32
|
-
|
33
|
-
source.on('error', function() {});
|
34
|
-
if (delayedStream.pauseStream) {
|
35
|
-
source.pause();
|
36
|
-
}
|
37
|
-
|
38
|
-
return delayedStream;
|
39
|
-
};
|
40
|
-
|
41
|
-
DelayedStream.prototype.__defineGetter__('readable', function() {
|
42
|
-
return this.source.readable;
|
43
|
-
});
|
44
|
-
|
45
|
-
DelayedStream.prototype.resume = function() {
|
46
|
-
if (!this._released) {
|
47
|
-
this.release();
|
48
|
-
}
|
49
|
-
|
50
|
-
this.source.resume();
|
51
|
-
};
|
52
|
-
|
53
|
-
DelayedStream.prototype.pause = function() {
|
54
|
-
this.source.pause();
|
55
|
-
};
|
56
|
-
|
57
|
-
DelayedStream.prototype.release = function() {
|
58
|
-
this._released = true;
|
59
|
-
|
60
|
-
this._bufferedEvents.forEach(function(args) {
|
61
|
-
this.emit.apply(this, args);
|
62
|
-
}.bind(this));
|
63
|
-
this._bufferedEvents = [];
|
64
|
-
};
|
65
|
-
|
66
|
-
DelayedStream.prototype.pipe = function() {
|
67
|
-
var r = Stream.prototype.pipe.apply(this, arguments);
|
68
|
-
this.resume();
|
69
|
-
return r;
|
70
|
-
};
|
71
|
-
|
72
|
-
DelayedStream.prototype._handleEmit = function(args) {
|
73
|
-
if (this._released) {
|
74
|
-
this.emit.apply(this, args);
|
75
|
-
return;
|
76
|
-
}
|
77
|
-
|
78
|
-
if (args[0] === 'data') {
|
79
|
-
this.dataSize += args[1].length;
|
80
|
-
this._checkIfMaxDataSizeExceeded();
|
81
|
-
}
|
82
|
-
|
83
|
-
this._bufferedEvents.push(args);
|
84
|
-
};
|
85
|
-
|
86
|
-
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
87
|
-
if (this._maxDataSizeExceeded) {
|
88
|
-
return;
|
89
|
-
}
|
90
|
-
|
91
|
-
if (this.dataSize <= this.maxDataSize) {
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
|
95
|
-
this._maxDataSizeExceeded = true;
|
96
|
-
var message =
|
97
|
-
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
|
98
|
-
this.emit('error', new Error(message));
|
99
|
-
};
|