Projects
Mega:24.09
nodejs-readable-stream
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
_service:tar_scm:nodejs-readable-stream.spec
Changed
@@ -3,8 +3,8 @@ %global packagename readable-stream %global owner nodejs Name: nodejs-readable-stream -Version: 3.6.2 -Release: 1 +Version: 2.3.6 +Release: 2 Summary: Streams3, a user-land copy of the stream library from Node.js License: MIT URL: https://www.npmjs.org/package/readable-stream @@ -48,9 +48,6 @@ %{nodejs_sitelib}/readable-stream/ %changelog -* Thu Mar 21 2024 Dongxing Wang <dongxing.wang_a@thundersoft.com> - 3.6.2-1 -- Update package with version 3.6.2 - * Thu Jul 7 2022 houyingchao <houyingchao@h-partners.com> - 2.3.6-2 - Fix compilation failed
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="scm">git</param> <param name="url">git@gitee.com:src-openeuler/nodejs-readable-stream.git</param> - <param name="revision">master</param> + <param name="revision">openEuler-24.09</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/.gitignore -> _service:tar_scm:readable-stream-2.3.6.tar.gz/.gitignore
Changed
@@ -4,5 +4,3 @@ coverage package-lock.json *.tap -.airtaprc -yarn.lock
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/.npmignore -> _service:tar_scm:readable-stream-2.3.6.tar.gz/.npmignore
Changed
@@ -3,10 +3,7 @@ examples/ fs.js zlib.js -.airtap.yml -.airtaprc -.babelrc -.travis.yml +.zuul.yml .nyc_output coverage -doc/ +docs/
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/.travis.yml -> _service:tar_scm:readable-stream-2.3.6.tar.gz/.travis.yml
Changed
@@ -1,23 +1,55 @@ +sudo: false language: node_js +before_install: + - npm install -g npm@2 + - test $NPM_LEGACY && npm install -g npm@latest-3 || npm install npm -g notifications: email: false matrix: fast_finish: true include: + - node_js: '0.8' + env: + - TASK=test + - NPM_LEGACY=true + - node_js: '0.10' + env: + - TASK=test + - NPM_LEGACY=true + - node_js: '0.11' + env: + - TASK=test + - NPM_LEGACY=true + - node_js: '0.12' + env: + - TASK=test + - NPM_LEGACY=true + - node_js: 1 + env: + - TASK=test + - NPM_LEGACY=true + - node_js: 2 + env: + - TASK=test + - NPM_LEGACY=true + - node_js: 3 + env: + - TASK=test + - NPM_LEGACY=true + - node_js: 4 + env: TASK=test + - node_js: 5 + env: TASK=test - node_js: 6 - env: CMD=test + env: TASK=test + - node_js: 7 + env: TASK=test - node_js: 8 - env: CMD=test + env: TASK=test - node_js: 9 - env: CMD=test - - node_js: 10 - env: CMD=test - - node_js: 12 - env: CMD=test - - node_js: 12 - env: CMD=test-browsers - addons: - sauce_connect: true - hosts: - - airtap.local -script: npm run $CMD + env: TASK=test +script: "npm run $TASK" +env: + global: + - secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc= + - secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/README.md -> _service:tar_scm:readable-stream-2.3.6.tar.gz/README.md
Changed
@@ -1,81 +1,30 @@ # readable-stream -***Node.js core streams for userland*** !Build Status(https://travis-ci.com/nodejs/readable-stream.svg?branch=master)(https://travis-ci.com/nodejs/readable-stream) +***Node-core v8.11.1 streams for userland*** !Build Status(https://travis-ci.org/nodejs/readable-stream.svg?branch=master)(https://travis-ci.org/nodejs/readable-stream) !NPM(https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)(https://nodei.co/npm/readable-stream/) !NPM(https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)(https://nodei.co/npm/readable-stream/) -!Sauce Test Status(https://saucelabs.com/browser-matrix/readabe-stream.svg)(https://saucelabs.com/u/readabe-stream) +!Sauce Test Status(https://saucelabs.com/browser-matrix/readable-stream.svg)(https://saucelabs.com/u/readable-stream) ```bash npm install --save readable-stream ``` -This package is a mirror of the streams implementations in Node.js. +***Node-core streams for userland*** -Full documentation may be found on the Node.js website(https://nodejs.org/dist/v10.18.1/docs/api/stream.html). +This package is a mirror of the Streams2 and Streams3 implementations in +Node-core. + +Full documentation may be found on the Node.js website(https://nodejs.org/dist/v8.11.1/docs/api/stream.html). If you want to guarantee a stable streams base, regardless of what version of Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see this blogpost(http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html). As of version 2.0.0 **readable-stream** uses semantic versioning. -## Version 3.x.x - -v3.x.x of `readable-stream` is a cut from Node 10. This version supports Node 6, 8, and 10, as well as evergreen browsers, IE 11 and latest Safari. The breaking changes introduced by v3 are composed by the combined breaking changes in Node v9(https://nodejs.org/en/blog/release/v9.0.0/) and Node v10(https://nodejs.org/en/blog/release/v10.0.0/), as follows: - -1. Error codes: https://github.com/nodejs/node/pull/13310, - https://github.com/nodejs/node/pull/13291, - https://github.com/nodejs/node/pull/16589, - https://github.com/nodejs/node/pull/15042, - https://github.com/nodejs/node/pull/15665, - https://github.com/nodejs/readable-stream/pull/344 -2. 'readable' have precedence over flowing - https://github.com/nodejs/node/pull/18994 -3. make virtual methods errors consistent - https://github.com/nodejs/node/pull/18813 -4. updated streams error handling - https://github.com/nodejs/node/pull/18438 -5. writable.end should return this. - https://github.com/nodejs/node/pull/18780 -6. readable continues to read when push('') - https://github.com/nodejs/node/pull/18211 -7. add custom inspect to BufferList - https://github.com/nodejs/node/pull/17907 -8. always defer 'readable' with nextTick - https://github.com/nodejs/node/pull/17979 - -## Version 2.x.x -v2.x.x of `readable-stream` is a cut of the stream module from Node 8 (there have been no semver-major changes from Node 4 to 8). This version supports all Node.js versions from 0.8, as well as evergreen browsers and IE 10 & 11. - -### Big Thanks - -Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labssauce - -# Usage - -You can swap your `require('stream')` with `require('readable-stream')` -without any changes, if you are just using one of the main classes and -functions. - -```js -const { - Readable, - Writable, - Transform, - Duplex, - pipeline, - finished -} = require('readable-stream') -```` - -Note that `require('stream')` will return `Stream`, while -`require('readable-stream')` will return `Readable`. We discourage using -whatever is exported directly, but rather use one of the properties as -shown in the example above. - # Streams Working Group `readable-stream` is maintained by the Streams Working Group, which @@ -95,12 +44,15 @@ <a name="members"></a> ## Team Members +* **Chris Dickinson** (@chrisdickinson(https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com> + - Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B * **Calvin Metcalf** (@calvinmetcalf(https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com> - Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242 +* **Rod Vagg** (@rvagg(https://github.com/rvagg)) <rod@vagg.org> + - Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D +* **Sam Newman** (@sonewman(https://github.com/sonewman)) <newmansam@outlook.com> * **Mathias Buus** (@mafintosh(https://github.com/mafintosh)) <mathiasbuus@gmail.com> +* **Domenic Denicola** (@domenic(https://github.com/domenic)) <d@domenic.me> * **Matteo Collina** (@mcollina(https://github.com/mcollina)) <matteo.collina@gmail.com> - Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E * **Irina Shestak** (@lrlna(https://github.com/lrlna)) <shestak.irina@gmail.com> -* **Yoshua Wyuts** (@yoshuawuyts(https://github.com/yoshuawuyts)) <yoshuawuyts@gmail.com> - -sauce: https://saucelabs.com
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/build/build.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/build/build.js
Changed
@@ -6,7 +6,7 @@ , path = require('path') , tar = require('tar-fs') , gunzip = require('gunzip-maybe') - , babel = require('@babel/core') + , babel = require('babel-core') , glob = require('glob') , pump = require('pump') , rimraf = require('rimraf') @@ -36,7 +36,7 @@ } // `inputLoc`: URL or local path. -function processFile (inputLoc, out, replacements, addAtEnd) { +function processFile (inputLoc, out, replacements) { var file = fs.createReadStream(inputLoc, encoding) file.pipe(bl(function (err, data) { @@ -55,15 +55,21 @@ } data = data.replace(regexp, arg2) }) - - if (addAtEnd) { - data += addAtEnd - } if (inputLoc.slice(-3) === '.js') { try { const transformed = babel.transform(data, { - // Required for babel to pick up .babelrc - filename: inputLoc + plugins: + 'transform-es2015-parameters', + 'transform-es2015-arrow-functions', + 'transform-es2015-block-scoping', + 'transform-es2015-template-literals', + 'transform-es2015-shorthand-properties', + 'transform-es2015-for-of', + 'transform-es2015-classes', { loose: true }, + 'transform-es2015-destructuring', + 'transform-es2015-computed-properties', + 'transform-es2015-spread' + }) data = transformed.code } catch (err) { @@ -107,7 +113,7 @@ if (testReplacefile) replacements = replacements.concat(testReplacefile) - processFile(url, out, replacements, ';(function () { var t = require(\'tap\'); t.pass(\'sync run\'); })();var _list = process.listeners(\'uncaughtException\'); process.removeAllListeners(\'uncaughtException\'); _list.pop(); _list.forEach((e) => process.on(\'uncaughtException\', e));') + processFile(url, out, replacements) } //-------------------------------------------------------------------- @@ -131,7 +137,7 @@ //-------------------------------------------------------------------- // Discover, grab and process all test-stream* files on the given release - glob(path.join(testsrcurl, 'test-@(stream|readable)*.js'), function (err, list) { + glob(path.join(testsrcurl, 'test-stream*.js'), function (err, list) { if (err) { throw err } @@ -145,14 +151,13 @@ file !== 'test-stream-inheritance.js' && file !== 'test-stream-base-prototype-accessors.js' && file !== 'test-stream-base-prototype-accessors-enumerability.js' && - file !== 'test-stream-wrap-drain.js' && - file !== 'test-stream-pipeline-http2.js' && file !== 'test-stream-base-typechecking.js') { processTestFile(file) } }) }) + //-------------------------------------------------------------------- // Grab the nodejs/node test/common.js @@ -164,7 +169,7 @@ list.forEach(function (file) { file = path.basename(file) processFile( - path.join(testsrcurl.replace(/parallel/\\$/, 'common/'), file) + path.join(testsrcurl.replace(/parallel\/$/, 'common/'), file) , path.join(testourroot.replace('parallel', 'common'), file) , testReplace'common.js' )
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/build/files.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/build/files.js
Changed
@@ -41,12 +41,8 @@ , utilReplacement = /^const util = require\('util'\);/m - , '' - - - , inherits = - /^util.inherits/m - , 'require(\'inherits\')' + , '\n/*<replacement>*/\nconst util = require(\'core-util-is\');\n' + + 'util.inherits = require(\'inherits\');\n/*</replacement>*/\n' , debugLogReplacement = @@ -76,6 +72,16 @@ + '}catch(_){}}());\n' + , isArrayDefine = + headRegexp + , '$1\n\n/*<replacement>*/\nvar isArray = require(\'isarray\');\n/*</replacement>*/\n' + + + , isArrayReplacement = + /Array\.isArray/g + , 'isArray' + + , objectKeysDefine = require('./common-replacements').objectKeysDefine , objectKeysReplacement = require('./common-replacements').objectKeysReplacement @@ -112,11 +118,51 @@ , 'Buffer.isBuffer($1)' + , processNextTickImport = + /^('use strict';)$/m + , `$1 + +/*<replacement>*/ + var pna = require(\'process-nextick-args\'); +/*</replacement>*/ +` + + + , processNextTickReplacement = + /process.nextTick\(/g + , 'pna.nextTick(' + + , internalUtilReplacement = /^const internalUtil = require\('internal\/util'\);/m , '\n/*<replacement>*/\nconst internalUtil = {\n deprecate: require(\'util-deprecate\')\n};\n' + '/*</replacement>*/\n' + , isNode10 = + headRegexp + , `$1 + +/*<replacement>*/ + var asyncWrite = !process.browser && 'v0.10' , 'v0.9.'.indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/*</replacement>*/ +` + + , fixSyncWrite = + /if \(sync\) {\n\s+pna.nextTick\(afterWrite, stream, state, finished, cb\);\n\s+}/ + , `if (sync) { + /*<replacement>*/ + asyncWrite(afterWrite, stream, state, finished, cb); + /*</replacement>*/ + } + ` + + , safeBufferFix = + /(?:var|const) (?:{ )Buffer(?: }) = require\('buffer'\)(?:\.Buffer)?;/, + `/*<replacement>*/ + var Buffer = require('safe-buffer').Buffer; +/*</replacement>*/ +` + , internalDirectory = /require\('internal\/streams\/(a-zA-z+)'\)/g, 'require(\'./internal/streams/$1\')' @@ -130,10 +176,10 @@ , `function(er) { onwrite(stream, er); }` , addUintStuff = - /(?:var|const) (?:{ )Buffer(?: }) = require\('buffer'\)(?:\.Buffer)?;/g + /(?:var|const) Buffer = require\('safe-buffer'\)\.Buffer;/ , ` - const Buffer = require('buffer').Buffer - const OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {} + const Buffer = require('safe-buffer').Buffer + const OurUint8Array = global.Uint8Array || function () {} function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } @@ -180,65 +226,27 @@ /Object\.getPrototypeOf\((chunk)\) !== Buffer\.prototype/g , '!Buffer.isBuffer($1)' - , errorsOneLevel = - /internal\/errors/ - , '../errors' - - , errorsTwoLevel = - /internal\/errors/ - , '../../../errors' - - , warnings = - /^const { emitExperimentalWarning } = require\('internal\/util'\);/m, - 'const { emitExperimentalWarning } = require(\'../experimentalWarning\');' - - , numberIE11 = - /Number\.isNaN\(n\)/g - , 'n !== n' - - , integerIE11 = - /Number\.isInteger\(hwm\)/g - , '(isFinite(hwm) && Math.floor(hwm) === hwm)' - - , noAsyncIterators1 = - /Readable\.prototype\Symbol\.asyncIterator\ = function\(\) \{/g - , 'if (typeof Symbol === \'function\' ) {\nReadable.prototypeSymbol.asyncIterator = function () {' - - , noAsyncIterators2 = - /return createReadableStreamAsyncIterator\(this\);\n};/m - , 'return createReadableStreamAsyncIterator(this);\n};\n}' - - , noAsyncIteratorsFrom1 = - /Readable\.from = function *\(iterable, opts\) \{/g - , 'if (typeof Symbol === \'function\' ) {\nReadable.from = function (iterable, opts) {' - - , noAsyncIteratorsFrom2 = - /return from\(Readable, iterable, opts\);\n};/m - , 'return from(Readable, iterable, opts);\n};\n}' - - , once = - /const \{ once \} = require\('internal\/util'\);/ - , 'function once(callback) { let called = false; return function(...args) { if (called) return; called = true; callback(...args); }; }' + , fixCopyBuffer = + /Buffer\.prototype\.copy\.call\(src, target, offset\);/ + , 'src.copy(target, offset);' module.exports'_stream_duplex.js' = requireReplacement , instanceofReplacement , utilReplacement - , inherits , stringDecoderReplacement , objectKeysReplacement , objectKeysDefine - , errorsOneLevel + , processNextTickImport + , processNextTickReplacement module.exports'_stream_passthrough.js' = requireReplacement , instanceofReplacement , utilReplacement - , inherits , stringDecoderReplacement - , errorsOneLevel module.exports'_stream_readable.js' = @@ -249,33 +257,28 @@ , altIndexOfImplReplacement , altIndexOfUseReplacement , stringDecoderReplacement + , isArrayReplacement + , isArrayDefine , debugLogReplacement , utilReplacement - , inherits , stringDecoderReplacement , eventEmittterReplacement , requireStreamReplacement , isBufferReplacement + , processNextTickImport + , processNextTickReplacement , eventEmittterListenerCountReplacement , internalDirectory + , safeBufferFix , fixUintStuff , addUintStuff - , errorsOneLevel - , warnings - , numberIE11 - , noAsyncIterators1 - , noAsyncIterators2 - , noAsyncIteratorsFrom1 - , noAsyncIteratorsFrom2 module.exports'_stream_transform.js' = requireReplacement , instanceofReplacement , utilReplacement - , inherits , stringDecoderReplacement - , errorsOneLevel module.exports'_stream_writable.js' = @@ -284,7 +287,6 @@ , requireReplacement , instanceofReplacement , utilReplacement - , inherits , stringDecoderReplacement , debugLogReplacement , deprecateReplacement @@ -294,88 +296,47 @@ , /^var assert = require\('assert'\);$/m, '' , requireStreamReplacement , isBufferReplacement + , isNode10 + , processNextTickImport + , processNextTickReplacement , internalUtilReplacement + , fixSyncWrite , fixInstanceCheck , removeOnWriteBind , internalDirectory + , safeBufferFix , fixUintStuff , addUintStuff , fixBufferCheck , useWriteReq , useCorkedRequest , addConstructors - , errorsOneLevel -module.exports'internal/streams/buffer_list.js' = - - /inspect.custom/g, - 'custom' - , +module.exports'internal/streams/BufferList.js' = - /const \{ inspect \} = require\('util'\);/, + /(?:var|const) (?:{ )Buffer(?: }) = require\('buffer'\)(?:\.Buffer)?;/, ` -const { inspect } = require('util') -const custom = inspect && inspect.custom || 'inspect' +const Buffer = require('safe-buffer').Buffer +const util = require('util') ` - -module.exports'internal/streams/destroy.js' = - errorsTwoLevel - - -module.exports'internal/streams/state.js' = - , errorsTwoLevel - , integerIE11 - - -module.exports'internal/streams/async_iterator.js' = - , errorsTwoLevel - , - /internal\/streams\/end-of-stream/, - './end-of-stream' - - , - /const AsyncIteratorPrototype = Object\.getPrototypeOf\(\n.*Object\.getPrototypeOf\(async function\* \(\) \{\}\).prototype\);/m, - 'const AsyncIteratorPrototype = Object\.getPrototypeOf(function () {})' - + , fixCopyBuffer , - / return\(\)/, - 'Symbol.asyncIterator() { return this },\n return\(\)' - - + /$/, + ` -module.exports'internal/streams/end-of-stream.js' = - , errorsTwoLevel - , - /const \{ once \} = require\('internal\/util'\);/, - `function once(callback) { - let called = false; - return function(...args) { - if (called) return; - called = true; - callback.apply(this, args); - }; -}` +if (util && util.inspect && util.inspect.custom) { + module.exports.prototypeutil.inspect.custom = function () { + const obj = util.inspect({ length: this.length }); + return \`\${this.constructor.name} \${obj}\`; + } +} +` - -module.exports'internal/streams/pipeline.js' = - once - , errorsTwoLevel - , - /require\('internal\/streams\/end-of-stream'\)/, - 'require(\'.\/end-of-stream\')' - - -module.exports'internal/streams/from.js' = - errorsTwoLevel - , - /if \(iterable && iterable\Symbol.asyncIterator\\)/ - , `if (iterable && typeof iterable.next === 'function') { - iterator = iterable - } -else if (iterable && iterableSymbol.asyncIterator)` - +module.exports'internal/streams/destroy.js' = + processNextTickImport + , processNextTickReplacement
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/build/package.json
Added
@@ -0,0 +1,26 @@ +{ + "name": "readable-stream-build", + "version": "0.0.0", + "description": "", + "main": "build.js", + "dependencies": { + "babel-core": "^6.26.0", + "babel-plugin-transform-es2015-arrow-functions": "^6.5.2", + "babel-plugin-transform-es2015-block-scoping": "^6.26.0", + "babel-plugin-transform-es2015-classes": "^6.24.1", + "babel-plugin-transform-es2015-computed-properties": "^6.24.1", + "babel-plugin-transform-es2015-destructuring": "^6.18.0", + "babel-plugin-transform-es2015-for-of": "^6.8.0", + "babel-plugin-transform-es2015-parameters": "^6.24.1", + "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", + "babel-plugin-transform-es2015-spread": "^6.22.0", + "babel-plugin-transform-es2015-template-literals": "^6.8.0", + "bl": "^1.2.1", + "glob": "^7.1.2", + "gunzip-maybe": "^1.4.1", + "hyperquest": "^2.1.3", + "pump": "^3.0.0", + "rimraf": "^2.6.2", + "tar-fs": "^1.16.0" + } +}
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/build/test-replacements.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/build/test-replacements.js
Changed
@@ -12,23 +12,6 @@ require('./common-replacements').bufferStaticMethods , specialForEachReplacment = require('./common-replacements').specialForEachReplacment - , deepStrictEqual = - /util\.isDeepStrictEqual/, - 'require(\'deep-strict-equal\')' - - , tapOk = - /console\.log\('ok'\);/g, - 'require(\'tap\').pass();' - - , catchES7 = - /} catch {/, - '} catch(_e) {' - - , catchES7OpenClose = - /} catch {}/, - '} catch(_e) {}' - - module.exports.all = @@ -55,14 +38,10 @@ , bufferShimFix , bufferStaticMethods - , + , /require\('"assert'"\)/g , 'require(\'assert/\')' - , - /\/\/ Flags: .*/ - , '' - module.exports'test-stream2-basic.js' = @@ -94,29 +73,32 @@ , altIndexOfUseReplacement -module.exports'test-stream-end-paused.js' = - - /console.log\('ok'\);/, - '' - - - module.exports'common.js' = objectKeysDefine , objectKeysReplacement , altForEachImplReplacement , altForEachUseReplacement - , deepStrictEqual - , catchES7 - , catchES7OpenClose - , - /require\('module'\)\.builtinModules\.includes\('worker_threads'\)/, - 'false' - + , - /process.argv.length === 2/, - 'false' + /(exports.mustCall\s\S*)/m + , '$1\n' + + 'if (!util._errnoException) {\n' + + ' var uv;\n' + + ' util._errnoException = function(err, syscall) {\n' + + ' if (util.isUndefined(uv)) try { uv = process.binding(\'uv\'); } catch (e) {}\n' + + ' var errname = uv ? uv.errname(err) : \'\';\n' + + ' var e = new Error(syscall + \' \' + errname);\n' + + ' e.code = errname;\n' + + ' e.errno = errname;\n' + + ' e.syscall = syscall;\n' + + ' return e;\n' + + ' };\n' + + '}\n' + + // for streams2 on node 0.11 + // and dtrace in 0.10 + // and coverage in all , /^( for \(var x in global\) \{|function leakedGlobals\(\) \{)$/m , ' /*<replacement>*/\n' @@ -128,27 +110,27 @@ + ' knownGlobals.push(DTRACE_NET_SOCKET_WRITE);\n' + ' if (global.__coverage__)\n' + ' knownGlobals.push(__coverage__);\n' - + '\'console,clearImmediate,setImmediate,core,__core-js_shared__,Promise,Map,Set,WeakMap,WeakSet,Reflect,System,queueMicrotask,asap,Observable,regeneratorRuntime,_babelPolyfill\'.split(\',\').filter(function (item) { return typeof globalitem !== undefined}).forEach(function (item) {knownGlobals.push(globalitem)})' + + '\'core,__core-js_shared__,Promise,Map,Set,WeakMap,WeakSet,Reflect,System,asap,Observable,regeneratorRuntime,_babelPolyfill\'.split(\',\').filter(function (item) { return typeof globalitem !== undefined}).forEach(function (item) {knownGlobals.push(globalitem)})' + ' /*</replacement>*/\n\n$1' + // for node 0.8 , - /(exports.mustCall\s\S*)/m - , '$1\n' - + 'if (!util._errnoException) {\n' - + ' var uv;\n' - + ' util._errnoException = function(err, syscall) {\n' - + ' if (util.isUndefined(uv)) try { uv = process.binding(\'uv\'); } catch (e) {}\n' - + ' var errname = uv ? uv.errname(err) : \'\';\n' - + ' var e = new Error(syscall + \' \' + errname);\n' - + ' e.code = errname;\n' - + ' e.errno = errname;\n' - + ' e.syscall = syscall;\n' - + ' return e;\n' + /^/ + , '/*<replacement>*/' + + '\nif (!global.setImmediate) {\n' + + ' global.setImmediate = function setImmediate(fn) {\n' + + + ' return setTimeout(fn.bind.apply(fn, arguments), 4);\n' + ' };\n' + '}\n' + + 'if (!global.clearImmediate) {\n' + + ' global.clearImmediate = function clearImmediate(i) {\n' + + ' return clearTimeout(i);\n' + + ' };\n' + + '}\n' + + '/*</replacement>*/\n' - , /^if \(global\.ArrayBuffer\) \{(^\}+)\}$/m , '/*<replacement>*/if (!process.browser) {' @@ -168,7 +150,7 @@ , /^/, `/*<replacement>*/ - require('@babel/polyfill'); + require('babel-polyfill'); var util = require('util'); for (var i in util) exportsi = utili; /*</replacement>*/` @@ -212,10 +194,6 @@ '}).enable();*/' , - /const async_hooks = require\('async_hooks'\)/, - 'var async_hooks = require(\'async_\' + \'hooks\')' -, - /(?:var|const) async_wrap = process\.binding\('async_wrap'\);\n.*(?:var|const) (?:{ )?kCheck(?: })? = async_wrap\.constants(?:\.kCheck)?;/gm, '// const async_wrap = process.binding(\'async_wrap\');\n' + ' // const kCheck = async_wrap.constants.kCheck;' @@ -223,18 +201,6 @@ /async_wrap\.async_hook_fields\kCheck\ \+= 1;/, '// async_wrap.async_hook_fieldskCheck += 1;' -, - - /os\.cpus\(\)/, - 'os.cpus().length === 0 ? { speed: 1000 } : os.cpus()' -, - - /const buildType = process.config.target_defaults.default_configuration;/, - 'const buildType = \'readable-stream\';' -, - - /const hasCrypto = Boolean\(process.versions.openssl\);/, - 'const hasCrypto = true;' @@ -300,6 +266,14 @@ +module.exports'test-stream2-readable-empty-buffer-no-eof.js' = + + `const buf = Buffer(5).fill('x');`, + `const buf = new Buffer(5); + buf.fill('x');` + + + module.exports'test-stream2-unpipe-drain.js' = /^/, @@ -327,60 +301,17 @@ module.exports'test-stream2-readable-from-list.js' = - /require\('internal\/streams\/buffer_list'\)/, - 'require(\'../../lib/internal/streams/buffer_list\')' - , - - /assert\.strictEqual\(\n *util.inspect\(\ list \, \{ compact: false \}\),\n *`\\n *BufferList \{\n *head: \Object\,\n *tail: \Object\,\n *length: 4\n *\}\n *\`\);/m, - 'assert.strictEqual(util.inspect( list , { compact: false }).indexOf(\'BufferList\') > 0, true)' + /require\('internal\/streams\/BufferList'\)/, + 'require(\'../../lib/internal/streams/BufferList\')' module.exports'test-stream-writev.js' = - tapOk, - /console.log\(`# decode=/, - 'require(\'tap\').test(`# decode=' + /'latin1'/g, + `'binary'` - -module.exports'test-stream3-pause-then-read.js' = - tapOk - - -module.exports'test-stream-unshift-read-race.js' = - tapOk - - -module.exports'test-stream2-unpipe-leak.js' = - tapOk - - -module.exports'test-stream2-compatibility.js' = - tapOk - - -module.exports'test-stream-push-strings.js' = - tapOk - - -module.exports'test-stream-unshift-empty-chunk.js' = - tapOk - - -module.exports'test-stream2-pipe-error-once-listener.js' = - tapOk - - -module.exports'test-stream-push-order.js' = - tapOk - - -module.exports'test-stream2-push.js' = - tapOk - - module.exports'test-stream2-readable-empty-buffer-no-eof.js' = - tapOk, /case 3:\n(\s+)setImmediate\(r\.read\.bind\(r, 0\)\);/, 'case 3:\n$1setTimeout(r.read.bind(r, 0), 50);' @@ -388,8 +319,8 @@ module.exports'test-stream-buffer-list.js' = - /require\('internal\/streams\/buffer_list'\);/, - 'require(\'../../lib/internal/streams/buffer_list\');' + /require\('internal\/streams\/BufferList'\);/, + 'require(\'../../lib/internal/streams/BufferList\');' @@ -406,68 +337,3 @@ 'if (process.version.indexOf(\'v0.8\') === 0) { process.exit(0) }\n' - -module.exports'test-stream-readable-flow-recursion.js' = - tapOk, - deepStrictEqual - - -module.exports'test-stream-readable-with-unimplemented-_read.js' = - deepStrictEqual - - -module.exports'test-stream-writable-needdrain-state.js' = - deepStrictEqual - - -module.exports'test-stream-readable-setEncoding-null.js' = - deepStrictEqual - - -module.exports'test-stream-pipeline.js' = - - /require\('http2'\)/g, - '{ createServer() { return { listen() {} } } }' - , - - /assert\.deepStrictEqual\(err, new Error\('kaboom'\)\);/g, - 'assert.strictEqual(err.message, \'kaboom\');' - , - - /cb\(new Error\('kaboom'\)\)/g, - 'process.nextTick(cb, new Error(\'kaboom\'))' - , - - /const \{ promisify \} = require\('util'\);/g, - 'const promisify = require(\'util-promisify\');' - - - -module.exports'test-stream-finished.js' = - - /const \{ promisify \} = require\('util'\);/g, - 'const promisify = require(\'util-promisify\');' - - - -module.exports'test-stream-readable-async-iterators.js' = - - /assert.rejects\(/g, - '(function(f, e) { let success = false; f().then(function() { success = true; throw new Error(\'should not succeed\') }).catch(function(e2) { if (success) { throw e2; } assert.strictEqual(e.message, e2.message); })})(' - , - - /tests\(\).then\(common\.mustCall\(\)\)/, - 'tests().then(common.mustCall(), common.mustNotCall(console.log))' - , - - /const AsyncIteratorPrototype = Object\.getPrototypeOf\(\n.*Object\.getPrototypeOf\(async function\* \(\) \{\}\).prototype\);/m, - 'const AsyncIteratorPrototype = Object\.getPrototypeOf(function () {})' - - - -module.exports'test-readable-from.js' = - - /const \{ once \} = require\('events'\);/ - , 'const once = require(\'events.once\');' - -
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/duplex-browser.js
Added
@@ -0,0 +1,1 @@ +module.exports = require('./lib/_stream_duplex.js');
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/duplex.js
Added
@@ -0,0 +1,1 @@ +module.exports = require('./readable').Duplex
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/examples/CAPSLOCKTYPER.JS -> _service:tar_scm:readable-stream-2.3.6.tar.gz/examples/CAPSLOCKTYPER.JS
Changed
@@ -11,7 +11,7 @@ inherits(MyStream, Transform); MyStream.prototype._transform = function (chunk, outputFn, callback) { - outputFn(Buffer.from(String(chunk).toUpperCase())); + outputFn(new Buffer(String(chunk).toUpperCase())); callback(); };
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/_stream_duplex.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/lib/_stream_duplex.js
Changed
@@ -27,91 +27,89 @@ 'use strict'; /*<replacement>*/ + +var pna = require('process-nextick-args'); +/*</replacement>*/ + +/*<replacement>*/ var objectKeys = Object.keys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ module.exports = Duplex; + +/*<replacement>*/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/*</replacement>*/ + var Readable = require('./_stream_readable'); var Writable = require('./_stream_writable'); -require('inherits')(Duplex, Readable); + +util.inherits(Duplex, Readable); + { - // Allow the keys array to be GC'ed. + // avoid scope creep, the keys array can then be collected var keys = objectKeys(Writable.prototype); for (var v = 0; v < keys.length; v++) { var method = keysv; if (!Duplex.prototypemethod) Duplex.prototypemethod = Writable.prototypemethod; } } + function Duplex(options) { if (!(this instanceof Duplex)) return new Duplex(options); + Readable.call(this, options); Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + this.allowHalfOpen = true; - if (options) { - if (options.readable === false) this.readable = false; - if (options.writable === false) this.writable = false; - if (options.allowHalfOpen === false) { - this.allowHalfOpen = false; - this.once('end', onend); - } - } + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); } + Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function get() { + get: function () { return this._writableState.highWaterMark; } }); -Object.defineProperty(Duplex.prototype, 'writableBuffer', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState && this._writableState.getBuffer(); - } -}); -Object.defineProperty(Duplex.prototype, 'writableLength', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState.length; - } -}); // the no-half-open enforcer function onend() { - // If the writable side ended, then we're ok. - if (this._writableState.ended) return; + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; // no more data can be written. // But allow more writes to happen in this tick. - process.nextTick(onEndNT, this); + pna.nextTick(onEndNT, this); } + function onEndNT(self) { self.end(); } + Object.defineProperty(Duplex.prototype, 'destroyed', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { + get: function () { if (this._readableState === undefined || this._writableState === undefined) { return false; } return this._readableState.destroyed && this._writableState.destroyed; }, - set: function set(value) { + set: function (value) { // we ignore the value if the stream // has not been initialized yet if (this._readableState === undefined || this._writableState === undefined) { @@ -123,4 +121,11 @@ this._readableState.destroyed = value; this._writableState.destroyed = value; } -}); \ No newline at end of file +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + pna.nextTick(cb, err); +}; \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/_stream_passthrough.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/lib/_stream_passthrough.js
Changed
@@ -26,12 +26,22 @@ 'use strict'; module.exports = PassThrough; + var Transform = require('./_stream_transform'); -require('inherits')(PassThrough, Transform); + +/*<replacement>*/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/*</replacement>*/ + +util.inherits(PassThrough, Transform); + function PassThrough(options) { if (!(this instanceof PassThrough)) return new PassThrough(options); + Transform.call(this, options); } + PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/_stream_readable.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/lib/_stream_readable.js
Changed
@@ -21,9 +21,18 @@ 'use strict'; +/*<replacement>*/ + +var pna = require('process-nextick-args'); +/*</replacement>*/ + module.exports = Readable; /*<replacement>*/ +var isArray = require('isarray'); +/*</replacement>*/ + +/*<replacement>*/ var Duplex; /*</replacement>*/ @@ -31,7 +40,8 @@ /*<replacement>*/ var EE = require('events').EventEmitter; -var EElistenerCount = function EElistenerCount(emitter, type) { + +var EElistenerCount = function (emitter, type) { return emitter.listeners(type).length; }; /*</replacement>*/ @@ -40,8 +50,10 @@ var Stream = require('./internal/streams/stream'); /*</replacement>*/ -var Buffer = require('buffer').Buffer; -var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {}; +/*<replacement>*/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } @@ -49,33 +61,31 @@ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } +/*</replacement>*/ + +/*<replacement>*/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/*</replacement>*/ + /*<replacement>*/ var debugUtil = require('util'); -var debug; +var debug = void 0; if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); } else { - debug = function debug() {}; + debug = function () {}; } /*</replacement>*/ -var BufferList = require('./internal/streams/buffer_list'); +var BufferList = require('./internal/streams/BufferList'); var destroyImpl = require('./internal/streams/destroy'); -var _require = require('./internal/streams/state'), - getHighWaterMark = _require.getHighWaterMark; -var _require$codes = require('../errors').codes, - ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, - ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, - ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, - ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; - -// Lazy loaded to improve the startup performance. var StringDecoder; -var createReadableStreamAsyncIterator; -var from; -require('inherits')(Readable, Stream); -var errorOrDestroy = destroyImpl.errorOrDestroy; + +util.inherits(Readable, Stream); + var kProxyEvents = 'error', 'close', 'destroy', 'pause', 'resume'; + function prependListener(emitter, event, fn) { // Sadly this is not cacheable as some libraries bundle their own // event emitter implementation with them. @@ -85,10 +95,12 @@ // userland ones. NEVER DO THIS. This is here only because this code needs // to continue to work with older versions of Node.js that do not include // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._eventsevent) emitter.on(event, fn);else if (Array.isArray(emitter._eventsevent)) emitter._eventsevent.unshift(fn);else emitter._eventsevent = fn, emitter._eventsevent; + if (!emitter._events || !emitter._eventsevent) emitter.on(event, fn);else if (isArray(emitter._eventsevent)) emitter._eventsevent.unshift(fn);else emitter._eventsevent = fn, emitter._eventsevent; } -function ReadableState(options, stream, isDuplex) { + +function ReadableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share @@ -96,16 +108,24 @@ // However, some cases require setting options to different // values for the readable and the writable sides of the duplex stream. // These options can be provided separately as readableXXX and writableXXX. - if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; + var isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to // make all the buffer merging and length checks go away this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever" - this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); // A linked list is used to store data chunks instead of an array because the // linked list can remove elements from the beginning faster than @@ -131,13 +151,6 @@ this.emittedReadable = false; this.readableListening = false; this.resumeScheduled = false; - this.paused = true; - - // Should close be emitted on destroy. Defaults to true. - this.emitClose = options.emitClose !== false; - - // Should .destroy() be called after 'end' (and potentially 'finish') - this.autoDestroy = !!options.autoDestroy; // has it been destroyed this.destroyed = false; @@ -152,6 +165,7 @@ // if true, a maybeReadMore has been scheduled this.readingMore = false; + this.decoder = null; this.encoding = null; if (options.encoding) { @@ -160,35 +174,34 @@ this.encoding = options.encoding; } } + function Readable(options) { Duplex = Duplex || require('./_stream_duplex'); + if (!(this instanceof Readable)) return new Readable(options); - // Checking for a Stream.Duplex instance is faster here instead of inside - // the ReadableState constructor, at least with V8 6.5 - var isDuplex = this instanceof Duplex; - this._readableState = new ReadableState(options, this, isDuplex); + this._readableState = new ReadableState(options, this); // legacy this.readable = true; + if (options) { if (typeof options.read === 'function') this._read = options.read; + if (typeof options.destroy === 'function') this._destroy = options.destroy; } + Stream.call(this); } + Object.defineProperty(Readable.prototype, 'destroyed', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { + get: function () { if (this._readableState === undefined) { return false; } return this._readableState.destroyed; }, - set: function set(value) { + set: function (value) { // we ignore the value if the stream // has not been initialized yet if (!this._readableState) { @@ -200,9 +213,11 @@ this._readableState.destroyed = value; } }); + Readable.prototype.destroy = destroyImpl.destroy; Readable.prototype._undestroy = destroyImpl.undestroy; Readable.prototype._destroy = function (err, cb) { + this.push(null); cb(err); }; @@ -213,6 +228,7 @@ Readable.prototype.push = function (chunk, encoding) { var state = this._readableState; var skipChunkCheck; + if (!state.objectMode) { if (typeof chunk === 'string') { encoding = encoding || state.defaultEncoding; @@ -225,6 +241,7 @@ } else { skipChunkCheck = true; } + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); }; @@ -232,8 +249,8 @@ Readable.prototype.unshift = function (chunk) { return readableAddChunk(this, chunk, null, true, false); }; + function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { - debug('readableAddChunk', chunk); var state = stream._readableState; if (chunk === null) { state.reading = false; @@ -242,17 +259,16 @@ var er; if (!skipChunkCheck) er = chunkInvalid(state, chunk); if (er) { - errorOrDestroy(stream, er); + stream.emit('error', er); } else if (state.objectMode || chunk && chunk.length > 0) { if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { chunk = _uint8ArrayToBuffer(chunk); } + if (addToFront) { - if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); } else if (state.ended) { - errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); - } else if (state.destroyed) { - return false; + stream.emit('error', new Error('stream.push() after EOF')); } else { state.reading = false; if (state.decoder && !encoding) { @@ -264,34 +280,45 @@ } } else if (!addToFront) { state.reading = false; - maybeReadMore(stream, state); } } - // We can push more data if we are below the highWaterMark. - // Also, if we have no data yet, we can stand some more bytes. - // This is to work around cases where hwm=0, such as the repl. - return !state.ended && (state.length < state.highWaterMark || state.length === 0); + return needMoreData(state); } + function addChunk(stream, state, chunk, addToFront) { if (state.flowing && state.length === 0 && !state.sync) { - state.awaitDrain = 0; stream.emit('data', chunk); + stream.read(0); } else { // update the buffer info. state.length += state.objectMode ? 1 : chunk.length; if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + if (state.needReadable) emitReadable(stream); } maybeReadMore(stream, state); } + function chunkInvalid(state, chunk) { var er; if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new ERR_INVALID_ARG_TYPE('chunk', 'string', 'Buffer', 'Uint8Array', chunk); + er = new TypeError('Invalid non-string/buffer chunk'); } return er; } + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + Readable.prototype.isPaused = function () { return this._readableState.flowing === false; }; @@ -299,29 +326,15 @@ // backwards compatibility. Readable.prototype.setEncoding = function (enc) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - var decoder = new StringDecoder(enc); - this._readableState.decoder = decoder; - // If setEncoding(null), decoder.encoding equals utf8 - this._readableState.encoding = this._readableState.decoder.encoding; - - // Iterate over current buffer to convert already stored Buffers: - var p = this._readableState.buffer.head; - var content = ''; - while (p !== null) { - content += decoder.write(p.data); - p = p.next; - } - this._readableState.buffer.clear(); - if (content !== '') this._readableState.buffer.push(content); - this._readableState.length = content.length; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; return this; }; -// Don't raise the hwm > 1GB -var MAX_HWM = 0x40000000; +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; function computeNewHighWaterMark(n) { if (n >= MAX_HWM) { - // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. n = MAX_HWM; } else { // Get the next highest power of 2 to prevent increasing hwm excessively in @@ -363,16 +376,18 @@ n = parseInt(n, 10); var state = this._readableState; var nOrig = n; + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we // already have a bunch of data in the buffer, then just trigger // the 'readable' event and move on. - if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { debug('read: emitReadable', state.length, state.ended); if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); return null; } + n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. @@ -431,15 +446,17 @@ // and we need to re-evaluate how much data we can return to the user. if (!state.reading) n = howMuchToRead(nOrig, state); } + var ret; if (n > 0) ret = fromList(n, state);else ret = null; + if (ret === null) { - state.needReadable = state.length <= state.highWaterMark; + state.needReadable = true; n = 0; } else { state.length -= n; - state.awaitDrain = 0; } + if (state.length === 0) { // If we have nothing in the buffer, then we want to know // as soon as we *do* get something into the buffer. @@ -448,11 +465,13 @@ // If we tried to read() past the EOF, then emit end on the next tick. if (nOrig !== n && state.ended) endReadable(this); } + if (ret !== null) this.emit('data', ret); + return ret; }; + function onEofChunk(stream, state) { - debug('onEofChunk'); if (state.ended) return; if (state.decoder) { var chunk = state.decoder.end(); @@ -462,19 +481,9 @@ } } state.ended = true; - if (state.sync) { - // if we are sync, wait until next tick to emit the data. - // Otherwise we risk emitting data in the flow() - // the readable code triggers during a read() call - emitReadable(stream); - } else { - // emit 'readable' now to make sure it gets picked up. - state.needReadable = false; - if (!state.emittedReadable) { - state.emittedReadable = true; - emitReadable_(stream); - } - } + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); } // Don't emit readable right away in sync mode, because this can trigger @@ -482,29 +491,17 @@ // a nextTick recursion warning, but that's not so bad. function emitReadable(stream) { var state = stream._readableState; - debug('emitReadable', state.needReadable, state.emittedReadable); state.needReadable = false; if (!state.emittedReadable) { debug('emitReadable', state.flowing); state.emittedReadable = true; - process.nextTick(emitReadable_, stream); + if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); } } -function emitReadable_(stream) { - var state = stream._readableState; - debug('emitReadable_', state.destroyed, state.length, state.ended); - if (!state.destroyed && (state.length || state.ended)) { - stream.emit('readable'); - state.emittedReadable = false; - } - // The stream needs another readable event if - // 1. It is not flowing, as the flow mechanism will take - // care of it. - // 2. It is not ended. - // 3. It is below the highWaterMark, so we can schedule - // another readable later. - state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); flow(stream); } @@ -517,40 +514,18 @@ function maybeReadMore(stream, state) { if (!state.readingMore) { state.readingMore = true; - process.nextTick(maybeReadMore_, stream, state); + pna.nextTick(maybeReadMore_, stream, state); } } + function maybeReadMore_(stream, state) { - // Attempt to read more data if we should. - // - // The conditions for reading more data are (one of): - // - Not enough data buffered (state.length < state.highWaterMark). The loop - // is responsible for filling the buffer with enough data if such data - // is available. If highWaterMark is 0 and we are not in the flowing mode - // we should _not_ attempt to buffer any extra data. We'll get more data - // when the stream consumer calls read() instead. - // - No data in the buffer, and the stream is in flowing mode. In this mode - // the loop below is responsible for ensuring read() is called. Failing to - // call read here would abort the flow and there's no other mechanism for - // continuing the flow if the stream consumer has just subscribed to the - // 'data' event. - // - // In addition to the above conditions to keep reading data, the following - // conditions prevent the data from being read: - // - The stream has ended (state.ended). - // - There is already a pending 'read' operation (state.reading). This is a - // case where the the stream has called the implementation defined _read() - // method, but they are processing the call asynchronously and have _not_ - // called push() with new data. In this case we skip performing more - // read()s. The execution ends in this method again after the _read() ends - // up calling push() with more data. - while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { - var len = state.length; + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { debug('maybeReadMore read 0'); stream.read(0); if (len === state.length) // didn't get any data, stop spinning. - break; + break;else len = state.length; } state.readingMore = false; } @@ -560,11 +535,13 @@ // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. Readable.prototype._read = function (n) { - errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); + this.emit('error', new Error('_read() is not implemented')); }; + Readable.prototype.pipe = function (dest, pipeOpts) { var src = this; var state = this._readableState; + switch (state.pipesCount) { case 0: state.pipes = dest; @@ -578,9 +555,12 @@ } state.pipesCount += 1; debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); + if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + dest.on('unpipe', onunpipe); function onunpipe(readable, unpipeInfo) { debug('onunpipe'); @@ -591,6 +571,7 @@ } } } + function onend() { debug('onend'); dest.end(); @@ -602,6 +583,7 @@ // too slow. var ondrain = pipeOnDrain(src); dest.on('drain', ondrain); + var cleanedUp = false; function cleanup() { debug('cleanup'); @@ -614,6 +596,7 @@ src.removeListener('end', onend); src.removeListener('end', unpipe); src.removeListener('data', ondata); + cleanedUp = true; // if the reader is waiting for a drain event from this @@ -623,19 +606,26 @@ // If we don't know, then assume that we are waiting for one. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; src.on('data', ondata); function ondata(chunk) { debug('ondata'); + increasedAwaitDrain = false; var ret = dest.write(chunk); - debug('dest.write', ret); - if (ret === false) { + if (false === ret && !increasedAwaitDrain) { // If the user unpiped during `dest.write()`, it is possible // to get stuck in a permanently paused state if that write // also returned false. // => Check whether `dest` is still a piping destination. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', state.awaitDrain); - state.awaitDrain++; + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; } src.pause(); } @@ -647,7 +637,7 @@ debug('onerror', er); unpipe(); dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); } // Make sure our error handler is attached before userland ones. @@ -665,6 +655,7 @@ unpipe(); } dest.once('finish', onfinish); + function unpipe() { debug('unpipe'); src.unpipe(dest); @@ -678,10 +669,12 @@ debug('pipe resume'); src.resume(); } + return dest; }; + function pipeOnDrain(src) { - return function pipeOnDrainFunctionResult() { + return function () { var state = src._readableState; debug('pipeOnDrain', state.awaitDrain); if (state.awaitDrain) state.awaitDrain--; @@ -691,11 +684,10 @@ } }; } + Readable.prototype.unpipe = function (dest) { var state = this._readableState; - var unpipeInfo = { - hasUnpiped: false - }; + var unpipeInfo = { hasUnpiped: false }; // if we're not piping anywhere, then do nothing. if (state.pipesCount === 0) return this; @@ -704,6 +696,7 @@ if (state.pipesCount === 1) { // passed in one, but it's not the right one. if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; // got a match. @@ -723,19 +716,22 @@ state.pipes = null; state.pipesCount = 0; state.flowing = false; - for (var i = 0; i < len; i++) destsi.emit('unpipe', this, { - hasUnpiped: false - }); - return this; + + for (var i = 0; i < len; i++) { + destsi.emit('unpipe', this, unpipeInfo); + }return this; } // try to find the right one. var index = indexOf(state.pipes, dest); if (index === -1) return this; + state.pipes.splice(index, 1); state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes0; + dest.emit('unpipe', this, unpipeInfo); + return this; }; @@ -743,69 +739,27 @@ // Ensure readable listeners eventually get something Readable.prototype.on = function (ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); - var state = this._readableState; - if (ev === 'data') { - // update readableListening so that resume() may be a no-op - // a few lines down. This is needed to support once('readable'). - state.readableListening = this.listenerCount('readable') > 0; - // Try start flowing on next tick if stream isn't explicitly paused - if (state.flowing !== false) this.resume(); + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); } else if (ev === 'readable') { + var state = this._readableState; if (!state.endEmitted && !state.readableListening) { state.readableListening = state.needReadable = true; - state.flowing = false; state.emittedReadable = false; - debug('on readable', state.length, state.reading); - if (state.length) { + if (!state.reading) { + pna.nextTick(nReadingNextTick, this); + } else if (state.length) { emitReadable(this); - } else if (!state.reading) { - process.nextTick(nReadingNextTick, this); } } } + return res; }; Readable.prototype.addListener = Readable.prototype.on; -Readable.prototype.removeListener = function (ev, fn) { - var res = Stream.prototype.removeListener.call(this, ev, fn); - if (ev === 'readable') { - // We need to check if there is someone still listening to - // readable and reset the state. However this needs to happen - // after readable has been emitted but before I/O (nextTick) to - // support once('readable', fn) cycles. This means that calling - // resume within the same tick will have no - // effect. - process.nextTick(updateReadableListening, this); - } - return res; -}; -Readable.prototype.removeAllListeners = function (ev) { - var res = Stream.prototype.removeAllListeners.apply(this, arguments); - if (ev === 'readable' || ev === undefined) { - // We need to check if there is someone still listening to - // readable and reset the state. However this needs to happen - // after readable has been emitted but before I/O (nextTick) to - // support once('readable', fn) cycles. This means that calling - // resume within the same tick will have no - // effect. - process.nextTick(updateReadableListening, this); - } - return res; -}; -function updateReadableListening(self) { - var state = self._readableState; - state.readableListening = self.listenerCount('readable') > 0; - if (state.resumeScheduled && !state.paused) { - // flowing needs to be set to true now, otherwise - // the upcoming resume will not flow. - state.flowing = true; - // crude way to check if we should resume - } else if (self.listenerCount('data') > 0) { - self.resume(); - } -} function nReadingNextTick(self) { debug('readable nexttick read 0'); self.read(0); @@ -817,45 +771,46 @@ var state = this._readableState; if (!state.flowing) { debug('resume'); - // we flow only if there is no one listening - // for readable, but we still have to call - // resume() - state.flowing = !state.readableListening; + state.flowing = true; resume(this, state); } - state.paused = false; return this; }; + function resume(stream, state) { if (!state.resumeScheduled) { state.resumeScheduled = true; - process.nextTick(resume_, stream, state); + pna.nextTick(resume_, stream, state); } } + function resume_(stream, state) { - debug('resume', state.reading); if (!state.reading) { + debug('resume read 0'); stream.read(0); } + state.resumeScheduled = false; + state.awaitDrain = 0; stream.emit('resume'); flow(stream); if (state.flowing && !state.reading) stream.read(0); } + Readable.prototype.pause = function () { debug('call pause flowing=%j', this._readableState.flowing); - if (this._readableState.flowing !== false) { + if (false !== this._readableState.flowing) { debug('pause'); this._readableState.flowing = false; this.emit('pause'); } - this._readableState.paused = true; return this; }; + function flow(stream) { var state = stream._readableState; debug('flow', state.flowing); - while (state.flowing && stream.read() !== null); + while (state.flowing && stream.read() !== null) {} } // wrap an old-style stream as the async data source. @@ -863,22 +818,27 @@ // It is an ugly unfortunate mess of history. Readable.prototype.wrap = function (stream) { var _this = this; + var state = this._readableState; var paused = false; + stream.on('end', function () { debug('wrapped end'); if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) _this.push(chunk); } + _this.push(null); }); + stream.on('data', function (chunk) { debug('wrapped data'); if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + var ret = _this.push(chunk); if (!ret) { paused = true; @@ -890,8 +850,8 @@ // important when wrapping filters and duplexes. for (var i in stream) { if (thisi === undefined && typeof streami === 'function') { - thisi = function methodWrap(method) { - return function methodWrapReturnFunction() { + thisi = function (method) { + return function () { return streammethod.apply(stream, arguments); }; }(i); @@ -912,60 +872,22 @@ stream.resume(); } }; + return this; }; -if (typeof Symbol === 'function') { - Readable.prototypeSymbol.asyncIterator = function () { - if (createReadableStreamAsyncIterator === undefined) { - createReadableStreamAsyncIterator = require('./internal/streams/async_iterator'); - } - return createReadableStreamAsyncIterator(this); - }; -} + Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function get() { + get: function () { return this._readableState.highWaterMark; } }); -Object.defineProperty(Readable.prototype, 'readableBuffer', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._readableState && this._readableState.buffer; - } -}); -Object.defineProperty(Readable.prototype, 'readableFlowing', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._readableState.flowing; - }, - set: function set(state) { - if (this._readableState) { - this._readableState.flowing = state; - } - } -}); // exposed for testing purposes only. Readable._fromList = fromList; -Object.defineProperty(Readable.prototype, 'readableLength', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._readableState.length; - } -}); // Pluck off n bytes from an array of buffers. // Length is the combined lengths of all the buffers in the list. @@ -974,51 +896,121 @@ function fromList(n, state) { // nothing buffered if (state.length === 0) return null; + var ret; if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); + 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); state.buffer.clear(); } else { // read part of list - ret = state.buffer.consume(n, state.decoder); + ret = fromListPartial(n, state.buffer, state.decoder); } + return ret; } + +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} + +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + function endReadable(stream) { var state = stream._readableState; - debug('endReadable', state.endEmitted); + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + if (!state.endEmitted) { state.ended = true; - process.nextTick(endReadableNT, state, stream); + pna.nextTick(endReadableNT, state, stream); } } -function endReadableNT(state, stream) { - debug('endReadableNT', state.endEmitted, state.length); +function endReadableNT(state, stream) { // Check that we didn't get one last unshift. if (!state.endEmitted && state.length === 0) { state.endEmitted = true; stream.readable = false; stream.emit('end'); - if (state.autoDestroy) { - // In case of duplex streams we need a way to detect - // if the writable side is ready for autoDestroy as well - var wState = stream._writableState; - if (!wState || wState.autoDestroy && wState.finished) { - stream.destroy(); - } - } } } -if (typeof Symbol === 'function') { - Readable.from = function (iterable, opts) { - if (from === undefined) { - from = require('./internal/streams/from'); - } - return from(Readable, iterable, opts); - }; -} + function indexOf(xs, x) { for (var i = 0, l = xs.length; i < l; i++) { if (xsi === x) return i;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/_stream_transform.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/lib/_stream_transform.js
Changed
@@ -64,35 +64,46 @@ 'use strict'; module.exports = Transform; -var _require$codes = require('../errors').codes, - ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, - ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, - ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, - ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; + var Duplex = require('./_stream_duplex'); -require('inherits')(Transform, Duplex); + +/*<replacement>*/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/*</replacement>*/ + +util.inherits(Transform, Duplex); + function afterTransform(er, data) { var ts = this._transformState; ts.transforming = false; + var cb = ts.writecb; - if (cb === null) { - return this.emit('error', new ERR_MULTIPLE_CALLBACK()); + + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); } + ts.writechunk = null; ts.writecb = null; - if (data != null) - // single equals check for both `null` and `undefined` + + if (data != null) // single equals check for both `null` and `undefined` this.push(data); + cb(er); + var rs = this._readableState; rs.reading = false; if (rs.needReadable || rs.length < rs.highWaterMark) { this._read(rs.highWaterMark); } } + function Transform(options) { if (!(this instanceof Transform)) return new Transform(options); + Duplex.call(this, options); + this._transformState = { afterTransform: afterTransform.bind(this), needTransform: false, @@ -109,17 +120,21 @@ // that Readable wants before the first _read call, so unset the // sync guard flag. this._readableState.sync = false; + if (options) { if (typeof options.transform === 'function') this._transform = options.transform; + if (typeof options.flush === 'function') this._flush = options.flush; } // When the writable side finishes, then flush out anything remaining. this.on('prefinish', prefinish); } + function prefinish() { var _this = this; - if (typeof this._flush === 'function' && !this._readableState.destroyed) { + + if (typeof this._flush === 'function') { this._flush(function (er, data) { done(_this, er, data); }); @@ -127,6 +142,7 @@ done(this, null, null); } } + Transform.prototype.push = function (chunk, encoding) { this._transformState.needTransform = false; return Duplex.prototype.push.call(this, chunk, encoding); @@ -143,8 +159,9 @@ // an error, then that'll put the hurt on the whole operation. If you // never call cb(), then you'll never get another chunk. Transform.prototype._transform = function (chunk, encoding, cb) { - cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); + throw new Error('_transform() is not implemented'); }; + Transform.prototype._write = function (chunk, encoding, cb) { var ts = this._transformState; ts.writecb = cb; @@ -161,7 +178,8 @@ // That we got here means that the readable side wants more data. Transform.prototype._read = function (n) { var ts = this._transformState; - if (ts.writechunk !== null && !ts.transforming) { + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { ts.transforming = true; this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); } else { @@ -170,21 +188,27 @@ ts.needTransform = true; } }; + Transform.prototype._destroy = function (err, cb) { + var _this2 = this; + Duplex.prototype._destroy.call(this, err, function (err2) { cb(err2); + _this2.emit('close'); }); }; + function done(stream, er, data) { if (er) return stream.emit('error', er); - if (data != null) - // single equals check for both `null` and `undefined` + + if (data != null) // single equals check for both `null` and `undefined` stream.push(data); - // TODO(BridgeAR): Write a test for these two error cases // if there's nothing in the write buffer, then that means // that nothing more will ever be provided - if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); - if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); + + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + return stream.push(null); } \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/_stream_writable.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/lib/_stream_writable.js
Changed
@@ -25,6 +25,11 @@ 'use strict'; +/*<replacement>*/ + +var pna = require('process-nextick-args'); +/*</replacement>*/ + module.exports = Writable; /* <replacement> */ @@ -39,6 +44,7 @@ // there will be only 2 of these for each stream function CorkedRequest(state) { var _this = this; + this.next = null; this.entry = null; this.finish = function () { @@ -48,12 +54,21 @@ /* </replacement> */ /*<replacement>*/ +var asyncWrite = !process.browser && 'v0.10', 'v0.9.'.indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/*</replacement>*/ + +/*<replacement>*/ var Duplex; /*</replacement>*/ Writable.WritableState = WritableState; /*<replacement>*/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/*</replacement>*/ + +/*<replacement>*/ var internalUtil = { deprecate: require('util-deprecate') }; @@ -63,49 +78,54 @@ var Stream = require('./internal/streams/stream'); /*</replacement>*/ -var Buffer = require('buffer').Buffer; -var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {}; +/*<replacement>*/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } + +/*</replacement>*/ + var destroyImpl = require('./internal/streams/destroy'); -var _require = require('./internal/streams/state'), - getHighWaterMark = _require.getHighWaterMark; -var _require$codes = require('../errors').codes, - ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, - ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, - ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, - ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, - ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, - ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, - ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, - ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; -var errorOrDestroy = destroyImpl.errorOrDestroy; -require('inherits')(Writable, Stream); + +util.inherits(Writable, Stream); + function nop() {} -function WritableState(options, stream, isDuplex) { + +function WritableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream, - // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. - if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream // contains buffers or objects. this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false // Note: 0 is a valid value, means that we always return false if // the entire buffer is not flushed immediately on write() - this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); // if _final has been called this.finalCalled = false; @@ -165,6 +185,7 @@ // the amount that is being written when _write is called. this.writelen = 0; + this.bufferedRequest = null; this.lastBufferedRequest = null; @@ -179,12 +200,6 @@ // True if the error was already emitted and should not be thrown again this.errorEmitted = false; - // Should close be emitted on destroy. Defaults to true. - this.emitClose = options.emitClose !== false; - - // Should .destroy() be called after 'finish' (and potentially 'end') - this.autoDestroy = !!options.autoDestroy; - // count buffered requests this.bufferedRequestCount = 0; @@ -192,6 +207,7 @@ // one allocated and free to use, and we maintain at most two this.corkedRequestsFree = new CorkedRequest(this); } + WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; var out = ; @@ -201,10 +217,11 @@ } return out; }; + (function () { try { Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function writableStateBufferGetter() { + get: internalUtil.deprecate(function () { return this.getBuffer(); }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') }); @@ -217,17 +234,19 @@ if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototypeSymbol.hasInstance === 'function') { realHasInstance = Function.prototypeSymbol.hasInstance; Object.defineProperty(Writable, Symbol.hasInstance, { - value: function value(object) { + value: function (object) { if (realHasInstance.call(this, object)) return true; if (this !== Writable) return false; + return object && object._writableState instanceof WritableState; } }); } else { - realHasInstance = function realHasInstance(object) { + realHasInstance = function (object) { return object instanceof this; }; } + function Writable(options) { Duplex = Duplex || require('./_stream_duplex'); @@ -238,109 +257,123 @@ // Trying to use the custom `instanceof` for Writable here will also break the // Node.js LazyTransform implementation, which has a non-trivial getter for // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } - // Checking for a Stream.Duplex instance is faster here instead of inside - // the WritableState constructor, at least with V8 6.5 - var isDuplex = this instanceof Duplex; - if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); - this._writableState = new WritableState(options, this, isDuplex); + this._writableState = new WritableState(options, this); // legacy. this.writable = true; + if (options) { if (typeof options.write === 'function') this._write = options.write; + if (typeof options.writev === 'function') this._writev = options.writev; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + if (typeof options.final === 'function') this._final = options.final; } + Stream.call(this); } // Otherwise people can pipe Writable streams, which is just wrong. Writable.prototype.pipe = function () { - errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); + this.emit('error', new Error('Cannot pipe, not readable')); }; + function writeAfterEnd(stream, cb) { - var er = new ERR_STREAM_WRITE_AFTER_END(); + var er = new Error('write after end'); // TODO: defer error events consistently everywhere, not just the cb - errorOrDestroy(stream, er); - process.nextTick(cb, er); + stream.emit('error', er); + pna.nextTick(cb, er); } // Checks that a user-supplied chunk is valid, especially for the particular // mode the stream is in. Currently this means that `null` is never accepted // and undefined/non-string values are only allowed in object mode. function validChunk(stream, state, chunk, cb) { - var er; + var valid = true; + var er = false; + if (chunk === null) { - er = new ERR_STREAM_NULL_VALUES(); - } else if (typeof chunk !== 'string' && !state.objectMode) { - er = new ERR_INVALID_ARG_TYPE('chunk', 'string', 'Buffer', chunk); + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); } if (er) { - errorOrDestroy(stream, er); - process.nextTick(cb, er); - return false; + stream.emit('error', er); + pna.nextTick(cb, er); + valid = false; } - return true; + return valid; } + Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; var isBuf = !state.objectMode && _isUint8Array(chunk); + if (isBuf && !Buffer.isBuffer(chunk)) { chunk = _uint8ArrayToBuffer(chunk); } + if (typeof encoding === 'function') { cb = encoding; encoding = null; } + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + if (typeof cb !== 'function') cb = nop; - if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } + return ret; }; + Writable.prototype.cork = function () { - this._writableState.corked++; + var state = this._writableState; + + state.corked++; }; + Writable.prototype.uncork = function () { var state = this._writableState; + if (state.corked) { state.corked--; - if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } }; + Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { // node::ParseEncoding() requires lower case. if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!('hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'.indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); + if (!('hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'.indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); this._writableState.defaultEncoding = encoding; return this; }; -Object.defineProperty(Writable.prototype, 'writableBuffer', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState && this._writableState.getBuffer(); - } -}); + function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { chunk = Buffer.from(chunk, encoding); } return chunk; } + Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function get() { + get: function () { return this._writableState.highWaterMark; } }); @@ -358,10 +391,13 @@ } } var len = state.objectMode ? 1 : chunk.length; + state.length += len; + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. if (!ret) state.needDrain = true; + if (state.writing || state.corked) { var last = state.lastBufferedRequest; state.lastBufferedRequest = { @@ -380,63 +416,75 @@ } else { doWrite(stream, state, false, len, chunk, encoding, cb); } + return ret; } + function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writelen = len; state.writecb = cb; state.writing = true; state.sync = true; - if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); state.sync = false; } + function onwriteError(stream, state, sync, er, cb) { --state.pendingcb; + if (sync) { // defer the callback if we are being called synchronously // to avoid piling up things on the stack - process.nextTick(cb, er); + pna.nextTick(cb, er); // this can emit finish, and it will always happen // after error - process.nextTick(finishMaybe, stream, state); + pna.nextTick(finishMaybe, stream, state); stream._writableState.errorEmitted = true; - errorOrDestroy(stream, er); + stream.emit('error', er); } else { // the caller expect this to happen before if // it is async cb(er); stream._writableState.errorEmitted = true; - errorOrDestroy(stream, er); + stream.emit('error', er); // this can emit finish, but finish must // always follow error finishMaybe(stream, state); } } + function onwriteStateUpdate(state) { state.writing = false; state.writecb = null; state.length -= state.writelen; state.writelen = 0; } + function onwrite(stream, er) { var state = stream._writableState; var sync = state.sync; var cb = state.writecb; - if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); + onwriteStateUpdate(state); + if (er) onwriteError(stream, state, sync, er, cb);else { // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state) || stream.destroyed; + var finished = needFinish(state); + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { clearBuffer(stream, state); } + if (sync) { - process.nextTick(afterWrite, stream, state, finished, cb); + /*<replacement>*/ + asyncWrite(afterWrite, stream, state, finished, cb); + /*</replacement>*/ } else { afterWrite(stream, state, finished, cb); } } } + function afterWrite(stream, state, finished, cb) { if (!finished) onwriteDrain(stream, state); state.pendingcb--; @@ -458,12 +506,14 @@ function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; + if (stream._writev && entry && entry.next) { // Fast case, write everything using _writev() var l = state.bufferedRequestCount; var buffer = new Array(l); var holder = state.corkedRequestsFree; holder.entry = entry; + var count = 0; var allBuffers = true; while (entry) { @@ -473,6 +523,7 @@ count += 1; } buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time @@ -493,6 +544,7 @@ var encoding = entry.encoding; var cb = entry.callback; var len = state.objectMode ? 1 : chunk.length; + doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; state.bufferedRequestCount--; @@ -504,17 +556,23 @@ break; } } + if (entry === null) state.lastBufferedRequest = null; } + state.bufferedRequest = entry; state.bufferProcessing = false; } + Writable.prototype._write = function (chunk, encoding, cb) { - cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); + cb(new Error('_write() is not implemented')); }; + Writable.prototype._writev = null; + Writable.prototype.end = function (chunk, encoding, cb) { var state = this._writableState; + if (typeof chunk === 'function') { cb = chunk; chunk = null; @@ -523,6 +581,7 @@ cb = encoding; encoding = null; } + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks @@ -532,18 +591,9 @@ } // ignore unnecessary end() calls. - if (!state.ending) endWritable(this, state, cb); - return this; + if (!state.ending && !state.finished) endWritable(this, state, cb); }; -Object.defineProperty(Writable.prototype, 'writableLength', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState.length; - } -}); + function needFinish(state) { return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } @@ -551,7 +601,7 @@ stream._final(function (err) { state.pendingcb--; if (err) { - errorOrDestroy(stream, err); + stream.emit('error', err); } state.prefinished = true; stream.emit('prefinish'); @@ -560,16 +610,17 @@ } function prefinish(stream, state) { if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function' && !state.destroyed) { + if (typeof stream._final === 'function') { state.pendingcb++; state.finalCalled = true; - process.nextTick(callFinal, stream, state); + pna.nextTick(callFinal, stream, state); } else { state.prefinished = true; stream.emit('prefinish'); } } } + function finishMaybe(stream, state) { var need = needFinish(state); if (need) { @@ -577,27 +628,21 @@ if (state.pendingcb === 0) { state.finished = true; stream.emit('finish'); - if (state.autoDestroy) { - // In case of duplex streams we need a way to detect - // if the readable side is ready for autoDestroy as well - var rState = stream._readableState; - if (!rState || rState.autoDestroy && rState.endEmitted) { - stream.destroy(); - } - } } } return need; } + function endWritable(stream, state, cb) { state.ending = true; finishMaybe(stream, state); if (cb) { - if (state.finished) process.nextTick(cb);else stream.once('finish', cb); + if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); } state.ended = true; stream.writable = false; } + function onCorkedFinish(corkReq, state, err) { var entry = corkReq.entry; corkReq.entry = null; @@ -607,22 +652,21 @@ cb(err); entry = entry.next; } - - // reuse the free corkReq. - state.corkedRequestsFree.next = corkReq; + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } } + Object.defineProperty(Writable.prototype, 'destroyed', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { + get: function () { if (this._writableState === undefined) { return false; } return this._writableState.destroyed; }, - set: function set(value) { + set: function (value) { // we ignore the value if the stream // has not been initialized yet if (!this._writableState) { @@ -634,8 +678,10 @@ this._writableState.destroyed = value; } }); + Writable.prototype.destroy = destroyImpl.destroy; Writable.prototype._undestroy = destroyImpl.undestroy; Writable.prototype._destroy = function (err, cb) { + this.end(); cb(err); }; \ No newline at end of file
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/lib/internal/streams/BufferList.js
Added
@@ -0,0 +1,79 @@ +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Buffer = require('safe-buffer').Buffer; +var util = require('util'); + +function copyBuffer(src, target, offset) { + src.copy(target, offset); +} + +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; + + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; + + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; + + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; + + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; + + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + }; + + return BufferList; +}(); + +if (util && util.inspect && util.inspect.custom) { + module.exports.prototypeutil.inspect.custom = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; + }; +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/internal/streams/destroy.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/lib/internal/streams/destroy.js
Changed
@@ -1,20 +1,22 @@ 'use strict'; +/*<replacement>*/ + +var pna = require('process-nextick-args'); +/*</replacement>*/ + // undocumented cb() API, needed for core, not for public API function destroy(err, cb) { var _this = this; + var readableDestroyed = this._readableState && this._readableState.destroyed; var writableDestroyed = this._writableState && this._writableState.destroyed; + if (readableDestroyed || writableDestroyed) { if (cb) { cb(err); - } else if (err) { - if (!this._writableState) { - process.nextTick(emitErrorNT, this, err); - } else if (!this._writableState.errorEmitted) { - this._writableState.errorEmitted = true; - process.nextTick(emitErrorNT, this, err); - } + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + pna.nextTick(emitErrorNT, this, err); } return this; } @@ -30,34 +32,21 @@ if (this._writableState) { this._writableState.destroyed = true; } + this._destroy(err || null, function (err) { if (!cb && err) { - if (!_this._writableState) { - process.nextTick(emitErrorAndCloseNT, _this, err); - } else if (!_this._writableState.errorEmitted) { + pna.nextTick(emitErrorNT, _this, err); + if (_this._writableState) { _this._writableState.errorEmitted = true; - process.nextTick(emitErrorAndCloseNT, _this, err); - } else { - process.nextTick(emitCloseNT, _this); } } else if (cb) { - process.nextTick(emitCloseNT, _this); cb(err); - } else { - process.nextTick(emitCloseNT, _this); } }); + return this; } -function emitErrorAndCloseNT(self, err) { - emitErrorNT(self, err); - emitCloseNT(self); -} -function emitCloseNT(self) { - if (self._writableState && !self._writableState.emitClose) return; - if (self._readableState && !self._readableState.emitClose) return; - self.emit('close'); -} + function undestroy() { if (this._readableState) { this._readableState.destroyed = false; @@ -65,32 +54,21 @@ this._readableState.ended = false; this._readableState.endEmitted = false; } + if (this._writableState) { this._writableState.destroyed = false; this._writableState.ended = false; this._writableState.ending = false; - this._writableState.finalCalled = false; - this._writableState.prefinished = false; this._writableState.finished = false; this._writableState.errorEmitted = false; } } + function emitErrorNT(self, err) { self.emit('error', err); } -function errorOrDestroy(stream, err) { - // We have tests that rely on errors being emitted - // in the same tick, so changing this is semver major. - // For now when you opt-in to autoDestroy we allow - // the error to be emitted nextTick. In a future - // semver major update we should change the default to this. - var rState = stream._readableState; - var wState = stream._writableState; - if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); -} module.exports = { destroy: destroy, - undestroy: undestroy, - errorOrDestroy: errorOrDestroy + undestroy: undestroy }; \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/package.json -> _service:tar_scm:readable-stream-2.3.6.tar.gz/package.json
Changed
@@ -1,46 +1,31 @@ { "name": "readable-stream", - "version": "3.6.2", + "version": "2.3.6", "description": "Streams3, a user-land copy of the stream library from Node.js", "main": "readable.js", - "engines": { - "node": ">= 6" - }, "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" }, "devDependencies": { - "@babel/cli": "^7.2.0", - "@babel/core": "^7.2.0", - "@babel/polyfill": "^7.0.0", - "@babel/preset-env": "^7.2.0", - "airtap": "0.0.9", "assert": "^1.4.0", - "bl": "^2.0.0", - "deep-strict-equal": "^0.2.0", - "events.once": "^2.0.2", - "glob": "^7.1.2", - "gunzip-maybe": "^1.4.1", - "hyperquest": "^2.1.3", - "lolex": "^2.6.0", - "nyc": "^11.0.0", - "pump": "^3.0.0", - "rimraf": "^2.6.2", - "tap": "^12.0.0", - "tape": "^4.9.0", - "tar-fs": "^1.16.2", - "util-promisify": "^2.1.0" + "babel-polyfill": "^6.9.1", + "buffer": "^4.9.0", + "lolex": "^2.3.2", + "nyc": "^6.4.0", + "tap": "^0.7.0", + "tape": "^4.8.0" }, "scripts": { - "test": "tap -J --no-esm test/parallel/*.js test/ours/*.js", - "ci": "TAP=1 tap --no-esm test/parallel/*.js test/ours/*.js | tee test.tap", - "test-browsers": "airtap --sauce-connect --loopback airtap.local -- test/browser.js", - "test-browser-local": "airtap --open --local -- test/browser.js", + "test": "tap test/parallel/*.js test/ours/*.js && node test/verify-dependencies.js", + "ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js", "cover": "nyc npm test", - "report": "nyc report --reporter=lcov", - "update-browser-errors": "babel -o errors-browser.js errors.js" + "report": "nyc report --reporter=lcov" }, "repository": { "type": "git", @@ -53,10 +38,9 @@ , "browser": { "util": false, - "worker_threads": false, - "./errors": "./errors-browser.js", "./readable.js": "./readable-browser.js", - "./lib/internal/streams/from.js": "./lib/internal/streams/from-browser.js", + "./writable.js": "./writable-browser.js", + "./duplex.js": "./duplex-browser.js", "./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js" }, "nyc": {
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/passthrough.js
Added
@@ -0,0 +1,1 @@ +module.exports = require('./readable').PassThrough
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/readable-browser.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/readable-browser.js
Changed
@@ -5,5 +5,3 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -exports.finished = require('./lib/internal/streams/end-of-stream.js'); -exports.pipeline = require('./lib/internal/streams/pipeline.js');
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/readable.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/readable.js
Changed
@@ -1,8 +1,13 @@ var Stream = require('stream'); if (process.env.READABLE_STREAM === 'disable' && Stream) { - module.exports = Stream.Readable; - Object.assign(module.exports, Stream); - module.exports.Stream = Stream; + module.exports = Stream; + exports = module.exports = Stream.Readable; + exports.Readable = Stream.Readable; + exports.Writable = Stream.Writable; + exports.Duplex = Stream.Duplex; + exports.Transform = Stream.Transform; + exports.PassThrough = Stream.PassThrough; + exports.Stream = Stream; } else { exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = Stream || exports; @@ -11,6 +16,4 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); - exports.finished = require('./lib/internal/streams/end-of-stream.js'); - exports.pipeline = require('./lib/internal/streams/pipeline.js'); }
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser.js
Changed
@@ -11,21 +11,6 @@ global.console.info = global.console.log; } var test = require('tape'); -var util = require('util'); - -// TODO: add replacements instead -global.process = { - env: {}, - on: function () {}, - cwd: function () { - return '/'; - }, - binding: function () { - return { - hasTracing: false - }; - } -}; test('streams', function (t) { require('./browser/test-stream-big-packet')(t); @@ -33,8 +18,6 @@ require('./browser/test-stream-duplex')(t); require('./browser/test-stream-end-paused')(t); require('./browser/test-stream-ispaused')(t); - require('./browser/test-stream-finished')(t); - require('./browser/test-stream-pipeline')(t); require('./browser/test-stream-pipe-after-end')(t); require('./browser/test-stream-pipe-cleanup')(t); require('./browser/test-stream-pipe-cleanup-pause')(t); @@ -66,8 +49,8 @@ require('./browser/test-stream2-pipe-error-once-listener')(t); require('./browser/test-stream2-push')(t); require('./browser/test-stream2-readable-empty-buffer-no-eof')(t); - // require('./browser/test-stream2-readable-from-list')(t); - // require('./browser/test-stream2-transform')(t); + require('./browser/test-stream2-readable-from-list')(t); + require('./browser/test-stream2-transform')(t); require('./browser/test-stream2-set-encoding')(t); require('./browser/test-stream2-readable-legacy-drain')(t); require('./browser/test-stream2-readable-wrap-empty')(t);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-big-packet.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-big-packet.js
Changed
@@ -40,7 +40,7 @@ s2.pipe(s3, {end: false}); // We must write a buffer larger than highWaterMark - var big = Buffer.alloc(s1._writableState.highWaterMark + 1); + var big = new Buffer(s1._writableState.highWaterMark + 1); big.fill('x'); // Since big is larger than highWaterMark, it will be buffered internally.
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-pipe-cleanup-pause.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-pipe-cleanup-pause.js
Changed
@@ -11,7 +11,7 @@ // 560000 is chosen here because it is larger than the (default) highWaterMark // and will cause `.write()` to return false // See: https://github.com/nodejs/node/issues/2323 - var buffer = Buffer.alloc(560000); + var buffer = new Buffer(560000); reader._read = function() {};
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-readable-event.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-readable-event.js
Changed
@@ -16,7 +16,7 @@ }; // This triggers a 'readable' event, which is lost. - r.push(Buffer.from('blerg')); + r.push(new Buffer('blerg')); var caughtReadable = false; setTimeout(function() { @@ -51,7 +51,7 @@ }; // This triggers a 'readable' event, which is lost. - r.push(Buffer.from('bl')); + r.push(new Buffer('bl')); var caughtReadable = false; setTimeout(function() { @@ -84,7 +84,7 @@ }; // This triggers a 'readable' event, which is lost. - r.push(Buffer.from('blerg')); + r.push(new Buffer('blerg')); r.push(null); var caughtReadable = false;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-transform-constructor-set-methods.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-transform-constructor-set-methods.js
Changed
@@ -21,7 +21,7 @@ flush: _flush }); - tr.end(Buffer.from('blerg')); + tr.end(new Buffer('blerg')); tr.resume(); tr.on('end', function() {
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-transform-split-objectmode.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-transform-split-objectmode.js
Changed
@@ -22,7 +22,7 @@ parsed = obj; }); - parser.end(Buffer.from(42)); + parser.end(new Buffer(42)); parser.on('end', function() { t.equals(parsed.val, 42, 'parser ended'); @@ -37,7 +37,7 @@ t.equals(serializer._writableState.highWaterMark, 16, 'serializer 4'); serializer._transform = function(obj, _, callback) { - callback(null, Buffer.from(obj.val)); + callback(null, new Buffer(obj.val)); }; var serialized;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-unshift-empty-chunk.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-unshift-empty-chunk.js
Changed
@@ -9,7 +9,7 @@ t.plan(1); var r = new Readable(); var nChunks = 10; - var chunk = Buffer.alloc(10); + var chunk = new Buffer(10); chunk.fill('x'); r._read = function(n) { @@ -29,7 +29,7 @@ // stream, like a parser might do. We just fill it with // 'y' so that it's easy to see which bits were touched, // and which were not. - var putBack = Buffer.alloc(readAll ? 0 : 5); + var putBack = new Buffer(readAll ? 0 : 5); putBack.fill('y'); readAll = !readAll; r.unshift(putBack);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-unshift-read-race.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-unshift-read-race.js
Changed
@@ -16,7 +16,7 @@ var chunks = 10; var t = (chunks * 5); - var data = Buffer.alloc(chunks * hwm + Math.ceil(hwm / 2)); + var data = new Buffer(chunks * hwm + Math.ceil(hwm / 2)); for (var i = 0; i < data.length; i++) { var c = 'asdf'.charCodeAt(i % 4); datai = c; @@ -50,7 +50,7 @@ function pushError() { tape.throws(function() { - r.push(Buffer.alloc(1)); + r.push(new Buffer(1)); }); } @@ -66,7 +66,7 @@ r.on('end', function() { tape.notOk(ended, 'end emitted more than once'); tape.throws(function() { - r.unshift(Buffer.alloc(1)); + r.unshift(new Buffer(1)); }); ended = true; w.end(); @@ -77,7 +77,7 @@ while (null !== (chunk = r.read(10))) { w.write(chunk); if (chunk.length > 4) - r.unshift(Buffer.from('1234')); + r.unshift(new Buffer('1234')); } });
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-writable-constructor-set-methods.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-writable-constructor-set-methods.js
Changed
@@ -12,7 +12,7 @@ } var w = new Writable({ write: _write }); - w.end(Buffer.from('blerg')); + w.end(new Buffer('blerg')); var _writevCalled = false; var dLength = 0; @@ -24,8 +24,8 @@ var w2 = new Writable({ writev: _writev }); w2.cork(); - w2.write(Buffer.from('blerg')); - w2.write(Buffer.from('blerg')); + w2.write(new Buffer('blerg')); + w2.write(new Buffer('blerg')); w2.end(); setImmediate(function() {
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-writev.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream-writev.js
Changed
@@ -82,7 +82,7 @@ if (multi) w.cork(); - w.write(Buffer.from('!'), 'buffer', cnt('!')); + w.write(new Buffer('!'), 'buffer', cnt('!')); w.write('\nand then...', 'binary', cnt('and then')); if (multi)
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-base64-single-char-read-end.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-base64-single-char-read-end.js
Changed
@@ -15,7 +15,7 @@ if(!hasRead) { hasRead = true; process.nextTick(function() { - src.push(Buffer.from('1')); + src.push(new Buffer('1')); src.push(null); }); };
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-compatibility.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-compatibility.js
Changed
@@ -10,7 +10,7 @@ function TestReader() { R.apply(this); - this._buffer = Buffer.alloc(100); + this._buffer = new Buffer(100); this._buffer.fill('x'); this.on('data', function() { @@ -22,7 +22,7 @@ TestReader.prototype._read = function(n) { this.push(this._buffer); - this._buffer = Buffer.alloc(0); + this._buffer = new Buffer(0); }; var reader = new TestReader();
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-large-read-stall.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-large-read-stall.js
Changed
@@ -51,7 +51,7 @@ } ;false && console.error(' push #%d', pushes); - if (r.push(Buffer.alloc(PUSHSIZE))) + if (r.push(new Buffer(PUSHSIZE))) setTimeout(push); }
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-pipe-error-handling.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-pipe-error-handling.js
Changed
@@ -10,7 +10,7 @@ source._read = function(n) { n = Math.min(count, n); count -= n; - source.push(Buffer.alloc(n)); + source.push(new Buffer(n)); }; var unpipedDest; @@ -51,7 +51,7 @@ source._read = function(n) { n = Math.min(count, n); count -= n; - source.push(Buffer.alloc(n)); + source.push(new Buffer(n)); }; var unpipedDest;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-readable-empty-buffer-no-eof.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-readable-empty-buffer-no-eof.js
Changed
@@ -18,7 +18,7 @@ // r.read(0) again later, otherwise there is no more work being done // and the process just exits. - var buf = Buffer.alloc(5); + var buf = new Buffer(5); buf.fill('x'); var reads = 5; r._read = function(n) { @@ -29,16 +29,16 @@ return r.push(buf); case 2: setTimeout(r.read.bind(r, 0), 50); - return r.push(Buffer.alloc(0)); // Not-EOF! + return r.push(new Buffer(0)); // Not-EOF! case 3: setTimeout(r.read.bind(r, 0), 50); return process.nextTick(function() { - return r.push(Buffer.alloc(0)); + return r.push(new Buffer(0)); }); case 4: setTimeout(r.read.bind(r, 0), 50); return setTimeout(function() { - return r.push(Buffer.alloc(0)); + return r.push(new Buffer(0)); }); case 5: return setTimeout(function() { @@ -72,7 +72,7 @@ if (!reads--) return r.push(null); // EOF else - return r.push(Buffer.from('x')); + return r.push(new Buffer('x')); }; var results = ;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-readable-legacy-drain.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-readable-legacy-drain.js
Changed
@@ -9,7 +9,7 @@ var N = 256; var reads = 0; r._read = function(n) { - return r.push(++reads === N ? null : Buffer.alloc(1)); + return r.push(++reads === N ? null : new Buffer(1)); }; t.plan(2); r.on('end', function() {
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-readable-non-empty-end.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-readable-non-empty-end.js
Changed
@@ -7,7 +7,7 @@ var len = 0; var chunks = new Array(10); for (var i = 1; i <= 10; i++) { - chunksi - 1 = Buffer.alloc(i); + chunksi - 1 = new Buffer(i); len += i; }
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-readable-wrap.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-readable-wrap.js
Changed
@@ -76,8 +76,8 @@ } module.exports = function (t) { t.test('readable wrap', function (t) { - runTest(t, 100, false, function() { return Buffer.alloc(100); }); - runTest(t, 10, false, function() { return Buffer.from('xxxxxxxxxx'); }); + runTest(t, 100, false, function() { return new Buffer(100); }); + runTest(t, 10, false, function() { return new Buffer('xxxxxxxxxx'); }); runTest(t, 1, true, function() { return { foo: 'bar' }; }); var objectChunks = 5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, , 555 ;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-set-encoding.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-set-encoding.js
Changed
@@ -36,7 +36,7 @@ } this.pos += n; - var ret = Buffer.alloc(n); + var ret = new Buffer(n); ret.fill('a'); //console.log('this.push(ret)', ret);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-transform.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-transform.js
Changed
@@ -18,7 +18,7 @@ }; for (var i = 1; i <= 10; i++) { - tx.write(Buffer.alloc(i)); + tx.write(new Buffer(i)); } tx.end(); @@ -35,10 +35,10 @@ t.test('passthrough', function(t) { var pt = new PassThrough(); - pt.write(Buffer.from('foog')); - pt.write(Buffer.from('bark')); - pt.write(Buffer.from('bazy')); - pt.write(Buffer.from('kuel')); + pt.write(new Buffer('foog')); + pt.write(new Buffer('bark')); + pt.write(new Buffer('bazy')); + pt.write(new Buffer('kuel')); pt.end(); t.equal(pt.read(5).toString(), 'foogb'); @@ -73,16 +73,16 @@ t.test('simple transform', function(t) { var pt = new Transform(); pt._transform = function(c, e, cb) { - var ret = Buffer.alloc(c.length); + var ret = new Buffer(c.length); ret.fill('x'); pt.push(ret); cb(); }; - pt.write(Buffer.from('foog')); - pt.write(Buffer.from('bark')); - pt.write(Buffer.from('bazy')); - pt.write(Buffer.from('kuel')); + pt.write(new Buffer('foog')); + pt.write(new Buffer('bark')); + pt.write(new Buffer('bazy')); + pt.write(new Buffer('kuel')); pt.end(); t.equal(pt.read(5).toString(), 'xxxxx'); @@ -127,10 +127,10 @@ }, 10); }; - pt.write(Buffer.from('foog')); - pt.write(Buffer.from('bark')); - pt.write(Buffer.from('bazy')); - pt.write(Buffer.from('kuel')); + pt.write(new Buffer('foog')); + pt.write(new Buffer('bark')); + pt.write(new Buffer('bazy')); + pt.write(new Buffer('kuel')); pt.end(); pt.on('finish', function() { @@ -156,10 +156,10 @@ }, 10); }; - pt.write(Buffer.from('foog')); - pt.write(Buffer.from('bark')); - pt.write(Buffer.from('bazy')); - pt.write(Buffer.from('kuel')); + pt.write(new Buffer('foog')); + pt.write(new Buffer('bark')); + pt.write(new Buffer('bazy')); + pt.write(new Buffer('kuel')); pt.end(); pt.on('finish', function() { @@ -188,7 +188,7 @@ setTimeout(function() { this.state += s.charAt(0); if (this.state.length === 3) { - pt.push(Buffer.from(this.state)); + pt.push(new Buffer(this.state)); this.state = ''; } cb(); @@ -197,25 +197,25 @@ pt._flush = function(cb) { // just output whatever we have. - pt.push(Buffer.from(this.state)); + pt.push(new Buffer(this.state)); this.state = ''; cb(); }; - pt.write(Buffer.from('aaaa')); - pt.write(Buffer.from('bbbb')); - pt.write(Buffer.from('cccc')); - pt.write(Buffer.from('dddd')); - pt.write(Buffer.from('eeee')); - pt.write(Buffer.from('aaaa')); - pt.write(Buffer.from('bbbb')); - pt.write(Buffer.from('cccc')); - pt.write(Buffer.from('dddd')); - pt.write(Buffer.from('eeee')); - pt.write(Buffer.from('aaaa')); - pt.write(Buffer.from('bbbb')); - pt.write(Buffer.from('cccc')); - pt.write(Buffer.from('dddd')); + pt.write(new Buffer('aaaa')); + pt.write(new Buffer('bbbb')); + pt.write(new Buffer('cccc')); + pt.write(new Buffer('dddd')); + pt.write(new Buffer('eeee')); + pt.write(new Buffer('aaaa')); + pt.write(new Buffer('bbbb')); + pt.write(new Buffer('cccc')); + pt.write(new Buffer('dddd')); + pt.write(new Buffer('eeee')); + pt.write(new Buffer('aaaa')); + pt.write(new Buffer('bbbb')); + pt.write(new Buffer('cccc')); + pt.write(new Buffer('dddd')); pt.end(); // 'abcdeabcdeabcd' @@ -249,8 +249,8 @@ pt.once('readable', function() { process.nextTick(function() { - pt.write(Buffer.from('d')); - pt.write(Buffer.from('ef'), function() { + pt.write(new Buffer('d')); + pt.write(new Buffer('ef'), function() { pt.end(); t.end(); }); @@ -259,7 +259,7 @@ }); }); - pt.write(Buffer.from('abc')); + pt.write(new Buffer('abc')); }); @@ -274,10 +274,10 @@ var i = 0; - pt.write(Buffer.from('foog')); + pt.write(new Buffer('foog')); //console.error('need emit 0'); - pt.write(Buffer.from('bark')); + pt.write(new Buffer('bark')); //console.error('should have emitted readable now 1 === %d', emits); t.equal(emits, 1); @@ -287,9 +287,9 @@ //console.error('need emit 1'); - pt.write(Buffer.from('bazy')); + pt.write(new Buffer('bazy')); //console.error('should have emitted, but not again'); - pt.write(Buffer.from('kuel')); + pt.write(new Buffer('kuel')); //console.error('should have emitted readable now 2 === %d', emits); t.equal(emits, 2); @@ -320,9 +320,9 @@ emits++; }); - pt.write(Buffer.from('foog')); + pt.write(new Buffer('foog')); //console.error('need emit 0'); - pt.write(Buffer.from('bark')); + pt.write(new Buffer('bark')); //console.error('should have emitted readable now 1 === %d', emits); t.equal(emits, 1); @@ -347,10 +347,10 @@ }); pt.end(); }); - pt.write(Buffer.from('kuel')); + pt.write(new Buffer('kuel')); }); - pt.write(Buffer.from('bazy')); + pt.write(new Buffer('bazy')); }); t.test('passthrough facaded', function(t) { @@ -366,13 +366,13 @@ t.end(); }); - pt.write(Buffer.from('foog')); + pt.write(new Buffer('foog')); setTimeout(function() { - pt.write(Buffer.from('bark')); + pt.write(new Buffer('bark')); setTimeout(function() { - pt.write(Buffer.from('bazy')); + pt.write(new Buffer('bazy')); setTimeout(function() { - pt.write(Buffer.from('kuel')); + pt.write(new Buffer('kuel')); setTimeout(function() { pt.end(); }, 10);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-unpipe-drain.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-unpipe-drain.js
Changed
@@ -58,7 +58,7 @@ dest.on('unpipe', function() { t.equal(src1.reads, 2); - t.equal(src2.reads, 1); + t.equal(src2.reads, 2); t.end(); }); });
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream2-writable.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream2-writable.js
Changed
@@ -137,7 +137,7 @@ forEach(chunks, function(chunk, i) { var enc = encodings i % encodings.length ; - chunk = Buffer.from(chunk); + chunk = new Buffer(chunk); tw.write(chunk.toString(enc), enc); }); t.end(); @@ -151,7 +151,7 @@ tw._write = function(chunk, encoding, cb) { t.equals(typeof chunk, 'string'); - chunk = Buffer.from(chunk, encoding); + chunk = new Buffer(chunk, encoding); return TestWriter.prototype._write.call(this, chunk, encoding, cb); }; @@ -174,7 +174,7 @@ forEach(chunks, function(chunk, i) { var enc = encodings i % encodings.length ; - chunk = Buffer.from(chunk); + chunk = new Buffer(chunk); tw.write(chunk.toString(enc), enc); }); t.end(); @@ -218,7 +218,7 @@ test('end callback with chunk', function(t) { var tw = new TestWriter(); - tw.end(Buffer.from('hello world'), function() { + tw.end(new Buffer('hello world'), function() { t.end(); }); }); @@ -232,7 +232,7 @@ test('end callback after .write() call', function(t) { var tw = new TestWriter(); - tw.write(Buffer.from('hello world')); + tw.write(new Buffer('hello world')); tw.end(function() { t.end(); }); @@ -241,7 +241,7 @@ test('end callback called after write callback', function(t) { var tw = new TestWriter(); var writeCalledback = false; - tw.write(Buffer.from('hello world'), function() { + tw.write(new Buffer('hello world'), function() { writeCalledback = true; }); tw.end(function() { @@ -257,7 +257,7 @@ t.equal(chunk.toString('hex'), hex); t.end(); }; - var buf = Buffer.from(hex, 'hex'); + var buf = new Buffer(hex, 'hex'); tw.write(buf, 'binary'); });
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream3-pause-then-read.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/browser/test-stream3-pause-then-read.js
Changed
@@ -25,7 +25,7 @@ var totalPushed = 0; function push() { - var chunk = chunks-- > 0 ? Buffer.alloc(chunkSize) : null; + var chunk = chunks-- > 0 ? new Buffer(chunkSize) : null; if (chunk) { totalPushed += chunk.length; chunk.fill('x');
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/README.md -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/README.md
Changed
@@ -1,8 +1,20 @@ /*<replacement>*/ - require('@babel/polyfill'); + require('babel-polyfill'); var util = require('util'); for (var i in util) exportsi = utili; - /*</replacement>*/# Node.js Core Test Common Modules + /*</replacement>*//*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +# Node.js Core Test Common Modules This directory contains modules used to test the Node.js implementation. @@ -14,11 +26,6 @@ * DNS module(#dns-module) * Duplex pair helper(#duplex-pair-helper) * Fixtures module(#fixtures-module) -* Heap dump checker module(#heap-dump-checker-module) -* HTTP2 module(#http2-module) -* Internet module(#internet-module) -* tick module(#tick-module) -* tmpdir module(#tmpdir-module) * WPT module(#wpt-module) ## Benchmark Module @@ -27,7 +34,7 @@ ### runBenchmark(name, args, env) -* `name` <string> Name of benchmark suite to be run. +* `name` <String> Name of benchmark suite to be run. * `args` <Array> Array of environment variable key/value pairs (ex: `n=1`) to be applied via `--set`. * `env` <Object> Environment variables to be applied during the run. @@ -43,13 +50,16 @@ Takes `whitelist` and concats that with predefined `knownGlobals`. +### arrayStream +A stream to push an array into a REPL + ### busyLoop(time) -* `time` <number> +* `time` <Number> Blocks for `time` amount of time. ### canCreateSymLink() -* return <boolean> +* return <Boolean> Checks whether the current running process can create symlinks. On Windows, this returns `false` if the process running doesn't have privileges to create @@ -57,20 +67,20 @@ (SeCreateSymbolicLinkPrivilege(https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716(v=vs.85).aspx)). On non-Windows platforms, this always returns `true`. -### createZeroFilledFile(filename) +### crashOnUnhandledRejection() -Creates a 10 MB file of all null characters. +Installs a `process.on('unhandledRejection')` handler that crashes the process +after a tick. This is useful for tests that use Promises and need to make sure +no unexpected rejections occur, because currently they result in silent +failures. -### disableCrashOnUnhandledRejection() +### ddCommand(filename, kilobytes) +* return <Object> -Removes the `process.on('unhandledRejection')` handler that crashes the process -after a tick. The handler is useful for tests that use Promises and need to make -sure no unexpected rejections occur, because currently they result in silent -failures. However, it is useful in some rare cases to disable it, for example if -the `unhandledRejection` hook is directly used by the test. +Platform normalizes the `dd` command ### enoughTestMem -* <boolean> +* <Boolean> Indicates if there is more than 1gb of total memory. @@ -79,19 +89,17 @@ * `settings` <Object> that must contain the `code` property plus any of the other following properties (some properties only apply for `AssertionError`): - * `code` <string> + * `code` <String> expected error must have this value for its `code` property. * `type` <Function> expected error must be an instance of `type` and must be an Error subclass. - * `message` <string> or <RegExp> + * `message` <String> or <RegExp> if a string is provided for `message`, expected error must have it for its `message` property; if a regular expression is provided for `message`, the regular expression must match the `message` property of the expected error. - * `name` <string> + * `name` <String> expected error must have this value for its `name` property. - * `info` <Object> expected error must have the same `info` property - that is deeply equal to this value. - * `generatedMessage` <string> + * `generatedMessage` <String> (`AssertionError` only) expected error must have this value for its `generatedMessage` property. * `actual` <any> @@ -103,7 +111,7 @@ * `operator` <any> (`AssertionError` only) expected error must have this value for its `operator` property. -* `exact` <number> default = 1 +* `exact` <Number> default = 1 * return <Function> If `fn` is provided, it will be passed to `assert.throws` as first argument @@ -113,14 +121,17 @@ returned function has not been called exactly `exact` number of times when the test is complete, then the test will fail. -### expectWarning(name, expected, code) -* `name` <string> -* `expected` <string> | <Array> -* `code` <string> +### expectWarning(name, expected) +* `name` <String> +* `expected` <String> | <Array> + +Tests whether `name` and `expected` are part of a raised warning. -Tests whether `name`, `expected`, and `code` are part of a raised warning. If -an expected warning does not have a code then `common.noWarnCode` can be used -to indicate this. +### fileExists(pathname) +* pathname <String> +* return <Boolean> + +Checks if `pathname` exists ### getArrayBufferViews(buf) * `buf` <Buffer> @@ -128,98 +139,123 @@ Returns an instance of all possible `ArrayBufferView`s of the provided Buffer. -### getBufferSources(buf) -* `buf` <Buffer> -* return <BufferSource[]> - -Returns an instance of all possible `BufferSource`s of the provided Buffer, -consisting of all `ArrayBufferView` and an `ArrayBuffer`. - ### getCallSite(func) * `func` <Function> -* return <string> +* return <String> Returns the file name and line number for the provided Function. -### getTTYfd() - -Attempts to get a valid TTY file descriptor. Returns `-1` if it fails. +### globalCheck +* <Boolean> -The TTY file descriptor is assumed to be capable of being writable. +Set to `false` if the test should not check for global leaks. ### hasCrypto -* <boolean> +* <Boolean> Indicates whether OpenSSL is available. ### hasFipsCrypto -* <boolean> +* <Boolean> Indicates `hasCrypto` and `crypto` with fips. ### hasIntl -* <boolean> +* <Boolean> Indicates if internationalization is supported. +### hasSmallICU +* <Boolean> + +Indicates `hasIntl` and `small-icu` are supported. + ### hasIPv6 -* <boolean> +* <Boolean> Indicates whether `IPv6` is supported on this platform. ### hasMultiLocalhost -* <boolean> +* <Boolean> Indicates if there are multiple localhosts available. +### hijackStderr(listener) +* `listener` <Function>: a listener with a single parameter + called `data`. + +Eavesdrop to `process.stderr.write` calls. Once `process.stderr.write` is +called, `listener` will also be called and the `data` of `write` function will +be passed to `listener`. What's more, `process.stderr.writeTimes` is a count of +the number of calls. + +### hijackStdout(listener) +* `listener` <Function>: a listener with a single parameter + called `data`. + +Eavesdrop to `process.stdout.write` calls. Once `process.stdout.write` is +called, `listener` will also be called and the `data` of `write` function will +be passed to `listener`. What's more, `process.stdout.writeTimes` is a count of +the number of calls. + ### inFreeBSDJail -* <boolean> +* <Boolean> Checks whether free BSD Jail is true or false. ### isAIX -* <boolean> +* <Boolean> Platform check for Advanced Interactive eXecutive (AIX). ### isAlive(pid) -* `pid` <number> -* return <boolean> +* `pid` <Number> +* return <Boolean> Attempts to 'kill' `pid` ### isFreeBSD -* <boolean> +* <Boolean> Platform check for Free BSD. ### isLinux -* <boolean> +* <Boolean> Platform check for Linux. ### isLinuxPPCBE -* <boolean> +* <Boolean> Platform check for Linux on PowerPC. ### isOSX -* <boolean> +* <Boolean> Platform check for macOS. ### isSunOS -* <boolean> +* <Boolean> Platform check for SunOS. ### isWindows -* <boolean> +* <Boolean> Platform check for Windows. +### isWOW64 +* <Boolean> + +Platform check for Windows 32-bit on Windows 64-bit. + +### leakedGlobals() +* return <Array> + +Indicates whether any globals are not on the `knownGlobals` list. + ### localhostIPv4 -* <string> +* <String> IP of `localhost`. @@ -230,7 +266,7 @@ ### mustCall(fn, exact) * `fn` <Function> default = () => {} -* `exact` <number> default = 1 +* `exact` <Number> default = 1 * return <Function> Returns a function that calls `fn`. If the returned function has not been called @@ -241,7 +277,7 @@ ### mustCallAtLeast(fn, minimum) * `fn` <Function> default = () => {} -* `minimum` <number> default = 1 +* `minimum` <Number> default = 1 * return <Function> Returns a function that calls `fn`. If the returned function has not been called @@ -251,76 +287,74 @@ If `fn` is not provided, an empty function will be used. ### mustNotCall(msg) -* `msg` <string> default = 'function should not have been called' +* `msg` <String> default = 'function should not have been called' * return <Function> Returns a function that triggers an `AssertionError` if it is invoked. `msg` is used as the error message for the `AssertionError`. ### nodeProcessAborted(exitCode, signal) -* `exitCode` <number> -* `signal` <string> -* return <boolean> +* `exitCode` <Number> +* `signal` <String> +* return <Boolean> Returns `true` if the exit code `exitCode` and/or signal name `signal` represent the exit code and/or signal name of a node process that aborted, `false` otherwise. -### noWarnCode -See `common.expectWarning()` for usage. - ### opensslCli -* <boolean> +* <Boolean> Indicates whether 'opensslCli' is supported. ### platformTimeout(ms) -* `ms` <number> -* return <number> +* `ms` <Number> +* return <Number> Platform normalizes timeout. ### PIPE -* <string> +* <String> Path to the test socket. ### PORT -* <number> +* <Number> A port number for tests to use if one is needed. ### printSkipMessage(msg) -* `msg` <string> +* `msg` <String> Logs '1..0 # Skipped: ' + `msg` -### pwdCommand -* <array> First two argument for the `spawn`/`exec` functions. +### refreshTmpDir() +* return <String> -Platform normalized `pwd` command options. Usage example: -```js -const common = require('../common'); -const { spawn } = require('child_process'); +Deletes the testing 'tmp' directory and recreates it. -spawn(...common.pwdCommand, { stdio: 'pipe' }); -``` +### restoreStderr() + +Restore the original `process.stderr.write`. Used to restore `stderr` to its +original state after calling `common.hijackStdErr()`. + +### restoreStdout() + +Restore the original `process.stdout.write`. Used to restore `stdout` to its +original state after calling `common.hijackStdOut()`. ### rootDir -* <string> +* <String> Path to the 'root' directory. either `/` or `c:\\` (windows) -### runWithInvalidFD(func) -* `func` <Function> +### projectDir +* <String> -Runs `func` with an invalid file descriptor that is an unsigned integer and -can be used to trigger `EBADF` as the first argument. If no such file -descriptor could be generated, a skip message will be printed and the `func` -will not be run. +Path to the project directory. ### skip(msg) -* `msg` <string> +* `msg` <String> Logs '1..0 # Skipped: ' + `msg` and exits with exit code `0`. @@ -339,33 +373,31 @@ Skip the rest of the tests in the current file when the Node.js executable was compiled with a pointer size smaller than 64 bits. -### skipIfWorker() +### spawnPwd(options) +* `options` <Object> +* return <Object> -Skip the rest of the tests in the current file when not running on a main -thread. +Platform normalizes the `pwd` command. -## ArrayStream Module +### spawnSyncPwd(options) +* `options` <Object> +* return <Object> -The `ArrayStream` module provides a simple `Stream` that pushes elements from -a given array. +Synchronous version of `spawnPwd`. -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -const ArrayStream = require('../common/arraystream'); -const stream = new ArrayStream(); -stream.run('a', 'b', 'c'); -``` +### tmpDir +* <String> -It can be used within tests as a simple mock stream. +The realpath of the 'tmp' directory. ## Countdown Module The `Countdown` module provides a simple countdown mechanism for tests that require a particular action to be taken after a given number of completed tasks (for instance, shutting down an HTTP server after a specific number of -requests). The Countdown will fail the test if the remainder did not reach 0. +requests). -<!-- eslint-disable strict, node-core/required-modules --> +<!-- eslint-disable strict, required-modules --> ```js const Countdown = require('../common/countdown'); @@ -396,30 +428,12 @@ ## DNS Module -The `DNS` module provides utilities related to the `dns` built-in module. - -### errorLookupMock(code, syscall) - -* `code` <string> Defaults to `dns.mockedErrorCode`. -* `syscall` <string> Defaults to `dns.mockedSysCall`. -* return <Function> - -A mock for the `lookup` option of `net.connect()` that would result in an error -with the `code` and the `syscall` specified. Returns a function that has the -same signature as `dns.lookup()`. - -### mockedErrorCode - -The default `code` of errors generated by `errorLookupMock`. - -### mockedSysCall - -The default `syscall` of errors generated by `errorLookupMock`. +The `DNS` module provides a naïve DNS parser/serializer. ### readDomainFromPacket(buffer, offset) * `buffer` <Buffer> -* `offset` <number> +* `offset` <Number> * return <Object> Reads the domain string from a packet and returns an object containing the @@ -435,14 +449,14 @@ ### writeIPv6(ip) -* `ip` <string> +* `ip` <String> * return <Buffer> Reads an IPv6 String and returns a Buffer containing the parts. ### writeDomainName(domain) -* `domain` <string> +* `domain` <String> * return <Buffer> Reads a Domain String and returns a Buffer containing the domain. @@ -470,308 +484,30 @@ ### fixtures.fixturesDir -* <string> +* <String> The absolute path to the `test/fixtures/` directory. ### fixtures.path(...args) -* `...args` <string> +* `...args` <String> Returns the result of `path.join(fixtures.fixturesDir, ...args)`. ### fixtures.readSync(args, enc) -* `args` <string> | <Array> +* `args` <String> | <Array> Returns the result of `fs.readFileSync(path.join(fixtures.fixturesDir, ...args), 'enc')`. ### fixtures.readKey(arg, enc) -* `arg` <string> +* `arg` <String> Returns the result of `fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')`. -## Heap dump checker module - -This provides utilities for checking the validity of heap dumps. -This requires the usage of `--expose-internals`. - -### heap.recordState() - -Create a heap dump and an embedder graph copy for inspection. -The returned object has a `validateSnapshotNodes` function similar to the -one listed below. (`heap.validateSnapshotNodes(...)` is a shortcut for -`heap.recordState().validateSnapshotNodes(...)`.) - -### heap.validateSnapshotNodes(name, expected, options) - -* `name` <string> Look for this string as the name of heap dump nodes. -* `expected` <Array> A list of objects, possibly with an `children` - property that points to expected other adjacent nodes. -* `options` <Array> - * `loose` <boolean> Do not expect an exact listing of occurrences - of nodes with name `name` in `expected`. - -Create a heap dump and an embedder graph copy and validate occurrences. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -validateSnapshotNodes('TLSWRAP', - { - children: - { name: 'enc_out' }, - { name: 'enc_in' }, - { name: 'TLSWrap' } - - } -); -``` - -## hijackstdio Module - -The `hijackstdio` module provides utility functions for temporarily redirecting -`stdout` and `stderr` output. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -const { hijackStdout, restoreStdout } = require('../common/hijackstdio'); - -hijackStdout((data) => { - /* Do something with data */ - restoreStdout(); -}); - -console.log('this is sent to the hijacked listener'); -``` - -### hijackStderr(listener) -* `listener` <Function>: a listener with a single parameter - called `data`. - -Eavesdrop to `process.stderr.write()` calls. Once `process.stderr.write()` is -called, `listener` will also be called and the `data` of `write` function will -be passed to `listener`. What's more, `process.stderr.writeTimes` is a count of -the number of calls. - -### hijackStdout(listener) -* `listener` <Function>: a listener with a single parameter - called `data`. - -Eavesdrop to `process.stdout.write()` calls. Once `process.stdout.write()` is -called, `listener` will also be called and the `data` of `write` function will -be passed to `listener`. What's more, `process.stdout.writeTimes` is a count of -the number of calls. - -### restoreStderr() - -Restore the original `process.stderr.write()`. Used to restore `stderr` to its -original state after calling `hijackstdio.hijackStdErr()`. - -### restoreStdout() - -Restore the original `process.stdout.write()`. Used to restore `stdout` to its -original state after calling `hijackstdio.hijackStdOut()`. - - -## HTTP/2 Module - -The http2.js module provides a handful of utilities for creating mock HTTP/2 -frames for testing of HTTP/2 endpoints - -<!-- eslint-disable no-unused-vars, node-core/required-modules --> -```js -const http2 = require('../common/http2'); -``` - -### Class: Frame - -The `http2.Frame` is a base class that creates a `Buffer` containing a -serialized HTTP/2 frame header. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -// length is a 24-bit unsigned integer -// type is an 8-bit unsigned integer identifying the frame type -// flags is an 8-bit unsigned integer containing the flag bits -// id is the 32-bit stream identifier, if any. -const frame = new http2.Frame(length, type, flags, id); - -// Write the frame data to a socket -socket.write(frame.data); -``` - -The serialized `Buffer` may be retrieved using the `frame.data` property. - -### Class: DataFrame extends Frame - -The `http2.DataFrame` is a subclass of `http2.Frame` that serializes a `DATA` -frame. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -// id is the 32-bit stream identifier -// payload is a Buffer containing the DATA payload -// padlen is an 8-bit integer giving the number of padding bytes to include -// final is a boolean indicating whether the End-of-stream flag should be set, -// defaults to false. -const frame = new http2.DataFrame(id, payload, padlen, final); - -socket.write(frame.data); -``` - -### Class: HeadersFrame - -The `http2.HeadersFrame` is a subclass of `http2.Frame` that serializes a -`HEADERS` frame. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -// id is the 32-bit stream identifier -// payload is a Buffer containing the HEADERS payload (see either -// http2.kFakeRequestHeaders or http2.kFakeResponseHeaders). -// padlen is an 8-bit integer giving the number of padding bytes to include -// final is a boolean indicating whether the End-of-stream flag should be set, -// defaults to false. -const frame = new http2.HeadersFrame(id, payload, padlen, final); - -socket.write(frame.data); -``` - -### Class: SettingsFrame - -The `http2.SettingsFrame` is a subclass of `http2.Frame` that serializes an -empty `SETTINGS` frame. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -// ack is a boolean indicating whether or not to set the ACK flag. -const frame = new http2.SettingsFrame(ack); - -socket.write(frame.data); -``` - -### http2.kFakeRequestHeaders - -Set to a `Buffer` instance that contains a minimal set of serialized HTTP/2 -request headers to be used as the payload of a `http2.HeadersFrame`. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -const frame = new http2.HeadersFrame(1, http2.kFakeRequestHeaders, 0, true); - -socket.write(frame.data); -``` - -### http2.kFakeResponseHeaders - -Set to a `Buffer` instance that contains a minimal set of serialized HTTP/2 -response headers to be used as the payload a `http2.HeadersFrame`. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -const frame = new http2.HeadersFrame(1, http2.kFakeResponseHeaders, 0, true); - -socket.write(frame.data); -``` - -### http2.kClientMagic - -Set to a `Buffer` containing the preamble bytes an HTTP/2 client must send -upon initial establishment of a connection. - -<!-- eslint-disable no-undef, node-core/required-modules --> -```js -socket.write(http2.kClientMagic); -``` - -## Internet Module - -The `common/internet` module provides utilities for working with -internet-related tests. - -### internet.addresses - -* <Object> - * `INET_HOST` <string> A generic host that has registered common - DNS records, supports both IPv4 and IPv6, and provides basic HTTP/HTTPS - services - * `INET4_HOST` <string> A host that provides IPv4 services - * `INET6_HOST` <string> A host that provides IPv6 services - * `INET4_IP` <string> An accessible IPv4 IP, defaults to the - Google Public DNS IPv4 address - * `INET6_IP` <string> An accessible IPv6 IP, defaults to the - Google Public DNS IPv6 address - * `INVALID_HOST` <string> An invalid host that cannot be resolved - * `MX_HOST` <string> A host with MX records registered - * `SRV_HOST` <string> A host with SRV records registered - * `PTR_HOST` <string> A host with PTR records registered - * `NAPTR_HOST` <string> A host with NAPTR records registered - * `SOA_HOST` <string> A host with SOA records registered - * `CNAME_HOST` <string> A host with CNAME records registered - * `NS_HOST` <string> A host with NS records registered - * `TXT_HOST` <string> A host with TXT records registered - * `DNS4_SERVER` <string> An accessible IPv4 DNS server - * `DNS6_SERVER` <string> An accessible IPv6 DNS server - -A set of addresses for internet-related tests. All properties are configurable -via `NODE_TEST_*` environment variables. For example, to configure -`internet.addresses.INET_HOST`, set the environment -variable `NODE_TEST_INET_HOST` to a specified host. - -## ongc Module - -The `ongc` module allows a garbage collection listener to be installed. The -module exports a single `onGC()` function. - -```js -require('../common'); -const onGC = require('../common/ongc'); - -onGC({}, { ongc() { console.log('collected'); } }); -``` - -### onGC(target, listener) -* `target` <Object> -* `listener` <Object> - * `ongc` <Function> - -Installs a GC listener for the collection of `target`. - -This uses `async_hooks` for GC tracking. This means that it enables -`async_hooks` tracking, which may affect the test functionality. It also -means that between a `global.gc()` call and the listener being invoked -a full `setImmediate()` invocation passes. - -`listener` is an object to make it easier to use a closure; the target object -should not be in scope when `listener.ongc()` is created. - - -## tick Module - -The `tick` module provides a helper function that can be used to call a callback -after a given number of event loop "ticks". - -### tick(x, cb) - -* `x` <number> Number of event loop "ticks". -* `cb` <Function> A callback function. - -## tmpdir Module - -The `tmpdir` module supports the use of a temporary directory for testing. - -### path -* <string> - -The realpath of the testing temporary directory. - -### refresh() - -Deletes and recreates the testing temporary directory. - ## WPT Module The wpt.js module is a port of parts of @@ -781,18 +517,17 @@ implementation with tests from W3C Web Platform Tests(https://github.com/w3c/web-platform-tests). - <Array>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array <ArrayBufferView[]>: https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView +<Boolean>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type <Buffer>: https://nodejs.org/api/buffer.html#buffer_class_buffer <Function>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function +<Number>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type <Object>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object <RegExp>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp -<boolean>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type -<number>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type -<string>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type -`hijackstdio.hijackStdErr()`: #hijackstderrlistener -`hijackstdio.hijackStdOut()`: #hijackstdoutlistener +<String>: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type +`common.hijackStdErr()`: #hijackstderrlistener +`common.hijackStdOut()`: #hijackstdoutlistener internationalization: https://github.com/nodejs/node/wiki/Intl function forEach (xs, f) {
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/benchmark.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/benchmark.js
Changed
@@ -1,55 +1,60 @@ -"use strict"; - /*<replacement>*/ -require('@babel/polyfill'); +require('babel-polyfill'); var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ +for (var i in util) { + exportsi = utili; +} /*</replacement>*/ /*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +/* eslint-disable required-modules */ 'use strict'; /*<replacement>*/ var objectKeys = objectKeys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ var assert = require('assert'); var fork = require('child_process').fork; var path = require('path'); + var runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); + function runBenchmark(name, args, env) { var argv = ; + for (var _i = 0; _i < args.length; _i++) { argv.push('--set'); argv.push(args_i); } + argv.push(name); + var mergedEnv = Object.assign({}, process.env, env); - var child = fork(runjs, argv, { - env: mergedEnv, - stdio: 'inherit', 'pipe', 'inherit', 'ipc' - }); - child.stdout.setEncoding('utf8'); - var stdout = ''; - child.stdout.on('data', function (line) { - stdout += line; - }); + + var child = fork(runjs, argv, { env: mergedEnv }); child.on('exit', function (code, signal) { assert.strictEqual(code, 0); assert.strictEqual(signal, null); - // This bit makes sure that each benchmark file is being sent settings such - // that the benchmark file runs just one set of options. This helps keep the - // benchmark tests from taking a long time to run. Therefore, each benchmark - // file should result in three lines of output: a blank line, a line with - // the name of the benchmark file, and a line with the only results that we - // get from testing the benchmark file. - assert.ok(/^(?:\n.+?\n.+?\n)+$/.test(stdout), "benchmark file not running exactly one configuration in test: ".concat(stdout)); }); } + module.exports = runBenchmark; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/countdown.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/countdown.js
Changed
@@ -1,54 +1,68 @@ -"use strict"; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } + /*<replacement>*/ -require('@babel/polyfill'); +require('babel-polyfill'); var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ - +for (var i in util) { + exportsi = utili; +} /*</replacement>*/ /*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +/* eslint-disable required-modules */ 'use strict'; /*<replacement>*/ var objectKeys = objectKeys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ var assert = require('assert'); var kLimit = Symbol('limit'); var kCallback = Symbol('callback'); -var common = require('./'); -var Countdown = /*#__PURE__*/function () { + +var Countdown = function () { function Countdown(limit, cb) { _classCallCheck(this, Countdown); + assert.strictEqual(typeof limit, 'number'); assert.strictEqual(typeof cb, 'function'); thiskLimit = limit; - thiskCallback = common.mustCall(cb); + thiskCallback = cb; } + + Countdown.prototype.dec = function dec() { + assert(thiskLimit > 0, 'Countdown expired'); + if (--thiskLimit === 0) thiskCallback(); + return thiskLimit; + }; + _createClass(Countdown, { - key: "dec", - value: function dec() { - assert(thiskLimit > 0, 'Countdown expired'); - if (--thiskLimit === 0) thiskCallback(); - return thiskLimit; - } - }, { - key: "remaining", - get: function get() { + key: 'remaining', + get: function () { return thiskLimit; } }); + return Countdown; }(); + module.exports = Countdown; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/dns.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/dns.js
Changed
@@ -1,29 +1,39 @@ -"use strict"; - -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && oSymbol.iterator || o"@@iterator"; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: oi++ }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } -function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2i = arri; return arr2; } -function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arrSymbol.iterator || arr"@@iterator"; if (null != _i) { var _s, _e, _x, _r, _arr = , _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } -function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = ; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arrSymbol.iterator(), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i"return") _i"return"(); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + /*<replacement>*/ -require('@babel/polyfill'); +require('babel-polyfill'); var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ +for (var i in util) { + exportsi = utili; +} /*</replacement>*/ /*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +/* eslint-disable required-modules */ 'use strict'; /*<replacement>*/ var objectKeys = objectKeys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ +// Naïve DNS parser/serializer. + var assert = require('assert'); var os = require('os'); + var types = { A: 1, AAAA: 28, @@ -35,35 +45,33 @@ TXT: 16, ANY: 255 }; + var classes = { IN: 1 }; -// Naïve DNS parser/serializer. - function readDomainFromPacket(buffer, offset) { assert.ok(offset < buffer.length); var length = bufferoffset; if (length === 0) { - return { - nread: 1, - domain: '' - }; + return { nread: 1, domain: '' }; } else if ((length & 0xC0) === 0) { offset += 1; var chunk = buffer.toString('ascii', offset, offset + length); // Read the rest of the domain. + var _readDomainFromPacket = readDomainFromPacket(buffer, offset + length), - nread = _readDomainFromPacket.nread, - domain = _readDomainFromPacket.domain; + nread = _readDomainFromPacket.nread, + domain = _readDomainFromPacket.domain; + return { nread: 1 + length + nread, - domain: domain ? "".concat(chunk, ".").concat(domain) : chunk + domain: domain ? chunk + '.' + domain : chunk }; } else { // Pointer to another part of the packet. assert.strictEqual(length & 0xC0, 0xC0); - // eslint-disable-next-line space-infix-ops, space-unary-ops + // eslint-disable-next-line var pointeeOffset = buffer.readUInt16BE(offset) & ~0xC000; return { nread: 2, @@ -71,116 +79,158 @@ }; } } + function parseDNSPacket(buffer) { assert.ok(buffer.length > 12); + var parsed = { id: buffer.readUInt16BE(0), flags: buffer.readUInt16BE(2) }; + var counts = 'questions', buffer.readUInt16BE(4), 'answers', buffer.readUInt16BE(6), 'authorityAnswers', buffer.readUInt16BE(8), 'additionalRecords', buffer.readUInt16BE(10); + var offset = 12; - for (var _i = 0, _counts = counts; _i < _counts.length; _i++) { - var _counts$_i = _slicedToArray(_counts_i, 2), - sectionName = _counts$_i0, - count = _counts$_i1; - parsedsectionName = ; - for (var _i2 = 0; _i2 < count; ++_i2) { - var _readDomainFromPacket2 = readDomainFromPacket(buffer, offset), - nread = _readDomainFromPacket2.nread, - domain = _readDomainFromPacket2.domain; - offset += nread; - var type = buffer.readUInt16BE(offset); - var rr = { - domain: domain, - cls: buffer.readUInt16BE(offset + 2) - }; - offset += 4; - for (var name in types) { - if (typesname === type) rr.type = name; - } - if (sectionName !== 'questions') { - rr.ttl = buffer.readInt32BE(offset); - var dataLength = buffer.readUInt16BE(offset); - offset += 6; - switch (type) { - case types.A: - assert.strictEqual(dataLength, 4); - rr.address = "".concat(bufferoffset + 0, ".").concat(bufferoffset + 1, ".") + "".concat(bufferoffset + 2, ".").concat(bufferoffset + 3); - break; - case types.AAAA: - assert.strictEqual(dataLength, 16); - rr.address = buffer.toString('hex', offset, offset + 16).replace(/(.{4}(?!$))/g, '$1:'); - break; - case types.TXT: - { - var position = offset; - rr.entries = ; - while (position < offset + dataLength) { - var txtLength = bufferoffset; - rr.entries.push(buffer.toString('utf8', position + 1, position + 1 + txtLength)); - position += 1 + txtLength; - } - assert.strictEqual(position, offset + dataLength); - break; - } - case types.MX: - { - rr.priority = buffer.readInt16BE(buffer, offset); - offset += 2; - var _readDomainFromPacket3 = readDomainFromPacket(buffer, offset), - _nread = _readDomainFromPacket3.nread, - _domain = _readDomainFromPacket3.domain; - rr.exchange = _domain; - assert.strictEqual(_nread, dataLength); - break; - } - case types.NS: - case types.CNAME: - case types.PTR: - { - var _readDomainFromPacket4 = readDomainFromPacket(buffer, offset), - _nread2 = _readDomainFromPacket4.nread, - _domain2 = _readDomainFromPacket4.domain; - rr.value = _domain2; - assert.strictEqual(_nread2, dataLength); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = countsSymbol.iterator(), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var _step$value = _slicedToArray(_step.value, 2), + sectionName = _step$value0, + count = _step$value1; + + parsedsectionName = ; + for (var _i = 0; _i < count; ++_i) { + var _readDomainFromPacket2 = readDomainFromPacket(buffer, offset), + nread = _readDomainFromPacket2.nread, + domain = _readDomainFromPacket2.domain; + + offset += nread; + + var type = buffer.readUInt16BE(offset); + + var rr = { + domain: domain, + cls: buffer.readUInt16BE(offset + 2) + }; + offset += 4; + + for (var name in types) { + if (typesname === type) rr.type = name; + } + + if (sectionName !== 'questions') { + rr.ttl = buffer.readInt32BE(offset); + var dataLength = buffer.readUInt16BE(offset); + offset += 6; + + switch (type) { + case types.A: + assert.strictEqual(dataLength, 4); + rr.address = bufferoffset + 0 + '.' + bufferoffset + 1 + '.' + (bufferoffset + 2 + '.' + bufferoffset + 3); break; - } - case types.SOA: - { - var mname = readDomainFromPacket(buffer, offset); - var rname = readDomainFromPacket(buffer, offset + mname.nread); - rr.nsname = mname.domain; - rr.hostmaster = rname.domain; - var trailerOffset = offset + mname.nread + rname.nread; - rr.serial = buffer.readUInt32BE(trailerOffset); - rr.refresh = buffer.readUInt32BE(trailerOffset + 4); - rr.retry = buffer.readUInt32BE(trailerOffset + 8); - rr.expire = buffer.readUInt32BE(trailerOffset + 12); - rr.minttl = buffer.readUInt32BE(trailerOffset + 16); - assert.strictEqual(trailerOffset + 20, dataLength); + case types.AAAA: + assert.strictEqual(dataLength, 16); + rr.address = buffer.toString('hex', offset, offset + 16).replace(/(.{4}(?!$))/g, '$1:'); break; - } - default: - throw new Error("Unknown RR type ".concat(rr.type)); + case types.TXT: + { + var position = offset; + rr.entries = ; + while (position < offset + dataLength) { + var txtLength = bufferoffset; + rr.entries.push(buffer.toString('utf8', position + 1, position + 1 + txtLength)); + position += 1 + txtLength; + } + assert.strictEqual(position, offset + dataLength); + break; + } + case types.MX: + { + rr.priority = buffer.readInt16BE(buffer, offset); + offset += 2; + + var _readDomainFromPacket3 = readDomainFromPacket(buffer, offset), + _nread = _readDomainFromPacket3.nread, + _domain = _readDomainFromPacket3.domain; + + rr.exchange = _domain; + assert.strictEqual(_nread, dataLength); + break; + } + case types.NS: + case types.CNAME: + case types.PTR: + { + var _readDomainFromPacket4 = readDomainFromPacket(buffer, offset), + _nread2 = _readDomainFromPacket4.nread, + _domain2 = _readDomainFromPacket4.domain; + + rr.value = _domain2; + assert.strictEqual(_nread2, dataLength); + break; + } + case types.SOA: + { + var mname = readDomainFromPacket(buffer, offset); + var rname = readDomainFromPacket(buffer, offset + mname.nread); + rr.nsname = mname.domain; + rr.hostmaster = rname.domain; + var trailerOffset = offset + mname.nread + rname.nread; + rr.serial = buffer.readUInt32BE(trailerOffset); + rr.refresh = buffer.readUInt32BE(trailerOffset + 4); + rr.retry = buffer.readUInt32BE(trailerOffset + 8); + rr.expire = buffer.readUInt32BE(trailerOffset + 12); + rr.minttl = buffer.readUInt32BE(trailerOffset + 16); + + assert.strictEqual(trailerOffset + 20, dataLength); + break; + } + default: + throw new Error('Unknown RR type ' + rr.type); + } + offset += dataLength; } - offset += dataLength; + + parsedsectionName.push(rr); + + assert.ok(offset <= buffer.length); + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; } - parsedsectionName.push(rr); - assert.ok(offset <= buffer.length); } } + assert.strictEqual(offset, buffer.length); return parsed; } + function writeIPv6(ip) { var parts = ip.replace(/^:|:$/g, '').split(':'); var buf = Buffer.alloc(16); + var offset = 0; - var _iterator = _createForOfIteratorHelper(parts), - _step; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var part = _step.value; + for (var _iterator2 = partsSymbol.iterator(), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var part = _step2.value; + if (part === '') { offset += 16 - 2 * (parts.length - 1); } else { @@ -189,48 +239,81 @@ } } } catch (err) { - _iterator.e(err); + _didIteratorError2 = true; + _iteratorError2 = err; } finally { - _iterator.f(); + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } } + return buf; } + function writeDomainName(domain) { return Buffer.concat(domain.split('.').map(function (label) { assert(label.length < 64); return Buffer.concat(Buffer.from(label.length), Buffer.from(label, 'ascii')); }).concat(Buffer.alloc(1))); } + function writeDNSPacket(parsed) { var buffers = ; var kStandardResponseFlags = 0x8180; + buffers.push(new Uint16Array(parsed.id, parsed.flags === undefined ? kStandardResponseFlags : parsed.flags, parsed.questions && parsed.questions.length, parsed.answers && parsed.answers.length, parsed.authorityAnswers && parsed.authorityAnswers.length, parsed.additionalRecords && parsed.additionalRecords.length)); - var _iterator2 = _createForOfIteratorHelper(parsed.questions), - _step2; + + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var q = _step2.value; + for (var _iterator3 = parsed.questionsSymbol.iterator(), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var q = _step3.value; + assert(typesq.type); buffers.push(writeDomainName(q.domain)); buffers.push(new Uint16Array(typesq.type, q.cls === undefined ? classes.IN : q.cls)); } } catch (err) { - _iterator2.e(err); + _didIteratorError3 = true; + _iteratorError3 = err; } finally { - _iterator2.f(); + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } } - var _iterator3 = _createForOfIteratorHelper(.concat(parsed.answers, parsed.authorityAnswers, parsed.additionalRecords)), - _step3; + + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var rr = _step3.value; + for (var _iterator4 = .concat(parsed.answers, parsed.authorityAnswers, parsed.additionalRecords)Symbol.iterator(), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var rr = _step4.value; + if (!rr) continue; + assert(typesrr.type); buffers.push(writeDomainName(rr.domain)); buffers.push(new Uint16Array(typesrr.type, rr.cls === undefined ? classes.IN : rr.cls)); buffers.push(new Int32Array(rr.ttl)); + var rdLengthBuf = new Uint16Array(1); buffers.push(rdLengthBuf); + switch (rr.type) { case 'A': rdLengthBuf0 = 4; @@ -248,19 +331,32 @@ }); // Total length of all strings + 1 byte each for their lengths. rdLengthBuf0 = rr.entries.length + total; - var _iterator4 = _createForOfIteratorHelper(rr.entries), - _step4; + var _iteratorNormalCompletion5 = true; + var _didIteratorError5 = false; + var _iteratorError5 = undefined; + try { - for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { - var txt = _step4.value; + for (var _iterator5 = rr.entriesSymbol.iterator(), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { + var txt = _step5.value; + buffers.push(new Uint8Array(Buffer.byteLength(txt))); buffers.push(Buffer.from(txt)); } } catch (err) { - _iterator4.e(err); + _didIteratorError5 = true; + _iteratorError5 = err; } finally { - _iterator4.f(); + try { + if (!_iteratorNormalCompletion5 && _iterator5.return) { + _iterator5.return(); + } + } finally { + if (_didIteratorError5) { + throw _iteratorError5; + } + } } + break; case 'MX': rdLengthBuf0 = 2; @@ -285,14 +381,24 @@ break; } default: - throw new Error("Unknown RR type ".concat(rr.type)); + throw new Error('Unknown RR type ' + rr.type); } } } catch (err) { - _iterator3.e(err); + _didIteratorError4 = true; + _iteratorError4 = err; } finally { - _iterator3.f(); + try { + if (!_iteratorNormalCompletion4 && _iterator4.return) { + _iterator4.return(); + } + } finally { + if (_didIteratorError4) { + throw _iteratorError4; + } + } } + return Buffer.concat(buffers.map(function (typedArray) { var buf = Buffer.from(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); if (os.endianness() === 'LE') { @@ -302,29 +408,9 @@ return buf; })); } -var mockedErrorCode = 'ENOTFOUND'; -var mockedSysCall = 'getaddrinfo'; -function errorLookupMock() { - var code = arguments.length > 0 && arguments0 !== undefined ? arguments0 : mockedErrorCode; - var syscall = arguments.length > 1 && arguments1 !== undefined ? arguments1 : mockedSysCall; - return function lookupWithError(hostname, dnsopts, cb) { - var err = new Error("".concat(syscall, " ").concat(code, " ").concat(hostname)); - err.code = code; - err.errno = code; - err.syscall = syscall; - err.hostname = hostname; - cb(err); - }; -} -module.exports = { - types: types, - classes: classes, - writeDNSPacket: writeDNSPacket, - parseDNSPacket: parseDNSPacket, - errorLookupMock: errorLookupMock, - mockedErrorCode: mockedErrorCode, - mockedSysCall: mockedSysCall -}; + +module.exports = { types: types, classes: classes, writeDNSPacket: writeDNSPacket, parseDNSPacket: parseDNSPacket }; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/duplexpair.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/duplexpair.js
Changed
@@ -1,85 +1,92 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /*<replacement>*/ -require('@babel/polyfill'); +require('babel-polyfill'); var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ +for (var i in util) { + exportsi = utili; +} /*</replacement>*/ /*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +/* eslint-disable required-modules */ 'use strict'; /*<replacement>*/ var objectKeys = objectKeys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ var _require = require('../../'), - Duplex = _require.Duplex; + Duplex = _require.Duplex; + var assert = require('assert'); + var kCallback = Symbol('Callback'); var kOtherSide = Symbol('Other'); -var DuplexSocket = /*#__PURE__*/function (_Duplex) { + +var DuplexSocket = function (_Duplex) { _inherits(DuplexSocket, _Duplex); - var _super = _createSuper(DuplexSocket); + function DuplexSocket() { - var _this; _classCallCheck(this, DuplexSocket); - _this = _super.call(this); + + var _this = _possibleConstructorReturn(this, _Duplex.call(this)); + _thiskCallback = null; _thiskOtherSide = null; return _this; } - _createClass(DuplexSocket, { - key: "_read", - value: function _read() { - var callback = thiskCallback; - if (callback) { - thiskCallback = null; - callback(); - } - } - }, { - key: "_write", - value: function _write(chunk, encoding, callback) { - assert.notStrictEqual(thiskOtherSide, null); - assert.strictEqual(thiskOtherSidekCallback, null); - thiskOtherSidekCallback = callback; - thiskOtherSide.push(chunk); - } - }, { - key: "_final", - value: function _final(callback) { - thiskOtherSide.on('end', callback); - thiskOtherSide.push(null); + + DuplexSocket.prototype._read = function _read() { + var callback = thiskCallback; + if (callback) { + thiskCallback = null; + callback(); } - }); + }; + + DuplexSocket.prototype._write = function _write(chunk, encoding, callback) { + assert.notStrictEqual(thiskOtherSide, null); + assert.strictEqual(thiskOtherSidekCallback, null); + thiskOtherSidekCallback = callback; + thiskOtherSide.push(chunk); + }; + + DuplexSocket.prototype._final = function _final(callback) { + thiskOtherSide.on('end', callback); + thiskOtherSide.push(null); + }; + return DuplexSocket; }(Duplex); + function makeDuplexPair() { var clientSide = new DuplexSocket(); var serverSide = new DuplexSocket(); clientSidekOtherSide = serverSide; serverSidekOtherSide = clientSide; - return { - clientSide: clientSide, - serverSide: serverSide - }; + return { clientSide: clientSide, serverSide: serverSide }; } + module.exports = makeDuplexPair; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/fixtures.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/fixtures.js
Changed
@@ -1,48 +1,63 @@ -"use strict"; - -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iterSymbol.iterator != null || iter"@@iterator" != null) return Array.from(iter); } -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2i = arri; return arr2; } +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2i = arri; } return arr2; } else { return Array.from(arr); } } + /*<replacement>*/ -require('@babel/polyfill'); +require('babel-polyfill'); var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ +for (var i in util) { + exportsi = utili; +} /*</replacement>*/ /*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +/* eslint-disable required-modules */ 'use strict'; /*<replacement>*/ var objectKeys = objectKeys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ var path = require('path'); var fs = require('fs'); + var fixturesDir = path.join(__dirname, '..', 'fixtures'); + function fixturesPath() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args_key = arguments_key; } + return path.join.apply(path, fixturesDir.concat(args)); } + function readFixtureSync(args, enc) { - if (Array.isArray(args)) return fs.readFileSync(fixturesPath.apply(void 0, _toConsumableArray(args)), enc); + if (Array.isArray(args)) return fs.readFileSync(fixturesPath.apply(undefined, _toConsumableArray(args)), enc); return fs.readFileSync(fixturesPath(args), enc); } + function readFixtureKey(name, enc) { return fs.readFileSync(fixturesPath('keys', name), enc); } + module.exports = { fixturesDir: fixturesDir, path: fixturesPath, readSync: readFixtureSync, readKey: readFixtureKey }; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/index.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/index.js
Changed
@@ -1,23 +1,25 @@ -"use strict"; - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { objkey = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } -function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iterSymbol.iterator != null || iter"@@iterator" != null) return Array.from(iter); } -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && oSymbol.iterator || o"@@iterator"; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: oi++ }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2i = arri; return arr2; } +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { objkey = value; } return obj; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2i = arri; } return arr2; } else { return Array.from(arr); } } + /*<replacement>*/ -require('@babel/polyfill'); +require('babel-polyfill'); var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ // Copyright Joyent, Inc. and other Node contributors. +for (var i in util) { + exportsi = utili; +} /*</replacement>*/ /*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +// Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the @@ -38,124 +40,100 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -/* eslint-disable node-core/required-modules, node-core/crypto-check */ +/* eslint-disable required-modules, crypto-check */ 'use strict'; /*<replacement>*/ var objectKeys = objectKeys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ -var process = global.process; // Some tests tamper with the process global. var path = require('path'); var fs = require('fs'); var assert = require('assert'); var os = require('os'); + var _require = require('child_process'), - exec = _require.exec, - execSync = _require.execSync, - spawnSync = _require.spawnSync; + exec = _require.exec, + execSync = _require.execSync, + spawn = _require.spawn, + spawnSync = _require.spawnSync; + +var stream = require('../../'); /*<replacement>*/ var util = require('core-util-is'); util.inherits = require('inherits'); /*</replacement>*/ -var Timer = { - now: function now() {} -}; -var tmpdir = require('./tmpdir'); -var _process$binding = process.binding('config'), - bits = _process$binding.bits, - hasIntl = _process$binding.hasIntl; -var noop = function noop() {}; -var hasCrypto = true; -var isMainThread = function () { - if (false) { - return require('worker_threads').isMainThread; - } - // Worker module not enabled → only a single main thread exists. - return true; -}(); - -// Check for flags. Skip this for workers (both, the `cluster` module and -// `worker_threads`) and child processes. -if (false && isMainThread && module.parent && require('cluster').isMaster) { - // The copyright notice is relatively big and the flags could come afterwards. - var bytesToRead = 1500; - var buffer = Buffer.allocUnsafe(bytesToRead); - var fd = fs.openSync(module.parent.filename, 'r'); - var bytesRead = fs.readSync(fd, buffer, 0, bytesToRead); - fs.closeSync(fd); - var source = buffer.toString('utf8', 0, bytesRead); - var flagStart = source.indexOf('// Flags: --') + 10; - if (flagStart !== 9) { - var flagEnd = source.indexOf('\n', flagStart); - // Normalize different EOL. - if (sourceflagEnd - 1 === '\r') { - flagEnd--; - } - var flags = source.substring(flagStart, flagEnd).replace(/_/g, '-').split(' '); - var args = process.execArgv.map(function (arg) { - return arg.replace(/_/g, '-'); - }); - var _iterator = _createForOfIteratorHelper(flags), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var flag = _step.value; - if (!args.includes(flag) && - // If the binary was built without-ssl then the crypto flags are - // invalid (bad option). The test itself should handle this case. - hasCrypto && ( - // If the binary is build without `intl` the inspect option is - // invalid. The test itself should handle this case. - process.config.variables.v8_enable_inspector !== 0 || !flag.startsWith('--inspect'))) { - throw new Error("Test has to be started with the flag: '".concat(flag, "'")); - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - } +var Timer = { now: function () {} }; + +var _require2 = require('./fixtures'), + fixturesDir = _require2.fixturesDir; + +var testRoot = process.env.NODE_TEST_DIR ? fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..'); + +var noop = function () {}; + +// Using a `.` prefixed name, which is the convention for "hidden" on POSIX, +// gets tools to ignore it by default or by simple rules, especially eslint. +var tmpDirName = '.tmp'; +// PORT should match the definition in test/testpy/__init__.py. +exports.PORT = +process.env.NODE_COMMON_PORT || 12346; +exports.isWindows = process.platform === 'win32'; +exports.isWOW64 = exports.isWindows && process.env.PROCESSOR_ARCHITEW6432 !== undefined; +exports.isAIX = process.platform === 'aix'; +exports.isLinuxPPCBE = process.platform === 'linux' && process.arch === 'ppc64' && os.endianness() === 'BE'; +exports.isSunOS = process.platform === 'sunos'; +exports.isFreeBSD = process.platform === 'freebsd'; +exports.isLinux = process.platform === 'linux'; +exports.isOSX = process.platform === 'darwin'; + +exports.enoughTestMem = os.totalmem() > 0x70000000; /* 1.75 Gb */ +var cpus = os.cpus(); +/*exports.enoughTestCpu = Array.isArray(cpus) && + (cpus.length > 1 || cpus0.speed > 999);*/ + +exports.rootDir = exports.isWindows ? 'c:\\' : '/'; +exports.projectDir = path.resolve(__dirname, '..', '..'); + +//exports.buildType = process.config.target_defaults.default_configuration; + +// Always enable async_hooks checks in tests +{ + // const async_wrap = process.binding('async_wrap'); + // const kCheck = async_wrap.constants.kCheck; + // async_wrap.async_hook_fieldskCheck += 1; + + exports.revert_force_async_hooks_checks = function () { + async_wrap.async_hook_fieldskCheck -= 1; + }; } -var isWindows = process.platform === 'win32'; -var isAIX = process.platform === 'aix'; -var isLinuxPPCBE = process.platform === 'linux' && process.arch === 'ppc64' && os.endianness() === 'BE'; -var isSunOS = process.platform === 'sunos'; -var isFreeBSD = process.platform === 'freebsd'; -var isOpenBSD = process.platform === 'openbsd'; -var isLinux = process.platform === 'linux'; -var isOSX = process.platform === 'darwin'; -var enoughTestMem = os.totalmem() > 0x70000000; /* 1.75 Gb */ -var cpus = os.cpus().length === 0 ? { - speed: 1000 -} : os.cpus(); -var enoughTestCpu = Array.isArray(cpus) && (cpus.length > 1 || cpus0.speed > 999); -var rootDir = isWindows ? 'c:\\' : '/'; -var buildType = 'readable-stream'; // If env var is set then enable async_hook hooks for all tests. if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) { var destroydIdsList = {}; var destroyListList = {}; var initHandles = {}; - var async_wrap = process.binding('async_wrap'); + var _async_wrap = process.binding('async_wrap'); + process.on('exit', function () { - // iterate through handles to make sure nothing crashes - for (var k in initHandles) util.inspect(initHandlesk); + // itterate through handles to make sure nothing crashes + for (var k in initHandles) { + util.inspect(initHandlesk); + } }); - var _queueDestroyAsyncId = async_wrap.queueDestroyAsyncId; - async_wrap.queueDestroyAsyncId = function queueDestroyAsyncId(id) { + + var _queueDestroyAsyncId = _async_wrap.queueDestroyAsyncId; + _async_wrap.queueDestroyAsyncId = function queueDestroyAsyncId(id) { if (destroyListListid !== undefined) { process._rawDebug(destroyListListid); process._rawDebug(); - throw new Error("same id added to destroy list twice (".concat(id, ")")); + throw new Error('same id added to destroy list twice (' + id + ')'); } destroyListListid = new Error().stack; _queueDestroyAsyncId(id); @@ -184,77 +162,238 @@ }).enable();*/ } +function rimrafSync(p) { + var st = void 0; + try { + st = fs.lstatSync(p); + } catch (e) { + if (e.code === 'ENOENT') return; + } + + try { + if (st && st.isDirectory()) rmdirSync(p, null);else fs.unlinkSync(p); + } catch (e) { + if (e.code === 'ENOENT') return; + if (e.code === 'EPERM') return rmdirSync(p, e); + if (e.code !== 'EISDIR') throw e; + rmdirSync(p, e); + } +} + +function rmdirSync(p, originalEr) { + try { + fs.rmdirSync(p); + } catch (e) { + if (e.code === 'ENOTDIR') throw originalEr; + if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') { + var enc = exports.isLinux ? 'buffer' : 'utf8'; + forEach(fs.readdirSync(p, enc), function (f) { + if (f instanceof Buffer) { + var buf = Buffer.concat(Buffer.from(p), Buffer.from(path.sep), f); + rimrafSync(buf); + } else { + rimrafSync(path.join(p, f)); + } + }); + fs.rmdirSync(p); + } + } +} + +exports.refreshTmpDir = function () { + rimrafSync(exports.tmpDir); + fs.mkdirSync(exports.tmpDir); +}; + +if (process.env.TEST_THREAD_ID) { + exports.PORT += process.env.TEST_THREAD_ID * 100; + tmpDirName += '.' + process.env.TEST_THREAD_ID; +} +exports.tmpDir = path.join(testRoot, tmpDirName); + var opensslCli = null; var inFreeBSDJail = null; var localhostIPv4 = null; -var localIPv6Hosts = isLinux ? -// Debian/Ubuntu -'ip6-localhost', 'ip6-loopback', -// SUSE -'ipv6-localhost', 'ipv6-loopback', -// Typically universal -'localhost' : 'localhost'; -var PIPE = function () { - var localRelative = path.relative(process.cwd(), "".concat(tmpdir.path, "/")); - var pipePrefix = isWindows ? '\\\\.\\pipe\\' : localRelative; - var pipeName = "node-test.".concat(process.pid, ".sock"); - return path.join(pipePrefix, pipeName); -}(); -var hasIPv6 = function () { + +exports.localIPv6Hosts = 'localhost'; +if (exports.isLinux) { + exports.localIPv6Hosts = + // Debian/Ubuntu + 'ip6-localhost', 'ip6-loopback', + + // SUSE + 'ipv6-localhost', 'ipv6-loopback', + + // Typically universal + 'localhost'; +} + +/*<replacement>*/if (!process.browser) { + Object.defineProperty(exports, 'inFreeBSDJail', { + get: function () { + if (inFreeBSDJail !== null) return inFreeBSDJail; + + if (exports.isFreeBSD && execSync('sysctl -n security.jail.jailed').toString() === '1\n') { + inFreeBSDJail = true; + } else { + inFreeBSDJail = false; + } + return inFreeBSDJail; + } + }); +} /*</replacement>*/ + +/*<replacement>*/if (!process.browser) { + Object.defineProperty(exports, 'localhostIPv4', { + get: function () { + if (localhostIPv4 !== null) return localhostIPv4; + + if (exports.inFreeBSDJail) { + // Jailed network interfaces are a bit special - since we need to jump + // through loops, as well as this being an exception case, assume the + // user will provide this instead. + if (process.env.LOCALHOST) { + localhostIPv4 = process.env.LOCALHOST; + } else { + console.error('Looks like we\'re in a FreeBSD Jail. ' + 'Please provide your default interface address ' + 'as LOCALHOST or expect some tests to fail.'); + } + } + + if (localhostIPv4 === null) localhostIPv4 = '127.0.0.1'; + + return localhostIPv4; + } + }); +} /*</replacement>*/ + +// opensslCli defined lazily to reduce overhead of spawnSync +/*<replacement>*/if (!process.browser) { + Object.defineProperty(exports, 'opensslCli', { get: function () { + if (opensslCli !== null) return opensslCli; + + if (process.config.variables.node_shared_openssl) { + // use external command + opensslCli = 'openssl'; + } else { + // use command built from sources included in Node.js repository + opensslCli = path.join(path.dirname(process.execPath), 'openssl-cli'); + } + + if (exports.isWindows) opensslCli += '.exe'; + + var opensslCmd = spawnSync(opensslCli, 'version'); + if (opensslCmd.status !== 0 || opensslCmd.error !== undefined) { + // openssl command cannot be executed + opensslCli = false; + } + return opensslCli; + }, enumerable: true }); +} /*</replacement>*/ + +/*<replacement>*/if (!process.browser) { + Object.defineProperty(exports, 'hasCrypto', { + get: function () { + return Boolean(process.versions.openssl); + } + }); +} /*</replacement>*/ + +/*<replacement>*/if (!process.browser) { + Object.defineProperty(exports, 'hasFipsCrypto', { + get: function () { + return exports.hasCrypto && require('crypto').fips; + } + }); +} /*</replacement>*/ + +{ + var localRelative = path.relative(process.cwd(), exports.tmpDir + '/'); + var pipePrefix = exports.isWindows ? '\\\\.\\pipe\\' : localRelative; + var pipeName = 'node-test.' + process.pid + '.sock'; + exports.PIPE = path.join(pipePrefix, pipeName); +} + +{ var iFaces = os.networkInterfaces(); - var re = isWindows ? /Loopback Pseudo-Interface/ : /lo/; - return objectKeys(iFaces).some(function (name) { - return re.test(name) && iFacesname.some(function (_ref) { - var family = _ref.family; - return family === 'IPv6'; + var re = exports.isWindows ? /Loopback Pseudo-Interface/ : /lo/; + exports.hasIPv6 = objectKeys(iFaces).some(function (name) { + return re.test(name) && iFacesname.some(function (info) { + return info.family === 'IPv6'; }); }); -}(); +} /* * Check that when running a test with * `$node --abort-on-uncaught-exception $file child` * the process aborts. */ -function childShouldThrowAndAbort() { +exports.childShouldThrowAndAbort = function () { var testCmd = ''; - if (!isWindows) { + if (!exports.isWindows) { // Do not create core files, as it can take a lot of disk space on // continuous testing and developers' machines testCmd += 'ulimit -c 0 && '; } - testCmd += "\"".concat(process.argv0, "\" --abort-on-uncaught-exception "); - testCmd += "\"".concat(process.argv1, "\" child"); + testCmd += '"' + process.argv0 + '" --abort-on-uncaught-exception '; + testCmd += '"' + process.argv1 + '" child'; var child = exec(testCmd); child.on('exit', function onExit(exitCode, signal) { - var errMsg = 'Test should have aborted ' + "but instead exited with exit code ".concat(exitCode) + " and signal ".concat(signal); - assert(nodeProcessAborted(exitCode, signal), errMsg); + var errMsg = 'Test should have aborted ' + ('but instead exited with exit code ' + exitCode) + (' and signal ' + signal); + assert(exports.nodeProcessAborted(exitCode, signal), errMsg); }); -} -function createZeroFilledFile(filename) { - var fd = fs.openSync(filename, 'w'); - fs.ftruncateSync(fd, 10 * 1024 * 1024); - fs.closeSync(fd); -} -var pwdCommand = isWindows ? 'cmd.exe', '/d', '/c', 'cd' : 'pwd', ; -function platformTimeout(ms) { +}; + +exports.ddCommand = function (filename, kilobytes) { + if (exports.isWindows) { + var p = path.resolve(fixturesDir, 'create-file.js'); + return '"' + process.argv0 + '" "' + p + '" "' + filename + '" ' + kilobytes * 1024; + } else { + return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes; + } +}; + +exports.spawnPwd = function (options) { + if (exports.isWindows) { + return spawn('cmd.exe', '/d', '/c', 'cd', options); + } else { + return spawn('pwd', , options); + } +}; + +exports.spawnSyncPwd = function (options) { + if (exports.isWindows) { + return spawnSync('cmd.exe', '/d', '/c', 'cd', options); + } else { + return spawnSync('pwd', , options); + } +}; + +exports.platformTimeout = function (ms) { if (process.features.debug) ms = 2 * ms; + if (global.__coverage__) ms = 4 * ms; - if (isAIX) return 2 * ms; // default localhost speed is slower on AIX + + if (exports.isAIX) return 2 * ms; // default localhost speed is slower on AIX if (process.arch !== 'arm') return ms; + var armv = process.config.variables.arm_version; + if (armv === '6') return 7 * ms; // ARMv6 if (armv === '7') return 2 * ms; // ARMv7 return ms; // ARMv8+ -} +}; + +var knownGlobals = Buffer, clearImmediate, clearInterval, clearTimeout, console, constructor, // Enumerable in V8 3.21. +global, process, setImmediate, setInterval, setTimeout; -var knownGlobals = Buffer, clearImmediate, clearInterval, clearTimeout, global, process, setImmediate, setInterval, setTimeout; if (global.gc) { knownGlobals.push(global.gc); } + if (global.DTRACE_HTTP_SERVER_RESPONSE) { knownGlobals.push(DTRACE_HTTP_SERVER_RESPONSE); knownGlobals.push(DTRACE_HTTP_SERVER_REQUEST); @@ -263,6 +402,7 @@ knownGlobals.push(DTRACE_NET_STREAM_END); knownGlobals.push(DTRACE_NET_SERVER_CONNECTION); } + if (global.COUNTER_NET_SERVER_CONNECTION) { knownGlobals.push(COUNTER_NET_SERVER_CONNECTION); knownGlobals.push(COUNTER_NET_SERVER_CONNECTION_CLOSE); @@ -271,23 +411,61 @@ knownGlobals.push(COUNTER_HTTP_CLIENT_REQUEST); knownGlobals.push(COUNTER_HTTP_CLIENT_RESPONSE); } + +if (global.LTTNG_HTTP_SERVER_RESPONSE) { + knownGlobals.push(LTTNG_HTTP_SERVER_RESPONSE); + knownGlobals.push(LTTNG_HTTP_SERVER_REQUEST); + knownGlobals.push(LTTNG_HTTP_CLIENT_RESPONSE); + knownGlobals.push(LTTNG_HTTP_CLIENT_REQUEST); + knownGlobals.push(LTTNG_NET_STREAM_END); + knownGlobals.push(LTTNG_NET_SERVER_CONNECTION); +} + +/*<replacement>*/if (!process.browser) { + if (global.ArrayBuffer) { + knownGlobals.push(ArrayBuffer); + knownGlobals.push(Int8Array); + knownGlobals.push(Uint8Array); + knownGlobals.push(Uint8ClampedArray); + knownGlobals.push(Int16Array); + knownGlobals.push(Uint16Array); + knownGlobals.push(Int32Array); + knownGlobals.push(Uint32Array); + knownGlobals.push(Float32Array); + knownGlobals.push(Float64Array); + knownGlobals.push(DataView); + } +} /*</replacement>*/ + +// Harmony features. +if (global.Proxy) { + knownGlobals.push(Proxy); +} + +if (global.Symbol) { + knownGlobals.push(Symbol); +} + if (process.env.NODE_TEST_KNOWN_GLOBALS) { var knownFromEnv = process.env.NODE_TEST_KNOWN_GLOBALS.split(','); - allowGlobals.apply(void 0, _toConsumableArray(knownFromEnv)); + allowGlobals.apply(undefined, _toConsumableArray(knownFromEnv)); } + function allowGlobals() { - for (var _len = arguments.length, whitelist = new Array(_len), _key = 0; _key < _len; _key++) { + for (var _len = arguments.length, whitelist = Array(_len), _key = 0; _key < _len; _key++) { whitelist_key = arguments_key; } + knownGlobals = knownGlobals.concat(whitelist); } +exports.allowGlobals = allowGlobals; /*<replacement>*/ if (typeof constructor == 'function') knownGlobals.push(constructor); if (typeof DTRACE_NET_SOCKET_READ == 'function') knownGlobals.push(DTRACE_NET_SOCKET_READ); if (typeof DTRACE_NET_SOCKET_WRITE == 'function') knownGlobals.push(DTRACE_NET_SOCKET_WRITE); if (global.__coverage__) knownGlobals.push(__coverage__); -'console,clearImmediate,setImmediate,core,__core-js_shared__,Promise,Map,Set,WeakMap,WeakSet,Reflect,System,queueMicrotask,asap,Observable,regeneratorRuntime,_babelPolyfill'.split(',').filter(function (item) { +'core,__core-js_shared__,Promise,Map,Set,WeakMap,WeakSet,Reflect,System,asap,Observable,regeneratorRuntime,_babelPolyfill'.split(',').filter(function (item) { return typeof globalitem !== undefined; }).forEach(function (item) { knownGlobals.push(globalitem); @@ -295,11 +473,13 @@ function leakedGlobals() { var leaked = ; + for (var val in global) { if (!knownGlobals.includes(globalval)) { leaked.push(val); } } + if (global.__coverage__) { return leaked.filter(function (varname) { return !/^(?:cov_|__cov)/.test(varname); @@ -308,40 +488,56 @@ return leaked; } } +exports.leakedGlobals = leakedGlobals; + +// Turn this off if the test should not check for global leaks. +exports.globalCheck = true; + process.on('exit', function () { + if (!exports.globalCheck) return; var leaked = leakedGlobals(); if (leaked.length > 0) { - assert.fail("Unexpected global(s) found: ".concat(leaked.join(', '))); + assert.fail('Unexpected global(s) found: ' + leaked.join(', ')); } }); + var mustCallChecks = ; + function runCallChecks(exitCode) { if (exitCode !== 0) return; + var failed = mustCallChecks.filter(function (context) { if ('minimum' in context) { - context.messageSegment = "at least ".concat(context.minimum); + context.messageSegment = 'at least ' + context.minimum; return context.actual < context.minimum; } else { - context.messageSegment = "exactly ".concat(context.exact); + context.messageSegment = 'exactly ' + context.exact; return context.actual !== context.exact; } }); + forEach(failed, function (context) { console.log('Mismatched %s function calls. Expected %s, actual %d.', context.name, context.messageSegment, context.actual); console.log(context.stack.split('\n').slice(2).join('\n')); }); + if (failed.length) process.exit(1); } -function mustCall(fn, exact) { + +exports.mustCall = function (fn, exact) { return _mustCallInner(fn, exact, 'exact'); -} -function mustCallAtLeast(fn, minimum) { +}; + +exports.mustCallAtLeast = function (fn, minimum) { return _mustCallInner(fn, minimum, 'minimum'); -} +}; + function _mustCallInner(fn) { var _context; + var criteria = arguments.length > 1 && arguments1 !== undefined ? arguments1 : 1; - var field = arguments.length > 2 ? arguments2 : undefined; + var field = arguments2; + if (process._exiting) throw new Error('Cannot use common.mustCall*() in process exit handler'); if (typeof fn === 'number') { criteria = fn; @@ -349,56 +545,79 @@ } else if (fn === undefined) { fn = noop; } - if (typeof criteria !== 'number') throw new TypeError("Invalid ".concat(field, " value: ").concat(criteria)); - var context = (_context = {}, _defineProperty(_context, field, criteria), _defineProperty(_context, "actual", 0), _defineProperty(_context, "stack", new Error().stack), _defineProperty(_context, "name", fn.name || '<anonymous>'), _context); + + if (typeof criteria !== 'number') throw new TypeError('Invalid ' + field + ' value: ' + criteria); + + var context = (_context = {}, _defineProperty(_context, field, criteria), _defineProperty(_context, 'actual', 0), _defineProperty(_context, 'stack', new Error().stack), _defineProperty(_context, 'name', fn.name || '<anonymous>'), _context); // add the exit listener only once to avoid listener leak warnings if (mustCallChecks.length === 0) process.on('exit', runCallChecks); + mustCallChecks.push(context); + return function () { context.actual++; return fn.apply(this, arguments); }; } -function hasMultiLocalhost() { - var _process$binding2 = process.binding('tcp_wrap'), - TCP = _process$binding2.TCP, - TCPConstants = _process$binding2.constants; + +exports.hasMultiLocalhost = function hasMultiLocalhost() { + var _process$binding = process.binding('tcp_wrap'), + TCP = _process$binding.TCP, + TCPConstants = _process$binding.constants; + var t = new TCP(TCPConstants.SOCKET); var ret = t.bind('127.0.0.2', 0); t.close(); return ret === 0; -} -function skipIfEslintMissing() { - if (!fs.existsSync(path.join(__dirname, '..', '..', 'tools', 'node_modules', 'eslint'))) { - skip('missing ESLint'); +}; + +exports.fileExists = function (pathname) { + try { + fs.accessSync(pathname); + return true; + } catch (err) { + return false; } -} -function canCreateSymLink() { +}; + +exports.skipIfEslintMissing = function () { + if (!exports.fileExists(path.join('..', '..', 'tools', 'node_modules', 'eslint'))) { + exports.skip('missing ESLint'); + } +}; + +exports.canCreateSymLink = function () { // On Windows, creating symlinks requires admin privileges. // We'll only try to run symlink test if we have enough privileges. // On other platforms, creating symlinks shouldn't need admin privileges - if (isWindows) { + if (exports.isWindows) { // whoami.exe needs to be the one from System32 // If unix tools are in the path, they can shadow the one we want, // so use the full path while executing whoami - var whoamiPath = path.join(process.env.SystemRoot, 'System32', 'whoami.exe'); + var whoamiPath = path.join(process.env'SystemRoot', 'System32', 'whoami.exe'); + + var err = false; + var output = ''; + try { - var output = execSync("".concat(whoamiPath, " /priv"), { - timout: 1000 - }); - return output.includes('SeCreateSymbolicLinkPrivilege'); - } catch (_e) { - return false; + output = execSync(whoamiPath + ' /priv', { timout: 1000 }); + } catch (e) { + err = true; + } finally { + if (err || !output.includes('SeCreateSymbolicLinkPrivilege')) { + return false; + } } } - // On non-Windows platforms, this always returns `true` + return true; -} -function getCallSite(top) { +}; + +exports.getCallSite = function getCallSite(top) { var originalStackFormatter = Error.prepareStackTrace; Error.prepareStackTrace = function (err, stack) { - return "".concat(stack0.getFileName(), ":").concat(stack0.getLineNumber()); + return stack0.getFileName() + ':' + stack0.getLineNumber(); }; var err = new Error(); Error.captureStackTrace(err, top); @@ -406,25 +625,47 @@ err.stack; Error.prepareStackTrace = originalStackFormatter; return err.stack; -} -function mustNotCall(msg) { - var callSite = getCallSite(mustNotCall); +}; + +exports.mustNotCall = function (msg) { + var callSite = exports.getCallSite(exports.mustNotCall); return function mustNotCall() { - assert.fail("".concat(msg || 'function should not have been called', " at ").concat(callSite)); + assert.fail((msg || 'function should not have been called') + ' at ' + callSite); }; -} -function printSkipMessage(msg) { - console.log("1..0 # Skipped: ".concat(msg)); -} -function skip(msg) { - printSkipMessage(msg); +}; + +exports.printSkipMessage = function (msg) { + console.log('1..0 # Skipped: ' + msg); +}; + +exports.skip = function (msg) { + exports.printSkipMessage(msg); process.exit(0); +}; + +// A stream to push an array into a REPL +function ArrayStream() { + this.run = function (data) { + var _this = this; + + forEach(data, function (line) { + _this.emit('data', line + '\n'); + }); + }; } +util.inherits(ArrayStream, stream.Stream); +exports.ArrayStream = ArrayStream; +ArrayStream.prototype.readable = true; +ArrayStream.prototype.writable = true; +ArrayStream.prototype.pause = noop; +ArrayStream.prototype.resume = noop; +ArrayStream.prototype.write = noop; + // Returns true if the exit code "exitCode" and/or signal name "signal" // represent the exit code and/or signal name of a node process that aborted, // false otherwise. -function nodeProcessAborted(exitCode, signal) { +exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) { // Depending on the compiler used, node will exit with either // exit code 132 (SIGILL), 133 (SIGTRAP) or 134 (SIGABRT). var expectedExitCodes = 132, 133, 134; @@ -439,9 +680,9 @@ // On Windows, 'aborts' are of 2 types, depending on the context: // (i) Forced access violation, if --abort-on-uncaught-exception is on // which corresponds to exit code 3221225477 (0xC0000005) - // (ii) Otherwise, _exit(134) which is called in place of abort() due to - // raising SIGABRT exiting with ambiguous exit code '3' by default - if (isWindows) expectedExitCodes = 0xC0000005, 134; + // (ii) raise(SIGABRT) or abort(), which lands up in CRT library calls + // which corresponds to exit code 3. + if (exports.isWindows) expectedExitCodes = 3221225477, 3; // When using --abort-on-uncaught-exception, V8 will use // base::OS::Abort to terminate the process. @@ -455,52 +696,48 @@ } else { return expectedExitCodes.includes(exitCode); } -} -function busyLoop(time) { +}; + +exports.busyLoop = function busyLoop(time) { var startTime = Timer.now(); var stopTime = startTime + time; while (Timer.now() < stopTime) {} -} -function isAlive(pid) { +}; + +exports.isAlive = function isAlive(pid) { try { process.kill(pid, 'SIGCONT'); return true; - } catch (_unused) { + } catch (e) { return false; } -} -function _expectWarning(name, expected) { - var map = new Map(expected); - return mustCall(function (warning) { +}; + +function expectWarning(name, expectedMessages) { + return exports.mustCall(function (warning) { assert.strictEqual(warning.name, name); - assert.ok(map.has(warning.message), "unexpected error message: \"".concat(warning.message, "\"")); - var code = map.get(warning.message); - assert.strictEqual(warning.code, code); + assert.ok(expectedMessages.includes(warning.message), 'unexpected error message: "' + warning.message + '"'); // Remove a warning message after it is seen so that we guarantee that we // get each message only once. - map.delete(expected); - }, expected.length); + expectedMessages.splice(expectedMessages.indexOf(warning.message), 1); + }, expectedMessages.length); } -function expectWarningByName(name, expected, code) { + +function expectWarningByName(name, expected) { if (typeof expected === 'string') { - expected = expected, code; + expected = expected; } - process.on('warning', _expectWarning(name, expected)); + process.on('warning', expectWarning(name, expected)); } + function expectWarningByMap(warningMap) { var catchWarning = {}; forEach(objectKeys(warningMap), function (name) { var expected = warningMapname; - if (!Array.isArray(expected)) { - throw new Error('warningMap entries must be arrays consisting of two ' + 'entries: message, warningCode'); + if (typeof expected === 'string') { + expected = expected; } - if (!Array.isArray(expected0)) { - if (expected.length === 0) { - return; - } - expected = expected0, expected1; - } - catchWarningname = _expectWarning(name, expected); + catchWarningname = expectWarning(name, expected); }); process.on('warning', function (warning) { return catchWarningwarning.name(warning); @@ -510,95 +747,65 @@ // accepts a warning name and description or array of descriptions or a map // of warning names to description(s) // ensures a warning is generated for each name/description pair -function expectWarning(nameOrMap, expected, code) { +exports.expectWarning = function (nameOrMap, expected) { if (typeof nameOrMap === 'string') { - expectWarningByName(nameOrMap, expected, code); + expectWarningByName(nameOrMap, expected); } else { expectWarningByMap(nameOrMap); } -} -var Comparison = /*#__PURE__*/_createClass(function Comparison(obj, keys) { - _classCallCheck(this, Comparison); - var _iterator2 = _createForOfIteratorHelper(keys), - _step2; - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var key = _step2.value; - if (key in obj) thiskey = objkey; +}; + +/*<replacement>*/if (!process.browser) { + Object.defineProperty(exports, 'hasIntl', { + get: function () { + return process.binding('config').hasIntl; } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } -}); // Useful for testing expected internal/error objects -function expectsError(fn, settings, exact) { + }); +} /*</replacement>*/ + +/*<replacement>*/if (!process.browser) { + Object.defineProperty(exports, 'hasSmallICU', { + get: function () { + return process.binding('config').hasSmallICU; + } + }); +} /*</replacement>*/ + +// Useful for testing expected internal/error objects +exports.expectsError = function expectsError(fn, settings, exact) { if (typeof fn !== 'function') { exact = settings; settings = fn; fn = undefined; } function innerFn(error) { - if (arguments.length !== 1) { - // Do not use `assert.strictEqual()` to prevent `util.inspect` from - // always being called. - assert.fail("Expected one argument, got ".concat(util.inspect(arguments))); - } - var descriptor = Object.getOwnPropertyDescriptor(error, 'message'); - // The error message should be non-enumerable - assert.strictEqual(descriptor.enumerable, false); - var innerSettings = settings; + assert.strictEqual(error.code, settings.code); if ('type' in settings) { var type = settings.type; if (type !== Error && !Error.isPrototypeOf(type)) { throw new TypeError('`settings.type` must inherit from `Error`'); } - var _constructor = error.constructor; - if (_constructor.name === 'NodeError' && type.name !== 'NodeError') { - _constructor = Object.getPrototypeOf(error.constructor); + assert(error instanceof type, error.name + ' is not instance of ' + type.name); + } + if ('message' in settings) { + var message = settings.message; + if (typeof message === 'string') { + assert.strictEqual(error.message, message); + } else { + assert(message.test(error.message), error.message + ' does not match ' + message); } - // Add the `type` to the error to properly compare and visualize it. - if (!('type' in error)) error.type = _constructor; } - if ('message' in settings && typeof settings.message === 'object' && settings.message.test(error.message)) { - // Make a copy so we are able to modify the settings. - innerSettings = Object.create(settings, Object.getOwnPropertyDescriptors(settings)); - // Visualize the message as identical in case of other errors. - innerSettings.message = error.message; + if ('name' in settings) { + assert.strictEqual(error.name, settings.name); } - - // Check all error properties. - var keys = objectKeys(settings); - var _iterator3 = _createForOfIteratorHelper(keys), - _step3; - try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var key = _step3.value; - if (!require('deep-strict-equal')(errorkey, innerSettingskey)) { - // Create placeholder objects to create a nice output. - var a = new Comparison(error, keys); - var b = new Comparison(innerSettings, keys); - var tmpLimit = Error.stackTraceLimit; - Error.stackTraceLimit = 0; - var err = new assert.AssertionError({ - actual: a, - expected: b, - operator: 'strictEqual', - stackStartFn: assert.throws - }); - Error.stackTraceLimit = tmpLimit; - throw new assert.AssertionError({ - actual: error, - expected: settings, - operator: 'common.expectsError', - message: err.message - }); + if (error.constructor.name === 'AssertionError') { + forEach('generatedMessage', 'actual', 'expected', 'operator', function (key) { + if (key in settings) { + var actual = errorkey; + var expected = settingskey; + assert.strictEqual(actual, expected, key + ': expected ' + expected + ', not ' + actual); } - } - } catch (err) { - _iterator3.e(err); - } finally { - _iterator3.f(); + }); } return true; } @@ -606,182 +813,143 @@ assert.throws(fn, innerFn); return; } - return mustCall(innerFn, exact); -} -function skipIfInspectorDisabled() { + return exports.mustCall(innerFn, exact); +}; + +exports.skipIfInspectorDisabled = function skipIfInspectorDisabled() { if (process.config.variables.v8_enable_inspector === 0) { - skip('V8 inspector is disabled'); - } -} -function skipIf32Bits() { - if (bits < 64) { - skip('The tested feature is not available in 32bit builds'); + exports.skip('V8 inspector is disabled'); } -} -function skipIfWorker() { - if (!isMainThread) { - skip('This test only works on a main thread'); +}; + +exports.skipIf32Bits = function skipIf32Bits() { + if (process.binding('config').bits < 64) { + exports.skip('The tested feature is not available in 32bit builds'); } -} -function getArrayBufferViews(buf) { +}; + +exports.getArrayBufferViews = function getArrayBufferViews(buf) { var buffer = buf.buffer, - byteOffset = buf.byteOffset, - byteLength = buf.byteLength; + byteOffset = buf.byteOffset, + byteLength = buf.byteLength; + + var out = ; + var arrayBufferViews = Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, DataView; - for (var _i = 0, _arrayBufferViews = arrayBufferViews; _i < _arrayBufferViews.length; _i++) { - var type = _arrayBufferViews_i; - var _type$BYTES_PER_ELEME = type.BYTES_PER_ELEMENT, - BYTES_PER_ELEMENT = _type$BYTES_PER_ELEME === void 0 ? 1 : _type$BYTES_PER_ELEME; - if (byteLength % BYTES_PER_ELEMENT === 0) { - out.push(new type(buffer, byteOffset, byteLength / BYTES_PER_ELEMENT)); + + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = arrayBufferViewsSymbol.iterator(), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var type = _step.value; + var _type$BYTES_PER_ELEME = type.BYTES_PER_ELEMENT, + BYTES_PER_ELEMENT = _type$BYTES_PER_ELEME === undefined ? 1 : _type$BYTES_PER_ELEME; + + if (byteLength % BYTES_PER_ELEMENT === 0) { + out.push(new type(buffer, byteOffset, byteLength / BYTES_PER_ELEMENT)); + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } } } + return out; -} -function getBufferSources(buf) { - return .concat(_toConsumableArray(getArrayBufferViews(buf)), new Uint8Array(buf).buffer); -} +}; // Crash the process on unhandled rejections. -var crashOnUnhandledRejection = function crashOnUnhandledRejection(err) { - throw err; +exports.crashOnUnhandledRejection = function () { + process.on('unhandledRejection', function (err) { + return process.nextTick(function () { + throw err; + }); + }); }; -process.on('unhandledRejection', crashOnUnhandledRejection); -function disableCrashOnUnhandledRejection() { - process.removeListener('unhandledRejection', crashOnUnhandledRejection); -} -function getTTYfd() { - // Do our best to grab a tty fd. + +exports.getTTYfd = function getTTYfd() { var tty = require('tty'); - // Don't attempt fd 0 as it is not writable on Windows. - // Ref: ef2861961c3d9e9ed6972e1e84d969683b25cf95 - var ttyFd = 1, 2, 4, 5.find(tty.isatty); - if (ttyFd === undefined) { + var tty_fd = 0; + if (!tty.isatty(tty_fd)) tty_fd++;else if (!tty.isatty(tty_fd)) tty_fd++;else if (!tty.isatty(tty_fd)) tty_fd++;else { try { - return fs.openSync('/dev/tty'); - } catch (_unused2) { + tty_fd = fs.openSync('/dev/tty'); + } catch (e) { // There aren't any tty fd's available to use. return -1; } } - return ttyFd; + return tty_fd; +}; + +// Hijack stdout and stderr +var stdWrite = {}; +function hijackStdWritable(name, listener) { + var stream = processname; + var _write = stdWritename = stream.write; + + stream.writeTimes = 0; + stream.write = function (data, callback) { + try { + listener(data); + } catch (e) { + process.nextTick(function () { + throw e; + }); + } + + _write.call(stream, data, callback); + stream.writeTimes++; + }; } -function runWithInvalidFD(func) { - var fd = 1 << 30; - // Get first known bad file descriptor. 1 << 30 is usually unlikely to - // be an valid one. - try { - while (fs.fstatSync(fd--) && fd > 0); - } catch (_unused3) { - return func(fd); - } - printSkipMessage('Could not generate an invalid fd'); + +function restoreWritable(name) { + processname.write = stdWritename; + delete processname.writeTimes; } -module.exports = { - allowGlobals: allowGlobals, - buildType: buildType, - busyLoop: busyLoop, - canCreateSymLink: canCreateSymLink, - childShouldThrowAndAbort: childShouldThrowAndAbort, - createZeroFilledFile: createZeroFilledFile, - disableCrashOnUnhandledRejection: disableCrashOnUnhandledRejection, - enoughTestCpu: enoughTestCpu, - enoughTestMem: enoughTestMem, - expectsError: expectsError, - expectWarning: expectWarning, - getArrayBufferViews: getArrayBufferViews, - getBufferSources: getBufferSources, - getCallSite: getCallSite, - getTTYfd: getTTYfd, - hasIntl: hasIntl, - hasCrypto: hasCrypto, - hasIPv6: hasIPv6, - hasMultiLocalhost: hasMultiLocalhost, - isAIX: isAIX, - isAlive: isAlive, - isFreeBSD: isFreeBSD, - isLinux: isLinux, - isLinuxPPCBE: isLinuxPPCBE, - isMainThread: isMainThread, - isOpenBSD: isOpenBSD, - isOSX: isOSX, - isSunOS: isSunOS, - isWindows: isWindows, - localIPv6Hosts: localIPv6Hosts, - mustCall: mustCall, - mustCallAtLeast: mustCallAtLeast, - mustNotCall: mustNotCall, - nodeProcessAborted: nodeProcessAborted, - noWarnCode: undefined, - PIPE: PIPE, - platformTimeout: platformTimeout, - printSkipMessage: printSkipMessage, - pwdCommand: pwdCommand, - rootDir: rootDir, - runWithInvalidFD: runWithInvalidFD, - skip: skip, - skipIf32Bits: skipIf32Bits, - skipIfEslintMissing: skipIfEslintMissing, - skipIfInspectorDisabled: skipIfInspectorDisabled, - skipIfWorker: skipIfWorker, - get localhostIPv6() { - return '::1'; - }, - get hasFipsCrypto() { - return hasCrypto && require('crypto').fips; - }, - get inFreeBSDJail() { - if (inFreeBSDJail !== null) return inFreeBSDJail; - if (exports.isFreeBSD && execSync('sysctl -n security.jail.jailed').toString() === '1\n') { - inFreeBSDJail = true; - } else { - inFreeBSDJail = false; - } - return inFreeBSDJail; - }, - get localhostIPv4() { - if (localhostIPv4 !== null) return localhostIPv4; - if (this.inFreeBSDJail) { - // Jailed network interfaces are a bit special - since we need to jump - // through loops, as well as this being an exception case, assume the - // user will provide this instead. - if (process.env.LOCALHOST) { - localhostIPv4 = process.env.LOCALHOST; - } else { - console.error('Looks like we\'re in a FreeBSD Jail. ' + 'Please provide your default interface address ' + 'as LOCALHOST or expect some tests to fail.'); - } - } - if (localhostIPv4 === null) localhostIPv4 = '127.0.0.1'; - return localhostIPv4; - }, - // opensslCli defined lazily to reduce overhead of spawnSync - get opensslCli() { - if (opensslCli !== null) return opensslCli; - if (process.config.variables.node_shared_openssl) { - // use external command - opensslCli = 'openssl'; - } else { - // use command built from sources included in Node.js repository - opensslCli = path.join(path.dirname(process.execPath), 'openssl-cli'); - } - if (exports.isWindows) opensslCli += '.exe'; - var opensslCmd = spawnSync(opensslCli, 'version'); - if (opensslCmd.status !== 0 || opensslCmd.error !== undefined) { - // openssl command cannot be executed - opensslCli = false; - } - return opensslCli; - }, - get PORT() { - if (+process.env.TEST_PARALLEL) { - throw new Error('common.PORT cannot be used in a parallelized test'); - } - return +process.env.NODE_COMMON_PORT || 12346; - } + +exports.hijackStdout = hijackStdWritable.bind(null, 'stdout'); +exports.hijackStderr = hijackStdWritable.bind(null, 'stderr'); +exports.restoreStdout = restoreWritable.bind(null, 'stdout'); +exports.restoreStderr = restoreWritable.bind(null, 'stderr'); + +var fd = 2; +exports.firstInvalidFD = function firstInvalidFD() { + // Get first known bad file descriptor. + try { + while (fs.fstatSync(++fd)) {} + } catch (e) {} + return fd; }; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i); } +} + +if (!util._errnoException) { + var uv; + util._errnoException = function (err, syscall) { + if (util.isUndefined(uv)) try { + uv = process.binding('uv'); + } catch (e) {} + var errname = uv ? uv.errname(err) : ''; + var e = new Error(syscall + ' ' + errname); + e.code = errname; + e.errno = errname; + e.syscall = syscall; + return e; + }; } \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/index.mjs -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/index.mjs
Changed
@@ -1,104 +1,128 @@ /*<replacement>*/ - require('@babel/polyfill'); + require('babel-polyfill'); var util = require('util'); for (var i in util) exportsi = utili; - /*</replacement>*/// Flags: --experimental-modules -/* eslint-disable node-core/required-modules */ -import common from './index.js'; - -const { - isMainThread, - isWindows, - isAIX, - isLinuxPPCBE, - isSunOS, - isFreeBSD, - isOpenBSD, - isLinux, - isOSX, - enoughTestMem, - enoughTestCpu, - rootDir, - buildType, - localIPv6Hosts, - opensslCli, - PIPE, - hasIPv6, - childShouldThrowAndAbort, - createZeroFilledFile, - platformTimeout, - allowGlobals, - mustCall, - mustCallAtLeast, - hasMultiLocalhost, - skipIfEslintMissing, - canCreateSymLink, - getCallSite, - mustNotCall, - printSkipMessage, - skip, - ArrayStream, - nodeProcessAborted, - busyLoop, - isAlive, - noWarnCode, - expectWarning, - expectsError, - skipIfInspectorDisabled, - skipIf32Bits, - getArrayBufferViews, - getBufferSources, - disableCrashOnUnhandledRejection, - getTTYfd, - runWithInvalidFD -} = common; - -export { - isMainThread, - isWindows, - isAIX, - isLinuxPPCBE, - isSunOS, - isFreeBSD, - isOpenBSD, - isLinux, - isOSX, - enoughTestMem, - enoughTestCpu, - rootDir, - buildType, - localIPv6Hosts, - opensslCli, - PIPE, - hasIPv6, - childShouldThrowAndAbort, - createZeroFilledFile, - platformTimeout, - allowGlobals, - mustCall, - mustCallAtLeast, - hasMultiLocalhost, - skipIfEslintMissing, - canCreateSymLink, - getCallSite, - mustNotCall, - printSkipMessage, - skip, - ArrayStream, - nodeProcessAborted, - busyLoop, - isAlive, - noWarnCode, - expectWarning, - expectsError, - skipIfInspectorDisabled, - skipIf32Bits, - getArrayBufferViews, - getBufferSources, - disableCrashOnUnhandledRejection, - getTTYfd, - runWithInvalidFD -}; + /*</replacement>*//*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +// Flags: --experimental-modules +/* eslint-disable required-modules */ + +import assert from 'assert'; + +let knownGlobals = + Buffer, + clearImmediate, + clearInterval, + clearTimeout, + console, + constructor, // Enumerable in V8 3.21. + global, + process, + setImmediate, + setInterval, + setTimeout +; + +if (process.env.NODE_TEST_KNOWN_GLOBALS) { + const knownFromEnv = process.env.NODE_TEST_KNOWN_GLOBALS.split(','); + allowGlobals(...knownFromEnv); +} + +export function allowGlobals(...whitelist) { + knownGlobals = knownGlobals.concat(whitelist); +} + +export function leakedGlobals() { + //add possible expected globals + if (global.gc) { + knownGlobals.push(global.gc); + } + + if (global.DTRACE_HTTP_SERVER_RESPONSE) { + knownGlobals.push(DTRACE_HTTP_SERVER_RESPONSE); + knownGlobals.push(DTRACE_HTTP_SERVER_REQUEST); + knownGlobals.push(DTRACE_HTTP_CLIENT_RESPONSE); + knownGlobals.push(DTRACE_HTTP_CLIENT_REQUEST); + knownGlobals.push(DTRACE_NET_STREAM_END); + knownGlobals.push(DTRACE_NET_SERVER_CONNECTION); + } + + if (global.COUNTER_NET_SERVER_CONNECTION) { + knownGlobals.push(COUNTER_NET_SERVER_CONNECTION); + knownGlobals.push(COUNTER_NET_SERVER_CONNECTION_CLOSE); + knownGlobals.push(COUNTER_HTTP_SERVER_REQUEST); + knownGlobals.push(COUNTER_HTTP_SERVER_RESPONSE); + knownGlobals.push(COUNTER_HTTP_CLIENT_REQUEST); + knownGlobals.push(COUNTER_HTTP_CLIENT_RESPONSE); + } + + if (global.LTTNG_HTTP_SERVER_RESPONSE) { + knownGlobals.push(LTTNG_HTTP_SERVER_RESPONSE); + knownGlobals.push(LTTNG_HTTP_SERVER_REQUEST); + knownGlobals.push(LTTNG_HTTP_CLIENT_RESPONSE); + knownGlobals.push(LTTNG_HTTP_CLIENT_REQUEST); + knownGlobals.push(LTTNG_NET_STREAM_END); + knownGlobals.push(LTTNG_NET_SERVER_CONNECTION); + } + + if (global.ArrayBuffer) { + knownGlobals.push(ArrayBuffer); + knownGlobals.push(Int8Array); + knownGlobals.push(Uint8Array); + knownGlobals.push(Uint8ClampedArray); + knownGlobals.push(Int16Array); + knownGlobals.push(Uint16Array); + knownGlobals.push(Int32Array); + knownGlobals.push(Uint32Array); + knownGlobals.push(Float32Array); + knownGlobals.push(Float64Array); + knownGlobals.push(DataView); + } + + // Harmony features. + if (global.Proxy) { + knownGlobals.push(Proxy); + } + + if (global.Symbol) { + knownGlobals.push(Symbol); + } + + const leaked = ; + + for (const val in global) { + if (!knownGlobals.includes(globalval)) { + leaked.push(val); + } + } + + if (global.__coverage__) { + return leaked.filter((varname) => !/^(?:cov_|__cov)/.test(varname)); + } else { + return leaked; + } +} + +// Turn this off if the test should not check for global leaks. +export let globalCheck = true; // eslint-disable-line + +process.on('exit', function() { + if (!globalCheck) return; + const leaked = leakedGlobals(); + if (leaked.length > 0) { + assert.fail(`Unexpected global(s) found: ${leaked.join(', ')}`); + } +}); function forEach (xs, f) { for (var i = 0, l = xs.length; i < l; i++) {
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/inspector-helper.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/inspector-helper.js
Changed
@@ -1,34 +1,30 @@ -"use strict"; - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = genkey(arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && oSymbol.iterator || o"@@iterator"; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: oi++ }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2i = arri; return arr2; } + /*<replacement>*/ -require('@babel/polyfill'); +require('babel-polyfill'); var util = require('util'); -for (var i in util) exportsi = utili; +for (var i in util) { + exportsi = utili; +} /*</replacement>*/ /*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} /*</replacement>*/ 'use strict'; /*<replacement>*/ var objectKeys = objectKeys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ @@ -37,17 +33,16 @@ var fs = require('fs'); var http = require('http'); var fixtures = require('../common/fixtures'); + var _require = require('child_process'), - spawn = _require.spawn; -var _require2 = require('url'), - parseURL = _require2.parse; -var _require3 = require('internal/url'), - pathToFileURL = _require3.pathToFileURL; -var _require4 = require('events'), - EventEmitter = _require4.EventEmitter; + spawn = _require.spawn; + +var url = require('url'); + var _MAINSCRIPT = fixtures.path('loop.js'); var DEBUG = false; var TIMEOUT = common.platformTimeout(15 * 1000); + function spawnChildProcess(inspectorFlags, scriptContents, scriptFile) { var args = .concat(inspectorFlags); if (scriptContents) { @@ -56,14 +51,16 @@ args.push(scriptFile); } var child = spawn(process.execPath, args); + var handler = tearDown.bind(null, child); process.on('exit', handler); process.on('uncaughtException', handler); - common.disableCrashOnUnhandledRejection(); process.on('unhandledRejection', handler); process.on('SIGINT', handler); + return child; } + function makeBufferingDataCallback(dataCallback) { var buffer = Buffer.alloc(0); return function (data) { @@ -71,20 +68,33 @@ var str = newData.toString('utf8'); var lines = str.replace(/\r/g, '').split('\n'); if (str.endsWith('\n')) buffer = Buffer.alloc(0);else buffer = Buffer.from(lines.pop(), 'utf8'); - var _iterator = _createForOfIteratorHelper(lines), - _step; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { + for (var _iterator = linesSymbol.iterator(), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var line = _step.value; + dataCallback(line); } } catch (err) { - _iterator.e(err); + _didIteratorError = true; + _iteratorError = err; } finally { - _iterator.f(); + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } } }; } + function tearDown(child, err) { child.kill(); if (err) { @@ -92,21 +102,15 @@ process.exit(1); } } + function parseWSFrame(buffer) { // Protocol described in https://tools.ietf.org/html/rfc6455#section-5 var message = null; - if (buffer.length < 2) return { - length: 0, - message: message - }; + if (buffer.length < 2) return { length: 0, message: message }; if (buffer0 === 0x88 && buffer1 === 0x00) { - return { - length: 2, - message: message, - closed: true - }; + return { length: 2, message: message, closed: true }; } - assert.strictEqual(buffer0, 0x81); + assert.strictEqual(0x81, buffer0); var dataLen = 0x7F & buffer1; var bodyOffset = 2; if (buffer.length < bodyOffset + dataLen) return 0; @@ -118,29 +122,26 @@ dataLen = buffer.readUIntBE(4, 6); bodyOffset = 10; } - if (buffer.length < bodyOffset + dataLen) return { - length: 0, - message: message - }; + if (buffer.length < bodyOffset + dataLen) return { length: 0, message: message }; var jsonPayload = buffer.slice(bodyOffset, bodyOffset + dataLen).toString('utf8'); try { message = JSON.parse(jsonPayload); } catch (e) { - console.error("JSON.parse() failed for: ".concat(jsonPayload)); + console.error('JSON.parse() failed for: ' + jsonPayload); throw e; } if (DEBUG) console.log('received', JSON.stringify(message)); - return { - length: bodyOffset + dataLen, - message: message - }; + return { length: bodyOffset + dataLen, message: message }; } + function formatWSFrame(message) { var messageBuf = Buffer.from(JSON.stringify(message)); + var wsHeaderBuf = Buffer.allocUnsafe(16); wsHeaderBuf.writeUInt8(0x81, 0); var byte2 = 0x80; var bodyLen = messageBuf.length; + var maskOffset = 2; if (bodyLen < 126) { byte2 = 0x80 + bodyLen; @@ -156,13 +157,18 @@ } wsHeaderBuf.writeUInt8(byte2, 1); wsHeaderBuf.writeUInt32BE(0x01020408, maskOffset); - for (var _i = 0; _i < messageBuf.length; _i++) messageBuf_i = messageBuf_i ^ 1 << _i % 4; - return Buffer.concat(wsHeaderBuf.slice(0, maskOffset + 4), messageBuf); + + for (var _i = 0; _i < messageBuf.length; _i++) { + messageBuf_i = messageBuf_i ^ 1 << _i % 4; + }return Buffer.concat(wsHeaderBuf.slice(0, maskOffset + 4), messageBuf); } -var InspectorSession = /*#__PURE__*/function () { + +var InspectorSession = function () { function InspectorSession(socket, instance) { var _this = this; + _classCallCheck(this, InspectorSession); + this._instance = instance; this._socket = socket; this._nextId = 1; @@ -170,19 +176,21 @@ this._unprocessedNotifications = ; this._notificationCallback = null; this._scriptsIdsByUrl = new Map(); + var buffer = Buffer.alloc(0); socket.on('data', function (data) { buffer = Buffer.concat(buffer, data); do { var _parseWSFrame = parseWSFrame(buffer), - length = _parseWSFrame.length, - message = _parseWSFrame.message, - closed = _parseWSFrame.closed; + length = _parseWSFrame.length, + message = _parseWSFrame.message, + closed = _parseWSFrame.closed; + if (!length) break; + if (closed) { socket.write(Buffer.from(0x88, 0x00)); // WS close frame } - buffer = buffer.slice(length); if (message) _this._onMessage(message); } while (true); @@ -191,413 +199,315 @@ socket.once('close', resolve); }); } - _createClass(InspectorSession, { - key: "waitForServerDisconnect", - value: function waitForServerDisconnect() { - return this._terminationPromise; - } - }, { - key: "disconnect", - value: function () { - var _disconnect = _asyncToGenerator(function* () { - this._socket.destroy(); - return this.waitForServerDisconnect(); - }); - function disconnect() { - return _disconnect.apply(this, arguments); + + InspectorSession.prototype.waitForServerDisconnect = function waitForServerDisconnect() { + return this._terminationPromise; + }; + + InspectorSession.prototype.disconnect = function disconnect() { + this._socket.destroy(); + }; + + InspectorSession.prototype._onMessage = function _onMessage(message) { + if (message.id) { + var _commandResponsePromi = this._commandResponsePromises.get(message.id), + resolve = _commandResponsePromi.resolve, + reject = _commandResponsePromi.reject; + + this._commandResponsePromises.delete(message.id); + if (message.result) resolve(message.result);else reject(message.error); + } else { + if (message.method === 'Debugger.scriptParsed') { + var script = message'params'; + var scriptId = script'scriptId'; + var _url = script'url'; + this._scriptsIdsByUrl.set(scriptId, _url); + if (_url === _MAINSCRIPT) this.mainScriptId = scriptId; } - return disconnect; - }() - }, { - key: "_onMessage", - value: function _onMessage(message) { - if (message.id) { - var _this$_commandRespons = this._commandResponsePromises.get(message.id), - resolve = _this$_commandRespons.resolve, - reject = _this$_commandRespons.reject; - this._commandResponsePromises.delete(message.id); - if (message.result) resolve(message.result);else reject(message.error); + + if (this._notificationCallback) { + // In case callback needs to install another + var callback = this._notificationCallback; + this._notificationCallback = null; + callback(message); } else { - if (message.method === 'Debugger.scriptParsed') { - var _message$params = message.params, - scriptId = _message$params.scriptId, - url = _message$params.url; - this._scriptsIdsByUrl.set(scriptId, url); - var fileUrl = url.startsWith('file:') ? url : pathToFileURL(url).toString(); - if (fileUrl === this.scriptURL().toString()) { - this.mainScriptId = scriptId; - } - } - if (this._notificationCallback) { - // In case callback needs to install another - var callback = this._notificationCallback; - this._notificationCallback = null; - callback(message); - } else { - this._unprocessedNotifications.push(message); - } + this._unprocessedNotifications.push(message); } } - }, { - key: "_sendMessage", - value: function _sendMessage(message) { - var _this2 = this; - var msg = JSON.parse(JSON.stringify(message)); // Clone! - msg.id = this._nextId++; - if (DEBUG) console.log('sent', JSON.stringify(msg)); - var responsePromise = new Promise(function (resolve, reject) { - _this2._commandResponsePromises.set(msg.id, { - resolve: resolve, - reject: reject - }); - }); - return new Promise(function (resolve) { - return _this2._socket.write(formatWSFrame(msg), resolve); - }).then(function () { - return responsePromise; - }); + }; + + InspectorSession.prototype._sendMessage = function _sendMessage(message) { + var _this2 = this; + + var msg = JSON.parse(JSON.stringify(message)); // Clone! + msg'id' = this._nextId++; + if (DEBUG) console.log('sent', JSON.stringify(msg)); + + var responsePromise = new Promise(function (resolve, reject) { + _this2._commandResponsePromises.set(msg'id', { resolve: resolve, reject: reject }); + }); + + return new Promise(function (resolve) { + return _this2._socket.write(formatWSFrame(msg), resolve); + }).then(function () { + return responsePromise; + }); + }; + + InspectorSession.prototype.send = function send(commands) { + var _this3 = this; + + if (Array.isArray(commands)) { + // Multiple commands means the response does not matter. There might even + // never be a response. + return Promise.all(commands.map(function (command) { + return _this3._sendMessage(command); + })).then(function () {}); + } else { + return this._sendMessage(commands); + } + }; + + InspectorSession.prototype.waitForNotification = function waitForNotification(methodOrPredicate, description) { + var desc = description || methodOrPredicate; + var message = 'Timed out waiting for matching notification (' + desc + '))'; + return fires(this._asyncWaitForNotification(methodOrPredicate), message, TIMEOUT); + }; + + InspectorSession.prototype._asyncWaitForNotification = async function _asyncWaitForNotification(methodOrPredicate) { + var _this4 = this; + + function matchMethod(notification) { + return notification.method === methodOrPredicate; } - }, { - key: "send", - value: function send(commands) { - var _this3 = this; - if (Array.isArray(commands)) { - // Multiple commands means the response does not matter. There might even - // never be a response. - return Promise.all(commands.map(function (command) { - return _this3._sendMessage(command); - })).then(function () {}); + var predicate = typeof methodOrPredicate === 'string' ? matchMethod : methodOrPredicate; + var notification = null; + do { + if (this._unprocessedNotifications.length) { + notification = this._unprocessedNotifications.shift(); } else { - return this._sendMessage(commands); + notification = await new Promise(function (resolve) { + return _this4._notificationCallback = resolve; + }); } + } while (!predicate(notification)); + return notification; + }; + + InspectorSession.prototype._isBreakOnLineNotification = function _isBreakOnLineNotification(message, line, url) { + if ('Debugger.paused' === message'method') { + var callFrame = message'params''callFrames'0; + var location = callFrame'location'; + assert.strictEqual(url, this._scriptsIdsByUrl.get(location'scriptId')); + assert.strictEqual(line, location'lineNumber'); + return true; } - }, { - key: "waitForNotification", - value: function waitForNotification(methodOrPredicate, description) { - var desc = description || methodOrPredicate; - var message = "Timed out waiting for matching notification (".concat(desc, "))"); - return fires(this._asyncWaitForNotification(methodOrPredicate), message, TIMEOUT); - } - }, { - key: "_asyncWaitForNotification", - value: function () { - var _asyncWaitForNotification2 = _asyncToGenerator(function* (methodOrPredicate) { - var _this4 = this; - function matchMethod(notification) { - return notification.method === methodOrPredicate; - } - var predicate = typeof methodOrPredicate === 'string' ? matchMethod : methodOrPredicate; - var notification = null; - do { - if (this._unprocessedNotifications.length) { - notification = this._unprocessedNotifications.shift(); - } else { - notification = yield new Promise(function (resolve) { - return _this4._notificationCallback = resolve; - }); + }; + + InspectorSession.prototype.waitForBreakOnLine = function waitForBreakOnLine(line, url) { + var _this5 = this; + + return this.waitForNotification(function (notification) { + return _this5._isBreakOnLineNotification(notification, line, url); + }, 'break on ' + url + ':' + line); + }; + + InspectorSession.prototype._matchesConsoleOutputNotification = function _matchesConsoleOutputNotification(notification, type, values) { + if (!Array.isArray(values)) values = values; + if ('Runtime.consoleAPICalled' === notification'method') { + var params = notification'params'; + if (params'type' === type) { + var _i2 = 0; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = params'args'Symbol.iterator(), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var value = _step2.value; + + if (value'value' !== values_i2++) return false; } - } while (!predicate(notification)); - return notification; - }); - function _asyncWaitForNotification(_x) { - return _asyncWaitForNotification2.apply(this, arguments); - } - return _asyncWaitForNotification; - }() - }, { - key: "_isBreakOnLineNotification", - value: function _isBreakOnLineNotification(message, line, expectedScriptPath) { - if (message.method === 'Debugger.paused') { - var callFrame = message.params.callFrames0; - var location = callFrame.location; - var scriptPath = this._scriptsIdsByUrl.get(location.scriptId); - assert.strictEqual(scriptPath.toString(), expectedScriptPath.toString(), "".concat(scriptPath, " !== ").concat(expectedScriptPath)); - assert.strictEqual(location.lineNumber, line); - return true; - } - } - }, { - key: "waitForBreakOnLine", - value: function waitForBreakOnLine(line, url) { - var _this5 = this; - return this.waitForNotification(function (notification) { - return _this5._isBreakOnLineNotification(notification, line, url); - }, "break on ".concat(url, ":").concat(line)); - } - }, { - key: "_matchesConsoleOutputNotification", - value: function _matchesConsoleOutputNotification(notification, type, values) { - if (!Array.isArray(values)) values = values; - if (notification.method === 'Runtime.consoleAPICalled') { - var params = notification.params; - if (params.type === type) { - var _i2 = 0; - var _iterator2 = _createForOfIteratorHelper(params.args), - _step2; + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var value = _step2.value; - if (value.value !== values_i2++) return false; + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); } - } catch (err) { - _iterator2.e(err); } finally { - _iterator2.f(); + if (_didIteratorError2) { + throw _iteratorError2; + } } - return _i2 === values.length; } + + return _i2 === values.length; } } - }, { - key: "waitForConsoleOutput", - value: function waitForConsoleOutput(type, values) { - var _this6 = this; - var desc = "Console output matching ".concat(JSON.stringify(values)); - return this.waitForNotification(function (notification) { - return _this6._matchesConsoleOutputNotification(notification, type, values); - }, desc); - } - }, { - key: "runToCompletion", - value: function () { - var _runToCompletion = _asyncToGenerator(function* () { - console.log('test', 'Verify node waits for the frontend to disconnect'); - yield this.send({ - 'method': 'Debugger.resume' - }); - yield this.waitForNotification(function (notification) { - return notification.method === 'Runtime.executionContextDestroyed' && notification.params.executionContextId === 1; - }); - while ((yield this._instance.nextStderrString()) !== 'Waiting for the debugger to disconnect...'); - yield this.disconnect(); - }); - function runToCompletion() { - return _runToCompletion.apply(this, arguments); - } - return runToCompletion; - }() - }, { - key: "scriptPath", - value: function scriptPath() { - return this._instance.scriptPath(); - } - }, { - key: "script", - value: function script() { - return this._instance.script(); - } - }, { - key: "scriptURL", - value: function scriptURL() { - return pathToFileURL(this.scriptPath()); - } - }); + }; + + InspectorSession.prototype.waitForConsoleOutput = function waitForConsoleOutput(type, values) { + var _this6 = this; + + var desc = 'Console output matching ' + JSON.stringify(values); + return this.waitForNotification(function (notification) { + return _this6._matchesConsoleOutputNotification(notification, type, values); + }, desc); + }; + + InspectorSession.prototype.runToCompletion = async function runToCompletion() { + console.log('test', 'Verify node waits for the frontend to disconnect'); + await this.send({ 'method': 'Debugger.resume' }); + await this.waitForNotification(function (notification) { + return notification.method === 'Runtime.executionContextDestroyed' && notification.params.executionContextId === 1; + }); + while ((await this._instance.nextStderrString()) !== 'Waiting for the debugger to disconnect...') {} + await this.disconnect(); + }; + return InspectorSession; }(); -var NodeInstance = /*#__PURE__*/function (_EventEmitter) { - _inherits(NodeInstance, _EventEmitter); - var _super = _createSuper(NodeInstance); + +var NodeInstance = function () { function NodeInstance() { - var _this7; var inspectorFlags = arguments.length > 0 && arguments0 !== undefined ? arguments0 : '--inspect-brk=0'; + + var _this7 = this; + var scriptContents = arguments.length > 1 && arguments1 !== undefined ? arguments1 : ''; var scriptFile = arguments.length > 2 && arguments2 !== undefined ? arguments2 : _MAINSCRIPT; + _classCallCheck(this, NodeInstance); - _this7 = _super.call(this); - _this7._scriptPath = scriptFile; - _this7._script = scriptFile ? null : scriptContents; - _this7._portCallback = null; - _this7.portPromise = new Promise(function (resolve) { + + this._portCallback = null; + this.portPromise = new Promise(function (resolve) { return _this7._portCallback = resolve; }); - _this7._process = spawnChildProcess(inspectorFlags, scriptContents, scriptFile); - _this7._running = true; - _this7._stderrLineCallback = null; - _this7._unprocessedStderrLines = ; - _this7._process.stdout.on('data', makeBufferingDataCallback(function (line) { - _this7.emit('stdout', line); - console.log('out', line); + this._process = spawnChildProcess(inspectorFlags, scriptContents, scriptFile); + this._running = true; + this._stderrLineCallback = null; + this._unprocessedStderrLines = ; + + this._process.stdout.on('data', makeBufferingDataCallback(function (line) { + return console.log('out', line); })); - _this7._process.stderr.on('data', makeBufferingDataCallback(function (message) { + + this._process.stderr.on('data', makeBufferingDataCallback(function (message) { return _this7.onStderrLine(message); })); - _this7._shutdownPromise = new Promise(function (resolve) { + + this._shutdownPromise = new Promise(function (resolve) { _this7._process.once('exit', function (exitCode, signal) { - resolve({ - exitCode: exitCode, - signal: signal - }); + resolve({ exitCode: exitCode, signal: signal }); _this7._running = false; }); }); - return _this7; } - _createClass(NodeInstance, { - key: "onStderrLine", - value: function onStderrLine(line) { - console.log('err', line); - if (this._portCallback) { - var matches = line.match(/Debugger listening on ws:\/\/.+:(\d+)\/.+/); - if (matches) { - this._portCallback(matches1); - this._portCallback = null; - } - } - if (this._stderrLineCallback) { - this._stderrLineCallback(line); - this._stderrLineCallback = null; - } else { - this._unprocessedStderrLines.push(line); + + NodeInstance.startViaSignal = async function startViaSignal(scriptContents) { + var instance = new NodeInstance(, scriptContents + '\nprocess._rawDebug(\'started\');', undefined); + var msg = 'Timed out waiting for process to start'; + while ((await fires(instance.nextStderrString(), msg, TIMEOUT)) !== 'started') {} + process._debugProcess(instance._process.pid); + return instance; + }; + + NodeInstance.prototype.onStderrLine = function onStderrLine(line) { + console.log('err', line); + if (this._portCallback) { + var matches = line.match(/Debugger listening on ws:\/\/.+:(\d+)\/.+/); + if (matches) { + this._portCallback(matches1); + this._portCallback = null; } } - }, { - key: "httpGet", - value: function httpGet(host, path, hostHeaderValue) { - console.log('test', "Testing ".concat(path)); - var headers = hostHeaderValue ? { - 'Host': hostHeaderValue - } : null; - return this.portPromise.then(function (port) { - return new Promise(function (resolve, reject) { - var req = http.get({ - host: host, - port: port, - path: path, - headers: headers - }, function (res) { - var response = ''; - res.setEncoding('utf8'); - res.on('data', function (data) { - return response += data.toString(); - }).on('end', function () { - resolve(response); - }); + if (this._stderrLineCallback) { + this._stderrLineCallback(line); + this._stderrLineCallback = null; + } else { + this._unprocessedStderrLines.push(line); + } + }; + + NodeInstance.prototype.httpGet = function httpGet(host, path) { + console.log('test', 'Testing ' + path); + return this.portPromise.then(function (port) { + return new Promise(function (resolve, reject) { + var req = http.get({ host: host, port: port, path: path }, function (res) { + var response = ''; + res.setEncoding('utf8'); + res.on('data', function (data) { + return response += data.toString(); + }).on('end', function () { + resolve(response); }); - req.on('error', reject); }); - }).then(function (response) { - try { - return JSON.parse(response); - } catch (e) { - e.body = response; - throw e; - } + req.on('error', reject); }); - } - }, { - key: "sendUpgradeRequest", - value: function () { - var _sendUpgradeRequest = _asyncToGenerator(function* () { - var response = yield this.httpGet(null, '/json/list'); - var devtoolsUrl = response0.webSocketDebuggerUrl; - var port = yield this.portPromise; - return http.get({ + }).then(function (response) { + try { + return JSON.parse(response); + } catch (e) { + e.body = response; + throw e; + } + }); + }; + + NodeInstance.prototype.wsHandshake = function wsHandshake(devtoolsUrl) { + var _this8 = this; + + return this.portPromise.then(function (port) { + return new Promise(function (resolve) { + http.get({ port: port, - path: parseURL(devtoolsUrl).path, + path: url.parse(devtoolsUrl).path, headers: { 'Connection': 'Upgrade', 'Upgrade': 'websocket', 'Sec-WebSocket-Version': 13, 'Sec-WebSocket-Key': 'key==' } - }); - }); - function sendUpgradeRequest() { - return _sendUpgradeRequest.apply(this, arguments); - } - return sendUpgradeRequest; - }() - }, { - key: "connectInspectorSession", - value: function () { - var _connectInspectorSession = _asyncToGenerator(function* () { - var _this8 = this; - console.log('test', 'Connecting to a child Node process'); - var upgradeRequest = yield this.sendUpgradeRequest(); - return new Promise(function (resolve) { - upgradeRequest.on('upgrade', function (message, socket) { - return resolve(new InspectorSession(socket, _this8)); - }).on('response', common.mustNotCall('Upgrade was not received')); - }); - }); - function connectInspectorSession() { - return _connectInspectorSession.apply(this, arguments); - } - return connectInspectorSession; - }() - }, { - key: "expectConnectionDeclined", - value: function () { - var _expectConnectionDeclined = _asyncToGenerator(function* () { - console.log('test', 'Checking upgrade is not possible'); - var upgradeRequest = yield this.sendUpgradeRequest(); - return new Promise(function (resolve) { - upgradeRequest.on('upgrade', common.mustNotCall('Upgrade was received')).on('response', function (response) { - return response.on('data', function () {}).on('end', function () { - return resolve(response.statusCode); - }); - }); - }); - }); - function expectConnectionDeclined() { - return _expectConnectionDeclined.apply(this, arguments); - } - return expectConnectionDeclined; - }() - }, { - key: "expectShutdown", - value: function expectShutdown() { - return this._shutdownPromise; - } - }, { - key: "nextStderrString", - value: function nextStderrString() { - var _this9 = this; - if (this._unprocessedStderrLines.length) return Promise.resolve(this._unprocessedStderrLines.shift()); - return new Promise(function (resolve) { - return _this9._stderrLineCallback = resolve; - }); - } - }, { - key: "write", - value: function write(message) { - this._process.stdin.write(message); - } - }, { - key: "kill", - value: function kill() { - this._process.kill(); - return this.expectShutdown(); - } - }, { - key: "scriptPath", - value: function scriptPath() { - return this._scriptPath; - } - }, { - key: "script", - value: function script() { - if (this._script === null) this._script = fs.readFileSync(this.scriptPath(), 'utf8'); - return this._script; - } - }, { - key: "startViaSignal", - value: function () { - var _startViaSignal = _asyncToGenerator(function* (scriptContents) { - var instance = new NodeInstance(, "".concat(scriptContents, "\nprocess._rawDebug('started');"), undefined); - var msg = 'Timed out waiting for process to start'; - while ((yield fires(instance.nextStderrString(), msg, TIMEOUT)) !== 'started') {} - process._debugProcess(instance._process.pid); - return instance; + }).on('upgrade', function (message, socket) { + resolve(new InspectorSession(socket, _this8)); + }).on('response', common.mustNotCall('Upgrade was not received')); }); - function startViaSignal(_x2) { - return _startViaSignal.apply(this, arguments); - } - return startViaSignal; - }() - }); + }); + }; + + NodeInstance.prototype.connectInspectorSession = async function connectInspectorSession() { + console.log('test', 'Connecting to a child Node process'); + var response = await this.httpGet(null, '/json/list'); + var url = response0'webSocketDebuggerUrl'; + return this.wsHandshake(url); + }; + + NodeInstance.prototype.expectShutdown = function expectShutdown() { + return this._shutdownPromise; + }; + + NodeInstance.prototype.nextStderrString = function nextStderrString() { + var _this9 = this; + + if (this._unprocessedStderrLines.length) return Promise.resolve(this._unprocessedStderrLines.shift()); + return new Promise(function (resolve) { + return _this9._stderrLineCallback = resolve; + }); + }; + + NodeInstance.prototype.kill = function kill() { + this._process.kill(); + }; + return NodeInstance; -}(EventEmitter); +}(); + +function readMainScriptSource() { + return fs.readFileSync(_MAINSCRIPT, 'utf8'); +} + function onResolvedOrRejected(promise, callback) { return promise.then(function (result) { callback(); @@ -607,6 +517,7 @@ throw error; }); } + function timeoutPromise(error, timeoutMs) { var clearCallback = null; var done = false; @@ -614,7 +525,7 @@ var timeout = setTimeout(function () { return reject(error); }, timeoutMs); - clearCallback = function clearCallback() { + clearCallback = function () { if (done) return; clearTimeout(timeout); resolve(); @@ -635,9 +546,13 @@ return timeout.clear(); }), timeout); } + module.exports = { + mainScriptPath: _MAINSCRIPT, + readMainScriptSource: readMainScriptSource, NodeInstance: NodeInstance }; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/wpt.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/common/wpt.js
Changed
@@ -1,17 +1,29 @@ -"use strict"; - /*<replacement>*/ -require('@babel/polyfill'); +require('babel-polyfill'); var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ +for (var i in util) { + exportsi = utili; +} /*</replacement>*/ /*<replacement>*/ +if (!global.setImmediate) { + global.setImmediate = function setImmediate(fn) { + return setTimeout(fn.bind.apply(fn, arguments), 4); + }; +} +if (!global.clearImmediate) { + global.clearImmediate = function clearImmediate(i) { + return clearTimeout(i); + }; +} +/*</replacement>*/ +/* eslint-disable required-modules */ 'use strict'; /*<replacement>*/ var objectKeys = objectKeys || function (obj) { var keys = ; - for (var key in obj) keys.push(key); - return keys; + for (var key in obj) { + keys.push(key); + }return keys; }; /*</replacement>*/ @@ -19,31 +31,32 @@ // https://github.com/w3c/testharness.js/blob/master/testharness.js module.exports = { - test: function test(fn, desc) { + test: function (fn, desc) { try { fn(); } catch (err) { - console.error("In ".concat(desc, ":")); + console.error('In ' + desc + ':'); throw err; } }, assert_equals: assert.strictEqual, - assert_true: function assert_true(value, message) { + assert_true: function (value, message) { return assert.strictEqual(value, true, message); }, - assert_false: function assert_false(value, message) { + assert_false: function (value, message) { return assert.strictEqual(value, false, message); }, - assert_throws: function assert_throws(code, func, desc) { + assert_throws: function (code, func, desc) { assert.throws(func, function (err) { return typeof err === 'object' && 'name' in err && err.name.startsWith(code.name); }, desc); }, assert_array_equals: assert.deepStrictEqual, - assert_unreached: function assert_unreached(desc) { - assert.fail("Reached unreachable code: ".concat(desc)); + assert_unreached: function (desc) { + assert.fail('Reached unreachable code: ' + desc); } }; + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i);
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/ours/lolex-fake-timers.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/ours/lolex-fake-timers.js
Changed
@@ -1,5 +1,4 @@ require('../common'); -var tap = require('tap'); var util = require('util'); var assert = require('assert'); var lolex = require('lolex'); @@ -38,4 +37,3 @@ clock.runAll() clock.uninstall(); assert(stream2DataCalled); -tap.pass('ok');
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/ours/test-stream-sync-write.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/ours/test-stream-sync-write.js
Changed
@@ -34,5 +34,3 @@ for (var i = 0; i < 2000; i++) { externalStream.write(i.toString()); } - -require('tap').pass('sync done');
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-big-packet.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-big-packet.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -39,34 +31,35 @@ require('../common'); var assert = require('assert/'); var stream = require('../../'); + var passed = false; -var TestStream = /*#__PURE__*/function (_stream$Transform) { + +var TestStream = function (_stream$Transform) { _inherits(TestStream, _stream$Transform); - var _super = _createSuper(TestStream); + function TestStream() { _classCallCheck(this, TestStream); - return _super.apply(this, arguments); + + return _possibleConstructorReturn(this, _stream$Transform.apply(this, arguments)); } - _createClass(TestStream, { - key: "_transform", - value: function _transform(chunk, encoding, done) { - if (!passed) { - // Char 'a' only exists in the last write - passed = chunk.toString().includes('a'); - } - done(); + + TestStream.prototype._transform = function _transform(chunk, encoding, done) { + if (!passed) { + // Char 'a' only exists in the last write + passed = chunk.toString().includes('a'); } - }); + done(); + }; + return TestStream; }(stream.Transform); + var s1 = new stream.PassThrough(); var s2 = new stream.PassThrough(); var s3 = new TestStream(); s1.pipe(s3); // Don't let s2 auto close which may close s3 -s2.pipe(s3, { - end: false -}); +s2.pipe(s3, { end: false }); // We must write a buffer larger than highWaterMark var big = bufferShim.alloc(s1.writableHighWaterMark + 1, 'x'); @@ -84,20 +77,10 @@ process.on('exit', function () { assert(passed, 'Large buffer is not handled properly by Writable Stream'); }); + function indexOf(xs, x) { for (var i = 0, l = xs.length; i < l; i++) { if (xsi === x) return i; } return -1; -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-big-push.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-big-push.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -28,11 +26,14 @@ var assert = require('assert/'); var stream = require('../../'); var str = 'asdfasdfasdfasdfasdf'; + var r = new stream.Readable({ highWaterMark: 5, encoding: 'utf8' }); + var reads = 0; + function _read() { if (reads === 0) { setTimeout(function () { @@ -47,7 +48,9 @@ r.push(null); } } + r._read = common.mustCall(_read, 3); + r.on('end', common.mustCall()); // push some data in to start. @@ -59,6 +62,7 @@ assert.strictEqual(chunk, str); chunk = r.read(); assert.strictEqual(chunk, null); + r.once('readable', function () { // this time, we'll get *all* the remaining data, because // it's been added synchronously, as the read WOULD take @@ -66,17 +70,7 @@ // which synchronously added more, which we then return. chunk = r.read(); assert.strictEqual(chunk, str + str); + chunk = r.read(); assert.strictEqual(chunk, null); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-buffer-list.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-buffer-list.js
Changed
@@ -1,38 +1,29 @@ -"use strict"; - +// Flags: --expose_internals /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ require('../common'); var assert = require('assert/'); -var BufferList = require('../../lib/internal/streams/buffer_list'); +var BufferList = require('../../lib/internal/streams/BufferList'); // Test empty buffer list. var emptyList = new BufferList(); + emptyList.shift(); assert.deepStrictEqual(emptyList, new BufferList()); + assert.strictEqual(emptyList.join(','), ''); + assert.deepStrictEqual(emptyList.concat(0), bufferShim.alloc(0)); -var buf = bufferShim.from('foo'); // Test buffer list with one element. var list = new BufferList(); -list.push(buf); -var copy = list.concat(3); -assert.notStrictEqual(copy, buf); -assert.deepStrictEqual(copy, buf); +list.push('foo'); + +assert.strictEqual(list.concat(1), 'foo'); + assert.strictEqual(list.join(','), 'foo'); + var shifted = list.shift(); -assert.strictEqual(shifted, buf); -assert.deepStrictEqual(list, new BufferList()); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +assert.strictEqual(shifted, 'foo'); +assert.deepStrictEqual(list, new BufferList()); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-decoder-objectmode.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-decoder-objectmode.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -7,11 +5,13 @@ require('../common'); var stream = require('../../'); var assert = require('assert/'); + var readable = new stream.Readable({ - read: function read() {}, + read: function () {}, encoding: 'utf16le', objectMode: true }); + readable.push(bufferShim.from('abc', 'utf16le')); readable.push(bufferShim.from('def', 'utf16le')); readable.push(null); @@ -19,15 +19,4 @@ // Without object mode, these would be concatenated into a single chunk. assert.strictEqual(readable.read(), 'abc'); assert.strictEqual(readable.read(), 'def'); -assert.strictEqual(readable.read(), null); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +assert.strictEqual(readable.read(), null); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-duplex-destroy.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-duplex-destroy.js
Changed
@@ -1,109 +1,133 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); + var _require = require('../../'), - Duplex = _require.Duplex; + Duplex = _require.Duplex; + var assert = require('assert/'); + +var _require2 = require('util'), + inherits = _require2.inherits; + { var duplex = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {} + read: function () {} }); + duplex.resume(); - duplex.on('end', common.mustNotCall()); - duplex.on('finish', common.mustNotCall()); - duplex.on('close', common.mustCall()); + + duplex.on('end', common.mustCall()); + duplex.on('finish', common.mustCall()); + duplex.destroy(); assert.strictEqual(duplex.destroyed, true); } + { var _duplex = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {} + read: function () {} }); _duplex.resume(); + var expected = new Error('kaboom'); - _duplex.on('end', common.mustNotCall()); - _duplex.on('finish', common.mustNotCall()); + + _duplex.on('end', common.mustCall()); + _duplex.on('finish', common.mustCall()); _duplex.on('error', common.mustCall(function (err) { assert.strictEqual(err, expected); })); + _duplex.destroy(expected); assert.strictEqual(_duplex.destroyed, true); } + { var _duplex2 = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {} + read: function () {} }); + _duplex2._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, _expected); cb(err); }); + var _expected = new Error('kaboom'); + _duplex2.on('finish', common.mustNotCall('no finish event')); _duplex2.on('error', common.mustCall(function (err) { assert.strictEqual(err, _expected); })); + _duplex2.destroy(_expected); assert.strictEqual(_duplex2.destroyed, true); } + { var _expected2 = new Error('kaboom'); var _duplex3 = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {}, + read: function () {}, + destroy: common.mustCall(function (err, cb) { assert.strictEqual(err, _expected2); cb(); }) }); _duplex3.resume(); + _duplex3.on('end', common.mustNotCall('no end event')); _duplex3.on('finish', common.mustNotCall('no finish event')); // error is swallowed by the custom _destroy _duplex3.on('error', common.mustNotCall('no error event')); - _duplex3.on('close', common.mustCall()); + _duplex3.destroy(_expected2); assert.strictEqual(_duplex3.destroyed, true); } + { var _duplex4 = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {} + read: function () {} }); + _duplex4._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, null); cb(); }); + _duplex4.destroy(); assert.strictEqual(_duplex4.destroyed, true); } + { var _duplex5 = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {} + read: function () {} }); _duplex5.resume(); + _duplex5._destroy = common.mustCall(function (err, cb) { var _this = this; + assert.strictEqual(err, null); process.nextTick(function () { _this.push(null); @@ -111,57 +135,72 @@ cb(); }); }); + var fail = common.mustNotCall('no finish or end event'); + _duplex5.on('finish', fail); _duplex5.on('end', fail); + _duplex5.destroy(); + _duplex5.removeListener('end', fail); _duplex5.removeListener('finish', fail); _duplex5.on('end', common.mustCall()); _duplex5.on('finish', common.mustCall()); assert.strictEqual(_duplex5.destroyed, true); } + { var _duplex6 = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {} + read: function () {} }); + var _expected3 = new Error('kaboom'); + _duplex6._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, null); cb(_expected3); }); + _duplex6.on('finish', common.mustNotCall('no finish event')); _duplex6.on('end', common.mustNotCall('no end event')); _duplex6.on('error', common.mustCall(function (err) { assert.strictEqual(err, _expected3); })); + _duplex6.destroy(); assert.strictEqual(_duplex6.destroyed, true); } + { var _duplex7 = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {}, + read: function () {}, + allowHalfOpen: true }); _duplex7.resume(); - _duplex7.on('finish', common.mustNotCall()); - _duplex7.on('end', common.mustNotCall()); + + _duplex7.on('finish', common.mustCall()); + _duplex7.on('end', common.mustCall()); + _duplex7.destroy(); assert.strictEqual(_duplex7.destroyed, true); } + { var _duplex8 = new Duplex({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, - read: function read() {} + read: function () {} }); + _duplex8.destroyed = true; assert.strictEqual(_duplex8.destroyed, true); @@ -170,24 +209,15 @@ _duplex8.on('end', common.mustNotCall()); _duplex8.destroy(); } + { - var MyDuplex = function MyDuplex() { + function MyDuplex() { assert.strictEqual(this.destroyed, false); this.destroyed = false; Duplex.call(this); - }; - Object.setPrototypeOf(MyDuplex.prototype, Duplex.prototype); - Object.setPrototypeOf(MyDuplex, Duplex); + } + + inherits(MyDuplex, Duplex); + new MyDuplex(); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-duplex.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-duplex.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -27,42 +25,31 @@ require('../common'); var assert = require('assert/'); var Duplex = require('../../').Duplex; -var stream = new Duplex({ - objectMode: true -}); + +var stream = new Duplex({ objectMode: true }); + assert(Duplex() instanceof Duplex); assert(stream._readableState.objectMode); assert(stream._writableState.objectMode); -assert(stream.allowHalfOpen); -assert.strictEqual(stream.listenerCount('end'), 0); -var written; -var read; + +var written = void 0; +var read = void 0; + stream._write = function (obj, _, cb) { written = obj; cb(); }; + stream._read = function () {}; + stream.on('data', function (obj) { read = obj; }); -stream.push({ - val: 1 -}); -stream.end({ - val: 2 -}); + +stream.push({ val: 1 }); +stream.end({ val: 2 }); + process.on('exit', function () { assert.strictEqual(read.val, 1); assert.strictEqual(written.val, 2); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-end-paused.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-end-paused.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -37,25 +35,18 @@ calledRead = true; this.push(null); }; + stream.on('data', function () { throw new Error('should not ever get data'); }); stream.pause(); + setTimeout(common.mustCall(function () { stream.on('end', common.mustCall()); stream.resume(); }), 1); + process.on('exit', function () { assert(calledRead); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + console.log('ok'); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-events-prepend.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-events-prepend.js
Changed
@@ -1,67 +1,52 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var stream = require('../../'); -var Writable = /*#__PURE__*/function (_stream$Writable) { + +var Writable = function (_stream$Writable) { _inherits(Writable, _stream$Writable); - var _super = _createSuper(Writable); + function Writable() { - var _this; _classCallCheck(this, Writable); - _this = _super.call(this); + + var _this = _possibleConstructorReturn(this, _stream$Writable.call(this)); + _this.prependListener = undefined; return _this; } - _createClass(Writable, { - key: "_write", - value: function _write(chunk, end, cb) { - cb(); - } - }); + + Writable.prototype._write = function _write(chunk, end, cb) { + cb(); + }; + return Writable; }(stream.Writable); -var Readable = /*#__PURE__*/function (_stream$Readable) { + +var Readable = function (_stream$Readable) { _inherits(Readable, _stream$Readable); - var _super2 = _createSuper(Readable); + function Readable() { _classCallCheck(this, Readable); - return _super2.apply(this, arguments); + + return _possibleConstructorReturn(this, _stream$Readable.apply(this, arguments)); } - _createClass(Readable, { - key: "_read", - value: function _read() { - this.push(null); - } - }); + + Readable.prototype._read = function _read() { + this.push(null); + }; + return Readable; }(stream.Readable); + var w = new Writable(); w.on('pipe', common.mustCall()); + var r = new Readable(); -r.pipe(w); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +r.pipe(w); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-ispaused.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-ispaused.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -27,6 +25,7 @@ require('../common'); var assert = require('assert/'); var stream = require('../../'); + var readable = new stream.Readable(); // _read is a noop, here. @@ -40,18 +39,8 @@ // still not paused. assert.ok(!readable.isPaused()); + readable.pause(); assert.ok(readable.isPaused()); readable.resume(); -assert.ok(!readable.isPaused()); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +assert.ok(!readable.isPaused()); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-objectmode-undefined.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-objectmode-undefined.js
Changed
@@ -1,14 +1,14 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var _require = require('../../'), - Readable = _require.Readable, - Writable = _require.Writable, - Transform = _require.Transform; + Readable = _require.Readable, + Writable = _require.Writable, + Transform = _require.Transform; + { var stream = new Readable({ objectMode: true, @@ -17,10 +17,12 @@ stream.push(null); }) }); + stream.on('data', common.mustCall(function (chunk) { assert.strictEqual(chunk, undefined); })); } + { var _stream = new Writable({ objectMode: true, @@ -28,8 +30,10 @@ assert.strictEqual(chunk, undefined); }) }); + _stream.write(undefined); } + { var _stream2 = new Transform({ objectMode: true, @@ -37,19 +41,10 @@ _stream2.push(chunk); }) }); + _stream2.on('data', common.mustCall(function (chunk) { assert.strictEqual(chunk, undefined); })); + _stream2.write(undefined); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-after-end.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-after-end.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -40,67 +32,64 @@ var assert = require('assert/'); var Readable = require('../../lib/_stream_readable'); var Writable = require('../../lib/_stream_writable'); -var TestReadable = /*#__PURE__*/function (_Readable) { + +var TestReadable = function (_Readable) { _inherits(TestReadable, _Readable); - var _super = _createSuper(TestReadable); + function TestReadable(opt) { - var _this; _classCallCheck(this, TestReadable); - _this = _super.call(this, opt); + + var _this = _possibleConstructorReturn(this, _Readable.call(this, opt)); + _this._ended = false; return _this; } - _createClass(TestReadable, { - key: "_read", - value: function _read() { - if (this._ended) this.emit('error', new Error('_read called twice')); - this._ended = true; - this.push(null); - } - }); + + TestReadable.prototype._read = function _read() { + if (this._ended) this.emit('error', new Error('_read called twice')); + this._ended = true; + this.push(null); + }; + return TestReadable; }(Readable); -var TestWritable = /*#__PURE__*/function (_Writable) { + +var TestWritable = function (_Writable) { _inherits(TestWritable, _Writable); - var _super2 = _createSuper(TestWritable); + function TestWritable(opt) { - var _this2; _classCallCheck(this, TestWritable); - _this2 = _super2.call(this, opt); + + var _this2 = _possibleConstructorReturn(this, _Writable.call(this, opt)); + _this2._written = ; return _this2; } - _createClass(TestWritable, { - key: "_write", - value: function _write(chunk, encoding, cb) { - this._written.push(chunk); - cb(); - } - }); + + TestWritable.prototype._write = function _write(chunk, encoding, cb) { + this._written.push(chunk); + cb(); + }; + return TestWritable; -}(Writable); // this one should not emit 'end' until we read() from it later. +}(Writable); + +// this one should not emit 'end' until we read() from it later. + + var ender = new TestReadable(); // what happens when you pipe() a Readable that's already ended? var piper = new TestReadable(); // pushes EOF null, and length=0, so this will trigger 'end' piper.read(); + setTimeout(common.mustCall(function () { ender.on('end', common.mustCall()); var c = ender.read(); assert.strictEqual(c, null); + var w = new TestWritable(); w.on('finish', common.mustCall()); piper.pipe(w); -}), 1); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +}), 1); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-await-drain-manual-resume.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-await-drain-manual-resume.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -13,20 +11,22 @@ var writable = new stream.Writable({ highWaterMark: 5 }); + var isCurrentlyBufferingWrites = true; var queue = ; + writable._write = function (chunk, encoding, cb) { - if (isCurrentlyBufferingWrites) queue.push({ - chunk: chunk, - cb: cb - });else cb(); + if (isCurrentlyBufferingWrites) queue.push({ chunk: chunk, cb: cb });else cb(); }; + var readable = new stream.Readable({ - read: function read() {} + read: function () {} }); + readable.pipe(writable); + readable.once('pause', common.mustCall(function () { - assert.strictEqual(readable._readableState.awaitDrain, 1, 'Expected awaitDrain to equal 1 but instead got ' + "".concat(readable._readableState.awaitDrain)); + assert.strictEqual(readable._readableState.awaitDrain, 1, 'Expected awaitDrain to equal 1 but instead got ' + ('' + readable._readableState.awaitDrain)); // First pause, resume manually. The next write() to writable will still // return false, because chunks are still being buffered, so it will increase // the awaitDrain counter again. @@ -34,36 +34,47 @@ process.nextTick(common.mustCall(function () { readable.resume(); })); + readable.once('pause', common.mustCall(function () { - assert.strictEqual(readable._readableState.awaitDrain, 1, '.resume() should not reset the counter but instead got ' + "".concat(readable._readableState.awaitDrain)); + assert.strictEqual(readable._readableState.awaitDrain, 1, '.resume() should not reset the counter but instead got ' + ('' + readable._readableState.awaitDrain)); // Second pause, handle all chunks from now on. Once all callbacks that // are currently queued up are handled, the awaitDrain drain counter should // fall back to 0 and all chunks that are pending on the readable side // should be flushed. isCurrentlyBufferingWrites = false; - for (var _i = 0, _queue = queue; _i < _queue.length; _i++) { - var queued = _queue_i; - queued.cb(); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = queueSymbol.iterator(), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var queued = _step.value; + + queued.cb(); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } } })); })); + readable.push(bufferShim.alloc(100)); // Fill the writable HWM, first 'pause'. readable.push(bufferShim.alloc(100)); // Second 'pause'. readable.push(bufferShim.alloc(100)); // Should get through to the writable. readable.push(null); + writable.on('finish', common.mustCall(function () { - assert.strictEqual(readable._readableState.awaitDrain, 0, 'awaitDrain should equal 0 after all chunks are written but instead got' + "".concat(readable._readableState.awaitDrain)); + assert.strictEqual(readable._readableState.awaitDrain, 0, 'awaitDrain should equal 0 after all chunks are written but instead got' + ('' + readable._readableState.awaitDrain)); // Everything okay, all chunks were written. -})); - -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +})); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-await-drain-push-while-write.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-await-drain-push-while-write.js
Changed
@@ -1,23 +1,31 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var stream = require('../../'); var assert = require('assert/'); + +var awaitDrainStates = 1, // after first chunk before callback +1, // after second chunk before callback +0 // resolving chunk pushed after first chunk, awaitDrain is decreased +; + +// A writable stream which pushes data onto the stream which pipes into it, +// but only the first time it's written to. Since it's not paused at this time, +// a second write will occur. If the pipe increases awaitDrain twice, we'll +// never get subsequent chunks because 'drain' is only emitted once. var writable = new stream.Writable({ write: common.mustCall(function (chunk, encoding, cb) { - assert.strictEqual(readable._readableState.awaitDrain, 0); if (chunk.length === 32 * 1024) { // first chunk + var beforePush = readable._readableState.awaitDrain; readable.push(bufferShim.alloc(34 * 1024)); // above hwm - // We should check if awaitDrain counter is increased in the next - // tick, because awaitDrain is incremented after this method finished - process.nextTick(function () { - assert.strictEqual(readable._readableState.awaitDrain, 1); - }); + // We should check if awaitDrain counter is increased. + var afterPush = readable._readableState.awaitDrain; + assert.strictEqual(afterPush - beforePush, 1, 'Counter is not increased for awaitDrain'); } + + assert.strictEqual(awaitDrainStates.shift(), readable._readableState.awaitDrain, 'State variable awaitDrain is not correct.'); cb(); }, 3) }); @@ -25,21 +33,11 @@ // A readable stream which produces two buffers. var bufs = bufferShim.alloc(32 * 1024), bufferShim.alloc(33 * 1024); // above hwm var readable = new stream.Readable({ - read: function read() { + read: function () { while (bufs.length > 0) { this.push(bufs.shift()); } } }); -readable.pipe(writable); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +readable.pipe(writable); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-await-drain.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-await-drain.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -18,13 +16,16 @@ // and will cause `.write()` to return false // See: https://github.com/nodejs/node/issues/5820 var buffer = bufferShim.allocUnsafe(560000); + reader._read = function () {}; + writer1._write = common.mustCall(function (chunk, encoding, cb) { this.emit('chunk-received'); cb(); }, 1); + writer1.once('chunk-received', function () { - assert.strictEqual(reader._readableState.awaitDrain, 0, 'awaitDrain initial value should be 0, actual is ' + reader._readableState.awaitDrain); + assert.strictEqual(reader._readableState.awaitDrain, 0, 'initial value is not 0'); setImmediate(function () { // This one should *not* get through to writer1 because writer2 is not // "done" processing. @@ -34,29 +35,20 @@ // A "slow" consumer: writer2._write = common.mustCall(function (chunk, encoding, cb) { - assert.strictEqual(reader._readableState.awaitDrain, 1, 'awaitDrain should be 1 after first push, actual is ' + reader._readableState.awaitDrain); + assert.strictEqual(reader._readableState.awaitDrain, 1, 'awaitDrain isn\'t 1 after first push'); // Not calling cb here to "simulate" slow stream. // This should be called exactly once, since the first .write() call // will return false. }, 1); + writer3._write = common.mustCall(function (chunk, encoding, cb) { - assert.strictEqual(reader._readableState.awaitDrain, 2, 'awaitDrain should be 2 after second push, actual is ' + reader._readableState.awaitDrain); + assert.strictEqual(reader._readableState.awaitDrain, 2, 'awaitDrain isn\'t 2 after second push'); // Not calling cb here to "simulate" slow stream. // This should be called exactly once, since the first .write() call // will return false. }, 1); + reader.pipe(writer1); reader.pipe(writer2); reader.pipe(writer3); -reader.push(buffer); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +reader.push(buffer); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-cleanup-pause.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-cleanup-pause.js
Changed
@@ -1,10 +1,9 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var stream = require('../../'); + var reader = new stream.Readable(); var writer1 = new stream.Writable(); var writer2 = new stream.Writable(); @@ -13,7 +12,9 @@ // and will cause `.write()` to return false // See: https://github.com/nodejs/node/issues/2323 var buffer = bufferShim.allocUnsafe(560000); + reader._read = function () {}; + writer1._write = common.mustCall(function (chunk, encoding, cb) { this.emit('chunk-received'); cb(); @@ -29,19 +30,10 @@ }); }); }); + writer2._write = common.mustCall(function (chunk, encoding, cb) { cb(); }, 3); + reader.pipe(writer1); -reader.push(buffer); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +reader.push(buffer); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-cleanup.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-cleanup.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -29,60 +27,73 @@ require('../common'); var stream = require('../../'); var assert = require('assert/'); +var util = require('util'); + (function () { if (/^v0\.8\./.test(process.version)) return; + function Writable() { this.writable = true; this.endCalls = 0; require('stream').Stream.call(this); } - Object.setPrototypeOf(Writable.prototype, require('stream').Stream.prototype); - Object.setPrototypeOf(Writable, require('stream').Stream); + util.inherits(Writable, require('stream').Stream); Writable.prototype.end = function () { this.endCalls++; }; + Writable.prototype.destroy = function () { this.endCalls++; }; + function Readable() { this.readable = true; require('stream').Stream.call(this); } - Object.setPrototypeOf(Readable.prototype, require('stream').Stream.prototype); - Object.setPrototypeOf(Readable, require('stream').Stream); + util.inherits(Readable, require('stream').Stream); + function Duplex() { this.readable = true; Writable.call(this); } - Object.setPrototypeOf(Duplex.prototype, Writable.prototype); - Object.setPrototypeOf(Duplex, Writable); + util.inherits(Duplex, Writable); + var i = 0; var limit = 100; + var w = new Writable(); - var r; + + var r = void 0; + for (i = 0; i < limit; i++) { r = new Readable(); r.pipe(w); r.emit('end'); } - assert.strictEqual(r.listeners('end').length, 0); - assert.strictEqual(w.endCalls, limit); + assert.strictEqual(0, r.listeners('end').length); + assert.strictEqual(limit, w.endCalls); + w.endCalls = 0; + for (i = 0; i < limit; i++) { r = new Readable(); r.pipe(w); r.emit('close'); } - assert.strictEqual(r.listeners('close').length, 0); - assert.strictEqual(w.endCalls, limit); + assert.strictEqual(0, r.listeners('close').length); + assert.strictEqual(limit, w.endCalls); + w.endCalls = 0; + r = new Readable(); + for (i = 0; i < limit; i++) { w = new Writable(); r.pipe(w); w.emit('close'); } - assert.strictEqual(w.listeners('close').length, 0); + assert.strictEqual(0, w.listeners('close').length); + r = new Readable(); w = new Writable(); var d = new Duplex(); @@ -115,14 +126,4 @@ assert.strictEqual(d.listeners('close').length, 0); assert.strictEqual(w.listeners('end').length, 0); assert.strictEqual(w.listeners('close').length, 0); -})(); -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +})(); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-error-handling.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-error-handling.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -27,40 +25,49 @@ var common = require('../common'); var assert = require('assert/'); var Stream = require('stream').Stream; + { var source = new Stream(); var dest = new Stream(); + source.pipe(dest); + var gotErr = null; source.on('error', function (err) { gotErr = err; }); + var err = new Error('This stream turned into bacon.'); source.emit('error', err); assert.strictEqual(gotErr, err); } + { var _source = new Stream(); var _dest = new Stream(); + _source.pipe(_dest); + var _err = new Error('This stream turned into bacon.'); + var _gotErr = null; try { _source.emit('error', _err); } catch (e) { _gotErr = e; } + assert.strictEqual(_gotErr, _err); } + { - var myOnError = function myOnError() { - throw new Error('this should not happen'); - }; var R = require('../../').Readable; var W = require('../../').Writable; + var r = new R(); var w = new W(); var removed = false; + r._read = common.mustCall(function () { setTimeout(common.mustCall(function () { assert(removed); @@ -69,38 +76,37 @@ }, /^Error: fail$/); }), 1); }); + w.on('error', myOnError); r.pipe(w); w.removeListener('error', myOnError); removed = true; + + function myOnError() { + throw new Error('this should not happen'); + } } + { var _R = require('../../').Readable; var _W = require('../../').Writable; + var _r = new _R(); var _w = new _W(); var _removed = false; + _r._read = common.mustCall(function () { setTimeout(common.mustCall(function () { assert(_removed); _w.emit('error', new Error('fail')); }), 1); }); + _w.on('error', common.mustCall()); _w._write = function () {}; + _r.pipe(_w); // Removing some OTHER random listener should not do anything _w.removeListener('error', function () {}); _removed = true; -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-event.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-event.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -27,34 +25,28 @@ require('../common'); var stream = require('../../'); var assert = require('assert/'); +var util = require('util'); + function Writable() { this.writable = true; require('stream').Stream.call(this); } -Object.setPrototypeOf(Writable.prototype, require('stream').Stream.prototype); -Object.setPrototypeOf(Writable, require('stream').Stream); +util.inherits(Writable, require('stream').Stream); + function Readable() { this.readable = true; require('stream').Stream.call(this); } -Object.setPrototypeOf(Readable.prototype, require('stream').Stream.prototype); -Object.setPrototypeOf(Readable, require('stream').Stream); +util.inherits(Readable, require('stream').Stream); + var passed = false; + var w = new Writable(); w.on('pipe', function (src) { passed = true; }); + var r = new Readable(); r.pipe(w); -assert.ok(passed); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +assert.ok(passed); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-multiple-pipes.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-multiple-pipes.js
Changed
@@ -1,16 +1,17 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var stream = require('../../'); var assert = require('assert/'); + var readable = new stream.Readable({ - read: function read() {} + read: function () {} }); + var writables = ; -var _loop = function _loop() { + +var _loop = function (i) { var target = new stream.Writable({ write: common.mustCall(function (chunk, encoding, callback) { target.output.push(chunk); @@ -18,44 +19,80 @@ }, 1) }); target.output = ; + target.on('pipe', common.mustCall()); readable.pipe(target); + writables.push(target); }; + for (var i = 0; i < 5; i++) { - _loop(); + _loop(i); } + var input = bufferShim.from(1, 2, 3, 4, 5); + readable.push(input); // The pipe() calls will postpone emission of the 'resume' event using nextTick, // so no data will be available to the writable streams until then. process.nextTick(common.mustCall(function () { - for (var _i = 0, _writables = writables; _i < _writables.length; _i++) { - var target = _writables_i; - assert.deepStrictEqual(target.output, input); - target.on('unpipe', common.mustCall()); - readable.unpipe(target); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = writablesSymbol.iterator(), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var _target = _step.value; + + assert.deepStrictEqual(_target.output, input); + + _target.on('unpipe', common.mustCall()); + readable.unpipe(_target); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } } + readable.push('something else'); // This does not get through. readable.push(null); readable.resume(); // Make sure the 'end' event gets emitted. })); readable.on('end', common.mustCall(function () { - for (var _i2 = 0, _writables2 = writables; _i2 < _writables2.length; _i2++) { - var target = _writables2_i2; - assert.deepStrictEqual(target.output, input); + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = writablesSymbol.iterator(), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var _target2 = _step2.value; + + assert.deepStrictEqual(_target2.output, input); + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } } -})); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +})); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-same-destination-twice.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-same-destination-twice.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -9,71 +7,77 @@ // Tests that piping a source stream twice to the same destination stream // works, and that a subsequent unpipe() call only removes the pipe *once*. var assert = require('assert/'); + var _require = require('../../'), - PassThrough = _require.PassThrough, - Writable = _require.Writable; + PassThrough = _require.PassThrough, + Writable = _require.Writable; + { var passThrough = new PassThrough(); var dest = new Writable({ write: common.mustCall(function (chunk, encoding, cb) { - assert.strictEqual("".concat(chunk), 'foobar'); + assert.strictEqual('' + chunk, 'foobar'); cb(); }) }); + passThrough.pipe(dest); passThrough.pipe(dest); + assert.strictEqual(passThrough._events.data.length, 2); assert.strictEqual(passThrough._readableState.pipesCount, 2); assert.strictEqual(passThrough._readableState.pipes0, dest); assert.strictEqual(passThrough._readableState.pipes1, dest); + passThrough.unpipe(dest); + assert.strictEqual(passThrough._events.data.length, 1); assert.strictEqual(passThrough._readableState.pipesCount, 1); assert.strictEqual(passThrough._readableState.pipes, dest); + passThrough.write('foobar'); passThrough.pipe(dest); } + { var _passThrough = new PassThrough(); var _dest = new Writable({ write: common.mustCall(function (chunk, encoding, cb) { - assert.strictEqual("".concat(chunk), 'foobar'); + assert.strictEqual('' + chunk, 'foobar'); cb(); }, 2) }); + _passThrough.pipe(_dest); _passThrough.pipe(_dest); + assert.strictEqual(_passThrough._events.data.length, 2); assert.strictEqual(_passThrough._readableState.pipesCount, 2); assert.strictEqual(_passThrough._readableState.pipes0, _dest); assert.strictEqual(_passThrough._readableState.pipes1, _dest); + _passThrough.write('foobar'); } + { var _passThrough2 = new PassThrough(); var _dest2 = new Writable({ write: common.mustNotCall() }); + _passThrough2.pipe(_dest2); _passThrough2.pipe(_dest2); + assert.strictEqual(_passThrough2._events.data.length, 2); assert.strictEqual(_passThrough2._readableState.pipesCount, 2); assert.strictEqual(_passThrough2._readableState.pipes0, _dest2); assert.strictEqual(_passThrough2._readableState.pipes1, _dest2); + _passThrough2.unpipe(_dest2); _passThrough2.unpipe(_dest2); + assert.strictEqual(_passThrough2._events.data, undefined); assert.strictEqual(_passThrough2._readableState.pipesCount, 0); + _passThrough2.write('foobar'); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-unpipe-streams.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-unpipe-streams.js
Changed
@@ -1,26 +1,23 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var _require = require('../../'), - Readable = _require.Readable, - Writable = _require.Writable; -var source = Readable({ - read: function read() {} -}); -var dest1 = Writable({ - write: function write() {} -}); -var dest2 = Writable({ - write: function write() {} -}); + Readable = _require.Readable, + Writable = _require.Writable; + +var source = Readable({ read: function () {} }); +var dest1 = Writable({ write: function () {} }); +var dest2 = Writable({ write: function () {} }); + source.pipe(dest1); source.pipe(dest2); + dest1.on('unpipe', common.mustCall()); dest2.on('unpipe', common.mustCall()); + assert.strictEqual(source._readableState.pipes0, dest1); assert.strictEqual(source._readableState.pipes1, dest2); assert.strictEqual(source._readableState.pipes.length, 2); @@ -28,59 +25,13 @@ // Should be able to unpipe them in the reverse order that they were piped. source.unpipe(dest2); + assert.strictEqual(source._readableState.pipes, dest1); assert.notStrictEqual(source._readableState.pipes, dest2); + dest2.on('unpipe', common.mustNotCall()); source.unpipe(dest2); + source.unpipe(dest1); -assert.strictEqual(source._readableState.pipes, null); -{ - var checkDestCleanup = function checkDestCleanup(dest) { - var currentDestId = ++destCount; - _source.pipe(dest); - var unpipeChecker = common.mustCall(function () { - assert.deepStrictEqual(dest.listeners('unpipe'), unpipeChecker, "destination{".concat(currentDestId, "} should have a 'unpipe' event ") + 'listener which is `unpipeChecker`'); - dest.removeListener('unpipe', unpipeChecker); - destCheckEventNames.forEach(function (eventName) { - assert.strictEqual(dest.listenerCount(eventName), 0, "destination{".concat(currentDestId, "}'s '").concat(eventName, "' event ") + 'listeners not removed'); - }); - if (--destCount === 0) checkSrcCleanup(); - }); - dest.on('unpipe', unpipeChecker); - }; - // test `cleanup()` if we unpipe all streams. - var _source = Readable({ - read: function read() {} - }); - var _dest = Writable({ - write: function write() {} - }); - var _dest2 = Writable({ - write: function write() {} - }); - var destCount = 0; - var srcCheckEventNames = 'end', 'data'; - var destCheckEventNames = 'close', 'finish', 'drain', 'error', 'unpipe'; - var checkSrcCleanup = common.mustCall(function () { - assert.strictEqual(_source._readableState.pipes, null); - assert.strictEqual(_source._readableState.pipesCount, 0); - assert.strictEqual(_source._readableState.flowing, false); - srcCheckEventNames.forEach(function (eventName) { - assert.strictEqual(_source.listenerCount(eventName), 0, "source's '".concat(eventName, "' event listeners not removed")); - }); - }); - checkDestCleanup(_dest); - checkDestCleanup(_dest2); - _source.unpipe(); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +assert.strictEqual(source._readableState.pipes, null); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-without-listenerCount.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-pipe-without-listenerCount.js
Changed
@@ -1,29 +1,19 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var stream = require('../../'); + var r = new stream.Stream(); r.listenerCount = undefined; + var w = new stream.Stream(); w.listenerCount = undefined; + w.on('pipe', function () { r.emit('error', new Error('Readable Error')); w.emit('error', new Error('Writable Error')); }); r.on('error', common.mustCall()); w.on('error', common.mustCall()); -r.pipe(w); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +r.pipe(w); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-push-order.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-push-order.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -27,11 +25,14 @@ require('../common'); var Readable = require('../../').Readable; var assert = require('assert/'); + var s = new Readable({ highWaterMark: 20, encoding: 'ascii' }); + var list = '1', '2', '3', '4', '5', '6'; + s._read = function (n) { var one = list.shift(); if (!one) { @@ -42,22 +43,12 @@ s.push(two); } }; + s.read(0); // ACTUALLY 1, 3, 5, 6, 4, 2 process.on('exit', function () { - assert.deepStrictEqual(s.readableBuffer.join(','), '1,2,3,4,5,6'); - require('tap').pass(); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + assert.deepStrictEqual(s._readableState.buffer.join(','), '1,2,3,4,5,6'); + console.log('ok'); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-push-strings.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-push-strings.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -38,61 +30,57 @@ /*</replacement>*/ require('../common'); var assert = require('assert/'); + var Readable = require('../../').Readable; -var MyStream = /*#__PURE__*/function (_Readable) { + +var MyStream = function (_Readable) { _inherits(MyStream, _Readable); - var _super = _createSuper(MyStream); + function MyStream(options) { - var _this; _classCallCheck(this, MyStream); - _this = _super.call(this, options); + + var _this = _possibleConstructorReturn(this, _Readable.call(this, options)); + _this._chunks = 3; return _this; } - _createClass(MyStream, { - key: "_read", - value: function _read(n) { - var _this2 = this; - switch (this._chunks--) { - case 0: - return this.push(null); - case 1: - return setTimeout(function () { - _this2.push('last chunk'); - }, 100); - case 2: - return this.push('second to last chunk'); - case 3: - return process.nextTick(function () { - _this2.push('first chunk'); - }); - default: - throw new Error('?'); - } + + MyStream.prototype._read = function _read(n) { + var _this2 = this; + + switch (this._chunks--) { + case 0: + return this.push(null); + case 1: + return setTimeout(function () { + _this2.push('last chunk'); + }, 100); + case 2: + return this.push('second to last chunk'); + case 3: + return process.nextTick(function () { + _this2.push('first chunk'); + }); + default: + throw new Error('?'); } - }); + }; + return MyStream; }(Readable); + var ms = new MyStream(); var results = ; ms.on('readable', function () { - var chunk; - while (null !== (chunk = ms.read())) results.push(String(chunk)); + var chunk = void 0; + while (null !== (chunk = ms.read())) { + results.push(String(chunk)); + } }); + var expect = 'first chunksecond to last chunk', 'last chunk'; process.on('exit', function () { assert.strictEqual(ms._chunks, -1); assert.deepStrictEqual(results, expect); - require('tap').pass(); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + console.log('ok'); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-constructor-set-methods.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-constructor-set-methods.js
Changed
@@ -1,25 +1,13 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); + var Readable = require('../../').Readable; + var _read = common.mustCall(function _read(n) { this.push(null); }); -var r = new Readable({ - read: _read -}); -r.resume(); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +var r = new Readable({ read: _read }); +r.resume(); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-destroy.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-destroy.js
Changed
@@ -1,123 +1,156 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); + var _require = require('../../'), - Readable = _require.Readable; + Readable = _require.Readable; + var assert = require('assert/'); + +var _require2 = require('util'), + inherits = _require2.inherits; + { var read = new Readable({ - read: function read() {} + read: function () {} }); read.resume(); - read.on('close', common.mustCall()); + + read.on('end', common.mustCall()); + read.destroy(); assert.strictEqual(read.destroyed, true); } + { var _read = new Readable({ - read: function read() {} + read: function () {} }); _read.resume(); + var expected = new Error('kaboom'); - _read.on('end', common.mustNotCall('no end event')); - _read.on('close', common.mustCall()); + + _read.on('end', common.mustCall()); _read.on('error', common.mustCall(function (err) { assert.strictEqual(err, expected); })); + _read.destroy(expected); assert.strictEqual(_read.destroyed, true); } + { var _read2 = new Readable({ - read: function read() {} + read: function () {} }); + _read2._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, _expected); cb(err); }); + var _expected = new Error('kaboom'); + _read2.on('end', common.mustNotCall('no end event')); - _read2.on('close', common.mustCall()); _read2.on('error', common.mustCall(function (err) { assert.strictEqual(err, _expected); })); + _read2.destroy(_expected); assert.strictEqual(_read2.destroyed, true); } + { var _read3 = new Readable({ - read: function read() {}, + read: function () {}, + destroy: common.mustCall(function (err, cb) { assert.strictEqual(err, _expected2); cb(); }) }); + var _expected2 = new Error('kaboom'); + _read3.on('end', common.mustNotCall('no end event')); // error is swallowed by the custom _destroy _read3.on('error', common.mustNotCall('no error event')); - _read3.on('close', common.mustCall()); + _read3.destroy(_expected2); assert.strictEqual(_read3.destroyed, true); } + { var _read4 = new Readable({ - read: function read() {} + read: function () {} }); + _read4._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, null); cb(); }); + _read4.destroy(); assert.strictEqual(_read4.destroyed, true); } + { var _read5 = new Readable({ - read: function read() {} + read: function () {} }); _read5.resume(); + _read5._destroy = common.mustCall(function (err, cb) { var _this = this; + assert.strictEqual(err, null); process.nextTick(function () { _this.push(null); cb(); }); }); + var fail = common.mustNotCall('no end event'); + _read5.on('end', fail); - _read5.on('close', common.mustCall()); + _read5.destroy(); + _read5.removeListener('end', fail); _read5.on('end', common.mustCall()); assert.strictEqual(_read5.destroyed, true); } + { var _read6 = new Readable({ - read: function read() {} + read: function () {} }); + var _expected3 = new Error('kaboom'); + _read6._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, null); cb(_expected3); }); + _read6.on('end', common.mustNotCall('no end event')); _read6.on('error', common.mustCall(function (err) { assert.strictEqual(err, _expected3); })); + _read6.destroy(); assert.strictEqual(_read6.destroyed, true); } + { var _read7 = new Readable({ - read: function read() {} + read: function () {} }); _read7.resume(); + _read7.destroyed = true; assert.strictEqual(_read7.destroyed, true); @@ -125,44 +158,29 @@ _read7.on('end', common.mustNotCall()); _read7.destroy(); } + { - var MyReadable = function MyReadable() { + function MyReadable() { assert.strictEqual(this.destroyed, false); this.destroyed = false; Readable.call(this); - }; - Object.setPrototypeOf(MyReadable.prototype, Readable.prototype); - Object.setPrototypeOf(MyReadable, Readable); + } + + inherits(MyReadable, Readable); + new MyReadable(); } + { // destroy and destroy callback var _read8 = new Readable({ - read: function read() {} + read: function () {} }); _read8.resume(); + var _expected4 = new Error('kaboom'); - _read8.on('close', common.mustCall()); + _read8.destroy(_expected4, common.mustCall(function (err) { - assert.strictEqual(err, _expected4); + assert.strictEqual(_expected4, err); })); -} -{ - var _read9 = new Readable({ - read: function read() {} - }); - _read9.destroy(); - _read9.push('hi'); - _read9.on('data', common.mustNotCall()); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-emittedReadable.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-emittedReadable.js
Changed
@@ -1,48 +1,47 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); var Readable = require('../../').Readable; + var readable = new Readable({ - read: function read() {} + read: function () {} }); // Initialized to false. assert.strictEqual(readable._readableState.emittedReadable, false); -var expected = bufferShim.from('foobar'), bufferShim.from('quo'), null; + readable.on('readable', common.mustCall(function () { // emittedReadable should be true when the readable event is emitted assert.strictEqual(readable._readableState.emittedReadable, true); - assert.deepStrictEqual(readable.read(), expected.shift()); + readable.read(); // emittedReadable is reset to false during read() assert.strictEqual(readable._readableState.emittedReadable, false); -}, 3)); +}, 4)); // When the first readable listener is just attached, // emittedReadable should be false assert.strictEqual(readable._readableState.emittedReadable, false); -// These trigger a single 'readable', as things are batched up +// Each one of these should trigger a readable event. process.nextTick(common.mustCall(function () { readable.push('foo'); })); process.nextTick(common.mustCall(function () { readable.push('bar'); })); - -// these triggers two readable events -setImmediate(common.mustCall(function () { +process.nextTick(common.mustCall(function () { readable.push('quo'); - process.nextTick(common.mustCall(function () { - readable.push(null); - })); })); +process.nextTick(common.mustCall(function () { + readable.push(null); +})); + var noRead = new Readable({ - read: function read() {} + read: function () {} }); + noRead.on('readable', common.mustCall(function () { // emittedReadable should be true when the readable event is emitted assert.strictEqual(noRead._readableState.emittedReadable, true); @@ -50,31 +49,24 @@ // emittedReadable is not reset during read(0) assert.strictEqual(noRead._readableState.emittedReadable, true); })); + noRead.push('foo'); noRead.push(null); + var flowing = new Readable({ - read: function read() {} + read: function () {} }); + flowing.on('data', common.mustCall(function () { // When in flowing mode, emittedReadable is always false. assert.strictEqual(flowing._readableState.emittedReadable, false); flowing.read(); assert.strictEqual(flowing._readableState.emittedReadable, false); }, 3)); + flowing.push('foooo'); flowing.push('bar'); flowing.push('quo'); process.nextTick(common.mustCall(function () { flowing.push(null); -})); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +})); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-event.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-event.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,23 +24,28 @@ /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var Readable = require('../../').Readable; + { // First test, not reading when the readable is added. // make sure that on('readable', ...) triggers a readable event. var r = new Readable({ highWaterMark: 3 }); + r._read = common.mustNotCall(); // This triggers a 'readable' event, which is lost. r.push(bufferShim.from('blerg')); + setTimeout(function () { // we're testing what we think we are assert(!r._readableState.reading); r.on('readable', common.mustCall()); }, 1); } + { // second test, make sure that readable is re-emitted if there's // already a length, while it IS reading. @@ -50,80 +53,35 @@ var _r = new Readable({ highWaterMark: 3 }); + _r._read = common.mustCall(); // This triggers a 'readable' event, which is lost. _r.push(bufferShim.from('bl')); + setTimeout(function () { // assert we're testing what we think we are assert(_r._readableState.reading); _r.on('readable', common.mustCall()); }, 1); } + { // Third test, not reading when the stream has not passed // the highWaterMark but *has* reached EOF. var _r2 = new Readable({ highWaterMark: 30 }); + _r2._read = common.mustNotCall(); // This triggers a 'readable' event, which is lost. _r2.push(bufferShim.from('blerg')); _r2.push(null); + setTimeout(function () { // assert we're testing what we think we are assert(!_r2._readableState.reading); _r2.on('readable', common.mustCall()); }, 1); -} -{ - // pushing a empty string in non-objectMode should - // trigger next `read()`. - var underlyingData = '', 'x', 'y', '', 'z'; - var expected = underlyingData.filter(function (data) { - return data; - }); - var result = ; - var _r3 = new Readable({ - encoding: 'utf8' - }); - _r3._read = function () { - var _this = this; - process.nextTick(function () { - if (!underlyingData.length) { - _this.push(null); - } else { - _this.push(underlyingData.shift()); - } - }); - }; - _r3.on('readable', function () { - var data = _r3.read(); - if (data !== null) result.push(data); - }); - _r3.on('end', common.mustCall(function () { - assert.deepStrictEqual(result, expected); - })); -} -{ - // #20923 - var _r4 = new Readable(); - _r4._read = function () { - // actually doing thing here - }; - _r4.on('data', function () {}); - _r4.removeAllListeners(); - assert.strictEqual(_r4.eventNames().length, 0); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-flow-recursion.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-flow-recursion.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -36,9 +34,8 @@ // throw an error if we trigger a nextTick warning. process.throwDeprecation = true; -var stream = new Readable({ - highWaterMark: 2 -}); + +var stream = new Readable({ highWaterMark: 2 }); var reads = 0; var total = 5000; stream._read = function (size) { @@ -47,35 +44,30 @@ total -= size; if (size === 0) stream.push(null);else stream.push(bufferShim.allocUnsafe(size)); }; + var depth = 0; + function flow(stream, size, callback) { depth += 1; var chunk = stream.read(size); + if (!chunk) stream.once('readable', flow.bind(null, stream, size, callback));else callback(chunk); + depth -= 1; - console.log("flow(".concat(depth, "): exit")); + console.log('flow(' + depth + '): exit'); } + flow(stream, 5000, function () { - console.log("complete (".concat(depth, ")")); + console.log('complete (' + depth + ')'); }); + process.on('exit', function (code) { assert.strictEqual(reads, 2); // we pushed up the high water mark assert.strictEqual(stream.readableHighWaterMark, 8192); // length is 0 right now, because we pulled it all out. - assert.strictEqual(stream.readableLength, 0); + assert.strictEqual(stream._readableState.length, 0); assert(!code); assert.strictEqual(depth, 0); - require('tap').pass(); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + console.log('ok'); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-invalid-chunk.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-invalid-chunk.js
Changed
@@ -1,37 +1,22 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ -var common = require('../common'); +require('../common'); var stream = require('../../'); +var assert = require('assert/'); + var readable = new stream.Readable({ - read: function read() {} + read: function () {} }); -function checkError(fn) { - common.expectsError(fn, { - code: 'ERR_INVALID_ARG_TYPE', - type: TypeError - }); -} -checkError(function () { + +var errMessage = /Invalid non-string\/buffer chunk/; +assert.throws(function () { return readable.push(); -}); -checkError(function () { +}, errMessage); +assert.throws(function () { return readable.push({}); -}); -checkError(function () { +}, errMessage); +assert.throws(function () { return readable.push(0); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +}, errMessage); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-needReadable.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-needReadable.js
Changed
@@ -1,17 +1,17 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); var Readable = require('../../').Readable; + var readable = new Readable({ - read: function read() {} + read: function () {} }); // Initialized to false. assert.strictEqual(readable._readableState.needReadable, false); + readable.on('readable', common.mustCall(function () { // When the readable event fires, needReadable is reset. assert.strictEqual(readable._readableState.needReadable, false); @@ -20,15 +20,19 @@ // If a readable listener is attached, then a readable event is needed. assert.strictEqual(readable._readableState.needReadable, true); + readable.push('foo'); readable.push(null); + readable.on('end', common.mustCall(function () { // No need to emit readable anymore when the stream ends. assert.strictEqual(readable._readableState.needReadable, false); })); + var asyncReadable = new Readable({ - read: function read() {} + read: function () {} }); + asyncReadable.on('readable', common.mustCall(function () { if (asyncReadable.read() !== null) { // After each read(), the buffer is empty. @@ -36,19 +40,20 @@ // then we need to notify the reader on future changes. assert.strictEqual(asyncReadable._readableState.needReadable, true); } -}, 2)); +}, 3)); + process.nextTick(common.mustCall(function () { asyncReadable.push('foooo'); })); process.nextTick(common.mustCall(function () { asyncReadable.push('bar'); })); -setImmediate(common.mustCall(function () { +process.nextTick(common.mustCall(function () { asyncReadable.push(null); - assert.strictEqual(asyncReadable._readableState.needReadable, false); })); + var flowing = new Readable({ - read: function read() {} + read: function () {} }); // Notice this must be above the on('data') call. @@ -64,9 +69,11 @@ flowing.on('data', common.mustCall(function (data) { assert.strictEqual(flowing._readableState.needReadable, false); }, 3)); + var slowProducer = new Readable({ - read: function read() {} + read: function () {} }); + slowProducer.on('readable', common.mustCall(function () { if (slowProducer.read(8) === null) { // The buffer doesn't have enough data, and the stream is not need, @@ -76,26 +83,16 @@ assert.strictEqual(slowProducer._readableState.needReadable, false); } }, 4)); + +process.nextTick(common.mustCall(function () { + slowProducer.push('foo'); +})); process.nextTick(common.mustCall(function () { slowProducer.push('foo'); - process.nextTick(common.mustCall(function () { - slowProducer.push('foo'); - process.nextTick(common.mustCall(function () { - slowProducer.push('foo'); - process.nextTick(common.mustCall(function () { - slowProducer.push(null); - })); - })); - })); })); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +process.nextTick(common.mustCall(function () { + slowProducer.push('foo'); +})); +process.nextTick(common.mustCall(function () { + slowProducer.push(null); +})); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-reading-readingMore.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-reading-readingMore.js
Changed
@@ -1,160 +1,66 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); var Readable = require('../../').Readable; -{ - var onStreamEnd = function onStreamEnd() { - // End of stream; state.reading is false - // And so should be readingMore. - assert.strictEqual(state.readingMore, false); - assert.strictEqual(state.reading, false); - }; - var readable = new Readable({ - read: function read(size) {} - }); - var state = readable._readableState; - - // Starting off with false initially. - assert.strictEqual(state.reading, false); + +var readable = new Readable({ + read: function (size) {} +}); + +var state = readable._readableState; + +// Starting off with false initially. +assert.strictEqual(state.reading, false); +assert.strictEqual(state.readingMore, false); + +readable.on('data', common.mustCall(function (data) { + // while in a flowing state, should try to read more. + if (state.flowing) assert.strictEqual(state.readingMore, true); + + // reading as long as we've not ended + assert.strictEqual(state.reading, !state.ended); +}, 2)); + +function onStreamEnd() { + // End of stream; state.reading is false + // And so should be readingMore. assert.strictEqual(state.readingMore, false); - readable.on('data', common.mustCall(function (data) { - // while in a flowing state with a 'readable' listener - // we should not be reading more - if (readable.readableFlowing) assert.strictEqual(state.readingMore, true); - - // reading as long as we've not ended - assert.strictEqual(state.reading, !state.ended); - }, 2)); - var expectedReadingMore = true, false; - readable.on('readable', common.mustCall(function () { - // there is only one readingMore scheduled from on('data'), - // after which everything is governed by the .read() call - assert.strictEqual(state.readingMore, expectedReadingMore.shift()); - - // if the stream has ended, we shouldn't be reading - assert.strictEqual(state.ended, !state.reading); - var data = readable.read(); - if (data === null) - // reached end of stream - process.nextTick(common.mustCall(onStreamEnd, 1)); - }, 2)); - readable.on('end', common.mustCall(onStreamEnd)); - readable.push('pushed'); - readable.read(6); - - // reading - assert.strictEqual(state.reading, true); + assert.strictEqual(state.reading, false); +} + +readable.on('readable', common.mustCall(function () { + // 'readable' always gets called before 'end' + // since 'end' hasn't been emitted, more data could be incoming assert.strictEqual(state.readingMore, true); - // add chunk to front - readable.unshift('unshifted'); + // if the stream has ended, we shouldn't be reading + assert.strictEqual(state.ended, !state.reading); - // end - readable.push(null); -} -{ - var _onStreamEnd = function _onStreamEnd() { - // End of stream; state.reading is false - // And so should be readingMore. - assert.strictEqual(_state.readingMore, false); - assert.strictEqual(_state.reading, false); - }; - var _readable = new Readable({ - read: function read(size) {} - }); - var _state = _readable._readableState; - - // Starting off with false initially. - assert.strictEqual(_state.reading, false); - assert.strictEqual(_state.readingMore, false); - _readable.on('data', common.mustCall(function (data) { - // while in a flowing state without a 'readable' listener - // we should be reading more - if (_readable.readableFlowing) assert.strictEqual(_state.readingMore, true); - - // reading as long as we've not ended - assert.strictEqual(_state.reading, !_state.ended); - }, 2)); - _readable.on('end', common.mustCall(_onStreamEnd)); - _readable.push('pushed'); - - // stop emitting 'data' events - assert.strictEqual(_state.flowing, true); - _readable.pause(); - - // paused - assert.strictEqual(_state.reading, false); - assert.strictEqual(_state.flowing, false); - _readable.resume(); - assert.strictEqual(_state.reading, false); - assert.strictEqual(_state.flowing, true); - - // add chunk to front - _readable.unshift('unshifted'); - - // end - _readable.push(null); -} -{ - var _onStreamEnd2 = function _onStreamEnd2() { - // End of stream; state.reading is false - // And so should be readingMore. - assert.strictEqual(_state2.readingMore, false); - assert.strictEqual(_state2.reading, false); - }; - var _readable2 = new Readable({ - read: function read(size) {} - }); - var _state2 = _readable2._readableState; - - // Starting off with false initially. - assert.strictEqual(_state2.reading, false); - assert.strictEqual(_state2.readingMore, false); - var onReadable = common.mustNotCall; - _readable2.on('readable', onReadable); - _readable2.on('data', common.mustCall(function (data) { - // reading as long as we've not ended - assert.strictEqual(_state2.reading, !_state2.ended); - }, 2)); - _readable2.removeListener('readable', onReadable); - _readable2.on('end', common.mustCall(_onStreamEnd2)); - _readable2.push('pushed'); - - // we are still not flowing, we will be resuming in the next tick - assert.strictEqual(_state2.flowing, false); - - // wait for nextTick, so the readableListener flag resets - process.nextTick(function () { - _readable2.resume(); - - // stop emitting 'data' events - assert.strictEqual(_state2.flowing, true); - _readable2.pause(); - - // paused - assert.strictEqual(_state2.flowing, false); - _readable2.resume(); - assert.strictEqual(_state2.flowing, true); - - // add chunk to front - _readable2.unshift('unshifted'); - - // end - _readable2.push(null); - }); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + if (readable.read() === null) // reached end of stream + process.nextTick(common.mustCall(onStreamEnd, 1)); +}, 2)); + +readable.on('end', common.mustCall(onStreamEnd)); + +readable.push('pushed'); + +// stop emitting 'data' events +readable.pause(); + +// read() should only be called while operating in paused mode +readable.read(6); + +// reading +assert.strictEqual(state.reading, true); +assert.strictEqual(state.readingMore, true); + +// resume emitting 'data' events +readable.resume(); + +// add chunk to front +readable.unshift('unshifted'); + +// end +readable.push(null); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-resumeScheduled.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-resumeScheduled.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -8,13 +6,15 @@ // Testing Readable Stream resumeScheduled state var assert = require('assert/'); + var _require = require('../../'), - Readable = _require.Readable, - Writable = _require.Writable; + Readable = _require.Readable, + Writable = _require.Writable; + { // pipe() test case var r = new Readable({ - read: function read() {} + read: function () {} }); var w = new Writable(); @@ -24,18 +24,21 @@ // calling pipe() should change the state value = true. r.pipe(w); assert.strictEqual(r._readableState.resumeScheduled, true); + process.nextTick(common.mustCall(function () { assert.strictEqual(r._readableState.resumeScheduled, false); })); } + { // 'data' listener test case var _r = new Readable({ - read: function read() {} + read: function () {} }); // resumeScheduled should start = `false`. assert.strictEqual(_r._readableState.resumeScheduled, false); + _r.push(bufferShim.from(1, 2, 3)); // adding 'data' listener should change the state value @@ -43,14 +46,16 @@ assert.strictEqual(_r._readableState.resumeScheduled, false); })); assert.strictEqual(_r._readableState.resumeScheduled, true); + process.nextTick(common.mustCall(function () { assert.strictEqual(_r._readableState.resumeScheduled, false); })); } + { // resume() test case var _r2 = new Readable({ - read: function read() {} + read: function () {} }); // resumeScheduled should start = `false`. @@ -59,22 +64,13 @@ // Calling resume() should change the state value. _r2.resume(); assert.strictEqual(_r2._readableState.resumeScheduled, true); + _r2.on('resume', common.mustCall(function () { // The state value should be `false` again assert.strictEqual(_r2._readableState.resumeScheduled, false); })); + process.nextTick(common.mustCall(function () { assert.strictEqual(_r2._readableState.resumeScheduled, false); })); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-with-unimplemented-_read.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readable-with-unimplemented-_read.js
Changed
@@ -1,26 +1,12 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable; -var readable = new Readable(); -readable.on('error', common.expectsError({ - code: 'ERR_METHOD_NOT_IMPLEMENTED', - type: Error, - message: 'The _read() method is not implemented' -})); -readable.read(); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +require('../common'); +var stream = require('../../'); +var assert = require('assert/'); + +var readable = new stream.Readable(); + +assert.throws(function () { + return readable.read(); +}, /not implemented/); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readableListening-state.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-readableListening-state.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -7,37 +5,32 @@ var common = require('../common'); var assert = require('assert/'); var stream = require('../../'); + var r = new stream.Readable({ - read: function read() {} + read: function () {} }); // readableListening state should start in `false`. assert.strictEqual(r._readableState.readableListening, false); + r.on('readable', common.mustCall(function () { // Inside the readable event this state should be true. assert.strictEqual(r._readableState.readableListening, true); })); + r.push(bufferShim.from('Testing readableListening state')); + var r2 = new stream.Readable({ - read: function read() {} + read: function () {} }); // readableListening state should start in `false`. assert.strictEqual(r2._readableState.readableListening, false); + r2.on('data', common.mustCall(function (chunk) { // readableListening should be false because we don't have // a `readable` listener assert.strictEqual(r2._readableState.readableListening, false); })); -r2.push(bufferShim.from('Testing readableListening state')); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +r2.push(bufferShim.from('Testing readableListening state')); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-callback-twice.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-callback-twice.js
Changed
@@ -1,31 +1,20 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); +var assert = require('assert/'); + var _require = require('../../'), - Transform = _require.Transform; + Transform = _require.Transform; + var stream = new Transform({ - transform: function transform(chunk, enc, cb) { - cb(); - cb(); + transform: function (chunk, enc, cb) { + cb();cb(); } }); -stream.on('error', common.expectsError({ - type: Error, - message: 'Callback called multiple times', - code: 'ERR_MULTIPLE_CALLBACK' + +stream.on('error', common.mustCall(function (err) { + assert.strictEqual(err.toString(), 'Error: write callback called multiple times'); })); -stream.write('foo'); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +stream.write('foo'); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-constructor-set-methods.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-constructor-set-methods.js
Changed
@@ -1,47 +1,40 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); -var _require = require('assert/'), - strictEqual = _require.strictEqual; -var _require2 = require('../../'), - Transform = _require2.Transform; -var t = new Transform(); -t.on('error', common.expectsError({ - type: Error, - code: 'ERR_METHOD_NOT_IMPLEMENTED', - message: 'The _transform() method is not implemented' -})); -t.end(bufferShim.from('blerg')); -var _transform = common.mustCall(function (chunk, _, next) { - next(); +var assert = require('assert/'); + +var Transform = require('../../').Transform; + +var _transform = common.mustCall(function _transform(d, e, n) { + n(); }); -var _final = common.mustCall(function (next) { - next(); + +var _final = common.mustCall(function _final(n) { + n(); }); -var _flush = common.mustCall(function (next) { - next(); + +var _flush = common.mustCall(function _flush(n) { + n(); }); -var t2 = new Transform({ + +var t = new Transform({ transform: _transform, flush: _flush, final: _final }); -strictEqual(t2._transform, _transform); -strictEqual(t2._flush, _flush); -strictEqual(t2._final, _final); -t2.end(bufferShim.from('blerg')); -t2.resume(); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + +var t2 = new Transform({}); + +t.end(bufferShim.from('blerg')); +t.resume(); + +assert.throws(function () { + t2.end(bufferShim.from('blerg')); +}, /^Error: .*Nnot implemented$/); + +process.on('exit', function () { + assert.strictEqual(t._transform, _transform); + assert.strictEqual(t._flush, _flush); + assert.strictEqual(t._final, _final); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-destroy.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-destroy.js
Changed
@@ -1,88 +1,111 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); + var _require = require('../../'), - Transform = _require.Transform; + Transform = _require.Transform; + var assert = require('assert/'); + { var transform = new Transform({ - transform: function transform(chunk, enc, cb) {} + transform: function (chunk, enc, cb) {} }); + transform.resume(); - transform.on('end', common.mustNotCall()); + + transform.on('end', common.mustCall()); transform.on('close', common.mustCall()); - transform.on('finish', common.mustNotCall()); + transform.on('finish', common.mustCall()); + transform.destroy(); } + { var _transform = new Transform({ - transform: function transform(chunk, enc, cb) {} + transform: function (chunk, enc, cb) {} }); _transform.resume(); + var expected = new Error('kaboom'); - _transform.on('end', common.mustNotCall()); - _transform.on('finish', common.mustNotCall()); + + _transform.on('end', common.mustCall()); + _transform.on('finish', common.mustCall()); _transform.on('close', common.mustCall()); _transform.on('error', common.mustCall(function (err) { assert.strictEqual(err, expected); })); + _transform.destroy(expected); } + { var _transform2 = new Transform({ - transform: function transform(chunk, enc, cb) {} + transform: function (chunk, enc, cb) {} }); + _transform2._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, _expected); cb(err); }, 1); + var _expected = new Error('kaboom'); + _transform2.on('finish', common.mustNotCall('no finish event')); - _transform2.on('close', common.mustCall()); + _transform2.on('close', common.mustNotCall('no close event')); _transform2.on('error', common.mustCall(function (err) { assert.strictEqual(err, _expected); })); + _transform2.destroy(_expected); } + { var _expected2 = new Error('kaboom'); var _transform3 = new Transform({ - transform: function transform(chunk, enc, cb) {}, + transform: function (chunk, enc, cb) {}, + destroy: common.mustCall(function (err, cb) { assert.strictEqual(err, _expected2); cb(); }, 1) }); _transform3.resume(); + _transform3.on('end', common.mustNotCall('no end event')); - _transform3.on('close', common.mustCall()); + _transform3.on('close', common.mustNotCall('no close event')); _transform3.on('finish', common.mustNotCall('no finish event')); // error is swallowed by the custom _destroy _transform3.on('error', common.mustNotCall('no error event')); + _transform3.destroy(_expected2); } + { var _transform4 = new Transform({ - transform: function transform(chunk, enc, cb) {} + transform: function (chunk, enc, cb) {} }); + _transform4._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, null); cb(); }, 1); + _transform4.destroy(); } + { var _transform5 = new Transform({ - transform: function transform(chunk, enc, cb) {} + transform: function (chunk, enc, cb) {} }); _transform5.resume(); + _transform5._destroy = common.mustCall(function (err, cb) { var _this = this; + assert.strictEqual(err, null); process.nextTick(function () { _this.push(null); @@ -90,41 +113,39 @@ cb(); }); }, 1); + var fail = common.mustNotCall('no event'); + _transform5.on('finish', fail); _transform5.on('end', fail); - _transform5.on('close', common.mustCall()); + _transform5.on('close', fail); + _transform5.destroy(); + _transform5.removeListener('end', fail); _transform5.removeListener('finish', fail); _transform5.on('end', common.mustCall()); _transform5.on('finish', common.mustCall()); } + { var _transform6 = new Transform({ - transform: function transform(chunk, enc, cb) {} + transform: function (chunk, enc, cb) {} }); + var _expected3 = new Error('kaboom'); + _transform6._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, null); cb(_expected3); }, 1); - _transform6.on('close', common.mustCall()); + + _transform6.on('close', common.mustNotCall('no close event')); _transform6.on('finish', common.mustNotCall('no finish event')); _transform6.on('end', common.mustNotCall('no end event')); _transform6.on('error', common.mustCall(function (err) { assert.strictEqual(err, _expected3); })); + _transform6.destroy(); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-final-sync.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-final-sync.js
Changed
@@ -1,16 +1,15 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var stream = require('../../'); var state = 0; /* What you do -var stream = new stream.Transform({ +var stream = new tream.Transform({ transform: function transformCallback(chunk, _, next) { // part 1 this.push(chunk); @@ -62,63 +61,42 @@ var t = new stream.Transform({ objectMode: true, transform: common.mustCall(function (chunk, _, next) { - // transformCallback part 1 - assert.strictEqual(++state, chunk); + assert.strictEqual(++state, chunk, 'transformCallback part 1'); this.push(state); - // transformCallback part 2 - assert.strictEqual(++state, chunk + 2); + assert.strictEqual(++state, chunk + 2, 'transformCallback part 2'); process.nextTick(next); }, 3), final: common.mustCall(function (done) { state++; - // finalCallback part 1 - assert.strictEqual(state, 10); + assert.strictEqual(state, 10, 'finalCallback part 1'); state++; - // finalCallback part 2 - assert.strictEqual(state, 11); + assert.strictEqual(state, 11, 'finalCallback part 2'); done(); }, 1), flush: common.mustCall(function (done) { state++; - // fluchCallback part 1 - assert.strictEqual(state, 12); + assert.strictEqual(state, 12, 'flushCallback part 1'); process.nextTick(function () { state++; - // fluchCallback part 2 - assert.strictEqual(state, 15); + assert.strictEqual(state, 15, 'flushCallback part 2'); done(); }); }, 1) }); t.on('finish', common.mustCall(function () { state++; - // finishListener - assert.strictEqual(state, 13); + assert.strictEqual(state, 13, 'finishListener'); }, 1)); t.on('end', common.mustCall(function () { state++; - // endEvent - assert.strictEqual(state, 16); + assert.strictEqual(state, 16, 'end event'); }, 1)); t.on('data', common.mustCall(function (d) { - // dataListener - assert.strictEqual(++state, d + 1); + assert.strictEqual(++state, d + 1, 'dataListener'); }, 3)); t.write(1); t.write(4); t.end(7, common.mustCall(function () { state++; - // endMethodCallback - assert.strictEqual(state, 14); -}, 1)); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + assert.strictEqual(state, 14, 'endMethodCallback'); +}, 1)); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-final.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-final.js
Changed
@@ -1,16 +1,15 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var stream = require('../../'); var state = 0; /* What you do -var stream = new stream.Transform({ +var stream = new tream.Transform({ transform: function transformCallback(chunk, _, next) { // part 1 this.push(chunk); @@ -62,65 +61,44 @@ var t = new stream.Transform({ objectMode: true, transform: common.mustCall(function (chunk, _, next) { - // transformCallback part 1 - assert.strictEqual(++state, chunk); + assert.strictEqual(++state, chunk, 'transformCallback part 1'); this.push(state); - // transformCallback part 2 - assert.strictEqual(++state, chunk + 2); + assert.strictEqual(++state, chunk + 2, 'transformCallback part 2'); process.nextTick(next); }, 3), final: common.mustCall(function (done) { state++; - // finalCallback part 1 - assert.strictEqual(state, 10); + assert.strictEqual(state, 10, 'finalCallback part 1'); setTimeout(function () { state++; - // finalCallback part 2 - assert.strictEqual(state, 11); + assert.strictEqual(state, 11, 'finalCallback part 2'); done(); }, 100); }, 1), flush: common.mustCall(function (done) { state++; - // flushCallback part 1 - assert.strictEqual(state, 12); + assert.strictEqual(state, 12, 'flushCallback part 1'); process.nextTick(function () { state++; - // flushCallback part 2 - assert.strictEqual(state, 15); + assert.strictEqual(state, 15, 'flushCallback part 2'); done(); }); }, 1) }); t.on('finish', common.mustCall(function () { state++; - // finishListener - assert.strictEqual(state, 13); + assert.strictEqual(state, 13, 'finishListener'); }, 1)); t.on('end', common.mustCall(function () { state++; - // end event - assert.strictEqual(state, 16); + assert.strictEqual(state, 16, 'end event'); }, 1)); t.on('data', common.mustCall(function (d) { - // dataListener - assert.strictEqual(++state, d + 1); + assert.strictEqual(++state, d + 1, 'dataListener'); }, 3)); t.write(1); t.write(4); t.end(7, common.mustCall(function () { state++; - // endMethodCallback - assert.strictEqual(state, 14); -}, 1)); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + assert.strictEqual(state, 14, 'endMethodCallback'); +}, 1)); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-flush-data.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-flush-data.js
Changed
@@ -1,35 +1,27 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ require('../common'); + var assert = require('assert/'); var Transform = require('../../').Transform; + var expected = 'asdf'; + function _transform(d, e, n) { n(); } function _flush(n) { n(null, expected); } + var t = new Transform({ transform: _transform, flush: _flush }); + t.end(bufferShim.from('blerg')); t.on('data', function (data) { assert.strictEqual(data.toString(), expected); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-objectmode-falsey-value.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-objectmode-falsey-value.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,23 +24,23 @@ /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var stream = require('../../'); var PassThrough = stream.PassThrough; -var src = new PassThrough({ - objectMode: true -}); -var tx = new PassThrough({ - objectMode: true -}); -var dest = new PassThrough({ - objectMode: true -}); + +var src = new PassThrough({ objectMode: true }); +var tx = new PassThrough({ objectMode: true }); +var dest = new PassThrough({ objectMode: true }); + var expect = -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10; var results = ; + dest.on('data', common.mustCall(function (x) { results.push(x); }, expect.length)); + src.pipe(tx).pipe(dest); + var i = -1; var int = setInterval(common.mustCall(function () { if (results.length === expect.length) { @@ -52,15 +50,4 @@ } else { src.write(i++); } -}, expect.length + 1), 1); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +}, expect.length + 1), 1); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-split-highwatermark.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-split-highwatermark.js
Changed
@@ -1,15 +1,16 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ -var common = require('../common'); +require('../common'); var assert = require('assert/'); + var _require = require('../../'), - Transform = _require.Transform, - Readable = _require.Readable, - Writable = _require.Writable; + Transform = _require.Transform, + Readable = _require.Readable, + Writable = _require.Writable; + var DEFAULT = 16 * 1024; + function testTransform(expectedReadableHwm, expectedWritableHwm, options) { var t = new Transform(options); assert.strictEqual(t._readableState.highWaterMark, expectedReadableHwm); @@ -17,24 +18,16 @@ } // test overriding defaultHwm -testTransform(666, DEFAULT, { - readableHighWaterMark: 666 -}); -testTransform(DEFAULT, 777, { - writableHighWaterMark: 777 -}); +testTransform(666, DEFAULT, { readableHighWaterMark: 666 }); +testTransform(DEFAULT, 777, { writableHighWaterMark: 777 }); testTransform(666, 777, { readableHighWaterMark: 666, writableHighWaterMark: 777 }); // test 0 overriding defaultHwm -testTransform(0, DEFAULT, { - readableHighWaterMark: 0 -}); -testTransform(DEFAULT, 0, { - writableHighWaterMark: 0 -}); +testTransform(0, DEFAULT, { readableHighWaterMark: 0 }); +testTransform(DEFAULT, 0, { writableHighWaterMark: 0 }); // test highWaterMark overriding testTransform(555, 555, { @@ -66,65 +59,18 @@ writableHighWaterMark: 777 }); -// test undefined, null -undefined, null.forEach(function (v) { - testTransform(DEFAULT, DEFAULT, { - readableHighWaterMark: v - }); - testTransform(DEFAULT, DEFAULT, { - writableHighWaterMark: v - }); - testTransform(666, DEFAULT, { - highWaterMark: v, - readableHighWaterMark: 666 - }); - testTransform(DEFAULT, 777, { - highWaterMark: v, - writableHighWaterMark: 777 - }); +// test undefined, null, NaN +undefined, null, NaN.forEach(function (v) { + testTransform(DEFAULT, DEFAULT, { readableHighWaterMark: v }); + testTransform(DEFAULT, DEFAULT, { writableHighWaterMark: v }); + testTransform(666, DEFAULT, { highWaterMark: v, readableHighWaterMark: 666 }); + testTransform(DEFAULT, 777, { highWaterMark: v, writableHighWaterMark: 777 }); }); -// test NaN -{ - common.expectsError(function () { - new Transform({ - readableHighWaterMark: NaN - }); - }, { - type: TypeError, - code: 'ERR_INVALID_OPT_VALUE', - message: 'The value "NaN" is invalid for option "readableHighWaterMark"' - }); - common.expectsError(function () { - new Transform({ - writableHighWaterMark: NaN - }); - }, { - type: TypeError, - code: 'ERR_INVALID_OPT_VALUE', - message: 'The value "NaN" is invalid for option "writableHighWaterMark"' - }); -} - // test non Duplex streams ignore the options { - var r = new Readable({ - readableHighWaterMark: 666 - }); + var r = new Readable({ readableHighWaterMark: 666 }); assert.strictEqual(r._readableState.highWaterMark, DEFAULT); - var w = new Writable({ - writableHighWaterMark: 777 - }); + var w = new Writable({ writableHighWaterMark: 777 }); assert.strictEqual(w._writableState.highWaterMark, DEFAULT); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-transform-split-objectmode.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-transform-split-objectmode.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,59 +24,55 @@ /*</replacement>*/ require('../common'); var assert = require('assert/'); + var Transform = require('../../').Transform; -var parser = new Transform({ - readableObjectMode: true -}); + +var parser = new Transform({ readableObjectMode: true }); + assert(parser._readableState.objectMode); assert(!parser._writableState.objectMode); assert.strictEqual(parser.readableHighWaterMark, 16); assert.strictEqual(parser.writableHighWaterMark, 16 * 1024); assert.strictEqual(parser.readableHighWaterMark, parser._readableState.highWaterMark); assert.strictEqual(parser.writableHighWaterMark, parser._writableState.highWaterMark); + parser._transform = function (chunk, enc, callback) { - callback(null, { - val: chunk0 - }); + callback(null, { val: chunk0 }); }; -var parsed; + +var parsed = void 0; + parser.on('data', function (obj) { parsed = obj; }); + parser.end(bufferShim.from(42)); + process.on('exit', function () { assert.strictEqual(parsed.val, 42); }); -var serializer = new Transform({ - writableObjectMode: true -}); + +var serializer = new Transform({ writableObjectMode: true }); + assert(!serializer._readableState.objectMode); assert(serializer._writableState.objectMode); assert.strictEqual(serializer.readableHighWaterMark, 16 * 1024); assert.strictEqual(serializer.writableHighWaterMark, 16); assert.strictEqual(parser.readableHighWaterMark, parser._readableState.highWaterMark); assert.strictEqual(parser.writableHighWaterMark, parser._writableState.highWaterMark); + serializer._transform = function (obj, _, callback) { callback(null, bufferShim.from(obj.val)); }; -var serialized; + +var serialized = void 0; + serializer.on('data', function (chunk) { serialized = chunk; }); -serializer.write({ - val: 42 -}); + +serializer.write({ val: 42 }); + process.on('exit', function () { assert.strictEqual(serialized0, 42); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-uint8array.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-uint8array.js
Changed
@@ -1,22 +1,19 @@ -"use strict"; - -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iterSymbol.iterator != null || iter"@@iterator" != null) return Array.from(iter); } -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2i = arri; return arr2; } +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2i = arri; } return arr2; } else { return Array.from(arr); } } + /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var _require = require('../../'), - Readable = _require.Readable, - Writable = _require.Writable; + Readable = _require.Readable, + Writable = _require.Writable; + var ABC = new Uint8Array(0x41, 0x42, 0x43); var DEF = new Uint8Array(0x44, 0x45, 0x46); var GHI = new Uint8Array(0x47, 0x48, 0x49); + { // Simple Writable test. @@ -29,12 +26,15 @@ } else { assert.strictEqual(String(chunk), 'DEF'); } + cb(); }, 2) }); + writable.write(ABC); writable.end(DEF); } + { // Writable test, pass in Uint8Array in object mode. @@ -48,11 +48,14 @@ cb(); }) }); + _writable.end(ABC); } + { // Writable test, multiple writes carried out via writev. - var callback; + var callback = void 0; + var _writable2 = new Writable({ write: common.mustCall(function (chunk, encoding, cb) { assert(chunk instanceof Buffer); @@ -67,41 +70,38 @@ assert.strictEqual(chunks0.chunk + chunks1.chunk, 'DEFGHI'); }) }); + _writable2.write(ABC); _writable2.write(DEF); _writable2.end(GHI); callback(); } + { // Simple Readable test. var readable = new Readable({ - read: function read() {} + read: function () {} }); + readable.push(DEF); readable.unshift(ABC); + var buf = readable.read(); assert(buf instanceof Buffer); - assert.deepStrictEqual(_toConsumableArray(buf), .concat(_toConsumableArray(ABC), _toConsumableArray(DEF))); + assert.deepStrictEqual(.concat(_toConsumableArray(buf)), .concat(_toConsumableArray(ABC), _toConsumableArray(DEF))); } + { // Readable test, setEncoding. var _readable = new Readable({ - read: function read() {} + read: function () {} }); + _readable.setEncoding('utf8'); + _readable.push(DEF); _readable.unshift(ABC); + var out = _readable.read(); assert.strictEqual(out, 'ABCDEF'); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-unpipe-event.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-unpipe-event.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + if (process.version.indexOf('v0.8') === 0) { process.exit(0); } @@ -20,52 +12,57 @@ /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var _require = require('../../'), - Writable = _require.Writable, - Readable = _require.Readable; -var NullWriteable = /*#__PURE__*/function (_Writable) { + Writable = _require.Writable, + Readable = _require.Readable; + +var NullWriteable = function (_Writable) { _inherits(NullWriteable, _Writable); - var _super = _createSuper(NullWriteable); + function NullWriteable() { _classCallCheck(this, NullWriteable); - return _super.apply(this, arguments); + + return _possibleConstructorReturn(this, _Writable.apply(this, arguments)); } - _createClass(NullWriteable, { - key: "_write", - value: function _write(chunk, encoding, callback) { - return callback(); - } - }); + + NullWriteable.prototype._write = function _write(chunk, encoding, callback) { + return callback(); + }; + return NullWriteable; }(Writable); -var QuickEndReadable = /*#__PURE__*/function (_Readable) { + +var QuickEndReadable = function (_Readable) { _inherits(QuickEndReadable, _Readable); - var _super2 = _createSuper(QuickEndReadable); + function QuickEndReadable() { _classCallCheck(this, QuickEndReadable); - return _super2.apply(this, arguments); + + return _possibleConstructorReturn(this, _Readable.apply(this, arguments)); } - _createClass(QuickEndReadable, { - key: "_read", - value: function _read() { - this.push(null); - } - }); + + QuickEndReadable.prototype._read = function _read() { + this.push(null); + }; + return QuickEndReadable; }(Readable); -var NeverEndReadable = /*#__PURE__*/function (_Readable2) { + +var NeverEndReadable = function (_Readable2) { _inherits(NeverEndReadable, _Readable2); - var _super3 = _createSuper(NeverEndReadable); + function NeverEndReadable() { _classCallCheck(this, NeverEndReadable); - return _super3.apply(this, arguments); + + return _possibleConstructorReturn(this, _Readable2.apply(this, arguments)); } - _createClass(NeverEndReadable, { - key: "_read", - value: function _read() {} - }); + + NeverEndReadable.prototype._read = function _read() {}; + return NeverEndReadable; }(Readable); + { var dest = new NullWriteable(); var src = new QuickEndReadable(); @@ -76,6 +73,7 @@ assert.strictEqual(src._readableState.pipesCount, 0); }); } + { var _dest = new NullWriteable(); var _src = new NeverEndReadable(); @@ -86,6 +84,7 @@ assert.strictEqual(_src._readableState.pipesCount, 1); }); } + { var _dest2 = new NullWriteable(); var _src2 = new NeverEndReadable(); @@ -97,51 +96,37 @@ assert.strictEqual(_src2._readableState.pipesCount, 0); }); } + { var _dest3 = new NullWriteable(); var _src3 = new QuickEndReadable(); _dest3.on('pipe', common.mustCall()); _dest3.on('unpipe', common.mustCall()); - _src3.pipe(_dest3, { - end: false - }); + _src3.pipe(_dest3, { end: false }); setImmediate(function () { assert.strictEqual(_src3._readableState.pipesCount, 0); }); } + { var _dest4 = new NullWriteable(); var _src4 = new NeverEndReadable(); _dest4.on('pipe', common.mustCall()); _dest4.on('unpipe', common.mustNotCall('unpipe should not have been emitted')); - _src4.pipe(_dest4, { - end: false - }); + _src4.pipe(_dest4, { end: false }); setImmediate(function () { assert.strictEqual(_src4._readableState.pipesCount, 1); }); } + { var _dest5 = new NullWriteable(); var _src5 = new NeverEndReadable(); _dest5.on('pipe', common.mustCall()); _dest5.on('unpipe', common.mustCall()); - _src5.pipe(_dest5, { - end: false - }); + _src5.pipe(_dest5, { end: false }); _src5.unpipe(_dest5); setImmediate(function () { assert.strictEqual(_src5._readableState.pipesCount, 0); }); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-unshift-empty-chunk.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-unshift-empty-chunk.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -30,18 +28,21 @@ // This test verifies that stream.unshift(bufferShim.alloc(0)) or // stream.unshift('') does not set state.reading=false. var Readable = require('../../').Readable; + var r = new Readable(); var nChunks = 10; var chunk = bufferShim.alloc(10, 'x'); + r._read = function (n) { setImmediate(function () { r.push(--nChunks === 0 ? null : chunk); }); }; + var readAll = false; var seen = ; r.on('readable', function () { - var chunk; + var chunk = void 0; while (chunk = r.read()) { seen.push(chunk.toString()); // simulate only reading a certain amount of the data, @@ -54,19 +55,10 @@ r.unshift(putBack); } }); + var expect = 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', 'yyyyy'; + r.on('end', function () { assert.deepStrictEqual(seen, expect); - require('tap').pass(); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + console.log('ok'); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-unshift-read-race.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-unshift-read-race.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -36,15 +34,15 @@ var stream = require('../../'); var hwm = 10; -var r = stream.Readable({ - highWaterMark: hwm -}); +var r = stream.Readable({ highWaterMark: hwm }); var chunks = 10; + var data = bufferShim.allocUnsafe(chunks * hwm + Math.ceil(hwm / 2)); for (var i = 0; i < data.length; i++) { var c = 'asdf'.charCodeAt(i % 4); datai = c; } + var pos = 0; var pushedNull = false; r._read = function (n) { @@ -52,9 +50,10 @@ // every third chunk is fast push(!(chunks % 3)); + function push(fast) { assert(!pushedNull, 'push() after null push'); - var c = pos >= data.length ? null : data.slice(pos, pos + n); + var c = pos >= data.length ? null : data.slice(pos, Math.min(pos + n, data.length)); pushedNull = c === null; if (fast) { pos += n; @@ -69,80 +68,63 @@ } } }; + function pushError() { - common.expectsError(function () { + assert.throws(function () { r.push(bufferShim.allocUnsafe(1)); - }, { - code: 'ERR_STREAM_PUSH_AFTER_EOF', - type: Error, - message: 'stream.push() after EOF' - }); + }, /^Error: stream\.push\(\) after EOF$/); } + var w = stream.Writable(); var written = ; w._write = function (chunk, encoding, cb) { written.push(chunk.toString()); cb(); }; + r.on('end', common.mustCall(function () { - common.expectsError(function () { + assert.throws(function () { r.unshift(bufferShim.allocUnsafe(1)); - }, { - code: 'ERR_STREAM_UNSHIFT_AFTER_END_EVENT', - type: Error, - message: 'stream.unshift() after end event' - }); + }, /^Error: stream\.unshift\(\) after end event$/); w.end(); })); + r.on('readable', function () { - var chunk; + var chunk = void 0; while (null !== (chunk = r.read(10))) { w.write(chunk); if (chunk.length > 4) r.unshift(bufferShim.from('1234')); } }); + w.on('finish', common.mustCall(function () { // each chunk should start with 1234, and then be asfdasdfasdf... // The first got pulled out before the first unshift('1234'), so it's // lacking that piece. assert.strictEqual(written0, 'asdfasdfas'); var asdf = 'd'; - console.error("0: ".concat(written0)); + console.error('0: ' + written0); for (var _i = 1; _i < written.length; _i++) { - console.error("".concat(_i.toString(32), ": ").concat(written_i)); + console.error(_i.toString(32) + ': ' + written_i); assert.strictEqual(written_i.slice(0, 4), '1234'); for (var j = 4; j < written_i.length; j++) { var _c = written_i.charAt(j); assert.strictEqual(_c, asdf); switch (asdf) { case 'a': - asdf = 's'; - break; + asdf = 's';break; case 's': - asdf = 'd'; - break; + asdf = 'd';break; case 'd': - asdf = 'f'; - break; + asdf = 'f';break; case 'f': - asdf = 'a'; - break; + asdf = 'a';break; } } } })); + process.on('exit', function () { assert.strictEqual(written.length, 18); - require('tap').pass(); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + console.log('ok'); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-change-default-encoding.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-change-default-encoding.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -36,77 +28,60 @@ /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ -var common = require('../common'); +require('../common'); var assert = require('assert/'); + var stream = require('../../'); -var MyWritable = /*#__PURE__*/function (_stream$Writable) { + +var MyWritable = function (_stream$Writable) { _inherits(MyWritable, _stream$Writable); - var _super = _createSuper(MyWritable); + function MyWritable(fn, options) { - var _this; _classCallCheck(this, MyWritable); - _this = _super.call(this, options); + + var _this = _possibleConstructorReturn(this, _stream$Writable.call(this, options)); + _this.fn = fn; return _this; } - _createClass(MyWritable, { - key: "_write", - value: function _write(chunk, encoding, callback) { - this.fn(Buffer.isBuffer(chunk), typeof chunk, encoding); - callback(); - } - }); + + MyWritable.prototype._write = function _write(chunk, encoding, callback) { + this.fn(Buffer.isBuffer(chunk), typeof chunk, encoding); + callback(); + }; + return MyWritable; }(stream.Writable); + (function defaultCondingIsUtf8() { var m = new MyWritable(function (isBuffer, type, enc) { assert.strictEqual(enc, 'utf8'); - }, { - decodeStrings: false - }); + }, { decodeStrings: false }); m.write('foo'); m.end(); })(); + (function changeDefaultEncodingToAscii() { var m = new MyWritable(function (isBuffer, type, enc) { assert.strictEqual(enc, 'ascii'); - }, { - decodeStrings: false - }); + }, { decodeStrings: false }); m.setDefaultEncoding('ascii'); m.write('bar'); m.end(); })(); -common.expectsError(function changeDefaultEncodingToInvalidValue() { - var m = new MyWritable(function (isBuffer, type, enc) {}, { - decodeStrings: false - }); + +assert.throws(function changeDefaultEncodingToInvalidValue() { + var m = new MyWritable(function (isBuffer, type, enc) {}, { decodeStrings: false }); m.setDefaultEncoding({}); m.write('bar'); m.end(); -}, { - type: TypeError, - code: 'ERR_UNKNOWN_ENCODING', - message: 'Unknown encoding: object Object' -}); +}, /^TypeError: Unknown encoding: \object Object\$/); + (function checkVairableCaseEncoding() { var m = new MyWritable(function (isBuffer, type, enc) { assert.strictEqual(enc, 'ascii'); - }, { - decodeStrings: false - }); + }, { decodeStrings: false }); m.setDefaultEncoding('AsCii'); m.write('bar'); m.end(); -})(); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +})(); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-constructor-set-methods.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-constructor-set-methods.js
Changed
@@ -1,46 +1,37 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ -var common = require('../common'); -var _require = require('assert/'), - strictEqual = _require.strictEqual; -var _require2 = require('../../'), - Writable = _require2.Writable; -var w = new Writable(); -w.on('error', common.expectsError({ - type: Error, - code: 'ERR_METHOD_NOT_IMPLEMENTED', - message: 'The _write() method is not implemented' -})); +require('../common'); +var assert = require('assert/'); + +var Writable = require('../../').Writable; + +var _writeCalled = false; +function _write(d, e, n) { + _writeCalled = true; +} + +var w = new Writable({ write: _write }); w.end(bufferShim.from('blerg')); -var _write = common.mustCall(function (chunk, _, next) { - next(); -}); -var _writev = common.mustCall(function (chunks, next) { - strictEqual(chunks.length, 2); - next(); -}); -var w2 = new Writable({ - write: _write, - writev: _writev -}); -strictEqual(w2._write, _write); -strictEqual(w2._writev, _writev); -w2.write(bufferShim.from('blerg')); + +var _writevCalled = false; +var dLength = 0; +function _writev(d, n) { + dLength = d.length; + _writevCalled = true; +} + +var w2 = new Writable({ writev: _writev }); w2.cork(); + w2.write(bufferShim.from('blerg')); w2.write(bufferShim.from('blerg')); w2.end(); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + +process.on('exit', function () { + assert.strictEqual(w._write, _write); + assert(_writeCalled); + assert.strictEqual(w2._writev, _writev); + assert.strictEqual(dLength, 2); + assert(_writevCalled); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-decoded-encoding.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-decoded-encoding.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -38,56 +30,45 @@ /*</replacement>*/ require('../common'); var assert = require('assert/'); + var stream = require('../../'); -var MyWritable = /*#__PURE__*/function (_stream$Writable) { + +var MyWritable = function (_stream$Writable) { _inherits(MyWritable, _stream$Writable); - var _super = _createSuper(MyWritable); + function MyWritable(fn, options) { - var _this; _classCallCheck(this, MyWritable); - _this = _super.call(this, options); + + var _this = _possibleConstructorReturn(this, _stream$Writable.call(this, options)); + _this.fn = fn; return _this; } - _createClass(MyWritable, { - key: "_write", - value: function _write(chunk, encoding, callback) { - this.fn(Buffer.isBuffer(chunk), typeof chunk, encoding); - callback(); - } - }); + + MyWritable.prototype._write = function _write(chunk, encoding, callback) { + this.fn(Buffer.isBuffer(chunk), typeof chunk, encoding); + callback(); + }; + return MyWritable; }(stream.Writable); + { var m = new MyWritable(function (isBuffer, type, enc) { assert(isBuffer); assert.strictEqual(type, 'object'); assert.strictEqual(enc, 'buffer'); - }, { - decodeStrings: true - }); + }, { decodeStrings: true }); m.write('some-text', 'utf8'); m.end(); } + { var _m = new MyWritable(function (isBuffer, type, enc) { assert(!isBuffer); assert.strictEqual(type, 'string'); assert.strictEqual(enc, 'utf8'); - }, { - decodeStrings: false - }); + }, { decodeStrings: false }); _m.write('some-text', 'utf8'); _m.end(); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-destroy.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-destroy.js
Changed
@@ -1,226 +1,217 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); + var _require = require('../../'), - Writable = _require.Writable; + Writable = _require.Writable; + var assert = require('assert/'); + +var _require2 = require('util'), + inherits = _require2.inherits; + { var write = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); - write.on('finish', common.mustNotCall()); - write.on('close', common.mustCall()); + + write.on('finish', common.mustCall()); + write.destroy(); assert.strictEqual(write.destroyed, true); } + { var _write = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); + var expected = new Error('kaboom'); - _write.on('finish', common.mustNotCall()); - _write.on('close', common.mustCall()); + + _write.on('finish', common.mustCall()); _write.on('error', common.mustCall(function (err) { assert.strictEqual(err, expected); })); + _write.destroy(expected); assert.strictEqual(_write.destroyed, true); } + { var _write2 = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); + _write2._destroy = function (err, cb) { assert.strictEqual(err, _expected); cb(err); }; + var _expected = new Error('kaboom'); + _write2.on('finish', common.mustNotCall('no finish event')); - _write2.on('close', common.mustCall()); _write2.on('error', common.mustCall(function (err) { assert.strictEqual(err, _expected); })); + _write2.destroy(_expected); assert.strictEqual(_write2.destroyed, true); } + { var _write3 = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); }, + destroy: common.mustCall(function (err, cb) { assert.strictEqual(err, _expected2); cb(); }) }); + var _expected2 = new Error('kaboom'); + _write3.on('finish', common.mustNotCall('no finish event')); - _write3.on('close', common.mustCall()); // error is swallowed by the custom _destroy _write3.on('error', common.mustNotCall('no error event')); + _write3.destroy(_expected2); assert.strictEqual(_write3.destroyed, true); } + { var _write4 = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); + _write4._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, null); cb(); }); + _write4.destroy(); assert.strictEqual(_write4.destroyed, true); } + { var _write5 = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); + _write5._destroy = common.mustCall(function (err, cb) { var _this = this; + assert.strictEqual(err, null); process.nextTick(function () { _this.end(); cb(); }); }); + var fail = common.mustNotCall('no finish event'); + _write5.on('finish', fail); - _write5.on('close', common.mustCall()); + _write5.destroy(); + _write5.removeListener('finish', fail); _write5.on('finish', common.mustCall()); assert.strictEqual(_write5.destroyed, true); } + { var _write6 = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); + var _expected3 = new Error('kaboom'); + _write6._destroy = common.mustCall(function (err, cb) { assert.strictEqual(err, null); cb(_expected3); }); - _write6.on('close', common.mustCall()); + _write6.on('finish', common.mustNotCall('no finish event')); _write6.on('error', common.mustCall(function (err) { assert.strictEqual(err, _expected3); })); + _write6.destroy(); assert.strictEqual(_write6.destroyed, true); } + { // double error case var _write7 = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); - _write7.on('close', common.mustCall()); + _write7.on('error', common.mustCall()); + _write7.destroy(new Error('kaboom 1')); _write7.destroy(new Error('kaboom 2')); assert.strictEqual(_write7._writableState.errorEmitted, true); assert.strictEqual(_write7.destroyed, true); } -{ - var writable = new Writable({ - destroy: common.mustCall(function (err, cb) { - process.nextTick(cb, new Error('kaboom 1')); - }), - write: function write(chunk, enc, cb) { - cb(); - } - }); - writable.on('close', common.mustCall()); - writable.on('error', common.expectsError({ - type: Error, - message: 'kaboom 2' - })); - writable.destroy(); - assert.strictEqual(writable.destroyed, true); - assert.strictEqual(writable._writableState.errorEmitted, false); - - // Test case where `writable.destroy()` is called again with an error before - // the `_destroy()` callback is called. - writable.destroy(new Error('kaboom 2')); - assert.strictEqual(writable._writableState.errorEmitted, true); -} + { var _write8 = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); + _write8.destroyed = true; assert.strictEqual(_write8.destroyed, true); // the internal destroy() mechanism should not be triggered - _write8.on('close', common.mustNotCall()); + _write8.on('finish', common.mustNotCall()); _write8.destroy(); } + { - var MyWritable = function MyWritable() { + function MyWritable() { assert.strictEqual(this.destroyed, false); this.destroyed = false; Writable.call(this); - }; - Object.setPrototypeOf(MyWritable.prototype, Writable.prototype); - Object.setPrototypeOf(MyWritable, Writable); + } + + inherits(MyWritable, Writable); + new MyWritable(); } + { // destroy and destroy callback var _write9 = new Writable({ - write: function write(chunk, enc, cb) { + write: function (chunk, enc, cb) { cb(); } }); + _write9.destroy(); + var _expected4 = new Error('kaboom'); + _write9.destroy(_expected4, common.mustCall(function (err) { - assert.strictEqual(err, _expected4); + assert.strictEqual(_expected4, err); })); -} -{ - // Checks that `._undestroy()` restores the state so that `final` will be - // called again. - var _write10 = new Writable({ - write: common.mustNotCall(), - final: common.mustCall(function (cb) { - return cb(); - }, 2) - }); - _write10.end(); - _write10.destroy(); - _write10._undestroy(); - _write10.end(); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-ended-state.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-ended-state.js
Changed
@@ -1,30 +1,23 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); + var assert = require('assert/'); var stream = require('../../'); + var writable = new stream.Writable(); + writable._write = function (chunk, encoding, cb) { assert.strictEqual(writable._writableState.ended, false); cb(); }; + assert.strictEqual(writable._writableState.ended, false); + writable.end('testing ended state', common.mustCall(function () { assert.strictEqual(writable._writableState.ended, true); })); -assert.strictEqual(writable._writableState.ended, true); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +assert.strictEqual(writable._writableState.ended, true); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-finished-state.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-finished-state.js
Changed
@@ -1,32 +1,24 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); + var assert = require('assert/'); var stream = require('../../'); + var writable = new stream.Writable(); + writable._write = function (chunk, encoding, cb) { // The state finished should start in false. assert.strictEqual(writable._writableState.finished, false); cb(); }; + writable.on('finish', common.mustCall(function () { assert.strictEqual(writable._writableState.finished, true); })); + writable.end('testing finished state', common.mustCall(function () { assert.strictEqual(writable._writableState.finished, true); -})); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +})); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-needdrain-state.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-needdrain-state.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -7,27 +5,21 @@ var common = require('../common'); var stream = require('../../'); var assert = require('assert/'); + var transform = new stream.Transform({ transform: _transform, highWaterMark: 1 }); + function _transform(chunk, encoding, cb) { assert.strictEqual(transform._writableState.needDrain, true); cb(); } + assert.strictEqual(transform._writableState.needDrain, false); + transform.write('asdasd', common.mustCall(function () { assert.strictEqual(transform._writableState.needDrain, false); })); -assert.strictEqual(transform._writableState.needDrain, true); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +assert.strictEqual(transform._writableState.needDrain, true); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-null.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-null.js
Changed
@@ -1,96 +1,75 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ -var common = require('../common'); +require('../common'); var assert = require('assert/'); + var stream = require('../../'); -var MyWritable = /*#__PURE__*/function (_stream$Writable) { + +var MyWritable = function (_stream$Writable) { _inherits(MyWritable, _stream$Writable); - var _super = _createSuper(MyWritable); - function MyWritable() { + + function MyWritable(opt) { _classCallCheck(this, MyWritable); - return _super.apply(this, arguments); + + return _possibleConstructorReturn(this, _stream$Writable.call(this, opt)); } - _createClass(MyWritable, { - key: "_write", - value: function _write(chunk, encoding, callback) { - assert.notStrictEqual(chunk, null); - callback(); - } - }); + + MyWritable.prototype._write = function _write(chunk, encoding, callback) { + assert.notStrictEqual(chunk, null); + callback(); + }; + return MyWritable; }(stream.Writable); -common.expectsError(function () { - var m = new MyWritable({ - objectMode: true - }); + +assert.throws(function () { + var m = new MyWritable({ objectMode: true }); m.write(null, function (err) { return assert.ok(err); }); -}, { - code: 'ERR_STREAM_NULL_VALUES', - type: TypeError, - message: 'May not write null values to stream' +}, /^TypeError: May not write null values to stream$/); +assert.doesNotThrow(function () { + var m = new MyWritable({ objectMode: true }).on('error', function (e) { + assert.ok(e); + }); + m.write(null, function (err) { + assert.ok(err); + }); }); -{ - // Should not throw. - var m = new MyWritable({ - objectMode: true - }).on('error', assert); - m.write(null, assert); -} -common.expectsError(function () { + +assert.throws(function () { var m = new MyWritable(); m.write(false, function (err) { return assert.ok(err); }); -}, { - code: 'ERR_INVALID_ARG_TYPE', - type: TypeError +}, /^TypeError: Invalid non-string\/buffer chunk$/); +assert.doesNotThrow(function () { + var m = new MyWritable().on('error', function (e) { + assert.ok(e); + }); + m.write(false, function (err) { + assert.ok(err); + }); }); -{ - // Should not throw. - var _m = new MyWritable().on('error', assert); - _m.write(false, assert); -} -{ - // Should not throw. - var _m2 = new MyWritable({ - objectMode: true + +assert.doesNotThrow(function () { + var m = new MyWritable({ objectMode: true }); + m.write(false, function (err) { + return assert.ifError(err); }); - _m2.write(false, assert.ifError); -} -{ - // Should not throw. - var _m3 = new MyWritable({ - objectMode: true - }).on('error', function (e) { +}); +assert.doesNotThrow(function () { + var m = new MyWritable({ objectMode: true }).on('error', function (e) { assert.ifError(e || new Error('should not get here')); }); - _m3.write(false, assert.ifError); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + m.write(false, function (err) { + assert.ifError(err); + }); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-write-writev-finish.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writable-write-writev-finish.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -13,78 +11,105 @@ { var writable = new stream.Writable(); + writable._write = function (chunks, encoding, cb) { cb(new Error('write test error')); }; + var firstError = false; writable.on('finish', common.mustCall(function () { assert.strictEqual(firstError, true); })); + writable.on('prefinish', common.mustCall()); + writable.on('error', common.mustCall(function (er) { assert.strictEqual(er.message, 'write test error'); firstError = true; })); + writable.end('test'); } + { var _writable = new stream.Writable(); + _writable._write = function (chunks, encoding, cb) { setImmediate(cb, new Error('write test error')); }; + var _firstError = false; _writable.on('finish', common.mustCall(function () { assert.strictEqual(_firstError, true); })); + _writable.on('prefinish', common.mustCall()); + _writable.on('error', common.mustCall(function (er) { assert.strictEqual(er.message, 'write test error'); _firstError = true; })); + _writable.end('test'); } + { var _writable2 = new stream.Writable(); + _writable2._write = function (chunks, encoding, cb) { cb(new Error('write test error')); }; + _writable2._writev = function (chunks, cb) { cb(new Error('writev test error')); }; + var _firstError2 = false; _writable2.on('finish', common.mustCall(function () { assert.strictEqual(_firstError2, true); })); + _writable2.on('prefinish', common.mustCall()); + _writable2.on('error', common.mustCall(function (er) { assert.strictEqual(er.message, 'writev test error'); _firstError2 = true; })); + _writable2.cork(); _writable2.write('test'); + setImmediate(function () { _writable2.end('test'); }); } + { var _writable3 = new stream.Writable(); + _writable3._write = function (chunks, encoding, cb) { setImmediate(cb, new Error('write test error')); }; + _writable3._writev = function (chunks, cb) { setImmediate(cb, new Error('writev test error')); }; + var _firstError3 = false; _writable3.on('finish', common.mustCall(function () { assert.strictEqual(_firstError3, true); })); + _writable3.on('prefinish', common.mustCall()); + _writable3.on('error', common.mustCall(function (er) { assert.strictEqual(er.message, 'writev test error'); _firstError3 = true; })); + _writable3.cork(); _writable3.write('test'); + setImmediate(function () { _writable3.end('test'); }); @@ -98,62 +123,36 @@ rs.push('ok'); rs.push(null); rs._read = function () {}; + var ws = new stream.Writable(); var _firstError4 = false; + ws.on('finish', common.mustCall(function () { assert.strictEqual(_firstError4, true); })); ws.on('error', common.mustCall(function () { _firstError4 = true; })); + ws._write = function (chunk, encoding, done) { setImmediate(done, new Error()); }; rs.pipe(ws); } + { var _rs = new stream.Readable(); _rs.push('ok'); _rs.push(null); _rs._read = function () {}; + var _ws = new stream.Writable(); + _ws.on('finish', common.mustNotCall()); _ws.on('error', common.mustCall()); + _ws._write = function (chunk, encoding, done) { done(new Error()); }; _rs.pipe(_ws); -} -{ - var w = new stream.Writable(); - w._write = function (chunk, encoding, cb) { - process.nextTick(cb); - }; - w.on('error', common.mustCall()); - w.on('prefinish', function () { - w.write("shouldn't write in prefinish listener"); - }); - w.end(); -} -{ - var _w = new stream.Writable(); - _w._write = function (chunk, encoding, cb) { - process.nextTick(cb); - }; - _w.on('error', common.mustCall()); - _w.on('finish', function () { - _w.write("shouldn't write in finish listener"); - }); - _w.end(); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writableState-ending.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writableState-ending.js
Changed
@@ -1,46 +1,36 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ require('../common'); + var assert = require('assert/'); var stream = require('../../'); + var writable = new stream.Writable(); + function testStates(ending, finished, ended) { assert.strictEqual(writable._writableState.ending, ending); assert.strictEqual(writable._writableState.finished, finished); assert.strictEqual(writable._writableState.ended, ended); } + writable._write = function (chunk, encoding, cb) { // ending, finished, ended start in false. testStates(false, false, false); cb(); }; + writable.on('finish', function () { // ending, finished, ended = true. testStates(true, true, true); }); -var result = writable.end('testing function end()', function () { + +writable.end('testing function end()', function () { // ending, finished, ended = true. testStates(true, true, true); }); -// end returns the writable instance -assert.strictEqual(result, writable); - // ending, ended = true. // finished = false. -testStates(true, false, true); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +testStates(true, false, true); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -7,11 +5,14 @@ var common = require('../common'); var assert = require('assert/'); var stream = require('../../'); + var writable = new stream.Writable(); + writable._writev = common.mustCall(function (chunks, cb) { - assert.strictEqual(chunks.length, 2); + assert.strictEqual(chunks.length, 2, 'two chunks to write'); cb(); }, 1); + writable._write = common.mustCall(function (chunk, encoding, cb) { cb(); }, 1); @@ -33,12 +34,14 @@ writable.uncork(); assert.strictEqual(writable._writableState.corked, 1); assert.strictEqual(writable._writableState.bufferedRequestCount, 1); + process.nextTick(uncork); // the second chunk is buffered, because we uncork at the end of tick writable.write('second chunk'); assert.strictEqual(writable._writableState.corked, 1); assert.strictEqual(writable._writableState.bufferedRequestCount, 2); + function uncork() { // second uncork flushes the buffer writable.uncork(); @@ -53,15 +56,4 @@ // end causes an uncork() as well assert.strictEqual(writable._writableState.corked, 0); assert.strictEqual(writable._writableState.bufferedRequestCount, 0); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-write-final.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-write-final.js
Changed
@@ -1,12 +1,12 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var stream = require('../../'); var shutdown = false; + var w = new stream.Writable({ final: common.mustCall(function (cb) { assert.strictEqual(this, w); @@ -15,7 +15,7 @@ cb(); }, 100); }), - write: function write(chunk, e, cb) { + write: function (chunk, e, cb) { process.nextTick(cb); } }); @@ -23,15 +23,4 @@ assert(shutdown); })); w.write(bufferShim.allocUnsafe(1)); -w.end(bufferShim.allocUnsafe(0)); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +w.end(bufferShim.allocUnsafe(0)); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writev.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream-writev.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,7 +24,9 @@ /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var stream = require('../../'); + var queue = ; for (var decode = 0; decode < 2; decode++) { for (var uncork = 0; uncork < 2; uncork++) { @@ -35,13 +35,16 @@ } } } + run(); + function run() { var t = queue.pop(); - if (t) test(t0, t1, t2, run);else require('tap').pass(); + if (t) test(t0, t1, t2, run);else console.log('ok'); } + function test(decode, uncork, multi, next) { - require('tap').test("# decode=".concat(decode, " uncork=").concat(uncork, " multi=").concat(multi)); + console.log('# decode=' + decode + ' uncork=' + uncork + ' multi=' + multi); var counter = 0; var expectCount = 0; function cnt(msg) { @@ -53,42 +56,18 @@ assert.strictEqual(counter, expect); }; } - var w = new stream.Writable({ - decodeStrings: decode - }); + + var w = new stream.Writable({ decodeStrings: decode }); w._write = common.mustNotCall('Should not call _write'); - var expectChunks = decode ? { - encoding: 'buffer', - chunk: 104, 101, 108, 108, 111, 44, 32 - }, { - encoding: 'buffer', - chunk: 119, 111, 114, 108, 100 - }, { - encoding: 'buffer', - chunk: 33 - }, { - encoding: 'buffer', - chunk: 10, 97, 110, 100, 32, 116, 104, 101, 110, 46, 46, 46 - }, { - encoding: 'buffer', - chunk: 250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173 - } : { - encoding: 'ascii', - chunk: 'hello, ' - }, { - encoding: 'utf8', - chunk: 'world' - }, { - encoding: 'buffer', - chunk: 33 - }, { - encoding: 'latin1', - chunk: '\nand then...' - }, { - encoding: 'hex', - chunk: 'facebea7deadbeefdecafbad' - }; - var actualChunks; + + var expectChunks = decode ? { encoding: 'buffer', + chunk: 104, 101, 108, 108, 111, 44, 32 }, { encoding: 'buffer', + chunk: 119, 111, 114, 108, 100 }, { encoding: 'buffer', + chunk: 33 }, { encoding: 'buffer', + chunk: 10, 97, 110, 100, 32, 116, 104, 101, 110, 46, 46, 46 }, { encoding: 'buffer', + chunk: 250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173 } : { encoding: 'ascii', chunk: 'hello, ' }, { encoding: 'utf8', chunk: 'world' }, { encoding: 'buffer', chunk: 33 }, { encoding: 'binary', chunk: '\nand then...' }, { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' }; + + var actualChunks = void 0; w._writev = function (chunks, cb) { actualChunks = chunks.map(function (chunk) { return { @@ -98,31 +77,28 @@ }); cb(); }; + w.cork(); w.write('hello, ', 'ascii', cnt('hello')); w.write('world', 'utf8', cnt('world')); + if (multi) w.cork(); + w.write(bufferShim.from('!'), 'buffer', cnt('!')); - w.write('\nand then...', 'latin1', cnt('and then')); + w.write('\nand then...', 'binary', cnt('and then')); + if (multi) w.uncork(); + w.write('facebea7deadbeefdecafbad', 'hex', cnt('hex')); + if (uncork) w.uncork(); + w.end(cnt('end')); + w.on('finish', function () { // make sure finish comes after all the write cb cnt('finish')(); - assert.deepStrictEqual(actualChunks, expectChunks); + assert.deepStrictEqual(expectChunks, actualChunks); next(); }); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-base64-single-char-read-end.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-base64-single-char-read-end.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -28,12 +26,12 @@ var R = require('../../lib/_stream_readable'); var W = require('../../lib/_stream_writable'); var assert = require('assert/'); -var src = new R({ - encoding: 'base64' -}); + +var src = new R({ encoding: 'base64' }); var dst = new W(); var hasRead = false; var accum = ; + src._read = function (n) { if (!hasRead) { hasRead = true; @@ -43,26 +41,19 @@ }); } }; + dst._write = function (chunk, enc, cb) { accum.push(chunk); cb(); }; + src.on('end', function () { assert.strictEqual(String(Buffer.concat(accum)), 'MQ=='); clearTimeout(timeout); }); + src.pipe(dst); + var timeout = setTimeout(function () { assert.fail('timed out waiting for _write'); -}, 100); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +}, 100); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-basic.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-basic.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -40,106 +32,123 @@ var common = require('../common'); var R = require('../../lib/_stream_readable'); var assert = require('assert/'); + var EE = require('events').EventEmitter; -var TestReader = /*#__PURE__*/function (_R) { + +var TestReader = function (_R) { _inherits(TestReader, _R); - var _super = _createSuper(TestReader); + function TestReader(n) { - var _this; _classCallCheck(this, TestReader); - _this = _super.call(this); + + var _this = _possibleConstructorReturn(this, _R.call(this)); + _this._buffer = bufferShim.alloc(n || 100, 'x'); _this._pos = 0; _this._bufs = 10; return _this; } - _createClass(TestReader, { - key: "_read", - value: function _read(n) { - var _this2 = this; - var max = this._buffer.length - this._pos; - n = Math.max(n, 0); - var toRead = Math.min(n, max); - if (toRead === 0) { - // simulate the read buffer filling up with some more bytes some time - // in the future. - setTimeout(function () { - _this2._pos = 0; - _this2._bufs -= 1; - if (_this2._bufs <= 0) { - // read them all! - if (!_this2.ended) _this2.push(null); - } else { - // now we have more. - // kinda cheating by calling _read, but whatever, - // it's just fake anyway. - _this2._read(n); - } - }, 10); - return; - } - var ret = this._buffer.slice(this._pos, this._pos + toRead); - this._pos += toRead; - this.push(ret); + + TestReader.prototype._read = function _read(n) { + var _this2 = this; + + var max = this._buffer.length - this._pos; + n = Math.max(n, 0); + var toRead = Math.min(n, max); + if (toRead === 0) { + // simulate the read buffer filling up with some more bytes some time + // in the future. + setTimeout(function () { + _this2._pos = 0; + _this2._bufs -= 1; + if (_this2._bufs <= 0) { + // read them all! + if (!_this2.ended) _this2.push(null); + } else { + // now we have more. + // kinda cheating by calling _read, but whatever, + // it's just fake anyway. + _this2._read(n); + } + }, 10); + return; } - }); + + var ret = this._buffer.slice(this._pos, this._pos + toRead); + this._pos += toRead; + this.push(ret); + }; + return TestReader; }(R); -var TestWriter = /*#__PURE__*/function (_EE) { + +///// + +var TestWriter = function (_EE) { _inherits(TestWriter, _EE); - var _super2 = _createSuper(TestWriter); + function TestWriter() { - var _this3; _classCallCheck(this, TestWriter); - _this3 = _super2.call(this); + + var _this3 = _possibleConstructorReturn(this, _EE.call(this)); + _this3.received = ; _this3.flush = false; return _this3; } - _createClass(TestWriter, { - key: "write", - value: function write(c) { - this.received.push(c.toString()); - this.emit('write', c); - return true; - } - }, { - key: "end", - value: function end(c) { - if (c) this.write(c); - this.emit('end', this.received); - } - }); + + TestWriter.prototype.write = function write(c) { + this.received.push(c.toString()); + this.emit('write', c); + return true; + }; + + TestWriter.prototype.end = function end(c) { + if (c) this.write(c); + this.emit('end', this.received); + }; + return TestWriter; }(EE); + { - var flow = function flow() { - var res; - while (null !== (res = r.read(readSize++))) { - reads.push(res.toString()); - } - r.once('readable', flow); - }; // Test basic functionality var r = new TestReader(20); + var reads = ; var expect = 'x', 'xx', 'xxx', 'xxxx', 'xxxxx', 'xxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxxxxx', 'xxxxxxxxxxxxx', 'xxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxx'; + r.on('end', common.mustCall(function () { assert.deepStrictEqual(reads, expect); })); + var readSize = 1; + function flow() { + var res = void 0; + while (null !== (res = r.read(readSize++))) { + reads.push(res.toString()); + } + r.once('readable', flow); + } + flow(); } + { // Verify pipe var _r = new TestReader(5); + var _expect = 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx'; + var w = new TestWriter(); + w.on('end', common.mustCall(function (received) { assert.deepStrictEqual(received, _expect); })); + _r.pipe(w); } + forEach(1, 2, 3, 4, 5, 6, 7, 8, 9, function (SPLIT) { // Verify unpipe var r = new TestReader(5); @@ -147,7 +156,9 @@ // unpipe after 3 writes, then write to another stream instead. var expect = 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx'; expect = expect.slice(0, SPLIT), expect.slice(SPLIT); + var w = new TestWriter(), new TestWriter(); + var writes = SPLIT; w0.on('write', function () { if (--writes === 0) { @@ -158,33 +169,42 @@ assert.strictEqual(r._readableState.pipes, w1); } }); + var ended = 0; + w0.on('end', common.mustCall(function (results) { ended++; assert.strictEqual(ended, 1); assert.deepStrictEqual(results, expect0); })); + w1.on('end', common.mustCall(function (results) { ended++; assert.strictEqual(ended, 2); assert.deepStrictEqual(results, expect1); })); + r.pipe(w0); }); + { // Verify both writers get the same data when piping to destinations var _r2 = new TestReader(5); var _w = new TestWriter(), new TestWriter(); + var _expect2 = 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx'; + _w0.on('end', common.mustCall(function (received) { - assert.deepStrictEqual(received, _expect2); + assert.deepStrictEqual(received, _expect2, 'first'); })); _w1.on('end', common.mustCall(function (received) { - assert.deepStrictEqual(received, _expect2); + assert.deepStrictEqual(received, _expect2, 'second'); })); + _r2.pipe(_w0); _r2.pipe(_w1); } + forEach(1, 2, 3, 4, 5, 6, 7, 8, 9, function (SPLIT) { // Verify multi-unpipe var r = new TestReader(5); @@ -192,7 +212,9 @@ // unpipe after 3 writes, then write to another stream instead. var expect = 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx'; expect = expect.slice(0, SPLIT), expect.slice(SPLIT); + var w = new TestWriter(), new TestWriter(), new TestWriter(); + var writes = SPLIT; w0.on('write', function () { if (--writes === 0) { @@ -201,25 +223,28 @@ r.pipe(w1); } }); + var ended = 0; + w0.on('end', common.mustCall(function (results) { ended++; assert.strictEqual(ended, 1); assert.deepStrictEqual(results, expect0); })); + w1.on('end', common.mustCall(function (results) { ended++; assert.strictEqual(ended, 2); assert.deepStrictEqual(results, expect1); })); + r.pipe(w0); r.pipe(w2); }); + { // Verify that back pressure is respected - var _r3 = new R({ - objectMode: true - }); + var _r3 = new R({ objectMode: true }); _r3._read = common.mustNotCall(); var counter = 0; _r3.push('one'); @@ -227,6 +252,7 @@ _r3.push('three'); _r3.push('four'); _r3.push(null); + var w1 = new R(); w1.write = function (chunk) { assert.strictEqual(chunk0, 'one'); @@ -237,35 +263,47 @@ }); }; w1.end = common.mustNotCall(); + _r3.pipe(w1); + var expected = 'two', 'two', 'three', 'three', 'four', 'four'; + var w2 = new R(); w2.write = function (chunk) { assert.strictEqual(chunk0, expected.shift()); assert.strictEqual(counter, 0); + counter++; + if (chunk0 === 'four') { return true; } + setTimeout(function () { counter--; w2.emit('drain'); }, 10); + return false; }; w2.end = common.mustCall(); + var w3 = new R(); w3.write = function (chunk) { assert.strictEqual(chunk0, expected.shift()); assert.strictEqual(counter, 1); + counter++; + if (chunk0 === 'four') { return true; } + setTimeout(function () { counter--; w3.emit('drain'); }, 50); + return false; }; w3.end = common.mustCall(function () { @@ -273,28 +311,37 @@ assert.strictEqual(expected.length, 0); }); } + { // Verify read(0) behavior for ended streams var _r4 = new R(); var written = false; var ended = false; _r4._read = common.mustNotCall(); + _r4.push(bufferShim.from('foo')); _r4.push(null); + var v = _r4.read(0); + assert.strictEqual(v, null); + var _w2 = new R(); + _w2.write = function (buffer) { written = true; assert.strictEqual(ended, false); assert.strictEqual(buffer.toString(), 'foo'); }; + _w2.end = common.mustCall(function () { ended = true; assert.strictEqual(written, true); }); + _r4.pipe(_w2); } + { // Verify synchronous _read ending var _r5 = new R(); @@ -302,34 +349,40 @@ _r5._read = function (n) { _r5.push(null); }; + _r5.once('end', function () { // Verify that this is called before the next tick called = true; }); + _r5.read(); + process.nextTick(function () { assert.strictEqual(called, true); }); } + { // Verify that adding readable listeners trigger data flow - var _r6 = new R({ - highWaterMark: 5 - }); + var _r6 = new R({ highWaterMark: 5 }); var onReadable = false; var readCalled = 0; + _r6._read = function (n) { if (readCalled++ === 2) _r6.push(null);else _r6.push(bufferShim.from('asdf')); }; + _r6.on('readable', function () { onReadable = true; _r6.read(); }); + _r6.on('end', common.mustCall(function () { assert.strictEqual(readCalled, 3); assert.ok(onReadable); })); } + { // Verify that streams are chainable var _r7 = new R(); @@ -337,19 +390,9 @@ var r2 = _r7.setEncoding('utf8').pause().resume().pause(); assert.strictEqual(_r7, r2); } + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i); } -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-compatibility.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-compatibility.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -40,68 +32,64 @@ var R = require('../../lib/_stream_readable'); var W = require('../../lib/_stream_writable'); var assert = require('assert/'); + var ondataCalled = 0; -var TestReader = /*#__PURE__*/function (_R) { + +var TestReader = function (_R) { _inherits(TestReader, _R); - var _super = _createSuper(TestReader); + function TestReader() { - var _this; _classCallCheck(this, TestReader); - _this = _super.call(this); + + var _this = _possibleConstructorReturn(this, _R.call(this)); + _this._buffer = bufferShim.alloc(100, 'x'); + _this.on('data', function () { ondataCalled++; }); return _this; } - _createClass(TestReader, { - key: "_read", - value: function _read(n) { - this.push(this._buffer); - this._buffer = bufferShim.alloc(0); - } - }); + + TestReader.prototype._read = function _read(n) { + this.push(this._buffer); + this._buffer = bufferShim.alloc(0); + }; + return TestReader; }(R); + var reader = new TestReader(); setImmediate(function () { assert.strictEqual(ondataCalled, 1); - require('tap').pass(); + console.log('ok'); reader.push(null); }); -var TestWriter = /*#__PURE__*/function (_W) { + +var TestWriter = function (_W) { _inherits(TestWriter, _W); - var _super2 = _createSuper(TestWriter); + function TestWriter() { - var _this2; _classCallCheck(this, TestWriter); - _this2 = _super2.call(this); + + var _this2 = _possibleConstructorReturn(this, _W.call(this)); + _this2.write('foo'); _this2.end(); return _this2; } - _createClass(TestWriter, { - key: "_write", - value: function _write(chunk, enc, cb) { - cb(); - } - }); + + TestWriter.prototype._write = function _write(chunk, enc, cb) { + cb(); + }; + return TestWriter; }(W); + var writer = new TestWriter(); + process.on('exit', function () { assert.strictEqual(reader.readable, false); assert.strictEqual(writer.writable, false); - require('tap').pass(); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + console.log('ok'); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-decode-partial.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-decode-partial.js
Changed
@@ -1,37 +1,25 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ require('../common'); var Readable = require('../../lib/_stream_readable'); var assert = require('assert/'); + var buf = ''; var euro = bufferShim.from(0xE2, 0x82, 0xAC); var cent = bufferShim.from(0xC2, 0xA2); var source = Buffer.concat(euro, cent); -var readable = Readable({ - encoding: 'utf8' -}); + +var readable = Readable({ encoding: 'utf8' }); readable.push(source.slice(0, 2)); readable.push(source.slice(2, 4)); -readable.push(source.slice(4, source.length)); -; +readable.push(source.slice(4, source.length));; readable.push(null); + readable.on('data', function (data) { buf += data; }); + process.on('exit', function () { assert.strictEqual(buf, '€¢'); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-finish-pipe.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-finish-pipe.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,28 +24,20 @@ /*</replacement>*/ require('../common'); var stream = require('../../'); + var r = new stream.Readable(); r._read = function (size) { r.push(bufferShim.allocUnsafe(size)); }; + var w = new stream.Writable(); w._write = function (data, encoding, cb) { cb(null); }; + r.pipe(w); // This might sound unrealistic, but it happens in net.js. When // `socket.allowHalfOpen === false`, EOF will cause `.destroySoon()` call which // ends the writable side of net.Socket. -w.end(); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +w.end(); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-large-read-stall.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-large-read-stall.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -34,49 +32,40 @@ var PUSHSIZE = 20; var PUSHCOUNT = 1000; var HWM = 50; + var Readable = require('../../').Readable; var r = new Readable({ highWaterMark: HWM }); var rs = r._readableState; + r._read = push; + r.on('readable', function () { - ; - false && console.error('>> readable'); - var ret; + ;false && console.error('>> readable'); + var ret = void 0; do { - ; - false && console.error(" > read(".concat(READSIZE, ")")); + ;false && console.error(' > read(' + READSIZE + ')'); ret = r.read(READSIZE); - ; - false && console.error(" < ".concat(ret && ret.length, " (").concat(rs.length, " remain)")); + ;false && console.error(' < ' + (ret && ret.length) + ' (' + rs.length + ' remain)'); } while (ret && ret.length === READSIZE); - ; - false && console.error('<< after read()', ret && ret.length, rs.needReadable, rs.length); + + ;false && console.error('<< after read()', ret && ret.length, rs.needReadable, rs.length); }); + r.on('end', common.mustCall(function () { assert.strictEqual(pushes, PUSHCOUNT + 1); })); + var pushes = 0; function push() { if (pushes > PUSHCOUNT) return; + if (pushes++ === PUSHCOUNT) { - ; - false && console.error(' push(EOF)'); + ;false && console.error(' push(EOF)'); return r.push(null); } - ; - false && console.error(" push #".concat(pushes)); + + ;false && console.error(' push #' + pushes); if (r.push(bufferShim.allocUnsafe(PUSHSIZE))) setTimeout(push, 1); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-objects.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-objects.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -29,162 +27,141 @@ var Readable = require('../../lib/_stream_readable'); var Writable = require('../../lib/_stream_writable'); var assert = require('assert/'); + function toArray(callback) { - var stream = new Writable({ - objectMode: true - }); + var stream = new Writable({ objectMode: true }); var list = ; stream.write = function (chunk) { list.push(chunk); }; + stream.end = common.mustCall(function () { callback(list); }); + return stream; } + function fromArray(list) { - var r = new Readable({ - objectMode: true - }); + var r = new Readable({ objectMode: true }); r._read = common.mustNotCall(); forEach(list, function (chunk) { r.push(chunk); }); r.push(null); + return r; } + { // Verify that objects can be read from the stream - var r = fromArray({ - one: '1' - }, { - two: '2' - }); + var r = fromArray({ one: '1' }, { two: '2' }); + var v1 = r.read(); var v2 = r.read(); var v3 = r.read(); - assert.deepStrictEqual(v1, { - one: '1' - }); - assert.deepStrictEqual(v2, { - two: '2' - }); + + assert.deepStrictEqual(v1, { one: '1' }); + assert.deepStrictEqual(v2, { two: '2' }); assert.deepStrictEqual(v3, null); } + { // Verify that objects can be piped into the stream - var _r = fromArray({ - one: '1' - }, { - two: '2' - }); + var _r = fromArray({ one: '1' }, { two: '2' }); + _r.pipe(toArray(common.mustCall(function (list) { - assert.deepStrictEqual(list, { - one: '1' - }, { - two: '2' - }); + assert.deepStrictEqual(list, { one: '1' }, { two: '2' }); }))); } + { // Verify that read(n) is ignored - var _r2 = fromArray({ - one: '1' - }, { - two: '2' - }); + var _r2 = fromArray({ one: '1' }, { two: '2' }); var value = _r2.read(2); - assert.deepStrictEqual(value, { - one: '1' - }); + + assert.deepStrictEqual(value, { one: '1' }); } + { // Verify that objects can be synchronously read - var _r3 = new Readable({ - objectMode: true - }); - var list = { - one: '1' - }, { - two: '2' - }; + var _r3 = new Readable({ objectMode: true }); + var list = { one: '1' }, { two: '2' }; _r3._read = function (n) { var item = list.shift(); _r3.push(item || null); }; + _r3.pipe(toArray(common.mustCall(function (list) { - assert.deepStrictEqual(list, { - one: '1' - }, { - two: '2' - }); + assert.deepStrictEqual(list, { one: '1' }, { two: '2' }); }))); } + { // Verify that objects can be asynchronously read - var _r4 = new Readable({ - objectMode: true - }); - var _list2 = { - one: '1' - }, { - two: '2' - }; + var _r4 = new Readable({ objectMode: true }); + var _list = { one: '1' }, { two: '2' }; _r4._read = function (n) { - var item = _list2.shift(); + var item = _list.shift(); process.nextTick(function () { _r4.push(item || null); }); }; + _r4.pipe(toArray(common.mustCall(function (list) { - assert.deepStrictEqual(list, { - one: '1' - }, { - two: '2' - }); + assert.deepStrictEqual(list, { one: '1' }, { two: '2' }); }))); } + { // Verify that strings can be read as objects var _r5 = new Readable({ objectMode: true }); _r5._read = common.mustNotCall(); - var _list3 = 'one', 'two', 'three'; - forEach(_list3, function (str) { + var _list2 = 'one', 'two', 'three'; + forEach(_list2, function (str) { _r5.push(str); }); _r5.push(null); + _r5.pipe(toArray(common.mustCall(function (array) { - assert.deepStrictEqual(array, _list3); + assert.deepStrictEqual(array, _list2); }))); } + { // Verify read(0) behavior for object streams var _r6 = new Readable({ objectMode: true }); _r6._read = common.mustNotCall(); + _r6.push('foobar'); _r6.push(null); + _r6.pipe(toArray(common.mustCall(function (array) { assert.deepStrictEqual(array, 'foobar'); }))); } + { // Verify the behavior of pushing falsey values var _r7 = new Readable({ objectMode: true }); _r7._read = common.mustNotCall(); + _r7.push(false); _r7.push(0); _r7.push(''); _r7.push(null); + _r7.pipe(toArray(common.mustCall(function (array) { assert.deepStrictEqual(array, false, 0, ''); }))); } + { // Verify high watermark _read() behavior var _r8 = new Readable({ @@ -192,22 +169,30 @@ objectMode: true }); var calls = 0; - var _list4 = '1', '2', '3', '4', '5', '6', '7', '8'; + var _list3 = '1', '2', '3', '4', '5', '6', '7', '8'; + _r8._read = function (n) { calls++; }; - forEach(_list4, function (c) { + + forEach(_list3, function (c) { _r8.push(c); }); + var v = _r8.read(); + assert.strictEqual(calls, 0); assert.strictEqual(v, '1'); + var _v = _r8.read(); assert.strictEqual(_v, '2'); + var _v2 = _r8.read(); assert.strictEqual(_v2, '3'); + assert.strictEqual(calls, 1); } + { // Verify high watermark push behavior var _r9 = new Readable({ @@ -220,36 +205,35 @@ assert.strictEqual(bool, i !== 5); } } + { // Verify that objects can be written to stream - var w = new Writable({ - objectMode: true - }); + var w = new Writable({ objectMode: true }); + w._write = function (chunk, encoding, cb) { - assert.deepStrictEqual(chunk, { - foo: 'bar' - }); + assert.deepStrictEqual(chunk, { foo: 'bar' }); cb(); }; + w.on('finish', common.mustCall()); - w.write({ - foo: 'bar' - }); + w.write({ foo: 'bar' }); w.end(); } + { // Verify that multiple objects can be written to stream - var _w = new Writable({ - objectMode: true - }); - var _list5 = ; + var _w = new Writable({ objectMode: true }); + var _list4 = ; + _w._write = function (chunk, encoding, cb) { - _list5.push(chunk); + _list4.push(chunk); cb(); }; + _w.on('finish', common.mustCall(function () { - assert.deepStrictEqual(_list5, 0, 1, 2, 3, 4); + assert.deepStrictEqual(_list4, 0, 1, 2, 3, 4); })); + _w.write(0); _w.write(1); _w.write(2); @@ -257,19 +241,23 @@ _w.write(4); _w.end(); } + { // Verify that strings can be written as objects var _w2 = new Writable({ objectMode: true }); - var _list6 = ; + var _list5 = ; + _w2._write = function (chunk, encoding, cb) { - _list6.push(chunk); + _list5.push(chunk); process.nextTick(cb); }; + _w2.on('finish', common.mustCall(function () { - assert.deepStrictEqual(_list6, '0', '1', '2', '3', '4'); + assert.deepStrictEqual(_list5, '0', '1', '2', '3', '4'); })); + _w2.write('0'); _w2.write('1'); _w2.write('2'); @@ -277,38 +265,33 @@ _w2.write('4'); _w2.end(); } + { // Verify that stream buffers finish until callback is called var _w3 = new Writable({ objectMode: true }); var called = false; + _w3._write = function (chunk, encoding, cb) { assert.strictEqual(chunk, 'foo'); + process.nextTick(function () { called = true; cb(); }); }; + _w3.on('finish', common.mustCall(function () { assert.strictEqual(called, true); })); + _w3.write('foo'); _w3.end(); } + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i); } -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-pipe-error-handling.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-pipe-error-handling.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -27,61 +25,77 @@ require('../common'); var assert = require('assert/'); var stream = require('../../'); + { var count = 1000; + var source = new stream.Readable(); source._read = function (n) { n = Math.min(count, n); count -= n; source.push(bufferShim.allocUnsafe(n)); }; - var unpipedDest; + + var unpipedDest = void 0; source.unpipe = function (dest) { unpipedDest = dest; stream.Readable.prototype.unpipe.call(this, dest); }; + var dest = new stream.Writable(); dest._write = function (chunk, encoding, cb) { cb(); }; + source.pipe(dest); + var gotErr = null; dest.on('error', function (err) { gotErr = err; }); - var unpipedSource; + + var unpipedSource = void 0; dest.on('unpipe', function (src) { unpipedSource = src; }); + var err = new Error('This stream turned into bacon.'); dest.emit('error', err); assert.strictEqual(gotErr, err); assert.strictEqual(unpipedSource, source); assert.strictEqual(unpipedDest, dest); } + { var _count = 1000; + var _source = new stream.Readable(); _source._read = function (n) { n = Math.min(_count, n); _count -= n; _source.push(bufferShim.allocUnsafe(n)); }; - var _unpipedDest; + + var _unpipedDest = void 0; _source.unpipe = function (dest) { _unpipedDest = dest; stream.Readable.prototype.unpipe.call(this, dest); }; + var _dest = new stream.Writable(); _dest._write = function (chunk, encoding, cb) { cb(); }; + _source.pipe(_dest); - var _unpipedSource; + + var _unpipedSource = void 0; _dest.on('unpipe', function (src) { _unpipedSource = src; }); + var _err = new Error('This stream turned into bacon.'); + var _gotErr = null; try { _dest.emit('error', _err); @@ -91,15 +105,4 @@ assert.strictEqual(_gotErr, _err); assert.strictEqual(_unpipedSource, _source); assert.strictEqual(_unpipedDest, _dest); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-pipe-error-once-listener.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-pipe-error-once-listener.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -39,56 +31,51 @@ require('../common'); var stream = require('../../'); -var Read = /*#__PURE__*/function (_stream$Readable) { + +var Read = function (_stream$Readable) { _inherits(Read, _stream$Readable); - var _super = _createSuper(Read); + function Read() { _classCallCheck(this, Read); - return _super.apply(this, arguments); + + return _possibleConstructorReturn(this, _stream$Readable.apply(this, arguments)); } - _createClass(Read, { - key: "_read", - value: function _read(size) { - this.push('x'); - this.push(null); - } - }); + + Read.prototype._read = function _read(size) { + this.push('x'); + this.push(null); + }; + return Read; }(stream.Readable); -var Write = /*#__PURE__*/function (_stream$Writable) { + +var Write = function (_stream$Writable) { _inherits(Write, _stream$Writable); - var _super2 = _createSuper(Write); + function Write() { _classCallCheck(this, Write); - return _super2.apply(this, arguments); + + return _possibleConstructorReturn(this, _stream$Writable.apply(this, arguments)); } - _createClass(Write, { - key: "_write", - value: function _write(buffer, encoding, cb) { - this.emit('error', new Error('boom')); - this.emit('alldone'); - } - }); + + Write.prototype._write = function _write(buffer, encoding, cb) { + this.emit('error', new Error('boom')); + this.emit('alldone'); + }; + return Write; }(stream.Writable); + var read = new Read(); var write = new Write(); + write.once('error', function () {}); write.once('alldone', function (err) { - require('tap').pass(); + console.log('ok'); }); + process.on('exit', function (c) { console.error('error thrown even with listener'); }); -read.pipe(write); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +read.pipe(write); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-push.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-push.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,9 +24,11 @@ /*</replacement>*/ require('../common'); var assert = require('assert/'); + var _require = require('../../'), - Readable = _require.Readable, - Writable = _require.Writable; + Readable = _require.Readable, + Writable = _require.Writable; + var EE = require('events').EventEmitter; // a mock thing a bit like the net.Socket/tcp_wrap.handle interaction @@ -37,28 +37,36 @@ highWaterMark: 16, encoding: 'utf8' }); + var source = new EE(); + stream._read = function () { console.error('stream._read'); readStart(); }; + var ended = false; stream.on('end', function () { ended = true; }); + source.on('data', function (chunk) { var ret = stream.push(chunk); - console.error('data', stream.readableLength); + console.error('data', stream._readableState.length); if (!ret) readStop(); }); + source.on('end', function () { stream.push(null); }); + var reading = false; + function readStart() { console.error('readStart'); reading = true; } + function readStop() { console.error('readStop'); reading = false; @@ -67,21 +75,27 @@ if (r !== null) writer.write(r); }); } + var writer = new Writable({ decodeStrings: false }); + var written = ; + var expectWritten = 'asdfgasdfgasdfgasdfg', 'asdfgasdfgasdfgasdfg', 'asdfgasdfgasdfgasdfg', 'asdfgasdfgasdfgasdfg', 'asdfgasdfgasdfgasdfg', 'asdfgasdfgasdfgasdfg'; + writer._write = function (chunk, encoding, cb) { - console.error("WRITE ".concat(chunk)); + console.error('WRITE ' + chunk); written.push(chunk); process.nextTick(cb); }; + writer.on('finish', finish); // now emit some chunks. var chunk = 'asdfg'; + var set = 0; readStart(); data(); @@ -97,11 +111,13 @@ assert(!reading); if (set++ < 5) setTimeout(data, 10);else end(); } + function finish() { console.error('finish'); assert.deepStrictEqual(written, expectWritten); - require('tap').pass(); + console.log('ok'); } + function end() { source.emit('end'); assert(!reading); @@ -109,15 +125,4 @@ setImmediate(function () { assert(ended); }); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-read-sync-stack.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-read-sync-stack.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,31 +24,24 @@ /*</replacement>*/ var common = require('../common'); var Readable = require('../../').Readable; - -// This tests synchronous read callbacks and verifies that even if they nest -// heavily the process handles it without an error - var r = new Readable(); var N = 256 * 1024; + +// Go ahead and allow the pathological case for this test. +// Yes, it's an infinite loop, that's the point. +process.maxTickDepth = N + 2; + var reads = 0; r._read = function (n) { var chunk = reads++ === N ? null : bufferShim.allocUnsafe(1); r.push(chunk); }; + r.on('readable', function onReadable() { - if (!(r.readableLength % 256)) console.error('readable', r.readableLength); + if (!(r._readableState.length % 256)) console.error('readable', r._readableState.length); r.read(N * 2); }); + r.on('end', common.mustCall()); -r.read(0); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +r.read(0); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-readable-empty-buffer-no-eof.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,9 +24,12 @@ /*</replacement>*/ require('../common'); var assert = require('assert/'); + var Readable = require('../../').Readable; + test1(); test2(); + function test1() { var r = new Readable(); @@ -62,64 +63,58 @@ }); case 2: setImmediate(r.read.bind(r, 0)); - return r.push(bufferShim.alloc(0)); - // Not-EOF! + return r.push(bufferShim.alloc(0)); // Not-EOF! case 1: return r.push(buf); case 0: - return r.push(null); - // EOF + return r.push(null); // EOF default: throw new Error('unreachable'); } }; + var results = ; function flow() { - var chunk; - while (null !== (chunk = r.read())) results.push(String(chunk)); + var chunk = void 0; + while (null !== (chunk = r.read())) { + results.push(String(chunk)); + } } r.on('readable', flow); r.on('end', function () { results.push('EOF'); }); flow(); + process.on('exit', function () { assert.deepStrictEqual(results, 'xxxxx', 'xxxxx', 'EOF'); - require('tap').pass(); + console.log('ok'); }); } + function test2() { - var r = new Readable({ - encoding: 'base64' - }); + var r = new Readable({ encoding: 'base64' }); var reads = 5; r._read = function (n) { if (!reads--) return r.push(null); // EOF else return r.push(bufferShim.from('x')); }; + var results = ; function flow() { - var chunk; - while (null !== (chunk = r.read())) results.push(String(chunk)); + var chunk = void 0; + while (null !== (chunk = r.read())) { + results.push(String(chunk)); + } } r.on('readable', flow); r.on('end', function () { results.push('EOF'); }); flow(); + process.on('exit', function () { assert.deepStrictEqual(results, 'eHh4', 'eHg=', 'EOF'); - require('tap').pass(); + console.log('ok'); }); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-readable-from-list.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-readable-from-list.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -21,106 +19,68 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +// Flags: --expose_internals /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ require('../common'); var assert = require('assert/'); var fromList = require('../../lib/_stream_readable')._fromList; -var BufferList = require('../../lib/internal/streams/buffer_list'); -var util = require('util'); +var BufferList = require('../../lib/internal/streams/BufferList'); + function bufferListFromArray(arr) { var bl = new BufferList(); - for (var i = 0; i < arr.length; ++i) bl.push(arri); - return bl; + for (var i = 0; i < arr.length; ++i) { + bl.push(arri); + }return bl; } + { // Verify behavior with buffers var list = bufferShim.from('foog'), bufferShim.from('bark'), bufferShim.from('bazy'), bufferShim.from('kuel'); list = bufferListFromArray(list); - assert.strictEqual(util.inspect(list, { - compact: false - }).indexOf('BufferList') > 0, true); // read more than the first element. - var ret = fromList(6, { - buffer: list, - length: 16 - }); + var ret = fromList(6, { buffer: list, length: 16 }); assert.strictEqual(ret.toString(), 'foogba'); // read exactly the first element. - ret = fromList(2, { - buffer: list, - length: 10 - }); + ret = fromList(2, { buffer: list, length: 10 }); assert.strictEqual(ret.toString(), 'rk'); // read less than the first element. - ret = fromList(2, { - buffer: list, - length: 8 - }); + ret = fromList(2, { buffer: list, length: 8 }); assert.strictEqual(ret.toString(), 'ba'); // read more than we have. - ret = fromList(100, { - buffer: list, - length: 6 - }); + ret = fromList(100, { buffer: list, length: 6 }); assert.strictEqual(ret.toString(), 'zykuel'); // all consumed. assert.deepStrictEqual(list, new BufferList()); } + { // Verify behavior with strings - var _list2 = 'foog', 'bark', 'bazy', 'kuel'; - _list2 = bufferListFromArray(_list2); + var _list = 'foog', 'bark', 'bazy', 'kuel'; + _list = bufferListFromArray(_list); // read more than the first element. - var _ret = fromList(6, { - buffer: _list2, - length: 16, - decoder: true - }); + var _ret = fromList(6, { buffer: _list, length: 16, decoder: true }); assert.strictEqual(_ret, 'foogba'); // read exactly the first element. - _ret = fromList(2, { - buffer: _list2, - length: 10, - decoder: true - }); + _ret = fromList(2, { buffer: _list, length: 10, decoder: true }); assert.strictEqual(_ret, 'rk'); // read less than the first element. - _ret = fromList(2, { - buffer: _list2, - length: 8, - decoder: true - }); + _ret = fromList(2, { buffer: _list, length: 8, decoder: true }); assert.strictEqual(_ret, 'ba'); // read more than we have. - _ret = fromList(100, { - buffer: _list2, - length: 6, - decoder: true - }); + _ret = fromList(100, { buffer: _list, length: 6, decoder: true }); assert.strictEqual(_ret, 'zykuel'); // all consumed. - assert.deepStrictEqual(_list2, new BufferList()); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + assert.deepStrictEqual(_list, new BufferList()); +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-readable-legacy-drain.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-readable-legacy-drain.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,15 +24,19 @@ /*</replacement>*/ var common = require('../common'); var assert = require('assert/'); + var Stream = require('../../'); var Readable = require('../../').Readable; + var r = new Readable(); var N = 256; var reads = 0; r._read = function (n) { return r.push(++reads === N ? null : bufferShim.allocUnsafe(1)); }; + r.on('end', common.mustCall()); + var w = new Stream(); w.writable = true; var buffered = 0; @@ -43,11 +45,13 @@ process.nextTick(drain); return false; }; + function drain() { assert(buffered <= 3); buffered = 0; w.emit('drain'); } + w.end = common.mustCall(); // Just for kicks, let's mess with the drain count. @@ -56,15 +60,5 @@ r.on('readable', function () { w.emit('drain'); }); -r.pipe(w); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +r.pipe(w); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-readable-non-empty-end.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-readable-non-empty-end.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -27,12 +25,14 @@ var common = require('../common'); var assert = require('assert/'); var Readable = require('../../lib/_stream_readable'); + var len = 0; var chunks = new Array(10); for (var i = 1; i <= 10; i++) { chunksi - 1 = bufferShim.allocUnsafe(i); len += i; } + var test = new Readable(); var n = 0; test._read = function (size) { @@ -41,22 +41,25 @@ test.push(chunk === undefined ? null : chunk); }, 1); }; + test.on('end', thrower); function thrower() { throw new Error('this should not happen!'); } + var bytesread = 0; test.on('readable', function () { var b = len - bytesread - 1; var res = test.read(b); if (res) { bytesread += res.length; - console.error("br=".concat(bytesread, " len=").concat(len)); + console.error('br=' + bytesread + ' len=' + len); setTimeout(next, 1); } test.read(0); }); test.read(0); + function next() { // now let's make 'end' happen test.removeListener('end', thrower); @@ -68,15 +71,4 @@ assert.strictEqual(r.length, 1); r = test.read(); assert.strictEqual(r, null); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-readable-wrap-empty.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-readable-wrap-empty.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -25,22 +23,16 @@ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ var common = require('../common'); + var Readable = require('../../lib/_stream_readable'); var EE = require('events').EventEmitter; + var oldStream = new EE(); oldStream.pause = function () {}; oldStream.resume = function () {}; + var newStream = new Readable().wrap(oldStream); + newStream.on('readable', function () {}).on('end', common.mustCall()); -oldStream.emit('end'); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file + +oldStream.emit('end'); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-set-encoding.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-set-encoding.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -39,170 +31,197 @@ var common = require('../common'); var assert = require('assert/'); var R = require('../../lib/_stream_readable'); -var TestReader = /*#__PURE__*/function (_R) { + +var TestReader = function (_R) { _inherits(TestReader, _R); - var _super = _createSuper(TestReader); + function TestReader(n, opts) { - var _this; _classCallCheck(this, TestReader); - _this = _super.call(this, opts); + + var _this = _possibleConstructorReturn(this, _R.call(this, opts)); + _this.pos = 0; _this.len = n || 100; return _this; } - _createClass(TestReader, { - key: "_read", - value: function _read(n) { - var _this2 = this; - setTimeout(function () { - if (_this2.pos >= _this2.len) { - // double push(null) to test eos handling - _this2.push(null); - return _this2.push(null); - } - n = Math.min(n, _this2.len - _this2.pos); - if (n <= 0) { - // double push(null) to test eos handling - _this2.push(null); - return _this2.push(null); - } - _this2.pos += n; - var ret = bufferShim.alloc(n, 'a'); - return _this2.push(ret); - }, 1); - } - }); + + TestReader.prototype._read = function _read(n) { + var _this2 = this; + + setTimeout(function () { + if (_this2.pos >= _this2.len) { + // double push(null) to test eos handling + _this2.push(null); + return _this2.push(null); + } + + n = Math.min(n, _this2.len - _this2.pos); + if (n <= 0) { + // double push(null) to test eos handling + _this2.push(null); + return _this2.push(null); + } + + _this2.pos += n; + var ret = bufferShim.alloc(n, 'a'); + + return _this2.push(ret); + }, 1); + }; + return TestReader; }(R); + { // Verify utf8 encoding var tr = new TestReader(100); tr.setEncoding('utf8'); var out = ; var expect = 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'; + tr.on('readable', function flow() { - var chunk; - while (null !== (chunk = tr.read(10))) out.push(chunk); + var chunk = void 0; + while (null !== (chunk = tr.read(10))) { + out.push(chunk); + } }); + tr.on('end', common.mustCall(function () { assert.deepStrictEqual(out, expect); })); } + { // Verify hex encoding var _tr = new TestReader(100); _tr.setEncoding('hex'); var _out = ; var _expect = '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161'; + _tr.on('readable', function flow() { - var chunk; - while (null !== (chunk = _tr.read(10))) _out.push(chunk); + var chunk = void 0; + while (null !== (chunk = _tr.read(10))) { + _out.push(chunk); + } }); + _tr.on('end', common.mustCall(function () { assert.deepStrictEqual(_out, _expect); })); } + { // Verify hex encoding with read(13) var _tr2 = new TestReader(100); _tr2.setEncoding('hex'); var _out2 = ; var _expect2 = '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '16161'; + _tr2.on('readable', function flow() { - var chunk; - while (null !== (chunk = _tr2.read(13))) _out2.push(chunk); + var chunk = void 0; + while (null !== (chunk = _tr2.read(13))) { + _out2.push(chunk); + } }); + _tr2.on('end', common.mustCall(function () { assert.deepStrictEqual(_out2, _expect2); })); } + { // Verify base64 encoding var _tr3 = new TestReader(100); _tr3.setEncoding('base64'); var _out3 = ; var _expect3 = 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYQ=='; + _tr3.on('readable', function flow() { - var chunk; - while (null !== (chunk = _tr3.read(10))) _out3.push(chunk); + var chunk = void 0; + while (null !== (chunk = _tr3.read(10))) { + _out3.push(chunk); + } }); + _tr3.on('end', common.mustCall(function () { assert.deepStrictEqual(_out3, _expect3); })); } + { // Verify utf8 encoding - var _tr4 = new TestReader(100, { - encoding: 'utf8' - }); + var _tr4 = new TestReader(100, { encoding: 'utf8' }); var _out4 = ; var _expect4 = 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'; + _tr4.on('readable', function flow() { - var chunk; - while (null !== (chunk = _tr4.read(10))) _out4.push(chunk); + var chunk = void 0; + while (null !== (chunk = _tr4.read(10))) { + _out4.push(chunk); + } }); + _tr4.on('end', common.mustCall(function () { assert.deepStrictEqual(_out4, _expect4); })); } + { // Verify hex encoding - var _tr5 = new TestReader(100, { - encoding: 'hex' - }); + var _tr5 = new TestReader(100, { encoding: 'hex' }); var _out5 = ; var _expect5 = '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161', '6161616161'; + _tr5.on('readable', function flow() { - var chunk; - while (null !== (chunk = _tr5.read(10))) _out5.push(chunk); + var chunk = void 0; + while (null !== (chunk = _tr5.read(10))) { + _out5.push(chunk); + } }); + _tr5.on('end', common.mustCall(function () { assert.deepStrictEqual(_out5, _expect5); })); } + { // Verify hex encoding with read(13) - var _tr6 = new TestReader(100, { - encoding: 'hex' - }); + var _tr6 = new TestReader(100, { encoding: 'hex' }); var _out6 = ; var _expect6 = '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '1616161616161', '6161616161616', '16161'; + _tr6.on('readable', function flow() { - var chunk; - while (null !== (chunk = _tr6.read(13))) _out6.push(chunk); + var chunk = void 0; + while (null !== (chunk = _tr6.read(13))) { + _out6.push(chunk); + } }); + _tr6.on('end', common.mustCall(function () { assert.deepStrictEqual(_out6, _expect6); })); } + { // Verify base64 encoding - var _tr7 = new TestReader(100, { - encoding: 'base64' - }); + var _tr7 = new TestReader(100, { encoding: 'base64' }); var _out7 = ; var _expect7 = 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', 'FhYQ=='; + _tr7.on('readable', function flow() { - var chunk; - while (null !== (chunk = _tr7.read(10))) _out7.push(chunk); + var chunk = void 0; + while (null !== (chunk = _tr7.read(10))) { + _out7.push(chunk); + } }); + _tr7.on('end', common.mustCall(function () { assert.deepStrictEqual(_out7, _expect7); })); } + { // Verify chaining behavior var _tr8 = new TestReader(100); assert.deepStrictEqual(_tr8.setEncoding('utf8'), _tr8); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-transform.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-transform.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -28,76 +26,85 @@ var assert = require('assert/'); var PassThrough = require('../../lib/_stream_passthrough'); var Transform = require('../../lib/_stream_transform'); + { // Verify writable side consumption var tx = new Transform({ highWaterMark: 10 }); + var transformed = 0; tx._transform = function (chunk, encoding, cb) { transformed += chunk.length; tx.push(chunk); cb(); }; + for (var i = 1; i <= 10; i++) { tx.write(bufferShim.allocUnsafe(i)); } tx.end(); - assert.strictEqual(tx.readableLength, 10); + + assert.strictEqual(tx._readableState.length, 10); assert.strictEqual(transformed, 10); assert.strictEqual(tx._transformState.writechunk.length, 5); - assert.deepStrictEqual(tx.writableBuffer.map(function (c) { + assert.deepStrictEqual(tx._writableState.getBuffer().map(function (c) { return c.chunk.length; }), 6, 7, 8, 9, 10); } + { // Verify passthrough behavior var pt = new PassThrough(); + pt.write(bufferShim.from('foog')); pt.write(bufferShim.from('bark')); pt.write(bufferShim.from('bazy')); pt.write(bufferShim.from('kuel')); pt.end(); + assert.strictEqual(pt.read(5).toString(), 'foogb'); assert.strictEqual(pt.read(5).toString(), 'arkba'); assert.strictEqual(pt.read(5).toString(), 'zykue'); assert.strictEqual(pt.read(5).toString(), 'l'); } + { // Verify object passthrough behavior - var _pt = new PassThrough({ - objectMode: true - }); + var _pt = new PassThrough({ objectMode: true }); + _pt.write(1); _pt.write(true); _pt.write(false); _pt.write(0); _pt.write('foo'); _pt.write(''); - _pt.write({ - a: 'b' - }); + _pt.write({ a: 'b' }); _pt.end(); + assert.strictEqual(_pt.read(), 1); assert.strictEqual(_pt.read(), true); assert.strictEqual(_pt.read(), false); assert.strictEqual(_pt.read(), 0); assert.strictEqual(_pt.read(), 'foo'); assert.strictEqual(_pt.read(), ''); - assert.deepStrictEqual(_pt.read(), { - a: 'b' - }); + assert.deepStrictEqual(_pt.read(), { a: 'b' }); } + { // Verify passthrough constructor behavior var _pt2 = PassThrough(); + assert(_pt2 instanceof PassThrough); } + { // Verify transform constructor behavior var _pt3 = Transform(); + assert(_pt3 instanceof Transform); } + { // Perform a simple transform var _pt4 = new Transform(); @@ -106,35 +113,36 @@ _pt4.push(ret); cb(); }; + _pt4.write(bufferShim.from('foog')); _pt4.write(bufferShim.from('bark')); _pt4.write(bufferShim.from('bazy')); _pt4.write(bufferShim.from('kuel')); _pt4.end(); + assert.strictEqual(_pt4.read(5).toString(), 'xxxxx'); assert.strictEqual(_pt4.read(5).toString(), 'xxxxx'); assert.strictEqual(_pt4.read(5).toString(), 'xxxxx'); assert.strictEqual(_pt4.read(5).toString(), 'x'); } + { // Verify simple object transform - var _pt5 = new Transform({ - objectMode: true - }); + var _pt5 = new Transform({ objectMode: true }); _pt5._transform = function (c, e, cb) { _pt5.push(JSON.stringify(c)); cb(); }; + _pt5.write(1); _pt5.write(true); _pt5.write(false); _pt5.write(0); _pt5.write('foo'); _pt5.write(''); - _pt5.write({ - a: 'b' - }); + _pt5.write({ a: 'b' }); _pt5.end(); + assert.strictEqual(_pt5.read(), '1'); assert.strictEqual(_pt5.read(), 'true'); assert.strictEqual(_pt5.read(), 'false'); @@ -143,6 +151,7 @@ assert.strictEqual(_pt5.read(), '""'); assert.strictEqual(_pt5.read(), '{"a":"b"}'); } + { // Verify async passthrough var _pt6 = new Transform(); @@ -152,11 +161,13 @@ cb(); }, 10); }; + _pt6.write(bufferShim.from('foog')); _pt6.write(bufferShim.from('bark')); _pt6.write(bufferShim.from('bazy')); _pt6.write(bufferShim.from('kuel')); _pt6.end(); + _pt6.on('finish', common.mustCall(function () { assert.strictEqual(_pt6.read(5).toString(), 'foogb'); assert.strictEqual(_pt6.read(5).toString(), 'arkba'); @@ -164,8 +175,9 @@ assert.strictEqual(_pt6.read(5).toString(), 'l'); })); } + { - // Verify asymmetric transform (expand) + // Verify assymetric transform (expand) var _pt7 = new Transform(); // emit each chunk 2 times. @@ -178,11 +190,13 @@ }, 10); }, 10); }; + _pt7.write(bufferShim.from('foog')); _pt7.write(bufferShim.from('bark')); _pt7.write(bufferShim.from('bazy')); _pt7.write(bufferShim.from('kuel')); _pt7.end(); + _pt7.on('finish', common.mustCall(function () { assert.strictEqual(_pt7.read(5).toString(), 'foogf'); assert.strictEqual(_pt7.read(5).toString(), 'oogba'); @@ -193,15 +207,18 @@ assert.strictEqual(_pt7.read(5).toString(), 'el'); })); } + { - // Verify asymmetric transform (compress) + // Verify assymetric trasform (compress) var _pt8 = new Transform(); // each output is the first char of 3 consecutive chunks, // or whatever's left. _pt8.state = ''; + _pt8._transform = function (chunk, encoding, cb) { var _this = this; + if (!chunk) chunk = ''; var s = chunk.toString(); setTimeout(function () { @@ -213,12 +230,14 @@ cb(); }, 10); }; + _pt8._flush = function (cb) { // just output whatever we have. _pt8.push(bufferShim.from(this.state)); this.state = ''; cb(); }; + _pt8.write(bufferShim.from('aaaa')); _pt8.write(bufferShim.from('bbbb')); _pt8.write(bufferShim.from('cccc')); @@ -246,12 +265,10 @@ // this tests for a stall when data is written to a full stream // that has empty transforms. { - // Verify complex transform behavior + // Verify compex transform behavior var count = 0; var saved = null; - var _pt9 = new Transform({ - highWaterMark: 3 - }); + var _pt9 = new Transform({ highWaterMark: 3 }); _pt9._transform = function (c, e, cb) { if (count++ === 1) saved = c;else { if (saved) { @@ -260,8 +277,10 @@ } _pt9.push(c); } + cb(); }; + _pt9.once('readable', function () { process.nextTick(function () { _pt9.write(bufferShim.from('d')); @@ -272,8 +291,10 @@ assert.strictEqual(_pt9.read(), null); }); }); + _pt9.write(bufferShim.from('abc')); } + { // Verify passthrough event emission var _pt10 = new PassThrough(); @@ -281,24 +302,31 @@ _pt10.on('readable', function () { emits++; }); + _pt10.write(bufferShim.from('foog')); _pt10.write(bufferShim.from('bark')); - assert.strictEqual(emits, 0); + + assert.strictEqual(emits, 1); assert.strictEqual(_pt10.read(5).toString(), 'foogb'); assert.strictEqual(String(_pt10.read(5)), 'null'); - assert.strictEqual(emits, 0); + _pt10.write(bufferShim.from('bazy')); _pt10.write(bufferShim.from('kuel')); - assert.strictEqual(emits, 0); + + assert.strictEqual(emits, 2); assert.strictEqual(_pt10.read(5).toString(), 'arkba'); assert.strictEqual(_pt10.read(5).toString(), 'zykue'); assert.strictEqual(_pt10.read(5), null); + _pt10.end(); - assert.strictEqual(emits, 1); + + assert.strictEqual(emits, 3); assert.strictEqual(_pt10.read(5).toString(), 'l'); assert.strictEqual(_pt10.read(5), null); - assert.strictEqual(emits, 1); + + assert.strictEqual(emits, 3); } + { // Verify passthrough event emission reordering var _pt11 = new PassThrough(); @@ -306,28 +334,34 @@ _pt11.on('readable', function () { _emits++; }); + _pt11.write(bufferShim.from('foog')); _pt11.write(bufferShim.from('bark')); - assert.strictEqual(_emits, 0); + + assert.strictEqual(_emits, 1); assert.strictEqual(_pt11.read(5).toString(), 'foogb'); assert.strictEqual(_pt11.read(5), null); + _pt11.once('readable', common.mustCall(function () { assert.strictEqual(_pt11.read(5).toString(), 'arkba'); assert.strictEqual(_pt11.read(5), null); + _pt11.once('readable', common.mustCall(function () { assert.strictEqual(_pt11.read(5).toString(), 'zykue'); assert.strictEqual(_pt11.read(5), null); _pt11.once('readable', common.mustCall(function () { assert.strictEqual(_pt11.read(5).toString(), 'l'); assert.strictEqual(_pt11.read(5), null); - assert.strictEqual(_emits, 3); + assert.strictEqual(_emits, 4); })); _pt11.end(); })); _pt11.write(bufferShim.from('kuel')); })); + _pt11.write(bufferShim.from('bazy')); } + { // Verify passthrough facade var _pt12 = new PassThrough(); @@ -335,9 +369,11 @@ _pt12.on('data', function (chunk) { datas.push(chunk.toString()); }); + _pt12.on('end', common.mustCall(function () { assert.deepStrictEqual(datas, 'foog', 'bark', 'bazy', 'kuel'); })); + _pt12.write(bufferShim.from('foog')); setTimeout(function () { _pt12.write(bufferShim.from('bark')); @@ -352,11 +388,10 @@ }, 10); }, 10); } + { // Verify object transform (JSON parse) - var jp = new Transform({ - objectMode: true - }); + var jp = new Transform({ objectMode: true }); jp._transform = function (data, encoding, cb) { try { jp.push(JSON.parse(data)); @@ -368,36 +403,31 @@ // anything except null/undefined is fine. // those are "magic" in the stream API, because they signal EOF. - var objects = { - foo: 'bar' - }, 100, 'string', { - nested: { - things: { - foo: 'bar' - }, 100, 'string' - } - }; + var objects = { foo: 'bar' }, 100, 'string', { nested: { things: { foo: 'bar' }, 100, 'string' } }; + var ended = false; jp.on('end', function () { ended = true; }); + forEach(objects, function (obj) { jp.write(JSON.stringify(obj)); var res = jp.read(); assert.deepStrictEqual(res, obj); }); + jp.end(); // read one more time to get the 'end' event jp.read(); + process.nextTick(common.mustCall(function () { assert.strictEqual(ended, true); })); } + { // Verify object transform (JSON stringify) - var js = new Transform({ - objectMode: true - }); + var js = new Transform({ objectMode: true }); js._transform = function (data, encoding, cb) { try { js.push(JSON.stringify(data)); @@ -409,44 +439,30 @@ // anything except null/undefined is fine. // those are "magic" in the stream API, because they signal EOF. - var _objects = { - foo: 'bar' - }, 100, 'string', { - nested: { - things: { - foo: 'bar' - }, 100, 'string' - } - }; + var _objects = { foo: 'bar' }, 100, 'string', { nested: { things: { foo: 'bar' }, 100, 'string' } }; + var _ended = false; js.on('end', function () { _ended = true; }); + forEach(_objects, function (obj) { js.write(obj); var res = js.read(); assert.strictEqual(res, JSON.stringify(obj)); }); + js.end(); // read one more time to get the 'end' event js.read(); + process.nextTick(common.mustCall(function () { assert.strictEqual(_ended, true); })); } + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i); } -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-unpipe-drain.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-unpipe-drain.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + (function () { // Copyright Joyent, Inc. and other Node contributors. // @@ -39,68 +31,69 @@ /*</replacement>*/ require('../common'); var assert = require('assert/'); + var stream = require('../../'); - var TestWriter = /*#__PURE__*/function (_stream$Writable) { + + var TestWriter = function (_stream$Writable) { _inherits(TestWriter, _stream$Writable); - var _super = _createSuper(TestWriter); + function TestWriter() { _classCallCheck(this, TestWriter); - return _super.apply(this, arguments); + + return _possibleConstructorReturn(this, _stream$Writable.apply(this, arguments)); } - _createClass(TestWriter, { - key: "_write", - value: function _write(buffer, encoding, callback) { - console.log('write called'); - // super slow write stream (callback never called) - } - }); + + TestWriter.prototype._write = function _write(buffer, encoding, callback) { + console.log('write called'); + // super slow write stream (callback never called) + }; + return TestWriter; }(stream.Writable); + var dest = new TestWriter(); - var TestReader = /*#__PURE__*/function (_stream$Readable) { + + var TestReader = function (_stream$Readable) { _inherits(TestReader, _stream$Readable); - var _super2 = _createSuper(TestReader); + function TestReader() { - var _this; _classCallCheck(this, TestReader); - _this = _super2.call(this); - _this.reads = 0; - return _this; + + var _this2 = _possibleConstructorReturn(this, _stream$Readable.call(this)); + + _this2.reads = 0; + return _this2; } - _createClass(TestReader, { - key: "_read", - value: function _read(size) { - this.reads += 1; - this.push(bufferShim.alloc(size)); - } - }); + + TestReader.prototype._read = function _read(size) { + this.reads += 1; + this.push(bufferShim.alloc(size)); + }; + return TestReader; }(stream.Readable); + var src1 = new TestReader(); var src2 = new TestReader(); + src1.pipe(dest); + src1.once('readable', function () { process.nextTick(function () { + src2.pipe(dest); + src2.once('readable', function () { process.nextTick(function () { + src1.unpipe(dest); }); }); }); }); + process.on('exit', function () { assert.strictEqual(src1.reads, 2); assert.strictEqual(src2.reads, 2); }); -})(); -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +})(); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-unpipe-leak.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-unpipe-leak.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -39,70 +31,68 @@ require('../common'); var assert = require('assert/'); var stream = require('../../'); + var chunk = bufferShim.from('hallo'); -var TestWriter = /*#__PURE__*/function (_stream$Writable) { + +var TestWriter = function (_stream$Writable) { _inherits(TestWriter, _stream$Writable); - var _super = _createSuper(TestWriter); + function TestWriter() { _classCallCheck(this, TestWriter); - return _super.apply(this, arguments); + + return _possibleConstructorReturn(this, _stream$Writable.apply(this, arguments)); } - _createClass(TestWriter, { - key: "_write", - value: function _write(buffer, encoding, callback) { - callback(null); - } - }); + + TestWriter.prototype._write = function _write(buffer, encoding, callback) { + callback(null); + }; + return TestWriter; }(stream.Writable); + var dest = new TestWriter(); // Set this high so that we'd trigger a nextTick warning // and/or RangeError if we do maybeReadMore wrong. -var TestReader = /*#__PURE__*/function (_stream$Readable) { + +var TestReader = function (_stream$Readable) { _inherits(TestReader, _stream$Readable); - var _super2 = _createSuper(TestReader); + function TestReader() { _classCallCheck(this, TestReader); - return _super2.call(this, { + + return _possibleConstructorReturn(this, _stream$Readable.call(this, { highWaterMark: 0x10000 - }); + })); } - _createClass(TestReader, { - key: "_read", - value: function _read(size) { - this.push(chunk); - } - }); + + TestReader.prototype._read = function _read(size) { + this.push(chunk); + }; + return TestReader; }(stream.Readable); + var src = new TestReader(); + for (var i = 0; i < 10; i++) { src.pipe(dest); src.unpipe(dest); } + assert.strictEqual(src.listeners('end').length, 0); assert.strictEqual(src.listeners('readable').length, 0); + assert.strictEqual(dest.listeners('unpipe').length, 0); assert.strictEqual(dest.listeners('drain').length, 0); assert.strictEqual(dest.listeners('error').length, 0); assert.strictEqual(dest.listeners('close').length, 0); assert.strictEqual(dest.listeners('finish').length, 0); + console.error(src._readableState); process.on('exit', function () { - src.readableBuffer.length = 0; + src._readableState.buffer.length = 0; console.error(src._readableState); - assert(src.readableLength >= src.readableHighWaterMark); - require('tap').pass(); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); + assert(src._readableState.length >= src.readableHighWaterMark); + console.log('ok'); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream2-writable.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream2-writable.js
Changed
@@ -1,17 +1,9 @@ -"use strict"; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -41,131 +33,151 @@ var W = require('../../lib/_stream_writable'); var D = require('../../lib/_stream_duplex'); var assert = require('assert/'); -var TestWriter = /*#__PURE__*/function (_W) { + +var TestWriter = function (_W) { _inherits(TestWriter, _W); - var _super = _createSuper(TestWriter); + function TestWriter(opts) { - var _this; _classCallCheck(this, TestWriter); - _this = _super.call(this, opts); + + var _this = _possibleConstructorReturn(this, _W.call(this, opts)); + _this.buffer = ; _this.written = 0; return _this; } - _createClass(TestWriter, { - key: "_write", - value: function _write(chunk, encoding, cb) { - var _this2 = this; - // simulate a small unpredictable latency - setTimeout(function () { - _this2.buffer.push(chunk.toString()); - _this2.written += chunk.length; - cb(); - }, Math.floor(Math.random() * 10)); - } - }); + + TestWriter.prototype._write = function _write(chunk, encoding, cb) { + var _this2 = this; + + // simulate a small unpredictable latency + setTimeout(function () { + _this2.buffer.push(chunk.toString()); + _this2.written += chunk.length; + cb(); + }, Math.floor(Math.random() * 10)); + }; + return TestWriter; }(W); + var chunks = new Array(50); for (var i = 0; i < chunks.length; i++) { chunksi = 'x'.repeat(i); } + { // Verify fast writing var tw = new TestWriter({ highWaterMark: 100 }); + tw.on('finish', common.mustCall(function () { - // got chunks in the right order - assert.deepStrictEqual(tw.buffer, chunks); + assert.deepStrictEqual(tw.buffer, chunks, 'got chunks in the right order'); })); + forEach(chunks, function (chunk) { // Ignore backpressure. Just buffer it all up. tw.write(chunk); }); tw.end(); } + { // Verify slow writing var _tw = new TestWriter({ highWaterMark: 100 }); + _tw.on('finish', common.mustCall(function () { - // got chunks in the right order - assert.deepStrictEqual(_tw.buffer, chunks); + assert.deepStrictEqual(_tw.buffer, chunks, 'got chunks in the right order'); })); + var _i = 0; (function W() { _tw.write(chunks_i++); if (_i < chunks.length) setTimeout(W, 10);else _tw.end(); })(); } + { // Verify write backpressure var _tw2 = new TestWriter({ highWaterMark: 50 }); + var drains = 0; + _tw2.on('finish', common.mustCall(function () { - // got chunks in the right order - assert.deepStrictEqual(_tw2.buffer, chunks); + assert.deepStrictEqual(_tw2.buffer, chunks, 'got chunks in the right order'); assert.strictEqual(drains, 17); })); + _tw2.on('drain', function () { drains++; }); + var _i2 = 0; (function W() { - var ret; + var ret = void 0; do { ret = _tw2.write(chunks_i2++); } while (ret !== false && _i2 < chunks.length); + if (_i2 < chunks.length) { - assert(_tw2.writableLength >= 50); + assert(_tw2._writableState.length >= 50); _tw2.once('drain', W); } else { _tw2.end(); } })(); } + { // Verify write buffersize var _tw3 = new TestWriter({ highWaterMark: 100 }); + var encodings = 'hex', 'utf8', 'utf-8', 'ascii', 'binary', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined; + _tw3.on('finish', function () { - // got the expected chunks - assert.deepStrictEqual(_tw3.buffer, chunks); + assert.deepStrictEqual(_tw3.buffer, chunks, 'got the expected chunks'); }); + forEach(chunks, function (chunk, i) { var enc = encodingsi % encodings.length; chunk = bufferShim.from(chunk); _tw3.write(chunk.toString(enc), enc); }); } + { // Verify write with no buffersize var _tw4 = new TestWriter({ highWaterMark: 100, decodeStrings: false }); + _tw4._write = function (chunk, encoding, cb) { assert.strictEqual(typeof chunk, 'string'); chunk = bufferShim.from(chunk, encoding); return TestWriter.prototype._write.call(this, chunk, encoding, cb); }; + var _encodings = 'hex', 'utf8', 'utf-8', 'ascii', 'binary', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined; + _tw4.on('finish', function () { - // got the expected chunks - assert.deepStrictEqual(_tw4.buffer, chunks); + assert.deepStrictEqual(_tw4.buffer, chunks, 'got the expected chunks'); }); + forEach(chunks, function (chunk, i) { var enc = _encodingsi % _encodings.length; chunk = bufferShim.from(chunk); _tw4.write(chunk.toString(enc), enc); }); } + { // Verify write callbacks var callbacks = chunks.map(function (chunk, i) { @@ -173,47 +185,53 @@ callbacks._calledi = chunk; }; }).reduce(function (set, x) { - set"callback-".concat(x0) = x1; + set'callback-' + x0 = x1; return set; }, {}); callbacks._called = ; + var _tw5 = new TestWriter({ highWaterMark: 100 }); + _tw5.on('finish', common.mustCall(function () { process.nextTick(common.mustCall(function () { - // got chunks in the right order - assert.deepStrictEqual(_tw5.buffer, chunks); - // called all callbacks - assert.deepStrictEqual(callbacks._called, chunks); + assert.deepStrictEqual(_tw5.buffer, chunks, 'got chunks in the right order'); + assert.deepStrictEqual(callbacks._called, chunks, 'called all callbacks'); })); })); + forEach(chunks, function (chunk, i) { - _tw5.write(chunk, callbacks"callback-".concat(i)); + _tw5.write(chunk, callbacks'callback-' + i); }); _tw5.end(); } + { // Verify end() callback var _tw6 = new TestWriter(); _tw6.end(common.mustCall()); } + { // Verify end() callback with chunk var _tw7 = new TestWriter(); _tw7.end(bufferShim.from('hello world'), common.mustCall()); } + { // Verify end() callback with chunk and encoding var _tw8 = new TestWriter(); _tw8.end('hello world', 'ascii', common.mustCall()); } + { // Verify end() callback after write() call var _tw9 = new TestWriter(); _tw9.write(bufferShim.from('hello world')); _tw9.end(common.mustCall()); } + { // Verify end() callback after write() callback var _tw10 = new TestWriter(); @@ -225,6 +243,7 @@ assert.strictEqual(writeCalledback, true); })); } + { // Verify encoding is ignored for buffers var _tw11 = new W(); @@ -235,6 +254,7 @@ var buf = bufferShim.from(hex, 'hex'); _tw11.write(buf, 'latin1'); } + { // Verify writables cannot be piped var w = new W(); @@ -246,6 +266,7 @@ w.pipe(process.stdout); assert.strictEqual(gotError, true); } + { // Verify that duplex streams cannot be piped var d = new D(); @@ -258,6 +279,7 @@ d.pipe(process.stdout); assert.strictEqual(_gotError, false); } + { // Verify that end(chunk) twice is an error var _w = new W(); @@ -275,6 +297,7 @@ assert.strictEqual(_gotError2, true); })); } + { // Verify stream doesn't end while writing var _w2 = new W(); @@ -294,6 +317,7 @@ _w2.write(bufferShim.alloc(0)); _w2.end(); } + { // Verify finish does not come before write() callback var _w3 = new W(); @@ -310,6 +334,7 @@ _w3.write(bufferShim.alloc(0)); _w3.end(); } + { // Verify finish does not come before synchronous _write() callback var _w4 = new W(); @@ -325,6 +350,7 @@ }); _w4.end(); } + { // Verify finish is emitted if the last chunk is empty var _w5 = new W(); @@ -335,10 +361,12 @@ _w5.write(bufferShim.allocUnsafe(1)); _w5.end(bufferShim.alloc(0)); } + { // Verify that finish is emitted after shutdown var _w6 = new W(); var shutdown = false; + _w6._final = common.mustCall(function (cb) { assert.strictEqual(this, _w6); setTimeout(function () { @@ -355,19 +383,9 @@ _w6.write(bufferShim.allocUnsafe(1)); _w6.end(bufferShim.allocUnsafe(0)); } + function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xsi, i); } -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream3-cork-end.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream3-cork-end.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -8,7 +6,7 @@ var stream = require('../../'); var Writable = stream.Writable; -// Test the buffering behavior of Writable streams. +// Test the buffering behaviour of Writable streams. // // The call to cork() triggers storing chunks which are flushed // on calling end() and the stream subsequently ended. @@ -19,6 +17,7 @@ var inputChunks = expectedChunks.slice(0); var seenChunks = ; var seenEnd = false; + var w = new Writable(); // lets arrange to store the chunks w._write = function (chunk, encoding, cb) { @@ -26,6 +25,7 @@ assert.ok(!seenEnd); // default encoding given none was specified assert.strictEqual(encoding, 'buffer'); + seenChunks.push(chunk); cb(); }; @@ -33,14 +33,17 @@ w.on('finish', function () { seenEnd = true; }); + function writeChunks(remainingChunks, callback) { var writeChunk = remainingChunks.shift(); - var writeState; + var writeState = void 0; + if (writeChunk) { setImmediate(function () { writeState = w.write(writeChunk); // we were not told to stop writing assert.ok(writeState); + writeChunks(remainingChunks, callback); }); } else { @@ -77,23 +80,14 @@ var seen = seenChunksi; // there was a chunk assert.ok(seen); + var expected = bufferShim.from(expectedChunksi); // it was what we expected assert.deepEqual(seen, expected); } + setImmediate(function () { // stream should have ended in next tick assert.ok(seenEnd); }); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream3-cork-uncork.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream3-cork-uncork.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ @@ -8,7 +6,7 @@ var stream = require('../../'); var Writable = stream.Writable; -// Test the buffering behavior of Writable streams. +// Test the buffering behaviour of Writable streams. // // The call to cork() triggers storing chunks which are flushed // on calling uncork() in the same tick. @@ -19,11 +17,13 @@ var inputChunks = expectedChunks.slice(0); var seenChunks = ; var seenEnd = false; + var w = new Writable(); // lets arrange to store the chunks w._write = function (chunk, encoding, cb) { // default encoding given none was specified assert.strictEqual(encoding, 'buffer'); + seenChunks.push(chunk); cb(); }; @@ -31,14 +31,17 @@ w.on('finish', function () { seenEnd = true; }); + function writeChunks(remainingChunks, callback) { var writeChunk = remainingChunks.shift(); - var writeState; + var writeState = void 0; + if (writeChunk) { setImmediate(function () { writeState = w.write(writeChunk); // we were not told to stop writing assert.ok(writeState); + writeChunks(remainingChunks, callback); }); } else { @@ -64,7 +67,7 @@ // trigger writing out the buffer w.uncork(); - // buffered bytes should be seen in current tick + // buffered bytes shoud be seen in current tick assert.strictEqual(seenChunks.length, 4); // did the chunks match @@ -72,23 +75,14 @@ var seen = seenChunksi; // there was a chunk assert.ok(seen); + var expected = bufferShim.from(expectedChunksi); // it was what we expected assert.deepEqual(seen, expected); } + setImmediate(function () { // the stream should not have been ended assert.ok(!seenEnd); }); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); }); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream3-pause-then-read.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-stream3-pause-then-read.js
Changed
@@ -1,5 +1,3 @@ -"use strict"; - // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -26,45 +24,46 @@ /*</replacement>*/ require('../common'); var assert = require('assert/'); + var stream = require('../../'); var Readable = stream.Readable; var Writable = stream.Writable; + var totalChunks = 100; var chunkSize = 99; var expectTotalData = totalChunks * chunkSize; var expectEndingData = expectTotalData; -var r = new Readable({ - highWaterMark: 1000 -}); + +var r = new Readable({ highWaterMark: 1000 }); var chunks = totalChunks; r._read = function (n) { - console.log('_read called', chunks); if (!(chunks % 2)) setImmediate(push);else if (!(chunks % 3)) process.nextTick(push);else push(); }; + var totalPushed = 0; function push() { var chunk = chunks-- > 0 ? bufferShim.alloc(chunkSize, 'x') : null; if (chunk) { totalPushed += chunk.length; } - console.log('chunks', chunks); r.push(chunk); } + read100(); // first we read 100 bytes function read100() { readn(100, onData); } + function readn(n, then) { - console.error("read ".concat(n)); + console.error('read ' + n); expectEndingData -= n; (function read() { var c = r.read(n); - console.error('c', c); if (!c) r.once('readable', read);else { assert.strictEqual(c.length, n); - assert(!r.readableFlowing); + assert(!r._readableState.flowing); then(); } })(); @@ -127,6 +126,7 @@ function read1234() { readn(1234, resumePause); } + function resumePause() { console.error('resumePause'); // don't read anything, just resume and re-pause a whole bunch @@ -142,6 +142,7 @@ r.pause(); setImmediate(pipe); } + function pipe() { console.error('pipe the rest'); var w = new Writable(); @@ -154,18 +155,7 @@ console.error('written', written, totalPushed); assert.strictEqual(written, expectEndingData); assert.strictEqual(totalPushed, expectTotalData); - require('tap').pass(); + console.log('ok'); }); r.pipe(w); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-streams-highwatermark.js -> _service:tar_scm:readable-stream-2.3.6.tar.gz/test/parallel/test-streams-highwatermark.js
Changed
@@ -1,81 +1,20 @@ -"use strict"; - /*<replacement>*/ var bufferShim = require('safe-buffer').Buffer; /*</replacement>*/ -var common = require('../common'); +require('../common'); + +// This test ensures that the stream implementation correctly handles values +// for highWaterMark which exceed the range of signed 32 bit integers. + var assert = require('assert/'); var stream = require('../../'); -{ - // This test ensures that the stream implementation correctly handles values - // for highWaterMark which exceed the range of signed 32 bit integers and - // rejects invalid values. - // This number exceeds the range of 32 bit integer arithmetic but should still - // be handled correctly. - var ovfl = Number.MAX_SAFE_INTEGER; - var readable = stream.Readable({ - highWaterMark: ovfl - }); - assert.strictEqual(readable._readableState.highWaterMark, ovfl); - var writable = stream.Writable({ - highWaterMark: ovfl - }); - assert.strictEqual(writable._writableState.highWaterMark, ovfl); - var _loop = function _loop() { - var invalidHwm = _arr_i; - var _loop2 = function _loop2() { - var type = _arr2_i2; - common.expectsError(function () { - type({ - highWaterMark: invalidHwm - }); - }, { - type: TypeError, - code: 'ERR_INVALID_OPT_VALUE', - message: "The value \"".concat(invalidHwm, "\" is invalid for option \"highWaterMark\"") - }); - }; - for (var _i2 = 0, _arr2 = stream.Readable, stream.Writable; _i2 < _arr2.length; _i2++) { - _loop2(); - } - }; - for (var _i = 0, _arr = true, false, '5', {}, -5, NaN; _i < _arr.length; _i++) { - _loop(); - } -} -{ - // This test ensures that the push method's implementation - // correctly handles the edge case where the highWaterMark and - // the state.length are both zero +// This number exceeds the range of 32 bit integer arithmetic but should still +// be handled correctly. +var ovfl = Number.MAX_SAFE_INTEGER; - var _readable = stream.Readable({ - highWaterMark: 0 - }); - for (var i = 0; i < 3; i++) { - var needMoreData = _readable.push(); - assert.strictEqual(needMoreData, true); - } -} -{ - // This test ensures that the read(n) method's implementation - // correctly handles the edge case where the highWaterMark, state.length - // and n are all zero +var readable = stream.Readable({ highWaterMark: ovfl }); +assert.strictEqual(readable._readableState.highWaterMark, ovfl); - var _readable2 = stream.Readable({ - highWaterMark: 0 - }); - _readable2._read = common.mustCall(); - _readable2.read(0); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file +var writable = stream.Writable({ highWaterMark: ovfl }); +assert.strictEqual(writable._writableState.highWaterMark, ovfl); \ No newline at end of file
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/test/verify-dependencies.js
Added
@@ -0,0 +1,13 @@ +'use strict' + +var pack = require('../package.json'); +var assert = require('assert'); + +function verifyNoCaret(deps) { + var keys = Object.keys(deps); + for (var i = 0; i < keys.length; i++) { + assert(depskeysi0 !== '^', keysi + ' must not be depended on using ^') + } +} + +verifyNoCaret(pack.dependencies)
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/transform.js
Added
@@ -0,0 +1,1 @@ +module.exports = require('./readable').Transform
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/writable-browser.js
Added
@@ -0,0 +1,1 @@ +module.exports = require('./lib/_stream_writable.js');
View file
_service:tar_scm:readable-stream-2.3.6.tar.gz/writable.js
Added
@@ -0,0 +1,8 @@ +var Stream = require("stream") +var Writable = require("./lib/_stream_writable.js") + +if (process.env.READABLE_STREAM === 'disable') { + module.exports = Stream && Stream.Writable || Writable +} else { + module.exports = Writable +}
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/.airtap.yml
Deleted
@@ -1,17 +0,0 @@ -sauce_connect: true -browsers: - - name: chrome - version: latest - platform: Windows 10 - - name: internet explorer - version: latest - platform: Windows 10 - - name: firefox - version: latest - platform: Windows 10 - - name: safari - version: latest - platform: Mac 10.13 - - name: microsoftedge - version: latest - platform: Windows 10
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/.babelrc
Deleted
@@ -1,15 +0,0 @@ -{ - "presets": - "@babel/preset-env", { - "targets": - "node 0.10" - , - "modules": "commonjs", - "exclude": - "transform-regenerator", - "transform-typeof-symbol" - , - "debug": true - } - -}
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/errors-browser.js
Deleted
@@ -1,127 +0,0 @@ -'use strict'; - -function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } - -var codes = {}; - -function createErrorType(code, message, Base) { - if (!Base) { - Base = Error; - } - - function getMessage(arg1, arg2, arg3) { - if (typeof message === 'string') { - return message; - } else { - return message(arg1, arg2, arg3); - } - } - - var NodeError = - /*#__PURE__*/ - function (_Base) { - _inheritsLoose(NodeError, _Base); - - function NodeError(arg1, arg2, arg3) { - return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; - } - - return NodeError; - }(Base); - - NodeError.prototype.name = Base.name; - NodeError.prototype.code = code; - codescode = NodeError; -} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js - - -function oneOf(expected, thing) { - if (Array.isArray(expected)) { - var len = expected.length; - expected = expected.map(function (i) { - return String(i); - }); - - if (len > 2) { - return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expectedlen - 1; - } else if (len === 2) { - return "one of ".concat(thing, " ").concat(expected0, " or ").concat(expected1); - } else { - return "of ".concat(thing, " ").concat(expected0); - } - } else { - return "of ".concat(thing, " ").concat(String(expected)); - } -} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith - - -function startsWith(str, search, pos) { - return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; -} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith - - -function endsWith(str, search, this_len) { - if (this_len === undefined || this_len > str.length) { - this_len = str.length; - } - - return str.substring(this_len - search.length, this_len) === search; -} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes - - -function includes(str, search, start) { - if (typeof start !== 'number') { - start = 0; - } - - if (start + search.length > str.length) { - return false; - } else { - return str.indexOf(search, start) !== -1; - } -} - -createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { - return 'The value "' + value + '" is invalid for option "' + name + '"'; -}, TypeError); -createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { - // determiner: 'must be' or 'must not be' - var determiner; - - if (typeof expected === 'string' && startsWith(expected, 'not ')) { - determiner = 'must not be'; - expected = expected.replace(/^not /, ''); - } else { - determiner = 'must be'; - } - - var msg; - - if (endsWith(name, ' argument')) { - // For cases like 'first argument' - msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); - } else { - var type = includes(name, '.') ? 'property' : 'argument'; - msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); - } - - msg += ". Received type ".concat(typeof actual); - return msg; -}, TypeError); -createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); -createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { - return 'The ' + name + ' method is not implemented'; -}); -createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); -createErrorType('ERR_STREAM_DESTROYED', function (name) { - return 'Cannot call ' + name + ' after a stream was destroyed'; -}); -createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); -createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); -createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); -createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); -createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { - return 'Unknown encoding: ' + arg; -}, TypeError); -createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); -module.exports.codes = codes;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/errors.js
Deleted
@@ -1,116 +0,0 @@ -'use strict'; - -const codes = {}; - -function createErrorType(code, message, Base) { - if (!Base) { - Base = Error - } - - function getMessage (arg1, arg2, arg3) { - if (typeof message === 'string') { - return message - } else { - return message(arg1, arg2, arg3) - } - } - - class NodeError extends Base { - constructor (arg1, arg2, arg3) { - super(getMessage(arg1, arg2, arg3)); - } - } - - NodeError.prototype.name = Base.name; - NodeError.prototype.code = code; - - codescode = NodeError; -} - -// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js -function oneOf(expected, thing) { - if (Array.isArray(expected)) { - const len = expected.length; - expected = expected.map((i) => String(i)); - if (len > 2) { - return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` + - expectedlen - 1; - } else if (len === 2) { - return `one of ${thing} ${expected0} or ${expected1}`; - } else { - return `of ${thing} ${expected0}`; - } - } else { - return `of ${thing} ${String(expected)}`; - } -} - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith -function startsWith(str, search, pos) { - return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; -} - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith -function endsWith(str, search, this_len) { - if (this_len === undefined || this_len > str.length) { - this_len = str.length; - } - return str.substring(this_len - search.length, this_len) === search; -} - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes -function includes(str, search, start) { - if (typeof start !== 'number') { - start = 0; - } - - if (start + search.length > str.length) { - return false; - } else { - return str.indexOf(search, start) !== -1; - } -} - -createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { - return 'The value "' + value + '" is invalid for option "' + name + '"' -}, TypeError); -createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { - // determiner: 'must be' or 'must not be' - let determiner; - if (typeof expected === 'string' && startsWith(expected, 'not ')) { - determiner = 'must not be'; - expected = expected.replace(/^not /, ''); - } else { - determiner = 'must be'; - } - - let msg; - if (endsWith(name, ' argument')) { - // For cases like 'first argument' - msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`; - } else { - const type = includes(name, '.') ? 'property' : 'argument'; - msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`; - } - - msg += `. Received type ${typeof actual}`; - return msg; -}, TypeError); -createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); -createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { - return 'The ' + name + ' method is not implemented' -}); -createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); -createErrorType('ERR_STREAM_DESTROYED', function (name) { - return 'Cannot call ' + name + ' after a stream was destroyed'; -}); -createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); -createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); -createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); -createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); -createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { - return 'Unknown encoding: ' + arg -}, TypeError); -createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); - -module.exports.codes = codes;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/experimentalWarning.js
Deleted
@@ -1,17 +0,0 @@ -'use strict' - -var experimentalWarnings = new Set(); - -function emitExperimentalWarning(feature) { - if (experimentalWarnings.has(feature)) return; - var msg = feature + ' is an experimental feature. This feature could ' + - 'change at any time'; - experimentalWarnings.add(feature); - process.emitWarning(msg, 'ExperimentalWarning'); -} - -function noop() {} - -module.exports.emitExperimentalWarning = process.emitWarning - ? emitExperimentalWarning - : noop;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/internal/streams/async_iterator.js
Deleted
@@ -1,180 +0,0 @@ -'use strict'; - -var _Object$setPrototypeO; -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { objkey = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -var finished = require('./end-of-stream'); -var kLastResolve = Symbol('lastResolve'); -var kLastReject = Symbol('lastReject'); -var kError = Symbol('error'); -var kEnded = Symbol('ended'); -var kLastPromise = Symbol('lastPromise'); -var kHandlePromise = Symbol('handlePromise'); -var kStream = Symbol('stream'); -function createIterResult(value, done) { - return { - value: value, - done: done - }; -} -function readAndResolve(iter) { - var resolve = iterkLastResolve; - if (resolve !== null) { - var data = iterkStream.read(); - // we defer if data is null - // we can be expecting either 'end' or - // 'error' - if (data !== null) { - iterkLastPromise = null; - iterkLastResolve = null; - iterkLastReject = null; - resolve(createIterResult(data, false)); - } - } -} -function onReadable(iter) { - // we wait for the next tick, because it might - // emit an error with process.nextTick - process.nextTick(readAndResolve, iter); -} -function wrapForNext(lastPromise, iter) { - return function (resolve, reject) { - lastPromise.then(function () { - if (iterkEnded) { - resolve(createIterResult(undefined, true)); - return; - } - iterkHandlePromise(resolve, reject); - }, reject); - }; -} -var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); -var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { - get stream() { - return thiskStream; - }, - next: function next() { - var _this = this; - // if we have detected an error in the meanwhile - // reject straight away - var error = thiskError; - if (error !== null) { - return Promise.reject(error); - } - if (thiskEnded) { - return Promise.resolve(createIterResult(undefined, true)); - } - if (thiskStream.destroyed) { - // We need to defer via nextTick because if .destroy(err) is - // called, the error will be emitted via nextTick, and - // we cannot guarantee that there is no error lingering around - // waiting to be emitted. - return new Promise(function (resolve, reject) { - process.nextTick(function () { - if (_thiskError) { - reject(_thiskError); - } else { - resolve(createIterResult(undefined, true)); - } - }); - }); - } - - // if we have multiple next() calls - // we will wait for the previous Promise to finish - // this logic is optimized to support for await loops, - // where next() is only called once at a time - var lastPromise = thiskLastPromise; - var promise; - if (lastPromise) { - promise = new Promise(wrapForNext(lastPromise, this)); - } else { - // fast path needed to support multiple this.push() - // without triggering the next() queue - var data = thiskStream.read(); - if (data !== null) { - return Promise.resolve(createIterResult(data, false)); - } - promise = new Promise(thiskHandlePromise); - } - thiskLastPromise = promise; - return promise; - } -}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { - return this; -}), _defineProperty(_Object$setPrototypeO, "return", function _return() { - var _this2 = this; - // destroy(err, cb) is a private API - // we can guarantee we have that here, because we control the - // Readable class this is attached to - return new Promise(function (resolve, reject) { - _this2kStream.destroy(null, function (err) { - if (err) { - reject(err); - return; - } - resolve(createIterResult(undefined, true)); - }); - }); -}), _Object$setPrototypeO), AsyncIteratorPrototype); -var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { - var _Object$create; - var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { - value: stream, - writable: true - }), _defineProperty(_Object$create, kLastResolve, { - value: null, - writable: true - }), _defineProperty(_Object$create, kLastReject, { - value: null, - writable: true - }), _defineProperty(_Object$create, kError, { - value: null, - writable: true - }), _defineProperty(_Object$create, kEnded, { - value: stream._readableState.endEmitted, - writable: true - }), _defineProperty(_Object$create, kHandlePromise, { - value: function value(resolve, reject) { - var data = iteratorkStream.read(); - if (data) { - iteratorkLastPromise = null; - iteratorkLastResolve = null; - iteratorkLastReject = null; - resolve(createIterResult(data, false)); - } else { - iteratorkLastResolve = resolve; - iteratorkLastReject = reject; - } - }, - writable: true - }), _Object$create)); - iteratorkLastPromise = null; - finished(stream, function (err) { - if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { - var reject = iteratorkLastReject; - // reject if we are waiting for data in the Promise - // returned by next() and store the error - if (reject !== null) { - iteratorkLastPromise = null; - iteratorkLastResolve = null; - iteratorkLastReject = null; - reject(err); - } - iteratorkError = err; - return; - } - var resolve = iteratorkLastResolve; - if (resolve !== null) { - iteratorkLastPromise = null; - iteratorkLastResolve = null; - iteratorkLastReject = null; - resolve(createIterResult(undefined, true)); - } - iteratorkEnded = true; - }); - stream.on('readable', onReadable.bind(null, iterator)); - return iterator; -}; -module.exports = createReadableStreamAsyncIterator; \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/internal/streams/buffer_list.js
Deleted
@@ -1,183 +0,0 @@ -'use strict'; - -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != argumentsi ? argumentsi : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, sourcekey); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { objkey = value; } return obj; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -var _require = require('buffer'), - Buffer = _require.Buffer; -var _require2 = require('util'), - inspect = _require2.inspect; -var custom = inspect && inspect.custom || 'inspect'; -function copyBuffer(src, target, offset) { - Buffer.prototype.copy.call(src, target, offset); -} -module.exports = /*#__PURE__*/function () { - function BufferList() { - _classCallCheck(this, BufferList); - this.head = null; - this.tail = null; - this.length = 0; - } - _createClass(BufferList, { - key: "push", - value: function push(v) { - var entry = { - data: v, - next: null - }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; - } - }, { - key: "unshift", - value: function unshift(v) { - var entry = { - data: v, - next: this.head - }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; - } - }, { - key: "shift", - value: function shift() { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; - } - }, { - key: "clear", - value: function clear() { - this.head = this.tail = null; - this.length = 0; - } - }, { - key: "join", - value: function join(s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) ret += s + p.data; - return ret; - } - }, { - key: "concat", - value: function concat(n) { - if (this.length === 0) return Buffer.alloc(0); - var ret = Buffer.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; - } - return ret; - } - - // Consumes a specified amount of bytes or characters from the buffered data. - }, { - key: "consume", - value: function consume(n, hasStrings) { - var ret; - if (n < this.head.data.length) { - // `slice` is the same for buffers and strings. - ret = this.head.data.slice(0, n); - this.head.data = this.head.data.slice(n); - } else if (n === this.head.data.length) { - // First chunk is a perfect match. - ret = this.shift(); - } else { - // Result spans more than one buffer. - ret = hasStrings ? this._getString(n) : this._getBuffer(n); - } - return ret; - } - }, { - key: "first", - value: function first() { - return this.head.data; - } - - // Consumes a specified amount of characters from the buffered data. - }, { - key: "_getString", - value: function _getString(n) { - var p = this.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) this.head = p.next;else this.head = this.tail = null; - } else { - this.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - this.length -= c; - return ret; - } - - // Consumes a specified amount of bytes from the buffered data. - }, { - key: "_getBuffer", - value: function _getBuffer(n) { - var ret = Buffer.allocUnsafe(n); - var p = this.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) this.head = p.next;else this.head = this.tail = null; - } else { - this.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; - } - this.length -= c; - return ret; - } - - // Make sure the linked list only shows the minimal necessary information. - }, { - key: custom, - value: function value(_, options) { - return inspect(this, _objectSpread(_objectSpread({}, options), {}, { - // Only inspect one level. - depth: 0, - // It should not recurse. - customInspect: false - })); - } - }); - return BufferList; -}(); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/internal/streams/end-of-stream.js
Deleted
@@ -1,86 +0,0 @@ -// Ported from https://github.com/mafintosh/end-of-stream with -// permission from the author, Mathias Buus (@mafintosh). - -'use strict'; - -var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE; -function once(callback) { - var called = false; - return function () { - if (called) return; - called = true; - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args_key = arguments_key; - } - callback.apply(this, args); - }; -} -function noop() {} -function isRequest(stream) { - return stream.setHeader && typeof stream.abort === 'function'; -} -function eos(stream, opts, callback) { - if (typeof opts === 'function') return eos(stream, null, opts); - if (!opts) opts = {}; - callback = once(callback || noop); - var readable = opts.readable || opts.readable !== false && stream.readable; - var writable = opts.writable || opts.writable !== false && stream.writable; - var onlegacyfinish = function onlegacyfinish() { - if (!stream.writable) onfinish(); - }; - var writableEnded = stream._writableState && stream._writableState.finished; - var onfinish = function onfinish() { - writable = false; - writableEnded = true; - if (!readable) callback.call(stream); - }; - var readableEnded = stream._readableState && stream._readableState.endEmitted; - var onend = function onend() { - readable = false; - readableEnded = true; - if (!writable) callback.call(stream); - }; - var onerror = function onerror(err) { - callback.call(stream, err); - }; - var onclose = function onclose() { - var err; - if (readable && !readableEnded) { - if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); - return callback.call(stream, err); - } - if (writable && !writableEnded) { - if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); - return callback.call(stream, err); - } - }; - var onrequest = function onrequest() { - stream.req.on('finish', onfinish); - }; - if (isRequest(stream)) { - stream.on('complete', onfinish); - stream.on('abort', onclose); - if (stream.req) onrequest();else stream.on('request', onrequest); - } else if (writable && !stream._writableState) { - // legacy streams - stream.on('end', onlegacyfinish); - stream.on('close', onlegacyfinish); - } - stream.on('end', onend); - stream.on('finish', onfinish); - if (opts.error !== false) stream.on('error', onerror); - stream.on('close', onclose); - return function () { - stream.removeListener('complete', onfinish); - stream.removeListener('abort', onclose); - stream.removeListener('request', onrequest); - if (stream.req) stream.req.removeListener('finish', onfinish); - stream.removeListener('end', onlegacyfinish); - stream.removeListener('close', onlegacyfinish); - stream.removeListener('finish', onfinish); - stream.removeListener('end', onend); - stream.removeListener('error', onerror); - stream.removeListener('close', onclose); - }; -} -module.exports = eos; \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/internal/streams/from-browser.js
Deleted
@@ -1,3 +0,0 @@ -module.exports = function () { - throw new Error('Readable.from is not available in the browser') -};
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/internal/streams/from.js
Deleted
@@ -1,52 +0,0 @@ -'use strict'; - -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = genkey(arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != argumentsi ? argumentsi : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, sourcekey); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { objkey = value; } return obj; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -var ERR_INVALID_ARG_TYPE = require('../../../errors').codes.ERR_INVALID_ARG_TYPE; -function from(Readable, iterable, opts) { - var iterator; - if (iterable && typeof iterable.next === 'function') { - iterator = iterable; - } else if (iterable && iterableSymbol.asyncIterator) iterator = iterableSymbol.asyncIterator();else if (iterable && iterableSymbol.iterator) iterator = iterableSymbol.iterator();else throw new ERR_INVALID_ARG_TYPE('iterable', 'Iterable', iterable); - var readable = new Readable(_objectSpread({ - objectMode: true - }, opts)); - // Reading boolean to protect against _read - // being called before last iteration completion. - var reading = false; - readable._read = function () { - if (!reading) { - reading = true; - next(); - } - }; - function next() { - return _next2.apply(this, arguments); - } - function _next2() { - _next2 = _asyncToGenerator(function* () { - try { - var _yield$iterator$next = yield iterator.next(), - value = _yield$iterator$next.value, - done = _yield$iterator$next.done; - if (done) { - readable.push(null); - } else if (readable.push(yield value)) { - next(); - } else { - reading = false; - } - } catch (err) { - readable.destroy(err); - } - }); - return _next2.apply(this, arguments); - } - return readable; -} -module.exports = from;
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/internal/streams/pipeline.js
Deleted
@@ -1,86 +0,0 @@ -// Ported from https://github.com/mafintosh/pump with -// permission from the author, Mathias Buus (@mafintosh). - -'use strict'; - -var eos; -function once(callback) { - var called = false; - return function () { - if (called) return; - called = true; - callback.apply(void 0, arguments); - }; -} -var _require$codes = require('../../../errors').codes, - ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, - ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; -function noop(err) { - // Rethrow the error if it exists to avoid swallowing it - if (err) throw err; -} -function isRequest(stream) { - return stream.setHeader && typeof stream.abort === 'function'; -} -function destroyer(stream, reading, writing, callback) { - callback = once(callback); - var closed = false; - stream.on('close', function () { - closed = true; - }); - if (eos === undefined) eos = require('./end-of-stream'); - eos(stream, { - readable: reading, - writable: writing - }, function (err) { - if (err) return callback(err); - closed = true; - callback(); - }); - var destroyed = false; - return function (err) { - if (closed) return; - if (destroyed) return; - destroyed = true; - - // request.destroy just do .end - .abort is what we want - if (isRequest(stream)) return stream.abort(); - if (typeof stream.destroy === 'function') return stream.destroy(); - callback(err || new ERR_STREAM_DESTROYED('pipe')); - }; -} -function call(fn) { - fn(); -} -function pipe(from, to) { - return from.pipe(to); -} -function popCallback(streams) { - if (!streams.length) return noop; - if (typeof streamsstreams.length - 1 !== 'function') return noop; - return streams.pop(); -} -function pipeline() { - for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { - streams_key = arguments_key; - } - var callback = popCallback(streams); - if (Array.isArray(streams0)) streams = streams0; - if (streams.length < 2) { - throw new ERR_MISSING_ARGS('streams'); - } - var error; - var destroys = streams.map(function (stream, i) { - var reading = i < streams.length - 1; - var writing = i > 0; - return destroyer(stream, reading, writing, function (err) { - if (!error) error = err; - if (err) destroys.forEach(call); - if (reading) return; - destroys.forEach(call); - callback(error); - }); - }); - return streams.reduce(pipe); -} -module.exports = pipeline; \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/lib/internal/streams/state.js
Deleted
@@ -1,22 +0,0 @@ -'use strict'; - -var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE; -function highWaterMarkFrom(options, isDuplex, duplexKey) { - return options.highWaterMark != null ? options.highWaterMark : isDuplex ? optionsduplexKey : null; -} -function getHighWaterMark(state, options, duplexKey, isDuplex) { - var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); - if (hwm != null) { - if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { - var name = isDuplex ? duplexKey : 'highWaterMark'; - throw new ERR_INVALID_OPT_VALUE(name, hwm); - } - return Math.floor(hwm); - } - - // Default value - return state.objectMode ? 16 : 16 * 1024; -} -module.exports = { - getHighWaterMark: getHighWaterMark -}; \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-finished.js
Deleted
@@ -1,60 +0,0 @@ -"use strict"; - - -var common = require('../common'); - -var _require = require('../../'), - Writable = _require.Writable, - Readable = _require.Readable, - Transform = _require.Transform, - finished = _require.finished; - -module.exports = function (t) { - t.test('readable finished', function (t) { - - var rs = new Readable({ - read: function read() {} - }); - finished(rs, common.mustCall(function (err) { - t.ok(!err, 'no error'); - t.end(); - })); - rs.push(null); - rs.resume(); - }); - t.test('writable finished', function (t) { - var ws = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - finished(ws, common.mustCall(function (err) { - t.ok(!err, 'no error'); - t.end(); - })); - ws.end(); - }); - t.test('transform finished', function (t) { - var tr = new Transform({ - transform: function transform(data, enc, cb) { - cb(); - } - }); - var finish = false; - var ended = false; - tr.on('end', function () { - ended = true; - }); - tr.on('finish', function () { - finish = true; - }); - finished(tr, common.mustCall(function (err) { - t.ok(!err, 'no error'); - t.ok(finish); - t.ok(ended); - t.end(); - })); - tr.end(); - tr.resume(); - }); -};
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/browser/test-stream-pipeline.js
Deleted
@@ -1,112 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); - -var _require = require('../../'), - Writable = _require.Writable, - Readable = _require.Readable, - Transform = _require.Transform, - finished = _require.finished, - pipeline = _require.pipeline; - -module.exports = function (t) { - t.test('pipeline', function (t) { - var finished = false; - var processed = ; - var expected = bufferShim.from('a'), bufferShim.from('b'), - bufferShim.from('c'); - var read = new Readable({ - read: function read() { - } - }); - var write = new Writable({ - write: function write(data, enc, cb) { - processed.push(data); - cb(); - } - }); - write.on('finish', function () { - finished = true; - }); - - for (var i = 0; i < expected.length; i++) { - read.push(expectedi); - } - - read.push(null); - pipeline(read, write, common.mustCall(function (err) { - t.ok(!err, 'no error'); - t.ok(finished); - t.deepEqual(processed, expected); - t.end(); - })); - }); - t.test('pipeline missing args', function (t) { - var _read = new Readable({ - read: function read() { - } - }); - - t.throws(function () { - pipeline(_read, function () { - }); - }); - t.throws(function () { - pipeline(function () { - }); - }); - t.throws(function () { - pipeline(); - }); - t.end(); - }); - t.test('pipeline error', function (t) { - var _read2 = new Readable({ - read: function read() { - } - }); - - var _write = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - - _read2.push('data'); - - setImmediate(function () { - return _read2.destroy(); - }); - pipeline(_read2, _write, common.mustCall(function (err) { - t.ok(err, 'should have an error'); - t.end(); - })); - }); - t.test('pipeline destroy', function () { - var _read3 = new Readable({ - read: function read() { - } - }); - - var _write2 = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - - _read3.push('data'); - - setImmediate(function () { - return _read3.destroy(new Error('kaboom')); - }); - var dst = pipeline(_read3, _write2, common.mustCall(function (err) { - t.equal(err.message, 'kaboom'); - t.end(); - })); - t.equal(dst, _write2); - }); -};
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/arraystream.js
Deleted
@@ -1,43 +0,0 @@ -"use strict"; - -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -var _require = require('../../'), - Stream = _require.Stream; -function noop() {} - -// A stream to push an array into a REPL -function ArrayStream() { - this.run = function (data) { - var _this = this; - forEach(data, function (line) { - _this.emit('data', "".concat(line, "\n")); - }); - }; -} -Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype); -Object.setPrototypeOf(ArrayStream, Stream); -ArrayStream.prototype.readable = true; -ArrayStream.prototype.writable = true; -ArrayStream.prototype.pause = noop; -ArrayStream.prototype.resume = noop; -ArrayStream.prototype.write = noop; -module.exports = ArrayStream; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/heap.js
Deleted
@@ -1,216 +0,0 @@ -"use strict"; - -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && oSymbol.iterator || o"@@iterator"; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: oi++ }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2i = arri; return arr2; } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -var assert = require('assert'); - -/*<replacement>*/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/*</replacement>*/ - -var internalTestHeap; -try { - internalTestHeap = require('internal/test/heap'); -} catch (e) { - console.log('using `test/common/heap.js` requires `--expose-internals`'); - throw e; -} -var _internalTestHeap = internalTestHeap, - createJSHeapDump = _internalTestHeap.createJSHeapDump, - buildEmbedderGraph = _internalTestHeap.buildEmbedderGraph; -function inspectNode(snapshot) { - return util.inspect(snapshot, { - depth: 4 - }); -} -function isEdge(edge, _ref) { - var node_name = _ref.node_name, - edge_name = _ref.edge_name; - // For ABI compatibility, we did not backport the virtual function - // AddEdge() with a name as last argument back to v10.x, so edge_name. - // is ignored. - // if (edge.name !== edge_name) { - // return false; - // } - // From our internal embedded graph - if (edge.to.value) { - if (edge.to.value.constructor.name !== node_name) { - return false; - } - } else if (edge.to.name !== node_name) { - return false; - } - return true; -} -var State = /*#__PURE__*/function () { - function State() { - _classCallCheck(this, State); - this.snapshot = createJSHeapDump(); - this.embedderGraph = buildEmbedderGraph(); - } - - // Validate the v8 heap snapshot - _createClass(State, { - key: "validateSnapshot", - value: function validateSnapshot(rootName, expected) { - var _ref2 = arguments.length > 2 && arguments2 !== undefined ? arguments2 : {}, - _ref2$loose = _ref2.loose, - loose = _ref2$loose === void 0 ? false : _ref2$loose; - var rootNodes = this.snapshot.filter(function (node) { - return node.name === rootName && node.type !== 'string'; - }); - if (loose) { - assert(rootNodes.length >= expected.length, "Expect to find at least ".concat(expected.length, " '").concat(rootName, "', ") + "found ".concat(rootNodes.length)); - } else { - assert.strictEqual(rootNodes.length, expected.length, "Expect to find ".concat(expected.length, " '").concat(rootName, "', ") + "found ".concat(rootNodes.length)); - } - var _iterator = _createForOfIteratorHelper(expected), - _step; - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var expectation = _step.value; - if (expectation.children) { - var _iterator2 = _createForOfIteratorHelper(expectation.children), - _step2; - try { - var _loop = function _loop() { - var expectedEdge = _step2.value; - var check = typeof expectedEdge === 'function' ? expectedEdge : function (edge) { - return isEdge(edge, expectedEdge); - }; - var hasChild = rootNodes.some(function (node) { - return node.outgoingEdges.some(check); - }); - // Don't use assert with a custom message here. Otherwise the - // inspection in the message is done eagerly and wastes a lot of CPU - // time. - if (!hasChild) { - throw new Error('expected to find child ' + "".concat(util.inspect(expectedEdge), " in ").concat(inspectNode(rootNodes))); - } - }; - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - _loop(); - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - } - - // Validate our internal embedded graph representation - }, { - key: "validateGraph", - value: function validateGraph(rootName, expected) { - var _ref3 = arguments.length > 2 && arguments2 !== undefined ? arguments2 : {}, - _ref3$loose = _ref3.loose, - loose = _ref3$loose === void 0 ? false : _ref3$loose; - var rootNodes = this.embedderGraph.filter(function (node) { - return node.name === rootName; - }); - if (loose) { - assert(rootNodes.length >= expected.length, "Expect to find at least ".concat(expected.length, " '").concat(rootName, "', ") + "found ".concat(rootNodes.length)); - } else { - assert.strictEqual(rootNodes.length, expected.length, "Expect to find ".concat(expected.length, " '").concat(rootName, "', ") + "found ".concat(rootNodes.length)); - } - var _iterator3 = _createForOfIteratorHelper(expected), - _step3; - try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var expectation = _step3.value; - if (expectation.children) { - var _iterator4 = _createForOfIteratorHelper(expectation.children), - _step4; - try { - var _loop2 = function _loop2() { - var expectedEdge = _step4.value; - var check = typeof expectedEdge === 'function' ? expectedEdge : function (edge) { - return isEdge(edge, expectedEdge); - }; - // Don't use assert with a custom message here. Otherwise the - // inspection in the message is done eagerly and wastes a lot of CPU - // time. - var hasChild = rootNodes.some(function (node) { - return node.edges.some(check); - }); - if (!hasChild) { - throw new Error('expected to find child ' + "".concat(util.inspect(expectedEdge), " in ").concat(inspectNode(rootNodes))); - } - }; - for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { - _loop2(); - } - } catch (err) { - _iterator4.e(err); - } finally { - _iterator4.f(); - } - } - } - } catch (err) { - _iterator3.e(err); - } finally { - _iterator3.f(); - } - } - }, { - key: "validateSnapshotNodes", - value: function validateSnapshotNodes(rootName, expected) { - var _ref4 = arguments.length > 2 && arguments2 !== undefined ? arguments2 : {}, - _ref4$loose = _ref4.loose, - loose = _ref4$loose === void 0 ? false : _ref4$loose; - this.validateSnapshot(rootName, expected, { - loose: loose - }); - this.validateGraph(rootName, expected, { - loose: loose - }); - } - }); - return State; -}(); -function recordState() { - return new State(); -} -function validateSnapshotNodes() { - var _recordState; - return (_recordState = recordState()).validateSnapshotNodes.apply(_recordState, arguments); -} -module.exports = { - recordState: recordState, - validateSnapshotNodes: validateSnapshotNodes -}; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/hijackstdio.js
Deleted
@@ -1,50 +0,0 @@ -"use strict"; - -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -// Hijack stdout and stderr -var stdWrite = {}; -function hijackStdWritable(name, listener) { - var stream = processname; - var _write = stdWritename = stream.write; - stream.writeTimes = 0; - stream.write = function (data, callback) { - try { - listener(data); - } catch (e) { - process.nextTick(function () { - throw e; - }); - } - _write.call(stream, data, callback); - stream.writeTimes++; - }; -} -function restoreWritable(name) { - processname.write = stdWritename; - delete processname.writeTimes; -} -module.exports = { - hijackStdout: hijackStdWritable.bind(null, 'stdout'), - hijackStderr: hijackStdWritable.bind(null, 'stderr'), - restoreStdout: restoreWritable.bind(null, 'stdout'), - restoreStderr: restoreWritable.bind(null, 'stderr') -}; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/http2.js
Deleted
@@ -1,191 +0,0 @@ -"use strict"; - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -// An HTTP/2 testing tool used to create mock frames for direct testing -// of HTTP/2 endpoints. - -var kFrameData = Symbol('frame-data'); -var FLAG_EOS = 0x1; -var FLAG_ACK = 0x1; -var FLAG_EOH = 0x4; -var FLAG_PADDED = 0x8; -var PADDING = Buffer.alloc(255); -var kClientMagic = Buffer.from('505249202a20485454502f322' + 'e300d0a0d0a534d0d0a0d0a', 'hex'); -var kFakeRequestHeaders = Buffer.from('828684410f7777772e65' + '78616d706c652e636f6d', 'hex'); -var kFakeResponseHeaders = Buffer.from('4803333032580770726976617465611d' + '4d6f6e2c203231204f63742032303133' + '2032303a31333a323120474d546e1768' + '747470733a2f2f7777772e6578616d70' + '6c652e636f6d', 'hex'); -function isUint32(val) { - return val >>> 0 === val; -} -function isUint24(val) { - return val >>> 0 === val && val <= 0xFFFFFF; -} -function isUint8(val) { - return val >>> 0 === val && val <= 0xFF; -} -function write32BE(array, pos, val) { - if (!isUint32(val)) throw new RangeError('val is not a 32-bit number'); - arraypos++ = val >> 24 & 0xff; - arraypos++ = val >> 16 & 0xff; - arraypos++ = val >> 8 & 0xff; - arraypos++ = val & 0xff; -} -function write24BE(array, pos, val) { - if (!isUint24(val)) throw new RangeError('val is not a 24-bit number'); - arraypos++ = val >> 16 & 0xff; - arraypos++ = val >> 8 & 0xff; - arraypos++ = val & 0xff; -} -function write8(array, pos, val) { - if (!isUint8(val)) throw new RangeError('val is not an 8-bit number'); - arraypos = val; -} -var Frame = /*#__PURE__*/function () { - function Frame(length, type, flags, id) { - _classCallCheck(this, Frame); - thiskFrameData = Buffer.alloc(9); - write24BE(thiskFrameData, 0, length); - write8(thiskFrameData, 3, type); - write8(thiskFrameData, 4, flags); - write32BE(thiskFrameData, 5, id); - } - _createClass(Frame, { - key: "data", - get: function get() { - return thiskFrameData; - } - }); - return Frame; -}(); -var SettingsFrame = /*#__PURE__*/function (_Frame) { - _inherits(SettingsFrame, _Frame); - var _super = _createSuper(SettingsFrame); - function SettingsFrame() { - var ack = arguments.length > 0 && arguments0 !== undefined ? arguments0 : false; - _classCallCheck(this, SettingsFrame); - var flags = 0; - if (ack) flags |= FLAG_ACK; - return _super.call(this, 0, 4, flags, 0); - } - return _createClass(SettingsFrame); -}(Frame); -var DataFrame = /*#__PURE__*/function (_Frame2) { - _inherits(DataFrame, _Frame2); - var _super2 = _createSuper(DataFrame); - function DataFrame(id, payload) { - var _this; - var padlen = arguments.length > 2 && arguments2 !== undefined ? arguments2 : 0; - var final = arguments.length > 3 && arguments3 !== undefined ? arguments3 : false; - _classCallCheck(this, DataFrame); - var len = payload.length; - var flags = 0; - if (final) flags |= FLAG_EOS; - var buffers = payload; - if (padlen > 0) { - buffers.unshift(Buffer.from(padlen)); - buffers.push(PADDING.slice(0, padlen)); - len += padlen + 1; - flags |= FLAG_PADDED; - } - _this = _super2.call(this, len, 0, flags, id); - buffers.unshift(_thiskFrameData); - _thiskFrameData = Buffer.concat(buffers); - return _this; - } - return _createClass(DataFrame); -}(Frame); -var HeadersFrame = /*#__PURE__*/function (_Frame3) { - _inherits(HeadersFrame, _Frame3); - var _super3 = _createSuper(HeadersFrame); - function HeadersFrame(id, payload) { - var _this2; - var padlen = arguments.length > 2 && arguments2 !== undefined ? arguments2 : 0; - var final = arguments.length > 3 && arguments3 !== undefined ? arguments3 : false; - _classCallCheck(this, HeadersFrame); - var len = payload.length; - var flags = FLAG_EOH; - if (final) flags |= FLAG_EOS; - var buffers = payload; - if (padlen > 0) { - buffers.unshift(Buffer.from(padlen)); - buffers.push(PADDING.slice(0, padlen)); - len += padlen + 1; - flags |= FLAG_PADDED; - } - _this2 = _super3.call(this, len, 1, flags, id); - buffers.unshift(_this2kFrameData); - _this2kFrameData = Buffer.concat(buffers); - return _this2; - } - return _createClass(HeadersFrame); -}(Frame); -var PingFrame = /*#__PURE__*/function (_Frame4) { - _inherits(PingFrame, _Frame4); - var _super4 = _createSuper(PingFrame); - function PingFrame() { - var _this3; - var ack = arguments.length > 0 && arguments0 !== undefined ? arguments0 : false; - _classCallCheck(this, PingFrame); - var buffers = Buffer.alloc(8); - _this3 = _super4.call(this, 8, 6, ack ? 1 : 0, 0); - buffers.unshift(_this3kFrameData); - _this3kFrameData = Buffer.concat(buffers); - return _this3; - } - return _createClass(PingFrame); -}(Frame); -var AltSvcFrame = /*#__PURE__*/function (_Frame5) { - _inherits(AltSvcFrame, _Frame5); - var _super5 = _createSuper(AltSvcFrame); - function AltSvcFrame(size) { - var _this4; - _classCallCheck(this, AltSvcFrame); - var buffers = Buffer.alloc(size); - _this4 = _super5.call(this, size, 10, 0, 0); - buffers.unshift(_this4kFrameData); - _this4kFrameData = Buffer.concat(buffers); - return _this4; - } - return _createClass(AltSvcFrame); -}(Frame); -module.exports = { - Frame: Frame, - AltSvcFrame: AltSvcFrame, - DataFrame: DataFrame, - HeadersFrame: HeadersFrame, - SettingsFrame: SettingsFrame, - PingFrame: PingFrame, - kFakeRequestHeaders: kFakeRequestHeaders, - kFakeResponseHeaders: kFakeResponseHeaders, - kClientMagic: kClientMagic -}; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/internet.js
Deleted
@@ -1,83 +0,0 @@ -"use strict"; - -function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && oSymbol.iterator || o"@@iterator"; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: oi++ }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a Symbol.iterator() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2i = arri; return arr2; } -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -// Utilities for internet-related tests - -var addresses = { - // A generic host that has registered common DNS records, - // supports both IPv4 and IPv6, and provides basic HTTP/HTTPS services - INET_HOST: 'nodejs.org', - // A host that provides IPv4 services - INET4_HOST: 'nodejs.org', - // A host that provides IPv6 services - INET6_HOST: 'nodejs.org', - // An accessible IPv4 IP, - // defaults to the Google Public DNS IPv4 address - INET4_IP: '8.8.8.8', - // An accessible IPv6 IP, - // defaults to the Google Public DNS IPv6 address - INET6_IP: '2001:4860:4860::8888', - // An invalid host that cannot be resolved - // See https://tools.ietf.org/html/rfc2606#section-2 - INVALID_HOST: 'something.invalid', - // A host with MX records registered - MX_HOST: 'nodejs.org', - // A host with SRV records registered - SRV_HOST: '_jabber._tcp.google.com', - // A host with PTR records registered - PTR_HOST: '8.8.8.8.in-addr.arpa', - // A host with NAPTR records registered - NAPTR_HOST: 'sip2sip.info', - // A host with SOA records registered - SOA_HOST: 'nodejs.org', - // A host with CNAME records registered - CNAME_HOST: 'blog.nodejs.org', - // A host with NS records registered - NS_HOST: 'nodejs.org', - // A host with TXT records registered - TXT_HOST: 'nodejs.org', - // An accessible IPv4 DNS server - DNS4_SERVER: '8.8.8.8', - // An accessible IPv4 DNS server - DNS6_SERVER: '2001:4860:4860::8888' -}; -var _iterator = _createForOfIteratorHelper(objectKeys(addresses)), - _step; -try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var key = _step.value; - var envName = "NODE_TEST_".concat(key); - if (process.envenvName) { - addresseskey = process.envenvName; - } - } -} catch (err) { - _iterator.e(err); -} finally { - _iterator.f(); -} -module.exports = { - addresses: addresses -}; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/ongc.js
Deleted
@@ -1,49 +0,0 @@ -"use strict"; - -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -var common = require('../common'); -var assert = require('assert'); -var gcTrackerMap = new WeakMap(); -var gcTrackerTag = 'NODE_TEST_COMMON_GC_TRACKER'; -function onGC(obj, gcListener) { - var async_hooks = - /*require('async_hooks'); - const onGcAsyncHook = async_hooks.createHook({ - init: common.mustCallAtLeast(function(id, type) { - if (this.trackedId === undefined) { - assert.strictEqual(type, gcTrackerTag); - this.trackedId = id; - } - }), - destroy(id) { - assert.notStrictEqual(this.trackedId, -1); - if (id === this.trackedId) { - this.gcListener.ongc(); - onGcAsyncHook.disable(); - } - } - }).enable();*/ - onGcAsyncHook.gcListener = gcListener; - gcTrackerMap.set(obj, new async_hooks.AsyncResource(gcTrackerTag)); - obj = null; -} -module.exports = onGC; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/shared-lib-util.js
Deleted
@@ -1,64 +0,0 @@ -"use strict"; - -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -var common = require('../common'); -var path = require('path'); -var kNodeShared = Boolean(process.config.variables.node_shared); -var kShlibSuffix = process.config.variables.shlib_suffix; -var kExecPath = path.dirname(process.execPath); - -// If node executable is linked to shared lib, need to take care about the -// shared lib path. -function addLibraryPath(env) { - if (!kNodeShared) { - return; - } - env = env || process.env; - env.LD_LIBRARY_PATH = (env.LD_LIBRARY_PATH ? env.LD_LIBRARY_PATH + path.delimiter : '') + path.join(kExecPath, 'lib.target'); - // For AIX. - env.LIBPATH = (env.LIBPATH ? env.LIBPATH + path.delimiter : '') + path.join(kExecPath, 'lib.target'); - // For Mac OSX. - env.DYLD_LIBRARY_PATH = (env.DYLD_LIBRARY_PATH ? env.DYLD_LIBRARY_PATH + path.delimiter : '') + kExecPath; - // For Windows. - env.PATH = (env.PATH ? env.PATH + path.delimiter : '') + kExecPath; -} - -// Get the full path of shared lib. -function getSharedLibPath() { - if (common.isWindows) { - return path.join(kExecPath, 'node.dll'); - } else if (common.isOSX) { - return path.join(kExecPath, "libnode.".concat(kShlibSuffix)); - } else { - return path.join(kExecPath, 'lib.target', "libnode.".concat(kShlibSuffix)); - } -} - -// Get the binary path of stack frames. -function getBinaryPath() { - return kNodeShared ? getSharedLibPath() : process.execPath; -} -module.exports = { - addLibraryPath: addLibraryPath, - getBinaryPath: getBinaryPath, - getSharedLibPath: getSharedLibPath -}; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/tick.js
Deleted
@@ -1,33 +0,0 @@ -"use strict"; - -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -require('../common'); -module.exports = function tick(x, cb) { - function ontick() { - if (--x === 0) { - if (typeof cb === 'function') cb(); - } else { - setImmediate(ontick); - } - } - setImmediate(ontick); -}; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/tls.js
Deleted
@@ -1,200 +0,0 @@ -"use strict"; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = propsi; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } -function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } -function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = inputSymbol.toPrimitive; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } -function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } -function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } -function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, , function () {})); return true; } catch (e) { return false; } } -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules, node-core/crypto-check */ - -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -var crypto = require('crypto'); -var net = require('net'); -exports.ccs = Buffer.from('140303000101', 'hex'); -var TestTLSSocket = /*#__PURE__*/function (_net$Socket) { - _inherits(TestTLSSocket, _net$Socket); - var _super = _createSuper(TestTLSSocket); - function TestTLSSocket(server_cert) { - var _this; - _classCallCheck(this, TestTLSSocket); - _this = _super.call(this); - _this.server_cert = server_cert; - _this.version = Buffer.from('0303', 'hex'); - _this.handshake_list = ; - // AES128-GCM-SHA256 - _this.ciphers = Buffer.from('000002009c0', 'hex'); - _this.pre_master_secret = Buffer.concat(_this.version, crypto.randomBytes(46)); - _this.master_secret = null; - _this.write_seq = 0; - _this.client_random = crypto.randomBytes(32); - _this.on('handshake', function (msg) { - _this.handshake_list.push(msg); - }); - _this.on('server_random', function (server_random) { - _this.master_secret = PRF12('sha256', _this.pre_master_secret, 'master secret', Buffer.concat(_this.client_random, server_random), 48); - var key_block = PRF12('sha256', _this.master_secret, 'key expansion', Buffer.concat(server_random, _this.client_random), 40); - _this.client_writeKey = key_block.slice(0, 16); - _this.client_writeIV = key_block.slice(32, 36); - }); - return _this; - } - _createClass(TestTLSSocket, { - key: "createClientHello", - value: function createClientHello() { - var compressions = Buffer.from('0100', 'hex'); // null - var msg = addHandshakeHeader(0x01, Buffer.concat(this.version, this.client_random, this.ciphers, compressions)); - this.emit('handshake', msg); - return addRecordHeader(0x16, msg); - } - }, { - key: "createClientKeyExchange", - value: function createClientKeyExchange() { - var encrypted_pre_master_secret = crypto.publicEncrypt({ - key: this.server_cert, - padding: crypto.constants.RSA_PKCS1_PADDING - }, this.pre_master_secret); - var length = Buffer.alloc(2); - length.writeUIntBE(encrypted_pre_master_secret.length, 0, 2); - var msg = addHandshakeHeader(0x10, Buffer.concat(length, encrypted_pre_master_secret)); - this.emit('handshake', msg); - return addRecordHeader(0x16, msg); - } - }, { - key: "createFinished", - value: function createFinished() { - var shasum = crypto.createHash('sha256'); - shasum.update(Buffer.concat(this.handshake_list)); - var message_hash = shasum.digest(); - var r = PRF12('sha256', this.master_secret, 'client finished', message_hash, 12); - var msg = addHandshakeHeader(0x14, r); - this.emit('handshake', msg); - return addRecordHeader(0x16, msg); - } - }, { - key: "createIllegalHandshake", - value: function createIllegalHandshake() { - var illegal_handshake = Buffer.alloc(5); - return addRecordHeader(0x16, illegal_handshake); - } - }, { - key: "parseTLSFrame", - value: function parseTLSFrame(buf) { - var offset = 0; - var record = buf.slice(offset, 5); - var type = record0; - var length = record.slice(3, 5).readUInt16BE(0); - offset += 5; - var remaining = buf.slice(offset, offset + length); - if (type === 0x16) { - do { - remaining = this.parseTLSHandshake(remaining); - } while (remaining.length > 0); - } - offset += length; - return buf.slice(offset); - } - }, { - key: "parseTLSHandshake", - value: function parseTLSHandshake(buf) { - var offset = 0; - var handshake_type = bufoffset; - if (handshake_type === 0x02) { - var server_random = buf.slice(6, 6 + 32); - this.emit('server_random', server_random); - } - offset += 1; - var length = buf.readUIntBE(offset, 3); - offset += 3; - var handshake = buf.slice(0, offset + length); - this.emit('handshake', handshake); - offset += length; - var remaining = buf.slice(offset); - return remaining; - } - }, { - key: "encrypt", - value: function encrypt(plain) { - var type = plain.slice(0, 1); - var version = plain.slice(1, 3); - var nonce = crypto.randomBytes(8); - var iv = Buffer.concat(this.client_writeIV.slice(0, 4), nonce); - var bob = crypto.createCipheriv('aes-128-gcm', this.client_writeKey, iv); - var write_seq = Buffer.alloc(8); - write_seq.writeUInt32BE(this.write_seq++, 4); - var aad = Buffer.concat(write_seq, plain.slice(0, 5)); - bob.setAAD(aad); - var encrypted1 = bob.update(plain.slice(5)); - var encrypted = Buffer.concat(encrypted1, bob.final()); - var tag = bob.getAuthTag(); - var length = Buffer.alloc(2); - length.writeUInt16BE(nonce.length + encrypted.length + tag.length, 0); - return Buffer.concat(type, version, length, nonce, encrypted, tag); - } - }); - return TestTLSSocket; -}(net.Socket); -function addRecordHeader(type, frame) { - var record_layer = Buffer.from('0003030000', 'hex'); - record_layer0 = type; - record_layer.writeUInt16BE(frame.length, 3); - return Buffer.concat(record_layer, frame); -} -function addHandshakeHeader(type, msg) { - var handshake_header = Buffer.alloc(4); - handshake_header0 = type; - handshake_header.writeUIntBE(msg.length, 1, 3); - return Buffer.concat(handshake_header, msg); -} -function PRF12(algo, secret, label, seed, size) { - var newSeed = Buffer.concat(Buffer.from(label, 'utf8'), seed); - return P_hash(algo, secret, newSeed, size); -} -function P_hash(algo, secret, seed, size) { - var result = Buffer.alloc(size); - var hmac = crypto.createHmac(algo, secret); - hmac.update(seed); - var a = hmac.digest(); - var j = 0; - while (j < size) { - hmac = crypto.createHmac(algo, secret); - hmac.update(a); - hmac.update(seed); - var b = hmac.digest(); - var todo = b.length; - if (j + todo > size) { - todo = size - j; - } - b.copy(result, j, 0, todo); - j += todo; - hmac = crypto.createHmac(algo, secret); - hmac.update(a); - a = hmac.digest(); - } - return result; -} -exports.TestTLSSocket = TestTLSSocket; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/common/tmpdir.js
Deleted
@@ -1,76 +0,0 @@ -"use strict"; - -/*<replacement>*/ -require('@babel/polyfill'); -var util = require('util'); -for (var i in util) exportsi = utili; -/*</replacement>*/ /* eslint-disable node-core/required-modules */ -'use strict'; - -/*<replacement>*/ -var objectKeys = objectKeys || function (obj) { - var keys = ; - for (var key in obj) keys.push(key); - return keys; -}; -/*</replacement>*/ - -var fs = require('fs'); -var path = require('path'); -function rimrafSync(p) { - var st; - try { - st = fs.lstatSync(p); - } catch (e) { - if (e.code === 'ENOENT') return; - } - try { - if (st && st.isDirectory()) rmdirSync(p, null);else fs.unlinkSync(p); - } catch (e) { - if (e.code === 'ENOENT') return; - if (e.code === 'EPERM') return rmdirSync(p, e); - if (e.code !== 'EISDIR') throw e; - rmdirSync(p, e); - } -} -function rmdirSync(p, originalEr) { - try { - fs.rmdirSync(p); - } catch (e) { - if (e.code === 'ENOTDIR') throw originalEr; - if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') { - var enc = process.platform === 'linux' ? 'buffer' : 'utf8'; - forEach(fs.readdirSync(p, enc), function (f) { - if (f instanceof Buffer) { - var buf = Buffer.concat(Buffer.from(p), Buffer.from(path.sep), f); - rimrafSync(buf); - } else { - rimrafSync(path.join(p, f)); - } - }); - fs.rmdirSync(p); - } - } -} -var testRoot = process.env.NODE_TEST_DIR ? fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..'); - -// Using a `.` prefixed name, which is the convention for "hidden" on POSIX, -// gets tools to ignore it by default or by simple rules, especially eslint. -var tmpdirName = '.tmp'; -if (process.env.TEST_THREAD_ID) { - tmpdirName += ".".concat(process.env.TEST_THREAD_ID); -} -var tmpPath = path.join(testRoot, tmpdirName); -function refresh() { - rimrafSync(this.path); - fs.mkdirSync(this.path); -} -module.exports = { - path: tmpPath, - refresh: refresh -}; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xsi, i); - } -} \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/ours/errors.js
Deleted
@@ -1,148 +0,0 @@ -var tap = require('tap'); -var assert = require('assert'); -var errors = require('../../errors').codes; - -function expect (err, Base, name, code, message) { - assert(err instanceof Base); - assert.strictEqual(err.name, name); - assert.strictEqual(err.code, code); - assert.strictEqual(err.message, message); -} - -expect( - new errors.ERR_INVALID_OPT_VALUE('name', 0), - TypeError, - 'TypeError', - 'ERR_INVALID_OPT_VALUE', - 'The value "0" is invalid for option "name"' -); - -expect( - new errors.ERR_INVALID_OPT_VALUE('name', undefined), - TypeError, - 'TypeError', - 'ERR_INVALID_OPT_VALUE', - 'The value "undefined" is invalid for option "name"' -); - -expect( - new errors.ERR_INVALID_ARG_TYPE('chunk', 'string', 'Buffer', 'Uint8Array', 0), - TypeError, - 'TypeError', - 'ERR_INVALID_ARG_TYPE', - 'The "chunk" argument must be one of type string, Buffer, or Uint8Array. Received type number' -); - -expect( - new errors.ERR_INVALID_ARG_TYPE('first argument', 'not string', 'foo'), - TypeError, - 'TypeError', - 'ERR_INVALID_ARG_TYPE', - 'The first argument must not be of type string. Received type string' -); - -expect( - new errors.ERR_INVALID_ARG_TYPE('obj.prop', 'string', undefined), - TypeError, - 'TypeError', - 'ERR_INVALID_ARG_TYPE', - 'The "obj.prop" property must be of type string. Received type undefined' -); - -expect( - new errors.ERR_STREAM_PUSH_AFTER_EOF(), - Error, - 'Error', - 'ERR_STREAM_PUSH_AFTER_EOF', - 'stream.push() after EOF' -); - -expect( - new errors.ERR_METHOD_NOT_IMPLEMENTED('_read()'), - Error, - 'Error', - 'ERR_METHOD_NOT_IMPLEMENTED', - 'The _read() method is not implemented' -); - -expect( - new errors.ERR_METHOD_NOT_IMPLEMENTED('_write()'), - Error, - 'Error', - 'ERR_METHOD_NOT_IMPLEMENTED', - 'The _write() method is not implemented' -); - -expect( - new errors.ERR_STREAM_PREMATURE_CLOSE(), - Error, - 'Error', - 'ERR_STREAM_PREMATURE_CLOSE', - 'Premature close' -); - -expect( - new errors.ERR_STREAM_DESTROYED('pipe'), - Error, - 'Error', - 'ERR_STREAM_DESTROYED', - 'Cannot call pipe after a stream was destroyed' -); - -expect( - new errors.ERR_STREAM_DESTROYED('write'), - Error, - 'Error', - 'ERR_STREAM_DESTROYED', - 'Cannot call write after a stream was destroyed' -); - -expect( - new errors.ERR_MULTIPLE_CALLBACK(), - Error, - 'Error', - 'ERR_MULTIPLE_CALLBACK', - 'Callback called multiple times' -); - -expect( - new errors.ERR_STREAM_CANNOT_PIPE(), - Error, - 'Error', - 'ERR_STREAM_CANNOT_PIPE', - 'Cannot pipe, not readable' -); - -expect( - new errors.ERR_STREAM_WRITE_AFTER_END(), - Error, - 'Error', - 'ERR_STREAM_WRITE_AFTER_END', - 'write after end' -); - -expect( - new errors.ERR_STREAM_NULL_VALUES(), - TypeError, - 'TypeError', - 'ERR_STREAM_NULL_VALUES', - 'May not write null values to stream' -); - -expect( - new errors.ERR_UNKNOWN_ENCODING('foo'), - TypeError, - 'TypeError', - 'ERR_UNKNOWN_ENCODING', - 'Unknown encoding: foo' -); - -expect( - new errors.ERR_STREAM_UNSHIFT_AFTER_END_EVENT(), - Error, - 'Error', - 'ERR_STREAM_UNSHIFT_AFTER_END_EVENT', - 'stream.unshift() after end event' -); - -require('tap').pass('sync done');
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-readable-from.js
Deleted
@@ -1,346 +0,0 @@ -"use strict"; - -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = genkey(arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } -function _awaitAsyncGenerator(value) { return new _OverloadYield(value, 0); } -function _wrapAsyncGenerator(fn) { return function () { return new _AsyncGenerator(fn.apply(this, arguments)); }; } -function _AsyncGenerator(gen) { var front, back; function resume(key, arg) { try { var result = genkey(arg), value = result.value, overloaded = value instanceof _OverloadYield; Promise.resolve(overloaded ? value.v : value).then(function (arg) { if (overloaded) { var nextKey = "return" === key ? "return" : "next"; if (!value.k || arg.done) return resume(nextKey, arg); arg = gennextKey(arg).value; } settle(result.done ? "return" : "normal", arg); }, function (err) { resume("throw", err); }); } catch (err) { settle("throw", err); } } function settle(type, value) { switch (type) { case "return": front.resolve({ value: value, done: !0 }); break; case "throw": front.reject(value); break; default: front.resolve({ value: value, done: !1 }); } (front = front.next) ? resume(front.key, front.arg) : back = null; } this._invoke = function (key, arg) { return new Promise(function (resolve, reject) { var request = { key: key, arg: arg, resolve: resolve, reject: reject, next: null }; back ? back = back.next = request : (front = back = request, resume(key, arg)); }); }, "function" != typeof gen.return && (this.return = void 0); } -_AsyncGenerator.prototype"function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator" = function () { return this; }, _AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); }, _AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); }, _AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); }; -function _OverloadYield(value, kind) { this.v = value, this.k = kind; } -function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterableasync)) return method.call(iterable); if (sync && null != (method = iterablesync)) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); } -function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); } -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var _require = require('../common'), - mustCall = _require.mustCall; -var once = require('events.once'); -var _require2 = require('../../'), - Readable = _require2.Readable; -var _require3 = require('assert/'), - strictEqual = _require3.strictEqual; -function toReadableBasicSupport() { - return _toReadableBasicSupport.apply(this, arguments); -} -function _toReadableBasicSupport() { - _toReadableBasicSupport = _asyncToGenerator(function* () { - function generate() { - return _generate.apply(this, arguments); - } - function _generate() { - _generate = _wrapAsyncGenerator(function* () { - yield 'a'; - yield 'b'; - yield 'c'; - }); - return _generate.apply(this, arguments); - } - var stream = Readable.from(generate()); - var expected = 'a', 'b', 'c'; - var _iteratorAbruptCompletion = false; - var _didIteratorError = false; - var _iteratorError; - try { - for (var _iterator = _asyncIterator(stream), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) { - var chunk = _step.value; - { - strictEqual(chunk, expected.shift()); - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (_iteratorAbruptCompletion && _iterator.return != null) { - yield _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - }); - return _toReadableBasicSupport.apply(this, arguments); -} -function toReadableSyncIterator() { - return _toReadableSyncIterator.apply(this, arguments); -} -function _toReadableSyncIterator() { - _toReadableSyncIterator = _asyncToGenerator(function* () { - function* generate() { - yield 'a'; - yield 'b'; - yield 'c'; - } - var stream = Readable.from(generate()); - var expected = 'a', 'b', 'c'; - var _iteratorAbruptCompletion2 = false; - var _didIteratorError2 = false; - var _iteratorError2; - try { - for (var _iterator2 = _asyncIterator(stream), _step2; _iteratorAbruptCompletion2 = !(_step2 = yield _iterator2.next()).done; _iteratorAbruptCompletion2 = false) { - var chunk = _step2.value; - { - strictEqual(chunk, expected.shift()); - } - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (_iteratorAbruptCompletion2 && _iterator2.return != null) { - yield _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - }); - return _toReadableSyncIterator.apply(this, arguments); -} -function toReadablePromises() { - return _toReadablePromises.apply(this, arguments); -} -function _toReadablePromises() { - _toReadablePromises = _asyncToGenerator(function* () { - var promises = Promise.resolve('a'), Promise.resolve('b'), Promise.resolve('c'); - var stream = Readable.from(promises); - var expected = 'a', 'b', 'c'; - var _iteratorAbruptCompletion3 = false; - var _didIteratorError3 = false; - var _iteratorError3; - try { - for (var _iterator3 = _asyncIterator(stream), _step3; _iteratorAbruptCompletion3 = !(_step3 = yield _iterator3.next()).done; _iteratorAbruptCompletion3 = false) { - var chunk = _step3.value; - { - strictEqual(chunk, expected.shift()); - } - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (_iteratorAbruptCompletion3 && _iterator3.return != null) { - yield _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - }); - return _toReadablePromises.apply(this, arguments); -} -function toReadableString() { - return _toReadableString.apply(this, arguments); -} -function _toReadableString() { - _toReadableString = _asyncToGenerator(function* () { - var stream = Readable.from('abc'); - var expected = 'a', 'b', 'c'; - var _iteratorAbruptCompletion4 = false; - var _didIteratorError4 = false; - var _iteratorError4; - try { - for (var _iterator4 = _asyncIterator(stream), _step4; _iteratorAbruptCompletion4 = !(_step4 = yield _iterator4.next()).done; _iteratorAbruptCompletion4 = false) { - var chunk = _step4.value; - { - strictEqual(chunk, expected.shift()); - } - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (_iteratorAbruptCompletion4 && _iterator4.return != null) { - yield _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - }); - return _toReadableString.apply(this, arguments); -} -function toReadableOnData() { - return _toReadableOnData.apply(this, arguments); -} -function _toReadableOnData() { - _toReadableOnData = _asyncToGenerator(function* () { - function generate() { - return _generate2.apply(this, arguments); - } - function _generate2() { - _generate2 = _wrapAsyncGenerator(function* () { - yield 'a'; - yield 'b'; - yield 'c'; - }); - return _generate2.apply(this, arguments); - } - var stream = Readable.from(generate()); - var iterations = 0; - var expected = 'a', 'b', 'c'; - stream.on('data', function (chunk) { - iterations++; - strictEqual(chunk, expected.shift()); - }); - yield once(stream, 'end'); - strictEqual(iterations, 3); - }); - return _toReadableOnData.apply(this, arguments); -} -function toReadableOnDataNonObject() { - return _toReadableOnDataNonObject.apply(this, arguments); -} -function _toReadableOnDataNonObject() { - _toReadableOnDataNonObject = _asyncToGenerator(function* () { - function generate() { - return _generate3.apply(this, arguments); - } - function _generate3() { - _generate3 = _wrapAsyncGenerator(function* () { - yield 'a'; - yield 'b'; - yield 'c'; - }); - return _generate3.apply(this, arguments); - } - var stream = Readable.from(generate(), { - objectMode: false - }); - var iterations = 0; - var expected = 'a', 'b', 'c'; - stream.on('data', function (chunk) { - iterations++; - strictEqual(chunk instanceof Buffer, true); - strictEqual(chunk.toString(), expected.shift()); - }); - yield once(stream, 'end'); - strictEqual(iterations, 3); - }); - return _toReadableOnDataNonObject.apply(this, arguments); -} -function destroysTheStreamWhenThrowing() { - return _destroysTheStreamWhenThrowing.apply(this, arguments); -} -function _destroysTheStreamWhenThrowing() { - _destroysTheStreamWhenThrowing = _asyncToGenerator(function* () { - function generate() { - return _generate4.apply(this, arguments); - } - function _generate4() { - _generate4 = _wrapAsyncGenerator(function* () { - throw new Error('kaboom'); - }); - return _generate4.apply(this, arguments); - } - var stream = Readable.from(generate()); - stream.read(); - try { - yield once(stream, 'error'); - } catch (err) { - strictEqual(err.message, 'kaboom'); - strictEqual(stream.destroyed, true); - } - }); - return _destroysTheStreamWhenThrowing.apply(this, arguments); -} -function asTransformStream() { - return _asTransformStream.apply(this, arguments); -} -function _asTransformStream() { - _asTransformStream = _asyncToGenerator(function* () { - function generate(_x) { - return _generate5.apply(this, arguments); - } - function _generate5() { - _generate5 = _wrapAsyncGenerator(function* (stream) { - var _iteratorAbruptCompletion6 = false; - var _didIteratorError6 = false; - var _iteratorError6; - try { - for (var _iterator6 = _asyncIterator(stream), _step6; _iteratorAbruptCompletion6 = !(_step6 = yield _awaitAsyncGenerator(_iterator6.next())).done; _iteratorAbruptCompletion6 = false) { - var chunk = _step6.value; - { - yield chunk.toUpperCase(); - } - } - } catch (err) { - _didIteratorError6 = true; - _iteratorError6 = err; - } finally { - try { - if (_iteratorAbruptCompletion6 && _iterator6.return != null) { - yield _awaitAsyncGenerator(_iterator6.return()); - } - } finally { - if (_didIteratorError6) { - throw _iteratorError6; - } - } - } - }); - return _generate5.apply(this, arguments); - } - var source = new Readable({ - objectMode: true, - read: function read() { - this.push('a'); - this.push('b'); - this.push('c'); - this.push(null); - } - }); - var stream = Readable.from(generate(source)); - var expected = 'A', 'B', 'C'; - var _iteratorAbruptCompletion5 = false; - var _didIteratorError5 = false; - var _iteratorError5; - try { - for (var _iterator5 = _asyncIterator(stream), _step5; _iteratorAbruptCompletion5 = !(_step5 = yield _iterator5.next()).done; _iteratorAbruptCompletion5 = false) { - var chunk = _step5.value; - { - strictEqual(chunk, expected.shift()); - } - } - } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; - } finally { - try { - if (_iteratorAbruptCompletion5 && _iterator5.return != null) { - yield _iterator5.return(); - } - } finally { - if (_didIteratorError5) { - throw _iteratorError5; - } - } - } - }); - return _asTransformStream.apply(this, arguments); -} -Promise.all(toReadableBasicSupport(), toReadableSyncIterator(), toReadablePromises(), toReadableString(), toReadableOnData(), toReadableOnDataNonObject(), destroysTheStreamWhenThrowing(), asTransformStream()).then(mustCall()); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-readable-large-hwm.js
Deleted
@@ -1,40 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable; - -// Make sure that readable completes -// even when reading larger buffer. -var bufferSize = 10 * 1024 * 1024; -var n = 0; -var r = new Readable({ - read: function read() { - // Try to fill readable buffer piece by piece. - r.push(bufferShim.alloc(bufferSize / 10)); - if (n++ > 10) { - r.push(null); - } - } -}); -r.on('readable', function () { - while (true) { - var ret = r.read(bufferSize); - if (ret === null) break; - } -}); -r.on('end', common.mustCall()); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-readable-single-end.js
Deleted
@@ -1,30 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable; - -// This test ensures that there will not be an additional empty 'readable' -// event when stream has ended (only 1 event signalling about end) - -var r = new Readable({ - read: function read() {} -}); -r.push(null); -r.on('readable', common.mustCall()); -r.on('end', common.mustCall()); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-auto-destroy.js
Deleted
@@ -1,88 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var stream = require('../../'); -var assert = require('assert/'); -{ - var r = new stream.Readable({ - autoDestroy: true, - read: function read() { - this.push('hello'); - this.push('world'); - this.push(null); - }, - destroy: common.mustCall(function (err, cb) { - return cb(); - }) - }); - var ended = false; - r.resume(); - r.on('end', common.mustCall(function () { - ended = true; - })); - r.on('close', common.mustCall(function () { - assert(ended); - })); -} -{ - var w = new stream.Writable({ - autoDestroy: true, - write: function write(data, enc, cb) { - cb(null); - }, - destroy: common.mustCall(function (err, cb) { - return cb(); - }) - }); - var finished = false; - w.write('hello'); - w.write('world'); - w.end(); - w.on('finish', common.mustCall(function () { - finished = true; - })); - w.on('close', common.mustCall(function () { - assert(finished); - })); -} -{ - var t = new stream.Transform({ - autoDestroy: true, - transform: function transform(data, enc, cb) { - cb(null, data); - }, - destroy: common.mustCall(function (err, cb) { - return cb(); - }) - }); - var _ended = false; - var _finished = false; - t.write('hello'); - t.write('world'); - t.end(); - t.resume(); - t.on('end', common.mustCall(function () { - _ended = true; - })); - t.on('finish', common.mustCall(function () { - _finished = true; - })); - t.on('close', common.mustCall(function () { - assert(_ended); - assert(_finished); - })); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-backpressure.js
Deleted
@@ -1,49 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var assert = require('assert/'); -var stream = require('../../'); -var pushes = 0; -var total = 65500 + 40 * 1024; -var rs = new stream.Readable({ - read: common.mustCall(function () { - if (pushes++ === 10) { - this.push(null); - return; - } - var length = this._readableState.length; - - // We are at most doing two full runs of _reads - // before stopping, because Readable is greedy - // to keep its buffer full - assert(length <= total); - this.push(bufferShim.alloc(65500)); - for (var i = 0; i < 40; i++) { - this.push(bufferShim.alloc(1024)); - } - - // We will be over highWaterMark at this point - // but a new call to _read is scheduled anyway. - }, 11) -}); -var ws = stream.Writable({ - write: common.mustCall(function (data, enc, cb) { - setImmediate(cb); - }, 41 * 10) -}); -rs.pipe(ws); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-destroy-event-order.js
Deleted
@@ -1,35 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var assert = require('assert/'); -var _require = require('../../'), - Readable = _require.Readable; -var rs = new Readable({ - read: function read() {} -}); -var closed = false; -var errored = false; -rs.on('close', common.mustCall(function () { - closed = true; - assert(errored); -})); -rs.on('error', common.mustCall(function (err) { - errored = true; - assert(!closed); -})); -rs.destroy(new Error('kaboom')); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-duplex-end.js
Deleted
@@ -1,53 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var assert = require('assert/'); -var Duplex = require('../../').Duplex; -{ - var stream = new Duplex({ - read: function read() {} - }); - assert.strictEqual(stream.allowHalfOpen, true); - stream.on('finish', common.mustNotCall()); - assert.strictEqual(stream.listenerCount('end'), 0); - stream.resume(); - stream.push(null); -} -{ - var _stream = new Duplex({ - read: function read() {}, - allowHalfOpen: false - }); - assert.strictEqual(_stream.allowHalfOpen, false); - _stream.on('finish', common.mustCall()); - assert.strictEqual(_stream.listenerCount('end'), 1); - _stream.resume(); - _stream.push(null); -} -{ - var _stream2 = new Duplex({ - read: function read() {}, - allowHalfOpen: false - }); - assert.strictEqual(_stream2.allowHalfOpen, false); - _stream2._writableState.ended = true; - _stream2.on('finish', common.mustNotCall()); - assert.strictEqual(_stream2.listenerCount('end'), 1); - _stream2.resume(); - _stream2.push(null); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-finished.js
Deleted
@@ -1,141 +0,0 @@ -"use strict"; - -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = genkey(arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var _require = require('../../'), - Writable = _require.Writable, - Readable = _require.Readable, - Transform = _require.Transform, - finished = _require.finished; -var assert = require('assert/'); -var fs = require('fs'); -var promisify = require('util-promisify'); -{ - var rs = new Readable({ - read: function read() {} - }); - finished(rs, common.mustCall(function (err) { - assert(!err, 'no error'); - })); - rs.push(null); - rs.resume(); -} -{ - var ws = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - finished(ws, common.mustCall(function (err) { - assert(!err, 'no error'); - })); - ws.end(); -} -{ - var tr = new Transform({ - transform: function transform(data, enc, cb) { - cb(); - } - }); - var finish = false; - var ended = false; - tr.on('end', function () { - ended = true; - }); - tr.on('finish', function () { - finish = true; - }); - finished(tr, common.mustCall(function (err) { - assert(!err, 'no error'); - assert(finish); - assert(ended); - })); - tr.end(); - tr.resume(); -} -{ - var _rs = fs.createReadStream(__filename); - _rs.resume(); - finished(_rs, common.mustCall()); -} -{ - var run = /*#__PURE__*/function () { - var _ref = _asyncToGenerator(function* () { - var rs = fs.createReadStream(__filename); - var done = common.mustCall(); - var ended = false; - rs.resume(); - rs.on('end', function () { - ended = true; - }); - yield finishedPromise(rs); - assert(ended); - done(); - }); - return function run() { - return _ref.apply(this, arguments); - }; - }(); - var finishedPromise = promisify(finished); - run(); -} -{ - var _rs2 = fs.createReadStream('file-does-not-exist'); - finished(_rs2, common.mustCall(function (err) { - assert.strictEqual(err.code, 'ENOENT'); - })); -} -{ - var _rs3 = new Readable(); - finished(_rs3, common.mustCall(function (err) { - assert(!err, 'no error'); - })); - _rs3.push(null); - _rs3.emit('close'); // should not trigger an error - _rs3.resume(); -} -{ - var _rs4 = new Readable(); - finished(_rs4, common.mustCall(function (err) { - assert(err, 'premature close error'); - })); - _rs4.emit('close'); // should trigger error - _rs4.push(null); - _rs4.resume(); -} - -// Test that calling returned function removes listeners -{ - var _ws = new Writable({ - write: function write(data, env, cb) { - cb(); - } - }); - var removeListener = finished(_ws, common.mustNotCall()); - removeListener(); - _ws.end(); -} -{ - var _rs5 = new Readable(); - var removeListeners = finished(_rs5, common.mustNotCall()); - removeListeners(); - _rs5.emit('close'); - _rs5.push(null); - _rs5.resume(); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-once-readable-pipe.js
Deleted
@@ -1,70 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var assert = require('assert/'); -var _require = require('../../'), - Readable = _require.Readable, - Writable = _require.Writable; - -// This test ensures that if have 'readable' listener -// on Readable instance it will not disrupt the pipe. - -{ - var receivedData = ''; - var w = new Writable({ - write: function write(chunk, env, callback) { - receivedData += chunk; - callback(); - } - }); - var data = 'foo', 'bar', 'baz'; - var r = new Readable({ - read: function read() {} - }); - r.once('readable', common.mustCall()); - r.pipe(w); - r.push(data0); - r.push(data1); - r.push(data2); - r.push(null); - w.on('finish', common.mustCall(function () { - assert.strictEqual(receivedData, data.join('')); - })); -} -{ - var _receivedData = ''; - var _w = new Writable({ - write: function write(chunk, env, callback) { - _receivedData += chunk; - callback(); - } - }); - var _data = 'foo', 'bar', 'baz'; - var _r = new Readable({ - read: function read() {} - }); - _r.pipe(_w); - _r.push(_data0); - _r.push(_data1); - _r.push(_data2); - _r.push(null); - _r.once('readable', common.mustCall()); - _w.on('finish', common.mustCall(function () { - assert.strictEqual(_receivedData, _data.join('')); - })); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-flow-after-unpipe.js
Deleted
@@ -1,47 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable, - Writable = _require.Writable; - -// Tests that calling .unpipe() un-blocks a stream that is paused because -// it is waiting on the writable side to finish a write(). - -var rs = new Readable({ - highWaterMark: 1, - // That this gets called at least 20 times is the real test here. - read: common.mustCallAtLeast(function () { - return rs.push('foo'); - }, 20) -}); -var ws = new Writable({ - highWaterMark: 1, - write: common.mustCall(function () { - // Ignore the callback, this write() simply never finishes. - setImmediate(function () { - return rs.unpipe(ws); - }); - }) -}); -var chunks = 0; -rs.on('data', common.mustCallAtLeast(function () { - chunks++; - if (chunks >= 20) rs.pause(); // Finish this test. -})); - -rs.pipe(ws); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-flow.js
Deleted
@@ -1,81 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable, - Writable = _require.Writable, - PassThrough = _require.PassThrough; -{ - var ticks = 17; - var rs = new Readable({ - objectMode: true, - read: function read() { - if (ticks-- > 0) return process.nextTick(function () { - return rs.push({}); - }); - rs.push({}); - rs.push(null); - } - }); - var ws = new Writable({ - highWaterMark: 0, - objectMode: true, - write: function write(data, end, cb) { - return setImmediate(cb); - } - }); - rs.on('end', common.mustCall()); - ws.on('finish', common.mustCall()); - rs.pipe(ws); -} -{ - var missing = 8; - var _rs = new Readable({ - objectMode: true, - read: function read() { - if (missing--) _rs.push({});else _rs.push(null); - } - }); - var pt = _rs.pipe(new PassThrough({ - objectMode: true, - highWaterMark: 2 - })).pipe(new PassThrough({ - objectMode: true, - highWaterMark: 2 - })); - pt.on('end', function () { - wrapper.push(null); - }); - var wrapper = new Readable({ - objectMode: true, - read: function read() { - process.nextTick(function () { - var data = pt.read(); - if (data === null) { - pt.once('readable', function () { - data = pt.read(); - if (data !== null) wrapper.push(data); - }); - } else { - wrapper.push(data); - } - }); - } - }); - wrapper.resume(); - wrapper.on('end', common.mustCall()); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipe-manual-resume.js
Deleted
@@ -1,52 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var stream = require('../../'); -function test(throwCodeInbetween) { - // Check that a pipe does not stall if .read() is called unexpectedly - // (i.e. the stream is not resumed by the pipe). - - var n = 1000; - var counter = n; - var rs = stream.Readable({ - objectMode: true, - read: common.mustCallAtLeast(function () { - if (--counter >= 0) rs.push({ - counter: counter - });else rs.push(null); - }, n) - }); - var ws = stream.Writable({ - objectMode: true, - write: common.mustCall(function (data, enc, cb) { - setImmediate(cb); - }, n) - }); - setImmediate(function () { - return throwCodeInbetween(rs, ws); - }); - rs.pipe(ws); -} -test(function (rs) { - return rs.read(); -}); -test(function (rs) { - return rs.resume(); -}); -test(function () { - return 0; -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipeline-queued-end-in-destroy.js
Deleted
@@ -1,54 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var assert = require('assert/'); -var _require = require('../../'), - Readable = _require.Readable, - Duplex = _require.Duplex, - pipeline = _require.pipeline; - -// Test that the callback for pipeline() is called even when the ._destroy() -// method of the stream places an .end() request to itself that does not -// get processed before the destruction of the stream (i.e. the 'close' event). -// Refs: https://github.com/nodejs/node/issues/24456 - -var readable = new Readable({ - read: common.mustCall(function () {}) -}); -var duplex = new Duplex({ - write: function write(chunk, enc, cb) { - // Simulate messages queueing up. - }, - read: function read() {}, - destroy: function destroy(err, cb) { - // Call end() from inside the destroy() method, like HTTP/2 streams - // do at the time of writing. - this.end(); - cb(err); - } -}); -duplex.on('finished', common.mustNotCall()); -pipeline(readable, duplex, common.mustCall(function (err) { - assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE'); -})); - -// Write one chunk of data, and destroy the stream later. -// That should trigger the pipeline destruction. -readable.push('foo'); -setImmediate(function () { - readable.destroy(); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-pipeline.js
Deleted
@@ -1,405 +0,0 @@ -"use strict"; - -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = genkey(arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var _require = require('../../'), - Stream = _require.Stream, - Writable = _require.Writable, - Readable = _require.Readable, - Transform = _require.Transform, - pipeline = _require.pipeline; -var assert = require('assert/'); -var http = require('http'); -var promisify = require('util-promisify'); -{ - var finished = false; - var processed = ; - var expected = bufferShim.from('a'), bufferShim.from('b'), bufferShim.from('c'); - var read = new Readable({ - read: function read() {} - }); - var write = new Writable({ - write: function write(data, enc, cb) { - processed.push(data); - cb(); - } - }); - write.on('finish', function () { - finished = true; - }); - for (var i = 0; i < expected.length; i++) { - read.push(expectedi); - } - read.push(null); - pipeline(read, write, common.mustCall(function (err) { - assert.ok(!err, 'no error'); - assert.ok(finished); - assert.deepStrictEqual(processed, expected); - })); -} -{ - var _read = new Readable({ - read: function read() {} - }); - assert.throws(function () { - pipeline(_read, function () {}); - }, /ERR_MISSING_ARGS/); - assert.throws(function () { - pipeline(function () {}); - }, /ERR_MISSING_ARGS/); - assert.throws(function () { - pipeline(); - }, /ERR_MISSING_ARGS/); -} -{ - var _read2 = new Readable({ - read: function read() {} - }); - var _write = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - _read2.push('data'); - setImmediate(function () { - return _read2.destroy(); - }); - pipeline(_read2, _write, common.mustCall(function (err) { - assert.ok(err, 'should have an error'); - })); -} -{ - var _read3 = new Readable({ - read: function read() {} - }); - var _write2 = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - _read3.push('data'); - setImmediate(function () { - return _read3.destroy(new Error('kaboom')); - }); - var dst = pipeline(_read3, _write2, common.mustCall(function (err) { - assert.strictEqual(err.message, 'kaboom'); - })); - assert.strictEqual(dst, _write2); -} -{ - var _read4 = new Readable({ - read: function read() {} - }); - var transform = new Transform({ - transform: function transform(data, enc, cb) { - process.nextTick(cb, new Error('kaboom')); - } - }); - var _write3 = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - _read4.on('close', common.mustCall()); - transform.on('close', common.mustCall()); - _write3.on('close', common.mustCall()); - var _dst = pipeline(_read4, transform, _write3, common.mustCall(function (err) { - assert.strictEqual(err.message, 'kaboom'); - })); - assert.strictEqual(_dst, _write3); - _read4.push('hello'); -} -{ - var server = http.createServer(function (req, res) { - var rs = new Readable({ - read: function read() { - rs.push('hello'); - rs.push(null); - } - }); - pipeline(rs, res, function () {}); - }); - server.listen(0, function () { - var req = http.request({ - port: server.address().port - }); - req.end(); - req.on('response', function (res) { - var buf = ; - res.on('data', function (data) { - return buf.push(data); - }); - res.on('end', common.mustCall(function () { - assert.deepStrictEqual(Buffer.concat(buf), bufferShim.from('hello')); - server.close(); - })); - }); - }); -} -{ - var _server = http.createServer(function (req, res) { - var sent = false; - var rs = new Readable({ - read: function read() { - if (sent) { - return; - } - sent = true; - rs.push('hello'); - }, - destroy: common.mustCall(function (err, cb) { - // prevents fd leaks by destroying http pipelines - cb(); - }) - }); - pipeline(rs, res, function () {}); - }); - _server.listen(0, function () { - var req = http.request({ - port: _server.address().port - }); - req.end(); - req.on('response', function (res) { - setImmediate(function () { - res.destroy(); - _server.close(); - }); - }); - }); -} -{ - var _server2 = http.createServer(function (req, res) { - var sent = 0; - var rs = new Readable({ - read: function read() { - if (sent++ > 10) { - return; - } - rs.push('hello'); - }, - destroy: common.mustCall(function (err, cb) { - cb(); - }) - }); - pipeline(rs, res, function () {}); - }); - var cnt = 10; - var badSink = new Writable({ - write: function write(data, enc, cb) { - cnt--; - if (cnt === 0) process.nextTick(cb, new Error('kaboom'));else cb(); - } - }); - _server2.listen(0, function () { - var req = http.request({ - port: _server2.address().port - }); - req.end(); - req.on('response', function (res) { - pipeline(res, badSink, common.mustCall(function (err) { - assert.strictEqual(err.message, 'kaboom'); - _server2.close(); - })); - }); - }); -} -{ - var _server3 = http.createServer(function (req, res) { - pipeline(req, res, common.mustCall()); - }); - _server3.listen(0, function () { - var req = http.request({ - port: _server3.address().port - }); - var sent = 0; - var rs = new Readable({ - read: function read() { - if (sent++ > 10) { - return; - } - rs.push('hello'); - } - }); - pipeline(rs, req, common.mustCall(function () { - _server3.close(); - })); - req.on('response', function (res) { - var cnt = 10; - res.on('data', function () { - cnt--; - if (cnt === 0) rs.destroy(); - }); - }); - }); -} -{ - var makeTransform = function makeTransform() { - var tr = new Transform({ - transform: function transform(data, enc, cb) { - cb(null, data); - } - }); - tr.on('close', common.mustCall()); - return tr; - }; - var rs = new Readable({ - read: function read() { - rs.push('hello'); - } - }); - var _cnt = 10; - var ws = new Writable({ - write: function write(data, enc, cb) { - _cnt--; - if (_cnt === 0) return process.nextTick(cb, new Error('kaboom')); - cb(); - } - }); - rs.on('close', common.mustCall()); - ws.on('close', common.mustCall()); - pipeline(rs, makeTransform(), makeTransform(), makeTransform(), makeTransform(), makeTransform(), makeTransform(), ws, common.mustCall(function (err) { - assert.strictEqual(err.message, 'kaboom'); - })); -} -{ - var oldStream = new Stream(); - oldStream.pause = oldStream.resume = function () {}; - oldStream.write = function (data) { - oldStream.emit('data', data); - return true; - }; - oldStream.end = function () { - oldStream.emit('end'); - }; - var _expected = bufferShim.from('hello'), bufferShim.from('world'); - var _rs = new Readable({ - read: function read() { - for (var _i = 0; _i < _expected.length; _i++) { - _rs.push(_expected_i); - } - _rs.push(null); - } - }); - var _ws = new Writable({ - write: function write(data, enc, cb) { - assert.deepStrictEqual(data, _expected.shift()); - cb(); - } - }); - var _finished = false; - _ws.on('finish', function () { - _finished = true; - }); - pipeline(_rs, oldStream, _ws, common.mustCall(function (err) { - assert(!err, 'no error'); - assert(_finished, 'last stream finished'); - })); -} -{ - var _oldStream = new Stream(); - _oldStream.pause = _oldStream.resume = function () {}; - _oldStream.write = function (data) { - _oldStream.emit('data', data); - return true; - }; - _oldStream.end = function () { - _oldStream.emit('end'); - }; - var destroyableOldStream = new Stream(); - destroyableOldStream.pause = destroyableOldStream.resume = function () {}; - destroyableOldStream.destroy = common.mustCall(function () { - destroyableOldStream.emit('close'); - }); - destroyableOldStream.write = function (data) { - destroyableOldStream.emit('data', data); - return true; - }; - destroyableOldStream.end = function () { - destroyableOldStream.emit('end'); - }; - var _rs2 = new Readable({ - read: function read() { - _rs2.destroy(new Error('stop')); - } - }); - var _ws2 = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - var _finished2 = false; - _ws2.on('finish', function () { - _finished2 = true; - }); - pipeline(_rs2, _oldStream, destroyableOldStream, _ws2, common.mustCall(function (err) { - assert.deepStrictEqual(err, new Error('stop')); - assert(!_finished2, 'should not finish'); - })); -} -{ - var run = /*#__PURE__*/function () { - var _ref = _asyncToGenerator(function* () { - var read = new Readable({ - read: function read() {} - }); - var write = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - read.push('data'); - read.push(null); - var finished = false; - write.on('finish', function () { - finished = true; - }); - yield pipelinePromise(read, write); - assert(finished); - }); - return function run() { - return _ref.apply(this, arguments); - }; - }(); - var pipelinePromise = promisify(pipeline); - run(); -} -{ - var _read5 = new Readable({ - read: function read() {} - }); - var _transform = new Transform({ - transform: function transform(data, enc, cb) { - process.nextTick(cb, new Error('kaboom')); - } - }); - var _write4 = new Writable({ - write: function write(data, enc, cb) { - cb(); - } - }); - _read5.on('close', common.mustCall()); - _transform.on('close', common.mustCall()); - _write4.on('close', common.mustCall()); - process.on('uncaughtException', common.mustCall(function (err) { - assert.strictEqual(err.message, 'kaboom'); - })); - var _dst2 = pipeline(_read5, _transform, _write4); - assert.strictEqual(_dst2, _write4); - _read5.push('hello'); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-async-iterators.js
Deleted
@@ -1,682 +0,0 @@ -"use strict"; - -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = genkey(arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } -function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } -function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterableasync)) return method.call(iterable); if (sync && null != (method = iterablesync)) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); } -function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); } -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable, - PassThrough = _require.PassThrough, - pipeline = _require.pipeline; -var assert = require('assert/'); -function tests() { - return _tests.apply(this, arguments); -} // to avoid missing some tests if a promise does not resolve -function _tests() { - _tests = _asyncToGenerator(function* () { - { - var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); - var rs = new Readable({}); - assert.strictEqual(Object.getPrototypeOf(Object.getPrototypeOf(rsSymbol.asyncIterator())), AsyncIteratorPrototype); - } - { - var readable = new Readable({ - objectMode: true, - read: function read() {} - }); - readable.push(0); - readable.push(1); - readable.push(null); - var iter = readableSymbol.asyncIterator(); - assert.strictEqual((yield iter.next()).value, 0); - var _iteratorAbruptCompletion = false; - var _didIteratorError = false; - var _iteratorError; - try { - for (var _iterator = _asyncIterator(iter), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) { - var d = _step.value; - { - assert.strictEqual(d, 1); - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (_iteratorAbruptCompletion && _iterator.return != null) { - yield _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - { - console.log('read without for..await'); - var max = 5; - var _readable = new Readable({ - objectMode: true, - read: function read() {} - }); - var _iter = _readableSymbol.asyncIterator(); - assert.strictEqual(_iter.stream, _readable); - var values = ; - for (var i = 0; i < max; i++) { - values.push(_iter.next()); - } - Promise.all(values).then(common.mustCall(function (values) { - values.forEach(common.mustCall(function (item, i) { - return assert.strictEqual(item.value, 'hello-' + i); - }, 5)); - })); - _readable.push('hello-0'); - _readable.push('hello-1'); - _readable.push('hello-2'); - _readable.push('hello-3'); - _readable.push('hello-4'); - _readable.push(null); - var last = yield _iter.next(); - assert.strictEqual(last.done, true); - } - { - console.log('read without for..await deferred'); - var _readable2 = new Readable({ - objectMode: true, - read: function read() {} - }); - var _iter2 = _readable2Symbol.asyncIterator(); - assert.strictEqual(_iter2.stream, _readable2); - var _values = ; - for (var _i = 0; _i < 3; _i++) { - _values.push(_iter2.next()); - } - _readable2.push('hello-0'); - _readable2.push('hello-1'); - _readable2.push('hello-2'); - var k = 0; - var results1 = yield Promise.all(_values); - results1.forEach(common.mustCall(function (item) { - return assert.strictEqual(item.value, 'hello-' + k++); - }, 3)); - _values = ; - for (var _i2 = 0; _i2 < 2; _i2++) { - _values.push(_iter2.next()); - } - _readable2.push('hello-3'); - _readable2.push('hello-4'); - _readable2.push(null); - var results2 = yield Promise.all(_values); - results2.forEach(common.mustCall(function (item) { - return assert.strictEqual(item.value, 'hello-' + k++); - }, 2)); - var _last = yield _iter2.next(); - assert.strictEqual(_last.done, true); - } - { - console.log('read without for..await with errors'); - var _max = 3; - var _readable3 = new Readable({ - objectMode: true, - read: function read() {} - }); - var _iter3 = _readable3Symbol.asyncIterator(); - assert.strictEqual(_iter3.stream, _readable3); - var _values2 = ; - var errors = ; - var _i3; - for (_i3 = 0; _i3 < _max; _i3++) { - _values2.push(_iter3.next()); - } - for (_i3 = 0; _i3 < 2; _i3++) { - errors.push(_iter3.next()); - } - _readable3.push('hello-0'); - _readable3.push('hello-1'); - _readable3.push('hello-2'); - var resolved = yield Promise.all(_values2); - resolved.forEach(common.mustCall(function (item, i) { - return assert.strictEqual(item.value, 'hello-' + i); - }, _max)); - errors.forEach(function (promise) { - promise.catch(common.mustCall(function (err) { - assert.strictEqual(err.message, 'kaboom'); - })); - }); - _readable3.destroy(new Error('kaboom')); - } - { - console.log('call next() after error'); - var _readable4 = new Readable({ - read: function read() {} - }); - var iterator = _readable4Symbol.asyncIterator(); - var err = new Error('kaboom'); - _readable4.destroy(new Error('kaboom')); - yield function (f, e) { - var success = false; - f().then(function () { - success = true; - throw new Error('should not succeed'); - }).catch(function (e2) { - if (success) { - throw e2; - } - assert.strictEqual(e.message, e2.message); - }); - }(iterator.next.bind(iterator), err); - } - { - console.log('read object mode'); - var _max2 = 42; - var readed = 0; - var received = 0; - var _readable5 = new Readable({ - objectMode: true, - read: function read() { - this.push('hello'); - if (++readed === _max2) { - this.push(null); - } - } - }); - var _iteratorAbruptCompletion2 = false; - var _didIteratorError2 = false; - var _iteratorError2; - try { - for (var _iterator2 = _asyncIterator(_readable5), _step2; _iteratorAbruptCompletion2 = !(_step2 = yield _iterator2.next()).done; _iteratorAbruptCompletion2 = false) { - var _k = _step2.value; - { - received++; - assert.strictEqual(_k, 'hello'); - } - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (_iteratorAbruptCompletion2 && _iterator2.return != null) { - yield _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - assert.strictEqual(readed, received); - } - { - console.log('destroy sync'); - var _readable6 = new Readable({ - objectMode: true, - read: function read() { - this.destroy(new Error('kaboom from read')); - } - }); - var _err; - try { - // eslint-disable-next-line no-unused-vars - var _iteratorAbruptCompletion3 = false; - var _didIteratorError3 = false; - var _iteratorError3; - try { - for (var _iterator3 = _asyncIterator(_readable6), _step3; _iteratorAbruptCompletion3 = !(_step3 = yield _iterator3.next()).done; _iteratorAbruptCompletion3 = false) { - var _k2 = _step3.value; - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (_iteratorAbruptCompletion3 && _iterator3.return != null) { - yield _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - } catch (e) { - _err = e; - } - assert.strictEqual(_err.message, 'kaboom from read'); - } - { - console.log('destroy async'); - var _readable7 = new Readable({ - objectMode: true, - read: function read() { - var _this = this; - if (!this.pushed) { - this.push('hello'); - this.pushed = true; - setImmediate(function () { - _this.destroy(new Error('kaboom')); - }); - } - } - }); - var _received = 0; - var _err2 = null; - try { - // eslint-disable-next-line no-unused-vars - var _iteratorAbruptCompletion4 = false; - var _didIteratorError4 = false; - var _iteratorError4; - try { - for (var _iterator4 = _asyncIterator(_readable7), _step4; _iteratorAbruptCompletion4 = !(_step4 = yield _iterator4.next()).done; _iteratorAbruptCompletion4 = false) { - var _k3 = _step4.value; - { - _received++; - } - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (_iteratorAbruptCompletion4 && _iterator4.return != null) { - yield _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - } catch (e) { - _err2 = e; - } - assert.strictEqual(_err2.message, 'kaboom'); - assert.strictEqual(_received, 1); - } - { - console.log('destroyed by throw'); - var _readable8 = new Readable({ - objectMode: true, - read: function read() { - this.push('hello'); - } - }); - var _err3 = null; - try { - var _iteratorAbruptCompletion5 = false; - var _didIteratorError5 = false; - var _iteratorError5; - try { - for (var _iterator5 = _asyncIterator(_readable8), _step5; _iteratorAbruptCompletion5 = !(_step5 = yield _iterator5.next()).done; _iteratorAbruptCompletion5 = false) { - var _k4 = _step5.value; - { - assert.strictEqual(_k4, 'hello'); - throw new Error('kaboom'); - } - } - } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; - } finally { - try { - if (_iteratorAbruptCompletion5 && _iterator5.return != null) { - yield _iterator5.return(); - } - } finally { - if (_didIteratorError5) { - throw _iteratorError5; - } - } - } - } catch (e) { - _err3 = e; - } - assert.strictEqual(_err3.message, 'kaboom'); - assert.strictEqual(_readable8.destroyed, true); - } - { - console.log('destroyed sync after push'); - var _readable9 = new Readable({ - objectMode: true, - read: function read() { - this.push('hello'); - this.destroy(new Error('kaboom')); - } - }); - var _received2 = 0; - var _err4 = null; - try { - var _iteratorAbruptCompletion6 = false; - var _didIteratorError6 = false; - var _iteratorError6; - try { - for (var _iterator6 = _asyncIterator(_readable9), _step6; _iteratorAbruptCompletion6 = !(_step6 = yield _iterator6.next()).done; _iteratorAbruptCompletion6 = false) { - var _k5 = _step6.value; - { - assert.strictEqual(_k5, 'hello'); - _received2++; - } - } - } catch (err) { - _didIteratorError6 = true; - _iteratorError6 = err; - } finally { - try { - if (_iteratorAbruptCompletion6 && _iterator6.return != null) { - yield _iterator6.return(); - } - } finally { - if (_didIteratorError6) { - throw _iteratorError6; - } - } - } - } catch (e) { - _err4 = e; - } - assert.strictEqual(_err4.message, 'kaboom'); - assert.strictEqual(_received2, 1); - } - { - console.log('push async'); - var _max3 = 42; - var _readed = 0; - var _received3 = 0; - var _readable10 = new Readable({ - objectMode: true, - read: function read() { - var _this2 = this; - setImmediate(function () { - _this2.push('hello'); - if (++_readed === _max3) { - _this2.push(null); - } - }); - } - }); - var _iteratorAbruptCompletion7 = false; - var _didIteratorError7 = false; - var _iteratorError7; - try { - for (var _iterator7 = _asyncIterator(_readable10), _step7; _iteratorAbruptCompletion7 = !(_step7 = yield _iterator7.next()).done; _iteratorAbruptCompletion7 = false) { - var _k6 = _step7.value; - { - _received3++; - assert.strictEqual(_k6, 'hello'); - } - } - } catch (err) { - _didIteratorError7 = true; - _iteratorError7 = err; - } finally { - try { - if (_iteratorAbruptCompletion7 && _iterator7.return != null) { - yield _iterator7.return(); - } - } finally { - if (_didIteratorError7) { - throw _iteratorError7; - } - } - } - assert.strictEqual(_readed, _received3); - } - { - console.log('push binary async'); - var _max4 = 42; - var _readed2 = 0; - var _readable11 = new Readable({ - read: function read() { - var _this3 = this; - setImmediate(function () { - _this3.push('hello'); - if (++_readed2 === _max4) { - _this3.push(null); - } - }); - } - }); - var expected = ''; - _readable11.setEncoding('utf8'); - _readable11.pause(); - _readable11.on('data', function (chunk) { - expected += chunk; - }); - var data = ''; - var _iteratorAbruptCompletion8 = false; - var _didIteratorError8 = false; - var _iteratorError8; - try { - for (var _iterator8 = _asyncIterator(_readable11), _step8; _iteratorAbruptCompletion8 = !(_step8 = yield _iterator8.next()).done; _iteratorAbruptCompletion8 = false) { - var _k7 = _step8.value; - { - data += _k7; - } - } - } catch (err) { - _didIteratorError8 = true; - _iteratorError8 = err; - } finally { - try { - if (_iteratorAbruptCompletion8 && _iterator8.return != null) { - yield _iterator8.return(); - } - } finally { - if (_didIteratorError8) { - throw _iteratorError8; - } - } - } - assert.strictEqual(data, expected); - } - { - console.log('.next() on destroyed stream'); - var _readable12 = new Readable({ - read: function read() { - // no-op - } - }); - _readable12.destroy(); - var _yield$_readable12$Sy = yield _readable12Symbol.asyncIterator().next(), - done = _yield$_readable12$Sy.done; - assert.strictEqual(done, true); - } - { - console.log('.next() on pipelined stream'); - var _readable13 = new Readable({ - read: function read() { - // no-op - } - }); - var passthrough = new PassThrough(); - var _err5 = new Error('kaboom'); - pipeline(_readable13, passthrough, common.mustCall(function (e) { - assert.strictEqual(e, _err5); - })); - _readable13.destroy(_err5); - try { - yield _readable13Symbol.asyncIterator().next(); - } catch (e) { - assert.strictEqual(e, _err5); - } - } - { - console.log('iterating on an ended stream completes'); - var r = new Readable({ - objectMode: true, - read: function read() { - this.push('asdf'); - this.push('hehe'); - this.push(null); - } - }); - // eslint-disable-next-line no-unused-vars - var _iteratorAbruptCompletion9 = false; - var _didIteratorError9 = false; - var _iteratorError9; - try { - for (var _iterator9 = _asyncIterator(r), _step9; _iteratorAbruptCompletion9 = !(_step9 = yield _iterator9.next()).done; _iteratorAbruptCompletion9 = false) { - var a = _step9.value; - } - // eslint-disable-next-line no-unused-vars - } catch (err) { - _didIteratorError9 = true; - _iteratorError9 = err; - } finally { - try { - if (_iteratorAbruptCompletion9 && _iterator9.return != null) { - yield _iterator9.return(); - } - } finally { - if (_didIteratorError9) { - throw _iteratorError9; - } - } - } - var _iteratorAbruptCompletion10 = false; - var _didIteratorError10 = false; - var _iteratorError10; - try { - for (var _iterator10 = _asyncIterator(r), _step10; _iteratorAbruptCompletion10 = !(_step10 = yield _iterator10.next()).done; _iteratorAbruptCompletion10 = false) { - var b = _step10.value; - } - } catch (err) { - _didIteratorError10 = true; - _iteratorError10 = err; - } finally { - try { - if (_iteratorAbruptCompletion10 && _iterator10.return != null) { - yield _iterator10.return(); - } - } finally { - if (_didIteratorError10) { - throw _iteratorError10; - } - } - } - } - { - console.log('destroy mid-stream does not error'); - var _r = new Readable({ - objectMode: true, - read: function read() { - this.push('asdf'); - this.push('hehe'); - } - }); - - // eslint-disable-next-line no-unused-vars - var _iteratorAbruptCompletion11 = false; - var _didIteratorError11 = false; - var _iteratorError11; - try { - for (var _iterator11 = _asyncIterator(_r), _step11; _iteratorAbruptCompletion11 = !(_step11 = yield _iterator11.next()).done; _iteratorAbruptCompletion11 = false) { - var _a = _step11.value; - { - _r.destroy(null); - } - } - } catch (err) { - _didIteratorError11 = true; - _iteratorError11 = err; - } finally { - try { - if (_iteratorAbruptCompletion11 && _iterator11.return != null) { - yield _iterator11.return(); - } - } finally { - if (_didIteratorError11) { - throw _iteratorError11; - } - } - } - } - { - console.log('all next promises must be resolved on end'); - var _r2 = new Readable({ - objectMode: true, - read: function read() {} - }); - var _b = _r2Symbol.asyncIterator(); - var c = _b.next(); - var _d = _b.next(); - _r2.push(null); - assert.deepStrictEqual(yield c, { - done: true, - value: undefined - }); - assert.deepStrictEqual(yield _d, { - done: true, - value: undefined - }); - } - { - console.log('all next promises must be resolved on destroy'); - var _r3 = new Readable({ - objectMode: true, - read: function read() {} - }); - var _b2 = _r3Symbol.asyncIterator(); - var _c = _b2.next(); - var _d2 = _b2.next(); - _r3.destroy(); - assert.deepStrictEqual(yield _c, { - done: true, - value: undefined - }); - assert.deepStrictEqual(yield _d2, { - done: true, - value: undefined - }); - } - { - console.log('all next promises must be resolved on destroy with error'); - var _r4 = new Readable({ - objectMode: true, - read: function read() {} - }); - var _b3 = _r4Symbol.asyncIterator(); - var _c2 = _b3.next(); - var _d3 = _b3.next(); - var _err6 = new Error('kaboom'); - _r4.destroy(_err6); - yield Promise.all(_asyncToGenerator(function* () { - var e; - try { - yield _c2; - } catch (_e) { - e = _e; - } - assert.strictEqual(e, _err6); - })(), _asyncToGenerator(function* () { - var e; - try { - yield _d3; - } catch (_e) { - e = _e; - } - assert.strictEqual(e, _err6); - })()); - } - }); - return _tests.apply(this, arguments); -} -tests().then(common.mustCall(), common.mustNotCall(console.log)); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-hwm-0-async.js
Deleted
@@ -1,37 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); - -// This test ensures that Readable stream will continue to call _read -// for streams with highWaterMark === 0 once the stream returns data -// by calling push() asynchronously. - -var _require = require('../../'), - Readable = _require.Readable; -var count = 5; -var r = new Readable({ - // Called 6 times: First 5 return data, last one signals end of stream. - read: common.mustCall(function () { - process.nextTick(common.mustCall(function () { - if (count--) r.push('a');else r.push(null); - })); - }, 6), - highWaterMark: 0 -}); -r.on('end', common.mustCall()); -r.on('data', common.mustCall(5)); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-hwm-0-no-flow-data.js
Deleted
@@ -1,103 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); - -// Ensure that subscribing the 'data' event will not make the stream flow. -// The 'data' event will require calling read() by hand. -// -// The test is written for the (somewhat rare) highWaterMark: 0 streams to -// specifically catch any regressions that might occur with these streams. - -var assert = require('assert/'); -var _require = require('../../'), - Readable = _require.Readable; -var streamData = 'a', null; - -// Track the calls so we can assert their order later. -var calls = ; -var r = new Readable({ - read: common.mustCall(function () { - calls.push('_read:' + streamData0); - process.nextTick(function () { - calls.push('push:' + streamData0); - r.push(streamData.shift()); - }); - }, streamData.length), - highWaterMark: 0, - // Object mode is used here just for testing convenience. It really - // shouldn't affect the order of events. Just the data and its format. - objectMode: true -}); -assert.strictEqual(r.readableFlowing, null); -r.on('readable', common.mustCall(function () { - calls.push('readable'); -}, 2)); -assert.strictEqual(r.readableFlowing, false); -r.on('data', common.mustCall(function (data) { - calls.push('data:' + data); -}, 1)); -r.on('end', common.mustCall(function () { - calls.push('end'); -})); -assert.strictEqual(r.readableFlowing, false); - -// The stream emits the events asynchronously but that's not guaranteed to -// happen on the next tick (especially since the _read implementation above -// uses process.nextTick). -// -// We use setImmediate here to give the stream enough time to emit all the -// events it's about to emit. -setImmediate(function () { - // Only the _read, push, readable calls have happened. No data must be - // emitted yet. - assert.deepStrictEqual(calls, '_read:a', 'push:a', 'readable'); - - // Calling 'r.read()' should trigger the data event. - assert.strictEqual(r.read(), 'a'); - assert.deepStrictEqual(calls, '_read:a', 'push:a', 'readable', 'data:a'); - - // The next 'read()' will return null because hwm: 0 does not buffer any - // data and the _read implementation above does the push() asynchronously. - // - // Note: This 'null' signals "no data available". It isn't the end-of-stream - // null value as the stream doesn't know yet that it is about to reach the - // end. - // - // Using setImmediate again to give the stream enough time to emit all the - // events it wants to emit. - assert.strictEqual(r.read(), null); - setImmediate(function () { - // There's a new 'readable' event after the data has been pushed. - // The 'end' event will be emitted only after a 'read()'. - // - // This is somewhat special for the case where the '_read' implementation - // calls 'push' asynchronously. If 'push' was synchronous, the 'end' event - // would be emitted here _before_ we call read(). - assert.deepStrictEqual(calls, '_read:a', 'push:a', 'readable', 'data:a', '_read:null', 'push:null', 'readable'); - assert.strictEqual(r.read(), null); - - // While it isn't really specified whether the 'end' event should happen - // synchronously with read() or not, we'll assert the current behavior - // ('end' event happening on the next tick after read()) so any changes - // to it are noted and acknowledged in the future. - assert.deepStrictEqual(calls, '_read:a', 'push:a', 'readable', 'data:a', '_read:null', 'push:null', 'readable'); - process.nextTick(function () { - assert.deepStrictEqual(calls, '_read:a', 'push:a', 'readable', 'data:a', '_read:null', 'push:null', 'readable', 'end'); - }); - }); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-hwm-0.js
Deleted
@@ -1,44 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); - -// This test ensures that Readable stream will call _read() for streams -// with highWaterMark === 0 upon .read(0) instead of just trying to -// emit 'readable' event. - -var assert = require('assert/'); -var _require = require('../../'), - Readable = _require.Readable; -var r = new Readable({ - // must be called only once upon setting 'readable' listener - read: common.mustCall(), - highWaterMark: 0 -}); -var pushedNull = false; -// this will trigger read(0) but must only be called after push(null) -// because the we haven't pushed any data -r.on('readable', common.mustCall(function () { - assert.strictEqual(r.read(), null); - assert.strictEqual(pushedNull, true); -})); -r.on('end', common.mustCall()); -process.nextTick(function () { - assert.strictEqual(r.read(), null); - pushedNull = true; - r.push(null); -}); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-infinite-read.js
Deleted
@@ -1,43 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var assert = require('assert/'); -var _require = require('../../'), - Readable = _require.Readable; -var buf = bufferShim.alloc(8192); -var readable = new Readable({ - read: common.mustCall(function () { - this.push(buf); - }, 31) -}); -var i = 0; -readable.on('readable', common.mustCall(function () { - if (i++ === 10) { - // We will just terminate now. - process.removeAllListeners('readable'); - return; - } - var data = readable.read(); - // TODO(mcollina): there is something odd in the highWaterMark logic - // investigate. - if (i === 1) { - assert.strictEqual(data.length, 8192 * 2); - } else { - assert.strictEqual(data.length, 8192 * 3); - } -}, 11)); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-no-unneeded-readable.js
Deleted
@@ -1,73 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable, - PassThrough = _require.PassThrough; -function test(r) { - var wrapper = new Readable({ - read: function read() { - var data = r.read(); - if (data) { - wrapper.push(data); - return; - } - r.once('readable', function () { - data = r.read(); - if (data) { - wrapper.push(data); - } - // else the end event should fire - }); - } - }); - - r.once('end', function () { - wrapper.push(null); - }); - wrapper.resume(); - wrapper.once('end', common.mustCall()); -} -{ - var source = new Readable({ - read: function read() {} - }); - source.push('foo'); - source.push('bar'); - source.push(null); - var pt = source.pipe(new PassThrough()); - test(pt); -} -{ - // This is the underlying cause of the above test case. - var pushChunks = 'foo', 'bar'; - var r = new Readable({ - read: function read() { - var chunk = pushChunks.shift(); - if (chunk) { - // synchronous call - r.push(chunk); - } else { - // asynchronous call - process.nextTick(function () { - return r.push(null); - }); - } - } - }); - test(r); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-object-multi-push-async.js
Deleted
@@ -1,180 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var assert = require('assert/'); -var _require = require('../../'), - Readable = _require.Readable; -var MAX = 42; -var BATCH = 10; -{ - var fetchData = function fetchData(cb) { - if (i > MAX) { - setTimeout(cb, 10, null, ); - } else { - var array = ; - var max = i + BATCH; - for (; i < max; i++) { - array.push(i); - } - setTimeout(cb, 10, null, array); - } - }; - var readable = new Readable({ - objectMode: true, - read: common.mustCall(function () { - var _this = this; - console.log('>> READ'); - fetchData(function (err, data) { - if (err) { - _this.destroy(err); - return; - } - if (data.length === 0) { - console.log('pushing null'); - _this.push(null); - return; - } - console.log('pushing'); - data.forEach(function (d) { - return _this.push(d); - }); - }); - }, Math.floor(MAX / BATCH) + 2) - }); - var i = 0; - readable.on('readable', function () { - var data; - console.log('readable emitted'); - while (data = readable.read()) { - console.log(data); - } - }); - readable.on('end', common.mustCall(function () { - assert.strictEqual(i, (Math.floor(MAX / BATCH) + 1) * BATCH); - })); -} -{ - var _fetchData = function _fetchData(cb) { - if (_i > MAX) { - setTimeout(cb, 10, null, ); - } else { - var array = ; - var max = _i + BATCH; - for (; _i < max; _i++) { - array.push(_i); - } - setTimeout(cb, 10, null, array); - } - }; - var _readable = new Readable({ - objectMode: true, - read: common.mustCall(function () { - var _this2 = this; - console.log('>> READ'); - _fetchData(function (err, data) { - if (err) { - _this2.destroy(err); - return; - } - if (data.length === 0) { - console.log('pushing null'); - _this2.push(null); - return; - } - console.log('pushing'); - data.forEach(function (d) { - return _this2.push(d); - }); - }); - }, Math.floor(MAX / BATCH) + 2) - }); - var _i = 0; - _readable.on('data', function (data) { - console.log('data emitted', data); - }); - _readable.on('end', common.mustCall(function () { - assert.strictEqual(_i, (Math.floor(MAX / BATCH) + 1) * BATCH); - })); -} -{ - var _fetchData2 = function _fetchData2(cb) { - var array = ; - var max = _i2 + BATCH; - for (; _i2 < max; _i2++) { - array.push(_i2); - } - setTimeout(cb, 10, null, array); - }; - var _readable2 = new Readable({ - objectMode: true, - read: common.mustCall(function () { - var _this3 = this; - console.log('>> READ'); - _fetchData2(function (err, data) { - if (err) { - _this3.destroy(err); - return; - } - console.log('pushing'); - data.forEach(function (d) { - return _this3.push(d); - }); - if (dataBATCH - 1 >= MAX) { - console.log('pushing null'); - _this3.push(null); - } - }); - }, Math.floor(MAX / BATCH) + 1) - }); - var _i2 = 0; - _readable2.on('data', function (data) { - console.log('data emitted', data); - }); - _readable2.on('end', common.mustCall(function () { - assert.strictEqual(_i2, (Math.floor(MAX / BATCH) + 1) * BATCH); - })); -} -{ - var _readable3 = new Readable({ - objectMode: true, - read: common.mustNotCall() - }); - _readable3.on('data', common.mustNotCall()); - _readable3.push(null); - var nextTickPassed = false; - process.nextTick(function () { - nextTickPassed = true; - }); - _readable3.on('end', common.mustCall(function () { - assert.strictEqual(nextTickPassed, true); - })); -} -{ - var _readable4 = new Readable({ - objectMode: true, - read: common.mustCall() - }); - _readable4.on('data', function (data) { - console.log('data emitted', data); - }); - _readable4.on('end', common.mustCall()); - setImmediate(function () { - _readable4.push('aaa'); - _readable4.push(null); - }); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-pause-and-resume.js
Deleted
@@ -1,50 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var _require = require('../../'), - Readable = _require.Readable; -var common = require('../common'); -var ticks = 18; -var expectedData = 19; -var rs = new Readable({ - objectMode: true, - read: function read() { - if (ticks-- > 0) return process.nextTick(function () { - return rs.push({}); - }); - rs.push({}); - rs.push(null); - } -}); -rs.on('end', common.mustCall()); -readAndPause(); -function readAndPause() { - // Does a on(data) -> pause -> wait -> resume -> on(data) ... loop. - // Expects on(data) to never fire if the stream is paused. - var ondata = common.mustCall(function (data) { - rs.pause(); - expectedData--; - if (expectedData <= 0) return; - setImmediate(function () { - rs.removeListener('data', ondata); - readAndPause(); - rs.resume(); - }); - }, 1); // only call ondata once - - rs.on('data', ondata); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-readable-then-resume.js
Deleted
@@ -1,43 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable; - -// This test verifies that a stream could be resumed after -// removing the readable event in the same tick - -check(new Readable({ - objectMode: true, - highWaterMark: 1, - read: function read() { - if (!this.first) { - this.push('hello'); - this.first = true; - return; - } - this.push(null); - } -})); -function check(s) { - var readableListener = common.mustNotCall(); - s.on('readable', readableListener); - s.on('end', common.mustCall()); - s.removeListener('readable', readableListener); - s.resume(); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-resume-hwm.js
Deleted
@@ -1,38 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var _require = require('../../'), - Readable = _require.Readable; - -// readable.resume() should not lead to a ._read() call being scheduled -// when we exceed the high water mark already. - -var readable = new Readable({ - read: common.mustNotCall(), - highWaterMark: 100 -}); - -// Fill up the internal buffer so that we definitely exceed the HWM: -for (var i = 0; i < 10; i++) readable.push('a'.repeat(200)); - -// Call resume, and pause after one chunk. -// The .pause() is just so that we don’t empty the buffer fully, which would -// be a valid reason to call ._read(). -readable.resume(); -readable.once('data', common.mustCall(function () { - return readable.pause(); -})); -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-setEncoding-existing-buffers.js
Deleted
@@ -1,74 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -require('../common'); -var _require = require('../../'), - Readable = _require.Readable; -var assert = require('assert/'); -{ - // Call .setEncoding() while there are bytes already in the buffer. - var r = new Readable({ - read: function read() {} - }); - r.push(bufferShim.from('a')); - r.push(bufferShim.from('b')); - r.setEncoding('utf8'); - var chunks = ; - r.on('data', function (chunk) { - return chunks.push(chunk); - }); - process.nextTick(function () { - assert.deepStrictEqual(chunks, 'ab'); - }); -} -{ - // Call .setEncoding() while the buffer contains a complete, - // but chunked character. - var _r = new Readable({ - read: function read() {} - }); - _r.push(bufferShim.from(0xf0)); - _r.push(bufferShim.from(0x9f)); - _r.push(bufferShim.from(0x8e)); - _r.push(bufferShim.from(0x89)); - _r.setEncoding('utf8'); - var _chunks = ; - _r.on('data', function (chunk) { - return _chunks.push(chunk); - }); - process.nextTick(function () { - assert.deepStrictEqual(_chunks, '🎉'); - }); -} -{ - // Call .setEncoding() while the buffer contains an incomplete character, - // and finish the character later. - var _r2 = new Readable({ - read: function read() {} - }); - _r2.push(bufferShim.from(0xf0)); - _r2.push(bufferShim.from(0x9f)); - _r2.setEncoding('utf8'); - _r2.push(bufferShim.from(0x8e)); - _r2.push(bufferShim.from(0x89)); - var _chunks2 = ; - _r2.on('data', function (chunk) { - return _chunks2.push(chunk); - }); - process.nextTick(function () { - assert.deepStrictEqual(_chunks2, '🎉'); - }); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-readable-setEncoding-null.js
Deleted
@@ -1,29 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ - -require('../common'); -var assert = require('assert/'); -var _require = require('../../'), - Readable = _require.Readable; -{ - var readable = new Readable({ - encoding: 'hex' - }); - assert.strictEqual(readable._readableState.encoding, 'hex'); - readable.setEncoding(null); - assert.strictEqual(readable._readableState.encoding, 'utf8'); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-writable-write-cb-twice.js
Deleted
@@ -1,62 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -var common = require('../common'); -var _require = require('../../'), - Writable = _require.Writable; -{ - // Sync + Sync - var writable = new Writable({ - write: common.mustCall(function (buf, enc, cb) { - cb(); - common.expectsError(cb, { - code: 'ERR_MULTIPLE_CALLBACK', - type: Error - }); - }) - }); - writable.write('hi'); -} -{ - // Sync + Async - var _writable = new Writable({ - write: common.mustCall(function (buf, enc, cb) { - cb(); - process.nextTick(function () { - common.expectsError(cb, { - code: 'ERR_MULTIPLE_CALLBACK', - type: Error - }); - }); - }) - }); - _writable.write('hi'); -} -{ - // Async + Async - var _writable2 = new Writable({ - write: common.mustCall(function (buf, enc, cb) { - process.nextTick(cb); - process.nextTick(function () { - common.expectsError(cb, { - code: 'ERR_MULTIPLE_CALLBACK', - type: Error - }); - }); - }) - }); - _writable2.write('hi'); -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
View file
_service:tar_scm:readable-stream-3.6.2.tar.gz/test/parallel/test-stream-write-destroy.js
Deleted
@@ -1,87 +0,0 @@ -"use strict"; - -/*<replacement>*/ -var bufferShim = require('safe-buffer').Buffer; -/*</replacement>*/ -require('../common'); -var assert = require('assert/'); -var _require = require('../../'), - Writable = _require.Writable; - -// Test interaction between calling .destroy() on a writable and pending -// writes. - -for (var _i = 0, _arr = false, true; _i < _arr.length; _i++) { - var withPendingData = _arr_i; - var _loop = function _loop() { - var useEnd = _arr2_i2; - var callbacks = ; - var w = new Writable({ - write: function write(data, enc, cb) { - callbacks.push(cb); - }, - // Effectively disable the HWM to observe 'drain' events more easily. - highWaterMark: 1 - }); - var chunksWritten = 0; - var drains = 0; - var finished = false; - w.on('drain', function () { - return drains++; - }); - w.on('finish', function () { - return finished = true; - }); - w.write('abc', function () { - return chunksWritten++; - }); - assert.strictEqual(chunksWritten, 0); - assert.strictEqual(drains, 0); - callbacks.shift()(); - assert.strictEqual(chunksWritten, 1); - assert.strictEqual(drains, 1); - if (withPendingData) { - // Test 2 cases: There either is or is not data still in the write queue. - // (The second write will never actually get executed either way.) - w.write('def', function () { - return chunksWritten++; - }); - } - if (useEnd) { - // Again, test 2 cases: Either we indicate that we want to end the - // writable or not. - w.end('ghi', function () { - return chunksWritten++; - }); - } else { - w.write('ghi', function () { - return chunksWritten++; - }); - } - assert.strictEqual(chunksWritten, 1); - w.destroy(); - assert.strictEqual(chunksWritten, 1); - callbacks.shift()(); - assert.strictEqual(chunksWritten, 2); - assert.strictEqual(callbacks.length, 0); - assert.strictEqual(drains, 1); - - // When we used `.end()`, we see the 'finished' event if and only if - // we actually finished processing the write queue. - assert.strictEqual(finished, !withPendingData && useEnd); - }; - for (var _i2 = 0, _arr2 = false, true; _i2 < _arr2.length; _i2++) { - _loop(); - } -} -; -(function () { - var t = require('tap'); - t.pass('sync run'); -})(); -var _list = process.listeners('uncaughtException'); -process.removeAllListeners('uncaughtException'); -_list.pop(); -_list.forEach(function (e) { - return process.on('uncaughtException', e); -}); \ No newline at end of file
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2