devsho

comment error fixed by devsho

Showing 1000 changed files with 4778 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 +.wrap{
2 + display: flex;
3 +}
4 +.list_board{
5 + display: block;
6 + float: left;
7 + width: 20%;
8 +}
9 +.board_btn{
10 + display: block;
11 + height: 50px;
12 + text-align: center;
13 + padding-top: 12px;
14 + padding-bottom: 10px;
15 + border-style: none;
16 + text-decoration: none;
17 + background-color: #F8F9FA;
18 + color: black;
19 +}
20 +
21 +.board_btn:link{
22 + background-color: #F8F9FA;
23 +}
24 +.board_btn:visited{
25 + background-color: #F8F9FA;
26 +}
27 +.board_btn:hover{
28 + color: black;
29 + background-color: #e0e0e0;
30 +}
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../detect-libc/bin/detect-libc.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../detect-libc/bin/detect-libc.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@ECHO off
2 +SETLOCAL
3 +CALL :find_dp0
4 +
5 +IF EXIST "%dp0%\node.exe" (
6 + SET "_prog=%dp0%\node.exe"
7 +) ELSE (
8 + SET "_prog=node"
9 + SET PATHEXT=%PATHEXT:;.JS;=;%
10 +)
11 +
12 +"%_prog%" "%dp0%\..\detect-libc\bin\detect-libc.js" %*
13 +ENDLOCAL
14 +EXIT /b %errorlevel%
15 +:find_dp0
16 +SET dp0=%~dp0
17 +EXIT /b
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + & "$basedir/node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
13 + $ret=$LASTEXITCODE
14 +} else {
15 + & "node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
16 + $ret=$LASTEXITCODE
17 +}
18 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../prebuild-install/bin.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../prebuild-install/bin.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@ECHO off
2 +SETLOCAL
3 +CALL :find_dp0
4 +
5 +IF EXIST "%dp0%\node.exe" (
6 + SET "_prog=%dp0%\node.exe"
7 +) ELSE (
8 + SET "_prog=node"
9 + SET PATHEXT=%PATHEXT:;.JS;=;%
10 +)
11 +
12 +"%_prog%" "%dp0%\..\prebuild-install\bin.js" %*
13 +ENDLOCAL
14 +EXIT /b %errorlevel%
15 +:find_dp0
16 +SET dp0=%~dp0
17 +EXIT /b
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + & "$basedir/node$exe" "$basedir/../prebuild-install/bin.js" $args
13 + $ret=$LASTEXITCODE
14 +} else {
15 + & "node$exe" "$basedir/../prebuild-install/bin.js" $args
16 + $ret=$LASTEXITCODE
17 +}
18 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../rc/cli.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../rc/cli.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@ECHO off
2 +SETLOCAL
3 +CALL :find_dp0
4 +
5 +IF EXIST "%dp0%\node.exe" (
6 + SET "_prog=%dp0%\node.exe"
7 +) ELSE (
8 + SET "_prog=node"
9 + SET PATHEXT=%PATHEXT:;.JS;=;%
10 +)
11 +
12 +"%_prog%" "%dp0%\..\rc\cli.js" %*
13 +ENDLOCAL
14 +EXIT /b %errorlevel%
15 +:find_dp0
16 +SET dp0=%~dp0
17 +EXIT /b
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + & "$basedir/node$exe" "$basedir/../rc/cli.js" $args
13 + $ret=$LASTEXITCODE
14 +} else {
15 + & "node$exe" "$basedir/../rc/cli.js" $args
16 + $ret=$LASTEXITCODE
17 +}
18 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../semver/bin/semver.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@ECHO off
2 +SETLOCAL
3 +CALL :find_dp0
4 +
5 +IF EXIST "%dp0%\node.exe" (
6 + SET "_prog=%dp0%\node.exe"
7 +) ELSE (
8 + SET "_prog=node"
9 + SET PATHEXT=%PATHEXT:;.JS;=;%
10 +)
11 +
12 +"%_prog%" "%dp0%\..\semver\bin\semver.js" %*
13 +ENDLOCAL
14 +EXIT /b %errorlevel%
15 +:find_dp0
16 +SET dp0=%~dp0
17 +EXIT /b
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + & "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
13 + $ret=$LASTEXITCODE
14 +} else {
15 + & "node$exe" "$basedir/../semver/bin/semver.js" $args
16 + $ret=$LASTEXITCODE
17 +}
18 +exit $ret
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../which/bin/which" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../which/bin/which" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@ECHO off
2 +SETLOCAL
3 +CALL :find_dp0
4 +
5 +IF EXIST "%dp0%\node.exe" (
6 + SET "_prog=%dp0%\node.exe"
7 +) ELSE (
8 + SET "_prog=node"
9 + SET PATHEXT=%PATHEXT:;.JS;=;%
10 +)
11 +
12 +"%_prog%" "%dp0%\..\which\bin\which" %*
13 +ENDLOCAL
14 +EXIT /b %errorlevel%
15 +:find_dp0
16 +SET dp0=%~dp0
17 +EXIT /b
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + & "$basedir/node$exe" "$basedir/../which/bin/which" $args
13 + $ret=$LASTEXITCODE
14 +} else {
15 + & "node$exe" "$basedir/../which/bin/which" $args
16 + $ret=$LASTEXITCODE
17 +}
18 +exit $ret
1 +'use strict';
2 +module.exports = function () {
3 + return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g;
4 +};
1 +The MIT License (MIT)
2 +
3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +{
2 + "_from": "ansi-regex@^2.0.0",
3 + "_id": "ansi-regex@2.1.1",
4 + "_inBundle": false,
5 + "_integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
6 + "_location": "/ansi-regex",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "ansi-regex@^2.0.0",
12 + "name": "ansi-regex",
13 + "escapedName": "ansi-regex",
14 + "rawSpec": "^2.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "^2.0.0"
17 + },
18 + "_requiredBy": [
19 + "/strip-ansi"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
22 + "_shasum": "c3b33ab5ee360d86e0e628f0468ae7ef27d654df",
23 + "_spec": "ansi-regex@^2.0.0",
24 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\strip-ansi",
25 + "author": {
26 + "name": "Sindre Sorhus",
27 + "email": "sindresorhus@gmail.com",
28 + "url": "sindresorhus.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/chalk/ansi-regex/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "Regular expression for matching ANSI escape codes",
36 + "devDependencies": {
37 + "ava": "0.17.0",
38 + "xo": "0.16.0"
39 + },
40 + "engines": {
41 + "node": ">=0.10.0"
42 + },
43 + "files": [
44 + "index.js"
45 + ],
46 + "homepage": "https://github.com/chalk/ansi-regex#readme",
47 + "keywords": [
48 + "ansi",
49 + "styles",
50 + "color",
51 + "colour",
52 + "colors",
53 + "terminal",
54 + "console",
55 + "cli",
56 + "string",
57 + "tty",
58 + "escape",
59 + "formatting",
60 + "rgb",
61 + "256",
62 + "shell",
63 + "xterm",
64 + "command-line",
65 + "text",
66 + "regex",
67 + "regexp",
68 + "re",
69 + "match",
70 + "test",
71 + "find",
72 + "pattern"
73 + ],
74 + "license": "MIT",
75 + "maintainers": [
76 + {
77 + "name": "Sindre Sorhus",
78 + "email": "sindresorhus@gmail.com",
79 + "url": "sindresorhus.com"
80 + },
81 + {
82 + "name": "Joshua Appelman",
83 + "email": "jappelman@xebia.com",
84 + "url": "jbnicolai.com"
85 + },
86 + {
87 + "name": "JD Ballard",
88 + "email": "i.am.qix@gmail.com",
89 + "url": "github.com/qix-"
90 + }
91 + ],
92 + "name": "ansi-regex",
93 + "repository": {
94 + "type": "git",
95 + "url": "git+https://github.com/chalk/ansi-regex.git"
96 + },
97 + "scripts": {
98 + "test": "xo && ava --verbose",
99 + "view-supported": "node fixtures/view-codes.js"
100 + },
101 + "version": "2.1.1",
102 + "xo": {
103 + "rules": {
104 + "guard-for-in": 0,
105 + "no-loop-func": 0
106 + }
107 + }
108 +}
1 +# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex)
2 +
3 +> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
4 +
5 +
6 +## Install
7 +
8 +```
9 +$ npm install --save ansi-regex
10 +```
11 +
12 +
13 +## Usage
14 +
15 +```js
16 +const ansiRegex = require('ansi-regex');
17 +
18 +ansiRegex().test('\u001b[4mcake\u001b[0m');
19 +//=> true
20 +
21 +ansiRegex().test('cake');
22 +//=> false
23 +
24 +'\u001b[4mcake\u001b[0m'.match(ansiRegex());
25 +//=> ['\u001b[4m', '\u001b[0m']
26 +```
27 +
28 +## FAQ
29 +
30 +### Why do you test for codes not in the ECMA 48 standard?
31 +
32 +Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. If I recall correctly, we test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
33 +
34 +On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
35 +
36 +
37 +## License
38 +
39 +MIT © [Sindre Sorhus](http://sindresorhus.com)
1 +Copyright (c) 2015, Rebecca Turner <me@re-becca.org>
2 +
3 +Permission to use, copy, modify, and/or distribute this software for any
4 +purpose with or without fee is hereby granted, provided that the above
5 +copyright notice and this permission notice appear in all copies.
6 +
7 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 +
1 +aproba
2 +======
3 +
4 +A ridiculously light-weight function argument validator
5 +
6 +```
7 +var validate = require("aproba")
8 +
9 +function myfunc(a, b, c) {
10 + // `a` must be a string, `b` a number, `c` a function
11 + validate('SNF', arguments) // [a,b,c] is also valid
12 +}
13 +
14 +myfunc('test', 23, function () {}) // ok
15 +myfunc(123, 23, function () {}) // type error
16 +myfunc('test', 23) // missing arg error
17 +myfunc('test', 23, function () {}, true) // too many args error
18 +
19 +```
20 +
21 +Valid types are:
22 +
23 +| type | description
24 +| :--: | :----------
25 +| * | matches any type
26 +| A | `Array.isArray` OR an `arguments` object
27 +| S | typeof == string
28 +| N | typeof == number
29 +| F | typeof == function
30 +| O | typeof == object and not type A and not type E
31 +| B | typeof == boolean
32 +| E | `instanceof Error` OR `null` **(special: see below)**
33 +| Z | == `null`
34 +
35 +Validation failures throw one of three exception types, distinguished by a
36 +`code` property of `EMISSINGARG`, `EINVALIDTYPE` or `ETOOMANYARGS`.
37 +
38 +If you pass in an invalid type then it will throw with a code of
39 +`EUNKNOWNTYPE`.
40 +
41 +If an **error** argument is found and is not null then the remaining
42 +arguments are optional. That is, if you say `ESO` then that's like using a
43 +non-magical `E` in: `E|ESO|ZSO`.
44 +
45 +### But I have optional arguments?!
46 +
47 +You can provide more than one signature by separating them with pipes `|`.
48 +If any signature matches the arguments then they'll be considered valid.
49 +
50 +So for example, say you wanted to write a signature for
51 +`fs.createWriteStream`. The docs for it describe it thusly:
52 +
53 +```
54 +fs.createWriteStream(path[, options])
55 +```
56 +
57 +This would be a signature of `SO|S`. That is, a string and and object, or
58 +just a string.
59 +
60 +Now, if you read the full `fs` docs, you'll see that actually path can ALSO
61 +be a buffer. And options can be a string, that is:
62 +```
63 +path <String> | <Buffer>
64 +options <String> | <Object>
65 +```
66 +
67 +To reproduce this you have to fully enumerate all of the possible
68 +combinations and that implies a signature of `SO|SS|OO|OS|S|O`. The
69 +awkwardness is a feature: It reminds you of the complexity you're adding to
70 +your API when you do this sort of thing.
71 +
72 +
73 +### Browser support
74 +
75 +This has no dependencies and should work in browsers, though you'll have
76 +noisier stack traces.
77 +
78 +### Why this exists
79 +
80 +I wanted a very simple argument validator. It needed to do two things:
81 +
82 +1. Be more concise and easier to use than assertions
83 +
84 +2. Not encourage an infinite bikeshed of DSLs
85 +
86 +This is why types are specified by a single character and there's no such
87 +thing as an optional argument.
88 +
89 +This is not intended to validate user data. This is specifically about
90 +asserting the interface of your functions.
91 +
92 +If you need greater validation, I encourage you to write them by hand or
93 +look elsewhere.
94 +
1 +'use strict'
2 +
3 +function isArguments (thingy) {
4 + return thingy != null && typeof thingy === 'object' && thingy.hasOwnProperty('callee')
5 +}
6 +
7 +var types = {
8 + '*': {label: 'any', check: function () { return true }},
9 + A: {label: 'array', check: function (thingy) { return Array.isArray(thingy) || isArguments(thingy) }},
10 + S: {label: 'string', check: function (thingy) { return typeof thingy === 'string' }},
11 + N: {label: 'number', check: function (thingy) { return typeof thingy === 'number' }},
12 + F: {label: 'function', check: function (thingy) { return typeof thingy === 'function' }},
13 + O: {label: 'object', check: function (thingy) { return typeof thingy === 'object' && thingy != null && !types.A.check(thingy) && !types.E.check(thingy) }},
14 + B: {label: 'boolean', check: function (thingy) { return typeof thingy === 'boolean' }},
15 + E: {label: 'error', check: function (thingy) { return thingy instanceof Error }},
16 + Z: {label: 'null', check: function (thingy) { return thingy == null }}
17 +}
18 +
19 +function addSchema (schema, arity) {
20 + var group = arity[schema.length] = arity[schema.length] || []
21 + if (group.indexOf(schema) === -1) group.push(schema)
22 +}
23 +
24 +var validate = module.exports = function (rawSchemas, args) {
25 + if (arguments.length !== 2) throw wrongNumberOfArgs(['SA'], arguments.length)
26 + if (!rawSchemas) throw missingRequiredArg(0, 'rawSchemas')
27 + if (!args) throw missingRequiredArg(1, 'args')
28 + if (!types.S.check(rawSchemas)) throw invalidType(0, ['string'], rawSchemas)
29 + if (!types.A.check(args)) throw invalidType(1, ['array'], args)
30 + var schemas = rawSchemas.split('|')
31 + var arity = {}
32 +
33 + schemas.forEach(function (schema) {
34 + for (var ii = 0; ii < schema.length; ++ii) {
35 + var type = schema[ii]
36 + if (!types[type]) throw unknownType(ii, type)
37 + }
38 + if (/E.*E/.test(schema)) throw moreThanOneError(schema)
39 + addSchema(schema, arity)
40 + if (/E/.test(schema)) {
41 + addSchema(schema.replace(/E.*$/, 'E'), arity)
42 + addSchema(schema.replace(/E/, 'Z'), arity)
43 + if (schema.length === 1) addSchema('', arity)
44 + }
45 + })
46 + var matching = arity[args.length]
47 + if (!matching) {
48 + throw wrongNumberOfArgs(Object.keys(arity), args.length)
49 + }
50 + for (var ii = 0; ii < args.length; ++ii) {
51 + var newMatching = matching.filter(function (schema) {
52 + var type = schema[ii]
53 + var typeCheck = types[type].check
54 + return typeCheck(args[ii])
55 + })
56 + if (!newMatching.length) {
57 + var labels = matching.map(function (schema) {
58 + return types[schema[ii]].label
59 + }).filter(function (schema) { return schema != null })
60 + throw invalidType(ii, labels, args[ii])
61 + }
62 + matching = newMatching
63 + }
64 +}
65 +
66 +function missingRequiredArg (num) {
67 + return newException('EMISSINGARG', 'Missing required argument #' + (num + 1))
68 +}
69 +
70 +function unknownType (num, type) {
71 + return newException('EUNKNOWNTYPE', 'Unknown type ' + type + ' in argument #' + (num + 1))
72 +}
73 +
74 +function invalidType (num, expectedTypes, value) {
75 + var valueType
76 + Object.keys(types).forEach(function (typeCode) {
77 + if (types[typeCode].check(value)) valueType = types[typeCode].label
78 + })
79 + return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' +
80 + englishList(expectedTypes) + ' but got ' + valueType)
81 +}
82 +
83 +function englishList (list) {
84 + return list.join(', ').replace(/, ([^,]+)$/, ' or $1')
85 +}
86 +
87 +function wrongNumberOfArgs (expected, got) {
88 + var english = englishList(expected)
89 + var args = expected.every(function (ex) { return ex.length === 1 })
90 + ? 'argument'
91 + : 'arguments'
92 + return newException('EWRONGARGCOUNT', 'Expected ' + english + ' ' + args + ' but got ' + got)
93 +}
94 +
95 +function moreThanOneError (schema) {
96 + return newException('ETOOMANYERRORTYPES',
97 + 'Only one error type per argument signature is allowed, more than one found in "' + schema + '"')
98 +}
99 +
100 +function newException (code, msg) {
101 + var e = new Error(msg)
102 + e.code = code
103 + if (Error.captureStackTrace) Error.captureStackTrace(e, validate)
104 + return e
105 +}
1 +{
2 + "_from": "aproba@^1.0.3",
3 + "_id": "aproba@1.2.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
6 + "_location": "/aproba",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "aproba@^1.0.3",
12 + "name": "aproba",
13 + "escapedName": "aproba",
14 + "rawSpec": "^1.0.3",
15 + "saveSpec": null,
16 + "fetchSpec": "^1.0.3"
17 + },
18 + "_requiredBy": [
19 + "/gauge"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
22 + "_shasum": "6802e6264efd18c790a1b0d517f0f2627bf2c94a",
23 + "_spec": "aproba@^1.0.3",
24 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\gauge",
25 + "author": {
26 + "name": "Rebecca Turner",
27 + "email": "me@re-becca.org"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/iarna/aproba/issues"
31 + },
32 + "bundleDependencies": false,
33 + "dependencies": {},
34 + "deprecated": false,
35 + "description": "A ridiculously light-weight argument validator (now browser friendly)",
36 + "devDependencies": {
37 + "standard": "^10.0.3",
38 + "tap": "^10.0.2"
39 + },
40 + "directories": {
41 + "test": "test"
42 + },
43 + "files": [
44 + "index.js"
45 + ],
46 + "homepage": "https://github.com/iarna/aproba",
47 + "keywords": [
48 + "argument",
49 + "validate"
50 + ],
51 + "license": "ISC",
52 + "main": "index.js",
53 + "name": "aproba",
54 + "repository": {
55 + "type": "git",
56 + "url": "git+https://github.com/iarna/aproba.git"
57 + },
58 + "scripts": {
59 + "test": "standard && tap -j3 test/*.js"
60 + },
61 + "version": "1.2.0"
62 +}
1 +Hi, figured we could actually use a changelog now:
2 +
3 +## 1.1.5 2018-05-24
4 +
5 +* [#92](https://github.com/iarna/are-we-there-yet/pull/92) Fix bug where
6 + `finish` would throw errors when including `TrackerStream` objects in
7 + `TrackerGroup` collections. (@brianloveswords)
8 +
9 +## 1.1.4 2017-04-21
10 +
11 +* Fix typo in package.json
12 +
13 +## 1.1.3 2017-04-21
14 +
15 +* Improve documentation and limit files included in the distribution.
16 +
17 +## 1.1.2 2016-03-15
18 +
19 +* Add tracker group cycle detection and tests for it
20 +
21 +## 1.1.1 2016-01-29
22 +
23 +* Fix a typo in stream completion tracker
24 +
25 +## 1.1.0 2016-01-29
26 +
27 +* Rewrote completion percent computation to be low impact– no more walking a
28 + tree of completion groups every time we need this info. Previously, with
29 + medium sized tree of completion groups, even a relatively modest number of
30 + calls to the top level `completed()` method would result in absurd numbers
31 + of calls overall as it walked down the tree. We now, instead, keep track as
32 + we bubble up changes, so the computation is limited to when data changes and
33 + to the depth of that one branch, instead of _every_ node. (Plus, we were already
34 + incurring _this_ cost, since we already bubbled out changes.)
35 +* Moved different tracker types out to their own files.
36 +* Made tests test for TOO MANY events too.
37 +* Standarized the source code formatting
1 +Copyright (c) 2015, Rebecca Turner
2 +
3 +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4 +
5 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1 +are-we-there-yet
2 +----------------
3 +
4 +Track complex hiearchies of asynchronous task completion statuses. This is
5 +intended to give you a way of recording and reporting the progress of the big
6 +recursive fan-out and gather type workflows that are so common in async.
7 +
8 +What you do with this completion data is up to you, but the most common use case is to
9 +feed it to one of the many progress bar modules.
10 +
11 +Most progress bar modules include a rudamentary version of this, but my
12 +needs were more complex.
13 +
14 +Usage
15 +=====
16 +
17 +```javascript
18 +var TrackerGroup = require("are-we-there-yet").TrackerGroup
19 +
20 +var top = new TrackerGroup("program")
21 +
22 +var single = top.newItem("one thing", 100)
23 +single.completeWork(20)
24 +
25 +console.log(top.completed()) // 0.2
26 +
27 +fs.stat("file", function(er, stat) {
28 + if (er) throw er
29 + var stream = top.newStream("file", stat.size)
30 + console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete
31 + // and 50% * 20% == 10%
32 + fs.createReadStream("file").pipe(stream).on("data", function (chunk) {
33 + // do stuff with chunk
34 + })
35 + top.on("change", function (name) {
36 + // called each time a chunk is read from "file"
37 + // top.completed() will start at 0.1 and fill up to 0.6 as the file is read
38 + })
39 +})
40 +```
41 +
42 +Shared Methods
43 +==============
44 +
45 +* var completed = tracker.completed()
46 +
47 +Implemented in: `Tracker`, `TrackerGroup`, `TrackerStream`
48 +
49 +Returns the ratio of completed work to work to be done. Range of 0 to 1.
50 +
51 +* tracker.finish()
52 +
53 +Implemented in: `Tracker`, `TrackerGroup`
54 +
55 +Marks the tracker as completed. With a TrackerGroup this marks all of its
56 +components as completed.
57 +
58 +Marks all of the components of this tracker as finished, which in turn means
59 +that `tracker.completed()` for this will now be 1.
60 +
61 +This will result in one or more `change` events being emitted.
62 +
63 +Events
64 +======
65 +
66 +All tracker objects emit `change` events with the following arguments:
67 +
68 +```
69 +function (name, completed, tracker)
70 +```
71 +
72 +`name` is the name of the tracker that originally emitted the event,
73 +or if it didn't have one, the first containing tracker group that had one.
74 +
75 +`completed` is the percent complete (as returned by `tracker.completed()` method).
76 +
77 +`tracker` is the tracker object that you are listening for events on.
78 +
79 +TrackerGroup
80 +============
81 +
82 +* var tracker = new TrackerGroup(**name**)
83 +
84 + * **name** *(optional)* - The name of this tracker group, used in change
85 + notifications if the component updating didn't have a name. Defaults to undefined.
86 +
87 +Creates a new empty tracker aggregation group. These are trackers whose
88 +completion status is determined by the completion status of other trackers.
89 +
90 +* tracker.addUnit(**otherTracker**, **weight**)
91 +
92 + * **otherTracker** - Any of the other are-we-there-yet tracker objects
93 + * **weight** *(optional)* - The weight to give the tracker, defaults to 1.
94 +
95 +Adds the **otherTracker** to this aggregation group. The weight determines
96 +how long you expect this tracker to take to complete in proportion to other
97 +units. So for instance, if you add one tracker with a weight of 1 and
98 +another with a weight of 2, you're saying the second will take twice as long
99 +to complete as the first. As such, the first will account for 33% of the
100 +completion of this tracker and the second will account for the other 67%.
101 +
102 +Returns **otherTracker**.
103 +
104 +* var subGroup = tracker.newGroup(**name**, **weight**)
105 +
106 +The above is exactly equivalent to:
107 +
108 +```javascript
109 + var subGroup = tracker.addUnit(new TrackerGroup(name), weight)
110 +```
111 +
112 +* var subItem = tracker.newItem(**name**, **todo**, **weight**)
113 +
114 +The above is exactly equivalent to:
115 +
116 +```javascript
117 + var subItem = tracker.addUnit(new Tracker(name, todo), weight)
118 +```
119 +
120 +* var subStream = tracker.newStream(**name**, **todo**, **weight**)
121 +
122 +The above is exactly equivalent to:
123 +
124 +```javascript
125 + var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)
126 +```
127 +
128 +* console.log( tracker.debug() )
129 +
130 +Returns a tree showing the completion of this tracker group and all of its
131 +children, including recursively entering all of the children.
132 +
133 +Tracker
134 +=======
135 +
136 +* var tracker = new Tracker(**name**, **todo**)
137 +
138 + * **name** *(optional)* The name of this counter to report in change
139 + events. Defaults to undefined.
140 + * **todo** *(optional)* The amount of work todo (a number). Defaults to 0.
141 +
142 +Ordinarily these are constructed as a part of a tracker group (via
143 +`newItem`).
144 +
145 +* var completed = tracker.completed()
146 +
147 +Returns the ratio of completed work to work to be done. Range of 0 to 1. If
148 +total work to be done is 0 then it will return 0.
149 +
150 +* tracker.addWork(**todo**)
151 +
152 + * **todo** A number to add to the amount of work to be done.
153 +
154 +Increases the amount of work to be done, thus decreasing the completion
155 +percentage. Triggers a `change` event.
156 +
157 +* tracker.completeWork(**completed**)
158 +
159 + * **completed** A number to add to the work complete
160 +
161 +Increase the amount of work complete, thus increasing the completion percentage.
162 +Will never increase the work completed past the amount of work todo. That is,
163 +percentages > 100% are not allowed. Triggers a `change` event.
164 +
165 +* tracker.finish()
166 +
167 +Marks this tracker as finished, tracker.completed() will now be 1. Triggers
168 +a `change` event.
169 +
170 +TrackerStream
171 +=============
172 +
173 +* var tracker = new TrackerStream(**name**, **size**, **options**)
174 +
175 + * **name** *(optional)* The name of this counter to report in change
176 + events. Defaults to undefined.
177 + * **size** *(optional)* The number of bytes being sent through this stream.
178 + * **options** *(optional)* A hash of stream options
179 +
180 +The tracker stream object is a pass through stream that updates an internal
181 +tracker object each time a block passes through. It's intended to track
182 +downloads, file extraction and other related activities. You use it by piping
183 +your data source into it and then using it as your data source.
184 +
185 +If your data has a length attribute then that's used as the amount of work
186 +completed when the chunk is passed through. If it does not (eg, object
187 +streams) then each chunk counts as completing 1 unit of work, so your size
188 +should be the total number of objects being streamed.
189 +
190 +* tracker.addWork(**todo**)
191 +
192 + * **todo** Increase the expected overall size by **todo** bytes.
193 +
194 +Increases the amount of work to be done, thus decreasing the completion
195 +percentage. Triggers a `change` event.
1 +'use strict'
2 +exports.TrackerGroup = require('./tracker-group.js')
3 +exports.Tracker = require('./tracker.js')
4 +exports.TrackerStream = require('./tracker-stream.js')
1 +{
2 + "_from": "are-we-there-yet@~1.1.2",
3 + "_id": "are-we-there-yet@1.1.7",
4 + "_inBundle": false,
5 + "_integrity": "sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==",
6 + "_location": "/are-we-there-yet",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "are-we-there-yet@~1.1.2",
12 + "name": "are-we-there-yet",
13 + "escapedName": "are-we-there-yet",
14 + "rawSpec": "~1.1.2",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.1.2"
17 + },
18 + "_requiredBy": [
19 + "/npmlog"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz",
22 + "_shasum": "b15474a932adab4ff8a50d9adfa7e4e926f21146",
23 + "_spec": "are-we-there-yet@~1.1.2",
24 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\npmlog",
25 + "author": {
26 + "name": "Rebecca Turner",
27 + "url": "http://re-becca.org"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/iarna/are-we-there-yet/issues"
31 + },
32 + "bundleDependencies": false,
33 + "dependencies": {
34 + "delegates": "^1.0.0",
35 + "readable-stream": "^2.0.6"
36 + },
37 + "deprecated": false,
38 + "description": "Keep track of the overall completion of many disparate processes",
39 + "devDependencies": {
40 + "standard": "^11.0.1",
41 + "tap": "^12.0.1"
42 + },
43 + "files": [
44 + "index.js",
45 + "tracker-base.js",
46 + "tracker-group.js",
47 + "tracker-stream.js",
48 + "tracker.js",
49 + "CHANGES.md"
50 + ],
51 + "homepage": "https://github.com/iarna/are-we-there-yet",
52 + "license": "ISC",
53 + "main": "index.js",
54 + "name": "are-we-there-yet",
55 + "repository": {
56 + "type": "git",
57 + "url": "git+https://github.com/iarna/are-we-there-yet.git"
58 + },
59 + "scripts": {
60 + "test": "standard && tap test/*.js"
61 + },
62 + "version": "1.1.7"
63 +}
1 +'use strict'
2 +var EventEmitter = require('events').EventEmitter
3 +var util = require('util')
4 +
5 +var trackerId = 0
6 +var TrackerBase = module.exports = function (name) {
7 + EventEmitter.call(this)
8 + this.id = ++trackerId
9 + this.name = name
10 +}
11 +util.inherits(TrackerBase, EventEmitter)
1 +'use strict'
2 +var util = require('util')
3 +var TrackerBase = require('./tracker-base.js')
4 +var Tracker = require('./tracker.js')
5 +var TrackerStream = require('./tracker-stream.js')
6 +
7 +var TrackerGroup = module.exports = function (name) {
8 + TrackerBase.call(this, name)
9 + this.parentGroup = null
10 + this.trackers = []
11 + this.completion = {}
12 + this.weight = {}
13 + this.totalWeight = 0
14 + this.finished = false
15 + this.bubbleChange = bubbleChange(this)
16 +}
17 +util.inherits(TrackerGroup, TrackerBase)
18 +
19 +function bubbleChange (trackerGroup) {
20 + return function (name, completed, tracker) {
21 + trackerGroup.completion[tracker.id] = completed
22 + if (trackerGroup.finished) return
23 + trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup)
24 + }
25 +}
26 +
27 +TrackerGroup.prototype.nameInTree = function () {
28 + var names = []
29 + var from = this
30 + while (from) {
31 + names.unshift(from.name)
32 + from = from.parentGroup
33 + }
34 + return names.join('/')
35 +}
36 +
37 +TrackerGroup.prototype.addUnit = function (unit, weight) {
38 + if (unit.addUnit) {
39 + var toTest = this
40 + while (toTest) {
41 + if (unit === toTest) {
42 + throw new Error(
43 + 'Attempted to add tracker group ' +
44 + unit.name + ' to tree that already includes it ' +
45 + this.nameInTree(this))
46 + }
47 + toTest = toTest.parentGroup
48 + }
49 + unit.parentGroup = this
50 + }
51 + this.weight[unit.id] = weight || 1
52 + this.totalWeight += this.weight[unit.id]
53 + this.trackers.push(unit)
54 + this.completion[unit.id] = unit.completed()
55 + unit.on('change', this.bubbleChange)
56 + if (!this.finished) this.emit('change', unit.name, this.completion[unit.id], unit)
57 + return unit
58 +}
59 +
60 +TrackerGroup.prototype.completed = function () {
61 + if (this.trackers.length === 0) return 0
62 + var valPerWeight = 1 / this.totalWeight
63 + var completed = 0
64 + for (var ii = 0; ii < this.trackers.length; ii++) {
65 + var trackerId = this.trackers[ii].id
66 + completed += valPerWeight * this.weight[trackerId] * this.completion[trackerId]
67 + }
68 + return completed
69 +}
70 +
71 +TrackerGroup.prototype.newGroup = function (name, weight) {
72 + return this.addUnit(new TrackerGroup(name), weight)
73 +}
74 +
75 +TrackerGroup.prototype.newItem = function (name, todo, weight) {
76 + return this.addUnit(new Tracker(name, todo), weight)
77 +}
78 +
79 +TrackerGroup.prototype.newStream = function (name, todo, weight) {
80 + return this.addUnit(new TrackerStream(name, todo), weight)
81 +}
82 +
83 +TrackerGroup.prototype.finish = function () {
84 + this.finished = true
85 + if (!this.trackers.length) this.addUnit(new Tracker(), 1, true)
86 + for (var ii = 0; ii < this.trackers.length; ii++) {
87 + var tracker = this.trackers[ii]
88 + tracker.finish()
89 + tracker.removeListener('change', this.bubbleChange)
90 + }
91 + this.emit('change', this.name, 1, this)
92 +}
93 +
94 +var buffer = ' '
95 +TrackerGroup.prototype.debug = function (depth) {
96 + depth = depth || 0
97 + var indent = depth ? buffer.substr(0, depth) : ''
98 + var output = indent + (this.name || 'top') + ': ' + this.completed() + '\n'
99 + this.trackers.forEach(function (tracker) {
100 + if (tracker instanceof TrackerGroup) {
101 + output += tracker.debug(depth + 1)
102 + } else {
103 + output += indent + ' ' + tracker.name + ': ' + tracker.completed() + '\n'
104 + }
105 + })
106 + return output
107 +}
1 +'use strict'
2 +var util = require('util')
3 +var stream = require('readable-stream')
4 +var delegate = require('delegates')
5 +var Tracker = require('./tracker.js')
6 +
7 +var TrackerStream = module.exports = function (name, size, options) {
8 + stream.Transform.call(this, options)
9 + this.tracker = new Tracker(name, size)
10 + this.name = name
11 + this.id = this.tracker.id
12 + this.tracker.on('change', delegateChange(this))
13 +}
14 +util.inherits(TrackerStream, stream.Transform)
15 +
16 +function delegateChange (trackerStream) {
17 + return function (name, completion, tracker) {
18 + trackerStream.emit('change', name, completion, trackerStream)
19 + }
20 +}
21 +
22 +TrackerStream.prototype._transform = function (data, encoding, cb) {
23 + this.tracker.completeWork(data.length ? data.length : 1)
24 + this.push(data)
25 + cb()
26 +}
27 +
28 +TrackerStream.prototype._flush = function (cb) {
29 + this.tracker.finish()
30 + cb()
31 +}
32 +
33 +delegate(TrackerStream.prototype, 'tracker')
34 + .method('completed')
35 + .method('addWork')
36 + .method('finish')
1 +'use strict'
2 +var util = require('util')
3 +var TrackerBase = require('./tracker-base.js')
4 +
5 +var Tracker = module.exports = function (name, todo) {
6 + TrackerBase.call(this, name)
7 + this.workDone = 0
8 + this.workTodo = todo || 0
9 +}
10 +util.inherits(Tracker, TrackerBase)
11 +
12 +Tracker.prototype.completed = function () {
13 + return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
14 +}
15 +
16 +Tracker.prototype.addWork = function (work) {
17 + this.workTodo += work
18 + this.emit('change', this.name, this.completed(), this)
19 +}
20 +
21 +Tracker.prototype.completeWork = function (work) {
22 + this.workDone += work
23 + if (this.workDone > this.workTodo) this.workDone = this.workTodo
24 + this.emit('change', this.name, this.completed(), this)
25 +}
26 +
27 +Tracker.prototype.finish = function () {
28 + this.workTodo = this.workDone = 1
29 + this.emit('change', this.name, 1, this)
30 +}
1 +# Compiled source #
2 +###################
3 +*.com
4 +*.class
5 +*.dll
6 +*.exe
7 +*.o
8 +*.so
9 +
10 +# Packages #
11 +############
12 +# it's better to unpack these files and commit the raw source
13 +# git has its own built in compression methods
14 +*.7z
15 +*.dmg
16 +*.gz
17 +*.iso
18 +*.jar
19 +*.rar
20 +*.tar
21 +*.zip
22 +
23 +# Logs and databases #
24 +######################
25 +*.log
26 +*.sql
27 +*.sqlite
28 +
29 +# OS generated files #
30 +######################
31 +.DS_Store*
32 +ehthumbs.db
33 +Icon?
34 +Thumbs.db
35 +
36 +# Node.js #
37 +###########
38 +lib-cov
39 +*.seed
40 +*.log
41 +*.csv
42 +*.dat
43 +*.out
44 +*.pid
45 +*.gz
46 +
47 +pids
48 +logs
49 +results
50 +
51 +node_modules
52 +npm-debug.log
53 +
54 +# Components #
55 +##############
56 +
57 +/build
58 +/components
...\ No newline at end of file ...\ No newline at end of file
1 +language: node_js
2 +node_js:
3 + - "0.4"
4 + - "0.6"
5 + - "0.8"
6 + - "0.10"
...\ No newline at end of file ...\ No newline at end of file
1 +# Array Series [![Build Status](https://travis-ci.org/component/array-parallel.png)](https://travis-ci.org/component/array-parallel)
2 +
3 +Call an array of asynchronous functions in parallel
4 +
5 +### API
6 +
7 +#### parallel(fns[, context[, callback]])
8 +
9 +```js
10 +var parallel = require('array-parallel')
11 +
12 +parallel([
13 + function (done) {
14 + done()
15 + }
16 +], this, function (err) {
17 +
18 +})
19 +```
20 +
21 +#### fns
22 +
23 +`fns` is an array of functions to call in parallel.
24 +The argument signature should be:
25 +
26 +```js
27 +function (done) {
28 + done(new Error())
29 + // or
30 + done(null, result)
31 +}
32 +```
33 +
34 +That is, each function should only take a `done` as an argument.
35 +Each callback should only take an `Error` as the first argument,
36 +or a value as the second.
37 +
38 +#### context
39 +
40 +Optional context to pass to each `fn`.
41 +Basically `fn.call(context, done)`.
42 +
43 +#### callback(err, results)
44 +
45 +```js
46 +function (err, results) {
47 +
48 +}
49 +```
50 +
51 +Only argument is an `Error` argument.
52 +It will be the first error retrieved from all the `fns`.
53 +`results` will be an array of results from each `fn`,
54 +thus this could be considered an asynchronous version of `[].map`.
55 +
56 +### License
57 +
58 +The MIT License (MIT)
59 +
60 +Copyright (c) 2013 Jonathan Ong me@jongleberry.com
61 +
62 +Permission is hereby granted, free of charge, to any person obtaining a copy
63 +of this software and associated documentation files (the "Software"), to deal
64 +in the Software without restriction, including without limitation the rights
65 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66 +copies of the Software, and to permit persons to whom the Software is
67 +furnished to do so, subject to the following conditions:
68 +
69 +The above copyright notice and this permission notice shall be included in
70 +all copies or substantial portions of the Software.
71 +
72 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
78 +THE SOFTWARE.
1 +{
2 + "name": "array-parallel",
3 + "description": "Call an array of asynchronous functions in parallel",
4 + "repo": "array-parallel",
5 + "version": "0.1.3",
6 + "main": "index.js",
7 + "scripts": [
8 + "index.js"
9 + ],
10 + "license": "MIT"
11 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module.exports = function parallel(fns, context, callback) {
2 + if (!callback) {
3 + if (typeof context === 'function') {
4 + callback = context
5 + context = null
6 + } else {
7 + callback = noop
8 + }
9 + }
10 +
11 + var pending = fns && fns.length
12 + if (!pending) return callback(null, []);
13 +
14 + var finished = false
15 + var results = new Array(pending)
16 +
17 + fns.forEach(context ? function (fn, i) {
18 + fn.call(context, maybeDone(i))
19 + } : function (fn, i) {
20 + fn(maybeDone(i))
21 + })
22 +
23 + function maybeDone(i) {
24 + return function (err, result) {
25 + if (finished) return;
26 +
27 + if (err) {
28 + callback(err, results)
29 + finished = true
30 + return
31 + }
32 +
33 + results[i] = result
34 +
35 + if (!--pending) callback(null, results);
36 + }
37 + }
38 +}
39 +
40 +function noop() {}
1 +{
2 + "_from": "array-parallel@~0.1.3",
3 + "_id": "array-parallel@0.1.3",
4 + "_inBundle": false,
5 + "_integrity": "sha1-j3hTCJJu1apHjEfmTRszS2wMlH0=",
6 + "_location": "/array-parallel",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "array-parallel@~0.1.3",
12 + "name": "array-parallel",
13 + "escapedName": "array-parallel",
14 + "rawSpec": "~0.1.3",
15 + "saveSpec": null,
16 + "fetchSpec": "~0.1.3"
17 + },
18 + "_requiredBy": [
19 + "/gm"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/array-parallel/-/array-parallel-0.1.3.tgz",
22 + "_shasum": "8f785308926ed5aa478c47e64d1b334b6c0c947d",
23 + "_spec": "array-parallel@~0.1.3",
24 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\gm",
25 + "author": {
26 + "name": "Jonathan Ong",
27 + "email": "me@jongleberry.com",
28 + "url": "http://jongleberry.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/component/array-parallel/issues",
32 + "email": "me@jongleberry.com"
33 + },
34 + "bundleDependencies": false,
35 + "deprecated": false,
36 + "description": "Call an array of asynchronous functions in parallel",
37 + "homepage": "https://github.com/component/array-parallel#readme",
38 + "license": "MIT",
39 + "name": "array-parallel",
40 + "repository": {
41 + "type": "git",
42 + "url": "git+https://github.com/component/array-parallel.git"
43 + },
44 + "scripts": {
45 + "test": "node test"
46 + },
47 + "version": "0.1.3"
48 +}
1 +var assert = require('assert')
2 +var parallel = require('./')
3 +
4 +var a, b, c
5 +parallel([
6 + function (done) {
7 + setTimeout(function () {
8 + done(null, a = 0)
9 + }, 5)
10 + },
11 + function (done) {
12 + setTimeout(function () {
13 + done(null, b = 1)
14 + }, 10)
15 + },
16 + function (done) {
17 + setTimeout(function () {
18 + done(null, c = 2)
19 + }, 15)
20 + }
21 +], function (err, results) {
22 + assert.equal(a, 0)
23 + assert.equal(b, 1)
24 + assert.equal(c, 2)
25 +
26 + assert.deepEqual(results, [0, 1, 2])
27 +})
28 +
29 +var d, e
30 +parallel([
31 + function (done) {
32 + setTimeout(function () {
33 + d = 1
34 + done(new Error('message'))
35 + }, 5)
36 + },
37 + function (done) {
38 + setTimeout(function () {
39 + e = 2
40 + done()
41 + }, 10)
42 + }
43 +], function (err) {
44 + assert.equal(err.message, 'message')
45 + assert.equal(d, 1)
46 + assert.equal(e, undefined)
47 +})
48 +
49 +var context = 'hello'
50 +parallel([function (done) {
51 + assert.equal(this, context)
52 +}], context)
53 +
54 +var f
55 +parallel([function (done) {
56 + f = true
57 + done()
58 +}])
59 +
60 +process.nextTick(function () {
61 + assert.equal(f, true)
62 +})
...\ No newline at end of file ...\ No newline at end of file
1 +# Compiled source #
2 +###################
3 +*.com
4 +*.class
5 +*.dll
6 +*.exe
7 +*.o
8 +*.so
9 +
10 +# Packages #
11 +############
12 +# it's better to unpack these files and commit the raw source
13 +# git has its own built in compression methods
14 +*.7z
15 +*.dmg
16 +*.gz
17 +*.iso
18 +*.jar
19 +*.rar
20 +*.tar
21 +*.zip
22 +
23 +# Logs and databases #
24 +######################
25 +*.log
26 +*.sql
27 +*.sqlite
28 +
29 +# OS generated files #
30 +######################
31 +.DS_Store*
32 +ehthumbs.db
33 +Icon?
34 +Thumbs.db
35 +
36 +# Node.js #
37 +###########
38 +lib-cov
39 +*.seed
40 +*.log
41 +*.csv
42 +*.dat
43 +*.out
44 +*.pid
45 +*.gz
46 +
47 +pids
48 +logs
49 +results
50 +
51 +node_modules
52 +npm-debug.log
53 +
54 +# Components #
55 +##############
56 +
57 +/build
58 +/components
...\ No newline at end of file ...\ No newline at end of file
1 +language: node_js
2 +node_js:
3 + - "0.8"
4 + - "0.10"
...\ No newline at end of file ...\ No newline at end of file
1 +# Array Series [![Build Status](https://travis-ci.org/component/array-series.png)](https://travis-ci.org/component/array-series)
2 +
3 +Call an array of asynchronous functions in series
4 +
5 +### API
6 +
7 +#### series(fns[, context[, callback]])
8 +
9 +```js
10 +var series = require('array-series')
11 +
12 +series([
13 + function (done) {
14 + done()
15 + }
16 +], this, function (err) {
17 +
18 +})
19 +```
20 +
21 +#### fns
22 +
23 +`fns` is an array of functions to call in series.
24 +The argument signature should be:
25 +
26 +```js
27 +function (done) {
28 + done(new Error())
29 + // or
30 + done()
31 +}
32 +```
33 +
34 +That is, each function should only take a `done` as an argument.
35 +Each callback should only take an optional `Error` as an argument.
36 +
37 +#### context
38 +
39 +Optional context to pass to each `fn`.
40 +Basically `fn.call(context, done)`.
41 +
42 +#### callback(err)
43 +
44 +```js
45 +function (err) {
46 +
47 +}
48 +```
49 +
50 +Only argument is an `Error` argument.
51 +It will return the first error in the series of functions that returns an error,
52 +and no function after will be called.
53 +
54 +### License
55 +
56 +The MIT License (MIT)
57 +
58 +Copyright (c) 2013 Jonathan Ong me@jongleberry.com
59 +
60 +Permission is hereby granted, free of charge, to any person obtaining a copy
61 +of this software and associated documentation files (the "Software"), to deal
62 +in the Software without restriction, including without limitation the rights
63 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
64 +copies of the Software, and to permit persons to whom the Software is
65 +furnished to do so, subject to the following conditions:
66 +
67 +The above copyright notice and this permission notice shall be included in
68 +all copies or substantial portions of the Software.
69 +
70 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
71 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
72 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
73 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
74 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
75 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
76 +THE SOFTWARE.
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "array-series",
3 + "description": "Call an array of asynchronous functions in series",
4 + "repo": "component/array-series",
5 + "version": "0.1.5",
6 + "main": "index.js",
7 + "scripts": [
8 + "index.js"
9 + ],
10 + "license": "MIT"
11 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module.exports = function series(fns, context, callback) {
2 + if (!callback) {
3 + if (typeof context === 'function') {
4 + callback = context
5 + context = null
6 + } else {
7 + callback = noop
8 + }
9 + }
10 +
11 + if (!(fns && fns.length)) return callback();
12 +
13 + fns = fns.slice(0)
14 +
15 + var call = context
16 + ? function () {
17 + fns.length
18 + ? fns.shift().call(context, next)
19 + : callback()
20 + }
21 + : function () {
22 + fns.length
23 + ? fns.shift()(next)
24 + : callback()
25 + }
26 +
27 + call()
28 +
29 + function next(err) {
30 + err ? callback(err) : call()
31 + }
32 +}
33 +
34 +function noop() {}
1 +{
2 + "_from": "array-series@~0.1.5",
3 + "_id": "array-series@0.1.5",
4 + "_inBundle": false,
5 + "_integrity": "sha1-3103v8XC7wdV4qpPkv6ufUtaly8=",
6 + "_location": "/array-series",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "array-series@~0.1.5",
12 + "name": "array-series",
13 + "escapedName": "array-series",
14 + "rawSpec": "~0.1.5",
15 + "saveSpec": null,
16 + "fetchSpec": "~0.1.5"
17 + },
18 + "_requiredBy": [
19 + "/gm"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/array-series/-/array-series-0.1.5.tgz",
22 + "_shasum": "df5d37bfc5c2ef0755e2aa4f92feae7d4b5a972f",
23 + "_spec": "array-series@~0.1.5",
24 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\gm",
25 + "author": {
26 + "name": "Jonathan Ong",
27 + "email": "me@jongleberry.com",
28 + "url": "http://jongleberry.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/component/array-series/issues",
32 + "email": "me@jongleberry.com"
33 + },
34 + "bundleDependencies": false,
35 + "deprecated": false,
36 + "description": "Call an array of asynchronous functions in series",
37 + "homepage": "https://github.com/component/array-series#readme",
38 + "license": "MIT",
39 + "name": "array-series",
40 + "repository": {
41 + "type": "git",
42 + "url": "git+https://github.com/component/array-series.git"
43 + },
44 + "scripts": {
45 + "test": "node test"
46 + },
47 + "version": "0.1.5"
48 +}
1 +var assert = require('assert')
2 +var series = require('./')
3 +
4 +var a, b, c
5 +
6 +series([
7 + function (done) {
8 + a = 1
9 + process.nextTick(done)
10 + check('a')
11 + },
12 + function (done) {
13 + b = 2
14 + process.nextTick(done)
15 + check('b')
16 + },
17 + function (done) {
18 + c = 3
19 + process.nextTick(done)
20 + check('c')
21 + }
22 +], function (err) {
23 + assert.ifError(err)
24 + assert.equal(a, 1)
25 + assert.equal(b, 2)
26 + assert.equal(c, 3)
27 +})
28 +
29 +function check(x) {
30 + switch (x) {
31 + case 'a':
32 + assert.equal(a, 1)
33 + assert.equal(b, undefined)
34 + assert.equal(c, undefined)
35 + break
36 + case 'b':
37 + assert.equal(a, 1)
38 + assert.equal(b, 2)
39 + assert.equal(c, undefined)
40 + break
41 + case 'c':
42 + assert.equal(a, 1)
43 + assert.equal(b, 2)
44 + assert.equal(c, 3)
45 + break
46 + }
47 +}
48 +
49 +var context = 'hello'
50 +series([function (done) {
51 + assert.equal(this, context)
52 + done()
53 +}], context)
54 +
55 +var finished
56 +series([], function (err) {
57 + finished = true
58 +})
59 +
60 +process.nextTick(function () {
61 + if (!finished)
62 + throw new Error('Failed with no functions.');
63 +})
64 +
65 +var r, d, o
66 +series([
67 + function (done) {
68 + r = 1
69 + process.nextTick(done)
70 + },
71 + function (done) {
72 + d = 0
73 + process.nextTick(function () {
74 + done(new Error('message'))
75 + })
76 + },
77 + function (done) {
78 + o = 0
79 + process.nextTick(done)
80 + }
81 +], function (err) {
82 + assert.equal(err.message, 'message')
83 + assert.equal(r, 1)
84 + assert.equal(d, 0)
85 + assert.equal(o, undefined)
86 +})
87 +
88 +console.log('Array series tests pass!')
...\ No newline at end of file ...\ No newline at end of file
1 +sudo: false
2 +arch:
3 + - amd64
4 + - ppc64le
5 +language: node_js
6 +node_js:
7 + - '6'
8 + - '8'
9 + - '10'
10 + - '12'
11 + - '14'
12 + - '15'
13 + - lts/*
14 +notifications:
15 + email:
16 + - rod@vagg.org
17 + - matteo.collina@gmail.com
1 +'use strict'
2 +
3 +const { Buffer } = require('buffer')
4 +const symbol = Symbol.for('BufferList')
5 +
6 +function BufferList (buf) {
7 + if (!(this instanceof BufferList)) {
8 + return new BufferList(buf)
9 + }
10 +
11 + BufferList._init.call(this, buf)
12 +}
13 +
14 +BufferList._init = function _init (buf) {
15 + Object.defineProperty(this, symbol, { value: true })
16 +
17 + this._bufs = []
18 + this.length = 0
19 +
20 + if (buf) {
21 + this.append(buf)
22 + }
23 +}
24 +
25 +BufferList.prototype._new = function _new (buf) {
26 + return new BufferList(buf)
27 +}
28 +
29 +BufferList.prototype._offset = function _offset (offset) {
30 + if (offset === 0) {
31 + return [0, 0]
32 + }
33 +
34 + let tot = 0
35 +
36 + for (let i = 0; i < this._bufs.length; i++) {
37 + const _t = tot + this._bufs[i].length
38 + if (offset < _t || i === this._bufs.length - 1) {
39 + return [i, offset - tot]
40 + }
41 + tot = _t
42 + }
43 +}
44 +
45 +BufferList.prototype._reverseOffset = function (blOffset) {
46 + const bufferId = blOffset[0]
47 + let offset = blOffset[1]
48 +
49 + for (let i = 0; i < bufferId; i++) {
50 + offset += this._bufs[i].length
51 + }
52 +
53 + return offset
54 +}
55 +
56 +BufferList.prototype.get = function get (index) {
57 + if (index > this.length || index < 0) {
58 + return undefined
59 + }
60 +
61 + const offset = this._offset(index)
62 +
63 + return this._bufs[offset[0]][offset[1]]
64 +}
65 +
66 +BufferList.prototype.slice = function slice (start, end) {
67 + if (typeof start === 'number' && start < 0) {
68 + start += this.length
69 + }
70 +
71 + if (typeof end === 'number' && end < 0) {
72 + end += this.length
73 + }
74 +
75 + return this.copy(null, 0, start, end)
76 +}
77 +
78 +BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
79 + if (typeof srcStart !== 'number' || srcStart < 0) {
80 + srcStart = 0
81 + }
82 +
83 + if (typeof srcEnd !== 'number' || srcEnd > this.length) {
84 + srcEnd = this.length
85 + }
86 +
87 + if (srcStart >= this.length) {
88 + return dst || Buffer.alloc(0)
89 + }
90 +
91 + if (srcEnd <= 0) {
92 + return dst || Buffer.alloc(0)
93 + }
94 +
95 + const copy = !!dst
96 + const off = this._offset(srcStart)
97 + const len = srcEnd - srcStart
98 + let bytes = len
99 + let bufoff = (copy && dstStart) || 0
100 + let start = off[1]
101 +
102 + // copy/slice everything
103 + if (srcStart === 0 && srcEnd === this.length) {
104 + if (!copy) {
105 + // slice, but full concat if multiple buffers
106 + return this._bufs.length === 1
107 + ? this._bufs[0]
108 + : Buffer.concat(this._bufs, this.length)
109 + }
110 +
111 + // copy, need to copy individual buffers
112 + for (let i = 0; i < this._bufs.length; i++) {
113 + this._bufs[i].copy(dst, bufoff)
114 + bufoff += this._bufs[i].length
115 + }
116 +
117 + return dst
118 + }
119 +
120 + // easy, cheap case where it's a subset of one of the buffers
121 + if (bytes <= this._bufs[off[0]].length - start) {
122 + return copy
123 + ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
124 + : this._bufs[off[0]].slice(start, start + bytes)
125 + }
126 +
127 + if (!copy) {
128 + // a slice, we need something to copy in to
129 + dst = Buffer.allocUnsafe(len)
130 + }
131 +
132 + for (let i = off[0]; i < this._bufs.length; i++) {
133 + const l = this._bufs[i].length - start
134 +
135 + if (bytes > l) {
136 + this._bufs[i].copy(dst, bufoff, start)
137 + bufoff += l
138 + } else {
139 + this._bufs[i].copy(dst, bufoff, start, start + bytes)
140 + bufoff += l
141 + break
142 + }
143 +
144 + bytes -= l
145 +
146 + if (start) {
147 + start = 0
148 + }
149 + }
150 +
151 + // safeguard so that we don't return uninitialized memory
152 + if (dst.length > bufoff) return dst.slice(0, bufoff)
153 +
154 + return dst
155 +}
156 +
157 +BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
158 + start = start || 0
159 + end = typeof end !== 'number' ? this.length : end
160 +
161 + if (start < 0) {
162 + start += this.length
163 + }
164 +
165 + if (end < 0) {
166 + end += this.length
167 + }
168 +
169 + if (start === end) {
170 + return this._new()
171 + }
172 +
173 + const startOffset = this._offset(start)
174 + const endOffset = this._offset(end)
175 + const buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
176 +
177 + if (endOffset[1] === 0) {
178 + buffers.pop()
179 + } else {
180 + buffers[buffers.length - 1] = buffers[buffers.length - 1].slice(0, endOffset[1])
181 + }
182 +
183 + if (startOffset[1] !== 0) {
184 + buffers[0] = buffers[0].slice(startOffset[1])
185 + }
186 +
187 + return this._new(buffers)
188 +}
189 +
190 +BufferList.prototype.toString = function toString (encoding, start, end) {
191 + return this.slice(start, end).toString(encoding)
192 +}
193 +
194 +BufferList.prototype.consume = function consume (bytes) {
195 + // first, normalize the argument, in accordance with how Buffer does it
196 + bytes = Math.trunc(bytes)
197 + // do nothing if not a positive number
198 + if (Number.isNaN(bytes) || bytes <= 0) return this
199 +
200 + while (this._bufs.length) {
201 + if (bytes >= this._bufs[0].length) {
202 + bytes -= this._bufs[0].length
203 + this.length -= this._bufs[0].length
204 + this._bufs.shift()
205 + } else {
206 + this._bufs[0] = this._bufs[0].slice(bytes)
207 + this.length -= bytes
208 + break
209 + }
210 + }
211 +
212 + return this
213 +}
214 +
215 +BufferList.prototype.duplicate = function duplicate () {
216 + const copy = this._new()
217 +
218 + for (let i = 0; i < this._bufs.length; i++) {
219 + copy.append(this._bufs[i])
220 + }
221 +
222 + return copy
223 +}
224 +
225 +BufferList.prototype.append = function append (buf) {
226 + if (buf == null) {
227 + return this
228 + }
229 +
230 + if (buf.buffer) {
231 + // append a view of the underlying ArrayBuffer
232 + this._appendBuffer(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength))
233 + } else if (Array.isArray(buf)) {
234 + for (let i = 0; i < buf.length; i++) {
235 + this.append(buf[i])
236 + }
237 + } else if (this._isBufferList(buf)) {
238 + // unwrap argument into individual BufferLists
239 + for (let i = 0; i < buf._bufs.length; i++) {
240 + this.append(buf._bufs[i])
241 + }
242 + } else {
243 + // coerce number arguments to strings, since Buffer(number) does
244 + // uninitialized memory allocation
245 + if (typeof buf === 'number') {
246 + buf = buf.toString()
247 + }
248 +
249 + this._appendBuffer(Buffer.from(buf))
250 + }
251 +
252 + return this
253 +}
254 +
255 +BufferList.prototype._appendBuffer = function appendBuffer (buf) {
256 + this._bufs.push(buf)
257 + this.length += buf.length
258 +}
259 +
260 +BufferList.prototype.indexOf = function (search, offset, encoding) {
261 + if (encoding === undefined && typeof offset === 'string') {
262 + encoding = offset
263 + offset = undefined
264 + }
265 +
266 + if (typeof search === 'function' || Array.isArray(search)) {
267 + throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.')
268 + } else if (typeof search === 'number') {
269 + search = Buffer.from([search])
270 + } else if (typeof search === 'string') {
271 + search = Buffer.from(search, encoding)
272 + } else if (this._isBufferList(search)) {
273 + search = search.slice()
274 + } else if (Array.isArray(search.buffer)) {
275 + search = Buffer.from(search.buffer, search.byteOffset, search.byteLength)
276 + } else if (!Buffer.isBuffer(search)) {
277 + search = Buffer.from(search)
278 + }
279 +
280 + offset = Number(offset || 0)
281 +
282 + if (isNaN(offset)) {
283 + offset = 0
284 + }
285 +
286 + if (offset < 0) {
287 + offset = this.length + offset
288 + }
289 +
290 + if (offset < 0) {
291 + offset = 0
292 + }
293 +
294 + if (search.length === 0) {
295 + return offset > this.length ? this.length : offset
296 + }
297 +
298 + const blOffset = this._offset(offset)
299 + let blIndex = blOffset[0] // index of which internal buffer we're working on
300 + let buffOffset = blOffset[1] // offset of the internal buffer we're working on
301 +
302 + // scan over each buffer
303 + for (; blIndex < this._bufs.length; blIndex++) {
304 + const buff = this._bufs[blIndex]
305 +
306 + while (buffOffset < buff.length) {
307 + const availableWindow = buff.length - buffOffset
308 +
309 + if (availableWindow >= search.length) {
310 + const nativeSearchResult = buff.indexOf(search, buffOffset)
311 +
312 + if (nativeSearchResult !== -1) {
313 + return this._reverseOffset([blIndex, nativeSearchResult])
314 + }
315 +
316 + buffOffset = buff.length - search.length + 1 // end of native search window
317 + } else {
318 + const revOffset = this._reverseOffset([blIndex, buffOffset])
319 +
320 + if (this._match(revOffset, search)) {
321 + return revOffset
322 + }
323 +
324 + buffOffset++
325 + }
326 + }
327 +
328 + buffOffset = 0
329 + }
330 +
331 + return -1
332 +}
333 +
334 +BufferList.prototype._match = function (offset, search) {
335 + if (this.length - offset < search.length) {
336 + return false
337 + }
338 +
339 + for (let searchOffset = 0; searchOffset < search.length; searchOffset++) {
340 + if (this.get(offset + searchOffset) !== search[searchOffset]) {
341 + return false
342 + }
343 + }
344 + return true
345 +}
346 +
347 +;(function () {
348 + const methods = {
349 + readDoubleBE: 8,
350 + readDoubleLE: 8,
351 + readFloatBE: 4,
352 + readFloatLE: 4,
353 + readInt32BE: 4,
354 + readInt32LE: 4,
355 + readUInt32BE: 4,
356 + readUInt32LE: 4,
357 + readInt16BE: 2,
358 + readInt16LE: 2,
359 + readUInt16BE: 2,
360 + readUInt16LE: 2,
361 + readInt8: 1,
362 + readUInt8: 1,
363 + readIntBE: null,
364 + readIntLE: null,
365 + readUIntBE: null,
366 + readUIntLE: null
367 + }
368 +
369 + for (const m in methods) {
370 + (function (m) {
371 + if (methods[m] === null) {
372 + BufferList.prototype[m] = function (offset, byteLength) {
373 + return this.slice(offset, offset + byteLength)[m](0, byteLength)
374 + }
375 + } else {
376 + BufferList.prototype[m] = function (offset = 0) {
377 + return this.slice(offset, offset + methods[m])[m](0)
378 + }
379 + }
380 + }(m))
381 + }
382 +}())
383 +
384 +// Used internally by the class and also as an indicator of this object being
385 +// a `BufferList`. It's not possible to use `instanceof BufferList` in a browser
386 +// environment because there could be multiple different copies of the
387 +// BufferList class and some `BufferList`s might be `BufferList`s.
388 +BufferList.prototype._isBufferList = function _isBufferList (b) {
389 + return b instanceof BufferList || BufferList.isBufferList(b)
390 +}
391 +
392 +BufferList.isBufferList = function isBufferList (b) {
393 + return b != null && b[symbol]
394 +}
395 +
396 +module.exports = BufferList
1 +The MIT License (MIT)
2 +=====================
3 +
4 +Copyright (c) 2013-2019 bl contributors
5 +----------------------------------
6 +
7 +*bl contributors listed at <https://github.com/rvagg/bl#contributors>*
8 +
9 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10 +
11 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This diff is collapsed. Click to expand it.
1 +'use strict'
2 +
3 +const DuplexStream = require('readable-stream').Duplex
4 +const inherits = require('inherits')
5 +const BufferList = require('./BufferList')
6 +
7 +function BufferListStream (callback) {
8 + if (!(this instanceof BufferListStream)) {
9 + return new BufferListStream(callback)
10 + }
11 +
12 + if (typeof callback === 'function') {
13 + this._callback = callback
14 +
15 + const piper = function piper (err) {
16 + if (this._callback) {
17 + this._callback(err)
18 + this._callback = null
19 + }
20 + }.bind(this)
21 +
22 + this.on('pipe', function onPipe (src) {
23 + src.on('error', piper)
24 + })
25 + this.on('unpipe', function onUnpipe (src) {
26 + src.removeListener('error', piper)
27 + })
28 +
29 + callback = null
30 + }
31 +
32 + BufferList._init.call(this, callback)
33 + DuplexStream.call(this)
34 +}
35 +
36 +inherits(BufferListStream, DuplexStream)
37 +Object.assign(BufferListStream.prototype, BufferList.prototype)
38 +
39 +BufferListStream.prototype._new = function _new (callback) {
40 + return new BufferListStream(callback)
41 +}
42 +
43 +BufferListStream.prototype._write = function _write (buf, encoding, callback) {
44 + this._appendBuffer(buf)
45 +
46 + if (typeof callback === 'function') {
47 + callback()
48 + }
49 +}
50 +
51 +BufferListStream.prototype._read = function _read (size) {
52 + if (!this.length) {
53 + return this.push(null)
54 + }
55 +
56 + size = Math.min(size, this.length)
57 + this.push(this.slice(0, size))
58 + this.consume(size)
59 +}
60 +
61 +BufferListStream.prototype.end = function end (chunk) {
62 + DuplexStream.prototype.end.call(this, chunk)
63 +
64 + if (this._callback) {
65 + this._callback(null, this.slice())
66 + this._callback = null
67 + }
68 +}
69 +
70 +BufferListStream.prototype._destroy = function _destroy (err, cb) {
71 + this._bufs.length = 0
72 + this.length = 0
73 + cb(err)
74 +}
75 +
76 +BufferListStream.prototype._isBufferList = function _isBufferList (b) {
77 + return b instanceof BufferListStream || b instanceof BufferList || BufferListStream.isBufferList(b)
78 +}
79 +
80 +BufferListStream.isBufferList = BufferList.isBufferList
81 +
82 +module.exports = BufferListStream
83 +module.exports.BufferListStream = BufferListStream
84 +module.exports.BufferList = BufferList
1 +The ISC License
2 +
3 +Copyright (c) Isaac Z. Schlueter
4 +
5 +Permission to use, copy, modify, and/or distribute this software for any
6 +purpose with or without fee is hereby granted, provided that the above
7 +copyright notice and this permission notice appear in all copies.
8 +
9 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10 +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11 +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12 +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14 +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 +PERFORMANCE OF THIS SOFTWARE.
16 +
1 +Browser-friendly inheritance fully compatible with standard node.js
2 +[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
3 +
4 +This package exports standard `inherits` from node.js `util` module in
5 +node environment, but also provides alternative browser-friendly
6 +implementation through [browser
7 +field](https://gist.github.com/shtylman/4339901). Alternative
8 +implementation is a literal copy of standard one located in standalone
9 +module to avoid requiring of `util`. It also has a shim for old
10 +browsers with no `Object.create` support.
11 +
12 +While keeping you sure you are using standard `inherits`
13 +implementation in node.js environment, it allows bundlers such as
14 +[browserify](https://github.com/substack/node-browserify) to not
15 +include full `util` package to your client code if all you need is
16 +just `inherits` function. It worth, because browser shim for `util`
17 +package is large and `inherits` is often the single function you need
18 +from it.
19 +
20 +It's recommended to use this package instead of
21 +`require('util').inherits` for any code that has chances to be used
22 +not only in node.js but in browser too.
23 +
24 +## usage
25 +
26 +```js
27 +var inherits = require('inherits');
28 +// then use exactly as the standard one
29 +```
30 +
31 +## note on version ~1.0
32 +
33 +Version ~1.0 had completely different motivation and is not compatible
34 +neither with 2.0 nor with standard node.js `inherits`.
35 +
36 +If you are using version ~1.0 and planning to switch to ~2.0, be
37 +careful:
38 +
39 +* new version uses `super_` instead of `super` for referencing
40 + superclass
41 +* new version overwrites current prototype while old one preserves any
42 + existing fields on it
1 +try {
2 + var util = require('util');
3 + /* istanbul ignore next */
4 + if (typeof util.inherits !== 'function') throw '';
5 + module.exports = util.inherits;
6 +} catch (e) {
7 + /* istanbul ignore next */
8 + module.exports = require('./inherits_browser.js');
9 +}
1 +if (typeof Object.create === 'function') {
2 + // implementation from standard node.js 'util' module
3 + module.exports = function inherits(ctor, superCtor) {
4 + if (superCtor) {
5 + ctor.super_ = superCtor
6 + ctor.prototype = Object.create(superCtor.prototype, {
7 + constructor: {
8 + value: ctor,
9 + enumerable: false,
10 + writable: true,
11 + configurable: true
12 + }
13 + })
14 + }
15 + };
16 +} else {
17 + // old school shim for old browsers
18 + module.exports = function inherits(ctor, superCtor) {
19 + if (superCtor) {
20 + ctor.super_ = superCtor
21 + var TempCtor = function () {}
22 + TempCtor.prototype = superCtor.prototype
23 + ctor.prototype = new TempCtor()
24 + ctor.prototype.constructor = ctor
25 + }
26 + }
27 +}
1 +{
2 + "_from": "inherits@^2.0.4",
3 + "_id": "inherits@2.0.4",
4 + "_inBundle": false,
5 + "_integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
6 + "_location": "/bl/inherits",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "inherits@^2.0.4",
12 + "name": "inherits",
13 + "escapedName": "inherits",
14 + "rawSpec": "^2.0.4",
15 + "saveSpec": null,
16 + "fetchSpec": "^2.0.4"
17 + },
18 + "_requiredBy": [
19 + "/bl",
20 + "/bl/readable-stream"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
23 + "_shasum": "0fa2c64f932917c3433a0ded55363aae37416b7c",
24 + "_spec": "inherits@^2.0.4",
25 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\bl",
26 + "browser": "./inherits_browser.js",
27 + "bugs": {
28 + "url": "https://github.com/isaacs/inherits/issues"
29 + },
30 + "bundleDependencies": false,
31 + "deprecated": false,
32 + "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
33 + "devDependencies": {
34 + "tap": "^14.2.4"
35 + },
36 + "files": [
37 + "inherits.js",
38 + "inherits_browser.js"
39 + ],
40 + "homepage": "https://github.com/isaacs/inherits#readme",
41 + "keywords": [
42 + "inheritance",
43 + "class",
44 + "klass",
45 + "oop",
46 + "object-oriented",
47 + "inherits",
48 + "browser",
49 + "browserify"
50 + ],
51 + "license": "ISC",
52 + "main": "./inherits.js",
53 + "name": "inherits",
54 + "repository": {
55 + "type": "git",
56 + "url": "git://github.com/isaacs/inherits.git"
57 + },
58 + "scripts": {
59 + "test": "tap"
60 + },
61 + "version": "2.0.4"
62 +}
1 +# Developer's Certificate of Origin 1.1
2 +
3 +By making a contribution to this project, I certify that:
4 +
5 +* (a) The contribution was created in whole or in part by me and I
6 + have the right to submit it under the open source license
7 + indicated in the file; or
8 +
9 +* (b) The contribution is based upon previous work that, to the best
10 + of my knowledge, is covered under an appropriate open source
11 + license and I have the right under that license to submit that
12 + work with modifications, whether created in whole or in part
13 + by me, under the same open source license (unless I am
14 + permitted to submit under a different license), as indicated
15 + in the file; or
16 +
17 +* (c) The contribution was provided directly to me by some other
18 + person who certified (a), (b) or (c) and I have not modified
19 + it.
20 +
21 +* (d) I understand and agree that this project and the contribution
22 + are public and that a record of the contribution (including all
23 + personal information I submit with it, including my sign-off) is
24 + maintained indefinitely and may be redistributed consistent with
25 + this project or the open source license(s) involved.
26 +
27 +## Moderation Policy
28 +
29 +The [Node.js Moderation Policy] applies to this WG.
30 +
31 +## Code of Conduct
32 +
33 +The [Node.js Code of Conduct][] applies to this WG.
34 +
35 +[Node.js Code of Conduct]:
36 +https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
37 +[Node.js Moderation Policy]:
38 +https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md
1 +### Streams Working Group
2 +
3 +The Node.js Streams is jointly governed by a Working Group
4 +(WG)
5 +that is responsible for high-level guidance of the project.
6 +
7 +The WG has final authority over this project including:
8 +
9 +* Technical direction
10 +* Project governance and process (including this policy)
11 +* Contribution policy
12 +* GitHub repository hosting
13 +* Conduct guidelines
14 +* Maintaining the list of additional Collaborators
15 +
16 +For the current list of WG members, see the project
17 +[README.md](./README.md#current-project-team-members).
18 +
19 +### Collaborators
20 +
21 +The readable-stream GitHub repository is
22 +maintained by the WG and additional Collaborators who are added by the
23 +WG on an ongoing basis.
24 +
25 +Individuals making significant and valuable contributions are made
26 +Collaborators and given commit-access to the project. These
27 +individuals are identified by the WG and their addition as
28 +Collaborators is discussed during the WG meeting.
29 +
30 +_Note:_ If you make a significant contribution and are not considered
31 +for commit-access log an issue or contact a WG member directly and it
32 +will be brought up in the next WG meeting.
33 +
34 +Modifications of the contents of the readable-stream repository are
35 +made on
36 +a collaborative basis. Anybody with a GitHub account may propose a
37 +modification via pull request and it will be considered by the project
38 +Collaborators. All pull requests must be reviewed and accepted by a
39 +Collaborator with sufficient expertise who is able to take full
40 +responsibility for the change. In the case of pull requests proposed
41 +by an existing Collaborator, an additional Collaborator is required
42 +for sign-off. Consensus should be sought if additional Collaborators
43 +participate and there is disagreement around a particular
44 +modification. See _Consensus Seeking Process_ below for further detail
45 +on the consensus model used for governance.
46 +
47 +Collaborators may opt to elevate significant or controversial
48 +modifications, or modifications that have not found consensus to the
49 +WG for discussion by assigning the ***WG-agenda*** tag to a pull
50 +request or issue. The WG should serve as the final arbiter where
51 +required.
52 +
53 +For the current list of Collaborators, see the project
54 +[README.md](./README.md#members).
55 +
56 +### WG Membership
57 +
58 +WG seats are not time-limited. There is no fixed size of the WG.
59 +However, the expected target is between 6 and 12, to ensure adequate
60 +coverage of important areas of expertise, balanced with the ability to
61 +make decisions efficiently.
62 +
63 +There is no specific set of requirements or qualifications for WG
64 +membership beyond these rules.
65 +
66 +The WG may add additional members to the WG by unanimous consensus.
67 +
68 +A WG member may be removed from the WG by voluntary resignation, or by
69 +unanimous consensus of all other WG members.
70 +
71 +Changes to WG membership should be posted in the agenda, and may be
72 +suggested as any other agenda item (see "WG Meetings" below).
73 +
74 +If an addition or removal is proposed during a meeting, and the full
75 +WG is not in attendance to participate, then the addition or removal
76 +is added to the agenda for the subsequent meeting. This is to ensure
77 +that all members are given the opportunity to participate in all
78 +membership decisions. If a WG member is unable to attend a meeting
79 +where a planned membership decision is being made, then their consent
80 +is assumed.
81 +
82 +No more than 1/3 of the WG members may be affiliated with the same
83 +employer. If removal or resignation of a WG member, or a change of
84 +employment by a WG member, creates a situation where more than 1/3 of
85 +the WG membership shares an employer, then the situation must be
86 +immediately remedied by the resignation or removal of one or more WG
87 +members affiliated with the over-represented employer(s).
88 +
89 +### WG Meetings
90 +
91 +The WG meets occasionally on a Google Hangout On Air. A designated moderator
92 +approved by the WG runs the meeting. Each meeting should be
93 +published to YouTube.
94 +
95 +Items are added to the WG agenda that are considered contentious or
96 +are modifications of governance, contribution policy, WG membership,
97 +or release process.
98 +
99 +The intention of the agenda is not to approve or review all patches;
100 +that should happen continuously on GitHub and be handled by the larger
101 +group of Collaborators.
102 +
103 +Any community member or contributor can ask that something be added to
104 +the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
105 +WG member or the moderator can add the item to the agenda by adding
106 +the ***WG-agenda*** tag to the issue.
107 +
108 +Prior to each WG meeting the moderator will share the Agenda with
109 +members of the WG. WG members can add any items they like to the
110 +agenda at the beginning of each meeting. The moderator and the WG
111 +cannot veto or remove items.
112 +
113 +The WG may invite persons or representatives from certain projects to
114 +participate in a non-voting capacity.
115 +
116 +The moderator is responsible for summarizing the discussion of each
117 +agenda item and sends it as a pull request after the meeting.
118 +
119 +### Consensus Seeking Process
120 +
121 +The WG follows a
122 +[Consensus
123 +Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
124 +decision-making model.
125 +
126 +When an agenda item has appeared to reach a consensus the moderator
127 +will ask "Does anyone object?" as a final call for dissent from the
128 +consensus.
129 +
130 +If an agenda item cannot reach a consensus a WG member can call for
131 +either a closing vote or a vote to table the issue to the next
132 +meeting. The call for a vote must be seconded by a majority of the WG
133 +or else the discussion will continue. Simple majority wins.
134 +
135 +Note that changes to WG membership require a majority consensus. See
136 +"WG Membership" above.
1 +Node.js is licensed for use as follows:
2 +
3 +"""
4 +Copyright Node.js contributors. All rights reserved.
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining a copy
7 +of this software and associated documentation files (the "Software"), to
8 +deal in the Software without restriction, including without limitation the
9 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 +sell copies of the Software, and to permit persons to whom the Software is
11 +furnished to do so, subject to the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be included in
14 +all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 +IN THE SOFTWARE.
23 +"""
24 +
25 +This license applies to parts of Node.js originating from the
26 +https://github.com/joyent/node repository:
27 +
28 +"""
29 +Copyright Joyent, Inc. and other Node contributors. All rights reserved.
30 +Permission is hereby granted, free of charge, to any person obtaining a copy
31 +of this software and associated documentation files (the "Software"), to
32 +deal in the Software without restriction, including without limitation the
33 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
34 +sell copies of the Software, and to permit persons to whom the Software is
35 +furnished to do so, subject to the following conditions:
36 +
37 +The above copyright notice and this permission notice shall be included in
38 +all copies or substantial portions of the Software.
39 +
40 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
45 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
46 +IN THE SOFTWARE.
47 +"""
1 +# readable-stream
2 +
3 +***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)
4 +
5 +
6 +[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/)
7 +[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/)
8 +
9 +
10 +[![Sauce Test Status](https://saucelabs.com/browser-matrix/readabe-stream.svg)](https://saucelabs.com/u/readabe-stream)
11 +
12 +```bash
13 +npm install --save readable-stream
14 +```
15 +
16 +This package is a mirror of the streams implementations in Node.js.
17 +
18 +Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.19.0/docs/api/stream.html).
19 +
20 +If you want to guarantee a stable streams base, regardless of what version of
21 +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).
22 +
23 +As of version 2.0.0 **readable-stream** uses semantic versioning.
24 +
25 +## Version 3.x.x
26 +
27 +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:
28 +
29 +1. Error codes: https://github.com/nodejs/node/pull/13310,
30 + https://github.com/nodejs/node/pull/13291,
31 + https://github.com/nodejs/node/pull/16589,
32 + https://github.com/nodejs/node/pull/15042,
33 + https://github.com/nodejs/node/pull/15665,
34 + https://github.com/nodejs/readable-stream/pull/344
35 +2. 'readable' have precedence over flowing
36 + https://github.com/nodejs/node/pull/18994
37 +3. make virtual methods errors consistent
38 + https://github.com/nodejs/node/pull/18813
39 +4. updated streams error handling
40 + https://github.com/nodejs/node/pull/18438
41 +5. writable.end should return this.
42 + https://github.com/nodejs/node/pull/18780
43 +6. readable continues to read when push('')
44 + https://github.com/nodejs/node/pull/18211
45 +7. add custom inspect to BufferList
46 + https://github.com/nodejs/node/pull/17907
47 +8. always defer 'readable' with nextTick
48 + https://github.com/nodejs/node/pull/17979
49 +
50 +## Version 2.x.x
51 +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.
52 +
53 +### Big Thanks
54 +
55 +Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs][sauce]
56 +
57 +# Usage
58 +
59 +You can swap your `require('stream')` with `require('readable-stream')`
60 +without any changes, if you are just using one of the main classes and
61 +functions.
62 +
63 +```js
64 +const {
65 + Readable,
66 + Writable,
67 + Transform,
68 + Duplex,
69 + pipeline,
70 + finished
71 +} = require('readable-stream')
72 +````
73 +
74 +Note that `require('stream')` will return `Stream`, while
75 +`require('readable-stream')` will return `Readable`. We discourage using
76 +whatever is exported directly, but rather use one of the properties as
77 +shown in the example above.
78 +
79 +# Streams Working Group
80 +
81 +`readable-stream` is maintained by the Streams Working Group, which
82 +oversees the development and maintenance of the Streams API within
83 +Node.js. The responsibilities of the Streams Working Group include:
84 +
85 +* Addressing stream issues on the Node.js issue tracker.
86 +* Authoring and editing stream documentation within the Node.js project.
87 +* Reviewing changes to stream subclasses within the Node.js project.
88 +* Redirecting changes to streams from the Node.js project to this
89 + project.
90 +* Assisting in the implementation of stream providers within Node.js.
91 +* Recommending versions of `readable-stream` to be included in Node.js.
92 +* Messaging about the future of streams to give the community advance
93 + notice of changes.
94 +
95 +<a name="members"></a>
96 +## Team Members
97 +
98 +* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) &lt;calvin.metcalf@gmail.com&gt;
99 + - Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
100 +* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) &lt;mathiasbuus@gmail.com&gt;
101 +* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) &lt;matteo.collina@gmail.com&gt;
102 + - Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
103 +* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) &lt;shestak.irina@gmail.com&gt;
104 +* **Yoshua Wyuts** ([@yoshuawuyts](https://github.com/yoshuawuyts)) &lt;yoshuawuyts@gmail.com&gt;
105 +
106 +[sauce]: https://saucelabs.com
1 +'use strict';
2 +
3 +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
4 +
5 +var codes = {};
6 +
7 +function createErrorType(code, message, Base) {
8 + if (!Base) {
9 + Base = Error;
10 + }
11 +
12 + function getMessage(arg1, arg2, arg3) {
13 + if (typeof message === 'string') {
14 + return message;
15 + } else {
16 + return message(arg1, arg2, arg3);
17 + }
18 + }
19 +
20 + var NodeError =
21 + /*#__PURE__*/
22 + function (_Base) {
23 + _inheritsLoose(NodeError, _Base);
24 +
25 + function NodeError(arg1, arg2, arg3) {
26 + return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
27 + }
28 +
29 + return NodeError;
30 + }(Base);
31 +
32 + NodeError.prototype.name = Base.name;
33 + NodeError.prototype.code = code;
34 + codes[code] = NodeError;
35 +} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
36 +
37 +
38 +function oneOf(expected, thing) {
39 + if (Array.isArray(expected)) {
40 + var len = expected.length;
41 + expected = expected.map(function (i) {
42 + return String(i);
43 + });
44 +
45 + if (len > 2) {
46 + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
47 + } else if (len === 2) {
48 + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
49 + } else {
50 + return "of ".concat(thing, " ").concat(expected[0]);
51 + }
52 + } else {
53 + return "of ".concat(thing, " ").concat(String(expected));
54 + }
55 +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
56 +
57 +
58 +function startsWith(str, search, pos) {
59 + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
60 +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
61 +
62 +
63 +function endsWith(str, search, this_len) {
64 + if (this_len === undefined || this_len > str.length) {
65 + this_len = str.length;
66 + }
67 +
68 + return str.substring(this_len - search.length, this_len) === search;
69 +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
70 +
71 +
72 +function includes(str, search, start) {
73 + if (typeof start !== 'number') {
74 + start = 0;
75 + }
76 +
77 + if (start + search.length > str.length) {
78 + return false;
79 + } else {
80 + return str.indexOf(search, start) !== -1;
81 + }
82 +}
83 +
84 +createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
85 + return 'The value "' + value + '" is invalid for option "' + name + '"';
86 +}, TypeError);
87 +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
88 + // determiner: 'must be' or 'must not be'
89 + var determiner;
90 +
91 + if (typeof expected === 'string' && startsWith(expected, 'not ')) {
92 + determiner = 'must not be';
93 + expected = expected.replace(/^not /, '');
94 + } else {
95 + determiner = 'must be';
96 + }
97 +
98 + var msg;
99 +
100 + if (endsWith(name, ' argument')) {
101 + // For cases like 'first argument'
102 + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
103 + } else {
104 + var type = includes(name, '.') ? 'property' : 'argument';
105 + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
106 + }
107 +
108 + msg += ". Received type ".concat(typeof actual);
109 + return msg;
110 +}, TypeError);
111 +createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
112 +createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
113 + return 'The ' + name + ' method is not implemented';
114 +});
115 +createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
116 +createErrorType('ERR_STREAM_DESTROYED', function (name) {
117 + return 'Cannot call ' + name + ' after a stream was destroyed';
118 +});
119 +createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
120 +createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
121 +createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
122 +createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
123 +createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
124 + return 'Unknown encoding: ' + arg;
125 +}, TypeError);
126 +createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
127 +module.exports.codes = codes;
1 +'use strict';
2 +
3 +const codes = {};
4 +
5 +function createErrorType(code, message, Base) {
6 + if (!Base) {
7 + Base = Error
8 + }
9 +
10 + function getMessage (arg1, arg2, arg3) {
11 + if (typeof message === 'string') {
12 + return message
13 + } else {
14 + return message(arg1, arg2, arg3)
15 + }
16 + }
17 +
18 + class NodeError extends Base {
19 + constructor (arg1, arg2, arg3) {
20 + super(getMessage(arg1, arg2, arg3));
21 + }
22 + }
23 +
24 + NodeError.prototype.name = Base.name;
25 + NodeError.prototype.code = code;
26 +
27 + codes[code] = NodeError;
28 +}
29 +
30 +// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
31 +function oneOf(expected, thing) {
32 + if (Array.isArray(expected)) {
33 + const len = expected.length;
34 + expected = expected.map((i) => String(i));
35 + if (len > 2) {
36 + return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
37 + expected[len - 1];
38 + } else if (len === 2) {
39 + return `one of ${thing} ${expected[0]} or ${expected[1]}`;
40 + } else {
41 + return `of ${thing} ${expected[0]}`;
42 + }
43 + } else {
44 + return `of ${thing} ${String(expected)}`;
45 + }
46 +}
47 +
48 +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
49 +function startsWith(str, search, pos) {
50 + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
51 +}
52 +
53 +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
54 +function endsWith(str, search, this_len) {
55 + if (this_len === undefined || this_len > str.length) {
56 + this_len = str.length;
57 + }
58 + return str.substring(this_len - search.length, this_len) === search;
59 +}
60 +
61 +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
62 +function includes(str, search, start) {
63 + if (typeof start !== 'number') {
64 + start = 0;
65 + }
66 +
67 + if (start + search.length > str.length) {
68 + return false;
69 + } else {
70 + return str.indexOf(search, start) !== -1;
71 + }
72 +}
73 +
74 +createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
75 + return 'The value "' + value + '" is invalid for option "' + name + '"'
76 +}, TypeError);
77 +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
78 + // determiner: 'must be' or 'must not be'
79 + let determiner;
80 + if (typeof expected === 'string' && startsWith(expected, 'not ')) {
81 + determiner = 'must not be';
82 + expected = expected.replace(/^not /, '');
83 + } else {
84 + determiner = 'must be';
85 + }
86 +
87 + let msg;
88 + if (endsWith(name, ' argument')) {
89 + // For cases like 'first argument'
90 + msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
91 + } else {
92 + const type = includes(name, '.') ? 'property' : 'argument';
93 + msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
94 + }
95 +
96 + msg += `. Received type ${typeof actual}`;
97 + return msg;
98 +}, TypeError);
99 +createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
100 +createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
101 + return 'The ' + name + ' method is not implemented'
102 +});
103 +createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
104 +createErrorType('ERR_STREAM_DESTROYED', function (name) {
105 + return 'Cannot call ' + name + ' after a stream was destroyed';
106 +});
107 +createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
108 +createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
109 +createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
110 +createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
111 +createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
112 + return 'Unknown encoding: ' + arg
113 +}, TypeError);
114 +createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
115 +
116 +module.exports.codes = codes;
1 +'use strict'
2 +
3 +var experimentalWarnings = new Set();
4 +
5 +function emitExperimentalWarning(feature) {
6 + if (experimentalWarnings.has(feature)) return;
7 + var msg = feature + ' is an experimental feature. This feature could ' +
8 + 'change at any time';
9 + experimentalWarnings.add(feature);
10 + process.emitWarning(msg, 'ExperimentalWarning');
11 +}
12 +
13 +function noop() {}
14 +
15 +module.exports.emitExperimentalWarning = process.emitWarning
16 + ? emitExperimentalWarning
17 + : noop;
1 +// Copyright Joyent, Inc. and other Node contributors.
2 +//
3 +// Permission is hereby granted, free of charge, to any person obtaining a
4 +// copy of this software and associated documentation files (the
5 +// "Software"), to deal in the Software without restriction, including
6 +// without limitation the rights to use, copy, modify, merge, publish,
7 +// distribute, sublicense, and/or sell copies of the Software, and to permit
8 +// persons to whom the Software is furnished to do so, subject to the
9 +// following conditions:
10 +//
11 +// The above copyright notice and this permission notice shall be included
12 +// in all copies or substantial portions of the Software.
13 +//
14 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 +// USE OR OTHER DEALINGS IN THE SOFTWARE.
21 +// a duplex stream is just a stream that is both readable and writable.
22 +// Since JS doesn't have multiple prototypal inheritance, this class
23 +// prototypally inherits from Readable, and then parasitically from
24 +// Writable.
25 +'use strict';
26 +/*<replacement>*/
27 +
28 +var objectKeys = Object.keys || function (obj) {
29 + var keys = [];
30 +
31 + for (var key in obj) {
32 + keys.push(key);
33 + }
34 +
35 + return keys;
36 +};
37 +/*</replacement>*/
38 +
39 +
40 +module.exports = Duplex;
41 +
42 +var Readable = require('./_stream_readable');
43 +
44 +var Writable = require('./_stream_writable');
45 +
46 +require('inherits')(Duplex, Readable);
47 +
48 +{
49 + // Allow the keys array to be GC'ed.
50 + var keys = objectKeys(Writable.prototype);
51 +
52 + for (var v = 0; v < keys.length; v++) {
53 + var method = keys[v];
54 + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
55 + }
56 +}
57 +
58 +function Duplex(options) {
59 + if (!(this instanceof Duplex)) return new Duplex(options);
60 + Readable.call(this, options);
61 + Writable.call(this, options);
62 + this.allowHalfOpen = true;
63 +
64 + if (options) {
65 + if (options.readable === false) this.readable = false;
66 + if (options.writable === false) this.writable = false;
67 +
68 + if (options.allowHalfOpen === false) {
69 + this.allowHalfOpen = false;
70 + this.once('end', onend);
71 + }
72 + }
73 +}
74 +
75 +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
76 + // making it explicit this property is not enumerable
77 + // because otherwise some prototype manipulation in
78 + // userland will fail
79 + enumerable: false,
80 + get: function get() {
81 + return this._writableState.highWaterMark;
82 + }
83 +});
84 +Object.defineProperty(Duplex.prototype, 'writableBuffer', {
85 + // making it explicit this property is not enumerable
86 + // because otherwise some prototype manipulation in
87 + // userland will fail
88 + enumerable: false,
89 + get: function get() {
90 + return this._writableState && this._writableState.getBuffer();
91 + }
92 +});
93 +Object.defineProperty(Duplex.prototype, 'writableLength', {
94 + // making it explicit this property is not enumerable
95 + // because otherwise some prototype manipulation in
96 + // userland will fail
97 + enumerable: false,
98 + get: function get() {
99 + return this._writableState.length;
100 + }
101 +}); // the no-half-open enforcer
102 +
103 +function onend() {
104 + // If the writable side ended, then we're ok.
105 + if (this._writableState.ended) return; // no more data can be written.
106 + // But allow more writes to happen in this tick.
107 +
108 + process.nextTick(onEndNT, this);
109 +}
110 +
111 +function onEndNT(self) {
112 + self.end();
113 +}
114 +
115 +Object.defineProperty(Duplex.prototype, 'destroyed', {
116 + // making it explicit this property is not enumerable
117 + // because otherwise some prototype manipulation in
118 + // userland will fail
119 + enumerable: false,
120 + get: function get() {
121 + if (this._readableState === undefined || this._writableState === undefined) {
122 + return false;
123 + }
124 +
125 + return this._readableState.destroyed && this._writableState.destroyed;
126 + },
127 + set: function set(value) {
128 + // we ignore the value if the stream
129 + // has not been initialized yet
130 + if (this._readableState === undefined || this._writableState === undefined) {
131 + return;
132 + } // backward compatibility, the user is explicitly
133 + // managing destroyed
134 +
135 +
136 + this._readableState.destroyed = value;
137 + this._writableState.destroyed = value;
138 + }
139 +});
...\ No newline at end of file ...\ No newline at end of file
1 +// Copyright Joyent, Inc. and other Node contributors.
2 +//
3 +// Permission is hereby granted, free of charge, to any person obtaining a
4 +// copy of this software and associated documentation files (the
5 +// "Software"), to deal in the Software without restriction, including
6 +// without limitation the rights to use, copy, modify, merge, publish,
7 +// distribute, sublicense, and/or sell copies of the Software, and to permit
8 +// persons to whom the Software is furnished to do so, subject to the
9 +// following conditions:
10 +//
11 +// The above copyright notice and this permission notice shall be included
12 +// in all copies or substantial portions of the Software.
13 +//
14 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 +// USE OR OTHER DEALINGS IN THE SOFTWARE.
21 +// a passthrough stream.
22 +// basically just the most minimal sort of Transform stream.
23 +// Every written chunk gets output as-is.
24 +'use strict';
25 +
26 +module.exports = PassThrough;
27 +
28 +var Transform = require('./_stream_transform');
29 +
30 +require('inherits')(PassThrough, Transform);
31 +
32 +function PassThrough(options) {
33 + if (!(this instanceof PassThrough)) return new PassThrough(options);
34 + Transform.call(this, options);
35 +}
36 +
37 +PassThrough.prototype._transform = function (chunk, encoding, cb) {
38 + cb(null, chunk);
39 +};
...\ No newline at end of file ...\ No newline at end of file
1 +// Copyright Joyent, Inc. and other Node contributors.
2 +//
3 +// Permission is hereby granted, free of charge, to any person obtaining a
4 +// copy of this software and associated documentation files (the
5 +// "Software"), to deal in the Software without restriction, including
6 +// without limitation the rights to use, copy, modify, merge, publish,
7 +// distribute, sublicense, and/or sell copies of the Software, and to permit
8 +// persons to whom the Software is furnished to do so, subject to the
9 +// following conditions:
10 +//
11 +// The above copyright notice and this permission notice shall be included
12 +// in all copies or substantial portions of the Software.
13 +//
14 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 +// USE OR OTHER DEALINGS IN THE SOFTWARE.
21 +// a transform stream is a readable/writable stream where you do
22 +// something with the data. Sometimes it's called a "filter",
23 +// but that's not a great name for it, since that implies a thing where
24 +// some bits pass through, and others are simply ignored. (That would
25 +// be a valid example of a transform, of course.)
26 +//
27 +// While the output is causally related to the input, it's not a
28 +// necessarily symmetric or synchronous transformation. For example,
29 +// a zlib stream might take multiple plain-text writes(), and then
30 +// emit a single compressed chunk some time in the future.
31 +//
32 +// Here's how this works:
33 +//
34 +// The Transform stream has all the aspects of the readable and writable
35 +// stream classes. When you write(chunk), that calls _write(chunk,cb)
36 +// internally, and returns false if there's a lot of pending writes
37 +// buffered up. When you call read(), that calls _read(n) until
38 +// there's enough pending readable data buffered up.
39 +//
40 +// In a transform stream, the written data is placed in a buffer. When
41 +// _read(n) is called, it transforms the queued up data, calling the
42 +// buffered _write cb's as it consumes chunks. If consuming a single
43 +// written chunk would result in multiple output chunks, then the first
44 +// outputted bit calls the readcb, and subsequent chunks just go into
45 +// the read buffer, and will cause it to emit 'readable' if necessary.
46 +//
47 +// This way, back-pressure is actually determined by the reading side,
48 +// since _read has to be called to start processing a new chunk. However,
49 +// a pathological inflate type of transform can cause excessive buffering
50 +// here. For example, imagine a stream where every byte of input is
51 +// interpreted as an integer from 0-255, and then results in that many
52 +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
53 +// 1kb of data being output. In this case, you could write a very small
54 +// amount of input, and end up with a very large amount of output. In
55 +// such a pathological inflating mechanism, there'd be no way to tell
56 +// the system to stop doing the transform. A single 4MB write could
57 +// cause the system to run out of memory.
58 +//
59 +// However, even in such a pathological case, only a single written chunk
60 +// would be consumed, and then the rest would wait (un-transformed) until
61 +// the results of the previous transformed chunk were consumed.
62 +'use strict';
63 +
64 +module.exports = Transform;
65 +
66 +var _require$codes = require('../errors').codes,
67 + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
68 + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
69 + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
70 + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
71 +
72 +var Duplex = require('./_stream_duplex');
73 +
74 +require('inherits')(Transform, Duplex);
75 +
76 +function afterTransform(er, data) {
77 + var ts = this._transformState;
78 + ts.transforming = false;
79 + var cb = ts.writecb;
80 +
81 + if (cb === null) {
82 + return this.emit('error', new ERR_MULTIPLE_CALLBACK());
83 + }
84 +
85 + ts.writechunk = null;
86 + ts.writecb = null;
87 + if (data != null) // single equals check for both `null` and `undefined`
88 + this.push(data);
89 + cb(er);
90 + var rs = this._readableState;
91 + rs.reading = false;
92 +
93 + if (rs.needReadable || rs.length < rs.highWaterMark) {
94 + this._read(rs.highWaterMark);
95 + }
96 +}
97 +
98 +function Transform(options) {
99 + if (!(this instanceof Transform)) return new Transform(options);
100 + Duplex.call(this, options);
101 + this._transformState = {
102 + afterTransform: afterTransform.bind(this),
103 + needTransform: false,
104 + transforming: false,
105 + writecb: null,
106 + writechunk: null,
107 + writeencoding: null
108 + }; // start out asking for a readable event once data is transformed.
109 +
110 + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things
111 + // that Readable wants before the first _read call, so unset the
112 + // sync guard flag.
113 +
114 + this._readableState.sync = false;
115 +
116 + if (options) {
117 + if (typeof options.transform === 'function') this._transform = options.transform;
118 + if (typeof options.flush === 'function') this._flush = options.flush;
119 + } // When the writable side finishes, then flush out anything remaining.
120 +
121 +
122 + this.on('prefinish', prefinish);
123 +}
124 +
125 +function prefinish() {
126 + var _this = this;
127 +
128 + if (typeof this._flush === 'function' && !this._readableState.destroyed) {
129 + this._flush(function (er, data) {
130 + done(_this, er, data);
131 + });
132 + } else {
133 + done(this, null, null);
134 + }
135 +}
136 +
137 +Transform.prototype.push = function (chunk, encoding) {
138 + this._transformState.needTransform = false;
139 + return Duplex.prototype.push.call(this, chunk, encoding);
140 +}; // This is the part where you do stuff!
141 +// override this function in implementation classes.
142 +// 'chunk' is an input chunk.
143 +//
144 +// Call `push(newChunk)` to pass along transformed output
145 +// to the readable side. You may call 'push' zero or more times.
146 +//
147 +// Call `cb(err)` when you are done with this chunk. If you pass
148 +// an error, then that'll put the hurt on the whole operation. If you
149 +// never call cb(), then you'll never get another chunk.
150 +
151 +
152 +Transform.prototype._transform = function (chunk, encoding, cb) {
153 + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
154 +};
155 +
156 +Transform.prototype._write = function (chunk, encoding, cb) {
157 + var ts = this._transformState;
158 + ts.writecb = cb;
159 + ts.writechunk = chunk;
160 + ts.writeencoding = encoding;
161 +
162 + if (!ts.transforming) {
163 + var rs = this._readableState;
164 + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
165 + }
166 +}; // Doesn't matter what the args are here.
167 +// _transform does all the work.
168 +// That we got here means that the readable side wants more data.
169 +
170 +
171 +Transform.prototype._read = function (n) {
172 + var ts = this._transformState;
173 +
174 + if (ts.writechunk !== null && !ts.transforming) {
175 + ts.transforming = true;
176 +
177 + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
178 + } else {
179 + // mark that we need a transform, so that any data that comes in
180 + // will get processed, now that we've asked for it.
181 + ts.needTransform = true;
182 + }
183 +};
184 +
185 +Transform.prototype._destroy = function (err, cb) {
186 + Duplex.prototype._destroy.call(this, err, function (err2) {
187 + cb(err2);
188 + });
189 +};
190 +
191 +function done(stream, er, data) {
192 + if (er) return stream.emit('error', er);
193 + if (data != null) // single equals check for both `null` and `undefined`
194 + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases
195 + // if there's nothing in the write buffer, then that means
196 + // that nothing more will ever be provided
197 +
198 + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
199 + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
200 + return stream.push(null);
201 +}
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _Object$setPrototypeO;
4 +
5 +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6 +
7 +var finished = require('./end-of-stream');
8 +
9 +var kLastResolve = Symbol('lastResolve');
10 +var kLastReject = Symbol('lastReject');
11 +var kError = Symbol('error');
12 +var kEnded = Symbol('ended');
13 +var kLastPromise = Symbol('lastPromise');
14 +var kHandlePromise = Symbol('handlePromise');
15 +var kStream = Symbol('stream');
16 +
17 +function createIterResult(value, done) {
18 + return {
19 + value: value,
20 + done: done
21 + };
22 +}
23 +
24 +function readAndResolve(iter) {
25 + var resolve = iter[kLastResolve];
26 +
27 + if (resolve !== null) {
28 + var data = iter[kStream].read(); // we defer if data is null
29 + // we can be expecting either 'end' or
30 + // 'error'
31 +
32 + if (data !== null) {
33 + iter[kLastPromise] = null;
34 + iter[kLastResolve] = null;
35 + iter[kLastReject] = null;
36 + resolve(createIterResult(data, false));
37 + }
38 + }
39 +}
40 +
41 +function onReadable(iter) {
42 + // we wait for the next tick, because it might
43 + // emit an error with process.nextTick
44 + process.nextTick(readAndResolve, iter);
45 +}
46 +
47 +function wrapForNext(lastPromise, iter) {
48 + return function (resolve, reject) {
49 + lastPromise.then(function () {
50 + if (iter[kEnded]) {
51 + resolve(createIterResult(undefined, true));
52 + return;
53 + }
54 +
55 + iter[kHandlePromise](resolve, reject);
56 + }, reject);
57 + };
58 +}
59 +
60 +var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
61 +var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
62 + get stream() {
63 + return this[kStream];
64 + },
65 +
66 + next: function next() {
67 + var _this = this;
68 +
69 + // if we have detected an error in the meanwhile
70 + // reject straight away
71 + var error = this[kError];
72 +
73 + if (error !== null) {
74 + return Promise.reject(error);
75 + }
76 +
77 + if (this[kEnded]) {
78 + return Promise.resolve(createIterResult(undefined, true));
79 + }
80 +
81 + if (this[kStream].destroyed) {
82 + // We need to defer via nextTick because if .destroy(err) is
83 + // called, the error will be emitted via nextTick, and
84 + // we cannot guarantee that there is no error lingering around
85 + // waiting to be emitted.
86 + return new Promise(function (resolve, reject) {
87 + process.nextTick(function () {
88 + if (_this[kError]) {
89 + reject(_this[kError]);
90 + } else {
91 + resolve(createIterResult(undefined, true));
92 + }
93 + });
94 + });
95 + } // if we have multiple next() calls
96 + // we will wait for the previous Promise to finish
97 + // this logic is optimized to support for await loops,
98 + // where next() is only called once at a time
99 +
100 +
101 + var lastPromise = this[kLastPromise];
102 + var promise;
103 +
104 + if (lastPromise) {
105 + promise = new Promise(wrapForNext(lastPromise, this));
106 + } else {
107 + // fast path needed to support multiple this.push()
108 + // without triggering the next() queue
109 + var data = this[kStream].read();
110 +
111 + if (data !== null) {
112 + return Promise.resolve(createIterResult(data, false));
113 + }
114 +
115 + promise = new Promise(this[kHandlePromise]);
116 + }
117 +
118 + this[kLastPromise] = promise;
119 + return promise;
120 + }
121 +}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
122 + return this;
123 +}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
124 + var _this2 = this;
125 +
126 + // destroy(err, cb) is a private API
127 + // we can guarantee we have that here, because we control the
128 + // Readable class this is attached to
129 + return new Promise(function (resolve, reject) {
130 + _this2[kStream].destroy(null, function (err) {
131 + if (err) {
132 + reject(err);
133 + return;
134 + }
135 +
136 + resolve(createIterResult(undefined, true));
137 + });
138 + });
139 +}), _Object$setPrototypeO), AsyncIteratorPrototype);
140 +
141 +var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
142 + var _Object$create;
143 +
144 + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
145 + value: stream,
146 + writable: true
147 + }), _defineProperty(_Object$create, kLastResolve, {
148 + value: null,
149 + writable: true
150 + }), _defineProperty(_Object$create, kLastReject, {
151 + value: null,
152 + writable: true
153 + }), _defineProperty(_Object$create, kError, {
154 + value: null,
155 + writable: true
156 + }), _defineProperty(_Object$create, kEnded, {
157 + value: stream._readableState.endEmitted,
158 + writable: true
159 + }), _defineProperty(_Object$create, kHandlePromise, {
160 + value: function value(resolve, reject) {
161 + var data = iterator[kStream].read();
162 +
163 + if (data) {
164 + iterator[kLastPromise] = null;
165 + iterator[kLastResolve] = null;
166 + iterator[kLastReject] = null;
167 + resolve(createIterResult(data, false));
168 + } else {
169 + iterator[kLastResolve] = resolve;
170 + iterator[kLastReject] = reject;
171 + }
172 + },
173 + writable: true
174 + }), _Object$create));
175 + iterator[kLastPromise] = null;
176 + finished(stream, function (err) {
177 + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
178 + var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise
179 + // returned by next() and store the error
180 +
181 + if (reject !== null) {
182 + iterator[kLastPromise] = null;
183 + iterator[kLastResolve] = null;
184 + iterator[kLastReject] = null;
185 + reject(err);
186 + }
187 +
188 + iterator[kError] = err;
189 + return;
190 + }
191 +
192 + var resolve = iterator[kLastResolve];
193 +
194 + if (resolve !== null) {
195 + iterator[kLastPromise] = null;
196 + iterator[kLastResolve] = null;
197 + iterator[kLastReject] = null;
198 + resolve(createIterResult(undefined, true));
199 + }
200 +
201 + iterator[kEnded] = true;
202 + });
203 + stream.on('readable', onReadable.bind(null, iterator));
204 + return iterator;
205 +};
206 +
207 +module.exports = createReadableStreamAsyncIterator;
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4 +
5 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6 +
7 +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8 +
9 +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10 +
11 +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12 +
13 +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14 +
15 +var _require = require('buffer'),
16 + Buffer = _require.Buffer;
17 +
18 +var _require2 = require('util'),
19 + inspect = _require2.inspect;
20 +
21 +var custom = inspect && inspect.custom || 'inspect';
22 +
23 +function copyBuffer(src, target, offset) {
24 + Buffer.prototype.copy.call(src, target, offset);
25 +}
26 +
27 +module.exports =
28 +/*#__PURE__*/
29 +function () {
30 + function BufferList() {
31 + _classCallCheck(this, BufferList);
32 +
33 + this.head = null;
34 + this.tail = null;
35 + this.length = 0;
36 + }
37 +
38 + _createClass(BufferList, [{
39 + key: "push",
40 + value: function push(v) {
41 + var entry = {
42 + data: v,
43 + next: null
44 + };
45 + if (this.length > 0) this.tail.next = entry;else this.head = entry;
46 + this.tail = entry;
47 + ++this.length;
48 + }
49 + }, {
50 + key: "unshift",
51 + value: function unshift(v) {
52 + var entry = {
53 + data: v,
54 + next: this.head
55 + };
56 + if (this.length === 0) this.tail = entry;
57 + this.head = entry;
58 + ++this.length;
59 + }
60 + }, {
61 + key: "shift",
62 + value: function shift() {
63 + if (this.length === 0) return;
64 + var ret = this.head.data;
65 + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
66 + --this.length;
67 + return ret;
68 + }
69 + }, {
70 + key: "clear",
71 + value: function clear() {
72 + this.head = this.tail = null;
73 + this.length = 0;
74 + }
75 + }, {
76 + key: "join",
77 + value: function join(s) {
78 + if (this.length === 0) return '';
79 + var p = this.head;
80 + var ret = '' + p.data;
81 +
82 + while (p = p.next) {
83 + ret += s + p.data;
84 + }
85 +
86 + return ret;
87 + }
88 + }, {
89 + key: "concat",
90 + value: function concat(n) {
91 + if (this.length === 0) return Buffer.alloc(0);
92 + var ret = Buffer.allocUnsafe(n >>> 0);
93 + var p = this.head;
94 + var i = 0;
95 +
96 + while (p) {
97 + copyBuffer(p.data, ret, i);
98 + i += p.data.length;
99 + p = p.next;
100 + }
101 +
102 + return ret;
103 + } // Consumes a specified amount of bytes or characters from the buffered data.
104 +
105 + }, {
106 + key: "consume",
107 + value: function consume(n, hasStrings) {
108 + var ret;
109 +
110 + if (n < this.head.data.length) {
111 + // `slice` is the same for buffers and strings.
112 + ret = this.head.data.slice(0, n);
113 + this.head.data = this.head.data.slice(n);
114 + } else if (n === this.head.data.length) {
115 + // First chunk is a perfect match.
116 + ret = this.shift();
117 + } else {
118 + // Result spans more than one buffer.
119 + ret = hasStrings ? this._getString(n) : this._getBuffer(n);
120 + }
121 +
122 + return ret;
123 + }
124 + }, {
125 + key: "first",
126 + value: function first() {
127 + return this.head.data;
128 + } // Consumes a specified amount of characters from the buffered data.
129 +
130 + }, {
131 + key: "_getString",
132 + value: function _getString(n) {
133 + var p = this.head;
134 + var c = 1;
135 + var ret = p.data;
136 + n -= ret.length;
137 +
138 + while (p = p.next) {
139 + var str = p.data;
140 + var nb = n > str.length ? str.length : n;
141 + if (nb === str.length) ret += str;else ret += str.slice(0, n);
142 + n -= nb;
143 +
144 + if (n === 0) {
145 + if (nb === str.length) {
146 + ++c;
147 + if (p.next) this.head = p.next;else this.head = this.tail = null;
148 + } else {
149 + this.head = p;
150 + p.data = str.slice(nb);
151 + }
152 +
153 + break;
154 + }
155 +
156 + ++c;
157 + }
158 +
159 + this.length -= c;
160 + return ret;
161 + } // Consumes a specified amount of bytes from the buffered data.
162 +
163 + }, {
164 + key: "_getBuffer",
165 + value: function _getBuffer(n) {
166 + var ret = Buffer.allocUnsafe(n);
167 + var p = this.head;
168 + var c = 1;
169 + p.data.copy(ret);
170 + n -= p.data.length;
171 +
172 + while (p = p.next) {
173 + var buf = p.data;
174 + var nb = n > buf.length ? buf.length : n;
175 + buf.copy(ret, ret.length - n, 0, nb);
176 + n -= nb;
177 +
178 + if (n === 0) {
179 + if (nb === buf.length) {
180 + ++c;
181 + if (p.next) this.head = p.next;else this.head = this.tail = null;
182 + } else {
183 + this.head = p;
184 + p.data = buf.slice(nb);
185 + }
186 +
187 + break;
188 + }
189 +
190 + ++c;
191 + }
192 +
193 + this.length -= c;
194 + return ret;
195 + } // Make sure the linked list only shows the minimal necessary information.
196 +
197 + }, {
198 + key: custom,
199 + value: function value(_, options) {
200 + return inspect(this, _objectSpread({}, options, {
201 + // Only inspect one level.
202 + depth: 0,
203 + // It should not recurse.
204 + customInspect: false
205 + }));
206 + }
207 + }]);
208 +
209 + return BufferList;
210 +}();
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict'; // undocumented cb() API, needed for core, not for public API
2 +
3 +function destroy(err, cb) {
4 + var _this = this;
5 +
6 + var readableDestroyed = this._readableState && this._readableState.destroyed;
7 + var writableDestroyed = this._writableState && this._writableState.destroyed;
8 +
9 + if (readableDestroyed || writableDestroyed) {
10 + if (cb) {
11 + cb(err);
12 + } else if (err) {
13 + if (!this._writableState) {
14 + process.nextTick(emitErrorNT, this, err);
15 + } else if (!this._writableState.errorEmitted) {
16 + this._writableState.errorEmitted = true;
17 + process.nextTick(emitErrorNT, this, err);
18 + }
19 + }
20 +
21 + return this;
22 + } // we set destroyed to true before firing error callbacks in order
23 + // to make it re-entrance safe in case destroy() is called within callbacks
24 +
25 +
26 + if (this._readableState) {
27 + this._readableState.destroyed = true;
28 + } // if this is a duplex stream mark the writable part as destroyed as well
29 +
30 +
31 + if (this._writableState) {
32 + this._writableState.destroyed = true;
33 + }
34 +
35 + this._destroy(err || null, function (err) {
36 + if (!cb && err) {
37 + if (!_this._writableState) {
38 + process.nextTick(emitErrorAndCloseNT, _this, err);
39 + } else if (!_this._writableState.errorEmitted) {
40 + _this._writableState.errorEmitted = true;
41 + process.nextTick(emitErrorAndCloseNT, _this, err);
42 + } else {
43 + process.nextTick(emitCloseNT, _this);
44 + }
45 + } else if (cb) {
46 + process.nextTick(emitCloseNT, _this);
47 + cb(err);
48 + } else {
49 + process.nextTick(emitCloseNT, _this);
50 + }
51 + });
52 +
53 + return this;
54 +}
55 +
56 +function emitErrorAndCloseNT(self, err) {
57 + emitErrorNT(self, err);
58 + emitCloseNT(self);
59 +}
60 +
61 +function emitCloseNT(self) {
62 + if (self._writableState && !self._writableState.emitClose) return;
63 + if (self._readableState && !self._readableState.emitClose) return;
64 + self.emit('close');
65 +}
66 +
67 +function undestroy() {
68 + if (this._readableState) {
69 + this._readableState.destroyed = false;
70 + this._readableState.reading = false;
71 + this._readableState.ended = false;
72 + this._readableState.endEmitted = false;
73 + }
74 +
75 + if (this._writableState) {
76 + this._writableState.destroyed = false;
77 + this._writableState.ended = false;
78 + this._writableState.ending = false;
79 + this._writableState.finalCalled = false;
80 + this._writableState.prefinished = false;
81 + this._writableState.finished = false;
82 + this._writableState.errorEmitted = false;
83 + }
84 +}
85 +
86 +function emitErrorNT(self, err) {
87 + self.emit('error', err);
88 +}
89 +
90 +function errorOrDestroy(stream, err) {
91 + // We have tests that rely on errors being emitted
92 + // in the same tick, so changing this is semver major.
93 + // For now when you opt-in to autoDestroy we allow
94 + // the error to be emitted nextTick. In a future
95 + // semver major update we should change the default to this.
96 + var rState = stream._readableState;
97 + var wState = stream._writableState;
98 + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
99 +}
100 +
101 +module.exports = {
102 + destroy: destroy,
103 + undestroy: undestroy,
104 + errorOrDestroy: errorOrDestroy
105 +};
...\ No newline at end of file ...\ No newline at end of file
1 +// Ported from https://github.com/mafintosh/end-of-stream with
2 +// permission from the author, Mathias Buus (@mafintosh).
3 +'use strict';
4 +
5 +var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;
6 +
7 +function once(callback) {
8 + var called = false;
9 + return function () {
10 + if (called) return;
11 + called = true;
12 +
13 + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
14 + args[_key] = arguments[_key];
15 + }
16 +
17 + callback.apply(this, args);
18 + };
19 +}
20 +
21 +function noop() {}
22 +
23 +function isRequest(stream) {
24 + return stream.setHeader && typeof stream.abort === 'function';
25 +}
26 +
27 +function eos(stream, opts, callback) {
28 + if (typeof opts === 'function') return eos(stream, null, opts);
29 + if (!opts) opts = {};
30 + callback = once(callback || noop);
31 + var readable = opts.readable || opts.readable !== false && stream.readable;
32 + var writable = opts.writable || opts.writable !== false && stream.writable;
33 +
34 + var onlegacyfinish = function onlegacyfinish() {
35 + if (!stream.writable) onfinish();
36 + };
37 +
38 + var writableEnded = stream._writableState && stream._writableState.finished;
39 +
40 + var onfinish = function onfinish() {
41 + writable = false;
42 + writableEnded = true;
43 + if (!readable) callback.call(stream);
44 + };
45 +
46 + var readableEnded = stream._readableState && stream._readableState.endEmitted;
47 +
48 + var onend = function onend() {
49 + readable = false;
50 + readableEnded = true;
51 + if (!writable) callback.call(stream);
52 + };
53 +
54 + var onerror = function onerror(err) {
55 + callback.call(stream, err);
56 + };
57 +
58 + var onclose = function onclose() {
59 + var err;
60 +
61 + if (readable && !readableEnded) {
62 + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
63 + return callback.call(stream, err);
64 + }
65 +
66 + if (writable && !writableEnded) {
67 + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
68 + return callback.call(stream, err);
69 + }
70 + };
71 +
72 + var onrequest = function onrequest() {
73 + stream.req.on('finish', onfinish);
74 + };
75 +
76 + if (isRequest(stream)) {
77 + stream.on('complete', onfinish);
78 + stream.on('abort', onclose);
79 + if (stream.req) onrequest();else stream.on('request', onrequest);
80 + } else if (writable && !stream._writableState) {
81 + // legacy streams
82 + stream.on('end', onlegacyfinish);
83 + stream.on('close', onlegacyfinish);
84 + }
85 +
86 + stream.on('end', onend);
87 + stream.on('finish', onfinish);
88 + if (opts.error !== false) stream.on('error', onerror);
89 + stream.on('close', onclose);
90 + return function () {
91 + stream.removeListener('complete', onfinish);
92 + stream.removeListener('abort', onclose);
93 + stream.removeListener('request', onrequest);
94 + if (stream.req) stream.req.removeListener('finish', onfinish);
95 + stream.removeListener('end', onlegacyfinish);
96 + stream.removeListener('close', onlegacyfinish);
97 + stream.removeListener('finish', onfinish);
98 + stream.removeListener('end', onend);
99 + stream.removeListener('error', onerror);
100 + stream.removeListener('close', onclose);
101 + };
102 +}
103 +
104 +module.exports = eos;
...\ No newline at end of file ...\ No newline at end of file
1 +module.exports = function () {
2 + throw new Error('Readable.from is not available in the browser')
3 +};
1 +'use strict';
2 +
3 +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4 +
5 +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); }); }; }
6 +
7 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
8 +
9 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
10 +
11 +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12 +
13 +var ERR_INVALID_ARG_TYPE = require('../../../errors').codes.ERR_INVALID_ARG_TYPE;
14 +
15 +function from(Readable, iterable, opts) {
16 + var iterator;
17 +
18 + if (iterable && typeof iterable.next === 'function') {
19 + iterator = iterable;
20 + } else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);
21 +
22 + var readable = new Readable(_objectSpread({
23 + objectMode: true
24 + }, opts)); // Reading boolean to protect against _read
25 + // being called before last iteration completion.
26 +
27 + var reading = false;
28 +
29 + readable._read = function () {
30 + if (!reading) {
31 + reading = true;
32 + next();
33 + }
34 + };
35 +
36 + function next() {
37 + return _next2.apply(this, arguments);
38 + }
39 +
40 + function _next2() {
41 + _next2 = _asyncToGenerator(function* () {
42 + try {
43 + var _ref = yield iterator.next(),
44 + value = _ref.value,
45 + done = _ref.done;
46 +
47 + if (done) {
48 + readable.push(null);
49 + } else if (readable.push((yield value))) {
50 + next();
51 + } else {
52 + reading = false;
53 + }
54 + } catch (err) {
55 + readable.destroy(err);
56 + }
57 + });
58 + return _next2.apply(this, arguments);
59 + }
60 +
61 + return readable;
62 +}
63 +
64 +module.exports = from;
...\ No newline at end of file ...\ No newline at end of file
1 +// Ported from https://github.com/mafintosh/pump with
2 +// permission from the author, Mathias Buus (@mafintosh).
3 +'use strict';
4 +
5 +var eos;
6 +
7 +function once(callback) {
8 + var called = false;
9 + return function () {
10 + if (called) return;
11 + called = true;
12 + callback.apply(void 0, arguments);
13 + };
14 +}
15 +
16 +var _require$codes = require('../../../errors').codes,
17 + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
18 + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
19 +
20 +function noop(err) {
21 + // Rethrow the error if it exists to avoid swallowing it
22 + if (err) throw err;
23 +}
24 +
25 +function isRequest(stream) {
26 + return stream.setHeader && typeof stream.abort === 'function';
27 +}
28 +
29 +function destroyer(stream, reading, writing, callback) {
30 + callback = once(callback);
31 + var closed = false;
32 + stream.on('close', function () {
33 + closed = true;
34 + });
35 + if (eos === undefined) eos = require('./end-of-stream');
36 + eos(stream, {
37 + readable: reading,
38 + writable: writing
39 + }, function (err) {
40 + if (err) return callback(err);
41 + closed = true;
42 + callback();
43 + });
44 + var destroyed = false;
45 + return function (err) {
46 + if (closed) return;
47 + if (destroyed) return;
48 + destroyed = true; // request.destroy just do .end - .abort is what we want
49 +
50 + if (isRequest(stream)) return stream.abort();
51 + if (typeof stream.destroy === 'function') return stream.destroy();
52 + callback(err || new ERR_STREAM_DESTROYED('pipe'));
53 + };
54 +}
55 +
56 +function call(fn) {
57 + fn();
58 +}
59 +
60 +function pipe(from, to) {
61 + return from.pipe(to);
62 +}
63 +
64 +function popCallback(streams) {
65 + if (!streams.length) return noop;
66 + if (typeof streams[streams.length - 1] !== 'function') return noop;
67 + return streams.pop();
68 +}
69 +
70 +function pipeline() {
71 + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
72 + streams[_key] = arguments[_key];
73 + }
74 +
75 + var callback = popCallback(streams);
76 + if (Array.isArray(streams[0])) streams = streams[0];
77 +
78 + if (streams.length < 2) {
79 + throw new ERR_MISSING_ARGS('streams');
80 + }
81 +
82 + var error;
83 + var destroys = streams.map(function (stream, i) {
84 + var reading = i < streams.length - 1;
85 + var writing = i > 0;
86 + return destroyer(stream, reading, writing, function (err) {
87 + if (!error) error = err;
88 + if (err) destroys.forEach(call);
89 + if (reading) return;
90 + destroys.forEach(call);
91 + callback(error);
92 + });
93 + });
94 + return streams.reduce(pipe);
95 +}
96 +
97 +module.exports = pipeline;
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
4 +
5 +function highWaterMarkFrom(options, isDuplex, duplexKey) {
6 + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
7 +}
8 +
9 +function getHighWaterMark(state, options, duplexKey, isDuplex) {
10 + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
11 +
12 + if (hwm != null) {
13 + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
14 + var name = isDuplex ? duplexKey : 'highWaterMark';
15 + throw new ERR_INVALID_OPT_VALUE(name, hwm);
16 + }
17 +
18 + return Math.floor(hwm);
19 + } // Default value
20 +
21 +
22 + return state.objectMode ? 16 : 16 * 1024;
23 +}
24 +
25 +module.exports = {
26 + getHighWaterMark: getHighWaterMark
27 +};
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "_from": "readable-stream@^3.4.0",
3 + "_id": "readable-stream@3.6.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
6 + "_location": "/bl/readable-stream",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "readable-stream@^3.4.0",
12 + "name": "readable-stream",
13 + "escapedName": "readable-stream",
14 + "rawSpec": "^3.4.0",
15 + "saveSpec": null,
16 + "fetchSpec": "^3.4.0"
17 + },
18 + "_requiredBy": [
19 + "/bl"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
22 + "_shasum": "337bbda3adc0706bd3e024426a286d4b4b2c9198",
23 + "_spec": "readable-stream@^3.4.0",
24 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\bl",
25 + "browser": {
26 + "util": false,
27 + "worker_threads": false,
28 + "./errors": "./errors-browser.js",
29 + "./readable.js": "./readable-browser.js",
30 + "./lib/internal/streams/from.js": "./lib/internal/streams/from-browser.js",
31 + "./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
32 + },
33 + "bugs": {
34 + "url": "https://github.com/nodejs/readable-stream/issues"
35 + },
36 + "bundleDependencies": false,
37 + "dependencies": {
38 + "inherits": "^2.0.3",
39 + "string_decoder": "^1.1.1",
40 + "util-deprecate": "^1.0.1"
41 + },
42 + "deprecated": false,
43 + "description": "Streams3, a user-land copy of the stream library from Node.js",
44 + "devDependencies": {
45 + "@babel/cli": "^7.2.0",
46 + "@babel/core": "^7.2.0",
47 + "@babel/polyfill": "^7.0.0",
48 + "@babel/preset-env": "^7.2.0",
49 + "airtap": "0.0.9",
50 + "assert": "^1.4.0",
51 + "bl": "^2.0.0",
52 + "deep-strict-equal": "^0.2.0",
53 + "events.once": "^2.0.2",
54 + "glob": "^7.1.2",
55 + "gunzip-maybe": "^1.4.1",
56 + "hyperquest": "^2.1.3",
57 + "lolex": "^2.6.0",
58 + "nyc": "^11.0.0",
59 + "pump": "^3.0.0",
60 + "rimraf": "^2.6.2",
61 + "tap": "^12.0.0",
62 + "tape": "^4.9.0",
63 + "tar-fs": "^1.16.2",
64 + "util-promisify": "^2.1.0"
65 + },
66 + "engines": {
67 + "node": ">= 6"
68 + },
69 + "homepage": "https://github.com/nodejs/readable-stream#readme",
70 + "keywords": [
71 + "readable",
72 + "stream",
73 + "pipe"
74 + ],
75 + "license": "MIT",
76 + "main": "readable.js",
77 + "name": "readable-stream",
78 + "nyc": {
79 + "include": [
80 + "lib/**.js"
81 + ]
82 + },
83 + "repository": {
84 + "type": "git",
85 + "url": "git://github.com/nodejs/readable-stream.git"
86 + },
87 + "scripts": {
88 + "ci": "TAP=1 tap --no-esm test/parallel/*.js test/ours/*.js | tee test.tap",
89 + "cover": "nyc npm test",
90 + "report": "nyc report --reporter=lcov",
91 + "test": "tap -J --no-esm test/parallel/*.js test/ours/*.js",
92 + "test-browser-local": "airtap --open --local -- test/browser.js",
93 + "test-browsers": "airtap --sauce-connect --loopback airtap.local -- test/browser.js",
94 + "update-browser-errors": "babel -o errors-browser.js errors.js"
95 + },
96 + "version": "3.6.0"
97 +}
1 +exports = module.exports = require('./lib/_stream_readable.js');
2 +exports.Stream = exports;
3 +exports.Readable = exports;
4 +exports.Writable = require('./lib/_stream_writable.js');
5 +exports.Duplex = require('./lib/_stream_duplex.js');
6 +exports.Transform = require('./lib/_stream_transform.js');
7 +exports.PassThrough = require('./lib/_stream_passthrough.js');
8 +exports.finished = require('./lib/internal/streams/end-of-stream.js');
9 +exports.pipeline = require('./lib/internal/streams/pipeline.js');
1 +var Stream = require('stream');
2 +if (process.env.READABLE_STREAM === 'disable' && Stream) {
3 + module.exports = Stream.Readable;
4 + Object.assign(module.exports, Stream);
5 + module.exports.Stream = Stream;
6 +} else {
7 + exports = module.exports = require('./lib/_stream_readable.js');
8 + exports.Stream = Stream || exports;
9 + exports.Readable = exports;
10 + exports.Writable = require('./lib/_stream_writable.js');
11 + exports.Duplex = require('./lib/_stream_duplex.js');
12 + exports.Transform = require('./lib/_stream_transform.js');
13 + exports.PassThrough = require('./lib/_stream_passthrough.js');
14 + exports.finished = require('./lib/internal/streams/end-of-stream.js');
15 + exports.pipeline = require('./lib/internal/streams/pipeline.js');
16 +}
1 +{
2 + "_from": "bl@^4.0.3",
3 + "_id": "bl@4.1.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",
6 + "_location": "/bl",
7 + "_phantomChildren": {
8 + "string_decoder": "1.1.1",
9 + "util-deprecate": "1.0.2"
10 + },
11 + "_requested": {
12 + "type": "range",
13 + "registry": true,
14 + "raw": "bl@^4.0.3",
15 + "name": "bl",
16 + "escapedName": "bl",
17 + "rawSpec": "^4.0.3",
18 + "saveSpec": null,
19 + "fetchSpec": "^4.0.3"
20 + },
21 + "_requiredBy": [
22 + "/tar-stream"
23 + ],
24 + "_resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
25 + "_shasum": "451535264182bec2fbbc83a62ab98cf11d9f7b3a",
26 + "_spec": "bl@^4.0.3",
27 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\tar-stream",
28 + "authors": [
29 + "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)",
30 + "Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
31 + "Jarett Cruger <jcrugzz@gmail.com> (https://github.com/jcrugzz)"
32 + ],
33 + "bugs": {
34 + "url": "https://github.com/rvagg/bl/issues"
35 + },
36 + "bundleDependencies": false,
37 + "dependencies": {
38 + "buffer": "^5.5.0",
39 + "inherits": "^2.0.4",
40 + "readable-stream": "^3.4.0"
41 + },
42 + "deprecated": false,
43 + "description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
44 + "devDependencies": {
45 + "faucet": "~0.0.1",
46 + "standard": "^14.3.0",
47 + "tape": "^4.11.0"
48 + },
49 + "homepage": "https://github.com/rvagg/bl",
50 + "keywords": [
51 + "buffer",
52 + "buffers",
53 + "stream",
54 + "awesomesauce"
55 + ],
56 + "license": "MIT",
57 + "main": "bl.js",
58 + "name": "bl",
59 + "repository": {
60 + "type": "git",
61 + "url": "git+https://github.com/rvagg/bl.git"
62 + },
63 + "scripts": {
64 + "lint": "standard *.js test/*.js",
65 + "test": "npm run lint && node test/test.js | faucet"
66 + },
67 + "version": "4.1.0"
68 +}
1 +'use strict'
2 +
3 +const tape = require('tape')
4 +const { BufferList, BufferListStream } = require('../')
5 +const { Buffer } = require('buffer')
6 +
7 +tape('convert from BufferList to BufferListStream', (t) => {
8 + const data = Buffer.from(`TEST-${Date.now()}`)
9 + const bl = new BufferList(data)
10 + const bls = new BufferListStream(bl)
11 + t.ok(bl.slice().equals(bls.slice()))
12 + t.end()
13 +})
14 +
15 +tape('convert from BufferListStream to BufferList', (t) => {
16 + const data = Buffer.from(`TEST-${Date.now()}`)
17 + const bls = new BufferListStream(data)
18 + const bl = new BufferList(bls)
19 + t.ok(bl.slice().equals(bls.slice()))
20 + t.end()
21 +})
This diff is collapsed. Click to expand it.
1 +'use strict'
2 +
3 +const tape = require('tape')
4 +const { BufferList, BufferListStream } = require('../')
5 +const { Buffer } = require('buffer')
6 +
7 +tape('isBufferList positives', (t) => {
8 + t.ok(BufferList.isBufferList(new BufferList()))
9 + t.ok(BufferList.isBufferList(new BufferListStream()))
10 +
11 + t.end()
12 +})
13 +
14 +tape('isBufferList negatives', (t) => {
15 + const types = [
16 + null,
17 + undefined,
18 + NaN,
19 + true,
20 + false,
21 + {},
22 + [],
23 + Buffer.alloc(0),
24 + [Buffer.alloc(0)]
25 + ]
26 +
27 + for (const obj of types) {
28 + t.notOk(BufferList.isBufferList(obj))
29 + }
30 +
31 + t.end()
32 +})
This diff is collapsed. Click to expand it.
1 +The ISC License
2 +
3 +Copyright (c) Isaac Z. Schlueter and Contributors
4 +
5 +Permission to use, copy, modify, and/or distribute this software for any
6 +purpose with or without fee is hereby granted, provided that the above
7 +copyright notice and this permission notice appear in all copies.
8 +
9 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15 +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1 +Like `chown -R`.
2 +
3 +Takes the same arguments as `fs.chown()`
1 +'use strict'
2 +const fs = require('fs')
3 +const path = require('path')
4 +
5 +/* istanbul ignore next */
6 +const LCHOWN = fs.lchown ? 'lchown' : 'chown'
7 +/* istanbul ignore next */
8 +const LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'
9 +
10 +/* istanbul ignore next */
11 +const needEISDIRHandled = fs.lchown &&
12 + !process.version.match(/v1[1-9]+\./) &&
13 + !process.version.match(/v10\.[6-9]/)
14 +
15 +const lchownSync = (path, uid, gid) => {
16 + try {
17 + return fs[LCHOWNSYNC](path, uid, gid)
18 + } catch (er) {
19 + if (er.code !== 'ENOENT')
20 + throw er
21 + }
22 +}
23 +
24 +/* istanbul ignore next */
25 +const chownSync = (path, uid, gid) => {
26 + try {
27 + return fs.chownSync(path, uid, gid)
28 + } catch (er) {
29 + if (er.code !== 'ENOENT')
30 + throw er
31 + }
32 +}
33 +
34 +/* istanbul ignore next */
35 +const handleEISDIR =
36 + needEISDIRHandled ? (path, uid, gid, cb) => er => {
37 + // Node prior to v10 had a very questionable implementation of
38 + // fs.lchown, which would always try to call fs.open on a directory
39 + // Fall back to fs.chown in those cases.
40 + if (!er || er.code !== 'EISDIR')
41 + cb(er)
42 + else
43 + fs.chown(path, uid, gid, cb)
44 + }
45 + : (_, __, ___, cb) => cb
46 +
47 +/* istanbul ignore next */
48 +const handleEISDirSync =
49 + needEISDIRHandled ? (path, uid, gid) => {
50 + try {
51 + return lchownSync(path, uid, gid)
52 + } catch (er) {
53 + if (er.code !== 'EISDIR')
54 + throw er
55 + chownSync(path, uid, gid)
56 + }
57 + }
58 + : (path, uid, gid) => lchownSync(path, uid, gid)
59 +
60 +// fs.readdir could only accept an options object as of node v6
61 +const nodeVersion = process.version
62 +let readdir = (path, options, cb) => fs.readdir(path, options, cb)
63 +let readdirSync = (path, options) => fs.readdirSync(path, options)
64 +/* istanbul ignore next */
65 +if (/^v4\./.test(nodeVersion))
66 + readdir = (path, options, cb) => fs.readdir(path, cb)
67 +
68 +const chown = (cpath, uid, gid, cb) => {
69 + fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, er => {
70 + // Skip ENOENT error
71 + cb(er && er.code !== 'ENOENT' ? er : null)
72 + }))
73 +}
74 +
75 +const chownrKid = (p, child, uid, gid, cb) => {
76 + if (typeof child === 'string')
77 + return fs.lstat(path.resolve(p, child), (er, stats) => {
78 + // Skip ENOENT error
79 + if (er)
80 + return cb(er.code !== 'ENOENT' ? er : null)
81 + stats.name = child
82 + chownrKid(p, stats, uid, gid, cb)
83 + })
84 +
85 + if (child.isDirectory()) {
86 + chownr(path.resolve(p, child.name), uid, gid, er => {
87 + if (er)
88 + return cb(er)
89 + const cpath = path.resolve(p, child.name)
90 + chown(cpath, uid, gid, cb)
91 + })
92 + } else {
93 + const cpath = path.resolve(p, child.name)
94 + chown(cpath, uid, gid, cb)
95 + }
96 +}
97 +
98 +
99 +const chownr = (p, uid, gid, cb) => {
100 + readdir(p, { withFileTypes: true }, (er, children) => {
101 + // any error other than ENOTDIR or ENOTSUP means it's not readable,
102 + // or doesn't exist. give up.
103 + if (er) {
104 + if (er.code === 'ENOENT')
105 + return cb()
106 + else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')
107 + return cb(er)
108 + }
109 + if (er || !children.length)
110 + return chown(p, uid, gid, cb)
111 +
112 + let len = children.length
113 + let errState = null
114 + const then = er => {
115 + if (errState)
116 + return
117 + if (er)
118 + return cb(errState = er)
119 + if (-- len === 0)
120 + return chown(p, uid, gid, cb)
121 + }
122 +
123 + children.forEach(child => chownrKid(p, child, uid, gid, then))
124 + })
125 +}
126 +
127 +const chownrKidSync = (p, child, uid, gid) => {
128 + if (typeof child === 'string') {
129 + try {
130 + const stats = fs.lstatSync(path.resolve(p, child))
131 + stats.name = child
132 + child = stats
133 + } catch (er) {
134 + if (er.code === 'ENOENT')
135 + return
136 + else
137 + throw er
138 + }
139 + }
140 +
141 + if (child.isDirectory())
142 + chownrSync(path.resolve(p, child.name), uid, gid)
143 +
144 + handleEISDirSync(path.resolve(p, child.name), uid, gid)
145 +}
146 +
147 +const chownrSync = (p, uid, gid) => {
148 + let children
149 + try {
150 + children = readdirSync(p, { withFileTypes: true })
151 + } catch (er) {
152 + if (er.code === 'ENOENT')
153 + return
154 + else if (er.code === 'ENOTDIR' || er.code === 'ENOTSUP')
155 + return handleEISDirSync(p, uid, gid)
156 + else
157 + throw er
158 + }
159 +
160 + if (children && children.length)
161 + children.forEach(child => chownrKidSync(p, child, uid, gid))
162 +
163 + return handleEISDirSync(p, uid, gid)
164 +}
165 +
166 +module.exports = chownr
167 +chownr.sync = chownrSync
1 +{
2 + "_from": "chownr@^1.1.1",
3 + "_id": "chownr@1.1.4",
4 + "_inBundle": false,
5 + "_integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==",
6 + "_location": "/chownr",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "chownr@^1.1.1",
12 + "name": "chownr",
13 + "escapedName": "chownr",
14 + "rawSpec": "^1.1.1",
15 + "saveSpec": null,
16 + "fetchSpec": "^1.1.1"
17 + },
18 + "_requiredBy": [
19 + "/tar-fs"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
22 + "_shasum": "6fc9d7b42d32a583596337666e7d08084da2cc6b",
23 + "_spec": "chownr@^1.1.1",
24 + "_where": "C:\\Users\\bshoo\\Desktop\\OSS\\Singer-Composer\\node_modules\\tar-fs",
25 + "author": {
26 + "name": "Isaac Z. Schlueter",
27 + "email": "i@izs.me",
28 + "url": "http://blog.izs.me/"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/isaacs/chownr/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "like `chown -R`",
36 + "devDependencies": {
37 + "mkdirp": "0.3",
38 + "rimraf": "^2.7.1",
39 + "tap": "^14.10.6"
40 + },
41 + "files": [
42 + "chownr.js"
43 + ],
44 + "homepage": "https://github.com/isaacs/chownr#readme",
45 + "license": "ISC",
46 + "main": "chownr.js",
47 + "name": "chownr",
48 + "repository": {
49 + "type": "git",
50 + "url": "git://github.com/isaacs/chownr.git"
51 + },
52 + "scripts": {
53 + "postversion": "npm publish",
54 + "prepublishOnly": "git push origin --follow-tags",
55 + "preversion": "npm test",
56 + "test": "tap"
57 + },
58 + "tap": {
59 + "check-coverage": true
60 + },
61 + "version": "1.1.4"
62 +}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
No preview for this file type
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This file is too large to display.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.