fsevents 1.0.15 → 1.1.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.
Potentially problematic release.
This version of fsevents might be problematic. Click here for more details.
- package/fsevents.js +3 -0
- package/install.js +7 -0
- package/lib/binding/Release/node-v48-darwin-x64/fse.node +0 -0
- package/node_modules/abbrev/abbrev.js +0 -1
- package/node_modules/abbrev/package.json +32 -21
- package/node_modules/ansi-regex/index.js +1 -1
- package/node_modules/ansi-regex/package.json +61 -42
- package/node_modules/ansi-regex/readme.md +10 -2
- package/node_modules/ansi-styles/package.json +27 -19
- package/node_modules/aproba/README.md +33 -3
- package/node_modules/aproba/index.js +71 -30
- package/node_modules/aproba/package.json +30 -22
- package/node_modules/are-we-there-yet/package.json +14 -6
- package/node_modules/asn1/package.json +16 -8
- package/node_modules/assert-plus/package.json +16 -8
- package/node_modules/{node-uuid/LICENSE.md → asynckit/LICENSE} +1 -1
- package/node_modules/asynckit/README.md +233 -0
- package/node_modules/asynckit/bench.js +76 -0
- package/node_modules/asynckit/index.js +6 -0
- package/node_modules/asynckit/lib/abort.js +29 -0
- package/node_modules/asynckit/lib/async.js +34 -0
- package/node_modules/asynckit/lib/defer.js +26 -0
- package/node_modules/asynckit/lib/iterate.js +75 -0
- package/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/node_modules/asynckit/lib/state.js +37 -0
- package/node_modules/asynckit/lib/streamify.js +141 -0
- package/node_modules/asynckit/lib/terminator.js +29 -0
- package/node_modules/asynckit/package.json +126 -0
- package/node_modules/asynckit/parallel.js +43 -0
- package/node_modules/asynckit/serial.js +17 -0
- package/node_modules/asynckit/serialOrdered.js +75 -0
- package/node_modules/asynckit/stream.js +21 -0
- package/node_modules/aws-sign2/package.json +15 -7
- package/node_modules/aws4/README.md +9 -0
- package/node_modules/aws4/aws4.js +21 -7
- package/node_modules/aws4/package.json +62 -54
- package/node_modules/balanced-match/package.json +27 -19
- package/node_modules/bcrypt-pbkdf/README.md +39 -0
- package/node_modules/bcrypt-pbkdf/index.js +556 -0
- package/node_modules/bcrypt-pbkdf/package.json +84 -0
- package/node_modules/block-stream/package.json +15 -7
- package/node_modules/boom/package.json +14 -6
- package/node_modules/brace-expansion/index.js +10 -0
- package/node_modules/brace-expansion/package.json +35 -27
- package/node_modules/buffer-shims/package.json +16 -7
- package/node_modules/caseless/package.json +18 -10
- package/node_modules/chalk/package.json +30 -22
- package/node_modules/code-point-at/index.js +3 -4
- package/node_modules/code-point-at/package.json +40 -30
- package/node_modules/code-point-at/readme.md +2 -4
- package/node_modules/combined-stream/package.json +15 -7
- package/node_modules/commander/package.json +16 -8
- package/node_modules/concat-map/package.json +30 -22
- package/node_modules/console-control-strings/package.json +15 -7
- package/node_modules/core-util-is/package.json +22 -14
- package/node_modules/cryptiles/package.json +14 -6
- package/node_modules/dashdash/CHANGES.md +364 -0
- package/node_modules/dashdash/LICENSE.txt +24 -0
- package/node_modules/dashdash/etc/dashdash.bash_completion.in +4 -3
- package/node_modules/dashdash/node_modules/assert-plus/package.json +16 -8
- package/node_modules/dashdash/package.json +33 -24
- package/node_modules/debug/package.json +20 -12
- package/node_modules/deep-extend/package.json +23 -15
- package/node_modules/delayed-stream/package.json +15 -7
- package/node_modules/delegates/package.json +14 -6
- package/node_modules/ecc-jsbn/package.json +17 -9
- package/node_modules/escape-string-regexp/package.json +20 -12
- package/node_modules/extend/package.json +16 -8
- package/node_modules/extsprintf/package.json +14 -6
- package/node_modules/forever-agent/package.json +15 -7
- package/node_modules/form-data/README.md +7 -8
- package/node_modules/form-data/lib/browser.js +1 -1
- package/node_modules/form-data/lib/form_data.js +101 -72
- package/node_modules/form-data/lib/populate.js +6 -5
- package/node_modules/form-data/package.json +68 -52
- package/node_modules/fs.realpath/package.json +19 -11
- package/node_modules/fstream/package.json +15 -7
- package/node_modules/fstream-ignore/package.json +15 -7
- package/node_modules/gauge/CHANGELOG.md +24 -0
- package/node_modules/gauge/README.md +4 -0
- package/node_modules/gauge/index.js +16 -9
- package/node_modules/gauge/package.json +37 -29
- package/node_modules/generate-function/package.json +16 -8
- package/node_modules/generate-object-property/package.json +14 -6
- package/node_modules/getpass/node_modules/assert-plus/package.json +16 -8
- package/node_modules/getpass/package.json +16 -8
- package/node_modules/glob/README.md +3 -0
- package/node_modules/glob/common.js +6 -1
- package/node_modules/glob/glob.js +23 -14
- package/node_modules/glob/package.json +29 -21
- package/node_modules/glob/sync.js +29 -11
- package/node_modules/graceful-fs/README.md +1 -1
- package/node_modules/graceful-fs/graceful-fs.js +23 -14
- package/node_modules/graceful-fs/package.json +35 -27
- package/node_modules/graceful-fs/polyfills.js +99 -21
- package/node_modules/graceful-readlink/package.json +14 -6
- package/node_modules/har-validator/package.json +16 -8
- package/node_modules/has-ansi/package.json +29 -21
- package/node_modules/has-unicode/package.json +18 -10
- package/node_modules/hawk/package.json +18 -10
- package/node_modules/hoek/package.json +14 -6
- package/node_modules/http-signature/package.json +14 -6
- package/node_modules/inflight/inflight.js +22 -12
- package/node_modules/inflight/package.json +28 -20
- package/node_modules/inherits/inherits.js +7 -1
- package/node_modules/inherits/package.json +41 -21
- package/node_modules/ini/package.json +15 -7
- package/node_modules/is-fullwidth-code-point/package.json +27 -19
- package/node_modules/is-my-json-valid/index.js +10 -0
- package/node_modules/is-my-json-valid/package.json +36 -20
- package/node_modules/is-my-json-valid/test/misc.js +24 -0
- package/node_modules/is-property/package.json +19 -11
- package/node_modules/is-typedarray/package.json +16 -8
- package/node_modules/isarray/package.json +28 -20
- package/node_modules/isstream/package.json +19 -11
- package/node_modules/jodid25519/package.json +18 -10
- package/node_modules/jsbn/index.js +8 -9
- package/node_modules/jsbn/package.json +30 -18
- package/node_modules/json-schema/lib/links.js +17 -3
- package/node_modules/json-schema/lib/validate.js +18 -5
- package/node_modules/json-schema/package.json +32 -18
- package/node_modules/json-stringify-safe/package.json +18 -10
- package/node_modules/{async/LICENSE → jsonpointer/LICENSE.md} +3 -1
- package/node_modules/jsonpointer/README.md +17 -10
- package/node_modules/jsonpointer/jsonpointer.js +73 -56
- package/node_modules/jsonpointer/package.json +47 -26
- package/node_modules/jsprim/CHANGES.md +4 -0
- package/node_modules/jsprim/package.json +25 -17
- package/node_modules/mime-db/HISTORY.md +50 -0
- package/node_modules/mime-db/db.json +126 -2
- package/node_modules/mime-db/package.json +43 -30
- package/node_modules/mime-types/HISTORY.md +19 -0
- package/node_modules/mime-types/index.js +8 -8
- package/node_modules/mime-types/package.json +32 -19
- package/node_modules/minimatch/minimatch.js +19 -20
- package/node_modules/minimatch/package.json +25 -17
- package/node_modules/minimist/package.json +24 -16
- package/node_modules/mkdirp/package.json +21 -13
- package/node_modules/ms/package.json +14 -6
- package/node_modules/node-pre-gyp/CHANGELOG.md +20 -0
- package/node_modules/node-pre-gyp/README.md +574 -0
- package/node_modules/node-pre-gyp/appveyor.yml +19 -9
- package/node_modules/node-pre-gyp/lib/install.js +31 -7
- package/node_modules/node-pre-gyp/lib/node-pre-gyp.js +3 -1
- package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +140 -0
- package/node_modules/node-pre-gyp/package.json +52 -48
- package/node_modules/nopt/package.json +19 -11
- package/node_modules/npmlog/CHANGELOG.md +9 -0
- package/node_modules/npmlog/README.md +7 -1
- package/node_modules/npmlog/log.js +12 -8
- package/node_modules/npmlog/package.json +30 -22
- package/node_modules/number-is-nan/package.json +39 -30
- package/node_modules/number-is-nan/readme.md +1 -3
- package/node_modules/oauth-sign/package.json +15 -7
- package/node_modules/object-assign/index.js +11 -4
- package/node_modules/object-assign/package.json +42 -30
- package/node_modules/object-assign/readme.md +8 -3
- package/node_modules/once/README.md +28 -0
- package/node_modules/once/once.js +21 -0
- package/node_modules/once/package.json +31 -20
- package/node_modules/path-is-absolute/index.js +5 -5
- package/node_modules/path-is-absolute/package.json +45 -31
- package/node_modules/path-is-absolute/readme.md +19 -11
- package/node_modules/pinkie/package.json +18 -10
- package/node_modules/pinkie-promise/package.json +18 -10
- package/node_modules/process-nextick-args/package.json +16 -8
- package/node_modules/punycode/LICENSE-MIT.txt +20 -0
- package/node_modules/punycode/README.md +176 -0
- package/node_modules/punycode/package.json +127 -0
- package/node_modules/punycode/punycode.js +533 -0
- package/node_modules/qs/.eslintrc +15 -15
- package/node_modules/qs/CHANGELOG.md +36 -0
- package/node_modules/qs/README.md +431 -0
- package/node_modules/qs/dist/qs.js +167 -67
- package/node_modules/qs/lib/formats.js +18 -0
- package/node_modules/qs/lib/index.js +6 -4
- package/node_modules/qs/lib/parse.js +31 -32
- package/node_modules/qs/lib/stringify.js +83 -20
- package/node_modules/qs/lib/utils.js +23 -7
- package/node_modules/qs/package.json +40 -30
- package/node_modules/qs/test/.eslintrc +10 -0
- package/node_modules/qs/test/index.js +2 -0
- package/node_modules/qs/test/parse.js +108 -47
- package/node_modules/qs/test/stringify.js +261 -28
- package/node_modules/qs/test/utils.js +13 -0
- package/node_modules/rc/node_modules/minimist/package.json +24 -16
- package/node_modules/rc/package.json +35 -23
- package/node_modules/readable-stream/.npmignore +1 -0
- package/node_modules/readable-stream/.travis.yml +2 -7
- package/node_modules/readable-stream/README.md +6 -2
- package/node_modules/readable-stream/lib/_stream_readable.js +158 -110
- package/node_modules/readable-stream/lib/_stream_transform.js +7 -5
- package/node_modules/readable-stream/lib/_stream_writable.js +35 -7
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +64 -0
- package/node_modules/readable-stream/package.json +34 -26
- package/node_modules/request/CHANGELOG.md +49 -18
- package/node_modules/request/README.md +3 -2
- package/node_modules/request/index.js +2 -3
- package/node_modules/request/lib/auth.js +1 -1
- package/node_modules/request/lib/helpers.js +4 -13
- package/node_modules/request/lib/multipart.js +1 -1
- package/node_modules/request/lib/oauth.js +1 -1
- package/node_modules/request/lib/redirect.js +5 -1
- package/node_modules/request/package.json +50 -31
- package/node_modules/request/request.js +84 -43
- package/node_modules/rimraf/package.json +28 -20
- package/node_modules/rimraf/rimraf.js +2 -2
- package/node_modules/semver/README.md +4 -0
- package/node_modules/semver/package.json +27 -19
- package/node_modules/semver/semver.js +14 -5
- package/node_modules/set-blocking/package.json +21 -13
- package/node_modules/signal-exit/CHANGELOG.md +10 -0
- package/node_modules/signal-exit/LICENSE.txt +2 -0
- package/node_modules/signal-exit/index.js +9 -0
- package/node_modules/signal-exit/package.json +32 -24
- package/node_modules/signal-exit/signals.js +5 -4
- package/node_modules/sntp/package.json +16 -8
- package/node_modules/sshpk/README.md +214 -3
- package/node_modules/sshpk/bin/sshpk-conv +6 -0
- package/node_modules/sshpk/lib/certificate.js +291 -0
- package/node_modules/sshpk/lib/errors.js +14 -1
- package/node_modules/sshpk/lib/fingerprint.js +28 -7
- package/node_modules/sshpk/lib/formats/openssh-cert.js +289 -0
- package/node_modules/sshpk/lib/formats/pem.js +2 -2
- package/node_modules/sshpk/lib/formats/pkcs8.js +2 -7
- package/node_modules/sshpk/lib/formats/ssh-private.js +140 -17
- package/node_modules/sshpk/lib/formats/x509-pem.js +77 -0
- package/node_modules/sshpk/lib/formats/x509.js +484 -0
- package/node_modules/sshpk/lib/identity.js +277 -0
- package/node_modules/sshpk/lib/index.js +13 -1
- package/node_modules/sshpk/lib/key.js +1 -0
- package/node_modules/sshpk/lib/signature.js +14 -6
- package/node_modules/sshpk/lib/ssh-buffer.js +24 -0
- package/node_modules/sshpk/lib/utils.js +43 -1
- package/node_modules/sshpk/node_modules/assert-plus/package.json +16 -8
- package/node_modules/sshpk/package.json +32 -22
- package/node_modules/string-width/index.js +5 -0
- package/node_modules/string-width/package.json +49 -36
- package/node_modules/string-width/readme.md +4 -3
- package/node_modules/string_decoder/package.json +19 -11
- package/node_modules/stringstream/package.json +18 -10
- package/node_modules/strip-ansi/package.json +29 -21
- package/node_modules/strip-json-comments/index.js +70 -0
- package/node_modules/strip-json-comments/package.json +49 -43
- package/node_modules/strip-json-comments/readme.md +12 -28
- package/node_modules/supports-color/package.json +26 -18
- package/node_modules/tar/package.json +19 -11
- package/node_modules/tar-pack/README.md +4 -1
- package/node_modules/tar-pack/index.js +17 -12
- package/node_modules/tar-pack/node_modules/once/LICENSE +15 -0
- package/node_modules/tar-pack/node_modules/once/README.md +51 -0
- package/node_modules/tar-pack/node_modules/once/once.js +21 -0
- package/node_modules/tar-pack/node_modules/once/package.json +96 -0
- package/node_modules/tar-pack/node_modules/readable-stream/.npmignore +8 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/.travis.yml +4 -7
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/LICENSE +0 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/README.md +2 -2
- package/node_modules/tar-pack/node_modules/readable-stream/doc/stream.md +2015 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/duplex.js +0 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/lib/_stream_duplex.js +0 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/lib/_stream_passthrough.js +0 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/lib/_stream_readable.js +164 -107
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/lib/_stream_transform.js +3 -3
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/lib/_stream_writable.js +25 -15
- package/node_modules/tar-pack/node_modules/readable-stream/lib/internal/streams/BufferList.js +64 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/package.json +50 -30
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/passthrough.js +0 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/readable.js +4 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/transform.js +0 -0
- package/node_modules/{bl → tar-pack}/node_modules/readable-stream/writable.js +0 -0
- package/node_modules/tar-pack/package.json +39 -22
- package/node_modules/tar-pack/test/index.js +43 -1
- package/node_modules/tough-cookie/README.md +17 -3
- package/node_modules/tough-cookie/lib/cookie.js +6 -12
- package/node_modules/tough-cookie/package.json +50 -35
- package/node_modules/tunnel-agent/package.json +15 -7
- package/node_modules/tweetnacl/AUTHORS.md +28 -0
- package/node_modules/tweetnacl/CHANGELOG.md +93 -0
- package/node_modules/tweetnacl/LICENSE +24 -0
- package/node_modules/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
- package/node_modules/tweetnacl/README.md +57 -61
- package/node_modules/tweetnacl/nacl-fast.js +22 -52
- package/node_modules/tweetnacl/nacl-fast.min.js +2 -2
- package/node_modules/tweetnacl/nacl.d.ts +98 -0
- package/node_modules/tweetnacl/nacl.js +21 -51
- package/node_modules/tweetnacl/nacl.min.js +1 -1
- package/node_modules/tweetnacl/package.json +47 -46
- package/node_modules/uid-number/package.json +15 -7
- package/node_modules/util-deprecate/package.json +21 -13
- package/node_modules/uuid/.npmignore +8 -0
- package/node_modules/uuid/.travis.yml +5 -0
- package/node_modules/uuid/AUTHORS +5 -0
- package/node_modules/uuid/HISTORY.md +28 -0
- package/node_modules/uuid/LICENSE.md +21 -0
- package/node_modules/uuid/README.md +132 -0
- package/node_modules/{node-uuid → uuid}/bin/uuid +0 -0
- package/node_modules/uuid/index.js +8 -0
- package/node_modules/uuid/lib/bytesToUuid.js +23 -0
- package/node_modules/uuid/lib/rng-browser.js +33 -0
- package/node_modules/uuid/lib/rng.js +10 -0
- package/node_modules/uuid/package.json +122 -0
- package/node_modules/uuid/test/mocha.opts +3 -0
- package/node_modules/uuid/test/test.js +96 -0
- package/node_modules/uuid/v1.js +103 -0
- package/node_modules/uuid/v4.js +29 -0
- package/node_modules/verror/package.json +14 -6
- package/node_modules/wide-align/package.json +19 -11
- package/node_modules/wrappy/package.json +17 -8
- package/node_modules/xtend/package.json +29 -21
- package/package.json +2 -2
- package/node_modules/async/CHANGELOG.md +0 -125
- package/node_modules/async/README.md +0 -1877
- package/node_modules/async/dist/async.js +0 -1265
- package/node_modules/async/dist/async.min.js +0 -2
- package/node_modules/async/lib/async.js +0 -1265
- package/node_modules/async/package.json +0 -149
- package/node_modules/bl/.jshintrc +0 -59
- package/node_modules/bl/.npmignore +0 -1
- package/node_modules/bl/.travis.yml +0 -13
- package/node_modules/bl/LICENSE.md +0 -13
- package/node_modules/bl/README.md +0 -200
- package/node_modules/bl/bl.js +0 -243
- package/node_modules/bl/node_modules/readable-stream/.npmignore +0 -5
- package/node_modules/bl/node_modules/readable-stream/.zuul.yml +0 -1
- package/node_modules/bl/node_modules/readable-stream/doc/stream.markdown +0 -1760
- package/node_modules/bl/package.json +0 -96
- package/node_modules/bl/test/test.js +0 -640
- package/node_modules/form-data/.dockerignore +0 -7
- package/node_modules/form-data/.editorconfig +0 -10
- package/node_modules/form-data/.eslintignore +0 -1
- package/node_modules/form-data/.eslintrc +0 -64
- package/node_modules/form-data/wercker.yml +0 -36
- package/node_modules/gauge/CHANGELOG.md~ +0 -123
- package/node_modules/gauge/README.md~ +0 -393
- package/node_modules/has-color/index.js +0 -32
- package/node_modules/has-color/package.json +0 -97
- package/node_modules/has-color/readme.md +0 -30
- package/node_modules/inherits/test.js +0 -25
- package/node_modules/jsonpointer/.travis.yml +0 -10
- package/node_modules/jsonpointer/test.js +0 -98
- package/node_modules/node-uuid/.npmignore +0 -4
- package/node_modules/node-uuid/README.md +0 -254
- package/node_modules/node-uuid/benchmark/README.md +0 -53
- package/node_modules/node-uuid/benchmark/bench.gnu +0 -174
- package/node_modules/node-uuid/benchmark/bench.sh +0 -34
- package/node_modules/node-uuid/benchmark/benchmark-native.c +0 -34
- package/node_modules/node-uuid/benchmark/benchmark.js +0 -84
- package/node_modules/node-uuid/bower.json +0 -23
- package/node_modules/node-uuid/component.json +0 -25
- package/node_modules/node-uuid/package.json +0 -105
- package/node_modules/node-uuid/test/compare_v1.js +0 -63
- package/node_modules/node-uuid/test/test.html +0 -17
- package/node_modules/node-uuid/test/test.js +0 -231
- package/node_modules/node-uuid/uuid.js +0 -272
- package/node_modules/npmlog/CHANGELOG.md~ +0 -31
- package/node_modules/qs/.jscs.json +0 -176
- package/node_modules/qs/CONTRIBUTING.md +0 -1
- package/node_modules/readable-stream/doc/stream.md +0 -1772
- package/node_modules/request/.eslintrc +0 -45
- package/node_modules/request/.npmignore +0 -6
- package/node_modules/request/.travis.yml +0 -21
- package/node_modules/request/CONTRIBUTING.md +0 -81
- package/node_modules/request/codecov.yml +0 -2
- package/node_modules/strip-json-comments/cli.js +0 -41
- package/node_modules/strip-json-comments/strip-json-comments.js +0 -73
@@ -10,6 +10,10 @@ var processNextTick = require('process-nextick-args');
|
|
10
10
|
var isArray = require('isarray');
|
11
11
|
/*</replacement>*/
|
12
12
|
|
13
|
+
/*<replacement>*/
|
14
|
+
var Duplex;
|
15
|
+
/*</replacement>*/
|
16
|
+
|
13
17
|
Readable.ReadableState = ReadableState;
|
14
18
|
|
15
19
|
/*<replacement>*/
|
@@ -51,24 +55,25 @@ if (debugUtil && debugUtil.debuglog) {
|
|
51
55
|
}
|
52
56
|
/*</replacement>*/
|
53
57
|
|
58
|
+
var BufferList = require('./internal/streams/BufferList');
|
54
59
|
var StringDecoder;
|
55
60
|
|
56
61
|
util.inherits(Readable, Stream);
|
57
62
|
|
58
|
-
var hasPrependListener = typeof EE.prototype.prependListener === 'function';
|
59
|
-
|
60
63
|
function prependListener(emitter, event, fn) {
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
// Sadly this is not cacheable as some libraries bundle their own
|
65
|
+
// event emitter implementation with them.
|
66
|
+
if (typeof emitter.prependListener === 'function') {
|
67
|
+
return emitter.prependListener(event, fn);
|
68
|
+
} else {
|
69
|
+
// This is a hack to make sure that our error handler is attached before any
|
70
|
+
// userland ones. NEVER DO THIS. This is here only because this code needs
|
71
|
+
// to continue to work with older versions of Node.js that do not include
|
72
|
+
// the prependListener() method. The goal is to eventually remove this hack.
|
73
|
+
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
|
74
|
+
}
|
69
75
|
}
|
70
76
|
|
71
|
-
var Duplex;
|
72
77
|
function ReadableState(options, stream) {
|
73
78
|
Duplex = Duplex || require('./_stream_duplex');
|
74
79
|
|
@@ -89,7 +94,10 @@ function ReadableState(options, stream) {
|
|
89
94
|
// cast to ints.
|
90
95
|
this.highWaterMark = ~ ~this.highWaterMark;
|
91
96
|
|
92
|
-
|
97
|
+
// A linked list is used to store data chunks instead of an array because the
|
98
|
+
// linked list can remove elements from the beginning faster than
|
99
|
+
// array.shift()
|
100
|
+
this.buffer = new BufferList();
|
93
101
|
this.length = 0;
|
94
102
|
this.pipes = null;
|
95
103
|
this.pipesCount = 0;
|
@@ -135,7 +143,6 @@ function ReadableState(options, stream) {
|
|
135
143
|
}
|
136
144
|
}
|
137
145
|
|
138
|
-
var Duplex;
|
139
146
|
function Readable(options) {
|
140
147
|
Duplex = Duplex || require('./_stream_duplex');
|
141
148
|
|
@@ -252,7 +259,8 @@ function computeNewHighWaterMark(n) {
|
|
252
259
|
if (n >= MAX_HWM) {
|
253
260
|
n = MAX_HWM;
|
254
261
|
} else {
|
255
|
-
// Get the next highest power of 2
|
262
|
+
// Get the next highest power of 2 to prevent increasing hwm excessively in
|
263
|
+
// tiny amounts
|
256
264
|
n--;
|
257
265
|
n |= n >>> 1;
|
258
266
|
n |= n >>> 2;
|
@@ -264,44 +272,34 @@ function computeNewHighWaterMark(n) {
|
|
264
272
|
return n;
|
265
273
|
}
|
266
274
|
|
275
|
+
// This function is designed to be inlinable, so please take care when making
|
276
|
+
// changes to the function body.
|
267
277
|
function howMuchToRead(n, state) {
|
268
|
-
if (state.length === 0 && state.ended) return 0;
|
269
|
-
|
270
|
-
if (
|
271
|
-
|
272
|
-
|
273
|
-
// only flow one buffer at a time
|
274
|
-
if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length;
|
278
|
+
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
279
|
+
if (state.objectMode) return 1;
|
280
|
+
if (n !== n) {
|
281
|
+
// Only flow one buffer at a time
|
282
|
+
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
275
283
|
}
|
276
|
-
|
277
|
-
if (n <= 0) return 0;
|
278
|
-
|
279
|
-
// If we're asking for more than the target buffer level,
|
280
|
-
// then raise the water mark. Bump up to the next highest
|
281
|
-
// power of 2, to prevent increasing it excessively in tiny
|
282
|
-
// amounts.
|
284
|
+
// If we're asking for more than the current hwm, then raise the hwm.
|
283
285
|
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
284
|
-
|
285
|
-
//
|
286
|
-
if (
|
287
|
-
|
288
|
-
|
289
|
-
return 0;
|
290
|
-
} else {
|
291
|
-
return state.length;
|
292
|
-
}
|
286
|
+
if (n <= state.length) return n;
|
287
|
+
// Don't have enough
|
288
|
+
if (!state.ended) {
|
289
|
+
state.needReadable = true;
|
290
|
+
return 0;
|
293
291
|
}
|
294
|
-
|
295
|
-
return n;
|
292
|
+
return state.length;
|
296
293
|
}
|
297
294
|
|
298
295
|
// you can override either this method, or the async _read(n) below.
|
299
296
|
Readable.prototype.read = function (n) {
|
300
297
|
debug('read', n);
|
298
|
+
n = parseInt(n, 10);
|
301
299
|
var state = this._readableState;
|
302
300
|
var nOrig = n;
|
303
301
|
|
304
|
-
if (
|
302
|
+
if (n !== 0) state.emittedReadable = false;
|
305
303
|
|
306
304
|
// if we're doing read(0) to trigger a readable event, but we
|
307
305
|
// already have a bunch of data in the buffer, then just trigger
|
@@ -357,9 +355,7 @@ Readable.prototype.read = function (n) {
|
|
357
355
|
if (state.ended || state.reading) {
|
358
356
|
doRead = false;
|
359
357
|
debug('reading or ended', doRead);
|
360
|
-
}
|
361
|
-
|
362
|
-
if (doRead) {
|
358
|
+
} else if (doRead) {
|
363
359
|
debug('do read');
|
364
360
|
state.reading = true;
|
365
361
|
state.sync = true;
|
@@ -368,28 +364,29 @@ Readable.prototype.read = function (n) {
|
|
368
364
|
// call internal read method
|
369
365
|
this._read(state.highWaterMark);
|
370
366
|
state.sync = false;
|
367
|
+
// If _read pushed data synchronously, then `reading` will be false,
|
368
|
+
// and we need to re-evaluate how much data we can return to the user.
|
369
|
+
if (!state.reading) n = howMuchToRead(nOrig, state);
|
371
370
|
}
|
372
371
|
|
373
|
-
// If _read pushed data synchronously, then `reading` will be false,
|
374
|
-
// and we need to re-evaluate how much data we can return to the user.
|
375
|
-
if (doRead && !state.reading) n = howMuchToRead(nOrig, state);
|
376
|
-
|
377
372
|
var ret;
|
378
373
|
if (n > 0) ret = fromList(n, state);else ret = null;
|
379
374
|
|
380
375
|
if (ret === null) {
|
381
376
|
state.needReadable = true;
|
382
377
|
n = 0;
|
378
|
+
} else {
|
379
|
+
state.length -= n;
|
383
380
|
}
|
384
381
|
|
385
|
-
state.length
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
if (state.length === 0 && !state.ended) state.needReadable = true;
|
382
|
+
if (state.length === 0) {
|
383
|
+
// If we have nothing in the buffer, then we want to know
|
384
|
+
// as soon as we *do* get something into the buffer.
|
385
|
+
if (!state.ended) state.needReadable = true;
|
390
386
|
|
391
|
-
|
392
|
-
|
387
|
+
// If we tried to read() past the EOF, then emit end on the next tick.
|
388
|
+
if (nOrig !== n && state.ended) endReadable(this);
|
389
|
+
}
|
393
390
|
|
394
391
|
if (ret !== null) this.emit('data', ret);
|
395
392
|
|
@@ -468,7 +465,7 @@ function maybeReadMore_(stream, state) {
|
|
468
465
|
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
469
466
|
// arbitrary, and perhaps not very meaningful.
|
470
467
|
Readable.prototype._read = function (n) {
|
471
|
-
this.emit('error', new Error('not implemented'));
|
468
|
+
this.emit('error', new Error('_read() is not implemented'));
|
472
469
|
};
|
473
470
|
|
474
471
|
Readable.prototype.pipe = function (dest, pipeOpts) {
|
@@ -537,11 +534,17 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
537
534
|
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
538
535
|
}
|
539
536
|
|
537
|
+
// If the user pushes more data while we're writing to dest then we'll end up
|
538
|
+
// in ondata again. However, we only want to increase awaitDrain once because
|
539
|
+
// dest will only emit one 'drain' event for the multiple writes.
|
540
|
+
// => Introduce a guard on increasing awaitDrain.
|
541
|
+
var increasedAwaitDrain = false;
|
540
542
|
src.on('data', ondata);
|
541
543
|
function ondata(chunk) {
|
542
544
|
debug('ondata');
|
545
|
+
increasedAwaitDrain = false;
|
543
546
|
var ret = dest.write(chunk);
|
544
|
-
if (false === ret) {
|
547
|
+
if (false === ret && !increasedAwaitDrain) {
|
545
548
|
// If the user unpiped during `dest.write()`, it is possible
|
546
549
|
// to get stuck in a permanently paused state if that write
|
547
550
|
// also returned false.
|
@@ -549,6 +552,7 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
549
552
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
550
553
|
debug('false write response, pause', src._readableState.awaitDrain);
|
551
554
|
src._readableState.awaitDrain++;
|
555
|
+
increasedAwaitDrain = true;
|
552
556
|
}
|
553
557
|
src.pause();
|
554
558
|
}
|
@@ -639,16 +643,16 @@ Readable.prototype.unpipe = function (dest) {
|
|
639
643
|
state.pipesCount = 0;
|
640
644
|
state.flowing = false;
|
641
645
|
|
642
|
-
for (var
|
643
|
-
dests[
|
646
|
+
for (var i = 0; i < len; i++) {
|
647
|
+
dests[i].emit('unpipe', this);
|
644
648
|
}return this;
|
645
649
|
}
|
646
650
|
|
647
651
|
// try to find the right one.
|
648
|
-
var
|
649
|
-
if (
|
652
|
+
var index = indexOf(state.pipes, dest);
|
653
|
+
if (index === -1) return this;
|
650
654
|
|
651
|
-
state.pipes.splice(
|
655
|
+
state.pipes.splice(index, 1);
|
652
656
|
state.pipesCount -= 1;
|
653
657
|
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
654
658
|
|
@@ -662,18 +666,14 @@ Readable.prototype.unpipe = function (dest) {
|
|
662
666
|
Readable.prototype.on = function (ev, fn) {
|
663
667
|
var res = Stream.prototype.on.call(this, ev, fn);
|
664
668
|
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
}
|
670
|
-
|
671
|
-
if (ev === 'readable' && !this._readableState.endEmitted) {
|
669
|
+
if (ev === 'data') {
|
670
|
+
// Start flowing on next tick if stream isn't explicitly paused
|
671
|
+
if (this._readableState.flowing !== false) this.resume();
|
672
|
+
} else if (ev === 'readable') {
|
672
673
|
var state = this._readableState;
|
673
|
-
if (!state.readableListening) {
|
674
|
-
state.readableListening = true;
|
674
|
+
if (!state.endEmitted && !state.readableListening) {
|
675
|
+
state.readableListening = state.needReadable = true;
|
675
676
|
state.emittedReadable = false;
|
676
|
-
state.needReadable = true;
|
677
677
|
if (!state.reading) {
|
678
678
|
processNextTick(nReadingNextTick, this);
|
679
679
|
} else if (state.length) {
|
@@ -717,6 +717,7 @@ function resume_(stream, state) {
|
|
717
717
|
}
|
718
718
|
|
719
719
|
state.resumeScheduled = false;
|
720
|
+
state.awaitDrain = 0;
|
720
721
|
stream.emit('resume');
|
721
722
|
flow(stream);
|
722
723
|
if (state.flowing && !state.reading) stream.read(0);
|
@@ -735,11 +736,7 @@ Readable.prototype.pause = function () {
|
|
735
736
|
function flow(stream) {
|
736
737
|
var state = stream._readableState;
|
737
738
|
debug('flow', state.flowing);
|
738
|
-
|
739
|
-
do {
|
740
|
-
var chunk = stream.read();
|
741
|
-
} while (null !== chunk && state.flowing);
|
742
|
-
}
|
739
|
+
while (state.flowing && stream.read() !== null) {}
|
743
740
|
}
|
744
741
|
|
745
742
|
// wrap an old-style stream as the async data source.
|
@@ -810,50 +807,101 @@ Readable._fromList = fromList;
|
|
810
807
|
|
811
808
|
// Pluck off n bytes from an array of buffers.
|
812
809
|
// Length is the combined lengths of all the buffers in the list.
|
810
|
+
// This function is designed to be inlinable, so please take care when making
|
811
|
+
// changes to the function body.
|
813
812
|
function fromList(n, state) {
|
814
|
-
|
815
|
-
|
816
|
-
var stringMode = !!state.decoder;
|
817
|
-
var objectMode = !!state.objectMode;
|
818
|
-
var ret;
|
819
|
-
|
820
|
-
// nothing in the list, definitely empty.
|
821
|
-
if (list.length === 0) return null;
|
813
|
+
// nothing buffered
|
814
|
+
if (state.length === 0) return null;
|
822
815
|
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
816
|
+
var ret;
|
817
|
+
if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
|
818
|
+
// read it all, truncate the list
|
819
|
+
if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
|
820
|
+
state.buffer.clear();
|
827
821
|
} else {
|
828
|
-
// read
|
829
|
-
|
830
|
-
|
831
|
-
// slice is the same for buffers and strings.
|
832
|
-
var buf = list[0];
|
833
|
-
ret = buf.slice(0, n);
|
834
|
-
list[0] = buf.slice(n);
|
835
|
-
} else if (n === list[0].length) {
|
836
|
-
// first list is a perfect match
|
837
|
-
ret = list.shift();
|
838
|
-
} else {
|
839
|
-
// complex case.
|
840
|
-
// we have enough to cover it, but it spans past the first buffer.
|
841
|
-
if (stringMode) ret = '';else ret = bufferShim.allocUnsafe(n);
|
842
|
-
|
843
|
-
var c = 0;
|
844
|
-
for (var i = 0, l = list.length; i < l && c < n; i++) {
|
845
|
-
var _buf = list[0];
|
846
|
-
var cpy = Math.min(n - c, _buf.length);
|
822
|
+
// read part of list
|
823
|
+
ret = fromListPartial(n, state.buffer, state.decoder);
|
824
|
+
}
|
847
825
|
|
848
|
-
|
826
|
+
return ret;
|
827
|
+
}
|
849
828
|
|
850
|
-
|
829
|
+
// Extracts only enough buffered data to satisfy the amount requested.
|
830
|
+
// This function is designed to be inlinable, so please take care when making
|
831
|
+
// changes to the function body.
|
832
|
+
function fromListPartial(n, list, hasStrings) {
|
833
|
+
var ret;
|
834
|
+
if (n < list.head.data.length) {
|
835
|
+
// slice is the same for buffers and strings
|
836
|
+
ret = list.head.data.slice(0, n);
|
837
|
+
list.head.data = list.head.data.slice(n);
|
838
|
+
} else if (n === list.head.data.length) {
|
839
|
+
// first chunk is a perfect match
|
840
|
+
ret = list.shift();
|
841
|
+
} else {
|
842
|
+
// result spans more than one buffer
|
843
|
+
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
844
|
+
}
|
845
|
+
return ret;
|
846
|
+
}
|
851
847
|
|
852
|
-
|
848
|
+
// Copies a specified amount of characters from the list of buffered data
|
849
|
+
// chunks.
|
850
|
+
// This function is designed to be inlinable, so please take care when making
|
851
|
+
// changes to the function body.
|
852
|
+
function copyFromBufferString(n, list) {
|
853
|
+
var p = list.head;
|
854
|
+
var c = 1;
|
855
|
+
var ret = p.data;
|
856
|
+
n -= ret.length;
|
857
|
+
while (p = p.next) {
|
858
|
+
var str = p.data;
|
859
|
+
var nb = n > str.length ? str.length : n;
|
860
|
+
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
861
|
+
n -= nb;
|
862
|
+
if (n === 0) {
|
863
|
+
if (nb === str.length) {
|
864
|
+
++c;
|
865
|
+
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
866
|
+
} else {
|
867
|
+
list.head = p;
|
868
|
+
p.data = str.slice(nb);
|
853
869
|
}
|
870
|
+
break;
|
854
871
|
}
|
872
|
+
++c;
|
855
873
|
}
|
874
|
+
list.length -= c;
|
875
|
+
return ret;
|
876
|
+
}
|
856
877
|
|
878
|
+
// Copies a specified amount of bytes from the list of buffered data chunks.
|
879
|
+
// This function is designed to be inlinable, so please take care when making
|
880
|
+
// changes to the function body.
|
881
|
+
function copyFromBuffer(n, list) {
|
882
|
+
var ret = bufferShim.allocUnsafe(n);
|
883
|
+
var p = list.head;
|
884
|
+
var c = 1;
|
885
|
+
p.data.copy(ret);
|
886
|
+
n -= p.data.length;
|
887
|
+
while (p = p.next) {
|
888
|
+
var buf = p.data;
|
889
|
+
var nb = n > buf.length ? buf.length : n;
|
890
|
+
buf.copy(ret, ret.length - n, 0, nb);
|
891
|
+
n -= nb;
|
892
|
+
if (n === 0) {
|
893
|
+
if (nb === buf.length) {
|
894
|
+
++c;
|
895
|
+
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
896
|
+
} else {
|
897
|
+
list.head = p;
|
898
|
+
p.data = buf.slice(nb);
|
899
|
+
}
|
900
|
+
break;
|
901
|
+
}
|
902
|
+
++c;
|
903
|
+
}
|
904
|
+
list.length -= c;
|
857
905
|
return ret;
|
858
906
|
}
|
859
907
|
|
@@ -94,7 +94,6 @@ function Transform(options) {
|
|
94
94
|
|
95
95
|
this._transformState = new TransformState(this);
|
96
96
|
|
97
|
-
// when the writable side finishes, then flush out anything remaining.
|
98
97
|
var stream = this;
|
99
98
|
|
100
99
|
// start out asking for a readable event once data is transformed.
|
@@ -111,9 +110,10 @@ function Transform(options) {
|
|
111
110
|
if (typeof options.flush === 'function') this._flush = options.flush;
|
112
111
|
}
|
113
112
|
|
113
|
+
// When the writable side finishes, then flush out anything remaining.
|
114
114
|
this.once('prefinish', function () {
|
115
|
-
if (typeof this._flush === 'function') this._flush(function (er) {
|
116
|
-
done(stream, er);
|
115
|
+
if (typeof this._flush === 'function') this._flush(function (er, data) {
|
116
|
+
done(stream, er, data);
|
117
117
|
});else done(stream);
|
118
118
|
});
|
119
119
|
}
|
@@ -134,7 +134,7 @@ Transform.prototype.push = function (chunk, encoding) {
|
|
134
134
|
// an error, then that'll put the hurt on the whole operation. If you
|
135
135
|
// never call cb(), then you'll never get another chunk.
|
136
136
|
Transform.prototype._transform = function (chunk, encoding, cb) {
|
137
|
-
throw new Error('
|
137
|
+
throw new Error('_transform() is not implemented');
|
138
138
|
};
|
139
139
|
|
140
140
|
Transform.prototype._write = function (chunk, encoding, cb) {
|
@@ -164,9 +164,11 @@ Transform.prototype._read = function (n) {
|
|
164
164
|
}
|
165
165
|
};
|
166
166
|
|
167
|
-
function done(stream, er) {
|
167
|
+
function done(stream, er, data) {
|
168
168
|
if (er) return stream.emit('error', er);
|
169
169
|
|
170
|
+
if (data !== null && data !== undefined) stream.push(data);
|
171
|
+
|
170
172
|
// if there's nothing in the write buffer, then that means
|
171
173
|
// that nothing more will ever be provided
|
172
174
|
var ws = stream._writableState;
|
@@ -14,6 +14,10 @@ var processNextTick = require('process-nextick-args');
|
|
14
14
|
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
|
15
15
|
/*</replacement>*/
|
16
16
|
|
17
|
+
/*<replacement>*/
|
18
|
+
var Duplex;
|
19
|
+
/*</replacement>*/
|
20
|
+
|
17
21
|
Writable.WritableState = WritableState;
|
18
22
|
|
19
23
|
/*<replacement>*/
|
@@ -54,7 +58,6 @@ function WriteReq(chunk, encoding, cb) {
|
|
54
58
|
this.next = null;
|
55
59
|
}
|
56
60
|
|
57
|
-
var Duplex;
|
58
61
|
function WritableState(options, stream) {
|
59
62
|
Duplex = Duplex || require('./_stream_duplex');
|
60
63
|
|
@@ -76,6 +79,7 @@ function WritableState(options, stream) {
|
|
76
79
|
// cast to ints.
|
77
80
|
this.highWaterMark = ~ ~this.highWaterMark;
|
78
81
|
|
82
|
+
// drain event flag.
|
79
83
|
this.needDrain = false;
|
80
84
|
// at the start of calling end()
|
81
85
|
this.ending = false;
|
@@ -150,7 +154,7 @@ function WritableState(options, stream) {
|
|
150
154
|
this.corkedRequestsFree = new CorkedRequest(this);
|
151
155
|
}
|
152
156
|
|
153
|
-
WritableState.prototype.getBuffer = function
|
157
|
+
WritableState.prototype.getBuffer = function getBuffer() {
|
154
158
|
var current = this.bufferedRequest;
|
155
159
|
var out = [];
|
156
160
|
while (current) {
|
@@ -170,13 +174,37 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
|
|
170
174
|
} catch (_) {}
|
171
175
|
})();
|
172
176
|
|
173
|
-
|
177
|
+
// Test _writableState for inheritance to account for Duplex streams,
|
178
|
+
// whose prototype chain only points to Readable.
|
179
|
+
var realHasInstance;
|
180
|
+
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
181
|
+
realHasInstance = Function.prototype[Symbol.hasInstance];
|
182
|
+
Object.defineProperty(Writable, Symbol.hasInstance, {
|
183
|
+
value: function (object) {
|
184
|
+
if (realHasInstance.call(this, object)) return true;
|
185
|
+
|
186
|
+
return object && object._writableState instanceof WritableState;
|
187
|
+
}
|
188
|
+
});
|
189
|
+
} else {
|
190
|
+
realHasInstance = function (object) {
|
191
|
+
return object instanceof this;
|
192
|
+
};
|
193
|
+
}
|
194
|
+
|
174
195
|
function Writable(options) {
|
175
196
|
Duplex = Duplex || require('./_stream_duplex');
|
176
197
|
|
177
|
-
// Writable ctor is applied to Duplexes,
|
178
|
-
//
|
179
|
-
|
198
|
+
// Writable ctor is applied to Duplexes, too.
|
199
|
+
// `realHasInstance` is necessary because using plain `instanceof`
|
200
|
+
// would return false, as no `_writableState` property is attached.
|
201
|
+
|
202
|
+
// Trying to use the custom `instanceof` for Writable here will also break the
|
203
|
+
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
204
|
+
// `_writableState` that would lead to infinite recursion.
|
205
|
+
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
206
|
+
return new Writable(options);
|
207
|
+
}
|
180
208
|
|
181
209
|
this._writableState = new WritableState(options, this);
|
182
210
|
|
@@ -436,7 +464,7 @@ function clearBuffer(stream, state) {
|
|
436
464
|
}
|
437
465
|
|
438
466
|
Writable.prototype._write = function (chunk, encoding, cb) {
|
439
|
-
cb(new Error('not implemented'));
|
467
|
+
cb(new Error('_write() is not implemented'));
|
440
468
|
};
|
441
469
|
|
442
470
|
Writable.prototype._writev = null;
|
@@ -0,0 +1,64 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var Buffer = require('buffer').Buffer;
|
4
|
+
/*<replacement>*/
|
5
|
+
var bufferShim = require('buffer-shims');
|
6
|
+
/*</replacement>*/
|
7
|
+
|
8
|
+
module.exports = BufferList;
|
9
|
+
|
10
|
+
function BufferList() {
|
11
|
+
this.head = null;
|
12
|
+
this.tail = null;
|
13
|
+
this.length = 0;
|
14
|
+
}
|
15
|
+
|
16
|
+
BufferList.prototype.push = function (v) {
|
17
|
+
var entry = { data: v, next: null };
|
18
|
+
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
19
|
+
this.tail = entry;
|
20
|
+
++this.length;
|
21
|
+
};
|
22
|
+
|
23
|
+
BufferList.prototype.unshift = function (v) {
|
24
|
+
var entry = { data: v, next: this.head };
|
25
|
+
if (this.length === 0) this.tail = entry;
|
26
|
+
this.head = entry;
|
27
|
+
++this.length;
|
28
|
+
};
|
29
|
+
|
30
|
+
BufferList.prototype.shift = function () {
|
31
|
+
if (this.length === 0) return;
|
32
|
+
var ret = this.head.data;
|
33
|
+
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
34
|
+
--this.length;
|
35
|
+
return ret;
|
36
|
+
};
|
37
|
+
|
38
|
+
BufferList.prototype.clear = function () {
|
39
|
+
this.head = this.tail = null;
|
40
|
+
this.length = 0;
|
41
|
+
};
|
42
|
+
|
43
|
+
BufferList.prototype.join = function (s) {
|
44
|
+
if (this.length === 0) return '';
|
45
|
+
var p = this.head;
|
46
|
+
var ret = '' + p.data;
|
47
|
+
while (p = p.next) {
|
48
|
+
ret += s + p.data;
|
49
|
+
}return ret;
|
50
|
+
};
|
51
|
+
|
52
|
+
BufferList.prototype.concat = function (n) {
|
53
|
+
if (this.length === 0) return bufferShim.alloc(0);
|
54
|
+
if (this.length === 1) return this.head.data;
|
55
|
+
var ret = bufferShim.allocUnsafe(n >>> 0);
|
56
|
+
var p = this.head;
|
57
|
+
var i = 0;
|
58
|
+
while (p) {
|
59
|
+
p.data.copy(ret, i);
|
60
|
+
i += p.data.length;
|
61
|
+
p = p.next;
|
62
|
+
}
|
63
|
+
return ret;
|
64
|
+
};
|