Run npm install (#43)
All checks were successful
Lint / pre-commit Linting (push) Successful in 1m18s
All checks were successful
Lint / pre-commit Linting (push) Successful in 1m18s
Reviewed-on: #43
This commit was merged in pull request #43.
This commit is contained in:
12
node_modules/.bin/detect-libc
generated
vendored
12
node_modules/.bin/detect-libc
generated
vendored
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
exec "$basedir/node" "$basedir/../detect-libc/bin/detect-libc.js" "$@"
|
|
||||||
else
|
|
||||||
exec node "$basedir/../detect-libc/bin/detect-libc.js" "$@"
|
|
||||||
fi
|
|
||||||
17
node_modules/.bin/detect-libc.cmd
generated
vendored
17
node_modules/.bin/detect-libc.cmd
generated
vendored
@@ -1,17 +0,0 @@
|
|||||||
@ECHO off
|
|
||||||
GOTO start
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
||||||
:start
|
|
||||||
SETLOCAL
|
|
||||||
CALL :find_dp0
|
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
|
||||||
SET "_prog=%dp0%\node.exe"
|
|
||||||
) ELSE (
|
|
||||||
SET "_prog=node"
|
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
)
|
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\detect-libc\bin\detect-libc.js" %*
|
|
||||||
28
node_modules/.bin/detect-libc.ps1
generated
vendored
28
node_modules/.bin/detect-libc.ps1
generated
vendored
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "$basedir/node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
|
||||||
} else {
|
|
||||||
& "$basedir/node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
||||||
12
node_modules/.bin/mkdirp
generated
vendored
12
node_modules/.bin/mkdirp
generated
vendored
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
exec "$basedir/node" "$basedir/../mkdirp/bin/cmd.js" "$@"
|
|
||||||
else
|
|
||||||
exec node "$basedir/../mkdirp/bin/cmd.js" "$@"
|
|
||||||
fi
|
|
||||||
17
node_modules/.bin/mkdirp.cmd
generated
vendored
17
node_modules/.bin/mkdirp.cmd
generated
vendored
@@ -1,17 +0,0 @@
|
|||||||
@ECHO off
|
|
||||||
GOTO start
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
||||||
:start
|
|
||||||
SETLOCAL
|
|
||||||
CALL :find_dp0
|
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
|
||||||
SET "_prog=%dp0%\node.exe"
|
|
||||||
) ELSE (
|
|
||||||
SET "_prog=node"
|
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
)
|
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mkdirp\bin\cmd.js" %*
|
|
||||||
28
node_modules/.bin/mkdirp.ps1
generated
vendored
28
node_modules/.bin/mkdirp.ps1
generated
vendored
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
|
||||||
} else {
|
|
||||||
& "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
||||||
12
node_modules/.bin/prebuild-install
generated
vendored
12
node_modules/.bin/prebuild-install
generated
vendored
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
exec "$basedir/node" "$basedir/../prebuild-install/bin.js" "$@"
|
|
||||||
else
|
|
||||||
exec node "$basedir/../prebuild-install/bin.js" "$@"
|
|
||||||
fi
|
|
||||||
17
node_modules/.bin/prebuild-install.cmd
generated
vendored
17
node_modules/.bin/prebuild-install.cmd
generated
vendored
@@ -1,17 +0,0 @@
|
|||||||
@ECHO off
|
|
||||||
GOTO start
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
||||||
:start
|
|
||||||
SETLOCAL
|
|
||||||
CALL :find_dp0
|
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
|
||||||
SET "_prog=%dp0%\node.exe"
|
|
||||||
) ELSE (
|
|
||||||
SET "_prog=node"
|
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
)
|
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\prebuild-install\bin.js" %*
|
|
||||||
28
node_modules/.bin/prebuild-install.ps1
generated
vendored
28
node_modules/.bin/prebuild-install.ps1
generated
vendored
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "$basedir/node$exe" "$basedir/../prebuild-install/bin.js" $args
|
|
||||||
} else {
|
|
||||||
& "$basedir/node$exe" "$basedir/../prebuild-install/bin.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "node$exe" "$basedir/../prebuild-install/bin.js" $args
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../prebuild-install/bin.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
||||||
12
node_modules/.bin/rc
generated
vendored
12
node_modules/.bin/rc
generated
vendored
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
exec "$basedir/node" "$basedir/../rc/cli.js" "$@"
|
|
||||||
else
|
|
||||||
exec node "$basedir/../rc/cli.js" "$@"
|
|
||||||
fi
|
|
||||||
17
node_modules/.bin/rc.cmd
generated
vendored
17
node_modules/.bin/rc.cmd
generated
vendored
@@ -1,17 +0,0 @@
|
|||||||
@ECHO off
|
|
||||||
GOTO start
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
||||||
:start
|
|
||||||
SETLOCAL
|
|
||||||
CALL :find_dp0
|
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
|
||||||
SET "_prog=%dp0%\node.exe"
|
|
||||||
) ELSE (
|
|
||||||
SET "_prog=node"
|
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
)
|
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\rc\cli.js" %*
|
|
||||||
28
node_modules/.bin/rc.ps1
generated
vendored
28
node_modules/.bin/rc.ps1
generated
vendored
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "$basedir/node$exe" "$basedir/../rc/cli.js" $args
|
|
||||||
} else {
|
|
||||||
& "$basedir/node$exe" "$basedir/../rc/cli.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "node$exe" "$basedir/../rc/cli.js" $args
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../rc/cli.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
||||||
12
node_modules/.bin/semver
generated
vendored
12
node_modules/.bin/semver
generated
vendored
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
exec "$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
|
||||||
else
|
|
||||||
exec node "$basedir/../semver/bin/semver" "$@"
|
|
||||||
fi
|
|
||||||
17
node_modules/.bin/semver.cmd
generated
vendored
17
node_modules/.bin/semver.cmd
generated
vendored
@@ -1,17 +0,0 @@
|
|||||||
@ECHO off
|
|
||||||
GOTO start
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
||||||
:start
|
|
||||||
SETLOCAL
|
|
||||||
CALL :find_dp0
|
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
|
||||||
SET "_prog=%dp0%\node.exe"
|
|
||||||
) ELSE (
|
|
||||||
SET "_prog=node"
|
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
)
|
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver" %*
|
|
||||||
28
node_modules/.bin/semver.ps1
generated
vendored
28
node_modules/.bin/semver.ps1
generated
vendored
@@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
|
||||||
} else {
|
|
||||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "node$exe" "$basedir/../semver/bin/semver" $args
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../semver/bin/semver" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
||||||
1020
node_modules/.package-lock.json
generated
vendored
1020
node_modules/.package-lock.json
generated
vendored
File diff suppressed because it is too large
Load Diff
14
node_modules/aproba/LICENSE
generated
vendored
14
node_modules/aproba/LICENSE
generated
vendored
@@ -1,14 +0,0 @@
|
|||||||
Copyright (c) 2015, Rebecca Turner <me@re-becca.org>
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
94
node_modules/aproba/README.md
generated
vendored
94
node_modules/aproba/README.md
generated
vendored
@@ -1,94 +0,0 @@
|
|||||||
aproba
|
|
||||||
======
|
|
||||||
|
|
||||||
A ridiculously light-weight function argument validator
|
|
||||||
|
|
||||||
```
|
|
||||||
var validate = require("aproba")
|
|
||||||
|
|
||||||
function myfunc(a, b, c) {
|
|
||||||
// `a` must be a string, `b` a number, `c` a function
|
|
||||||
validate('SNF', arguments) // [a,b,c] is also valid
|
|
||||||
}
|
|
||||||
|
|
||||||
myfunc('test', 23, function () {}) // ok
|
|
||||||
myfunc(123, 23, function () {}) // type error
|
|
||||||
myfunc('test', 23) // missing arg error
|
|
||||||
myfunc('test', 23, function () {}, true) // too many args error
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Valid types are:
|
|
||||||
|
|
||||||
| type | description
|
|
||||||
| :--: | :----------
|
|
||||||
| * | matches any type
|
|
||||||
| A | `Array.isArray` OR an `arguments` object
|
|
||||||
| S | typeof == string
|
|
||||||
| N | typeof == number
|
|
||||||
| F | typeof == function
|
|
||||||
| O | typeof == object and not type A and not type E
|
|
||||||
| B | typeof == boolean
|
|
||||||
| E | `instanceof Error` OR `null` **(special: see below)**
|
|
||||||
| Z | == `null`
|
|
||||||
|
|
||||||
Validation failures throw one of three exception types, distinguished by a
|
|
||||||
`code` property of `EMISSINGARG`, `EINVALIDTYPE` or `ETOOMANYARGS`.
|
|
||||||
|
|
||||||
If you pass in an invalid type then it will throw with a code of
|
|
||||||
`EUNKNOWNTYPE`.
|
|
||||||
|
|
||||||
If an **error** argument is found and is not null then the remaining
|
|
||||||
arguments are optional. That is, if you say `ESO` then that's like using a
|
|
||||||
non-magical `E` in: `E|ESO|ZSO`.
|
|
||||||
|
|
||||||
### But I have optional arguments?!
|
|
||||||
|
|
||||||
You can provide more than one signature by separating them with pipes `|`.
|
|
||||||
If any signature matches the arguments then they'll be considered valid.
|
|
||||||
|
|
||||||
So for example, say you wanted to write a signature for
|
|
||||||
`fs.createWriteStream`. The docs for it describe it thusly:
|
|
||||||
|
|
||||||
```
|
|
||||||
fs.createWriteStream(path[, options])
|
|
||||||
```
|
|
||||||
|
|
||||||
This would be a signature of `SO|S`. That is, a string and and object, or
|
|
||||||
just a string.
|
|
||||||
|
|
||||||
Now, if you read the full `fs` docs, you'll see that actually path can ALSO
|
|
||||||
be a buffer. And options can be a string, that is:
|
|
||||||
```
|
|
||||||
path <String> | <Buffer>
|
|
||||||
options <String> | <Object>
|
|
||||||
```
|
|
||||||
|
|
||||||
To reproduce this you have to fully enumerate all of the possible
|
|
||||||
combinations and that implies a signature of `SO|SS|OO|OS|S|O`. The
|
|
||||||
awkwardness is a feature: It reminds you of the complexity you're adding to
|
|
||||||
your API when you do this sort of thing.
|
|
||||||
|
|
||||||
|
|
||||||
### Browser support
|
|
||||||
|
|
||||||
This has no dependencies and should work in browsers, though you'll have
|
|
||||||
noisier stack traces.
|
|
||||||
|
|
||||||
### Why this exists
|
|
||||||
|
|
||||||
I wanted a very simple argument validator. It needed to do two things:
|
|
||||||
|
|
||||||
1. Be more concise and easier to use than assertions
|
|
||||||
|
|
||||||
2. Not encourage an infinite bikeshed of DSLs
|
|
||||||
|
|
||||||
This is why types are specified by a single character and there's no such
|
|
||||||
thing as an optional argument.
|
|
||||||
|
|
||||||
This is not intended to validate user data. This is specifically about
|
|
||||||
asserting the interface of your functions.
|
|
||||||
|
|
||||||
If you need greater validation, I encourage you to write them by hand or
|
|
||||||
look elsewhere.
|
|
||||||
|
|
||||||
105
node_modules/aproba/index.js
generated
vendored
105
node_modules/aproba/index.js
generated
vendored
@@ -1,105 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
function isArguments (thingy) {
|
|
||||||
return thingy != null && typeof thingy === 'object' && thingy.hasOwnProperty('callee')
|
|
||||||
}
|
|
||||||
|
|
||||||
var types = {
|
|
||||||
'*': {label: 'any', check: function () { return true }},
|
|
||||||
A: {label: 'array', check: function (thingy) { return Array.isArray(thingy) || isArguments(thingy) }},
|
|
||||||
S: {label: 'string', check: function (thingy) { return typeof thingy === 'string' }},
|
|
||||||
N: {label: 'number', check: function (thingy) { return typeof thingy === 'number' }},
|
|
||||||
F: {label: 'function', check: function (thingy) { return typeof thingy === 'function' }},
|
|
||||||
O: {label: 'object', check: function (thingy) { return typeof thingy === 'object' && thingy != null && !types.A.check(thingy) && !types.E.check(thingy) }},
|
|
||||||
B: {label: 'boolean', check: function (thingy) { return typeof thingy === 'boolean' }},
|
|
||||||
E: {label: 'error', check: function (thingy) { return thingy instanceof Error }},
|
|
||||||
Z: {label: 'null', check: function (thingy) { return thingy == null }}
|
|
||||||
}
|
|
||||||
|
|
||||||
function addSchema (schema, arity) {
|
|
||||||
var group = arity[schema.length] = arity[schema.length] || []
|
|
||||||
if (group.indexOf(schema) === -1) group.push(schema)
|
|
||||||
}
|
|
||||||
|
|
||||||
var validate = module.exports = function (rawSchemas, args) {
|
|
||||||
if (arguments.length !== 2) throw wrongNumberOfArgs(['SA'], arguments.length)
|
|
||||||
if (!rawSchemas) throw missingRequiredArg(0, 'rawSchemas')
|
|
||||||
if (!args) throw missingRequiredArg(1, 'args')
|
|
||||||
if (!types.S.check(rawSchemas)) throw invalidType(0, ['string'], rawSchemas)
|
|
||||||
if (!types.A.check(args)) throw invalidType(1, ['array'], args)
|
|
||||||
var schemas = rawSchemas.split('|')
|
|
||||||
var arity = {}
|
|
||||||
|
|
||||||
schemas.forEach(function (schema) {
|
|
||||||
for (var ii = 0; ii < schema.length; ++ii) {
|
|
||||||
var type = schema[ii]
|
|
||||||
if (!types[type]) throw unknownType(ii, type)
|
|
||||||
}
|
|
||||||
if (/E.*E/.test(schema)) throw moreThanOneError(schema)
|
|
||||||
addSchema(schema, arity)
|
|
||||||
if (/E/.test(schema)) {
|
|
||||||
addSchema(schema.replace(/E.*$/, 'E'), arity)
|
|
||||||
addSchema(schema.replace(/E/, 'Z'), arity)
|
|
||||||
if (schema.length === 1) addSchema('', arity)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
var matching = arity[args.length]
|
|
||||||
if (!matching) {
|
|
||||||
throw wrongNumberOfArgs(Object.keys(arity), args.length)
|
|
||||||
}
|
|
||||||
for (var ii = 0; ii < args.length; ++ii) {
|
|
||||||
var newMatching = matching.filter(function (schema) {
|
|
||||||
var type = schema[ii]
|
|
||||||
var typeCheck = types[type].check
|
|
||||||
return typeCheck(args[ii])
|
|
||||||
})
|
|
||||||
if (!newMatching.length) {
|
|
||||||
var labels = matching.map(function (schema) {
|
|
||||||
return types[schema[ii]].label
|
|
||||||
}).filter(function (schema) { return schema != null })
|
|
||||||
throw invalidType(ii, labels, args[ii])
|
|
||||||
}
|
|
||||||
matching = newMatching
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function missingRequiredArg (num) {
|
|
||||||
return newException('EMISSINGARG', 'Missing required argument #' + (num + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
function unknownType (num, type) {
|
|
||||||
return newException('EUNKNOWNTYPE', 'Unknown type ' + type + ' in argument #' + (num + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
function invalidType (num, expectedTypes, value) {
|
|
||||||
var valueType
|
|
||||||
Object.keys(types).forEach(function (typeCode) {
|
|
||||||
if (types[typeCode].check(value)) valueType = types[typeCode].label
|
|
||||||
})
|
|
||||||
return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' +
|
|
||||||
englishList(expectedTypes) + ' but got ' + valueType)
|
|
||||||
}
|
|
||||||
|
|
||||||
function englishList (list) {
|
|
||||||
return list.join(', ').replace(/, ([^,]+)$/, ' or $1')
|
|
||||||
}
|
|
||||||
|
|
||||||
function wrongNumberOfArgs (expected, got) {
|
|
||||||
var english = englishList(expected)
|
|
||||||
var args = expected.every(function (ex) { return ex.length === 1 })
|
|
||||||
? 'argument'
|
|
||||||
: 'arguments'
|
|
||||||
return newException('EWRONGARGCOUNT', 'Expected ' + english + ' ' + args + ' but got ' + got)
|
|
||||||
}
|
|
||||||
|
|
||||||
function moreThanOneError (schema) {
|
|
||||||
return newException('ETOOMANYERRORTYPES',
|
|
||||||
'Only one error type per argument signature is allowed, more than one found in "' + schema + '"')
|
|
||||||
}
|
|
||||||
|
|
||||||
function newException (code, msg) {
|
|
||||||
var e = new Error(msg)
|
|
||||||
e.code = code
|
|
||||||
if (Error.captureStackTrace) Error.captureStackTrace(e, validate)
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
34
node_modules/aproba/package.json
generated
vendored
34
node_modules/aproba/package.json
generated
vendored
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "aproba",
|
|
||||||
"version": "1.2.0",
|
|
||||||
"description": "A ridiculously light-weight argument validator (now browser friendly)",
|
|
||||||
"main": "index.js",
|
|
||||||
"directories": {
|
|
||||||
"test": "test"
|
|
||||||
},
|
|
||||||
"dependencies": {},
|
|
||||||
"devDependencies": {
|
|
||||||
"standard": "^10.0.3",
|
|
||||||
"tap": "^10.0.2"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"test": "standard && tap -j3 test/*.js"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/iarna/aproba"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"argument",
|
|
||||||
"validate"
|
|
||||||
],
|
|
||||||
"author": "Rebecca Turner <me@re-becca.org>",
|
|
||||||
"license": "ISC",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/iarna/aproba/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/iarna/aproba"
|
|
||||||
}
|
|
||||||
37
node_modules/are-we-there-yet/CHANGES.md
generated
vendored
37
node_modules/are-we-there-yet/CHANGES.md
generated
vendored
@@ -1,37 +0,0 @@
|
|||||||
Hi, figured we could actually use a changelog now:
|
|
||||||
|
|
||||||
## 1.1.5 2018-05-24
|
|
||||||
|
|
||||||
* [#92](https://github.com/iarna/are-we-there-yet/pull/92) Fix bug where
|
|
||||||
`finish` would throw errors when including `TrackerStream` objects in
|
|
||||||
`TrackerGroup` collections. (@brianloveswords)
|
|
||||||
|
|
||||||
## 1.1.4 2017-04-21
|
|
||||||
|
|
||||||
* Fix typo in package.json
|
|
||||||
|
|
||||||
## 1.1.3 2017-04-21
|
|
||||||
|
|
||||||
* Improve documentation and limit files included in the distribution.
|
|
||||||
|
|
||||||
## 1.1.2 2016-03-15
|
|
||||||
|
|
||||||
* Add tracker group cycle detection and tests for it
|
|
||||||
|
|
||||||
## 1.1.1 2016-01-29
|
|
||||||
|
|
||||||
* Fix a typo in stream completion tracker
|
|
||||||
|
|
||||||
## 1.1.0 2016-01-29
|
|
||||||
|
|
||||||
* Rewrote completion percent computation to be low impact– no more walking a
|
|
||||||
tree of completion groups every time we need this info. Previously, with
|
|
||||||
medium sized tree of completion groups, even a relatively modest number of
|
|
||||||
calls to the top level `completed()` method would result in absurd numbers
|
|
||||||
of calls overall as it walked down the tree. We now, instead, keep track as
|
|
||||||
we bubble up changes, so the computation is limited to when data changes and
|
|
||||||
to the depth of that one branch, instead of _every_ node. (Plus, we were already
|
|
||||||
incurring _this_ cost, since we already bubbled out changes.)
|
|
||||||
* Moved different tracker types out to their own files.
|
|
||||||
* Made tests test for TOO MANY events too.
|
|
||||||
* Standarized the source code formatting
|
|
||||||
5
node_modules/are-we-there-yet/LICENSE
generated
vendored
5
node_modules/are-we-there-yet/LICENSE
generated
vendored
@@ -1,5 +0,0 @@
|
|||||||
Copyright (c) 2015, Rebecca Turner
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
|
||||||
195
node_modules/are-we-there-yet/README.md
generated
vendored
195
node_modules/are-we-there-yet/README.md
generated
vendored
@@ -1,195 +0,0 @@
|
|||||||
are-we-there-yet
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Track complex hiearchies of asynchronous task completion statuses. This is
|
|
||||||
intended to give you a way of recording and reporting the progress of the big
|
|
||||||
recursive fan-out and gather type workflows that are so common in async.
|
|
||||||
|
|
||||||
What you do with this completion data is up to you, but the most common use case is to
|
|
||||||
feed it to one of the many progress bar modules.
|
|
||||||
|
|
||||||
Most progress bar modules include a rudamentary version of this, but my
|
|
||||||
needs were more complex.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var TrackerGroup = require("are-we-there-yet").TrackerGroup
|
|
||||||
|
|
||||||
var top = new TrackerGroup("program")
|
|
||||||
|
|
||||||
var single = top.newItem("one thing", 100)
|
|
||||||
single.completeWork(20)
|
|
||||||
|
|
||||||
console.log(top.completed()) // 0.2
|
|
||||||
|
|
||||||
fs.stat("file", function(er, stat) {
|
|
||||||
if (er) throw er
|
|
||||||
var stream = top.newStream("file", stat.size)
|
|
||||||
console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete
|
|
||||||
// and 50% * 20% == 10%
|
|
||||||
fs.createReadStream("file").pipe(stream).on("data", function (chunk) {
|
|
||||||
// do stuff with chunk
|
|
||||||
})
|
|
||||||
top.on("change", function (name) {
|
|
||||||
// called each time a chunk is read from "file"
|
|
||||||
// top.completed() will start at 0.1 and fill up to 0.6 as the file is read
|
|
||||||
})
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
Shared Methods
|
|
||||||
==============
|
|
||||||
|
|
||||||
* var completed = tracker.completed()
|
|
||||||
|
|
||||||
Implemented in: `Tracker`, `TrackerGroup`, `TrackerStream`
|
|
||||||
|
|
||||||
Returns the ratio of completed work to work to be done. Range of 0 to 1.
|
|
||||||
|
|
||||||
* tracker.finish()
|
|
||||||
|
|
||||||
Implemented in: `Tracker`, `TrackerGroup`
|
|
||||||
|
|
||||||
Marks the tracker as completed. With a TrackerGroup this marks all of its
|
|
||||||
components as completed.
|
|
||||||
|
|
||||||
Marks all of the components of this tracker as finished, which in turn means
|
|
||||||
that `tracker.completed()` for this will now be 1.
|
|
||||||
|
|
||||||
This will result in one or more `change` events being emitted.
|
|
||||||
|
|
||||||
Events
|
|
||||||
======
|
|
||||||
|
|
||||||
All tracker objects emit `change` events with the following arguments:
|
|
||||||
|
|
||||||
```
|
|
||||||
function (name, completed, tracker)
|
|
||||||
```
|
|
||||||
|
|
||||||
`name` is the name of the tracker that originally emitted the event,
|
|
||||||
or if it didn't have one, the first containing tracker group that had one.
|
|
||||||
|
|
||||||
`completed` is the percent complete (as returned by `tracker.completed()` method).
|
|
||||||
|
|
||||||
`tracker` is the tracker object that you are listening for events on.
|
|
||||||
|
|
||||||
TrackerGroup
|
|
||||||
============
|
|
||||||
|
|
||||||
* var tracker = new TrackerGroup(**name**)
|
|
||||||
|
|
||||||
* **name** *(optional)* - The name of this tracker group, used in change
|
|
||||||
notifications if the component updating didn't have a name. Defaults to undefined.
|
|
||||||
|
|
||||||
Creates a new empty tracker aggregation group. These are trackers whose
|
|
||||||
completion status is determined by the completion status of other trackers.
|
|
||||||
|
|
||||||
* tracker.addUnit(**otherTracker**, **weight**)
|
|
||||||
|
|
||||||
* **otherTracker** - Any of the other are-we-there-yet tracker objects
|
|
||||||
* **weight** *(optional)* - The weight to give the tracker, defaults to 1.
|
|
||||||
|
|
||||||
Adds the **otherTracker** to this aggregation group. The weight determines
|
|
||||||
how long you expect this tracker to take to complete in proportion to other
|
|
||||||
units. So for instance, if you add one tracker with a weight of 1 and
|
|
||||||
another with a weight of 2, you're saying the second will take twice as long
|
|
||||||
to complete as the first. As such, the first will account for 33% of the
|
|
||||||
completion of this tracker and the second will account for the other 67%.
|
|
||||||
|
|
||||||
Returns **otherTracker**.
|
|
||||||
|
|
||||||
* var subGroup = tracker.newGroup(**name**, **weight**)
|
|
||||||
|
|
||||||
The above is exactly equivalent to:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var subGroup = tracker.addUnit(new TrackerGroup(name), weight)
|
|
||||||
```
|
|
||||||
|
|
||||||
* var subItem = tracker.newItem(**name**, **todo**, **weight**)
|
|
||||||
|
|
||||||
The above is exactly equivalent to:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var subItem = tracker.addUnit(new Tracker(name, todo), weight)
|
|
||||||
```
|
|
||||||
|
|
||||||
* var subStream = tracker.newStream(**name**, **todo**, **weight**)
|
|
||||||
|
|
||||||
The above is exactly equivalent to:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)
|
|
||||||
```
|
|
||||||
|
|
||||||
* console.log( tracker.debug() )
|
|
||||||
|
|
||||||
Returns a tree showing the completion of this tracker group and all of its
|
|
||||||
children, including recursively entering all of the children.
|
|
||||||
|
|
||||||
Tracker
|
|
||||||
=======
|
|
||||||
|
|
||||||
* var tracker = new Tracker(**name**, **todo**)
|
|
||||||
|
|
||||||
* **name** *(optional)* The name of this counter to report in change
|
|
||||||
events. Defaults to undefined.
|
|
||||||
* **todo** *(optional)* The amount of work todo (a number). Defaults to 0.
|
|
||||||
|
|
||||||
Ordinarily these are constructed as a part of a tracker group (via
|
|
||||||
`newItem`).
|
|
||||||
|
|
||||||
* var completed = tracker.completed()
|
|
||||||
|
|
||||||
Returns the ratio of completed work to work to be done. Range of 0 to 1. If
|
|
||||||
total work to be done is 0 then it will return 0.
|
|
||||||
|
|
||||||
* tracker.addWork(**todo**)
|
|
||||||
|
|
||||||
* **todo** A number to add to the amount of work to be done.
|
|
||||||
|
|
||||||
Increases the amount of work to be done, thus decreasing the completion
|
|
||||||
percentage. Triggers a `change` event.
|
|
||||||
|
|
||||||
* tracker.completeWork(**completed**)
|
|
||||||
|
|
||||||
* **completed** A number to add to the work complete
|
|
||||||
|
|
||||||
Increase the amount of work complete, thus increasing the completion percentage.
|
|
||||||
Will never increase the work completed past the amount of work todo. That is,
|
|
||||||
percentages > 100% are not allowed. Triggers a `change` event.
|
|
||||||
|
|
||||||
* tracker.finish()
|
|
||||||
|
|
||||||
Marks this tracker as finished, tracker.completed() will now be 1. Triggers
|
|
||||||
a `change` event.
|
|
||||||
|
|
||||||
TrackerStream
|
|
||||||
=============
|
|
||||||
|
|
||||||
* var tracker = new TrackerStream(**name**, **size**, **options**)
|
|
||||||
|
|
||||||
* **name** *(optional)* The name of this counter to report in change
|
|
||||||
events. Defaults to undefined.
|
|
||||||
* **size** *(optional)* The number of bytes being sent through this stream.
|
|
||||||
* **options** *(optional)* A hash of stream options
|
|
||||||
|
|
||||||
The tracker stream object is a pass through stream that updates an internal
|
|
||||||
tracker object each time a block passes through. It's intended to track
|
|
||||||
downloads, file extraction and other related activities. You use it by piping
|
|
||||||
your data source into it and then using it as your data source.
|
|
||||||
|
|
||||||
If your data has a length attribute then that's used as the amount of work
|
|
||||||
completed when the chunk is passed through. If it does not (eg, object
|
|
||||||
streams) then each chunk counts as completing 1 unit of work, so your size
|
|
||||||
should be the total number of objects being streamed.
|
|
||||||
|
|
||||||
* tracker.addWork(**todo**)
|
|
||||||
|
|
||||||
* **todo** Increase the expected overall size by **todo** bytes.
|
|
||||||
|
|
||||||
Increases the amount of work to be done, thus decreasing the completion
|
|
||||||
percentage. Triggers a `change` event.
|
|
||||||
4
node_modules/are-we-there-yet/index.js
generated
vendored
4
node_modules/are-we-there-yet/index.js
generated
vendored
@@ -1,4 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
exports.TrackerGroup = require('./tracker-group.js')
|
|
||||||
exports.Tracker = require('./tracker.js')
|
|
||||||
exports.TrackerStream = require('./tracker-stream.js')
|
|
||||||
35
node_modules/are-we-there-yet/package.json
generated
vendored
35
node_modules/are-we-there-yet/package.json
generated
vendored
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "are-we-there-yet",
|
|
||||||
"version": "1.1.7",
|
|
||||||
"description": "Keep track of the overall completion of many disparate processes",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "standard && tap test/*.js"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/iarna/are-we-there-yet.git"
|
|
||||||
},
|
|
||||||
"author": "Rebecca Turner (http://re-becca.org)",
|
|
||||||
"license": "ISC",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/iarna/are-we-there-yet/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/iarna/are-we-there-yet",
|
|
||||||
"devDependencies": {
|
|
||||||
"standard": "^11.0.1",
|
|
||||||
"tap": "^12.0.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"delegates": "^1.0.0",
|
|
||||||
"readable-stream": "^2.0.6"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js",
|
|
||||||
"tracker-base.js",
|
|
||||||
"tracker-group.js",
|
|
||||||
"tracker-stream.js",
|
|
||||||
"tracker.js",
|
|
||||||
"CHANGES.md"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
11
node_modules/are-we-there-yet/tracker-base.js
generated
vendored
11
node_modules/are-we-there-yet/tracker-base.js
generated
vendored
@@ -1,11 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
var EventEmitter = require('events').EventEmitter
|
|
||||||
var util = require('util')
|
|
||||||
|
|
||||||
var trackerId = 0
|
|
||||||
var TrackerBase = module.exports = function (name) {
|
|
||||||
EventEmitter.call(this)
|
|
||||||
this.id = ++trackerId
|
|
||||||
this.name = name
|
|
||||||
}
|
|
||||||
util.inherits(TrackerBase, EventEmitter)
|
|
||||||
107
node_modules/are-we-there-yet/tracker-group.js
generated
vendored
107
node_modules/are-we-there-yet/tracker-group.js
generated
vendored
@@ -1,107 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
var util = require('util')
|
|
||||||
var TrackerBase = require('./tracker-base.js')
|
|
||||||
var Tracker = require('./tracker.js')
|
|
||||||
var TrackerStream = require('./tracker-stream.js')
|
|
||||||
|
|
||||||
var TrackerGroup = module.exports = function (name) {
|
|
||||||
TrackerBase.call(this, name)
|
|
||||||
this.parentGroup = null
|
|
||||||
this.trackers = []
|
|
||||||
this.completion = {}
|
|
||||||
this.weight = {}
|
|
||||||
this.totalWeight = 0
|
|
||||||
this.finished = false
|
|
||||||
this.bubbleChange = bubbleChange(this)
|
|
||||||
}
|
|
||||||
util.inherits(TrackerGroup, TrackerBase)
|
|
||||||
|
|
||||||
function bubbleChange (trackerGroup) {
|
|
||||||
return function (name, completed, tracker) {
|
|
||||||
trackerGroup.completion[tracker.id] = completed
|
|
||||||
if (trackerGroup.finished) return
|
|
||||||
trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerGroup.prototype.nameInTree = function () {
|
|
||||||
var names = []
|
|
||||||
var from = this
|
|
||||||
while (from) {
|
|
||||||
names.unshift(from.name)
|
|
||||||
from = from.parentGroup
|
|
||||||
}
|
|
||||||
return names.join('/')
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerGroup.prototype.addUnit = function (unit, weight) {
|
|
||||||
if (unit.addUnit) {
|
|
||||||
var toTest = this
|
|
||||||
while (toTest) {
|
|
||||||
if (unit === toTest) {
|
|
||||||
throw new Error(
|
|
||||||
'Attempted to add tracker group ' +
|
|
||||||
unit.name + ' to tree that already includes it ' +
|
|
||||||
this.nameInTree(this))
|
|
||||||
}
|
|
||||||
toTest = toTest.parentGroup
|
|
||||||
}
|
|
||||||
unit.parentGroup = this
|
|
||||||
}
|
|
||||||
this.weight[unit.id] = weight || 1
|
|
||||||
this.totalWeight += this.weight[unit.id]
|
|
||||||
this.trackers.push(unit)
|
|
||||||
this.completion[unit.id] = unit.completed()
|
|
||||||
unit.on('change', this.bubbleChange)
|
|
||||||
if (!this.finished) this.emit('change', unit.name, this.completion[unit.id], unit)
|
|
||||||
return unit
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerGroup.prototype.completed = function () {
|
|
||||||
if (this.trackers.length === 0) return 0
|
|
||||||
var valPerWeight = 1 / this.totalWeight
|
|
||||||
var completed = 0
|
|
||||||
for (var ii = 0; ii < this.trackers.length; ii++) {
|
|
||||||
var trackerId = this.trackers[ii].id
|
|
||||||
completed += valPerWeight * this.weight[trackerId] * this.completion[trackerId]
|
|
||||||
}
|
|
||||||
return completed
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerGroup.prototype.newGroup = function (name, weight) {
|
|
||||||
return this.addUnit(new TrackerGroup(name), weight)
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerGroup.prototype.newItem = function (name, todo, weight) {
|
|
||||||
return this.addUnit(new Tracker(name, todo), weight)
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerGroup.prototype.newStream = function (name, todo, weight) {
|
|
||||||
return this.addUnit(new TrackerStream(name, todo), weight)
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerGroup.prototype.finish = function () {
|
|
||||||
this.finished = true
|
|
||||||
if (!this.trackers.length) this.addUnit(new Tracker(), 1, true)
|
|
||||||
for (var ii = 0; ii < this.trackers.length; ii++) {
|
|
||||||
var tracker = this.trackers[ii]
|
|
||||||
tracker.finish()
|
|
||||||
tracker.removeListener('change', this.bubbleChange)
|
|
||||||
}
|
|
||||||
this.emit('change', this.name, 1, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
var buffer = ' '
|
|
||||||
TrackerGroup.prototype.debug = function (depth) {
|
|
||||||
depth = depth || 0
|
|
||||||
var indent = depth ? buffer.substr(0, depth) : ''
|
|
||||||
var output = indent + (this.name || 'top') + ': ' + this.completed() + '\n'
|
|
||||||
this.trackers.forEach(function (tracker) {
|
|
||||||
if (tracker instanceof TrackerGroup) {
|
|
||||||
output += tracker.debug(depth + 1)
|
|
||||||
} else {
|
|
||||||
output += indent + ' ' + tracker.name + ': ' + tracker.completed() + '\n'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
36
node_modules/are-we-there-yet/tracker-stream.js
generated
vendored
36
node_modules/are-we-there-yet/tracker-stream.js
generated
vendored
@@ -1,36 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
var util = require('util')
|
|
||||||
var stream = require('readable-stream')
|
|
||||||
var delegate = require('delegates')
|
|
||||||
var Tracker = require('./tracker.js')
|
|
||||||
|
|
||||||
var TrackerStream = module.exports = function (name, size, options) {
|
|
||||||
stream.Transform.call(this, options)
|
|
||||||
this.tracker = new Tracker(name, size)
|
|
||||||
this.name = name
|
|
||||||
this.id = this.tracker.id
|
|
||||||
this.tracker.on('change', delegateChange(this))
|
|
||||||
}
|
|
||||||
util.inherits(TrackerStream, stream.Transform)
|
|
||||||
|
|
||||||
function delegateChange (trackerStream) {
|
|
||||||
return function (name, completion, tracker) {
|
|
||||||
trackerStream.emit('change', name, completion, trackerStream)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerStream.prototype._transform = function (data, encoding, cb) {
|
|
||||||
this.tracker.completeWork(data.length ? data.length : 1)
|
|
||||||
this.push(data)
|
|
||||||
cb()
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackerStream.prototype._flush = function (cb) {
|
|
||||||
this.tracker.finish()
|
|
||||||
cb()
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate(TrackerStream.prototype, 'tracker')
|
|
||||||
.method('completed')
|
|
||||||
.method('addWork')
|
|
||||||
.method('finish')
|
|
||||||
30
node_modules/are-we-there-yet/tracker.js
generated
vendored
30
node_modules/are-we-there-yet/tracker.js
generated
vendored
@@ -1,30 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
var util = require('util')
|
|
||||||
var TrackerBase = require('./tracker-base.js')
|
|
||||||
|
|
||||||
var Tracker = module.exports = function (name, todo) {
|
|
||||||
TrackerBase.call(this, name)
|
|
||||||
this.workDone = 0
|
|
||||||
this.workTodo = todo || 0
|
|
||||||
}
|
|
||||||
util.inherits(Tracker, TrackerBase)
|
|
||||||
|
|
||||||
Tracker.prototype.completed = function () {
|
|
||||||
return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
|
|
||||||
}
|
|
||||||
|
|
||||||
Tracker.prototype.addWork = function (work) {
|
|
||||||
this.workTodo += work
|
|
||||||
this.emit('change', this.name, this.completed(), this)
|
|
||||||
}
|
|
||||||
|
|
||||||
Tracker.prototype.completeWork = function (work) {
|
|
||||||
this.workDone += work
|
|
||||||
if (this.workDone > this.workTodo) this.workDone = this.workTodo
|
|
||||||
this.emit('change', this.name, this.completed(), this)
|
|
||||||
}
|
|
||||||
|
|
||||||
Tracker.prototype.finish = function () {
|
|
||||||
this.workTodo = this.workDone = 1
|
|
||||||
this.emit('change', this.name, 1, this)
|
|
||||||
}
|
|
||||||
2
node_modules/async-limiter/.eslintignore
generated
vendored
2
node_modules/async-limiter/.eslintignore
generated
vendored
@@ -1,2 +0,0 @@
|
|||||||
coverage
|
|
||||||
.nyc_output
|
|
||||||
10
node_modules/async-limiter/.nycrc
generated
vendored
10
node_modules/async-limiter/.nycrc
generated
vendored
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"check-coverage": false,
|
|
||||||
"lines": 99,
|
|
||||||
"statements": 99,
|
|
||||||
"functions": 99,
|
|
||||||
"branches": 99,
|
|
||||||
"include": [
|
|
||||||
"index.js"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
9
node_modules/async-limiter/.travis.yml
generated
vendored
9
node_modules/async-limiter/.travis.yml
generated
vendored
@@ -1,9 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- "6"
|
|
||||||
- "8"
|
|
||||||
- "10"
|
|
||||||
- "node"
|
|
||||||
script: npm run travis
|
|
||||||
cache:
|
|
||||||
yarn: true
|
|
||||||
8
node_modules/async-limiter/LICENSE
generated
vendored
8
node_modules/async-limiter/LICENSE
generated
vendored
@@ -1,8 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
Copyright (c) 2017 Samuel Reed <samuel.trace.reed@gmail.com>
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
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.
|
|
||||||
67
node_modules/async-limiter/index.js
generated
vendored
67
node_modules/async-limiter/index.js
generated
vendored
@@ -1,67 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
function Queue(options) {
|
|
||||||
if (!(this instanceof Queue)) {
|
|
||||||
return new Queue(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
options = options || {};
|
|
||||||
this.concurrency = options.concurrency || Infinity;
|
|
||||||
this.pending = 0;
|
|
||||||
this.jobs = [];
|
|
||||||
this.cbs = [];
|
|
||||||
this._done = done.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
var arrayAddMethods = [
|
|
||||||
'push',
|
|
||||||
'unshift',
|
|
||||||
'splice'
|
|
||||||
];
|
|
||||||
|
|
||||||
arrayAddMethods.forEach(function(method) {
|
|
||||||
Queue.prototype[method] = function() {
|
|
||||||
var methodResult = Array.prototype[method].apply(this.jobs, arguments);
|
|
||||||
this._run();
|
|
||||||
return methodResult;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.defineProperty(Queue.prototype, 'length', {
|
|
||||||
get: function() {
|
|
||||||
return this.pending + this.jobs.length;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Queue.prototype._run = function() {
|
|
||||||
if (this.pending === this.concurrency) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.jobs.length) {
|
|
||||||
var job = this.jobs.shift();
|
|
||||||
this.pending++;
|
|
||||||
job(this._done);
|
|
||||||
this._run();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.pending === 0) {
|
|
||||||
while (this.cbs.length !== 0) {
|
|
||||||
var cb = this.cbs.pop();
|
|
||||||
process.nextTick(cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype.onDone = function(cb) {
|
|
||||||
if (typeof cb === 'function') {
|
|
||||||
this.cbs.push(cb);
|
|
||||||
this._run();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function done() {
|
|
||||||
this.pending--;
|
|
||||||
this._run();
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Queue;
|
|
||||||
35
node_modules/async-limiter/package.json
generated
vendored
35
node_modules/async-limiter/package.json
generated
vendored
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "async-limiter",
|
|
||||||
"version": "1.0.1",
|
|
||||||
"description": "asynchronous function queue with adjustable concurrency",
|
|
||||||
"keywords": [
|
|
||||||
"throttle",
|
|
||||||
"async",
|
|
||||||
"limiter",
|
|
||||||
"asynchronous",
|
|
||||||
"job",
|
|
||||||
"task",
|
|
||||||
"concurrency",
|
|
||||||
"concurrent"
|
|
||||||
],
|
|
||||||
"dependencies": {},
|
|
||||||
"devDependencies": {
|
|
||||||
"coveralls": "^3.0.3",
|
|
||||||
"eslint": "^5.16.0",
|
|
||||||
"eslint-plugin-mocha": "^5.3.0",
|
|
||||||
"intelli-espower-loader": "^1.0.1",
|
|
||||||
"mocha": "^6.1.4",
|
|
||||||
"nyc": "^14.1.1",
|
|
||||||
"power-assert": "^1.6.1"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "mocha --require intelli-espower-loader test/",
|
|
||||||
"travis": "npm run lint && npm run test",
|
|
||||||
"coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
|
|
||||||
"example": "node example",
|
|
||||||
"lint": "eslint ."
|
|
||||||
},
|
|
||||||
"repository": "https://github.com/strml/async-limiter.git",
|
|
||||||
"author": "Samuel Reed <samuel.trace.reed@gmail.com",
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
||||||
132
node_modules/async-limiter/readme.md
generated
vendored
132
node_modules/async-limiter/readme.md
generated
vendored
@@ -1,132 +0,0 @@
|
|||||||
# Async-Limiter
|
|
||||||
|
|
||||||
A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue).
|
|
||||||
|
|
||||||
[](http://www.npmjs.org/async-limiter)
|
|
||||||
[](https://travis-ci.org/STRML/async-limiter)
|
|
||||||
[](https://coveralls.io/r/STRML/async-limiter)
|
|
||||||
|
|
||||||
This module exports a class `Limiter` that implements some of the `Array` API.
|
|
||||||
Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods.
|
|
||||||
|
|
||||||
## Motivation
|
|
||||||
|
|
||||||
Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when
|
|
||||||
run at infinite concurrency.
|
|
||||||
|
|
||||||
In this case, it is actually faster, and takes far less memory, to limit concurrency.
|
|
||||||
|
|
||||||
This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would
|
|
||||||
make this module faster or lighter, but new functionality is not desired.
|
|
||||||
|
|
||||||
Style should confirm to nodejs/node style.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
``` javascript
|
|
||||||
var Limiter = require('async-limiter')
|
|
||||||
|
|
||||||
var t = new Limiter({concurrency: 2});
|
|
||||||
var results = []
|
|
||||||
|
|
||||||
// add jobs using the familiar Array API
|
|
||||||
t.push(function (cb) {
|
|
||||||
results.push('two')
|
|
||||||
cb()
|
|
||||||
})
|
|
||||||
|
|
||||||
t.push(
|
|
||||||
function (cb) {
|
|
||||||
results.push('four')
|
|
||||||
cb()
|
|
||||||
},
|
|
||||||
function (cb) {
|
|
||||||
results.push('five')
|
|
||||||
cb()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
t.unshift(function (cb) {
|
|
||||||
results.push('one')
|
|
||||||
cb()
|
|
||||||
})
|
|
||||||
|
|
||||||
t.splice(2, 0, function (cb) {
|
|
||||||
results.push('three')
|
|
||||||
cb()
|
|
||||||
})
|
|
||||||
|
|
||||||
// Jobs run automatically. If you want a callback when all are done,
|
|
||||||
// call 'onDone()'.
|
|
||||||
t.onDone(function () {
|
|
||||||
console.log('all done:', results)
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Zlib Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
const zlib = require('zlib');
|
|
||||||
const Limiter = require('async-limiter');
|
|
||||||
|
|
||||||
const message = {some: "data"};
|
|
||||||
const payload = new Buffer(JSON.stringify(message));
|
|
||||||
|
|
||||||
// Try with different concurrency values to see how this actually
|
|
||||||
// slows significantly with higher concurrency!
|
|
||||||
//
|
|
||||||
// 5: 1398.607ms
|
|
||||||
// 10: 1375.668ms
|
|
||||||
// Infinity: 4423.300ms
|
|
||||||
//
|
|
||||||
const t = new Limiter({concurrency: 5});
|
|
||||||
function deflate(payload, cb) {
|
|
||||||
t.push(function(done) {
|
|
||||||
zlib.deflate(payload, function(err, buffer) {
|
|
||||||
done();
|
|
||||||
cb(err, buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
console.time('deflate');
|
|
||||||
for(let i = 0; i < 30000; ++i) {
|
|
||||||
deflate(payload, function (err, buffer) {});
|
|
||||||
}
|
|
||||||
t.onDone(function() {
|
|
||||||
console.timeEnd('deflate');
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
`npm install async-limiter`
|
|
||||||
|
|
||||||
## Test
|
|
||||||
|
|
||||||
`npm test`
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### `var t = new Limiter([opts])`
|
|
||||||
Constructor. `opts` may contain inital values for:
|
|
||||||
* `t.concurrency`
|
|
||||||
|
|
||||||
## Instance methods
|
|
||||||
|
|
||||||
### `t.onDone(fn)`
|
|
||||||
`fn` will be called once and only once, when the queue is empty.
|
|
||||||
|
|
||||||
## Instance methods mixed in from `Array`
|
|
||||||
Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
|
|
||||||
### `t.push(element1, ..., elementN)`
|
|
||||||
### `t.unshift(element1, ..., elementN)`
|
|
||||||
### `t.splice(index , howMany[, element1[, ...[, elementN]]])`
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
### `t.concurrency`
|
|
||||||
Max number of jobs the queue should process concurrently, defaults to `Infinity`.
|
|
||||||
|
|
||||||
### `t.length`
|
|
||||||
Jobs pending + jobs to process (readonly).
|
|
||||||
|
|
||||||
98
node_modules/bindings/README.md
generated
vendored
98
node_modules/bindings/README.md
generated
vendored
@@ -1,98 +0,0 @@
|
|||||||
node-bindings
|
|
||||||
=============
|
|
||||||
### Helper module for loading your native module's .node file
|
|
||||||
|
|
||||||
This is a helper module for authors of Node.js native addon modules.
|
|
||||||
It is basically the "swiss army knife" of `require()`ing your native module's
|
|
||||||
`.node` file.
|
|
||||||
|
|
||||||
Throughout the course of Node's native addon history, addons have ended up being
|
|
||||||
compiled in a variety of different places, depending on which build tool and which
|
|
||||||
version of node was used. To make matters worse, now the _gyp_ build tool can
|
|
||||||
produce either a _Release_ or _Debug_ build, each being built into different
|
|
||||||
locations.
|
|
||||||
|
|
||||||
This module checks _all_ the possible locations that a native addon would be built
|
|
||||||
at, and returns the first one that loads successfully.
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
Install with `npm`:
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
$ npm install bindings
|
|
||||||
```
|
|
||||||
|
|
||||||
Or add it to the `"dependencies"` section of your _package.json_ file.
|
|
||||||
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
`require()`ing the proper bindings file for the current node version, platform
|
|
||||||
and architecture is as simple as:
|
|
||||||
|
|
||||||
``` js
|
|
||||||
var bindings = require('bindings')('binding.node')
|
|
||||||
|
|
||||||
// Use your bindings defined in your C files
|
|
||||||
bindings.your_c_function()
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Nice Error Output
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
When the `.node` file could not be loaded, `node-bindings` throws an Error with
|
|
||||||
a nice error message telling you exactly what was tried. You can also check the
|
|
||||||
`err.tries` Array property.
|
|
||||||
|
|
||||||
```
|
|
||||||
Error: Could not load the bindings file. Tried:
|
|
||||||
→ /Users/nrajlich/ref/build/binding.node
|
|
||||||
→ /Users/nrajlich/ref/build/Debug/binding.node
|
|
||||||
→ /Users/nrajlich/ref/build/Release/binding.node
|
|
||||||
→ /Users/nrajlich/ref/out/Debug/binding.node
|
|
||||||
→ /Users/nrajlich/ref/Debug/binding.node
|
|
||||||
→ /Users/nrajlich/ref/out/Release/binding.node
|
|
||||||
→ /Users/nrajlich/ref/Release/binding.node
|
|
||||||
→ /Users/nrajlich/ref/build/default/binding.node
|
|
||||||
→ /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node
|
|
||||||
at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13)
|
|
||||||
at Object.<anonymous> (/Users/nrajlich/ref/lib/ref.js:5:47)
|
|
||||||
at Module._compile (module.js:449:26)
|
|
||||||
at Object.Module._extensions..js (module.js:467:10)
|
|
||||||
at Module.load (module.js:356:32)
|
|
||||||
at Function.Module._load (module.js:312:12)
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
The searching for the `.node` file will originate from the first directory in which has a `package.json` file is found.
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
|
|
||||||
(The MIT License)
|
|
||||||
|
|
||||||
Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
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.
|
|
||||||
174
node_modules/bindings/bindings.js
generated
vendored
174
node_modules/bindings/bindings.js
generated
vendored
@@ -1,174 +0,0 @@
|
|||||||
|
|
||||||
/**
|
|
||||||
* Module dependencies.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var fs = require('fs')
|
|
||||||
, path = require('path')
|
|
||||||
, join = path.join
|
|
||||||
, dirname = path.dirname
|
|
||||||
, exists = ((fs.accessSync && function (path) { try { fs.accessSync(path); } catch (e) { return false; } return true; })
|
|
||||||
|| fs.existsSync || path.existsSync)
|
|
||||||
, defaults = {
|
|
||||||
arrow: process.env.NODE_BINDINGS_ARROW || ' → '
|
|
||||||
, compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled'
|
|
||||||
, platform: process.platform
|
|
||||||
, arch: process.arch
|
|
||||||
, version: process.versions.node
|
|
||||||
, bindings: 'bindings.node'
|
|
||||||
, try: [
|
|
||||||
// node-gyp's linked version in the "build" dir
|
|
||||||
[ 'module_root', 'build', 'bindings' ]
|
|
||||||
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
||||||
, [ 'module_root', 'build', 'Debug', 'bindings' ]
|
|
||||||
, [ 'module_root', 'build', 'Release', 'bindings' ]
|
|
||||||
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
||||||
, [ 'module_root', 'out', 'Debug', 'bindings' ]
|
|
||||||
, [ 'module_root', 'Debug', 'bindings' ]
|
|
||||||
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
||||||
, [ 'module_root', 'out', 'Release', 'bindings' ]
|
|
||||||
, [ 'module_root', 'Release', 'bindings' ]
|
|
||||||
// Legacy from node-waf, node <= 0.4.x
|
|
||||||
, [ 'module_root', 'build', 'default', 'bindings' ]
|
|
||||||
// Production "Release" buildtype binary (meh...)
|
|
||||||
, [ 'module_root', 'compiled', 'version', 'platform', 'arch', 'bindings' ]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The main `bindings()` function loads the compiled bindings for a given module.
|
|
||||||
* It uses V8's Error API to determine the parent filename that this function is
|
|
||||||
* being invoked from, which is then used to find the root directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function bindings (opts) {
|
|
||||||
|
|
||||||
// Argument surgery
|
|
||||||
if (typeof opts == 'string') {
|
|
||||||
opts = { bindings: opts }
|
|
||||||
} else if (!opts) {
|
|
||||||
opts = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// maps `defaults` onto `opts` object
|
|
||||||
Object.keys(defaults).map(function(i) {
|
|
||||||
if (!(i in opts)) opts[i] = defaults[i];
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get the module root
|
|
||||||
if (!opts.module_root) {
|
|
||||||
opts.module_root = exports.getRoot(exports.getFileName())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the given bindings name ends with .node
|
|
||||||
if (path.extname(opts.bindings) != '.node') {
|
|
||||||
opts.bindings += '.node'
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/webpack/webpack/issues/4175#issuecomment-342931035
|
|
||||||
var requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require
|
|
||||||
|
|
||||||
var tries = []
|
|
||||||
, i = 0
|
|
||||||
, l = opts.try.length
|
|
||||||
, n
|
|
||||||
, b
|
|
||||||
, err
|
|
||||||
|
|
||||||
for (; i<l; i++) {
|
|
||||||
n = join.apply(null, opts.try[i].map(function (p) {
|
|
||||||
return opts[p] || p
|
|
||||||
}))
|
|
||||||
tries.push(n)
|
|
||||||
try {
|
|
||||||
b = opts.path ? requireFunc.resolve(n) : requireFunc(n)
|
|
||||||
if (!opts.path) {
|
|
||||||
b.path = n
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
} catch (e) {
|
|
||||||
if (!/not find/i.test(e.message)) {
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = new Error('Could not locate the bindings file. Tried:\n'
|
|
||||||
+ tries.map(function (a) { return opts.arrow + a }).join('\n'))
|
|
||||||
err.tries = tries
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
module.exports = exports = bindings
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the filename of the JavaScript file that invokes this function.
|
|
||||||
* Used to help find the root directory of a module.
|
|
||||||
* Optionally accepts an filename argument to skip when searching for the invoking filename
|
|
||||||
*/
|
|
||||||
|
|
||||||
exports.getFileName = function getFileName (calling_file) {
|
|
||||||
var origPST = Error.prepareStackTrace
|
|
||||||
, origSTL = Error.stackTraceLimit
|
|
||||||
, dummy = {}
|
|
||||||
, fileName
|
|
||||||
|
|
||||||
Error.stackTraceLimit = 10
|
|
||||||
|
|
||||||
Error.prepareStackTrace = function (e, st) {
|
|
||||||
for (var i=0, l=st.length; i<l; i++) {
|
|
||||||
fileName = st[i].getFileName()
|
|
||||||
if (fileName !== __filename) {
|
|
||||||
if (calling_file) {
|
|
||||||
if (fileName !== calling_file) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// run the 'prepareStackTrace' function above
|
|
||||||
Error.captureStackTrace(dummy)
|
|
||||||
dummy.stack
|
|
||||||
|
|
||||||
// cleanup
|
|
||||||
Error.prepareStackTrace = origPST
|
|
||||||
Error.stackTraceLimit = origSTL
|
|
||||||
|
|
||||||
return fileName
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the root directory of a module, given an arbitrary filename
|
|
||||||
* somewhere in the module tree. The "root directory" is the directory
|
|
||||||
* containing the `package.json` file.
|
|
||||||
*
|
|
||||||
* In: /home/nate/node-native-module/lib/index.js
|
|
||||||
* Out: /home/nate/node-native-module
|
|
||||||
*/
|
|
||||||
|
|
||||||
exports.getRoot = function getRoot (file) {
|
|
||||||
var dir = dirname(file)
|
|
||||||
, prev
|
|
||||||
while (true) {
|
|
||||||
if (dir === '.') {
|
|
||||||
// Avoids an infinite loop in rare cases, like the REPL
|
|
||||||
dir = process.cwd()
|
|
||||||
}
|
|
||||||
if (exists(join(dir, 'package.json')) || exists(join(dir, 'node_modules'))) {
|
|
||||||
// Found the 'package.json' file or 'node_modules' dir; we're done
|
|
||||||
return dir
|
|
||||||
}
|
|
||||||
if (prev === dir) {
|
|
||||||
// Got to the top
|
|
||||||
throw new Error('Could not find module root given file: "' + file
|
|
||||||
+ '". Do you have a `package.json` file? ')
|
|
||||||
}
|
|
||||||
// Try the parent dir next
|
|
||||||
prev = dir
|
|
||||||
dir = join(dir, '..')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
25
node_modules/bindings/package.json
generated
vendored
25
node_modules/bindings/package.json
generated
vendored
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "bindings",
|
|
||||||
"description": "Helper module for loading your native module's .node file",
|
|
||||||
"keywords": [
|
|
||||||
"native",
|
|
||||||
"addon",
|
|
||||||
"bindings",
|
|
||||||
"gyp",
|
|
||||||
"waf",
|
|
||||||
"c",
|
|
||||||
"c++"
|
|
||||||
],
|
|
||||||
"version": "1.3.1",
|
|
||||||
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/TooTallNate/node-bindings.git"
|
|
||||||
},
|
|
||||||
"main": "./bindings.js",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/TooTallNate/node-bindings/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/TooTallNate/node-bindings",
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
||||||
59
node_modules/bl/.jshintrc
generated
vendored
59
node_modules/bl/.jshintrc
generated
vendored
@@ -1,59 +0,0 @@
|
|||||||
{
|
|
||||||
"predef": [ ]
|
|
||||||
, "bitwise": false
|
|
||||||
, "camelcase": false
|
|
||||||
, "curly": false
|
|
||||||
, "eqeqeq": false
|
|
||||||
, "forin": false
|
|
||||||
, "immed": false
|
|
||||||
, "latedef": false
|
|
||||||
, "noarg": true
|
|
||||||
, "noempty": true
|
|
||||||
, "nonew": true
|
|
||||||
, "plusplus": false
|
|
||||||
, "quotmark": true
|
|
||||||
, "regexp": false
|
|
||||||
, "undef": true
|
|
||||||
, "unused": true
|
|
||||||
, "strict": false
|
|
||||||
, "trailing": true
|
|
||||||
, "maxlen": 120
|
|
||||||
, "asi": true
|
|
||||||
, "boss": true
|
|
||||||
, "debug": true
|
|
||||||
, "eqnull": true
|
|
||||||
, "esnext": true
|
|
||||||
, "evil": true
|
|
||||||
, "expr": true
|
|
||||||
, "funcscope": false
|
|
||||||
, "globalstrict": false
|
|
||||||
, "iterator": false
|
|
||||||
, "lastsemic": true
|
|
||||||
, "laxbreak": true
|
|
||||||
, "laxcomma": true
|
|
||||||
, "loopfunc": true
|
|
||||||
, "multistr": false
|
|
||||||
, "onecase": false
|
|
||||||
, "proto": false
|
|
||||||
, "regexdash": false
|
|
||||||
, "scripturl": true
|
|
||||||
, "smarttabs": false
|
|
||||||
, "shadow": false
|
|
||||||
, "sub": true
|
|
||||||
, "supernew": false
|
|
||||||
, "validthis": true
|
|
||||||
, "browser": true
|
|
||||||
, "couch": false
|
|
||||||
, "devel": false
|
|
||||||
, "dojo": false
|
|
||||||
, "mootools": false
|
|
||||||
, "node": true
|
|
||||||
, "nonstandard": true
|
|
||||||
, "prototypejs": false
|
|
||||||
, "rhino": false
|
|
||||||
, "worker": true
|
|
||||||
, "wsh": false
|
|
||||||
, "nomen": false
|
|
||||||
, "onevar": false
|
|
||||||
, "passfail": false
|
|
||||||
}
|
|
||||||
13
node_modules/bl/.travis.yml
generated
vendored
13
node_modules/bl/.travis.yml
generated
vendored
@@ -1,13 +0,0 @@
|
|||||||
sudo: false
|
|
||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- '6'
|
|
||||||
- '8'
|
|
||||||
- '10'
|
|
||||||
- '12'
|
|
||||||
- '14'
|
|
||||||
- lts/*
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
- rod@vagg.org
|
|
||||||
- matteo.collina@gmail.com
|
|
||||||
13
node_modules/bl/LICENSE.md
generated
vendored
13
node_modules/bl/LICENSE.md
generated
vendored
@@ -1,13 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
=====================
|
|
||||||
|
|
||||||
Copyright (c) 2013-2016 bl contributors
|
|
||||||
----------------------------------
|
|
||||||
|
|
||||||
*bl contributors listed at <https://github.com/rvagg/bl#contributors>*
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
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.
|
|
||||||
208
node_modules/bl/README.md
generated
vendored
208
node_modules/bl/README.md
generated
vendored
@@ -1,208 +0,0 @@
|
|||||||
# bl *(BufferList)*
|
|
||||||
|
|
||||||
[](https://travis-ci.org/rvagg/bl)
|
|
||||||
|
|
||||||
**A Node.js Buffer list collector, reader and streamer thingy.**
|
|
||||||
|
|
||||||
[](https://nodei.co/npm/bl/)
|
|
||||||
[](https://nodei.co/npm/bl/)
|
|
||||||
|
|
||||||
**bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them!
|
|
||||||
|
|
||||||
The original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const BufferList = require('bl')
|
|
||||||
|
|
||||||
var bl = new BufferList()
|
|
||||||
bl.append(new Buffer('abcd'))
|
|
||||||
bl.append(new Buffer('efg'))
|
|
||||||
bl.append('hi') // bl will also accept & convert Strings
|
|
||||||
bl.append(new Buffer('j'))
|
|
||||||
bl.append(new Buffer([ 0x3, 0x4 ]))
|
|
||||||
|
|
||||||
console.log(bl.length) // 12
|
|
||||||
|
|
||||||
console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij'
|
|
||||||
console.log(bl.slice(3, 10).toString('ascii')) // 'defghij'
|
|
||||||
console.log(bl.slice(3, 6).toString('ascii')) // 'def'
|
|
||||||
console.log(bl.slice(3, 8).toString('ascii')) // 'defgh'
|
|
||||||
console.log(bl.slice(5, 10).toString('ascii')) // 'fghij'
|
|
||||||
|
|
||||||
// or just use toString!
|
|
||||||
console.log(bl.toString()) // 'abcdefghij\u0003\u0004'
|
|
||||||
console.log(bl.toString('ascii', 3, 8)) // 'defgh'
|
|
||||||
console.log(bl.toString('ascii', 5, 10)) // 'fghij'
|
|
||||||
|
|
||||||
// other standard Buffer readables
|
|
||||||
console.log(bl.readUInt16BE(10)) // 0x0304
|
|
||||||
console.log(bl.readUInt16LE(10)) // 0x0403
|
|
||||||
```
|
|
||||||
|
|
||||||
Give it a callback in the constructor and use it just like **[concat-stream](https://github.com/maxogden/node-concat-stream)**:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const bl = require('bl')
|
|
||||||
, fs = require('fs')
|
|
||||||
|
|
||||||
fs.createReadStream('README.md')
|
|
||||||
.pipe(bl(function (err, data) { // note 'new' isn't strictly required
|
|
||||||
// `data` is a complete Buffer object containing the full data
|
|
||||||
console.log(data.toString())
|
|
||||||
}))
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that when you use the *callback* method like this, the resulting `data` parameter is a concatenation of all `Buffer` objects in the list. If you want to avoid the overhead of this concatenation (in cases of extreme performance consciousness), then avoid the *callback* method and just listen to `'end'` instead, like a standard Stream.
|
|
||||||
|
|
||||||
Or to fetch a URL using [hyperquest](https://github.com/substack/hyperquest) (should work with [request](http://github.com/mikeal/request) and even plain Node http too!):
|
|
||||||
```js
|
|
||||||
const hyperquest = require('hyperquest')
|
|
||||||
, bl = require('bl')
|
|
||||||
, url = 'https://raw.github.com/rvagg/bl/master/README.md'
|
|
||||||
|
|
||||||
hyperquest(url).pipe(bl(function (err, data) {
|
|
||||||
console.log(data.toString())
|
|
||||||
}))
|
|
||||||
```
|
|
||||||
|
|
||||||
Or, use it as a readable stream to recompose a list of Buffers to an output source:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const BufferList = require('bl')
|
|
||||||
, fs = require('fs')
|
|
||||||
|
|
||||||
var bl = new BufferList()
|
|
||||||
bl.append(new Buffer('abcd'))
|
|
||||||
bl.append(new Buffer('efg'))
|
|
||||||
bl.append(new Buffer('hi'))
|
|
||||||
bl.append(new Buffer('j'))
|
|
||||||
|
|
||||||
bl.pipe(fs.createWriteStream('gibberish.txt'))
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
* <a href="#ctor"><code><b>new BufferList([ callback ])</b></code></a>
|
|
||||||
* <a href="#length"><code>bl.<b>length</b></code></a>
|
|
||||||
* <a href="#append"><code>bl.<b>append(buffer)</b></code></a>
|
|
||||||
* <a href="#get"><code>bl.<b>get(index)</b></code></a>
|
|
||||||
* <a href="#slice"><code>bl.<b>slice([ start[, end ] ])</b></code></a>
|
|
||||||
* <a href="#shallowSlice"><code>bl.<b>shallowSlice([ start[, end ] ])</b></code></a>
|
|
||||||
* <a href="#copy"><code>bl.<b>copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])</b></code></a>
|
|
||||||
* <a href="#duplicate"><code>bl.<b>duplicate()</b></code></a>
|
|
||||||
* <a href="#consume"><code>bl.<b>consume(bytes)</b></code></a>
|
|
||||||
* <a href="#toString"><code>bl.<b>toString([encoding, [ start, [ end ]]])</b></code></a>
|
|
||||||
* <a href="#readXX"><code>bl.<b>readDoubleBE()</b></code>, <code>bl.<b>readDoubleLE()</b></code>, <code>bl.<b>readFloatBE()</b></code>, <code>bl.<b>readFloatLE()</b></code>, <code>bl.<b>readInt32BE()</b></code>, <code>bl.<b>readInt32LE()</b></code>, <code>bl.<b>readUInt32BE()</b></code>, <code>bl.<b>readUInt32LE()</b></code>, <code>bl.<b>readInt16BE()</b></code>, <code>bl.<b>readInt16LE()</b></code>, <code>bl.<b>readUInt16BE()</b></code>, <code>bl.<b>readUInt16LE()</b></code>, <code>bl.<b>readInt8()</b></code>, <code>bl.<b>readUInt8()</b></code></a>
|
|
||||||
* <a href="#streams">Streams</a>
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="ctor"></a>
|
|
||||||
### new BufferList([ callback | Buffer | Buffer array | BufferList | BufferList array | String ])
|
|
||||||
The constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream.
|
|
||||||
|
|
||||||
Normally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object.
|
|
||||||
|
|
||||||
`new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var bl = require('bl')
|
|
||||||
var myinstance = bl()
|
|
||||||
|
|
||||||
// equivalent to:
|
|
||||||
|
|
||||||
var BufferList = require('bl')
|
|
||||||
var myinstance = new BufferList()
|
|
||||||
```
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="length"></a>
|
|
||||||
### bl.length
|
|
||||||
Get the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="append"></a>
|
|
||||||
### bl.append(Buffer | Buffer array | BufferList | BufferList array | String)
|
|
||||||
`append(buffer)` adds an additional buffer or BufferList to the internal list. `this` is returned so it can be chained.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="get"></a>
|
|
||||||
### bl.get(index)
|
|
||||||
`get()` will return the byte at the specified index.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="slice"></a>
|
|
||||||
### bl.slice([ start, [ end ] ])
|
|
||||||
`slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
|
|
||||||
|
|
||||||
If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="shallowSlice"></a>
|
|
||||||
### bl.shallowSlice([ start, [ end ] ])
|
|
||||||
`shallowSlice()` returns a new `BufferList` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
|
|
||||||
|
|
||||||
No copies will be performed. All buffers in the result share memory with the original list.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="copy"></a>
|
|
||||||
### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
|
|
||||||
`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="duplicate"></a>
|
|
||||||
### bl.duplicate()
|
|
||||||
`duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var bl = new BufferList()
|
|
||||||
|
|
||||||
bl.append('hello')
|
|
||||||
bl.append(' world')
|
|
||||||
bl.append('\n')
|
|
||||||
|
|
||||||
bl.duplicate().pipe(process.stdout, { end: false })
|
|
||||||
|
|
||||||
console.log(bl.toString())
|
|
||||||
```
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="consume"></a>
|
|
||||||
### bl.consume(bytes)
|
|
||||||
`consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers—initial offsets will be calculated accordingly in order to give you a consistent view of the data.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="toString"></a>
|
|
||||||
### bl.toString([encoding, [ start, [ end ]]])
|
|
||||||
`toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="readXX"></a>
|
|
||||||
### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()
|
|
||||||
|
|
||||||
All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently.
|
|
||||||
|
|
||||||
See the <b><code>[Buffer](http://nodejs.org/docs/latest/api/buffer.html)</code></b> documentation for how these work.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
<a name="streams"></a>
|
|
||||||
### Streams
|
|
||||||
**bl** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **bl** instance.
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
**bl** is brought to you by the following hackers:
|
|
||||||
|
|
||||||
* [Rod Vagg](https://github.com/rvagg)
|
|
||||||
* [Matteo Collina](https://github.com/mcollina)
|
|
||||||
* [Jarett Cruger](https://github.com/jcrugzz)
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
<a name="license"></a>
|
|
||||||
## License & copyright
|
|
||||||
|
|
||||||
Copyright (c) 2013-2016 bl contributors (listed above).
|
|
||||||
|
|
||||||
bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
|
|
||||||
290
node_modules/bl/bl.js
generated
vendored
290
node_modules/bl/bl.js
generated
vendored
@@ -1,290 +0,0 @@
|
|||||||
var DuplexStream = require('readable-stream/duplex')
|
|
||||||
, util = require('util')
|
|
||||||
, Buffer = require('safe-buffer').Buffer
|
|
||||||
|
|
||||||
|
|
||||||
function BufferList (callback) {
|
|
||||||
if (!(this instanceof BufferList))
|
|
||||||
return new BufferList(callback)
|
|
||||||
|
|
||||||
this._bufs = []
|
|
||||||
this.length = 0
|
|
||||||
|
|
||||||
if (typeof callback == 'function') {
|
|
||||||
this._callback = callback
|
|
||||||
|
|
||||||
var piper = function piper (err) {
|
|
||||||
if (this._callback) {
|
|
||||||
this._callback(err)
|
|
||||||
this._callback = null
|
|
||||||
}
|
|
||||||
}.bind(this)
|
|
||||||
|
|
||||||
this.on('pipe', function onPipe (src) {
|
|
||||||
src.on('error', piper)
|
|
||||||
})
|
|
||||||
this.on('unpipe', function onUnpipe (src) {
|
|
||||||
src.removeListener('error', piper)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.append(callback)
|
|
||||||
}
|
|
||||||
|
|
||||||
DuplexStream.call(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
util.inherits(BufferList, DuplexStream)
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype._offset = function _offset (offset) {
|
|
||||||
var tot = 0, i = 0, _t
|
|
||||||
if (offset === 0) return [ 0, 0 ]
|
|
||||||
for (; i < this._bufs.length; i++) {
|
|
||||||
_t = tot + this._bufs[i].length
|
|
||||||
if (offset < _t || i == this._bufs.length - 1)
|
|
||||||
return [ i, offset - tot ]
|
|
||||||
tot = _t
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype.append = function append (buf) {
|
|
||||||
var i = 0
|
|
||||||
|
|
||||||
if (Buffer.isBuffer(buf)) {
|
|
||||||
this._appendBuffer(buf);
|
|
||||||
} else if (Array.isArray(buf)) {
|
|
||||||
for (; i < buf.length; i++)
|
|
||||||
this.append(buf[i])
|
|
||||||
} else if (buf instanceof BufferList) {
|
|
||||||
// unwrap argument into individual BufferLists
|
|
||||||
for (; i < buf._bufs.length; i++)
|
|
||||||
this.append(buf._bufs[i])
|
|
||||||
} else if (buf != null) {
|
|
||||||
// coerce number arguments to strings, since Buffer(number) does
|
|
||||||
// uninitialized memory allocation
|
|
||||||
if (typeof buf == 'number')
|
|
||||||
buf = buf.toString()
|
|
||||||
|
|
||||||
this._appendBuffer(Buffer.from(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype._appendBuffer = function appendBuffer (buf) {
|
|
||||||
this._bufs.push(buf)
|
|
||||||
this.length += buf.length
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype._write = function _write (buf, encoding, callback) {
|
|
||||||
this._appendBuffer(buf)
|
|
||||||
|
|
||||||
if (typeof callback == 'function')
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype._read = function _read (size) {
|
|
||||||
if (!this.length)
|
|
||||||
return this.push(null)
|
|
||||||
|
|
||||||
size = Math.min(size, this.length)
|
|
||||||
this.push(this.slice(0, size))
|
|
||||||
this.consume(size)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype.end = function end (chunk) {
|
|
||||||
DuplexStream.prototype.end.call(this, chunk)
|
|
||||||
|
|
||||||
if (this._callback) {
|
|
||||||
this._callback(null, this.slice())
|
|
||||||
this._callback = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype.get = function get (index) {
|
|
||||||
return this.slice(index, index + 1)[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype.slice = function slice (start, end) {
|
|
||||||
if (typeof start == 'number' && start < 0)
|
|
||||||
start += this.length
|
|
||||||
if (typeof end == 'number' && end < 0)
|
|
||||||
end += this.length
|
|
||||||
return this.copy(null, 0, start, end)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
|
|
||||||
if (typeof srcStart != 'number' || srcStart < 0)
|
|
||||||
srcStart = 0
|
|
||||||
if (typeof srcEnd != 'number' || srcEnd > this.length)
|
|
||||||
srcEnd = this.length
|
|
||||||
if (srcStart >= this.length)
|
|
||||||
return dst || Buffer.alloc(0)
|
|
||||||
if (srcEnd <= 0)
|
|
||||||
return dst || Buffer.alloc(0)
|
|
||||||
|
|
||||||
var copy = !!dst
|
|
||||||
, off = this._offset(srcStart)
|
|
||||||
, len = srcEnd - srcStart
|
|
||||||
, bytes = len
|
|
||||||
, bufoff = (copy && dstStart) || 0
|
|
||||||
, start = off[1]
|
|
||||||
, l
|
|
||||||
, i
|
|
||||||
|
|
||||||
// copy/slice everything
|
|
||||||
if (srcStart === 0 && srcEnd == this.length) {
|
|
||||||
if (!copy) { // slice, but full concat if multiple buffers
|
|
||||||
return this._bufs.length === 1
|
|
||||||
? this._bufs[0]
|
|
||||||
: Buffer.concat(this._bufs, this.length)
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy, need to copy individual buffers
|
|
||||||
for (i = 0; i < this._bufs.length; i++) {
|
|
||||||
this._bufs[i].copy(dst, bufoff)
|
|
||||||
bufoff += this._bufs[i].length
|
|
||||||
}
|
|
||||||
|
|
||||||
return dst
|
|
||||||
}
|
|
||||||
|
|
||||||
// easy, cheap case where it's a subset of one of the buffers
|
|
||||||
if (bytes <= this._bufs[off[0]].length - start) {
|
|
||||||
return copy
|
|
||||||
? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
|
|
||||||
: this._bufs[off[0]].slice(start, start + bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!copy) // a slice, we need something to copy in to
|
|
||||||
dst = Buffer.allocUnsafe(len)
|
|
||||||
|
|
||||||
for (i = off[0]; i < this._bufs.length; i++) {
|
|
||||||
l = this._bufs[i].length - start
|
|
||||||
|
|
||||||
if (bytes > l) {
|
|
||||||
this._bufs[i].copy(dst, bufoff, start)
|
|
||||||
bufoff += l
|
|
||||||
} else {
|
|
||||||
this._bufs[i].copy(dst, bufoff, start, start + bytes)
|
|
||||||
bufoff += l
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes -= l
|
|
||||||
|
|
||||||
if (start)
|
|
||||||
start = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// safeguard so that we don't return uninitialized memory
|
|
||||||
if (dst.length > bufoff) return dst.slice(0, bufoff)
|
|
||||||
|
|
||||||
return dst
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
|
|
||||||
start = start || 0
|
|
||||||
end = end || this.length
|
|
||||||
|
|
||||||
if (start < 0)
|
|
||||||
start += this.length
|
|
||||||
if (end < 0)
|
|
||||||
end += this.length
|
|
||||||
|
|
||||||
var startOffset = this._offset(start)
|
|
||||||
, endOffset = this._offset(end)
|
|
||||||
, buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
|
|
||||||
|
|
||||||
if (endOffset[1] == 0)
|
|
||||||
buffers.pop()
|
|
||||||
else
|
|
||||||
buffers[buffers.length-1] = buffers[buffers.length-1].slice(0, endOffset[1])
|
|
||||||
|
|
||||||
if (startOffset[1] != 0)
|
|
||||||
buffers[0] = buffers[0].slice(startOffset[1])
|
|
||||||
|
|
||||||
return new BufferList(buffers)
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferList.prototype.toString = function toString (encoding, start, end) {
|
|
||||||
return this.slice(start, end).toString(encoding)
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferList.prototype.consume = function consume (bytes) {
|
|
||||||
// first, normalize the argument, in accordance with how Buffer does it
|
|
||||||
bytes = Math.trunc(bytes)
|
|
||||||
// do nothing if not a positive number
|
|
||||||
if (Number.isNaN(bytes) || bytes <= 0) return this
|
|
||||||
|
|
||||||
while (this._bufs.length) {
|
|
||||||
if (bytes >= this._bufs[0].length) {
|
|
||||||
bytes -= this._bufs[0].length
|
|
||||||
this.length -= this._bufs[0].length
|
|
||||||
this._bufs.shift()
|
|
||||||
} else {
|
|
||||||
this._bufs[0] = this._bufs[0].slice(bytes)
|
|
||||||
this.length -= bytes
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype.duplicate = function duplicate () {
|
|
||||||
var i = 0
|
|
||||||
, copy = new BufferList()
|
|
||||||
|
|
||||||
for (; i < this._bufs.length; i++)
|
|
||||||
copy.append(this._bufs[i])
|
|
||||||
|
|
||||||
return copy
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BufferList.prototype.destroy = function destroy () {
|
|
||||||
this._bufs.length = 0
|
|
||||||
this.length = 0
|
|
||||||
this.push(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
;(function () {
|
|
||||||
var methods = {
|
|
||||||
'readDoubleBE' : 8
|
|
||||||
, 'readDoubleLE' : 8
|
|
||||||
, 'readFloatBE' : 4
|
|
||||||
, 'readFloatLE' : 4
|
|
||||||
, 'readInt32BE' : 4
|
|
||||||
, 'readInt32LE' : 4
|
|
||||||
, 'readUInt32BE' : 4
|
|
||||||
, 'readUInt32LE' : 4
|
|
||||||
, 'readInt16BE' : 2
|
|
||||||
, 'readInt16LE' : 2
|
|
||||||
, 'readUInt16BE' : 2
|
|
||||||
, 'readUInt16LE' : 2
|
|
||||||
, 'readInt8' : 1
|
|
||||||
, 'readUInt8' : 1
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var m in methods) {
|
|
||||||
(function (m) {
|
|
||||||
BufferList.prototype[m] = function (offset) {
|
|
||||||
return this.slice(offset, offset + methods[m])[m](0)
|
|
||||||
}
|
|
||||||
}(m))
|
|
||||||
}
|
|
||||||
}())
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = BufferList
|
|
||||||
35
node_modules/bl/package.json
generated
vendored
35
node_modules/bl/package.json
generated
vendored
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "bl",
|
|
||||||
"version": "1.2.3",
|
|
||||||
"description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
|
|
||||||
"main": "bl.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "node test/test.js | faucet"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/rvagg/bl.git"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/rvagg/bl",
|
|
||||||
"authors": [
|
|
||||||
"Rod Vagg <rod@vagg.org> (https://github.com/rvagg)",
|
|
||||||
"Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
|
|
||||||
"Jarett Cruger <jcrugzz@gmail.com> (https://github.com/jcrugzz)"
|
|
||||||
],
|
|
||||||
"keywords": [
|
|
||||||
"buffer",
|
|
||||||
"buffers",
|
|
||||||
"stream",
|
|
||||||
"awesomesauce"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"readable-stream": "^2.3.5",
|
|
||||||
"safe-buffer": "^5.1.1"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"faucet": "0.0.1",
|
|
||||||
"hash_file": "~0.1.1",
|
|
||||||
"tape": "~4.9.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
718
node_modules/bl/test/test.js
generated
vendored
718
node_modules/bl/test/test.js
generated
vendored
@@ -1,718 +0,0 @@
|
|||||||
var tape = require('tape')
|
|
||||||
, crypto = require('crypto')
|
|
||||||
, fs = require('fs')
|
|
||||||
, hash = require('hash_file')
|
|
||||||
, BufferList = require('../')
|
|
||||||
, Buffer = require('safe-buffer').Buffer
|
|
||||||
|
|
||||||
, encodings =
|
|
||||||
('hex utf8 utf-8 ascii binary base64'
|
|
||||||
+ (process.browser ? '' : ' ucs2 ucs-2 utf16le utf-16le')).split(' ')
|
|
||||||
|
|
||||||
tape('single bytes from single buffer', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
bl.append(Buffer.from('abcd'))
|
|
||||||
|
|
||||||
t.equal(bl.length, 4)
|
|
||||||
|
|
||||||
t.equal(bl.get(0), 97)
|
|
||||||
t.equal(bl.get(1), 98)
|
|
||||||
t.equal(bl.get(2), 99)
|
|
||||||
t.equal(bl.get(3), 100)
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('single bytes from multiple buffers', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
bl.append(Buffer.from('abcd'))
|
|
||||||
bl.append(Buffer.from('efg'))
|
|
||||||
bl.append(Buffer.from('hi'))
|
|
||||||
bl.append(Buffer.from('j'))
|
|
||||||
|
|
||||||
t.equal(bl.length, 10)
|
|
||||||
|
|
||||||
t.equal(bl.get(0), 97)
|
|
||||||
t.equal(bl.get(1), 98)
|
|
||||||
t.equal(bl.get(2), 99)
|
|
||||||
t.equal(bl.get(3), 100)
|
|
||||||
t.equal(bl.get(4), 101)
|
|
||||||
t.equal(bl.get(5), 102)
|
|
||||||
t.equal(bl.get(6), 103)
|
|
||||||
t.equal(bl.get(7), 104)
|
|
||||||
t.equal(bl.get(8), 105)
|
|
||||||
t.equal(bl.get(9), 106)
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('multi bytes from single buffer', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
bl.append(Buffer.from('abcd'))
|
|
||||||
|
|
||||||
t.equal(bl.length, 4)
|
|
||||||
|
|
||||||
t.equal(bl.slice(0, 4).toString('ascii'), 'abcd')
|
|
||||||
t.equal(bl.slice(0, 3).toString('ascii'), 'abc')
|
|
||||||
t.equal(bl.slice(1, 4).toString('ascii'), 'bcd')
|
|
||||||
t.equal(bl.slice(-4, -1).toString('ascii'), 'abc')
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('multi bytes from single buffer (negative indexes)', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
bl.append(Buffer.from('buffer'))
|
|
||||||
|
|
||||||
t.equal(bl.length, 6)
|
|
||||||
|
|
||||||
t.equal(bl.slice(-6, -1).toString('ascii'), 'buffe')
|
|
||||||
t.equal(bl.slice(-6, -2).toString('ascii'), 'buff')
|
|
||||||
t.equal(bl.slice(-5, -2).toString('ascii'), 'uff')
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('multiple bytes from multiple buffers', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
|
|
||||||
bl.append(Buffer.from('abcd'))
|
|
||||||
bl.append(Buffer.from('efg'))
|
|
||||||
bl.append(Buffer.from('hi'))
|
|
||||||
bl.append(Buffer.from('j'))
|
|
||||||
|
|
||||||
t.equal(bl.length, 10)
|
|
||||||
|
|
||||||
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
|
|
||||||
t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
|
|
||||||
t.equal(bl.slice(3, 6).toString('ascii'), 'def')
|
|
||||||
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
|
|
||||||
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
|
|
||||||
t.equal(bl.slice(-7, -4).toString('ascii'), 'def')
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('multiple bytes from multiple buffer lists', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
|
|
||||||
bl.append(new BufferList([ Buffer.from('abcd'), Buffer.from('efg') ]))
|
|
||||||
bl.append(new BufferList([ Buffer.from('hi'), Buffer.from('j') ]))
|
|
||||||
|
|
||||||
t.equal(bl.length, 10)
|
|
||||||
|
|
||||||
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
|
|
||||||
|
|
||||||
t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
|
|
||||||
t.equal(bl.slice(3, 6).toString('ascii'), 'def')
|
|
||||||
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
|
|
||||||
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
// same data as previous test, just using nested constructors
|
|
||||||
tape('multiple bytes from crazy nested buffer lists', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
|
|
||||||
bl.append(new BufferList([
|
|
||||||
new BufferList([
|
|
||||||
new BufferList(Buffer.from('abc'))
|
|
||||||
, Buffer.from('d')
|
|
||||||
, new BufferList(Buffer.from('efg'))
|
|
||||||
])
|
|
||||||
, new BufferList([ Buffer.from('hi') ])
|
|
||||||
, new BufferList(Buffer.from('j'))
|
|
||||||
]))
|
|
||||||
|
|
||||||
t.equal(bl.length, 10)
|
|
||||||
|
|
||||||
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
|
|
||||||
|
|
||||||
t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
|
|
||||||
t.equal(bl.slice(3, 6).toString('ascii'), 'def')
|
|
||||||
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
|
|
||||||
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('append accepts arrays of Buffers', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
bl.append(Buffer.from('abc'))
|
|
||||||
bl.append([ Buffer.from('def') ])
|
|
||||||
bl.append([ Buffer.from('ghi'), Buffer.from('jkl') ])
|
|
||||||
bl.append([ Buffer.from('mnop'), Buffer.from('qrstu'), Buffer.from('vwxyz') ])
|
|
||||||
t.equal(bl.length, 26)
|
|
||||||
t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('append accepts arrays of BufferLists', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
bl.append(Buffer.from('abc'))
|
|
||||||
bl.append([ new BufferList('def') ])
|
|
||||||
bl.append(new BufferList([ Buffer.from('ghi'), new BufferList('jkl') ]))
|
|
||||||
bl.append([ Buffer.from('mnop'), new BufferList([ Buffer.from('qrstu'), Buffer.from('vwxyz') ]) ])
|
|
||||||
t.equal(bl.length, 26)
|
|
||||||
t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('append chainable', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
t.ok(bl.append(Buffer.from('abcd')) === bl)
|
|
||||||
t.ok(bl.append([ Buffer.from('abcd') ]) === bl)
|
|
||||||
t.ok(bl.append(new BufferList(Buffer.from('abcd'))) === bl)
|
|
||||||
t.ok(bl.append([ new BufferList(Buffer.from('abcd')) ]) === bl)
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('append chainable (test results)', function (t) {
|
|
||||||
var bl = new BufferList('abc')
|
|
||||||
.append([ new BufferList('def') ])
|
|
||||||
.append(new BufferList([ Buffer.from('ghi'), new BufferList('jkl') ]))
|
|
||||||
.append([ Buffer.from('mnop'), new BufferList([ Buffer.from('qrstu'), Buffer.from('vwxyz') ]) ])
|
|
||||||
|
|
||||||
t.equal(bl.length, 26)
|
|
||||||
t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('consuming from multiple buffers', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
|
|
||||||
bl.append(Buffer.from('abcd'))
|
|
||||||
bl.append(Buffer.from('efg'))
|
|
||||||
bl.append(Buffer.from('hi'))
|
|
||||||
bl.append(Buffer.from('j'))
|
|
||||||
|
|
||||||
t.equal(bl.length, 10)
|
|
||||||
|
|
||||||
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
|
|
||||||
|
|
||||||
bl.consume(3)
|
|
||||||
t.equal(bl.length, 7)
|
|
||||||
t.equal(bl.slice(0, 7).toString('ascii'), 'defghij')
|
|
||||||
|
|
||||||
bl.consume(2)
|
|
||||||
t.equal(bl.length, 5)
|
|
||||||
t.equal(bl.slice(0, 5).toString('ascii'), 'fghij')
|
|
||||||
|
|
||||||
bl.consume(1)
|
|
||||||
t.equal(bl.length, 4)
|
|
||||||
t.equal(bl.slice(0, 4).toString('ascii'), 'ghij')
|
|
||||||
|
|
||||||
bl.consume(1)
|
|
||||||
t.equal(bl.length, 3)
|
|
||||||
t.equal(bl.slice(0, 3).toString('ascii'), 'hij')
|
|
||||||
|
|
||||||
bl.consume(2)
|
|
||||||
t.equal(bl.length, 1)
|
|
||||||
t.equal(bl.slice(0, 1).toString('ascii'), 'j')
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('complete consumption', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
|
|
||||||
bl.append(Buffer.from('a'))
|
|
||||||
bl.append(Buffer.from('b'))
|
|
||||||
|
|
||||||
bl.consume(2)
|
|
||||||
|
|
||||||
t.equal(bl.length, 0)
|
|
||||||
t.equal(bl._bufs.length, 0)
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test readUInt8 / readInt8', function (t) {
|
|
||||||
var buf1 = Buffer.alloc(1)
|
|
||||||
, buf2 = Buffer.alloc(3)
|
|
||||||
, buf3 = Buffer.alloc(3)
|
|
||||||
, bl = new BufferList()
|
|
||||||
|
|
||||||
buf2[1] = 0x3
|
|
||||||
buf2[2] = 0x4
|
|
||||||
buf3[0] = 0x23
|
|
||||||
buf3[1] = 0x42
|
|
||||||
|
|
||||||
bl.append(buf1)
|
|
||||||
bl.append(buf2)
|
|
||||||
bl.append(buf3)
|
|
||||||
|
|
||||||
t.equal(bl.readUInt8(2), 0x3)
|
|
||||||
t.equal(bl.readInt8(2), 0x3)
|
|
||||||
t.equal(bl.readUInt8(3), 0x4)
|
|
||||||
t.equal(bl.readInt8(3), 0x4)
|
|
||||||
t.equal(bl.readUInt8(4), 0x23)
|
|
||||||
t.equal(bl.readInt8(4), 0x23)
|
|
||||||
t.equal(bl.readUInt8(5), 0x42)
|
|
||||||
t.equal(bl.readInt8(5), 0x42)
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) {
|
|
||||||
var buf1 = Buffer.alloc(1)
|
|
||||||
, buf2 = Buffer.alloc(3)
|
|
||||||
, buf3 = Buffer.alloc(3)
|
|
||||||
, bl = new BufferList()
|
|
||||||
|
|
||||||
buf2[1] = 0x3
|
|
||||||
buf2[2] = 0x4
|
|
||||||
buf3[0] = 0x23
|
|
||||||
buf3[1] = 0x42
|
|
||||||
|
|
||||||
bl.append(buf1)
|
|
||||||
bl.append(buf2)
|
|
||||||
bl.append(buf3)
|
|
||||||
|
|
||||||
t.equal(bl.readUInt16BE(2), 0x0304)
|
|
||||||
t.equal(bl.readUInt16LE(2), 0x0403)
|
|
||||||
t.equal(bl.readInt16BE(2), 0x0304)
|
|
||||||
t.equal(bl.readInt16LE(2), 0x0403)
|
|
||||||
t.equal(bl.readUInt16BE(3), 0x0423)
|
|
||||||
t.equal(bl.readUInt16LE(3), 0x2304)
|
|
||||||
t.equal(bl.readInt16BE(3), 0x0423)
|
|
||||||
t.equal(bl.readInt16LE(3), 0x2304)
|
|
||||||
t.equal(bl.readUInt16BE(4), 0x2342)
|
|
||||||
t.equal(bl.readUInt16LE(4), 0x4223)
|
|
||||||
t.equal(bl.readInt16BE(4), 0x2342)
|
|
||||||
t.equal(bl.readInt16LE(4), 0x4223)
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) {
|
|
||||||
var buf1 = Buffer.alloc(1)
|
|
||||||
, buf2 = Buffer.alloc(3)
|
|
||||||
, buf3 = Buffer.alloc(3)
|
|
||||||
, bl = new BufferList()
|
|
||||||
|
|
||||||
buf2[1] = 0x3
|
|
||||||
buf2[2] = 0x4
|
|
||||||
buf3[0] = 0x23
|
|
||||||
buf3[1] = 0x42
|
|
||||||
|
|
||||||
bl.append(buf1)
|
|
||||||
bl.append(buf2)
|
|
||||||
bl.append(buf3)
|
|
||||||
|
|
||||||
t.equal(bl.readUInt32BE(2), 0x03042342)
|
|
||||||
t.equal(bl.readUInt32LE(2), 0x42230403)
|
|
||||||
t.equal(bl.readInt32BE(2), 0x03042342)
|
|
||||||
t.equal(bl.readInt32LE(2), 0x42230403)
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test readFloatLE / readFloatBE', function (t) {
|
|
||||||
var buf1 = Buffer.alloc(1)
|
|
||||||
, buf2 = Buffer.alloc(3)
|
|
||||||
, buf3 = Buffer.alloc(3)
|
|
||||||
, bl = new BufferList()
|
|
||||||
|
|
||||||
buf2[1] = 0x00
|
|
||||||
buf2[2] = 0x00
|
|
||||||
buf3[0] = 0x80
|
|
||||||
buf3[1] = 0x3f
|
|
||||||
|
|
||||||
bl.append(buf1)
|
|
||||||
bl.append(buf2)
|
|
||||||
bl.append(buf3)
|
|
||||||
|
|
||||||
t.equal(bl.readFloatLE(2), 0x01)
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test readDoubleLE / readDoubleBE', function (t) {
|
|
||||||
var buf1 = Buffer.alloc(1)
|
|
||||||
, buf2 = Buffer.alloc(3)
|
|
||||||
, buf3 = Buffer.alloc(10)
|
|
||||||
, bl = new BufferList()
|
|
||||||
|
|
||||||
buf2[1] = 0x55
|
|
||||||
buf2[2] = 0x55
|
|
||||||
buf3[0] = 0x55
|
|
||||||
buf3[1] = 0x55
|
|
||||||
buf3[2] = 0x55
|
|
||||||
buf3[3] = 0x55
|
|
||||||
buf3[4] = 0xd5
|
|
||||||
buf3[5] = 0x3f
|
|
||||||
|
|
||||||
bl.append(buf1)
|
|
||||||
bl.append(buf2)
|
|
||||||
bl.append(buf3)
|
|
||||||
|
|
||||||
t.equal(bl.readDoubleLE(2), 0.3333333333333333)
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test toString', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
|
|
||||||
bl.append(Buffer.from('abcd'))
|
|
||||||
bl.append(Buffer.from('efg'))
|
|
||||||
bl.append(Buffer.from('hi'))
|
|
||||||
bl.append(Buffer.from('j'))
|
|
||||||
|
|
||||||
t.equal(bl.toString('ascii', 0, 10), 'abcdefghij')
|
|
||||||
t.equal(bl.toString('ascii', 3, 10), 'defghij')
|
|
||||||
t.equal(bl.toString('ascii', 3, 6), 'def')
|
|
||||||
t.equal(bl.toString('ascii', 3, 8), 'defgh')
|
|
||||||
t.equal(bl.toString('ascii', 5, 10), 'fghij')
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test toString encoding', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
, b = Buffer.from('abcdefghij\xff\x00')
|
|
||||||
|
|
||||||
bl.append(Buffer.from('abcd'))
|
|
||||||
bl.append(Buffer.from('efg'))
|
|
||||||
bl.append(Buffer.from('hi'))
|
|
||||||
bl.append(Buffer.from('j'))
|
|
||||||
bl.append(Buffer.from('\xff\x00'))
|
|
||||||
|
|
||||||
encodings.forEach(function (enc) {
|
|
||||||
t.equal(bl.toString(enc), b.toString(enc), enc)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('uninitialized memory', function (t) {
|
|
||||||
const secret = crypto.randomBytes(256)
|
|
||||||
for (let i = 0; i < 1e6; i++) {
|
|
||||||
const clone = Buffer.from(secret)
|
|
||||||
const bl = new BufferList()
|
|
||||||
bl.append(Buffer.from('a'))
|
|
||||||
bl.consume(-1024)
|
|
||||||
const buf = bl.slice(1)
|
|
||||||
if (buf.indexOf(clone) !== -1) {
|
|
||||||
t.fail(`Match (at ${i})`)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
!process.browser && tape('test stream', function (t) {
|
|
||||||
var random = crypto.randomBytes(65534)
|
|
||||||
, rndhash = hash(random, 'md5')
|
|
||||||
, md5sum = crypto.createHash('md5')
|
|
||||||
, bl = new BufferList(function (err, buf) {
|
|
||||||
t.ok(Buffer.isBuffer(buf))
|
|
||||||
t.ok(err === null)
|
|
||||||
t.equal(rndhash, hash(bl.slice(), 'md5'))
|
|
||||||
t.equal(rndhash, hash(buf, 'md5'))
|
|
||||||
|
|
||||||
bl.pipe(fs.createWriteStream('/tmp/bl_test_rnd_out.dat'))
|
|
||||||
.on('close', function () {
|
|
||||||
var s = fs.createReadStream('/tmp/bl_test_rnd_out.dat')
|
|
||||||
s.on('data', md5sum.update.bind(md5sum))
|
|
||||||
s.on('end', function() {
|
|
||||||
t.equal(rndhash, md5sum.digest('hex'), 'woohoo! correct hash!')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
fs.writeFileSync('/tmp/bl_test_rnd.dat', random)
|
|
||||||
fs.createReadStream('/tmp/bl_test_rnd.dat').pipe(bl)
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('instantiation with Buffer', function (t) {
|
|
||||||
var buf = crypto.randomBytes(1024)
|
|
||||||
, buf2 = crypto.randomBytes(1024)
|
|
||||||
, b = BufferList(buf)
|
|
||||||
|
|
||||||
t.equal(buf.toString('hex'), b.slice().toString('hex'), 'same buffer')
|
|
||||||
b = BufferList([ buf, buf2 ])
|
|
||||||
t.equal(b.slice().toString('hex'), Buffer.concat([ buf, buf2 ]).toString('hex'), 'same buffer')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test String appendage', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
, b = Buffer.from('abcdefghij\xff\x00')
|
|
||||||
|
|
||||||
bl.append('abcd')
|
|
||||||
bl.append('efg')
|
|
||||||
bl.append('hi')
|
|
||||||
bl.append('j')
|
|
||||||
bl.append('\xff\x00')
|
|
||||||
|
|
||||||
encodings.forEach(function (enc) {
|
|
||||||
t.equal(bl.toString(enc), b.toString(enc))
|
|
||||||
})
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('test Number appendage', function (t) {
|
|
||||||
var bl = new BufferList()
|
|
||||||
, b = Buffer.from('1234567890')
|
|
||||||
|
|
||||||
bl.append(1234)
|
|
||||||
bl.append(567)
|
|
||||||
bl.append(89)
|
|
||||||
bl.append(0)
|
|
||||||
|
|
||||||
encodings.forEach(function (enc) {
|
|
||||||
t.equal(bl.toString(enc), b.toString(enc))
|
|
||||||
})
|
|
||||||
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('write nothing, should get empty buffer', function (t) {
|
|
||||||
t.plan(3)
|
|
||||||
BufferList(function (err, data) {
|
|
||||||
t.notOk(err, 'no error')
|
|
||||||
t.ok(Buffer.isBuffer(data), 'got a buffer')
|
|
||||||
t.equal(0, data.length, 'got a zero-length buffer')
|
|
||||||
t.end()
|
|
||||||
}).end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('unicode string', function (t) {
|
|
||||||
t.plan(2)
|
|
||||||
var inp1 = '\u2600'
|
|
||||||
, inp2 = '\u2603'
|
|
||||||
, exp = inp1 + ' and ' + inp2
|
|
||||||
, bl = BufferList()
|
|
||||||
bl.write(inp1)
|
|
||||||
bl.write(' and ')
|
|
||||||
bl.write(inp2)
|
|
||||||
t.equal(exp, bl.toString())
|
|
||||||
t.equal(Buffer.from(exp).toString('hex'), bl.toString('hex'))
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('should emit finish', function (t) {
|
|
||||||
var source = BufferList()
|
|
||||||
, dest = BufferList()
|
|
||||||
|
|
||||||
source.write('hello')
|
|
||||||
source.pipe(dest)
|
|
||||||
|
|
||||||
dest.on('finish', function () {
|
|
||||||
t.equal(dest.toString('utf8'), 'hello')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('basic copy', function (t) {
|
|
||||||
var buf = crypto.randomBytes(1024)
|
|
||||||
, buf2 = Buffer.alloc(1024)
|
|
||||||
, b = BufferList(buf)
|
|
||||||
|
|
||||||
b.copy(buf2)
|
|
||||||
t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('copy after many appends', function (t) {
|
|
||||||
var buf = crypto.randomBytes(512)
|
|
||||||
, buf2 = Buffer.alloc(1024)
|
|
||||||
, b = BufferList(buf)
|
|
||||||
|
|
||||||
b.append(buf)
|
|
||||||
b.copy(buf2)
|
|
||||||
t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('copy at a precise position', function (t) {
|
|
||||||
var buf = crypto.randomBytes(1004)
|
|
||||||
, buf2 = Buffer.alloc(1024)
|
|
||||||
, b = BufferList(buf)
|
|
||||||
|
|
||||||
b.copy(buf2, 20)
|
|
||||||
t.equal(b.slice().toString('hex'), buf2.slice(20).toString('hex'), 'same buffer')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('copy starting from a precise location', function (t) {
|
|
||||||
var buf = crypto.randomBytes(10)
|
|
||||||
, buf2 = Buffer.alloc(5)
|
|
||||||
, b = BufferList(buf)
|
|
||||||
|
|
||||||
b.copy(buf2, 0, 5)
|
|
||||||
t.equal(b.slice(5).toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('copy in an interval', function (t) {
|
|
||||||
var rnd = crypto.randomBytes(10)
|
|
||||||
, b = BufferList(rnd) // put the random bytes there
|
|
||||||
, actual = Buffer.alloc(3)
|
|
||||||
, expected = Buffer.alloc(3)
|
|
||||||
|
|
||||||
rnd.copy(expected, 0, 5, 8)
|
|
||||||
b.copy(actual, 0, 5, 8)
|
|
||||||
|
|
||||||
t.equal(actual.toString('hex'), expected.toString('hex'), 'same buffer')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('copy an interval between two buffers', function (t) {
|
|
||||||
var buf = crypto.randomBytes(10)
|
|
||||||
, buf2 = Buffer.alloc(10)
|
|
||||||
, b = BufferList(buf)
|
|
||||||
|
|
||||||
b.append(buf)
|
|
||||||
b.copy(buf2, 0, 5, 15)
|
|
||||||
|
|
||||||
t.equal(b.slice(5, 15).toString('hex'), buf2.toString('hex'), 'same buffer')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('shallow slice across buffer boundaries', function (t) {
|
|
||||||
var bl = new BufferList(['First', 'Second', 'Third'])
|
|
||||||
|
|
||||||
t.equal(bl.shallowSlice(3, 13).toString(), 'stSecondTh')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('shallow slice within single buffer', function (t) {
|
|
||||||
t.plan(2)
|
|
||||||
var bl = new BufferList(['First', 'Second', 'Third'])
|
|
||||||
|
|
||||||
t.equal(bl.shallowSlice(5, 10).toString(), 'Secon')
|
|
||||||
t.equal(bl.shallowSlice(7, 10).toString(), 'con')
|
|
||||||
t.end()
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('shallow slice single buffer', function (t) {
|
|
||||||
t.plan(3)
|
|
||||||
var bl = new BufferList(['First', 'Second', 'Third'])
|
|
||||||
|
|
||||||
t.equal(bl.shallowSlice(0, 5).toString(), 'First')
|
|
||||||
t.equal(bl.shallowSlice(5, 11).toString(), 'Second')
|
|
||||||
t.equal(bl.shallowSlice(11, 16).toString(), 'Third')
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('shallow slice with negative or omitted indices', function (t) {
|
|
||||||
t.plan(4)
|
|
||||||
var bl = new BufferList(['First', 'Second', 'Third'])
|
|
||||||
|
|
||||||
t.equal(bl.shallowSlice().toString(), 'FirstSecondThird')
|
|
||||||
t.equal(bl.shallowSlice(5).toString(), 'SecondThird')
|
|
||||||
t.equal(bl.shallowSlice(5, -3).toString(), 'SecondTh')
|
|
||||||
t.equal(bl.shallowSlice(-8).toString(), 'ondThird')
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('shallow slice does not make a copy', function (t) {
|
|
||||||
t.plan(1)
|
|
||||||
var buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
|
|
||||||
var bl = (new BufferList(buffers)).shallowSlice(5, -3)
|
|
||||||
|
|
||||||
buffers[1].fill('h')
|
|
||||||
buffers[2].fill('h')
|
|
||||||
|
|
||||||
t.equal(bl.toString(), 'hhhhhhhh')
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('duplicate', function (t) {
|
|
||||||
t.plan(2)
|
|
||||||
|
|
||||||
var bl = new BufferList('abcdefghij\xff\x00')
|
|
||||||
, dup = bl.duplicate()
|
|
||||||
|
|
||||||
t.equal(bl.prototype, dup.prototype)
|
|
||||||
t.equal(bl.toString('hex'), dup.toString('hex'))
|
|
||||||
})
|
|
||||||
|
|
||||||
tape('destroy no pipe', function (t) {
|
|
||||||
t.plan(2)
|
|
||||||
|
|
||||||
var bl = new BufferList('alsdkfja;lsdkfja;lsdk')
|
|
||||||
bl.destroy()
|
|
||||||
|
|
||||||
t.equal(bl._bufs.length, 0)
|
|
||||||
t.equal(bl.length, 0)
|
|
||||||
})
|
|
||||||
|
|
||||||
!process.browser && tape('destroy with pipe before read end', function (t) {
|
|
||||||
t.plan(2)
|
|
||||||
|
|
||||||
var bl = new BufferList()
|
|
||||||
fs.createReadStream(__dirname + '/test.js')
|
|
||||||
.pipe(bl)
|
|
||||||
|
|
||||||
bl.destroy()
|
|
||||||
|
|
||||||
t.equal(bl._bufs.length, 0)
|
|
||||||
t.equal(bl.length, 0)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
!process.browser && tape('destroy with pipe before read end with race', function (t) {
|
|
||||||
t.plan(2)
|
|
||||||
|
|
||||||
var bl = new BufferList()
|
|
||||||
fs.createReadStream(__dirname + '/test.js')
|
|
||||||
.pipe(bl)
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
bl.destroy()
|
|
||||||
setTimeout(function () {
|
|
||||||
t.equal(bl._bufs.length, 0)
|
|
||||||
t.equal(bl.length, 0)
|
|
||||||
}, 500)
|
|
||||||
}, 500)
|
|
||||||
})
|
|
||||||
|
|
||||||
!process.browser && tape('destroy with pipe after read end', function (t) {
|
|
||||||
t.plan(2)
|
|
||||||
|
|
||||||
var bl = new BufferList()
|
|
||||||
fs.createReadStream(__dirname + '/test.js')
|
|
||||||
.on('end', onEnd)
|
|
||||||
.pipe(bl)
|
|
||||||
|
|
||||||
function onEnd () {
|
|
||||||
bl.destroy()
|
|
||||||
|
|
||||||
t.equal(bl._bufs.length, 0)
|
|
||||||
t.equal(bl.length, 0)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
!process.browser && tape('destroy with pipe while writing to a destination', function (t) {
|
|
||||||
t.plan(4)
|
|
||||||
|
|
||||||
var bl = new BufferList()
|
|
||||||
, ds = new BufferList()
|
|
||||||
|
|
||||||
fs.createReadStream(__dirname + '/test.js')
|
|
||||||
.on('end', onEnd)
|
|
||||||
.pipe(bl)
|
|
||||||
|
|
||||||
function onEnd () {
|
|
||||||
bl.pipe(ds)
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
bl.destroy()
|
|
||||||
|
|
||||||
t.equals(bl._bufs.length, 0)
|
|
||||||
t.equals(bl.length, 0)
|
|
||||||
|
|
||||||
ds.destroy()
|
|
||||||
|
|
||||||
t.equals(bl._bufs.length, 0)
|
|
||||||
t.equals(bl.length, 0)
|
|
||||||
|
|
||||||
}, 100)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
!process.browser && tape('handle error', function (t) {
|
|
||||||
t.plan(2)
|
|
||||||
fs.createReadStream('/does/not/exist').pipe(BufferList(function (err, data) {
|
|
||||||
t.ok(err instanceof Error, 'has error')
|
|
||||||
t.notOk(data, 'no data')
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
21
node_modules/bluebird/LICENSE
generated
vendored
21
node_modules/bluebird/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013-2018 Petka Antonov
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
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.
|
|
||||||
57
node_modules/bluebird/README.md
generated
vendored
57
node_modules/bluebird/README.md
generated
vendored
@@ -1,57 +0,0 @@
|
|||||||
<a href="http://promisesaplus.com/">
|
|
||||||
<img src="http://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo"
|
|
||||||
title="Promises/A+ 1.1 compliant" align="right" />
|
|
||||||
</a>
|
|
||||||
|
|
||||||
|
|
||||||
[](https://travis-ci.org/petkaantonov/bluebird)
|
|
||||||
[](http://petkaantonov.github.io/bluebird/coverage/debug/index.html)
|
|
||||||
|
|
||||||
**Got a question?** Join us on [stackoverflow](http://stackoverflow.com/questions/tagged/bluebird), the [mailing list](https://groups.google.com/forum/#!forum/bluebird-js) or chat on [IRC](https://webchat.freenode.net/?channels=#promises)
|
|
||||||
|
|
||||||
# Introduction
|
|
||||||
|
|
||||||
Bluebird is a fully featured promise library with focus on innovative features and performance
|
|
||||||
|
|
||||||
See the [**bluebird website**](http://bluebirdjs.com/docs/getting-started.html) for further documentation, references and instructions. See the [**API reference**](http://bluebirdjs.com/docs/api-reference.html) here.
|
|
||||||
|
|
||||||
For bluebird 2.x documentation and files, see the [2.x tree](https://github.com/petkaantonov/bluebird/tree/2.x).
|
|
||||||
|
|
||||||
### Note
|
|
||||||
|
|
||||||
Promises in Node.js 10 are significantly faster than before. Bluebird still includes a lot of features like cancellation, iteration methods and warnings that native promises don't. If you are using Bluebird for performance rather than for those - please consider giving native promises a shot and running the benchmarks yourself.
|
|
||||||
|
|
||||||
# Questions and issues
|
|
||||||
|
|
||||||
The [github issue tracker](https://github.com/petkaantonov/bluebird/issues) is **_only_** for bug reports and feature requests. Anything else, such as questions for help in using the library, should be posted in [StackOverflow](http://stackoverflow.com/questions/tagged/bluebird) under tags `promise` and `bluebird`.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Thanks
|
|
||||||
|
|
||||||
Thanks to BrowserStack for providing us with a free account which lets us support old browsers like IE8.
|
|
||||||
|
|
||||||
# License
|
|
||||||
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013-2019 Petka Antonov
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
1
node_modules/bluebird/changelog.md
generated
vendored
1
node_modules/bluebird/changelog.md
generated
vendored
@@ -1 +0,0 @@
|
|||||||
[http://bluebirdjs.com/docs/changelog.html](http://bluebirdjs.com/docs/changelog.html)
|
|
||||||
3914
node_modules/bluebird/js/browser/bluebird.core.js
generated
vendored
3914
node_modules/bluebird/js/browser/bluebird.core.js
generated
vendored
File diff suppressed because it is too large
Load Diff
31
node_modules/bluebird/js/browser/bluebird.core.min.js
generated
vendored
31
node_modules/bluebird/js/browser/bluebird.core.min.js
generated
vendored
File diff suppressed because one or more lines are too long
5778
node_modules/bluebird/js/browser/bluebird.js
generated
vendored
5778
node_modules/bluebird/js/browser/bluebird.js
generated
vendored
File diff suppressed because it is too large
Load Diff
31
node_modules/bluebird/js/browser/bluebird.min.js
generated
vendored
31
node_modules/bluebird/js/browser/bluebird.min.js
generated
vendored
File diff suppressed because one or more lines are too long
21
node_modules/bluebird/js/release/any.js
generated
vendored
21
node_modules/bluebird/js/release/any.js
generated
vendored
@@ -1,21 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise) {
|
|
||||||
var SomePromiseArray = Promise._SomePromiseArray;
|
|
||||||
function any(promises) {
|
|
||||||
var ret = new SomePromiseArray(promises);
|
|
||||||
var promise = ret.promise();
|
|
||||||
ret.setHowMany(1);
|
|
||||||
ret.setUnwrap();
|
|
||||||
ret.init();
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.any = function (promises) {
|
|
||||||
return any(promises);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.any = function () {
|
|
||||||
return any(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
55
node_modules/bluebird/js/release/assert.js
generated
vendored
55
node_modules/bluebird/js/release/assert.js
generated
vendored
@@ -1,55 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = (function(){
|
|
||||||
var AssertionError = (function() {
|
|
||||||
function AssertionError(a) {
|
|
||||||
this.constructor$(a);
|
|
||||||
this.message = a;
|
|
||||||
this.name = "AssertionError";
|
|
||||||
}
|
|
||||||
AssertionError.prototype = new Error();
|
|
||||||
AssertionError.prototype.constructor = AssertionError;
|
|
||||||
AssertionError.prototype.constructor$ = Error;
|
|
||||||
return AssertionError;
|
|
||||||
})();
|
|
||||||
|
|
||||||
function getParams(args) {
|
|
||||||
var params = [];
|
|
||||||
for (var i = 0; i < args.length; ++i) params.push("arg" + i);
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
function nativeAssert(callName, args, expect) {
|
|
||||||
try {
|
|
||||||
var params = getParams(args);
|
|
||||||
var constructorArgs = params;
|
|
||||||
constructorArgs.push("return " +
|
|
||||||
callName + "("+ params.join(",") + ");");
|
|
||||||
var fn = Function.apply(null, constructorArgs);
|
|
||||||
return fn.apply(null, args);
|
|
||||||
} catch (e) {
|
|
||||||
if (!(e instanceof SyntaxError)) {
|
|
||||||
throw e;
|
|
||||||
} else {
|
|
||||||
return expect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return function assert(boolExpr, message) {
|
|
||||||
if (boolExpr === true) return;
|
|
||||||
|
|
||||||
if (typeof boolExpr === "string" &&
|
|
||||||
boolExpr.charAt(0) === "%") {
|
|
||||||
var nativeCallName = boolExpr;
|
|
||||||
var $_len = arguments.length;var args = new Array(Math.max($_len - 2, 0)); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];};
|
|
||||||
if (nativeAssert(nativeCallName, args, message) === message) return;
|
|
||||||
message = (nativeCallName + " !== " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
var ret = new AssertionError(message);
|
|
||||||
if (Error.captureStackTrace) {
|
|
||||||
Error.captureStackTrace(ret, assert);
|
|
||||||
}
|
|
||||||
throw ret;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
120
node_modules/bluebird/js/release/async.js
generated
vendored
120
node_modules/bluebird/js/release/async.js
generated
vendored
@@ -1,120 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var firstLineError;
|
|
||||||
try {throw new Error(); } catch (e) {firstLineError = e;}
|
|
||||||
var schedule = require("./schedule");
|
|
||||||
var Queue = require("./queue");
|
|
||||||
|
|
||||||
function Async() {
|
|
||||||
this._customScheduler = false;
|
|
||||||
this._isTickUsed = false;
|
|
||||||
this._lateQueue = new Queue(16);
|
|
||||||
this._normalQueue = new Queue(16);
|
|
||||||
this._haveDrainedQueues = false;
|
|
||||||
var self = this;
|
|
||||||
this.drainQueues = function () {
|
|
||||||
self._drainQueues();
|
|
||||||
};
|
|
||||||
this._schedule = schedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
Async.prototype.setScheduler = function(fn) {
|
|
||||||
var prev = this._schedule;
|
|
||||||
this._schedule = fn;
|
|
||||||
this._customScheduler = true;
|
|
||||||
return prev;
|
|
||||||
};
|
|
||||||
|
|
||||||
Async.prototype.hasCustomScheduler = function() {
|
|
||||||
return this._customScheduler;
|
|
||||||
};
|
|
||||||
|
|
||||||
Async.prototype.haveItemsQueued = function () {
|
|
||||||
return this._isTickUsed || this._haveDrainedQueues;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Async.prototype.fatalError = function(e, isNode) {
|
|
||||||
if (isNode) {
|
|
||||||
process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e) +
|
|
||||||
"\n");
|
|
||||||
process.exit(2);
|
|
||||||
} else {
|
|
||||||
this.throwLater(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Async.prototype.throwLater = function(fn, arg) {
|
|
||||||
if (arguments.length === 1) {
|
|
||||||
arg = fn;
|
|
||||||
fn = function () { throw arg; };
|
|
||||||
}
|
|
||||||
if (typeof setTimeout !== "undefined") {
|
|
||||||
setTimeout(function() {
|
|
||||||
fn(arg);
|
|
||||||
}, 0);
|
|
||||||
} else try {
|
|
||||||
this._schedule(function() {
|
|
||||||
fn(arg);
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function AsyncInvokeLater(fn, receiver, arg) {
|
|
||||||
this._lateQueue.push(fn, receiver, arg);
|
|
||||||
this._queueTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
function AsyncInvoke(fn, receiver, arg) {
|
|
||||||
this._normalQueue.push(fn, receiver, arg);
|
|
||||||
this._queueTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
function AsyncSettlePromises(promise) {
|
|
||||||
this._normalQueue._pushOne(promise);
|
|
||||||
this._queueTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
Async.prototype.invokeLater = AsyncInvokeLater;
|
|
||||||
Async.prototype.invoke = AsyncInvoke;
|
|
||||||
Async.prototype.settlePromises = AsyncSettlePromises;
|
|
||||||
|
|
||||||
|
|
||||||
function _drainQueue(queue) {
|
|
||||||
while (queue.length() > 0) {
|
|
||||||
_drainQueueStep(queue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _drainQueueStep(queue) {
|
|
||||||
var fn = queue.shift();
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
fn._settlePromises();
|
|
||||||
} else {
|
|
||||||
var receiver = queue.shift();
|
|
||||||
var arg = queue.shift();
|
|
||||||
fn.call(receiver, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Async.prototype._drainQueues = function () {
|
|
||||||
_drainQueue(this._normalQueue);
|
|
||||||
this._reset();
|
|
||||||
this._haveDrainedQueues = true;
|
|
||||||
_drainQueue(this._lateQueue);
|
|
||||||
};
|
|
||||||
|
|
||||||
Async.prototype._queueTick = function () {
|
|
||||||
if (!this._isTickUsed) {
|
|
||||||
this._isTickUsed = true;
|
|
||||||
this._schedule(this.drainQueues);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Async.prototype._reset = function () {
|
|
||||||
this._isTickUsed = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Async;
|
|
||||||
module.exports.firstLineError = firstLineError;
|
|
||||||
67
node_modules/bluebird/js/release/bind.js
generated
vendored
67
node_modules/bluebird/js/release/bind.js
generated
vendored
@@ -1,67 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
|
|
||||||
var calledBind = false;
|
|
||||||
var rejectThis = function(_, e) {
|
|
||||||
this._reject(e);
|
|
||||||
};
|
|
||||||
|
|
||||||
var targetRejected = function(e, context) {
|
|
||||||
context.promiseRejectionQueued = true;
|
|
||||||
context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
|
|
||||||
};
|
|
||||||
|
|
||||||
var bindingResolved = function(thisArg, context) {
|
|
||||||
if (((this._bitField & 50397184) === 0)) {
|
|
||||||
this._resolveCallback(context.target);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var bindingRejected = function(e, context) {
|
|
||||||
if (!context.promiseRejectionQueued) this._reject(e);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.bind = function (thisArg) {
|
|
||||||
if (!calledBind) {
|
|
||||||
calledBind = true;
|
|
||||||
Promise.prototype._propagateFrom = debug.propagateFromFunction();
|
|
||||||
Promise.prototype._boundValue = debug.boundValueFunction();
|
|
||||||
}
|
|
||||||
var maybePromise = tryConvertToPromise(thisArg);
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
ret._propagateFrom(this, 1);
|
|
||||||
var target = this._target();
|
|
||||||
ret._setBoundTo(maybePromise);
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
var context = {
|
|
||||||
promiseRejectionQueued: false,
|
|
||||||
promise: ret,
|
|
||||||
target: target,
|
|
||||||
bindingPromise: maybePromise
|
|
||||||
};
|
|
||||||
target._then(INTERNAL, targetRejected, undefined, ret, context);
|
|
||||||
maybePromise._then(
|
|
||||||
bindingResolved, bindingRejected, undefined, ret, context);
|
|
||||||
ret._setOnCancel(maybePromise);
|
|
||||||
} else {
|
|
||||||
ret._resolveCallback(target);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setBoundTo = function (obj) {
|
|
||||||
if (obj !== undefined) {
|
|
||||||
this._bitField = this._bitField | 2097152;
|
|
||||||
this._boundTo = obj;
|
|
||||||
} else {
|
|
||||||
this._bitField = this._bitField & (~2097152);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._isBound = function () {
|
|
||||||
return (this._bitField & 2097152) === 2097152;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.bind = function (thisArg, value) {
|
|
||||||
return Promise.resolve(value).bind(thisArg);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
11
node_modules/bluebird/js/release/bluebird.js
generated
vendored
11
node_modules/bluebird/js/release/bluebird.js
generated
vendored
@@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var old;
|
|
||||||
if (typeof Promise !== "undefined") old = Promise;
|
|
||||||
function noConflict() {
|
|
||||||
try { if (Promise === bluebird) Promise = old; }
|
|
||||||
catch (e) {}
|
|
||||||
return bluebird;
|
|
||||||
}
|
|
||||||
var bluebird = require("./promise")();
|
|
||||||
bluebird.noConflict = noConflict;
|
|
||||||
module.exports = bluebird;
|
|
||||||
123
node_modules/bluebird/js/release/call_get.js
generated
vendored
123
node_modules/bluebird/js/release/call_get.js
generated
vendored
@@ -1,123 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var cr = Object.create;
|
|
||||||
if (cr) {
|
|
||||||
var callerCache = cr(null);
|
|
||||||
var getterCache = cr(null);
|
|
||||||
callerCache[" size"] = getterCache[" size"] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = function(Promise) {
|
|
||||||
var util = require("./util");
|
|
||||||
var canEvaluate = util.canEvaluate;
|
|
||||||
var isIdentifier = util.isIdentifier;
|
|
||||||
|
|
||||||
var getMethodCaller;
|
|
||||||
var getGetter;
|
|
||||||
if (!false) {
|
|
||||||
var makeMethodCaller = function (methodName) {
|
|
||||||
return new Function("ensureMethod", " \n\
|
|
||||||
return function(obj) { \n\
|
|
||||||
'use strict' \n\
|
|
||||||
var len = this.length; \n\
|
|
||||||
ensureMethod(obj, 'methodName'); \n\
|
|
||||||
switch(len) { \n\
|
|
||||||
case 1: return obj.methodName(this[0]); \n\
|
|
||||||
case 2: return obj.methodName(this[0], this[1]); \n\
|
|
||||||
case 3: return obj.methodName(this[0], this[1], this[2]); \n\
|
|
||||||
case 0: return obj.methodName(); \n\
|
|
||||||
default: \n\
|
|
||||||
return obj.methodName.apply(obj, this); \n\
|
|
||||||
} \n\
|
|
||||||
}; \n\
|
|
||||||
".replace(/methodName/g, methodName))(ensureMethod);
|
|
||||||
};
|
|
||||||
|
|
||||||
var makeGetter = function (propertyName) {
|
|
||||||
return new Function("obj", " \n\
|
|
||||||
'use strict'; \n\
|
|
||||||
return obj.propertyName; \n\
|
|
||||||
".replace("propertyName", propertyName));
|
|
||||||
};
|
|
||||||
|
|
||||||
var getCompiled = function(name, compiler, cache) {
|
|
||||||
var ret = cache[name];
|
|
||||||
if (typeof ret !== "function") {
|
|
||||||
if (!isIdentifier(name)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ret = compiler(name);
|
|
||||||
cache[name] = ret;
|
|
||||||
cache[" size"]++;
|
|
||||||
if (cache[" size"] > 512) {
|
|
||||||
var keys = Object.keys(cache);
|
|
||||||
for (var i = 0; i < 256; ++i) delete cache[keys[i]];
|
|
||||||
cache[" size"] = keys.length - 256;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
getMethodCaller = function(name) {
|
|
||||||
return getCompiled(name, makeMethodCaller, callerCache);
|
|
||||||
};
|
|
||||||
|
|
||||||
getGetter = function(name) {
|
|
||||||
return getCompiled(name, makeGetter, getterCache);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function ensureMethod(obj, methodName) {
|
|
||||||
var fn;
|
|
||||||
if (obj != null) fn = obj[methodName];
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
var message = "Object " + util.classString(obj) + " has no method '" +
|
|
||||||
util.toString(methodName) + "'";
|
|
||||||
throw new Promise.TypeError(message);
|
|
||||||
}
|
|
||||||
return fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
function caller(obj) {
|
|
||||||
var methodName = this.pop();
|
|
||||||
var fn = ensureMethod(obj, methodName);
|
|
||||||
return fn.apply(obj, this);
|
|
||||||
}
|
|
||||||
Promise.prototype.call = function (methodName) {
|
|
||||||
var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
|
|
||||||
if (!false) {
|
|
||||||
if (canEvaluate) {
|
|
||||||
var maybeCaller = getMethodCaller(methodName);
|
|
||||||
if (maybeCaller !== null) {
|
|
||||||
return this._then(
|
|
||||||
maybeCaller, undefined, undefined, args, undefined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
args.push(methodName);
|
|
||||||
return this._then(caller, undefined, undefined, args, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
function namedGetter(obj) {
|
|
||||||
return obj[this];
|
|
||||||
}
|
|
||||||
function indexedGetter(obj) {
|
|
||||||
var index = +this;
|
|
||||||
if (index < 0) index = Math.max(0, index + obj.length);
|
|
||||||
return obj[index];
|
|
||||||
}
|
|
||||||
Promise.prototype.get = function (propertyName) {
|
|
||||||
var isIndex = (typeof propertyName === "number");
|
|
||||||
var getter;
|
|
||||||
if (!isIndex) {
|
|
||||||
if (canEvaluate) {
|
|
||||||
var maybeGetter = getGetter(propertyName);
|
|
||||||
getter = maybeGetter !== null ? maybeGetter : namedGetter;
|
|
||||||
} else {
|
|
||||||
getter = namedGetter;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
getter = indexedGetter;
|
|
||||||
}
|
|
||||||
return this._then(getter, undefined, undefined, propertyName, undefined);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
129
node_modules/bluebird/js/release/cancel.js
generated
vendored
129
node_modules/bluebird/js/release/cancel.js
generated
vendored
@@ -1,129 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, PromiseArray, apiRejection, debug) {
|
|
||||||
var util = require("./util");
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
var async = Promise._async;
|
|
||||||
|
|
||||||
Promise.prototype["break"] = Promise.prototype.cancel = function() {
|
|
||||||
if (!debug.cancellation()) return this._warn("cancellation is disabled");
|
|
||||||
|
|
||||||
var promise = this;
|
|
||||||
var child = promise;
|
|
||||||
while (promise._isCancellable()) {
|
|
||||||
if (!promise._cancelBy(child)) {
|
|
||||||
if (child._isFollowing()) {
|
|
||||||
child._followee().cancel();
|
|
||||||
} else {
|
|
||||||
child._cancelBranched();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var parent = promise._cancellationParent;
|
|
||||||
if (parent == null || !parent._isCancellable()) {
|
|
||||||
if (promise._isFollowing()) {
|
|
||||||
promise._followee().cancel();
|
|
||||||
} else {
|
|
||||||
promise._cancelBranched();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (promise._isFollowing()) promise._followee().cancel();
|
|
||||||
promise._setWillBeCancelled();
|
|
||||||
child = promise;
|
|
||||||
promise = parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._branchHasCancelled = function() {
|
|
||||||
this._branchesRemainingToCancel--;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._enoughBranchesHaveCancelled = function() {
|
|
||||||
return this._branchesRemainingToCancel === undefined ||
|
|
||||||
this._branchesRemainingToCancel <= 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._cancelBy = function(canceller) {
|
|
||||||
if (canceller === this) {
|
|
||||||
this._branchesRemainingToCancel = 0;
|
|
||||||
this._invokeOnCancel();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
this._branchHasCancelled();
|
|
||||||
if (this._enoughBranchesHaveCancelled()) {
|
|
||||||
this._invokeOnCancel();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._cancelBranched = function() {
|
|
||||||
if (this._enoughBranchesHaveCancelled()) {
|
|
||||||
this._cancel();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._cancel = function() {
|
|
||||||
if (!this._isCancellable()) return;
|
|
||||||
this._setCancelled();
|
|
||||||
async.invoke(this._cancelPromises, this, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._cancelPromises = function() {
|
|
||||||
if (this._length() > 0) this._settlePromises();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._unsetOnCancel = function() {
|
|
||||||
this._onCancelField = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._isCancellable = function() {
|
|
||||||
return this.isPending() && !this._isCancelled();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.isCancellable = function() {
|
|
||||||
return this.isPending() && !this.isCancelled();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) {
|
|
||||||
if (util.isArray(onCancelCallback)) {
|
|
||||||
for (var i = 0; i < onCancelCallback.length; ++i) {
|
|
||||||
this._doInvokeOnCancel(onCancelCallback[i], internalOnly);
|
|
||||||
}
|
|
||||||
} else if (onCancelCallback !== undefined) {
|
|
||||||
if (typeof onCancelCallback === "function") {
|
|
||||||
if (!internalOnly) {
|
|
||||||
var e = tryCatch(onCancelCallback).call(this._boundValue());
|
|
||||||
if (e === errorObj) {
|
|
||||||
this._attachExtraTrace(e.e);
|
|
||||||
async.throwLater(e.e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
onCancelCallback._resultCancelled(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._invokeOnCancel = function() {
|
|
||||||
var onCancelCallback = this._onCancel();
|
|
||||||
this._unsetOnCancel();
|
|
||||||
async.invoke(this._doInvokeOnCancel, this, onCancelCallback);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._invokeInternalOnCancel = function() {
|
|
||||||
if (this._isCancellable()) {
|
|
||||||
this._doInvokeOnCancel(this._onCancel(), true);
|
|
||||||
this._unsetOnCancel();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._resultCancelled = function() {
|
|
||||||
this.cancel();
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
42
node_modules/bluebird/js/release/catch_filter.js
generated
vendored
42
node_modules/bluebird/js/release/catch_filter.js
generated
vendored
@@ -1,42 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(NEXT_FILTER) {
|
|
||||||
var util = require("./util");
|
|
||||||
var getKeys = require("./es5").keys;
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
|
|
||||||
function catchFilter(instances, cb, promise) {
|
|
||||||
return function(e) {
|
|
||||||
var boundTo = promise._boundValue();
|
|
||||||
predicateLoop: for (var i = 0; i < instances.length; ++i) {
|
|
||||||
var item = instances[i];
|
|
||||||
|
|
||||||
if (item === Error ||
|
|
||||||
(item != null && item.prototype instanceof Error)) {
|
|
||||||
if (e instanceof item) {
|
|
||||||
return tryCatch(cb).call(boundTo, e);
|
|
||||||
}
|
|
||||||
} else if (typeof item === "function") {
|
|
||||||
var matchesPredicate = tryCatch(item).call(boundTo, e);
|
|
||||||
if (matchesPredicate === errorObj) {
|
|
||||||
return matchesPredicate;
|
|
||||||
} else if (matchesPredicate) {
|
|
||||||
return tryCatch(cb).call(boundTo, e);
|
|
||||||
}
|
|
||||||
} else if (util.isObject(e)) {
|
|
||||||
var keys = getKeys(item);
|
|
||||||
for (var j = 0; j < keys.length; ++j) {
|
|
||||||
var key = keys[j];
|
|
||||||
if (item[key] != e[key]) {
|
|
||||||
continue predicateLoop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tryCatch(cb).call(boundTo, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NEXT_FILTER;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return catchFilter;
|
|
||||||
};
|
|
||||||
69
node_modules/bluebird/js/release/context.js
generated
vendored
69
node_modules/bluebird/js/release/context.js
generated
vendored
@@ -1,69 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise) {
|
|
||||||
var longStackTraces = false;
|
|
||||||
var contextStack = [];
|
|
||||||
|
|
||||||
Promise.prototype._promiseCreated = function() {};
|
|
||||||
Promise.prototype._pushContext = function() {};
|
|
||||||
Promise.prototype._popContext = function() {return null;};
|
|
||||||
Promise._peekContext = Promise.prototype._peekContext = function() {};
|
|
||||||
|
|
||||||
function Context() {
|
|
||||||
this._trace = new Context.CapturedTrace(peekContext());
|
|
||||||
}
|
|
||||||
Context.prototype._pushContext = function () {
|
|
||||||
if (this._trace !== undefined) {
|
|
||||||
this._trace._promiseCreated = null;
|
|
||||||
contextStack.push(this._trace);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Context.prototype._popContext = function () {
|
|
||||||
if (this._trace !== undefined) {
|
|
||||||
var trace = contextStack.pop();
|
|
||||||
var ret = trace._promiseCreated;
|
|
||||||
trace._promiseCreated = null;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
function createContext() {
|
|
||||||
if (longStackTraces) return new Context();
|
|
||||||
}
|
|
||||||
|
|
||||||
function peekContext() {
|
|
||||||
var lastIndex = contextStack.length - 1;
|
|
||||||
if (lastIndex >= 0) {
|
|
||||||
return contextStack[lastIndex];
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
Context.CapturedTrace = null;
|
|
||||||
Context.create = createContext;
|
|
||||||
Context.deactivateLongStackTraces = function() {};
|
|
||||||
Context.activateLongStackTraces = function() {
|
|
||||||
var Promise_pushContext = Promise.prototype._pushContext;
|
|
||||||
var Promise_popContext = Promise.prototype._popContext;
|
|
||||||
var Promise_PeekContext = Promise._peekContext;
|
|
||||||
var Promise_peekContext = Promise.prototype._peekContext;
|
|
||||||
var Promise_promiseCreated = Promise.prototype._promiseCreated;
|
|
||||||
Context.deactivateLongStackTraces = function() {
|
|
||||||
Promise.prototype._pushContext = Promise_pushContext;
|
|
||||||
Promise.prototype._popContext = Promise_popContext;
|
|
||||||
Promise._peekContext = Promise_PeekContext;
|
|
||||||
Promise.prototype._peekContext = Promise_peekContext;
|
|
||||||
Promise.prototype._promiseCreated = Promise_promiseCreated;
|
|
||||||
longStackTraces = false;
|
|
||||||
};
|
|
||||||
longStackTraces = true;
|
|
||||||
Promise.prototype._pushContext = Context.prototype._pushContext;
|
|
||||||
Promise.prototype._popContext = Context.prototype._popContext;
|
|
||||||
Promise._peekContext = Promise.prototype._peekContext = peekContext;
|
|
||||||
Promise.prototype._promiseCreated = function() {
|
|
||||||
var ctx = this._peekContext();
|
|
||||||
if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
return Context;
|
|
||||||
};
|
|
||||||
1009
node_modules/bluebird/js/release/debuggability.js
generated
vendored
1009
node_modules/bluebird/js/release/debuggability.js
generated
vendored
File diff suppressed because it is too large
Load Diff
46
node_modules/bluebird/js/release/direct_resolve.js
generated
vendored
46
node_modules/bluebird/js/release/direct_resolve.js
generated
vendored
@@ -1,46 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise) {
|
|
||||||
function returner() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
function thrower() {
|
|
||||||
throw this.reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype["return"] =
|
|
||||||
Promise.prototype.thenReturn = function (value) {
|
|
||||||
if (value instanceof Promise) value.suppressUnhandledRejections();
|
|
||||||
return this._then(
|
|
||||||
returner, undefined, undefined, {value: value}, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype["throw"] =
|
|
||||||
Promise.prototype.thenThrow = function (reason) {
|
|
||||||
return this._then(
|
|
||||||
thrower, undefined, undefined, {reason: reason}, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.catchThrow = function (reason) {
|
|
||||||
if (arguments.length <= 1) {
|
|
||||||
return this._then(
|
|
||||||
undefined, thrower, undefined, {reason: reason}, undefined);
|
|
||||||
} else {
|
|
||||||
var _reason = arguments[1];
|
|
||||||
var handler = function() {throw _reason;};
|
|
||||||
return this.caught(reason, handler);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.catchReturn = function (value) {
|
|
||||||
if (arguments.length <= 1) {
|
|
||||||
if (value instanceof Promise) value.suppressUnhandledRejections();
|
|
||||||
return this._then(
|
|
||||||
undefined, returner, undefined, {value: value}, undefined);
|
|
||||||
} else {
|
|
||||||
var _value = arguments[1];
|
|
||||||
if (_value instanceof Promise) _value.suppressUnhandledRejections();
|
|
||||||
var handler = function() {return _value;};
|
|
||||||
return this.caught(value, handler);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
30
node_modules/bluebird/js/release/each.js
generated
vendored
30
node_modules/bluebird/js/release/each.js
generated
vendored
@@ -1,30 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, INTERNAL) {
|
|
||||||
var PromiseReduce = Promise.reduce;
|
|
||||||
var PromiseAll = Promise.all;
|
|
||||||
|
|
||||||
function promiseAllThis() {
|
|
||||||
return PromiseAll(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
function PromiseMapSeries(promises, fn) {
|
|
||||||
return PromiseReduce(promises, fn, INTERNAL, INTERNAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype.each = function (fn) {
|
|
||||||
return PromiseReduce(this, fn, INTERNAL, 0)
|
|
||||||
._then(promiseAllThis, undefined, undefined, this, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.mapSeries = function (fn) {
|
|
||||||
return PromiseReduce(this, fn, INTERNAL, INTERNAL);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.each = function (promises, fn) {
|
|
||||||
return PromiseReduce(promises, fn, INTERNAL, 0)
|
|
||||||
._then(promiseAllThis, undefined, undefined, promises, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.mapSeries = PromiseMapSeries;
|
|
||||||
};
|
|
||||||
|
|
||||||
116
node_modules/bluebird/js/release/errors.js
generated
vendored
116
node_modules/bluebird/js/release/errors.js
generated
vendored
@@ -1,116 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var es5 = require("./es5");
|
|
||||||
var Objectfreeze = es5.freeze;
|
|
||||||
var util = require("./util");
|
|
||||||
var inherits = util.inherits;
|
|
||||||
var notEnumerableProp = util.notEnumerableProp;
|
|
||||||
|
|
||||||
function subError(nameProperty, defaultMessage) {
|
|
||||||
function SubError(message) {
|
|
||||||
if (!(this instanceof SubError)) return new SubError(message);
|
|
||||||
notEnumerableProp(this, "message",
|
|
||||||
typeof message === "string" ? message : defaultMessage);
|
|
||||||
notEnumerableProp(this, "name", nameProperty);
|
|
||||||
if (Error.captureStackTrace) {
|
|
||||||
Error.captureStackTrace(this, this.constructor);
|
|
||||||
} else {
|
|
||||||
Error.call(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inherits(SubError, Error);
|
|
||||||
return SubError;
|
|
||||||
}
|
|
||||||
|
|
||||||
var _TypeError, _RangeError;
|
|
||||||
var Warning = subError("Warning", "warning");
|
|
||||||
var CancellationError = subError("CancellationError", "cancellation error");
|
|
||||||
var TimeoutError = subError("TimeoutError", "timeout error");
|
|
||||||
var AggregateError = subError("AggregateError", "aggregate error");
|
|
||||||
try {
|
|
||||||
_TypeError = TypeError;
|
|
||||||
_RangeError = RangeError;
|
|
||||||
} catch(e) {
|
|
||||||
_TypeError = subError("TypeError", "type error");
|
|
||||||
_RangeError = subError("RangeError", "range error");
|
|
||||||
}
|
|
||||||
|
|
||||||
var methods = ("join pop push shift unshift slice filter forEach some " +
|
|
||||||
"every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
|
|
||||||
|
|
||||||
for (var i = 0; i < methods.length; ++i) {
|
|
||||||
if (typeof Array.prototype[methods[i]] === "function") {
|
|
||||||
AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
es5.defineProperty(AggregateError.prototype, "length", {
|
|
||||||
value: 0,
|
|
||||||
configurable: false,
|
|
||||||
writable: true,
|
|
||||||
enumerable: true
|
|
||||||
});
|
|
||||||
AggregateError.prototype["isOperational"] = true;
|
|
||||||
var level = 0;
|
|
||||||
AggregateError.prototype.toString = function() {
|
|
||||||
var indent = Array(level * 4 + 1).join(" ");
|
|
||||||
var ret = "\n" + indent + "AggregateError of:" + "\n";
|
|
||||||
level++;
|
|
||||||
indent = Array(level * 4 + 1).join(" ");
|
|
||||||
for (var i = 0; i < this.length; ++i) {
|
|
||||||
var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
|
|
||||||
var lines = str.split("\n");
|
|
||||||
for (var j = 0; j < lines.length; ++j) {
|
|
||||||
lines[j] = indent + lines[j];
|
|
||||||
}
|
|
||||||
str = lines.join("\n");
|
|
||||||
ret += str + "\n";
|
|
||||||
}
|
|
||||||
level--;
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
function OperationalError(message) {
|
|
||||||
if (!(this instanceof OperationalError))
|
|
||||||
return new OperationalError(message);
|
|
||||||
notEnumerableProp(this, "name", "OperationalError");
|
|
||||||
notEnumerableProp(this, "message", message);
|
|
||||||
this.cause = message;
|
|
||||||
this["isOperational"] = true;
|
|
||||||
|
|
||||||
if (message instanceof Error) {
|
|
||||||
notEnumerableProp(this, "message", message.message);
|
|
||||||
notEnumerableProp(this, "stack", message.stack);
|
|
||||||
} else if (Error.captureStackTrace) {
|
|
||||||
Error.captureStackTrace(this, this.constructor);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
inherits(OperationalError, Error);
|
|
||||||
|
|
||||||
var errorTypes = Error["__BluebirdErrorTypes__"];
|
|
||||||
if (!errorTypes) {
|
|
||||||
errorTypes = Objectfreeze({
|
|
||||||
CancellationError: CancellationError,
|
|
||||||
TimeoutError: TimeoutError,
|
|
||||||
OperationalError: OperationalError,
|
|
||||||
RejectionError: OperationalError,
|
|
||||||
AggregateError: AggregateError
|
|
||||||
});
|
|
||||||
es5.defineProperty(Error, "__BluebirdErrorTypes__", {
|
|
||||||
value: errorTypes,
|
|
||||||
writable: false,
|
|
||||||
enumerable: false,
|
|
||||||
configurable: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
Error: Error,
|
|
||||||
TypeError: _TypeError,
|
|
||||||
RangeError: _RangeError,
|
|
||||||
CancellationError: errorTypes.CancellationError,
|
|
||||||
OperationalError: errorTypes.OperationalError,
|
|
||||||
TimeoutError: errorTypes.TimeoutError,
|
|
||||||
AggregateError: errorTypes.AggregateError,
|
|
||||||
Warning: Warning
|
|
||||||
};
|
|
||||||
80
node_modules/bluebird/js/release/es5.js
generated
vendored
80
node_modules/bluebird/js/release/es5.js
generated
vendored
@@ -1,80 +0,0 @@
|
|||||||
var isES5 = (function(){
|
|
||||||
"use strict";
|
|
||||||
return this === undefined;
|
|
||||||
})();
|
|
||||||
|
|
||||||
if (isES5) {
|
|
||||||
module.exports = {
|
|
||||||
freeze: Object.freeze,
|
|
||||||
defineProperty: Object.defineProperty,
|
|
||||||
getDescriptor: Object.getOwnPropertyDescriptor,
|
|
||||||
keys: Object.keys,
|
|
||||||
names: Object.getOwnPropertyNames,
|
|
||||||
getPrototypeOf: Object.getPrototypeOf,
|
|
||||||
isArray: Array.isArray,
|
|
||||||
isES5: isES5,
|
|
||||||
propertyIsWritable: function(obj, prop) {
|
|
||||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
||||||
return !!(!descriptor || descriptor.writable || descriptor.set);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
var has = {}.hasOwnProperty;
|
|
||||||
var str = {}.toString;
|
|
||||||
var proto = {}.constructor.prototype;
|
|
||||||
|
|
||||||
var ObjectKeys = function (o) {
|
|
||||||
var ret = [];
|
|
||||||
for (var key in o) {
|
|
||||||
if (has.call(o, key)) {
|
|
||||||
ret.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
var ObjectGetDescriptor = function(o, key) {
|
|
||||||
return {value: o[key]};
|
|
||||||
};
|
|
||||||
|
|
||||||
var ObjectDefineProperty = function (o, key, desc) {
|
|
||||||
o[key] = desc.value;
|
|
||||||
return o;
|
|
||||||
};
|
|
||||||
|
|
||||||
var ObjectFreeze = function (obj) {
|
|
||||||
return obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
var ObjectGetPrototypeOf = function (obj) {
|
|
||||||
try {
|
|
||||||
return Object(obj).constructor.prototype;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return proto;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var ArrayIsArray = function (obj) {
|
|
||||||
try {
|
|
||||||
return str.call(obj) === "[object Array]";
|
|
||||||
}
|
|
||||||
catch(e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
isArray: ArrayIsArray,
|
|
||||||
keys: ObjectKeys,
|
|
||||||
names: ObjectKeys,
|
|
||||||
defineProperty: ObjectDefineProperty,
|
|
||||||
getDescriptor: ObjectGetDescriptor,
|
|
||||||
freeze: ObjectFreeze,
|
|
||||||
getPrototypeOf: ObjectGetPrototypeOf,
|
|
||||||
isES5: isES5,
|
|
||||||
propertyIsWritable: function() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
12
node_modules/bluebird/js/release/filter.js
generated
vendored
12
node_modules/bluebird/js/release/filter.js
generated
vendored
@@ -1,12 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, INTERNAL) {
|
|
||||||
var PromiseMap = Promise.map;
|
|
||||||
|
|
||||||
Promise.prototype.filter = function (fn, options) {
|
|
||||||
return PromiseMap(this, fn, options, INTERNAL);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.filter = function (promises, fn, options) {
|
|
||||||
return PromiseMap(promises, fn, options, INTERNAL);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
146
node_modules/bluebird/js/release/finally.js
generated
vendored
146
node_modules/bluebird/js/release/finally.js
generated
vendored
@@ -1,146 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, tryConvertToPromise, NEXT_FILTER) {
|
|
||||||
var util = require("./util");
|
|
||||||
var CancellationError = Promise.CancellationError;
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
var catchFilter = require("./catch_filter")(NEXT_FILTER);
|
|
||||||
|
|
||||||
function PassThroughHandlerContext(promise, type, handler) {
|
|
||||||
this.promise = promise;
|
|
||||||
this.type = type;
|
|
||||||
this.handler = handler;
|
|
||||||
this.called = false;
|
|
||||||
this.cancelPromise = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
PassThroughHandlerContext.prototype.isFinallyHandler = function() {
|
|
||||||
return this.type === 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
function FinallyHandlerCancelReaction(finallyHandler) {
|
|
||||||
this.finallyHandler = finallyHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
FinallyHandlerCancelReaction.prototype._resultCancelled = function() {
|
|
||||||
checkCancel(this.finallyHandler);
|
|
||||||
};
|
|
||||||
|
|
||||||
function checkCancel(ctx, reason) {
|
|
||||||
if (ctx.cancelPromise != null) {
|
|
||||||
if (arguments.length > 1) {
|
|
||||||
ctx.cancelPromise._reject(reason);
|
|
||||||
} else {
|
|
||||||
ctx.cancelPromise._cancel();
|
|
||||||
}
|
|
||||||
ctx.cancelPromise = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function succeed() {
|
|
||||||
return finallyHandler.call(this, this.promise._target()._settledValue());
|
|
||||||
}
|
|
||||||
function fail(reason) {
|
|
||||||
if (checkCancel(this, reason)) return;
|
|
||||||
errorObj.e = reason;
|
|
||||||
return errorObj;
|
|
||||||
}
|
|
||||||
function finallyHandler(reasonOrValue) {
|
|
||||||
var promise = this.promise;
|
|
||||||
var handler = this.handler;
|
|
||||||
|
|
||||||
if (!this.called) {
|
|
||||||
this.called = true;
|
|
||||||
var ret = this.isFinallyHandler()
|
|
||||||
? handler.call(promise._boundValue())
|
|
||||||
: handler.call(promise._boundValue(), reasonOrValue);
|
|
||||||
if (ret === NEXT_FILTER) {
|
|
||||||
return ret;
|
|
||||||
} else if (ret !== undefined) {
|
|
||||||
promise._setReturnedNonUndefined();
|
|
||||||
var maybePromise = tryConvertToPromise(ret, promise);
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
if (this.cancelPromise != null) {
|
|
||||||
if (maybePromise._isCancelled()) {
|
|
||||||
var reason =
|
|
||||||
new CancellationError("late cancellation observer");
|
|
||||||
promise._attachExtraTrace(reason);
|
|
||||||
errorObj.e = reason;
|
|
||||||
return errorObj;
|
|
||||||
} else if (maybePromise.isPending()) {
|
|
||||||
maybePromise._attachCancellationCallback(
|
|
||||||
new FinallyHandlerCancelReaction(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return maybePromise._then(
|
|
||||||
succeed, fail, undefined, this, undefined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (promise.isRejected()) {
|
|
||||||
checkCancel(this);
|
|
||||||
errorObj.e = reasonOrValue;
|
|
||||||
return errorObj;
|
|
||||||
} else {
|
|
||||||
checkCancel(this);
|
|
||||||
return reasonOrValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype._passThrough = function(handler, type, success, fail) {
|
|
||||||
if (typeof handler !== "function") return this.then();
|
|
||||||
return this._then(success,
|
|
||||||
fail,
|
|
||||||
undefined,
|
|
||||||
new PassThroughHandlerContext(this, type, handler),
|
|
||||||
undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.lastly =
|
|
||||||
Promise.prototype["finally"] = function (handler) {
|
|
||||||
return this._passThrough(handler,
|
|
||||||
0,
|
|
||||||
finallyHandler,
|
|
||||||
finallyHandler);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Promise.prototype.tap = function (handler) {
|
|
||||||
return this._passThrough(handler, 1, finallyHandler);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.tapCatch = function (handlerOrPredicate) {
|
|
||||||
var len = arguments.length;
|
|
||||||
if(len === 1) {
|
|
||||||
return this._passThrough(handlerOrPredicate,
|
|
||||||
1,
|
|
||||||
undefined,
|
|
||||||
finallyHandler);
|
|
||||||
} else {
|
|
||||||
var catchInstances = new Array(len - 1),
|
|
||||||
j = 0, i;
|
|
||||||
for (i = 0; i < len - 1; ++i) {
|
|
||||||
var item = arguments[i];
|
|
||||||
if (util.isObject(item)) {
|
|
||||||
catchInstances[j++] = item;
|
|
||||||
} else {
|
|
||||||
return Promise.reject(new TypeError(
|
|
||||||
"tapCatch statement predicate: "
|
|
||||||
+ "expecting an object but got " + util.classString(item)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catchInstances.length = j;
|
|
||||||
var handler = arguments[i];
|
|
||||||
return this._passThrough(catchFilter(catchInstances, handler, this),
|
|
||||||
1,
|
|
||||||
undefined,
|
|
||||||
finallyHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
return PassThroughHandlerContext;
|
|
||||||
};
|
|
||||||
223
node_modules/bluebird/js/release/generators.js
generated
vendored
223
node_modules/bluebird/js/release/generators.js
generated
vendored
@@ -1,223 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise,
|
|
||||||
apiRejection,
|
|
||||||
INTERNAL,
|
|
||||||
tryConvertToPromise,
|
|
||||||
Proxyable,
|
|
||||||
debug) {
|
|
||||||
var errors = require("./errors");
|
|
||||||
var TypeError = errors.TypeError;
|
|
||||||
var util = require("./util");
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
var yieldHandlers = [];
|
|
||||||
|
|
||||||
function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
|
|
||||||
for (var i = 0; i < yieldHandlers.length; ++i) {
|
|
||||||
traceParent._pushContext();
|
|
||||||
var result = tryCatch(yieldHandlers[i])(value);
|
|
||||||
traceParent._popContext();
|
|
||||||
if (result === errorObj) {
|
|
||||||
traceParent._pushContext();
|
|
||||||
var ret = Promise.reject(errorObj.e);
|
|
||||||
traceParent._popContext();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
var maybePromise = tryConvertToPromise(result, traceParent);
|
|
||||||
if (maybePromise instanceof Promise) return maybePromise;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
|
|
||||||
if (debug.cancellation()) {
|
|
||||||
var internal = new Promise(INTERNAL);
|
|
||||||
var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
|
|
||||||
this._promise = internal.lastly(function() {
|
|
||||||
return _finallyPromise;
|
|
||||||
});
|
|
||||||
internal._captureStackTrace();
|
|
||||||
internal._setOnCancel(this);
|
|
||||||
} else {
|
|
||||||
var promise = this._promise = new Promise(INTERNAL);
|
|
||||||
promise._captureStackTrace();
|
|
||||||
}
|
|
||||||
this._stack = stack;
|
|
||||||
this._generatorFunction = generatorFunction;
|
|
||||||
this._receiver = receiver;
|
|
||||||
this._generator = undefined;
|
|
||||||
this._yieldHandlers = typeof yieldHandler === "function"
|
|
||||||
? [yieldHandler].concat(yieldHandlers)
|
|
||||||
: yieldHandlers;
|
|
||||||
this._yieldedPromise = null;
|
|
||||||
this._cancellationPhase = false;
|
|
||||||
}
|
|
||||||
util.inherits(PromiseSpawn, Proxyable);
|
|
||||||
|
|
||||||
PromiseSpawn.prototype._isResolved = function() {
|
|
||||||
return this._promise === null;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseSpawn.prototype._cleanup = function() {
|
|
||||||
this._promise = this._generator = null;
|
|
||||||
if (debug.cancellation() && this._finallyPromise !== null) {
|
|
||||||
this._finallyPromise._fulfill();
|
|
||||||
this._finallyPromise = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseSpawn.prototype._promiseCancelled = function() {
|
|
||||||
if (this._isResolved()) return;
|
|
||||||
var implementsReturn = typeof this._generator["return"] !== "undefined";
|
|
||||||
|
|
||||||
var result;
|
|
||||||
if (!implementsReturn) {
|
|
||||||
var reason = new Promise.CancellationError(
|
|
||||||
"generator .return() sentinel");
|
|
||||||
Promise.coroutine.returnSentinel = reason;
|
|
||||||
this._promise._attachExtraTrace(reason);
|
|
||||||
this._promise._pushContext();
|
|
||||||
result = tryCatch(this._generator["throw"]).call(this._generator,
|
|
||||||
reason);
|
|
||||||
this._promise._popContext();
|
|
||||||
} else {
|
|
||||||
this._promise._pushContext();
|
|
||||||
result = tryCatch(this._generator["return"]).call(this._generator,
|
|
||||||
undefined);
|
|
||||||
this._promise._popContext();
|
|
||||||
}
|
|
||||||
this._cancellationPhase = true;
|
|
||||||
this._yieldedPromise = null;
|
|
||||||
this._continue(result);
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseSpawn.prototype._promiseFulfilled = function(value) {
|
|
||||||
this._yieldedPromise = null;
|
|
||||||
this._promise._pushContext();
|
|
||||||
var result = tryCatch(this._generator.next).call(this._generator, value);
|
|
||||||
this._promise._popContext();
|
|
||||||
this._continue(result);
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseSpawn.prototype._promiseRejected = function(reason) {
|
|
||||||
this._yieldedPromise = null;
|
|
||||||
this._promise._attachExtraTrace(reason);
|
|
||||||
this._promise._pushContext();
|
|
||||||
var result = tryCatch(this._generator["throw"])
|
|
||||||
.call(this._generator, reason);
|
|
||||||
this._promise._popContext();
|
|
||||||
this._continue(result);
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseSpawn.prototype._resultCancelled = function() {
|
|
||||||
if (this._yieldedPromise instanceof Promise) {
|
|
||||||
var promise = this._yieldedPromise;
|
|
||||||
this._yieldedPromise = null;
|
|
||||||
promise.cancel();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseSpawn.prototype.promise = function () {
|
|
||||||
return this._promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseSpawn.prototype._run = function () {
|
|
||||||
this._generator = this._generatorFunction.call(this._receiver);
|
|
||||||
this._receiver =
|
|
||||||
this._generatorFunction = undefined;
|
|
||||||
this._promiseFulfilled(undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseSpawn.prototype._continue = function (result) {
|
|
||||||
var promise = this._promise;
|
|
||||||
if (result === errorObj) {
|
|
||||||
this._cleanup();
|
|
||||||
if (this._cancellationPhase) {
|
|
||||||
return promise.cancel();
|
|
||||||
} else {
|
|
||||||
return promise._rejectCallback(result.e, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var value = result.value;
|
|
||||||
if (result.done === true) {
|
|
||||||
this._cleanup();
|
|
||||||
if (this._cancellationPhase) {
|
|
||||||
return promise.cancel();
|
|
||||||
} else {
|
|
||||||
return promise._resolveCallback(value);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var maybePromise = tryConvertToPromise(value, this._promise);
|
|
||||||
if (!(maybePromise instanceof Promise)) {
|
|
||||||
maybePromise =
|
|
||||||
promiseFromYieldHandler(maybePromise,
|
|
||||||
this._yieldHandlers,
|
|
||||||
this._promise);
|
|
||||||
if (maybePromise === null) {
|
|
||||||
this._promiseRejected(
|
|
||||||
new TypeError(
|
|
||||||
"A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", String(value)) +
|
|
||||||
"From coroutine:\u000a" +
|
|
||||||
this._stack.split("\n").slice(1, -7).join("\n")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maybePromise = maybePromise._target();
|
|
||||||
var bitField = maybePromise._bitField;
|
|
||||||
;
|
|
||||||
if (((bitField & 50397184) === 0)) {
|
|
||||||
this._yieldedPromise = maybePromise;
|
|
||||||
maybePromise._proxy(this, null);
|
|
||||||
} else if (((bitField & 33554432) !== 0)) {
|
|
||||||
Promise._async.invoke(
|
|
||||||
this._promiseFulfilled, this, maybePromise._value()
|
|
||||||
);
|
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
|
||||||
Promise._async.invoke(
|
|
||||||
this._promiseRejected, this, maybePromise._reason()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this._promiseCancelled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.coroutine = function (generatorFunction, options) {
|
|
||||||
if (typeof generatorFunction !== "function") {
|
|
||||||
throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
var yieldHandler = Object(options).yieldHandler;
|
|
||||||
var PromiseSpawn$ = PromiseSpawn;
|
|
||||||
var stack = new Error().stack;
|
|
||||||
return function () {
|
|
||||||
var generator = generatorFunction.apply(this, arguments);
|
|
||||||
var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
|
|
||||||
stack);
|
|
||||||
var ret = spawn.promise();
|
|
||||||
spawn._generator = generator;
|
|
||||||
spawn._promiseFulfilled(undefined);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.coroutine.addYieldHandler = function(fn) {
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
throw new TypeError("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
yieldHandlers.push(fn);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.spawn = function (generatorFunction) {
|
|
||||||
debug.deprecated("Promise.spawn()", "Promise.coroutine()");
|
|
||||||
if (typeof generatorFunction !== "function") {
|
|
||||||
return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
var spawn = new PromiseSpawn(generatorFunction, this);
|
|
||||||
var ret = spawn.promise();
|
|
||||||
spawn._run(Promise.spawn);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
165
node_modules/bluebird/js/release/join.js
generated
vendored
165
node_modules/bluebird/js/release/join.js
generated
vendored
@@ -1,165 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports =
|
|
||||||
function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async) {
|
|
||||||
var util = require("./util");
|
|
||||||
var canEvaluate = util.canEvaluate;
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
var reject;
|
|
||||||
|
|
||||||
if (!false) {
|
|
||||||
if (canEvaluate) {
|
|
||||||
var thenCallback = function(i) {
|
|
||||||
return new Function("value", "holder", " \n\
|
|
||||||
'use strict'; \n\
|
|
||||||
holder.pIndex = value; \n\
|
|
||||||
holder.checkFulfillment(this); \n\
|
|
||||||
".replace(/Index/g, i));
|
|
||||||
};
|
|
||||||
|
|
||||||
var promiseSetter = function(i) {
|
|
||||||
return new Function("promise", "holder", " \n\
|
|
||||||
'use strict'; \n\
|
|
||||||
holder.pIndex = promise; \n\
|
|
||||||
".replace(/Index/g, i));
|
|
||||||
};
|
|
||||||
|
|
||||||
var generateHolderClass = function(total) {
|
|
||||||
var props = new Array(total);
|
|
||||||
for (var i = 0; i < props.length; ++i) {
|
|
||||||
props[i] = "this.p" + (i+1);
|
|
||||||
}
|
|
||||||
var assignment = props.join(" = ") + " = null;";
|
|
||||||
var cancellationCode= "var promise;\n" + props.map(function(prop) {
|
|
||||||
return " \n\
|
|
||||||
promise = " + prop + "; \n\
|
|
||||||
if (promise instanceof Promise) { \n\
|
|
||||||
promise.cancel(); \n\
|
|
||||||
} \n\
|
|
||||||
";
|
|
||||||
}).join("\n");
|
|
||||||
var passedArguments = props.join(", ");
|
|
||||||
var name = "Holder$" + total;
|
|
||||||
|
|
||||||
|
|
||||||
var code = "return function(tryCatch, errorObj, Promise, async) { \n\
|
|
||||||
'use strict'; \n\
|
|
||||||
function [TheName](fn) { \n\
|
|
||||||
[TheProperties] \n\
|
|
||||||
this.fn = fn; \n\
|
|
||||||
this.asyncNeeded = true; \n\
|
|
||||||
this.now = 0; \n\
|
|
||||||
} \n\
|
|
||||||
\n\
|
|
||||||
[TheName].prototype._callFunction = function(promise) { \n\
|
|
||||||
promise._pushContext(); \n\
|
|
||||||
var ret = tryCatch(this.fn)([ThePassedArguments]); \n\
|
|
||||||
promise._popContext(); \n\
|
|
||||||
if (ret === errorObj) { \n\
|
|
||||||
promise._rejectCallback(ret.e, false); \n\
|
|
||||||
} else { \n\
|
|
||||||
promise._resolveCallback(ret); \n\
|
|
||||||
} \n\
|
|
||||||
}; \n\
|
|
||||||
\n\
|
|
||||||
[TheName].prototype.checkFulfillment = function(promise) { \n\
|
|
||||||
var now = ++this.now; \n\
|
|
||||||
if (now === [TheTotal]) { \n\
|
|
||||||
if (this.asyncNeeded) { \n\
|
|
||||||
async.invoke(this._callFunction, this, promise); \n\
|
|
||||||
} else { \n\
|
|
||||||
this._callFunction(promise); \n\
|
|
||||||
} \n\
|
|
||||||
\n\
|
|
||||||
} \n\
|
|
||||||
}; \n\
|
|
||||||
\n\
|
|
||||||
[TheName].prototype._resultCancelled = function() { \n\
|
|
||||||
[CancellationCode] \n\
|
|
||||||
}; \n\
|
|
||||||
\n\
|
|
||||||
return [TheName]; \n\
|
|
||||||
}(tryCatch, errorObj, Promise, async); \n\
|
|
||||||
";
|
|
||||||
|
|
||||||
code = code.replace(/\[TheName\]/g, name)
|
|
||||||
.replace(/\[TheTotal\]/g, total)
|
|
||||||
.replace(/\[ThePassedArguments\]/g, passedArguments)
|
|
||||||
.replace(/\[TheProperties\]/g, assignment)
|
|
||||||
.replace(/\[CancellationCode\]/g, cancellationCode);
|
|
||||||
|
|
||||||
return new Function("tryCatch", "errorObj", "Promise", "async", code)
|
|
||||||
(tryCatch, errorObj, Promise, async);
|
|
||||||
};
|
|
||||||
|
|
||||||
var holderClasses = [];
|
|
||||||
var thenCallbacks = [];
|
|
||||||
var promiseSetters = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < 8; ++i) {
|
|
||||||
holderClasses.push(generateHolderClass(i + 1));
|
|
||||||
thenCallbacks.push(thenCallback(i + 1));
|
|
||||||
promiseSetters.push(promiseSetter(i + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
reject = function (reason) {
|
|
||||||
this._reject(reason);
|
|
||||||
};
|
|
||||||
}}
|
|
||||||
|
|
||||||
Promise.join = function () {
|
|
||||||
var last = arguments.length - 1;
|
|
||||||
var fn;
|
|
||||||
if (last > 0 && typeof arguments[last] === "function") {
|
|
||||||
fn = arguments[last];
|
|
||||||
if (!false) {
|
|
||||||
if (last <= 8 && canEvaluate) {
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
ret._captureStackTrace();
|
|
||||||
var HolderClass = holderClasses[last - 1];
|
|
||||||
var holder = new HolderClass(fn);
|
|
||||||
var callbacks = thenCallbacks;
|
|
||||||
|
|
||||||
for (var i = 0; i < last; ++i) {
|
|
||||||
var maybePromise = tryConvertToPromise(arguments[i], ret);
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
maybePromise = maybePromise._target();
|
|
||||||
var bitField = maybePromise._bitField;
|
|
||||||
;
|
|
||||||
if (((bitField & 50397184) === 0)) {
|
|
||||||
maybePromise._then(callbacks[i], reject,
|
|
||||||
undefined, ret, holder);
|
|
||||||
promiseSetters[i](maybePromise, holder);
|
|
||||||
holder.asyncNeeded = false;
|
|
||||||
} else if (((bitField & 33554432) !== 0)) {
|
|
||||||
callbacks[i].call(ret,
|
|
||||||
maybePromise._value(), holder);
|
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
|
||||||
ret._reject(maybePromise._reason());
|
|
||||||
} else {
|
|
||||||
ret._cancel();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
callbacks[i].call(ret, maybePromise, holder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ret._isFateSealed()) {
|
|
||||||
if (holder.asyncNeeded) {
|
|
||||||
var context = Promise._getContext();
|
|
||||||
holder.fn = util.contextBind(context, holder.fn);
|
|
||||||
}
|
|
||||||
ret._setAsyncGuaranteed();
|
|
||||||
ret._setOnCancel(holder);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len ; ++$_i) {args[$_i] = arguments[$_i ];};
|
|
||||||
if (fn) args.pop();
|
|
||||||
var ret = new PromiseArray(args).promise();
|
|
||||||
return fn !== undefined ? ret.spread(fn) : ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
175
node_modules/bluebird/js/release/map.js
generated
vendored
175
node_modules/bluebird/js/release/map.js
generated
vendored
@@ -1,175 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise,
|
|
||||||
PromiseArray,
|
|
||||||
apiRejection,
|
|
||||||
tryConvertToPromise,
|
|
||||||
INTERNAL,
|
|
||||||
debug) {
|
|
||||||
var util = require("./util");
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
var async = Promise._async;
|
|
||||||
|
|
||||||
function MappingPromiseArray(promises, fn, limit, _filter) {
|
|
||||||
this.constructor$(promises);
|
|
||||||
this._promise._captureStackTrace();
|
|
||||||
var context = Promise._getContext();
|
|
||||||
this._callback = util.contextBind(context, fn);
|
|
||||||
this._preservedValues = _filter === INTERNAL
|
|
||||||
? new Array(this.length())
|
|
||||||
: null;
|
|
||||||
this._limit = limit;
|
|
||||||
this._inFlight = 0;
|
|
||||||
this._queue = [];
|
|
||||||
async.invoke(this._asyncInit, this, undefined);
|
|
||||||
if (util.isArray(promises)) {
|
|
||||||
for (var i = 0; i < promises.length; ++i) {
|
|
||||||
var maybePromise = promises[i];
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
maybePromise.suppressUnhandledRejections();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
util.inherits(MappingPromiseArray, PromiseArray);
|
|
||||||
|
|
||||||
MappingPromiseArray.prototype._asyncInit = function() {
|
|
||||||
this._init$(undefined, -2);
|
|
||||||
};
|
|
||||||
|
|
||||||
MappingPromiseArray.prototype._init = function () {};
|
|
||||||
|
|
||||||
MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
|
||||||
var values = this._values;
|
|
||||||
var length = this.length();
|
|
||||||
var preservedValues = this._preservedValues;
|
|
||||||
var limit = this._limit;
|
|
||||||
|
|
||||||
if (index < 0) {
|
|
||||||
index = (index * -1) - 1;
|
|
||||||
values[index] = value;
|
|
||||||
if (limit >= 1) {
|
|
||||||
this._inFlight--;
|
|
||||||
this._drainQueue();
|
|
||||||
if (this._isResolved()) return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (limit >= 1 && this._inFlight >= limit) {
|
|
||||||
values[index] = value;
|
|
||||||
this._queue.push(index);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (preservedValues !== null) preservedValues[index] = value;
|
|
||||||
|
|
||||||
var promise = this._promise;
|
|
||||||
var callback = this._callback;
|
|
||||||
var receiver = promise._boundValue();
|
|
||||||
promise._pushContext();
|
|
||||||
var ret = tryCatch(callback).call(receiver, value, index, length);
|
|
||||||
var promiseCreated = promise._popContext();
|
|
||||||
debug.checkForgottenReturns(
|
|
||||||
ret,
|
|
||||||
promiseCreated,
|
|
||||||
preservedValues !== null ? "Promise.filter" : "Promise.map",
|
|
||||||
promise
|
|
||||||
);
|
|
||||||
if (ret === errorObj) {
|
|
||||||
this._reject(ret.e);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var maybePromise = tryConvertToPromise(ret, this._promise);
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
maybePromise = maybePromise._target();
|
|
||||||
var bitField = maybePromise._bitField;
|
|
||||||
;
|
|
||||||
if (((bitField & 50397184) === 0)) {
|
|
||||||
if (limit >= 1) this._inFlight++;
|
|
||||||
values[index] = maybePromise;
|
|
||||||
maybePromise._proxy(this, (index + 1) * -1);
|
|
||||||
return false;
|
|
||||||
} else if (((bitField & 33554432) !== 0)) {
|
|
||||||
ret = maybePromise._value();
|
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
|
||||||
this._reject(maybePromise._reason());
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
this._cancel();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
values[index] = ret;
|
|
||||||
}
|
|
||||||
var totalResolved = ++this._totalResolved;
|
|
||||||
if (totalResolved >= length) {
|
|
||||||
if (preservedValues !== null) {
|
|
||||||
this._filter(values, preservedValues);
|
|
||||||
} else {
|
|
||||||
this._resolve(values);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
MappingPromiseArray.prototype._drainQueue = function () {
|
|
||||||
var queue = this._queue;
|
|
||||||
var limit = this._limit;
|
|
||||||
var values = this._values;
|
|
||||||
while (queue.length > 0 && this._inFlight < limit) {
|
|
||||||
if (this._isResolved()) return;
|
|
||||||
var index = queue.pop();
|
|
||||||
this._promiseFulfilled(values[index], index);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
MappingPromiseArray.prototype._filter = function (booleans, values) {
|
|
||||||
var len = values.length;
|
|
||||||
var ret = new Array(len);
|
|
||||||
var j = 0;
|
|
||||||
for (var i = 0; i < len; ++i) {
|
|
||||||
if (booleans[i]) ret[j++] = values[i];
|
|
||||||
}
|
|
||||||
ret.length = j;
|
|
||||||
this._resolve(ret);
|
|
||||||
};
|
|
||||||
|
|
||||||
MappingPromiseArray.prototype.preservedValues = function () {
|
|
||||||
return this._preservedValues;
|
|
||||||
};
|
|
||||||
|
|
||||||
function map(promises, fn, options, _filter) {
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
|
|
||||||
var limit = 0;
|
|
||||||
if (options !== undefined) {
|
|
||||||
if (typeof options === "object" && options !== null) {
|
|
||||||
if (typeof options.concurrency !== "number") {
|
|
||||||
return Promise.reject(
|
|
||||||
new TypeError("'concurrency' must be a number but it is " +
|
|
||||||
util.classString(options.concurrency)));
|
|
||||||
}
|
|
||||||
limit = options.concurrency;
|
|
||||||
} else {
|
|
||||||
return Promise.reject(new TypeError(
|
|
||||||
"options argument must be an object but it is " +
|
|
||||||
util.classString(options)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
limit = typeof limit === "number" &&
|
|
||||||
isFinite(limit) && limit >= 1 ? limit : 0;
|
|
||||||
return new MappingPromiseArray(promises, fn, limit, _filter).promise();
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype.map = function (fn, options) {
|
|
||||||
return map(this, fn, options, null);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.map = function (promises, fn, options, _filter) {
|
|
||||||
return map(promises, fn, options, _filter);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
55
node_modules/bluebird/js/release/method.js
generated
vendored
55
node_modules/bluebird/js/release/method.js
generated
vendored
@@ -1,55 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports =
|
|
||||||
function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
|
|
||||||
var util = require("./util");
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
|
|
||||||
Promise.method = function (fn) {
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
return function () {
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
ret._captureStackTrace();
|
|
||||||
ret._pushContext();
|
|
||||||
var value = tryCatch(fn).apply(this, arguments);
|
|
||||||
var promiseCreated = ret._popContext();
|
|
||||||
debug.checkForgottenReturns(
|
|
||||||
value, promiseCreated, "Promise.method", ret);
|
|
||||||
ret._resolveFromSyncValue(value);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.attempt = Promise["try"] = function (fn) {
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
ret._captureStackTrace();
|
|
||||||
ret._pushContext();
|
|
||||||
var value;
|
|
||||||
if (arguments.length > 1) {
|
|
||||||
debug.deprecated("calling Promise.try with more than 1 argument");
|
|
||||||
var arg = arguments[1];
|
|
||||||
var ctx = arguments[2];
|
|
||||||
value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
|
|
||||||
: tryCatch(fn).call(ctx, arg);
|
|
||||||
} else {
|
|
||||||
value = tryCatch(fn)();
|
|
||||||
}
|
|
||||||
var promiseCreated = ret._popContext();
|
|
||||||
debug.checkForgottenReturns(
|
|
||||||
value, promiseCreated, "Promise.try", ret);
|
|
||||||
ret._resolveFromSyncValue(value);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._resolveFromSyncValue = function (value) {
|
|
||||||
if (value === util.errorObj) {
|
|
||||||
this._rejectCallback(value.e, false);
|
|
||||||
} else {
|
|
||||||
this._resolveCallback(value, true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
51
node_modules/bluebird/js/release/nodeback.js
generated
vendored
51
node_modules/bluebird/js/release/nodeback.js
generated
vendored
@@ -1,51 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var util = require("./util");
|
|
||||||
var maybeWrapAsError = util.maybeWrapAsError;
|
|
||||||
var errors = require("./errors");
|
|
||||||
var OperationalError = errors.OperationalError;
|
|
||||||
var es5 = require("./es5");
|
|
||||||
|
|
||||||
function isUntypedError(obj) {
|
|
||||||
return obj instanceof Error &&
|
|
||||||
es5.getPrototypeOf(obj) === Error.prototype;
|
|
||||||
}
|
|
||||||
|
|
||||||
var rErrorKey = /^(?:name|message|stack|cause)$/;
|
|
||||||
function wrapAsOperationalError(obj) {
|
|
||||||
var ret;
|
|
||||||
if (isUntypedError(obj)) {
|
|
||||||
ret = new OperationalError(obj);
|
|
||||||
ret.name = obj.name;
|
|
||||||
ret.message = obj.message;
|
|
||||||
ret.stack = obj.stack;
|
|
||||||
var keys = es5.keys(obj);
|
|
||||||
for (var i = 0; i < keys.length; ++i) {
|
|
||||||
var key = keys[i];
|
|
||||||
if (!rErrorKey.test(key)) {
|
|
||||||
ret[key] = obj[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
util.markAsOriginatingFromRejection(obj);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function nodebackForPromise(promise, multiArgs) {
|
|
||||||
return function(err, value) {
|
|
||||||
if (promise === null) return;
|
|
||||||
if (err) {
|
|
||||||
var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
|
|
||||||
promise._attachExtraTrace(wrapped);
|
|
||||||
promise._reject(wrapped);
|
|
||||||
} else if (!multiArgs) {
|
|
||||||
promise._fulfill(value);
|
|
||||||
} else {
|
|
||||||
var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
|
|
||||||
promise._fulfill(args);
|
|
||||||
}
|
|
||||||
promise = null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = nodebackForPromise;
|
|
||||||
58
node_modules/bluebird/js/release/nodeify.js
generated
vendored
58
node_modules/bluebird/js/release/nodeify.js
generated
vendored
@@ -1,58 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise) {
|
|
||||||
var util = require("./util");
|
|
||||||
var async = Promise._async;
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
|
|
||||||
function spreadAdapter(val, nodeback) {
|
|
||||||
var promise = this;
|
|
||||||
if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
|
|
||||||
var ret =
|
|
||||||
tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
|
|
||||||
if (ret === errorObj) {
|
|
||||||
async.throwLater(ret.e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function successAdapter(val, nodeback) {
|
|
||||||
var promise = this;
|
|
||||||
var receiver = promise._boundValue();
|
|
||||||
var ret = val === undefined
|
|
||||||
? tryCatch(nodeback).call(receiver, null)
|
|
||||||
: tryCatch(nodeback).call(receiver, null, val);
|
|
||||||
if (ret === errorObj) {
|
|
||||||
async.throwLater(ret.e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function errorAdapter(reason, nodeback) {
|
|
||||||
var promise = this;
|
|
||||||
if (!reason) {
|
|
||||||
var newReason = new Error(reason + "");
|
|
||||||
newReason.cause = reason;
|
|
||||||
reason = newReason;
|
|
||||||
}
|
|
||||||
var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
|
|
||||||
if (ret === errorObj) {
|
|
||||||
async.throwLater(ret.e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback,
|
|
||||||
options) {
|
|
||||||
if (typeof nodeback == "function") {
|
|
||||||
var adapter = successAdapter;
|
|
||||||
if (options !== undefined && Object(options).spread) {
|
|
||||||
adapter = spreadAdapter;
|
|
||||||
}
|
|
||||||
this._then(
|
|
||||||
adapter,
|
|
||||||
errorAdapter,
|
|
||||||
undefined,
|
|
||||||
this,
|
|
||||||
nodeback
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
819
node_modules/bluebird/js/release/promise.js
generated
vendored
819
node_modules/bluebird/js/release/promise.js
generated
vendored
@@ -1,819 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function() {
|
|
||||||
var makeSelfResolutionError = function () {
|
|
||||||
return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
};
|
|
||||||
var reflectHandler = function() {
|
|
||||||
return new Promise.PromiseInspection(this._target());
|
|
||||||
};
|
|
||||||
var apiRejection = function(msg) {
|
|
||||||
return Promise.reject(new TypeError(msg));
|
|
||||||
};
|
|
||||||
function Proxyable() {}
|
|
||||||
var UNDEFINED_BINDING = {};
|
|
||||||
var util = require("./util");
|
|
||||||
util.setReflectHandler(reflectHandler);
|
|
||||||
|
|
||||||
var getDomain = function() {
|
|
||||||
var domain = process.domain;
|
|
||||||
if (domain === undefined) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return domain;
|
|
||||||
};
|
|
||||||
var getContextDefault = function() {
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
var getContextDomain = function() {
|
|
||||||
return {
|
|
||||||
domain: getDomain(),
|
|
||||||
async: null
|
|
||||||
};
|
|
||||||
};
|
|
||||||
var AsyncResource = util.isNode && util.nodeSupportsAsyncResource ?
|
|
||||||
require("async_hooks").AsyncResource : null;
|
|
||||||
var getContextAsyncHooks = function() {
|
|
||||||
return {
|
|
||||||
domain: getDomain(),
|
|
||||||
async: new AsyncResource("Bluebird::Promise")
|
|
||||||
};
|
|
||||||
};
|
|
||||||
var getContext = util.isNode ? getContextDomain : getContextDefault;
|
|
||||||
util.notEnumerableProp(Promise, "_getContext", getContext);
|
|
||||||
var enableAsyncHooks = function() {
|
|
||||||
getContext = getContextAsyncHooks;
|
|
||||||
util.notEnumerableProp(Promise, "_getContext", getContextAsyncHooks);
|
|
||||||
};
|
|
||||||
var disableAsyncHooks = function() {
|
|
||||||
getContext = getContextDomain;
|
|
||||||
util.notEnumerableProp(Promise, "_getContext", getContextDomain);
|
|
||||||
};
|
|
||||||
|
|
||||||
var es5 = require("./es5");
|
|
||||||
var Async = require("./async");
|
|
||||||
var async = new Async();
|
|
||||||
es5.defineProperty(Promise, "_async", {value: async});
|
|
||||||
var errors = require("./errors");
|
|
||||||
var TypeError = Promise.TypeError = errors.TypeError;
|
|
||||||
Promise.RangeError = errors.RangeError;
|
|
||||||
var CancellationError = Promise.CancellationError = errors.CancellationError;
|
|
||||||
Promise.TimeoutError = errors.TimeoutError;
|
|
||||||
Promise.OperationalError = errors.OperationalError;
|
|
||||||
Promise.RejectionError = errors.OperationalError;
|
|
||||||
Promise.AggregateError = errors.AggregateError;
|
|
||||||
var INTERNAL = function(){};
|
|
||||||
var APPLY = {};
|
|
||||||
var NEXT_FILTER = {};
|
|
||||||
var tryConvertToPromise = require("./thenables")(Promise, INTERNAL);
|
|
||||||
var PromiseArray =
|
|
||||||
require("./promise_array")(Promise, INTERNAL,
|
|
||||||
tryConvertToPromise, apiRejection, Proxyable);
|
|
||||||
var Context = require("./context")(Promise);
|
|
||||||
/*jshint unused:false*/
|
|
||||||
var createContext = Context.create;
|
|
||||||
|
|
||||||
var debug = require("./debuggability")(Promise, Context,
|
|
||||||
enableAsyncHooks, disableAsyncHooks);
|
|
||||||
var CapturedTrace = debug.CapturedTrace;
|
|
||||||
var PassThroughHandlerContext =
|
|
||||||
require("./finally")(Promise, tryConvertToPromise, NEXT_FILTER);
|
|
||||||
var catchFilter = require("./catch_filter")(NEXT_FILTER);
|
|
||||||
var nodebackForPromise = require("./nodeback");
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
function check(self, executor) {
|
|
||||||
if (self == null || self.constructor !== Promise) {
|
|
||||||
throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
if (typeof executor !== "function") {
|
|
||||||
throw new TypeError("expecting a function but got " + util.classString(executor));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function Promise(executor) {
|
|
||||||
if (executor !== INTERNAL) {
|
|
||||||
check(this, executor);
|
|
||||||
}
|
|
||||||
this._bitField = 0;
|
|
||||||
this._fulfillmentHandler0 = undefined;
|
|
||||||
this._rejectionHandler0 = undefined;
|
|
||||||
this._promise0 = undefined;
|
|
||||||
this._receiver0 = undefined;
|
|
||||||
this._resolveFromExecutor(executor);
|
|
||||||
this._promiseCreated();
|
|
||||||
this._fireEvent("promiseCreated", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype.toString = function () {
|
|
||||||
return "[object Promise]";
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
|
|
||||||
var len = arguments.length;
|
|
||||||
if (len > 1) {
|
|
||||||
var catchInstances = new Array(len - 1),
|
|
||||||
j = 0, i;
|
|
||||||
for (i = 0; i < len - 1; ++i) {
|
|
||||||
var item = arguments[i];
|
|
||||||
if (util.isObject(item)) {
|
|
||||||
catchInstances[j++] = item;
|
|
||||||
} else {
|
|
||||||
return apiRejection("Catch statement predicate: " +
|
|
||||||
"expecting an object but got " + util.classString(item));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catchInstances.length = j;
|
|
||||||
fn = arguments[i];
|
|
||||||
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
throw new TypeError("The last argument to .catch() " +
|
|
||||||
"must be a function, got " + util.toString(fn));
|
|
||||||
}
|
|
||||||
return this.then(undefined, catchFilter(catchInstances, fn, this));
|
|
||||||
}
|
|
||||||
return this.then(undefined, fn);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.reflect = function () {
|
|
||||||
return this._then(reflectHandler,
|
|
||||||
reflectHandler, undefined, this, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.then = function (didFulfill, didReject) {
|
|
||||||
if (debug.warnings() && arguments.length > 0 &&
|
|
||||||
typeof didFulfill !== "function" &&
|
|
||||||
typeof didReject !== "function") {
|
|
||||||
var msg = ".then() only accepts functions but was passed: " +
|
|
||||||
util.classString(didFulfill);
|
|
||||||
if (arguments.length > 1) {
|
|
||||||
msg += ", " + util.classString(didReject);
|
|
||||||
}
|
|
||||||
this._warn(msg);
|
|
||||||
}
|
|
||||||
return this._then(didFulfill, didReject, undefined, undefined, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.done = function (didFulfill, didReject) {
|
|
||||||
var promise =
|
|
||||||
this._then(didFulfill, didReject, undefined, undefined, undefined);
|
|
||||||
promise._setIsFinal();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.spread = function (fn) {
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
return this.all()._then(fn, undefined, undefined, APPLY, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.toJSON = function () {
|
|
||||||
var ret = {
|
|
||||||
isFulfilled: false,
|
|
||||||
isRejected: false,
|
|
||||||
fulfillmentValue: undefined,
|
|
||||||
rejectionReason: undefined
|
|
||||||
};
|
|
||||||
if (this.isFulfilled()) {
|
|
||||||
ret.fulfillmentValue = this.value();
|
|
||||||
ret.isFulfilled = true;
|
|
||||||
} else if (this.isRejected()) {
|
|
||||||
ret.rejectionReason = this.reason();
|
|
||||||
ret.isRejected = true;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.all = function () {
|
|
||||||
if (arguments.length > 0) {
|
|
||||||
this._warn(".all() was passed arguments but it does not take any");
|
|
||||||
}
|
|
||||||
return new PromiseArray(this).promise();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.error = function (fn) {
|
|
||||||
return this.caught(util.originatesFromRejection, fn);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.getNewLibraryCopy = module.exports;
|
|
||||||
|
|
||||||
Promise.is = function (val) {
|
|
||||||
return val instanceof Promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.fromNode = Promise.fromCallback = function(fn) {
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
ret._captureStackTrace();
|
|
||||||
var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs
|
|
||||||
: false;
|
|
||||||
var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs));
|
|
||||||
if (result === errorObj) {
|
|
||||||
ret._rejectCallback(result.e, true);
|
|
||||||
}
|
|
||||||
if (!ret._isFateSealed()) ret._setAsyncGuaranteed();
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.all = function (promises) {
|
|
||||||
return new PromiseArray(promises).promise();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.cast = function (obj) {
|
|
||||||
var ret = tryConvertToPromise(obj);
|
|
||||||
if (!(ret instanceof Promise)) {
|
|
||||||
ret = new Promise(INTERNAL);
|
|
||||||
ret._captureStackTrace();
|
|
||||||
ret._setFulfilled();
|
|
||||||
ret._rejectionHandler0 = obj;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.resolve = Promise.fulfilled = Promise.cast;
|
|
||||||
|
|
||||||
Promise.reject = Promise.rejected = function (reason) {
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
ret._captureStackTrace();
|
|
||||||
ret._rejectCallback(reason, true);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.setScheduler = function(fn) {
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
throw new TypeError("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
return async.setScheduler(fn);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._then = function (
|
|
||||||
didFulfill,
|
|
||||||
didReject,
|
|
||||||
_, receiver,
|
|
||||||
internalData
|
|
||||||
) {
|
|
||||||
var haveInternalData = internalData !== undefined;
|
|
||||||
var promise = haveInternalData ? internalData : new Promise(INTERNAL);
|
|
||||||
var target = this._target();
|
|
||||||
var bitField = target._bitField;
|
|
||||||
|
|
||||||
if (!haveInternalData) {
|
|
||||||
promise._propagateFrom(this, 3);
|
|
||||||
promise._captureStackTrace();
|
|
||||||
if (receiver === undefined &&
|
|
||||||
((this._bitField & 2097152) !== 0)) {
|
|
||||||
if (!((bitField & 50397184) === 0)) {
|
|
||||||
receiver = this._boundValue();
|
|
||||||
} else {
|
|
||||||
receiver = target === this ? undefined : this._boundTo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._fireEvent("promiseChained", this, promise);
|
|
||||||
}
|
|
||||||
|
|
||||||
var context = getContext();
|
|
||||||
if (!((bitField & 50397184) === 0)) {
|
|
||||||
var handler, value, settler = target._settlePromiseCtx;
|
|
||||||
if (((bitField & 33554432) !== 0)) {
|
|
||||||
value = target._rejectionHandler0;
|
|
||||||
handler = didFulfill;
|
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
|
||||||
value = target._fulfillmentHandler0;
|
|
||||||
handler = didReject;
|
|
||||||
target._unsetRejectionIsUnhandled();
|
|
||||||
} else {
|
|
||||||
settler = target._settlePromiseLateCancellationObserver;
|
|
||||||
value = new CancellationError("late cancellation observer");
|
|
||||||
target._attachExtraTrace(value);
|
|
||||||
handler = didReject;
|
|
||||||
}
|
|
||||||
|
|
||||||
async.invoke(settler, target, {
|
|
||||||
handler: util.contextBind(context, handler),
|
|
||||||
promise: promise,
|
|
||||||
receiver: receiver,
|
|
||||||
value: value
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
target._addCallbacks(didFulfill, didReject, promise,
|
|
||||||
receiver, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
return promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._length = function () {
|
|
||||||
return this._bitField & 65535;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._isFateSealed = function () {
|
|
||||||
return (this._bitField & 117506048) !== 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._isFollowing = function () {
|
|
||||||
return (this._bitField & 67108864) === 67108864;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setLength = function (len) {
|
|
||||||
this._bitField = (this._bitField & -65536) |
|
|
||||||
(len & 65535);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setFulfilled = function () {
|
|
||||||
this._bitField = this._bitField | 33554432;
|
|
||||||
this._fireEvent("promiseFulfilled", this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setRejected = function () {
|
|
||||||
this._bitField = this._bitField | 16777216;
|
|
||||||
this._fireEvent("promiseRejected", this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setFollowing = function () {
|
|
||||||
this._bitField = this._bitField | 67108864;
|
|
||||||
this._fireEvent("promiseResolved", this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setIsFinal = function () {
|
|
||||||
this._bitField = this._bitField | 4194304;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._isFinal = function () {
|
|
||||||
return (this._bitField & 4194304) > 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._unsetCancelled = function() {
|
|
||||||
this._bitField = this._bitField & (~65536);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setCancelled = function() {
|
|
||||||
this._bitField = this._bitField | 65536;
|
|
||||||
this._fireEvent("promiseCancelled", this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setWillBeCancelled = function() {
|
|
||||||
this._bitField = this._bitField | 8388608;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setAsyncGuaranteed = function() {
|
|
||||||
if (async.hasCustomScheduler()) return;
|
|
||||||
var bitField = this._bitField;
|
|
||||||
this._bitField = bitField |
|
|
||||||
(((bitField & 536870912) >> 2) ^
|
|
||||||
134217728);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setNoAsyncGuarantee = function() {
|
|
||||||
this._bitField = (this._bitField | 536870912) &
|
|
||||||
(~134217728);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._receiverAt = function (index) {
|
|
||||||
var ret = index === 0 ? this._receiver0 : this[
|
|
||||||
index * 4 - 4 + 3];
|
|
||||||
if (ret === UNDEFINED_BINDING) {
|
|
||||||
return undefined;
|
|
||||||
} else if (ret === undefined && this._isBound()) {
|
|
||||||
return this._boundValue();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._promiseAt = function (index) {
|
|
||||||
return this[
|
|
||||||
index * 4 - 4 + 2];
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._fulfillmentHandlerAt = function (index) {
|
|
||||||
return this[
|
|
||||||
index * 4 - 4 + 0];
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._rejectionHandlerAt = function (index) {
|
|
||||||
return this[
|
|
||||||
index * 4 - 4 + 1];
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._boundValue = function() {};
|
|
||||||
|
|
||||||
Promise.prototype._migrateCallback0 = function (follower) {
|
|
||||||
var bitField = follower._bitField;
|
|
||||||
var fulfill = follower._fulfillmentHandler0;
|
|
||||||
var reject = follower._rejectionHandler0;
|
|
||||||
var promise = follower._promise0;
|
|
||||||
var receiver = follower._receiverAt(0);
|
|
||||||
if (receiver === undefined) receiver = UNDEFINED_BINDING;
|
|
||||||
this._addCallbacks(fulfill, reject, promise, receiver, null);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._migrateCallbackAt = function (follower, index) {
|
|
||||||
var fulfill = follower._fulfillmentHandlerAt(index);
|
|
||||||
var reject = follower._rejectionHandlerAt(index);
|
|
||||||
var promise = follower._promiseAt(index);
|
|
||||||
var receiver = follower._receiverAt(index);
|
|
||||||
if (receiver === undefined) receiver = UNDEFINED_BINDING;
|
|
||||||
this._addCallbacks(fulfill, reject, promise, receiver, null);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._addCallbacks = function (
|
|
||||||
fulfill,
|
|
||||||
reject,
|
|
||||||
promise,
|
|
||||||
receiver,
|
|
||||||
context
|
|
||||||
) {
|
|
||||||
var index = this._length();
|
|
||||||
|
|
||||||
if (index >= 65535 - 4) {
|
|
||||||
index = 0;
|
|
||||||
this._setLength(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index === 0) {
|
|
||||||
this._promise0 = promise;
|
|
||||||
this._receiver0 = receiver;
|
|
||||||
if (typeof fulfill === "function") {
|
|
||||||
this._fulfillmentHandler0 = util.contextBind(context, fulfill);
|
|
||||||
}
|
|
||||||
if (typeof reject === "function") {
|
|
||||||
this._rejectionHandler0 = util.contextBind(context, reject);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var base = index * 4 - 4;
|
|
||||||
this[base + 2] = promise;
|
|
||||||
this[base + 3] = receiver;
|
|
||||||
if (typeof fulfill === "function") {
|
|
||||||
this[base + 0] =
|
|
||||||
util.contextBind(context, fulfill);
|
|
||||||
}
|
|
||||||
if (typeof reject === "function") {
|
|
||||||
this[base + 1] =
|
|
||||||
util.contextBind(context, reject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._setLength(index + 1);
|
|
||||||
return index;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._proxy = function (proxyable, arg) {
|
|
||||||
this._addCallbacks(undefined, undefined, arg, proxyable, null);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._resolveCallback = function(value, shouldBind) {
|
|
||||||
if (((this._bitField & 117506048) !== 0)) return;
|
|
||||||
if (value === this)
|
|
||||||
return this._rejectCallback(makeSelfResolutionError(), false);
|
|
||||||
var maybePromise = tryConvertToPromise(value, this);
|
|
||||||
if (!(maybePromise instanceof Promise)) return this._fulfill(value);
|
|
||||||
|
|
||||||
if (shouldBind) this._propagateFrom(maybePromise, 2);
|
|
||||||
|
|
||||||
|
|
||||||
var promise = maybePromise._target();
|
|
||||||
|
|
||||||
if (promise === this) {
|
|
||||||
this._reject(makeSelfResolutionError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var bitField = promise._bitField;
|
|
||||||
if (((bitField & 50397184) === 0)) {
|
|
||||||
var len = this._length();
|
|
||||||
if (len > 0) promise._migrateCallback0(this);
|
|
||||||
for (var i = 1; i < len; ++i) {
|
|
||||||
promise._migrateCallbackAt(this, i);
|
|
||||||
}
|
|
||||||
this._setFollowing();
|
|
||||||
this._setLength(0);
|
|
||||||
this._setFollowee(maybePromise);
|
|
||||||
} else if (((bitField & 33554432) !== 0)) {
|
|
||||||
this._fulfill(promise._value());
|
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
|
||||||
this._reject(promise._reason());
|
|
||||||
} else {
|
|
||||||
var reason = new CancellationError("late cancellation observer");
|
|
||||||
promise._attachExtraTrace(reason);
|
|
||||||
this._reject(reason);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._rejectCallback =
|
|
||||||
function(reason, synchronous, ignoreNonErrorWarnings) {
|
|
||||||
var trace = util.ensureErrorObject(reason);
|
|
||||||
var hasStack = trace === reason;
|
|
||||||
if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) {
|
|
||||||
var message = "a promise was rejected with a non-error: " +
|
|
||||||
util.classString(reason);
|
|
||||||
this._warn(message, true);
|
|
||||||
}
|
|
||||||
this._attachExtraTrace(trace, synchronous ? hasStack : false);
|
|
||||||
this._reject(reason);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._resolveFromExecutor = function (executor) {
|
|
||||||
if (executor === INTERNAL) return;
|
|
||||||
var promise = this;
|
|
||||||
this._captureStackTrace();
|
|
||||||
this._pushContext();
|
|
||||||
var synchronous = true;
|
|
||||||
var r = this._execute(executor, function(value) {
|
|
||||||
promise._resolveCallback(value);
|
|
||||||
}, function (reason) {
|
|
||||||
promise._rejectCallback(reason, synchronous);
|
|
||||||
});
|
|
||||||
synchronous = false;
|
|
||||||
this._popContext();
|
|
||||||
|
|
||||||
if (r !== undefined) {
|
|
||||||
promise._rejectCallback(r, true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._settlePromiseFromHandler = function (
|
|
||||||
handler, receiver, value, promise
|
|
||||||
) {
|
|
||||||
var bitField = promise._bitField;
|
|
||||||
if (((bitField & 65536) !== 0)) return;
|
|
||||||
promise._pushContext();
|
|
||||||
var x;
|
|
||||||
if (receiver === APPLY) {
|
|
||||||
if (!value || typeof value.length !== "number") {
|
|
||||||
x = errorObj;
|
|
||||||
x.e = new TypeError("cannot .spread() a non-array: " +
|
|
||||||
util.classString(value));
|
|
||||||
} else {
|
|
||||||
x = tryCatch(handler).apply(this._boundValue(), value);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
x = tryCatch(handler).call(receiver, value);
|
|
||||||
}
|
|
||||||
var promiseCreated = promise._popContext();
|
|
||||||
bitField = promise._bitField;
|
|
||||||
if (((bitField & 65536) !== 0)) return;
|
|
||||||
|
|
||||||
if (x === NEXT_FILTER) {
|
|
||||||
promise._reject(value);
|
|
||||||
} else if (x === errorObj) {
|
|
||||||
promise._rejectCallback(x.e, false);
|
|
||||||
} else {
|
|
||||||
debug.checkForgottenReturns(x, promiseCreated, "", promise, this);
|
|
||||||
promise._resolveCallback(x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._target = function() {
|
|
||||||
var ret = this;
|
|
||||||
while (ret._isFollowing()) ret = ret._followee();
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._followee = function() {
|
|
||||||
return this._rejectionHandler0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setFollowee = function(promise) {
|
|
||||||
this._rejectionHandler0 = promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._settlePromise = function(promise, handler, receiver, value) {
|
|
||||||
var isPromise = promise instanceof Promise;
|
|
||||||
var bitField = this._bitField;
|
|
||||||
var asyncGuaranteed = ((bitField & 134217728) !== 0);
|
|
||||||
if (((bitField & 65536) !== 0)) {
|
|
||||||
if (isPromise) promise._invokeInternalOnCancel();
|
|
||||||
|
|
||||||
if (receiver instanceof PassThroughHandlerContext &&
|
|
||||||
receiver.isFinallyHandler()) {
|
|
||||||
receiver.cancelPromise = promise;
|
|
||||||
if (tryCatch(handler).call(receiver, value) === errorObj) {
|
|
||||||
promise._reject(errorObj.e);
|
|
||||||
}
|
|
||||||
} else if (handler === reflectHandler) {
|
|
||||||
promise._fulfill(reflectHandler.call(receiver));
|
|
||||||
} else if (receiver instanceof Proxyable) {
|
|
||||||
receiver._promiseCancelled(promise);
|
|
||||||
} else if (isPromise || promise instanceof PromiseArray) {
|
|
||||||
promise._cancel();
|
|
||||||
} else {
|
|
||||||
receiver.cancel();
|
|
||||||
}
|
|
||||||
} else if (typeof handler === "function") {
|
|
||||||
if (!isPromise) {
|
|
||||||
handler.call(receiver, value, promise);
|
|
||||||
} else {
|
|
||||||
if (asyncGuaranteed) promise._setAsyncGuaranteed();
|
|
||||||
this._settlePromiseFromHandler(handler, receiver, value, promise);
|
|
||||||
}
|
|
||||||
} else if (receiver instanceof Proxyable) {
|
|
||||||
if (!receiver._isResolved()) {
|
|
||||||
if (((bitField & 33554432) !== 0)) {
|
|
||||||
receiver._promiseFulfilled(value, promise);
|
|
||||||
} else {
|
|
||||||
receiver._promiseRejected(value, promise);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (isPromise) {
|
|
||||||
if (asyncGuaranteed) promise._setAsyncGuaranteed();
|
|
||||||
if (((bitField & 33554432) !== 0)) {
|
|
||||||
promise._fulfill(value);
|
|
||||||
} else {
|
|
||||||
promise._reject(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) {
|
|
||||||
var handler = ctx.handler;
|
|
||||||
var promise = ctx.promise;
|
|
||||||
var receiver = ctx.receiver;
|
|
||||||
var value = ctx.value;
|
|
||||||
if (typeof handler === "function") {
|
|
||||||
if (!(promise instanceof Promise)) {
|
|
||||||
handler.call(receiver, value, promise);
|
|
||||||
} else {
|
|
||||||
this._settlePromiseFromHandler(handler, receiver, value, promise);
|
|
||||||
}
|
|
||||||
} else if (promise instanceof Promise) {
|
|
||||||
promise._reject(value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._settlePromiseCtx = function(ctx) {
|
|
||||||
this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._settlePromise0 = function(handler, value, bitField) {
|
|
||||||
var promise = this._promise0;
|
|
||||||
var receiver = this._receiverAt(0);
|
|
||||||
this._promise0 = undefined;
|
|
||||||
this._receiver0 = undefined;
|
|
||||||
this._settlePromise(promise, handler, receiver, value);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._clearCallbackDataAtIndex = function(index) {
|
|
||||||
var base = index * 4 - 4;
|
|
||||||
this[base + 2] =
|
|
||||||
this[base + 3] =
|
|
||||||
this[base + 0] =
|
|
||||||
this[base + 1] = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._fulfill = function (value) {
|
|
||||||
var bitField = this._bitField;
|
|
||||||
if (((bitField & 117506048) >>> 16)) return;
|
|
||||||
if (value === this) {
|
|
||||||
var err = makeSelfResolutionError();
|
|
||||||
this._attachExtraTrace(err);
|
|
||||||
return this._reject(err);
|
|
||||||
}
|
|
||||||
this._setFulfilled();
|
|
||||||
this._rejectionHandler0 = value;
|
|
||||||
|
|
||||||
if ((bitField & 65535) > 0) {
|
|
||||||
if (((bitField & 134217728) !== 0)) {
|
|
||||||
this._settlePromises();
|
|
||||||
} else {
|
|
||||||
async.settlePromises(this);
|
|
||||||
}
|
|
||||||
this._dereferenceTrace();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._reject = function (reason) {
|
|
||||||
var bitField = this._bitField;
|
|
||||||
if (((bitField & 117506048) >>> 16)) return;
|
|
||||||
this._setRejected();
|
|
||||||
this._fulfillmentHandler0 = reason;
|
|
||||||
|
|
||||||
if (this._isFinal()) {
|
|
||||||
return async.fatalError(reason, util.isNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((bitField & 65535) > 0) {
|
|
||||||
async.settlePromises(this);
|
|
||||||
} else {
|
|
||||||
this._ensurePossibleRejectionHandled();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._fulfillPromises = function (len, value) {
|
|
||||||
for (var i = 1; i < len; i++) {
|
|
||||||
var handler = this._fulfillmentHandlerAt(i);
|
|
||||||
var promise = this._promiseAt(i);
|
|
||||||
var receiver = this._receiverAt(i);
|
|
||||||
this._clearCallbackDataAtIndex(i);
|
|
||||||
this._settlePromise(promise, handler, receiver, value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._rejectPromises = function (len, reason) {
|
|
||||||
for (var i = 1; i < len; i++) {
|
|
||||||
var handler = this._rejectionHandlerAt(i);
|
|
||||||
var promise = this._promiseAt(i);
|
|
||||||
var receiver = this._receiverAt(i);
|
|
||||||
this._clearCallbackDataAtIndex(i);
|
|
||||||
this._settlePromise(promise, handler, receiver, reason);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._settlePromises = function () {
|
|
||||||
var bitField = this._bitField;
|
|
||||||
var len = (bitField & 65535);
|
|
||||||
|
|
||||||
if (len > 0) {
|
|
||||||
if (((bitField & 16842752) !== 0)) {
|
|
||||||
var reason = this._fulfillmentHandler0;
|
|
||||||
this._settlePromise0(this._rejectionHandler0, reason, bitField);
|
|
||||||
this._rejectPromises(len, reason);
|
|
||||||
} else {
|
|
||||||
var value = this._rejectionHandler0;
|
|
||||||
this._settlePromise0(this._fulfillmentHandler0, value, bitField);
|
|
||||||
this._fulfillPromises(len, value);
|
|
||||||
}
|
|
||||||
this._setLength(0);
|
|
||||||
}
|
|
||||||
this._clearCancellationData();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._settledValue = function() {
|
|
||||||
var bitField = this._bitField;
|
|
||||||
if (((bitField & 33554432) !== 0)) {
|
|
||||||
return this._rejectionHandler0;
|
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
|
||||||
return this._fulfillmentHandler0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
|
|
||||||
es5.defineProperty(Promise.prototype, Symbol.toStringTag, {
|
|
||||||
get: function () {
|
|
||||||
return "Object";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function deferResolve(v) {this.promise._resolveCallback(v);}
|
|
||||||
function deferReject(v) {this.promise._rejectCallback(v, false);}
|
|
||||||
|
|
||||||
Promise.defer = Promise.pending = function() {
|
|
||||||
debug.deprecated("Promise.defer", "new Promise");
|
|
||||||
var promise = new Promise(INTERNAL);
|
|
||||||
return {
|
|
||||||
promise: promise,
|
|
||||||
resolve: deferResolve,
|
|
||||||
reject: deferReject
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
util.notEnumerableProp(Promise,
|
|
||||||
"_makeSelfResolutionError",
|
|
||||||
makeSelfResolutionError);
|
|
||||||
|
|
||||||
require("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection,
|
|
||||||
debug);
|
|
||||||
require("./bind")(Promise, INTERNAL, tryConvertToPromise, debug);
|
|
||||||
require("./cancel")(Promise, PromiseArray, apiRejection, debug);
|
|
||||||
require("./direct_resolve")(Promise);
|
|
||||||
require("./synchronous_inspection")(Promise);
|
|
||||||
require("./join")(
|
|
||||||
Promise, PromiseArray, tryConvertToPromise, INTERNAL, async);
|
|
||||||
Promise.Promise = Promise;
|
|
||||||
Promise.version = "3.7.2";
|
|
||||||
require('./call_get.js')(Promise);
|
|
||||||
require('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
|
|
||||||
require('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
|
||||||
require('./nodeify.js')(Promise);
|
|
||||||
require('./promisify.js')(Promise, INTERNAL);
|
|
||||||
require('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
|
|
||||||
require('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
|
|
||||||
require('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
|
|
||||||
require('./settle.js')(Promise, PromiseArray, debug);
|
|
||||||
require('./some.js')(Promise, PromiseArray, apiRejection);
|
|
||||||
require('./timers.js')(Promise, INTERNAL, debug);
|
|
||||||
require('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
|
|
||||||
require('./any.js')(Promise);
|
|
||||||
require('./each.js')(Promise, INTERNAL);
|
|
||||||
require('./filter.js')(Promise, INTERNAL);
|
|
||||||
|
|
||||||
util.toFastProperties(Promise);
|
|
||||||
util.toFastProperties(Promise.prototype);
|
|
||||||
function fillTypes(value) {
|
|
||||||
var p = new Promise(INTERNAL);
|
|
||||||
p._fulfillmentHandler0 = value;
|
|
||||||
p._rejectionHandler0 = value;
|
|
||||||
p._promise0 = value;
|
|
||||||
p._receiver0 = value;
|
|
||||||
}
|
|
||||||
// Complete slack tracking, opt out of field-type tracking and
|
|
||||||
// stabilize map
|
|
||||||
fillTypes({a: 1});
|
|
||||||
fillTypes({b: 2});
|
|
||||||
fillTypes({c: 3});
|
|
||||||
fillTypes(1);
|
|
||||||
fillTypes(function(){});
|
|
||||||
fillTypes(undefined);
|
|
||||||
fillTypes(false);
|
|
||||||
fillTypes(new Promise(INTERNAL));
|
|
||||||
debug.setBounds(Async.firstLineError, util.lastLineError);
|
|
||||||
return Promise;
|
|
||||||
|
|
||||||
};
|
|
||||||
186
node_modules/bluebird/js/release/promise_array.js
generated
vendored
186
node_modules/bluebird/js/release/promise_array.js
generated
vendored
@@ -1,186 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, INTERNAL, tryConvertToPromise,
|
|
||||||
apiRejection, Proxyable) {
|
|
||||||
var util = require("./util");
|
|
||||||
var isArray = util.isArray;
|
|
||||||
|
|
||||||
function toResolutionValue(val) {
|
|
||||||
switch(val) {
|
|
||||||
case -2: return [];
|
|
||||||
case -3: return {};
|
|
||||||
case -6: return new Map();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function PromiseArray(values) {
|
|
||||||
var promise = this._promise = new Promise(INTERNAL);
|
|
||||||
if (values instanceof Promise) {
|
|
||||||
promise._propagateFrom(values, 3);
|
|
||||||
values.suppressUnhandledRejections();
|
|
||||||
}
|
|
||||||
promise._setOnCancel(this);
|
|
||||||
this._values = values;
|
|
||||||
this._length = 0;
|
|
||||||
this._totalResolved = 0;
|
|
||||||
this._init(undefined, -2);
|
|
||||||
}
|
|
||||||
util.inherits(PromiseArray, Proxyable);
|
|
||||||
|
|
||||||
PromiseArray.prototype.length = function () {
|
|
||||||
return this._length;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype.promise = function () {
|
|
||||||
return this._promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
|
|
||||||
var values = tryConvertToPromise(this._values, this._promise);
|
|
||||||
if (values instanceof Promise) {
|
|
||||||
values = values._target();
|
|
||||||
var bitField = values._bitField;
|
|
||||||
;
|
|
||||||
this._values = values;
|
|
||||||
|
|
||||||
if (((bitField & 50397184) === 0)) {
|
|
||||||
this._promise._setAsyncGuaranteed();
|
|
||||||
return values._then(
|
|
||||||
init,
|
|
||||||
this._reject,
|
|
||||||
undefined,
|
|
||||||
this,
|
|
||||||
resolveValueIfEmpty
|
|
||||||
);
|
|
||||||
} else if (((bitField & 33554432) !== 0)) {
|
|
||||||
values = values._value();
|
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
|
||||||
return this._reject(values._reason());
|
|
||||||
} else {
|
|
||||||
return this._cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
values = util.asArray(values);
|
|
||||||
if (values === null) {
|
|
||||||
var err = apiRejection(
|
|
||||||
"expecting an array or an iterable object but got " + util.classString(values)).reason();
|
|
||||||
this._promise._rejectCallback(err, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (values.length === 0) {
|
|
||||||
if (resolveValueIfEmpty === -5) {
|
|
||||||
this._resolveEmptyArray();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this._resolve(toResolutionValue(resolveValueIfEmpty));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._iterate(values);
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._iterate = function(values) {
|
|
||||||
var len = this.getActualLength(values.length);
|
|
||||||
this._length = len;
|
|
||||||
this._values = this.shouldCopyValues() ? new Array(len) : this._values;
|
|
||||||
var result = this._promise;
|
|
||||||
var isResolved = false;
|
|
||||||
var bitField = null;
|
|
||||||
for (var i = 0; i < len; ++i) {
|
|
||||||
var maybePromise = tryConvertToPromise(values[i], result);
|
|
||||||
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
maybePromise = maybePromise._target();
|
|
||||||
bitField = maybePromise._bitField;
|
|
||||||
} else {
|
|
||||||
bitField = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isResolved) {
|
|
||||||
if (bitField !== null) {
|
|
||||||
maybePromise.suppressUnhandledRejections();
|
|
||||||
}
|
|
||||||
} else if (bitField !== null) {
|
|
||||||
if (((bitField & 50397184) === 0)) {
|
|
||||||
maybePromise._proxy(this, i);
|
|
||||||
this._values[i] = maybePromise;
|
|
||||||
} else if (((bitField & 33554432) !== 0)) {
|
|
||||||
isResolved = this._promiseFulfilled(maybePromise._value(), i);
|
|
||||||
} else if (((bitField & 16777216) !== 0)) {
|
|
||||||
isResolved = this._promiseRejected(maybePromise._reason(), i);
|
|
||||||
} else {
|
|
||||||
isResolved = this._promiseCancelled(i);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isResolved = this._promiseFulfilled(maybePromise, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isResolved) result._setAsyncGuaranteed();
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._isResolved = function () {
|
|
||||||
return this._values === null;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._resolve = function (value) {
|
|
||||||
this._values = null;
|
|
||||||
this._promise._fulfill(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._cancel = function() {
|
|
||||||
if (this._isResolved() || !this._promise._isCancellable()) return;
|
|
||||||
this._values = null;
|
|
||||||
this._promise._cancel();
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._reject = function (reason) {
|
|
||||||
this._values = null;
|
|
||||||
this._promise._rejectCallback(reason, false);
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._promiseFulfilled = function (value, index) {
|
|
||||||
this._values[index] = value;
|
|
||||||
var totalResolved = ++this._totalResolved;
|
|
||||||
if (totalResolved >= this._length) {
|
|
||||||
this._resolve(this._values);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._promiseCancelled = function() {
|
|
||||||
this._cancel();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._promiseRejected = function (reason) {
|
|
||||||
this._totalResolved++;
|
|
||||||
this._reject(reason);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype._resultCancelled = function() {
|
|
||||||
if (this._isResolved()) return;
|
|
||||||
var values = this._values;
|
|
||||||
this._cancel();
|
|
||||||
if (values instanceof Promise) {
|
|
||||||
values.cancel();
|
|
||||||
} else {
|
|
||||||
for (var i = 0; i < values.length; ++i) {
|
|
||||||
if (values[i] instanceof Promise) {
|
|
||||||
values[i].cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype.shouldCopyValues = function () {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseArray.prototype.getActualLength = function (len) {
|
|
||||||
return len;
|
|
||||||
};
|
|
||||||
|
|
||||||
return PromiseArray;
|
|
||||||
};
|
|
||||||
314
node_modules/bluebird/js/release/promisify.js
generated
vendored
314
node_modules/bluebird/js/release/promisify.js
generated
vendored
@@ -1,314 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, INTERNAL) {
|
|
||||||
var THIS = {};
|
|
||||||
var util = require("./util");
|
|
||||||
var nodebackForPromise = require("./nodeback");
|
|
||||||
var withAppended = util.withAppended;
|
|
||||||
var maybeWrapAsError = util.maybeWrapAsError;
|
|
||||||
var canEvaluate = util.canEvaluate;
|
|
||||||
var TypeError = require("./errors").TypeError;
|
|
||||||
var defaultSuffix = "Async";
|
|
||||||
var defaultPromisified = {__isPromisified__: true};
|
|
||||||
var noCopyProps = [
|
|
||||||
"arity", "length",
|
|
||||||
"name",
|
|
||||||
"arguments",
|
|
||||||
"caller",
|
|
||||||
"callee",
|
|
||||||
"prototype",
|
|
||||||
"__isPromisified__"
|
|
||||||
];
|
|
||||||
var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
|
|
||||||
|
|
||||||
var defaultFilter = function(name) {
|
|
||||||
return util.isIdentifier(name) &&
|
|
||||||
name.charAt(0) !== "_" &&
|
|
||||||
name !== "constructor";
|
|
||||||
};
|
|
||||||
|
|
||||||
function propsFilter(key) {
|
|
||||||
return !noCopyPropsPattern.test(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isPromisified(fn) {
|
|
||||||
try {
|
|
||||||
return fn.__isPromisified__ === true;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasPromisified(obj, key, suffix) {
|
|
||||||
var val = util.getDataPropertyOrDefault(obj, key + suffix,
|
|
||||||
defaultPromisified);
|
|
||||||
return val ? isPromisified(val) : false;
|
|
||||||
}
|
|
||||||
function checkValid(ret, suffix, suffixRegexp) {
|
|
||||||
for (var i = 0; i < ret.length; i += 2) {
|
|
||||||
var key = ret[i];
|
|
||||||
if (suffixRegexp.test(key)) {
|
|
||||||
var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
|
|
||||||
for (var j = 0; j < ret.length; j += 2) {
|
|
||||||
if (ret[j] === keyWithoutAsyncSuffix) {
|
|
||||||
throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/MqrFmX\u000a"
|
|
||||||
.replace("%s", suffix));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
|
|
||||||
var keys = util.inheritedDataKeys(obj);
|
|
||||||
var ret = [];
|
|
||||||
for (var i = 0; i < keys.length; ++i) {
|
|
||||||
var key = keys[i];
|
|
||||||
var value = obj[key];
|
|
||||||
var passesDefaultFilter = filter === defaultFilter
|
|
||||||
? true : defaultFilter(key, value, obj);
|
|
||||||
if (typeof value === "function" &&
|
|
||||||
!isPromisified(value) &&
|
|
||||||
!hasPromisified(obj, key, suffix) &&
|
|
||||||
filter(key, value, obj, passesDefaultFilter)) {
|
|
||||||
ret.push(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checkValid(ret, suffix, suffixRegexp);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
var escapeIdentRegex = function(str) {
|
|
||||||
return str.replace(/([$])/, "\\$");
|
|
||||||
};
|
|
||||||
|
|
||||||
var makeNodePromisifiedEval;
|
|
||||||
if (!false) {
|
|
||||||
var switchCaseArgumentOrder = function(likelyArgumentCount) {
|
|
||||||
var ret = [likelyArgumentCount];
|
|
||||||
var min = Math.max(0, likelyArgumentCount - 1 - 3);
|
|
||||||
for(var i = likelyArgumentCount - 1; i >= min; --i) {
|
|
||||||
ret.push(i);
|
|
||||||
}
|
|
||||||
for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
|
|
||||||
ret.push(i);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
var argumentSequence = function(argumentCount) {
|
|
||||||
return util.filledRange(argumentCount, "_arg", "");
|
|
||||||
};
|
|
||||||
|
|
||||||
var parameterDeclaration = function(parameterCount) {
|
|
||||||
return util.filledRange(
|
|
||||||
Math.max(parameterCount, 3), "_arg", "");
|
|
||||||
};
|
|
||||||
|
|
||||||
var parameterCount = function(fn) {
|
|
||||||
if (typeof fn.length === "number") {
|
|
||||||
return Math.max(Math.min(fn.length, 1023 + 1), 0);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
makeNodePromisifiedEval =
|
|
||||||
function(callback, receiver, originalName, fn, _, multiArgs) {
|
|
||||||
var newParameterCount = Math.max(0, parameterCount(fn) - 1);
|
|
||||||
var argumentOrder = switchCaseArgumentOrder(newParameterCount);
|
|
||||||
var shouldProxyThis = typeof callback === "string" || receiver === THIS;
|
|
||||||
|
|
||||||
function generateCallForArgumentCount(count) {
|
|
||||||
var args = argumentSequence(count).join(", ");
|
|
||||||
var comma = count > 0 ? ", " : "";
|
|
||||||
var ret;
|
|
||||||
if (shouldProxyThis) {
|
|
||||||
ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
|
|
||||||
} else {
|
|
||||||
ret = receiver === undefined
|
|
||||||
? "ret = callback({{args}}, nodeback); break;\n"
|
|
||||||
: "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
|
|
||||||
}
|
|
||||||
return ret.replace("{{args}}", args).replace(", ", comma);
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateArgumentSwitchCase() {
|
|
||||||
var ret = "";
|
|
||||||
for (var i = 0; i < argumentOrder.length; ++i) {
|
|
||||||
ret += "case " + argumentOrder[i] +":" +
|
|
||||||
generateCallForArgumentCount(argumentOrder[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret += " \n\
|
|
||||||
default: \n\
|
|
||||||
var args = new Array(len + 1); \n\
|
|
||||||
var i = 0; \n\
|
|
||||||
for (var i = 0; i < len; ++i) { \n\
|
|
||||||
args[i] = arguments[i]; \n\
|
|
||||||
} \n\
|
|
||||||
args[i] = nodeback; \n\
|
|
||||||
[CodeForCall] \n\
|
|
||||||
break; \n\
|
|
||||||
".replace("[CodeForCall]", (shouldProxyThis
|
|
||||||
? "ret = callback.apply(this, args);\n"
|
|
||||||
: "ret = callback.apply(receiver, args);\n"));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
var getFunctionCode = typeof callback === "string"
|
|
||||||
? ("this != null ? this['"+callback+"'] : fn")
|
|
||||||
: "fn";
|
|
||||||
var body = "'use strict'; \n\
|
|
||||||
var ret = function (Parameters) { \n\
|
|
||||||
'use strict'; \n\
|
|
||||||
var len = arguments.length; \n\
|
|
||||||
var promise = new Promise(INTERNAL); \n\
|
|
||||||
promise._captureStackTrace(); \n\
|
|
||||||
var nodeback = nodebackForPromise(promise, " + multiArgs + "); \n\
|
|
||||||
var ret; \n\
|
|
||||||
var callback = tryCatch([GetFunctionCode]); \n\
|
|
||||||
switch(len) { \n\
|
|
||||||
[CodeForSwitchCase] \n\
|
|
||||||
} \n\
|
|
||||||
if (ret === errorObj) { \n\
|
|
||||||
promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
|
|
||||||
} \n\
|
|
||||||
if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); \n\
|
|
||||||
return promise; \n\
|
|
||||||
}; \n\
|
|
||||||
notEnumerableProp(ret, '__isPromisified__', true); \n\
|
|
||||||
return ret; \n\
|
|
||||||
".replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
|
|
||||||
.replace("[GetFunctionCode]", getFunctionCode);
|
|
||||||
body = body.replace("Parameters", parameterDeclaration(newParameterCount));
|
|
||||||
return new Function("Promise",
|
|
||||||
"fn",
|
|
||||||
"receiver",
|
|
||||||
"withAppended",
|
|
||||||
"maybeWrapAsError",
|
|
||||||
"nodebackForPromise",
|
|
||||||
"tryCatch",
|
|
||||||
"errorObj",
|
|
||||||
"notEnumerableProp",
|
|
||||||
"INTERNAL",
|
|
||||||
body)(
|
|
||||||
Promise,
|
|
||||||
fn,
|
|
||||||
receiver,
|
|
||||||
withAppended,
|
|
||||||
maybeWrapAsError,
|
|
||||||
nodebackForPromise,
|
|
||||||
util.tryCatch,
|
|
||||||
util.errorObj,
|
|
||||||
util.notEnumerableProp,
|
|
||||||
INTERNAL);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeNodePromisifiedClosure(callback, receiver, _, fn, __, multiArgs) {
|
|
||||||
var defaultThis = (function() {return this;})();
|
|
||||||
var method = callback;
|
|
||||||
if (typeof method === "string") {
|
|
||||||
callback = fn;
|
|
||||||
}
|
|
||||||
function promisified() {
|
|
||||||
var _receiver = receiver;
|
|
||||||
if (receiver === THIS) _receiver = this;
|
|
||||||
var promise = new Promise(INTERNAL);
|
|
||||||
promise._captureStackTrace();
|
|
||||||
var cb = typeof method === "string" && this !== defaultThis
|
|
||||||
? this[method] : callback;
|
|
||||||
var fn = nodebackForPromise(promise, multiArgs);
|
|
||||||
try {
|
|
||||||
cb.apply(_receiver, withAppended(arguments, fn));
|
|
||||||
} catch(e) {
|
|
||||||
promise._rejectCallback(maybeWrapAsError(e), true, true);
|
|
||||||
}
|
|
||||||
if (!promise._isFateSealed()) promise._setAsyncGuaranteed();
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
util.notEnumerableProp(promisified, "__isPromisified__", true);
|
|
||||||
return promisified;
|
|
||||||
}
|
|
||||||
|
|
||||||
var makeNodePromisified = canEvaluate
|
|
||||||
? makeNodePromisifiedEval
|
|
||||||
: makeNodePromisifiedClosure;
|
|
||||||
|
|
||||||
function promisifyAll(obj, suffix, filter, promisifier, multiArgs) {
|
|
||||||
var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
|
|
||||||
var methods =
|
|
||||||
promisifiableMethods(obj, suffix, suffixRegexp, filter);
|
|
||||||
|
|
||||||
for (var i = 0, len = methods.length; i < len; i+= 2) {
|
|
||||||
var key = methods[i];
|
|
||||||
var fn = methods[i+1];
|
|
||||||
var promisifiedKey = key + suffix;
|
|
||||||
if (promisifier === makeNodePromisified) {
|
|
||||||
obj[promisifiedKey] =
|
|
||||||
makeNodePromisified(key, THIS, key, fn, suffix, multiArgs);
|
|
||||||
} else {
|
|
||||||
var promisified = promisifier(fn, function() {
|
|
||||||
return makeNodePromisified(key, THIS, key,
|
|
||||||
fn, suffix, multiArgs);
|
|
||||||
});
|
|
||||||
util.notEnumerableProp(promisified, "__isPromisified__", true);
|
|
||||||
obj[promisifiedKey] = promisified;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
util.toFastProperties(obj);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function promisify(callback, receiver, multiArgs) {
|
|
||||||
return makeNodePromisified(callback, receiver, undefined,
|
|
||||||
callback, null, multiArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.promisify = function (fn, options) {
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
throw new TypeError("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
if (isPromisified(fn)) {
|
|
||||||
return fn;
|
|
||||||
}
|
|
||||||
options = Object(options);
|
|
||||||
var receiver = options.context === undefined ? THIS : options.context;
|
|
||||||
var multiArgs = !!options.multiArgs;
|
|
||||||
var ret = promisify(fn, receiver, multiArgs);
|
|
||||||
util.copyDescriptors(fn, ret, propsFilter);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.promisifyAll = function (target, options) {
|
|
||||||
if (typeof target !== "function" && typeof target !== "object") {
|
|
||||||
throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
options = Object(options);
|
|
||||||
var multiArgs = !!options.multiArgs;
|
|
||||||
var suffix = options.suffix;
|
|
||||||
if (typeof suffix !== "string") suffix = defaultSuffix;
|
|
||||||
var filter = options.filter;
|
|
||||||
if (typeof filter !== "function") filter = defaultFilter;
|
|
||||||
var promisifier = options.promisifier;
|
|
||||||
if (typeof promisifier !== "function") promisifier = makeNodePromisified;
|
|
||||||
|
|
||||||
if (!util.isIdentifier(suffix)) {
|
|
||||||
throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
|
|
||||||
var keys = util.inheritedDataKeys(target);
|
|
||||||
for (var i = 0; i < keys.length; ++i) {
|
|
||||||
var value = target[keys[i]];
|
|
||||||
if (keys[i] !== "constructor" &&
|
|
||||||
util.isClass(value)) {
|
|
||||||
promisifyAll(value.prototype, suffix, filter, promisifier,
|
|
||||||
multiArgs);
|
|
||||||
promisifyAll(value, suffix, filter, promisifier, multiArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return promisifyAll(target, suffix, filter, promisifier, multiArgs);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
118
node_modules/bluebird/js/release/props.js
generated
vendored
118
node_modules/bluebird/js/release/props.js
generated
vendored
@@ -1,118 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(
|
|
||||||
Promise, PromiseArray, tryConvertToPromise, apiRejection) {
|
|
||||||
var util = require("./util");
|
|
||||||
var isObject = util.isObject;
|
|
||||||
var es5 = require("./es5");
|
|
||||||
var Es6Map;
|
|
||||||
if (typeof Map === "function") Es6Map = Map;
|
|
||||||
|
|
||||||
var mapToEntries = (function() {
|
|
||||||
var index = 0;
|
|
||||||
var size = 0;
|
|
||||||
|
|
||||||
function extractEntry(value, key) {
|
|
||||||
this[index] = value;
|
|
||||||
this[index + size] = key;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return function mapToEntries(map) {
|
|
||||||
size = map.size;
|
|
||||||
index = 0;
|
|
||||||
var ret = new Array(map.size * 2);
|
|
||||||
map.forEach(extractEntry, ret);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
var entriesToMap = function(entries) {
|
|
||||||
var ret = new Es6Map();
|
|
||||||
var length = entries.length / 2 | 0;
|
|
||||||
for (var i = 0; i < length; ++i) {
|
|
||||||
var key = entries[length + i];
|
|
||||||
var value = entries[i];
|
|
||||||
ret.set(key, value);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
function PropertiesPromiseArray(obj) {
|
|
||||||
var isMap = false;
|
|
||||||
var entries;
|
|
||||||
if (Es6Map !== undefined && obj instanceof Es6Map) {
|
|
||||||
entries = mapToEntries(obj);
|
|
||||||
isMap = true;
|
|
||||||
} else {
|
|
||||||
var keys = es5.keys(obj);
|
|
||||||
var len = keys.length;
|
|
||||||
entries = new Array(len * 2);
|
|
||||||
for (var i = 0; i < len; ++i) {
|
|
||||||
var key = keys[i];
|
|
||||||
entries[i] = obj[key];
|
|
||||||
entries[i + len] = key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.constructor$(entries);
|
|
||||||
this._isMap = isMap;
|
|
||||||
this._init$(undefined, isMap ? -6 : -3);
|
|
||||||
}
|
|
||||||
util.inherits(PropertiesPromiseArray, PromiseArray);
|
|
||||||
|
|
||||||
PropertiesPromiseArray.prototype._init = function () {};
|
|
||||||
|
|
||||||
PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
|
||||||
this._values[index] = value;
|
|
||||||
var totalResolved = ++this._totalResolved;
|
|
||||||
if (totalResolved >= this._length) {
|
|
||||||
var val;
|
|
||||||
if (this._isMap) {
|
|
||||||
val = entriesToMap(this._values);
|
|
||||||
} else {
|
|
||||||
val = {};
|
|
||||||
var keyOffset = this.length();
|
|
||||||
for (var i = 0, len = this.length(); i < len; ++i) {
|
|
||||||
val[this._values[i + keyOffset]] = this._values[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._resolve(val);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
PropertiesPromiseArray.prototype.shouldCopyValues = function () {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
PropertiesPromiseArray.prototype.getActualLength = function (len) {
|
|
||||||
return len >> 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
function props(promises) {
|
|
||||||
var ret;
|
|
||||||
var castValue = tryConvertToPromise(promises);
|
|
||||||
|
|
||||||
if (!isObject(castValue)) {
|
|
||||||
return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
} else if (castValue instanceof Promise) {
|
|
||||||
ret = castValue._then(
|
|
||||||
Promise.props, undefined, undefined, undefined, undefined);
|
|
||||||
} else {
|
|
||||||
ret = new PropertiesPromiseArray(castValue).promise();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (castValue instanceof Promise) {
|
|
||||||
ret._propagateFrom(castValue, 2);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype.props = function () {
|
|
||||||
return props(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.props = function (promises) {
|
|
||||||
return props(promises);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
73
node_modules/bluebird/js/release/queue.js
generated
vendored
73
node_modules/bluebird/js/release/queue.js
generated
vendored
@@ -1,73 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
function arrayMove(src, srcIndex, dst, dstIndex, len) {
|
|
||||||
for (var j = 0; j < len; ++j) {
|
|
||||||
dst[j + dstIndex] = src[j + srcIndex];
|
|
||||||
src[j + srcIndex] = void 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Queue(capacity) {
|
|
||||||
this._capacity = capacity;
|
|
||||||
this._length = 0;
|
|
||||||
this._front = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Queue.prototype._willBeOverCapacity = function (size) {
|
|
||||||
return this._capacity < size;
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype._pushOne = function (arg) {
|
|
||||||
var length = this.length();
|
|
||||||
this._checkCapacity(length + 1);
|
|
||||||
var i = (this._front + length) & (this._capacity - 1);
|
|
||||||
this[i] = arg;
|
|
||||||
this._length = length + 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype.push = function (fn, receiver, arg) {
|
|
||||||
var length = this.length() + 3;
|
|
||||||
if (this._willBeOverCapacity(length)) {
|
|
||||||
this._pushOne(fn);
|
|
||||||
this._pushOne(receiver);
|
|
||||||
this._pushOne(arg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var j = this._front + length - 3;
|
|
||||||
this._checkCapacity(length);
|
|
||||||
var wrapMask = this._capacity - 1;
|
|
||||||
this[(j + 0) & wrapMask] = fn;
|
|
||||||
this[(j + 1) & wrapMask] = receiver;
|
|
||||||
this[(j + 2) & wrapMask] = arg;
|
|
||||||
this._length = length;
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype.shift = function () {
|
|
||||||
var front = this._front,
|
|
||||||
ret = this[front];
|
|
||||||
|
|
||||||
this[front] = undefined;
|
|
||||||
this._front = (front + 1) & (this._capacity - 1);
|
|
||||||
this._length--;
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype.length = function () {
|
|
||||||
return this._length;
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype._checkCapacity = function (size) {
|
|
||||||
if (this._capacity < size) {
|
|
||||||
this._resizeTo(this._capacity << 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Queue.prototype._resizeTo = function (capacity) {
|
|
||||||
var oldCapacity = this._capacity;
|
|
||||||
this._capacity = capacity;
|
|
||||||
var front = this._front;
|
|
||||||
var length = this._length;
|
|
||||||
var moveItemsCount = (front + length) & (oldCapacity - 1);
|
|
||||||
arrayMove(this, 0, this, oldCapacity, moveItemsCount);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Queue;
|
|
||||||
49
node_modules/bluebird/js/release/race.js
generated
vendored
49
node_modules/bluebird/js/release/race.js
generated
vendored
@@ -1,49 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(
|
|
||||||
Promise, INTERNAL, tryConvertToPromise, apiRejection) {
|
|
||||||
var util = require("./util");
|
|
||||||
|
|
||||||
var raceLater = function (promise) {
|
|
||||||
return promise.then(function(array) {
|
|
||||||
return race(array, promise);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function race(promises, parent) {
|
|
||||||
var maybePromise = tryConvertToPromise(promises);
|
|
||||||
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
return raceLater(maybePromise);
|
|
||||||
} else {
|
|
||||||
promises = util.asArray(promises);
|
|
||||||
if (promises === null)
|
|
||||||
return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
|
|
||||||
}
|
|
||||||
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
if (parent !== undefined) {
|
|
||||||
ret._propagateFrom(parent, 3);
|
|
||||||
}
|
|
||||||
var fulfill = ret._fulfill;
|
|
||||||
var reject = ret._reject;
|
|
||||||
for (var i = 0, len = promises.length; i < len; ++i) {
|
|
||||||
var val = promises[i];
|
|
||||||
|
|
||||||
if (val === undefined && !(i in promises)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.race = function (promises) {
|
|
||||||
return race(promises, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.race = function () {
|
|
||||||
return race(this, undefined);
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
183
node_modules/bluebird/js/release/reduce.js
generated
vendored
183
node_modules/bluebird/js/release/reduce.js
generated
vendored
@@ -1,183 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise,
|
|
||||||
PromiseArray,
|
|
||||||
apiRejection,
|
|
||||||
tryConvertToPromise,
|
|
||||||
INTERNAL,
|
|
||||||
debug) {
|
|
||||||
var util = require("./util");
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
|
|
||||||
function ReductionPromiseArray(promises, fn, initialValue, _each) {
|
|
||||||
this.constructor$(promises);
|
|
||||||
var context = Promise._getContext();
|
|
||||||
this._fn = util.contextBind(context, fn);
|
|
||||||
if (initialValue !== undefined) {
|
|
||||||
initialValue = Promise.resolve(initialValue);
|
|
||||||
initialValue._attachCancellationCallback(this);
|
|
||||||
}
|
|
||||||
this._initialValue = initialValue;
|
|
||||||
this._currentCancellable = null;
|
|
||||||
if(_each === INTERNAL) {
|
|
||||||
this._eachValues = Array(this._length);
|
|
||||||
} else if (_each === 0) {
|
|
||||||
this._eachValues = null;
|
|
||||||
} else {
|
|
||||||
this._eachValues = undefined;
|
|
||||||
}
|
|
||||||
this._promise._captureStackTrace();
|
|
||||||
this._init$(undefined, -5);
|
|
||||||
}
|
|
||||||
util.inherits(ReductionPromiseArray, PromiseArray);
|
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._gotAccum = function(accum) {
|
|
||||||
if (this._eachValues !== undefined &&
|
|
||||||
this._eachValues !== null &&
|
|
||||||
accum !== INTERNAL) {
|
|
||||||
this._eachValues.push(accum);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._eachComplete = function(value) {
|
|
||||||
if (this._eachValues !== null) {
|
|
||||||
this._eachValues.push(value);
|
|
||||||
}
|
|
||||||
return this._eachValues;
|
|
||||||
};
|
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._init = function() {};
|
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._resolveEmptyArray = function() {
|
|
||||||
this._resolve(this._eachValues !== undefined ? this._eachValues
|
|
||||||
: this._initialValue);
|
|
||||||
};
|
|
||||||
|
|
||||||
ReductionPromiseArray.prototype.shouldCopyValues = function () {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._resolve = function(value) {
|
|
||||||
this._promise._resolveCallback(value);
|
|
||||||
this._values = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._resultCancelled = function(sender) {
|
|
||||||
if (sender === this._initialValue) return this._cancel();
|
|
||||||
if (this._isResolved()) return;
|
|
||||||
this._resultCancelled$();
|
|
||||||
if (this._currentCancellable instanceof Promise) {
|
|
||||||
this._currentCancellable.cancel();
|
|
||||||
}
|
|
||||||
if (this._initialValue instanceof Promise) {
|
|
||||||
this._initialValue.cancel();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ReductionPromiseArray.prototype._iterate = function (values) {
|
|
||||||
this._values = values;
|
|
||||||
var value;
|
|
||||||
var i;
|
|
||||||
var length = values.length;
|
|
||||||
if (this._initialValue !== undefined) {
|
|
||||||
value = this._initialValue;
|
|
||||||
i = 0;
|
|
||||||
} else {
|
|
||||||
value = Promise.resolve(values[0]);
|
|
||||||
i = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._currentCancellable = value;
|
|
||||||
|
|
||||||
for (var j = i; j < length; ++j) {
|
|
||||||
var maybePromise = values[j];
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
maybePromise.suppressUnhandledRejections();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!value.isRejected()) {
|
|
||||||
for (; i < length; ++i) {
|
|
||||||
var ctx = {
|
|
||||||
accum: null,
|
|
||||||
value: values[i],
|
|
||||||
index: i,
|
|
||||||
length: length,
|
|
||||||
array: this
|
|
||||||
};
|
|
||||||
|
|
||||||
value = value._then(gotAccum, undefined, undefined, ctx, undefined);
|
|
||||||
|
|
||||||
if ((i & 127) === 0) {
|
|
||||||
value._setNoAsyncGuarantee();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._eachValues !== undefined) {
|
|
||||||
value = value
|
|
||||||
._then(this._eachComplete, undefined, undefined, this, undefined);
|
|
||||||
}
|
|
||||||
value._then(completed, completed, undefined, value, this);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.reduce = function (fn, initialValue) {
|
|
||||||
return reduce(this, fn, initialValue, null);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.reduce = function (promises, fn, initialValue, _each) {
|
|
||||||
return reduce(promises, fn, initialValue, _each);
|
|
||||||
};
|
|
||||||
|
|
||||||
function completed(valueOrReason, array) {
|
|
||||||
if (this.isFulfilled()) {
|
|
||||||
array._resolve(valueOrReason);
|
|
||||||
} else {
|
|
||||||
array._reject(valueOrReason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function reduce(promises, fn, initialValue, _each) {
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
|
|
||||||
return array.promise();
|
|
||||||
}
|
|
||||||
|
|
||||||
function gotAccum(accum) {
|
|
||||||
this.accum = accum;
|
|
||||||
this.array._gotAccum(accum);
|
|
||||||
var value = tryConvertToPromise(this.value, this.array._promise);
|
|
||||||
if (value instanceof Promise) {
|
|
||||||
this.array._currentCancellable = value;
|
|
||||||
return value._then(gotValue, undefined, undefined, this, undefined);
|
|
||||||
} else {
|
|
||||||
return gotValue.call(this, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function gotValue(value) {
|
|
||||||
var array = this.array;
|
|
||||||
var promise = array._promise;
|
|
||||||
var fn = tryCatch(array._fn);
|
|
||||||
promise._pushContext();
|
|
||||||
var ret;
|
|
||||||
if (array._eachValues !== undefined) {
|
|
||||||
ret = fn.call(promise._boundValue(), value, this.index, this.length);
|
|
||||||
} else {
|
|
||||||
ret = fn.call(promise._boundValue(),
|
|
||||||
this.accum, value, this.index, this.length);
|
|
||||||
}
|
|
||||||
if (ret instanceof Promise) {
|
|
||||||
array._currentCancellable = ret;
|
|
||||||
}
|
|
||||||
var promiseCreated = promise._popContext();
|
|
||||||
debug.checkForgottenReturns(
|
|
||||||
ret,
|
|
||||||
promiseCreated,
|
|
||||||
array._eachValues !== undefined ? "Promise.each" : "Promise.reduce",
|
|
||||||
promise
|
|
||||||
);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
62
node_modules/bluebird/js/release/schedule.js
generated
vendored
62
node_modules/bluebird/js/release/schedule.js
generated
vendored
@@ -1,62 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var util = require("./util");
|
|
||||||
var schedule;
|
|
||||||
var noAsyncScheduler = function() {
|
|
||||||
throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
};
|
|
||||||
var NativePromise = util.getNativePromise();
|
|
||||||
if (util.isNode && typeof MutationObserver === "undefined") {
|
|
||||||
var GlobalSetImmediate = global.setImmediate;
|
|
||||||
var ProcessNextTick = process.nextTick;
|
|
||||||
schedule = util.isRecentNode
|
|
||||||
? function(fn) { GlobalSetImmediate.call(global, fn); }
|
|
||||||
: function(fn) { ProcessNextTick.call(process, fn); };
|
|
||||||
} else if (typeof NativePromise === "function" &&
|
|
||||||
typeof NativePromise.resolve === "function") {
|
|
||||||
var nativePromise = NativePromise.resolve();
|
|
||||||
schedule = function(fn) {
|
|
||||||
nativePromise.then(fn);
|
|
||||||
};
|
|
||||||
} else if ((typeof MutationObserver !== "undefined") &&
|
|
||||||
!(typeof window !== "undefined" &&
|
|
||||||
window.navigator &&
|
|
||||||
(window.navigator.standalone || window.cordova)) &&
|
|
||||||
("classList" in document.documentElement)) {
|
|
||||||
schedule = (function() {
|
|
||||||
var div = document.createElement("div");
|
|
||||||
var opts = {attributes: true};
|
|
||||||
var toggleScheduled = false;
|
|
||||||
var div2 = document.createElement("div");
|
|
||||||
var o2 = new MutationObserver(function() {
|
|
||||||
div.classList.toggle("foo");
|
|
||||||
toggleScheduled = false;
|
|
||||||
});
|
|
||||||
o2.observe(div2, opts);
|
|
||||||
|
|
||||||
var scheduleToggle = function() {
|
|
||||||
if (toggleScheduled) return;
|
|
||||||
toggleScheduled = true;
|
|
||||||
div2.classList.toggle("foo");
|
|
||||||
};
|
|
||||||
|
|
||||||
return function schedule(fn) {
|
|
||||||
var o = new MutationObserver(function() {
|
|
||||||
o.disconnect();
|
|
||||||
fn();
|
|
||||||
});
|
|
||||||
o.observe(div, opts);
|
|
||||||
scheduleToggle();
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
} else if (typeof setImmediate !== "undefined") {
|
|
||||||
schedule = function (fn) {
|
|
||||||
setImmediate(fn);
|
|
||||||
};
|
|
||||||
} else if (typeof setTimeout !== "undefined") {
|
|
||||||
schedule = function (fn) {
|
|
||||||
setTimeout(fn, 0);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
schedule = noAsyncScheduler;
|
|
||||||
}
|
|
||||||
module.exports = schedule;
|
|
||||||
47
node_modules/bluebird/js/release/settle.js
generated
vendored
47
node_modules/bluebird/js/release/settle.js
generated
vendored
@@ -1,47 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports =
|
|
||||||
function(Promise, PromiseArray, debug) {
|
|
||||||
var PromiseInspection = Promise.PromiseInspection;
|
|
||||||
var util = require("./util");
|
|
||||||
|
|
||||||
function SettledPromiseArray(values) {
|
|
||||||
this.constructor$(values);
|
|
||||||
}
|
|
||||||
util.inherits(SettledPromiseArray, PromiseArray);
|
|
||||||
|
|
||||||
SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
|
|
||||||
this._values[index] = inspection;
|
|
||||||
var totalResolved = ++this._totalResolved;
|
|
||||||
if (totalResolved >= this._length) {
|
|
||||||
this._resolve(this._values);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
|
|
||||||
var ret = new PromiseInspection();
|
|
||||||
ret._bitField = 33554432;
|
|
||||||
ret._settledValueField = value;
|
|
||||||
return this._promiseResolved(index, ret);
|
|
||||||
};
|
|
||||||
SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
|
|
||||||
var ret = new PromiseInspection();
|
|
||||||
ret._bitField = 16777216;
|
|
||||||
ret._settledValueField = reason;
|
|
||||||
return this._promiseResolved(index, ret);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.settle = function (promises) {
|
|
||||||
debug.deprecated(".settle()", ".reflect()");
|
|
||||||
return new SettledPromiseArray(promises).promise();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.allSettled = function (promises) {
|
|
||||||
return new SettledPromiseArray(promises).promise();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.settle = function () {
|
|
||||||
return Promise.settle(this);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
148
node_modules/bluebird/js/release/some.js
generated
vendored
148
node_modules/bluebird/js/release/some.js
generated
vendored
@@ -1,148 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports =
|
|
||||||
function(Promise, PromiseArray, apiRejection) {
|
|
||||||
var util = require("./util");
|
|
||||||
var RangeError = require("./errors").RangeError;
|
|
||||||
var AggregateError = require("./errors").AggregateError;
|
|
||||||
var isArray = util.isArray;
|
|
||||||
var CANCELLATION = {};
|
|
||||||
|
|
||||||
|
|
||||||
function SomePromiseArray(values) {
|
|
||||||
this.constructor$(values);
|
|
||||||
this._howMany = 0;
|
|
||||||
this._unwrap = false;
|
|
||||||
this._initialized = false;
|
|
||||||
}
|
|
||||||
util.inherits(SomePromiseArray, PromiseArray);
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._init = function () {
|
|
||||||
if (!this._initialized) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this._howMany === 0) {
|
|
||||||
this._resolve([]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._init$(undefined, -5);
|
|
||||||
var isArrayResolved = isArray(this._values);
|
|
||||||
if (!this._isResolved() &&
|
|
||||||
isArrayResolved &&
|
|
||||||
this._howMany > this._canPossiblyFulfill()) {
|
|
||||||
this._reject(this._getRangeError(this.length()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype.init = function () {
|
|
||||||
this._initialized = true;
|
|
||||||
this._init();
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype.setUnwrap = function () {
|
|
||||||
this._unwrap = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype.howMany = function () {
|
|
||||||
return this._howMany;
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype.setHowMany = function (count) {
|
|
||||||
this._howMany = count;
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._promiseFulfilled = function (value) {
|
|
||||||
this._addFulfilled(value);
|
|
||||||
if (this._fulfilled() === this.howMany()) {
|
|
||||||
this._values.length = this.howMany();
|
|
||||||
if (this.howMany() === 1 && this._unwrap) {
|
|
||||||
this._resolve(this._values[0]);
|
|
||||||
} else {
|
|
||||||
this._resolve(this._values);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
};
|
|
||||||
SomePromiseArray.prototype._promiseRejected = function (reason) {
|
|
||||||
this._addRejected(reason);
|
|
||||||
return this._checkOutcome();
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._promiseCancelled = function () {
|
|
||||||
if (this._values instanceof Promise || this._values == null) {
|
|
||||||
return this._cancel();
|
|
||||||
}
|
|
||||||
this._addRejected(CANCELLATION);
|
|
||||||
return this._checkOutcome();
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._checkOutcome = function() {
|
|
||||||
if (this.howMany() > this._canPossiblyFulfill()) {
|
|
||||||
var e = new AggregateError();
|
|
||||||
for (var i = this.length(); i < this._values.length; ++i) {
|
|
||||||
if (this._values[i] !== CANCELLATION) {
|
|
||||||
e.push(this._values[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.length > 0) {
|
|
||||||
this._reject(e);
|
|
||||||
} else {
|
|
||||||
this._cancel();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._fulfilled = function () {
|
|
||||||
return this._totalResolved;
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._rejected = function () {
|
|
||||||
return this._values.length - this.length();
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._addRejected = function (reason) {
|
|
||||||
this._values.push(reason);
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._addFulfilled = function (value) {
|
|
||||||
this._values[this._totalResolved++] = value;
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._canPossiblyFulfill = function () {
|
|
||||||
return this.length() - this._rejected();
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._getRangeError = function (count) {
|
|
||||||
var message = "Input array must contain at least " +
|
|
||||||
this._howMany + " items but contains only " + count + " items";
|
|
||||||
return new RangeError(message);
|
|
||||||
};
|
|
||||||
|
|
||||||
SomePromiseArray.prototype._resolveEmptyArray = function () {
|
|
||||||
this._reject(this._getRangeError(0));
|
|
||||||
};
|
|
||||||
|
|
||||||
function some(promises, howMany) {
|
|
||||||
if ((howMany | 0) !== howMany || howMany < 0) {
|
|
||||||
return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
var ret = new SomePromiseArray(promises);
|
|
||||||
var promise = ret.promise();
|
|
||||||
ret.setHowMany(howMany);
|
|
||||||
ret.init();
|
|
||||||
return promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.some = function (promises, howMany) {
|
|
||||||
return some(promises, howMany);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.some = function (howMany) {
|
|
||||||
return some(this, howMany);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise._SomePromiseArray = SomePromiseArray;
|
|
||||||
};
|
|
||||||
103
node_modules/bluebird/js/release/synchronous_inspection.js
generated
vendored
103
node_modules/bluebird/js/release/synchronous_inspection.js
generated
vendored
@@ -1,103 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise) {
|
|
||||||
function PromiseInspection(promise) {
|
|
||||||
if (promise !== undefined) {
|
|
||||||
promise = promise._target();
|
|
||||||
this._bitField = promise._bitField;
|
|
||||||
this._settledValueField = promise._isFateSealed()
|
|
||||||
? promise._settledValue() : undefined;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this._bitField = 0;
|
|
||||||
this._settledValueField = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PromiseInspection.prototype._settledValue = function() {
|
|
||||||
return this._settledValueField;
|
|
||||||
};
|
|
||||||
|
|
||||||
var value = PromiseInspection.prototype.value = function () {
|
|
||||||
if (!this.isFulfilled()) {
|
|
||||||
throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
return this._settledValue();
|
|
||||||
};
|
|
||||||
|
|
||||||
var reason = PromiseInspection.prototype.error =
|
|
||||||
PromiseInspection.prototype.reason = function () {
|
|
||||||
if (!this.isRejected()) {
|
|
||||||
throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
|
|
||||||
}
|
|
||||||
return this._settledValue();
|
|
||||||
};
|
|
||||||
|
|
||||||
var isFulfilled = PromiseInspection.prototype.isFulfilled = function() {
|
|
||||||
return (this._bitField & 33554432) !== 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
var isRejected = PromiseInspection.prototype.isRejected = function () {
|
|
||||||
return (this._bitField & 16777216) !== 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
var isPending = PromiseInspection.prototype.isPending = function () {
|
|
||||||
return (this._bitField & 50397184) === 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
var isResolved = PromiseInspection.prototype.isResolved = function () {
|
|
||||||
return (this._bitField & 50331648) !== 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
PromiseInspection.prototype.isCancelled = function() {
|
|
||||||
return (this._bitField & 8454144) !== 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.__isCancelled = function() {
|
|
||||||
return (this._bitField & 65536) === 65536;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._isCancelled = function() {
|
|
||||||
return this._target().__isCancelled();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.isCancelled = function() {
|
|
||||||
return (this._target()._bitField & 8454144) !== 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.isPending = function() {
|
|
||||||
return isPending.call(this._target());
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.isRejected = function() {
|
|
||||||
return isRejected.call(this._target());
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.isFulfilled = function() {
|
|
||||||
return isFulfilled.call(this._target());
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.isResolved = function() {
|
|
||||||
return isResolved.call(this._target());
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.value = function() {
|
|
||||||
return value.call(this._target());
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.reason = function() {
|
|
||||||
var target = this._target();
|
|
||||||
target._unsetRejectionIsUnhandled();
|
|
||||||
return reason.call(target);
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._value = function() {
|
|
||||||
return this._settledValue();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._reason = function() {
|
|
||||||
this._unsetRejectionIsUnhandled();
|
|
||||||
return this._settledValue();
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.PromiseInspection = PromiseInspection;
|
|
||||||
};
|
|
||||||
86
node_modules/bluebird/js/release/thenables.js
generated
vendored
86
node_modules/bluebird/js/release/thenables.js
generated
vendored
@@ -1,86 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, INTERNAL) {
|
|
||||||
var util = require("./util");
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
var isObject = util.isObject;
|
|
||||||
|
|
||||||
function tryConvertToPromise(obj, context) {
|
|
||||||
if (isObject(obj)) {
|
|
||||||
if (obj instanceof Promise) return obj;
|
|
||||||
var then = getThen(obj);
|
|
||||||
if (then === errorObj) {
|
|
||||||
if (context) context._pushContext();
|
|
||||||
var ret = Promise.reject(then.e);
|
|
||||||
if (context) context._popContext();
|
|
||||||
return ret;
|
|
||||||
} else if (typeof then === "function") {
|
|
||||||
if (isAnyBluebirdPromise(obj)) {
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
obj._then(
|
|
||||||
ret._fulfill,
|
|
||||||
ret._reject,
|
|
||||||
undefined,
|
|
||||||
ret,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return doThenable(obj, then, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function doGetThen(obj) {
|
|
||||||
return obj.then;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getThen(obj) {
|
|
||||||
try {
|
|
||||||
return doGetThen(obj);
|
|
||||||
} catch (e) {
|
|
||||||
errorObj.e = e;
|
|
||||||
return errorObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var hasProp = {}.hasOwnProperty;
|
|
||||||
function isAnyBluebirdPromise(obj) {
|
|
||||||
try {
|
|
||||||
return hasProp.call(obj, "_promise0");
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function doThenable(x, then, context) {
|
|
||||||
var promise = new Promise(INTERNAL);
|
|
||||||
var ret = promise;
|
|
||||||
if (context) context._pushContext();
|
|
||||||
promise._captureStackTrace();
|
|
||||||
if (context) context._popContext();
|
|
||||||
var synchronous = true;
|
|
||||||
var result = util.tryCatch(then).call(x, resolve, reject);
|
|
||||||
synchronous = false;
|
|
||||||
|
|
||||||
if (promise && result === errorObj) {
|
|
||||||
promise._rejectCallback(result.e, true, true);
|
|
||||||
promise = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolve(value) {
|
|
||||||
if (!promise) return;
|
|
||||||
promise._resolveCallback(value);
|
|
||||||
promise = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function reject(reason) {
|
|
||||||
if (!promise) return;
|
|
||||||
promise._rejectCallback(reason, synchronous, true);
|
|
||||||
promise = null;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tryConvertToPromise;
|
|
||||||
};
|
|
||||||
93
node_modules/bluebird/js/release/timers.js
generated
vendored
93
node_modules/bluebird/js/release/timers.js
generated
vendored
@@ -1,93 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function(Promise, INTERNAL, debug) {
|
|
||||||
var util = require("./util");
|
|
||||||
var TimeoutError = Promise.TimeoutError;
|
|
||||||
|
|
||||||
function HandleWrapper(handle) {
|
|
||||||
this.handle = handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleWrapper.prototype._resultCancelled = function() {
|
|
||||||
clearTimeout(this.handle);
|
|
||||||
};
|
|
||||||
|
|
||||||
var afterValue = function(value) { return delay(+this).thenReturn(value); };
|
|
||||||
var delay = Promise.delay = function (ms, value) {
|
|
||||||
var ret;
|
|
||||||
var handle;
|
|
||||||
if (value !== undefined) {
|
|
||||||
ret = Promise.resolve(value)
|
|
||||||
._then(afterValue, null, null, ms, undefined);
|
|
||||||
if (debug.cancellation() && value instanceof Promise) {
|
|
||||||
ret._setOnCancel(value);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret = new Promise(INTERNAL);
|
|
||||||
handle = setTimeout(function() { ret._fulfill(); }, +ms);
|
|
||||||
if (debug.cancellation()) {
|
|
||||||
ret._setOnCancel(new HandleWrapper(handle));
|
|
||||||
}
|
|
||||||
ret._captureStackTrace();
|
|
||||||
}
|
|
||||||
ret._setAsyncGuaranteed();
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.delay = function (ms) {
|
|
||||||
return delay(ms, this);
|
|
||||||
};
|
|
||||||
|
|
||||||
var afterTimeout = function (promise, message, parent) {
|
|
||||||
var err;
|
|
||||||
if (typeof message !== "string") {
|
|
||||||
if (message instanceof Error) {
|
|
||||||
err = message;
|
|
||||||
} else {
|
|
||||||
err = new TimeoutError("operation timed out");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
err = new TimeoutError(message);
|
|
||||||
}
|
|
||||||
util.markAsOriginatingFromRejection(err);
|
|
||||||
promise._attachExtraTrace(err);
|
|
||||||
promise._reject(err);
|
|
||||||
|
|
||||||
if (parent != null) {
|
|
||||||
parent.cancel();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function successClear(value) {
|
|
||||||
clearTimeout(this.handle);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
function failureClear(reason) {
|
|
||||||
clearTimeout(this.handle);
|
|
||||||
throw reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.prototype.timeout = function (ms, message) {
|
|
||||||
ms = +ms;
|
|
||||||
var ret, parent;
|
|
||||||
|
|
||||||
var handleWrapper = new HandleWrapper(setTimeout(function timeoutTimeout() {
|
|
||||||
if (ret.isPending()) {
|
|
||||||
afterTimeout(ret, message, parent);
|
|
||||||
}
|
|
||||||
}, ms));
|
|
||||||
|
|
||||||
if (debug.cancellation()) {
|
|
||||||
parent = this.then();
|
|
||||||
ret = parent._then(successClear, failureClear,
|
|
||||||
undefined, handleWrapper, undefined);
|
|
||||||
ret._setOnCancel(handleWrapper);
|
|
||||||
} else {
|
|
||||||
ret = this._then(successClear, failureClear,
|
|
||||||
undefined, handleWrapper, undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
226
node_modules/bluebird/js/release/using.js
generated
vendored
226
node_modules/bluebird/js/release/using.js
generated
vendored
@@ -1,226 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
module.exports = function (Promise, apiRejection, tryConvertToPromise,
|
|
||||||
createContext, INTERNAL, debug) {
|
|
||||||
var util = require("./util");
|
|
||||||
var TypeError = require("./errors").TypeError;
|
|
||||||
var inherits = require("./util").inherits;
|
|
||||||
var errorObj = util.errorObj;
|
|
||||||
var tryCatch = util.tryCatch;
|
|
||||||
var NULL = {};
|
|
||||||
|
|
||||||
function thrower(e) {
|
|
||||||
setTimeout(function(){throw e;}, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function castPreservingDisposable(thenable) {
|
|
||||||
var maybePromise = tryConvertToPromise(thenable);
|
|
||||||
if (maybePromise !== thenable &&
|
|
||||||
typeof thenable._isDisposable === "function" &&
|
|
||||||
typeof thenable._getDisposer === "function" &&
|
|
||||||
thenable._isDisposable()) {
|
|
||||||
maybePromise._setDisposable(thenable._getDisposer());
|
|
||||||
}
|
|
||||||
return maybePromise;
|
|
||||||
}
|
|
||||||
function dispose(resources, inspection) {
|
|
||||||
var i = 0;
|
|
||||||
var len = resources.length;
|
|
||||||
var ret = new Promise(INTERNAL);
|
|
||||||
function iterator() {
|
|
||||||
if (i >= len) return ret._fulfill();
|
|
||||||
var maybePromise = castPreservingDisposable(resources[i++]);
|
|
||||||
if (maybePromise instanceof Promise &&
|
|
||||||
maybePromise._isDisposable()) {
|
|
||||||
try {
|
|
||||||
maybePromise = tryConvertToPromise(
|
|
||||||
maybePromise._getDisposer().tryDispose(inspection),
|
|
||||||
resources.promise);
|
|
||||||
} catch (e) {
|
|
||||||
return thrower(e);
|
|
||||||
}
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
return maybePromise._then(iterator, thrower,
|
|
||||||
null, null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iterator();
|
|
||||||
}
|
|
||||||
iterator();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Disposer(data, promise, context) {
|
|
||||||
this._data = data;
|
|
||||||
this._promise = promise;
|
|
||||||
this._context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
Disposer.prototype.data = function () {
|
|
||||||
return this._data;
|
|
||||||
};
|
|
||||||
|
|
||||||
Disposer.prototype.promise = function () {
|
|
||||||
return this._promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
Disposer.prototype.resource = function () {
|
|
||||||
if (this.promise().isFulfilled()) {
|
|
||||||
return this.promise().value();
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
Disposer.prototype.tryDispose = function(inspection) {
|
|
||||||
var resource = this.resource();
|
|
||||||
var context = this._context;
|
|
||||||
if (context !== undefined) context._pushContext();
|
|
||||||
var ret = resource !== NULL
|
|
||||||
? this.doDispose(resource, inspection) : null;
|
|
||||||
if (context !== undefined) context._popContext();
|
|
||||||
this._promise._unsetDisposable();
|
|
||||||
this._data = null;
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
Disposer.isDisposer = function (d) {
|
|
||||||
return (d != null &&
|
|
||||||
typeof d.resource === "function" &&
|
|
||||||
typeof d.tryDispose === "function");
|
|
||||||
};
|
|
||||||
|
|
||||||
function FunctionDisposer(fn, promise, context) {
|
|
||||||
this.constructor$(fn, promise, context);
|
|
||||||
}
|
|
||||||
inherits(FunctionDisposer, Disposer);
|
|
||||||
|
|
||||||
FunctionDisposer.prototype.doDispose = function (resource, inspection) {
|
|
||||||
var fn = this.data();
|
|
||||||
return fn.call(resource, resource, inspection);
|
|
||||||
};
|
|
||||||
|
|
||||||
function maybeUnwrapDisposer(value) {
|
|
||||||
if (Disposer.isDisposer(value)) {
|
|
||||||
this.resources[this.index]._setDisposable(value);
|
|
||||||
return value.promise();
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ResourceList(length) {
|
|
||||||
this.length = length;
|
|
||||||
this.promise = null;
|
|
||||||
this[length-1] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceList.prototype._resultCancelled = function() {
|
|
||||||
var len = this.length;
|
|
||||||
for (var i = 0; i < len; ++i) {
|
|
||||||
var item = this[i];
|
|
||||||
if (item instanceof Promise) {
|
|
||||||
item.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.using = function () {
|
|
||||||
var len = arguments.length;
|
|
||||||
if (len < 2) return apiRejection(
|
|
||||||
"you must pass at least 2 arguments to Promise.using");
|
|
||||||
var fn = arguments[len - 1];
|
|
||||||
if (typeof fn !== "function") {
|
|
||||||
return apiRejection("expecting a function but got " + util.classString(fn));
|
|
||||||
}
|
|
||||||
var input;
|
|
||||||
var spreadArgs = true;
|
|
||||||
if (len === 2 && Array.isArray(arguments[0])) {
|
|
||||||
input = arguments[0];
|
|
||||||
len = input.length;
|
|
||||||
spreadArgs = false;
|
|
||||||
} else {
|
|
||||||
input = arguments;
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
var resources = new ResourceList(len);
|
|
||||||
for (var i = 0; i < len; ++i) {
|
|
||||||
var resource = input[i];
|
|
||||||
if (Disposer.isDisposer(resource)) {
|
|
||||||
var disposer = resource;
|
|
||||||
resource = resource.promise();
|
|
||||||
resource._setDisposable(disposer);
|
|
||||||
} else {
|
|
||||||
var maybePromise = tryConvertToPromise(resource);
|
|
||||||
if (maybePromise instanceof Promise) {
|
|
||||||
resource =
|
|
||||||
maybePromise._then(maybeUnwrapDisposer, null, null, {
|
|
||||||
resources: resources,
|
|
||||||
index: i
|
|
||||||
}, undefined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resources[i] = resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
var reflectedResources = new Array(resources.length);
|
|
||||||
for (var i = 0; i < reflectedResources.length; ++i) {
|
|
||||||
reflectedResources[i] = Promise.resolve(resources[i]).reflect();
|
|
||||||
}
|
|
||||||
|
|
||||||
var resultPromise = Promise.all(reflectedResources)
|
|
||||||
.then(function(inspections) {
|
|
||||||
for (var i = 0; i < inspections.length; ++i) {
|
|
||||||
var inspection = inspections[i];
|
|
||||||
if (inspection.isRejected()) {
|
|
||||||
errorObj.e = inspection.error();
|
|
||||||
return errorObj;
|
|
||||||
} else if (!inspection.isFulfilled()) {
|
|
||||||
resultPromise.cancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
inspections[i] = inspection.value();
|
|
||||||
}
|
|
||||||
promise._pushContext();
|
|
||||||
|
|
||||||
fn = tryCatch(fn);
|
|
||||||
var ret = spreadArgs
|
|
||||||
? fn.apply(undefined, inspections) : fn(inspections);
|
|
||||||
var promiseCreated = promise._popContext();
|
|
||||||
debug.checkForgottenReturns(
|
|
||||||
ret, promiseCreated, "Promise.using", promise);
|
|
||||||
return ret;
|
|
||||||
});
|
|
||||||
|
|
||||||
var promise = resultPromise.lastly(function() {
|
|
||||||
var inspection = new Promise.PromiseInspection(resultPromise);
|
|
||||||
return dispose(resources, inspection);
|
|
||||||
});
|
|
||||||
resources.promise = promise;
|
|
||||||
promise._setOnCancel(resources);
|
|
||||||
return promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._setDisposable = function (disposer) {
|
|
||||||
this._bitField = this._bitField | 131072;
|
|
||||||
this._disposer = disposer;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._isDisposable = function () {
|
|
||||||
return (this._bitField & 131072) > 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._getDisposer = function () {
|
|
||||||
return this._disposer;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype._unsetDisposable = function () {
|
|
||||||
this._bitField = this._bitField & (~131072);
|
|
||||||
this._disposer = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
Promise.prototype.disposer = function (fn) {
|
|
||||||
if (typeof fn === "function") {
|
|
||||||
return new FunctionDisposer(fn, this, createContext());
|
|
||||||
}
|
|
||||||
throw new TypeError();
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
421
node_modules/bluebird/js/release/util.js
generated
vendored
421
node_modules/bluebird/js/release/util.js
generated
vendored
@@ -1,421 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var es5 = require("./es5");
|
|
||||||
var canEvaluate = typeof navigator == "undefined";
|
|
||||||
|
|
||||||
var errorObj = {e: {}};
|
|
||||||
var tryCatchTarget;
|
|
||||||
var globalObject = typeof self !== "undefined" ? self :
|
|
||||||
typeof window !== "undefined" ? window :
|
|
||||||
typeof global !== "undefined" ? global :
|
|
||||||
this !== undefined ? this : null;
|
|
||||||
|
|
||||||
function tryCatcher() {
|
|
||||||
try {
|
|
||||||
var target = tryCatchTarget;
|
|
||||||
tryCatchTarget = null;
|
|
||||||
return target.apply(this, arguments);
|
|
||||||
} catch (e) {
|
|
||||||
errorObj.e = e;
|
|
||||||
return errorObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function tryCatch(fn) {
|
|
||||||
tryCatchTarget = fn;
|
|
||||||
return tryCatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
var inherits = function(Child, Parent) {
|
|
||||||
var hasProp = {}.hasOwnProperty;
|
|
||||||
|
|
||||||
function T() {
|
|
||||||
this.constructor = Child;
|
|
||||||
this.constructor$ = Parent;
|
|
||||||
for (var propertyName in Parent.prototype) {
|
|
||||||
if (hasProp.call(Parent.prototype, propertyName) &&
|
|
||||||
propertyName.charAt(propertyName.length-1) !== "$"
|
|
||||||
) {
|
|
||||||
this[propertyName + "$"] = Parent.prototype[propertyName];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
T.prototype = Parent.prototype;
|
|
||||||
Child.prototype = new T();
|
|
||||||
return Child.prototype;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function isPrimitive(val) {
|
|
||||||
return val == null || val === true || val === false ||
|
|
||||||
typeof val === "string" || typeof val === "number";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function isObject(value) {
|
|
||||||
return typeof value === "function" ||
|
|
||||||
typeof value === "object" && value !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function maybeWrapAsError(maybeError) {
|
|
||||||
if (!isPrimitive(maybeError)) return maybeError;
|
|
||||||
|
|
||||||
return new Error(safeToString(maybeError));
|
|
||||||
}
|
|
||||||
|
|
||||||
function withAppended(target, appendee) {
|
|
||||||
var len = target.length;
|
|
||||||
var ret = new Array(len + 1);
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < len; ++i) {
|
|
||||||
ret[i] = target[i];
|
|
||||||
}
|
|
||||||
ret[i] = appendee;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDataPropertyOrDefault(obj, key, defaultValue) {
|
|
||||||
if (es5.isES5) {
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
||||||
|
|
||||||
if (desc != null) {
|
|
||||||
return desc.get == null && desc.set == null
|
|
||||||
? desc.value
|
|
||||||
: defaultValue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function notEnumerableProp(obj, name, value) {
|
|
||||||
if (isPrimitive(obj)) return obj;
|
|
||||||
var descriptor = {
|
|
||||||
value: value,
|
|
||||||
configurable: true,
|
|
||||||
enumerable: false,
|
|
||||||
writable: true
|
|
||||||
};
|
|
||||||
es5.defineProperty(obj, name, descriptor);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function thrower(r) {
|
|
||||||
throw r;
|
|
||||||
}
|
|
||||||
|
|
||||||
var inheritedDataKeys = (function() {
|
|
||||||
var excludedPrototypes = [
|
|
||||||
Array.prototype,
|
|
||||||
Object.prototype,
|
|
||||||
Function.prototype
|
|
||||||
];
|
|
||||||
|
|
||||||
var isExcludedProto = function(val) {
|
|
||||||
for (var i = 0; i < excludedPrototypes.length; ++i) {
|
|
||||||
if (excludedPrototypes[i] === val) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (es5.isES5) {
|
|
||||||
var getKeys = Object.getOwnPropertyNames;
|
|
||||||
return function(obj) {
|
|
||||||
var ret = [];
|
|
||||||
var visitedKeys = Object.create(null);
|
|
||||||
while (obj != null && !isExcludedProto(obj)) {
|
|
||||||
var keys;
|
|
||||||
try {
|
|
||||||
keys = getKeys(obj);
|
|
||||||
} catch (e) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
for (var i = 0; i < keys.length; ++i) {
|
|
||||||
var key = keys[i];
|
|
||||||
if (visitedKeys[key]) continue;
|
|
||||||
visitedKeys[key] = true;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
||||||
if (desc != null && desc.get == null && desc.set == null) {
|
|
||||||
ret.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
obj = es5.getPrototypeOf(obj);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
var hasProp = {}.hasOwnProperty;
|
|
||||||
return function(obj) {
|
|
||||||
if (isExcludedProto(obj)) return [];
|
|
||||||
var ret = [];
|
|
||||||
|
|
||||||
/*jshint forin:false */
|
|
||||||
enumeration: for (var key in obj) {
|
|
||||||
if (hasProp.call(obj, key)) {
|
|
||||||
ret.push(key);
|
|
||||||
} else {
|
|
||||||
for (var i = 0; i < excludedPrototypes.length; ++i) {
|
|
||||||
if (hasProp.call(excludedPrototypes[i], key)) {
|
|
||||||
continue enumeration;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
|
|
||||||
function isClass(fn) {
|
|
||||||
try {
|
|
||||||
if (typeof fn === "function") {
|
|
||||||
var keys = es5.names(fn.prototype);
|
|
||||||
|
|
||||||
var hasMethods = es5.isES5 && keys.length > 1;
|
|
||||||
var hasMethodsOtherThanConstructor = keys.length > 0 &&
|
|
||||||
!(keys.length === 1 && keys[0] === "constructor");
|
|
||||||
var hasThisAssignmentAndStaticMethods =
|
|
||||||
thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
|
|
||||||
|
|
||||||
if (hasMethods || hasMethodsOtherThanConstructor ||
|
|
||||||
hasThisAssignmentAndStaticMethods) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toFastProperties(obj) {
|
|
||||||
/*jshint -W027,-W055,-W031*/
|
|
||||||
function FakeConstructor() {}
|
|
||||||
FakeConstructor.prototype = obj;
|
|
||||||
var receiver = new FakeConstructor();
|
|
||||||
function ic() {
|
|
||||||
return typeof receiver.foo;
|
|
||||||
}
|
|
||||||
ic();
|
|
||||||
ic();
|
|
||||||
return obj;
|
|
||||||
eval(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
var rident = /^[a-z$_][a-z$_0-9]*$/i;
|
|
||||||
function isIdentifier(str) {
|
|
||||||
return rident.test(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
function filledRange(count, prefix, suffix) {
|
|
||||||
var ret = new Array(count);
|
|
||||||
for(var i = 0; i < count; ++i) {
|
|
||||||
ret[i] = prefix + i + suffix;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function safeToString(obj) {
|
|
||||||
try {
|
|
||||||
return obj + "";
|
|
||||||
} catch (e) {
|
|
||||||
return "[no string representation]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isError(obj) {
|
|
||||||
return obj instanceof Error ||
|
|
||||||
(obj !== null &&
|
|
||||||
typeof obj === "object" &&
|
|
||||||
typeof obj.message === "string" &&
|
|
||||||
typeof obj.name === "string");
|
|
||||||
}
|
|
||||||
|
|
||||||
function markAsOriginatingFromRejection(e) {
|
|
||||||
try {
|
|
||||||
notEnumerableProp(e, "isOperational", true);
|
|
||||||
}
|
|
||||||
catch(ignore) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
function originatesFromRejection(e) {
|
|
||||||
if (e == null) return false;
|
|
||||||
return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
|
|
||||||
e["isOperational"] === true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function canAttachTrace(obj) {
|
|
||||||
return isError(obj) && es5.propertyIsWritable(obj, "stack");
|
|
||||||
}
|
|
||||||
|
|
||||||
var ensureErrorObject = (function() {
|
|
||||||
if (!("stack" in new Error())) {
|
|
||||||
return function(value) {
|
|
||||||
if (canAttachTrace(value)) return value;
|
|
||||||
try {throw new Error(safeToString(value));}
|
|
||||||
catch(err) {return err;}
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return function(value) {
|
|
||||||
if (canAttachTrace(value)) return value;
|
|
||||||
return new Error(safeToString(value));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
function classString(obj) {
|
|
||||||
return {}.toString.call(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyDescriptors(from, to, filter) {
|
|
||||||
var keys = es5.names(from);
|
|
||||||
for (var i = 0; i < keys.length; ++i) {
|
|
||||||
var key = keys[i];
|
|
||||||
if (filter(key)) {
|
|
||||||
try {
|
|
||||||
es5.defineProperty(to, key, es5.getDescriptor(from, key));
|
|
||||||
} catch (ignore) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var asArray = function(v) {
|
|
||||||
if (es5.isArray(v)) {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (typeof Symbol !== "undefined" && Symbol.iterator) {
|
|
||||||
var ArrayFrom = typeof Array.from === "function" ? function(v) {
|
|
||||||
return Array.from(v);
|
|
||||||
} : function(v) {
|
|
||||||
var ret = [];
|
|
||||||
var it = v[Symbol.iterator]();
|
|
||||||
var itResult;
|
|
||||||
while (!((itResult = it.next()).done)) {
|
|
||||||
ret.push(itResult.value);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
asArray = function(v) {
|
|
||||||
if (es5.isArray(v)) {
|
|
||||||
return v;
|
|
||||||
} else if (v != null && typeof v[Symbol.iterator] === "function") {
|
|
||||||
return ArrayFrom(v);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var isNode = typeof process !== "undefined" &&
|
|
||||||
classString(process).toLowerCase() === "[object process]";
|
|
||||||
|
|
||||||
var hasEnvVariables = typeof process !== "undefined" &&
|
|
||||||
typeof process.env !== "undefined";
|
|
||||||
|
|
||||||
function env(key) {
|
|
||||||
return hasEnvVariables ? process.env[key] : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNativePromise() {
|
|
||||||
if (typeof Promise === "function") {
|
|
||||||
try {
|
|
||||||
var promise = new Promise(function(){});
|
|
||||||
if (classString(promise) === "[object Promise]") {
|
|
||||||
return Promise;
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var reflectHandler;
|
|
||||||
function contextBind(ctx, cb) {
|
|
||||||
if (ctx === null ||
|
|
||||||
typeof cb !== "function" ||
|
|
||||||
cb === reflectHandler) {
|
|
||||||
return cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx.domain !== null) {
|
|
||||||
cb = ctx.domain.bind(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
var async = ctx.async;
|
|
||||||
if (async !== null) {
|
|
||||||
var old = cb;
|
|
||||||
cb = function() {
|
|
||||||
var $_len = arguments.length + 2;var args = new Array($_len); for(var $_i = 2; $_i < $_len ; ++$_i) {args[$_i] = arguments[$_i - 2];};
|
|
||||||
args[0] = old;
|
|
||||||
args[1] = this;
|
|
||||||
return async.runInAsyncScope.apply(async, args);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
var ret = {
|
|
||||||
setReflectHandler: function(fn) {
|
|
||||||
reflectHandler = fn;
|
|
||||||
},
|
|
||||||
isClass: isClass,
|
|
||||||
isIdentifier: isIdentifier,
|
|
||||||
inheritedDataKeys: inheritedDataKeys,
|
|
||||||
getDataPropertyOrDefault: getDataPropertyOrDefault,
|
|
||||||
thrower: thrower,
|
|
||||||
isArray: es5.isArray,
|
|
||||||
asArray: asArray,
|
|
||||||
notEnumerableProp: notEnumerableProp,
|
|
||||||
isPrimitive: isPrimitive,
|
|
||||||
isObject: isObject,
|
|
||||||
isError: isError,
|
|
||||||
canEvaluate: canEvaluate,
|
|
||||||
errorObj: errorObj,
|
|
||||||
tryCatch: tryCatch,
|
|
||||||
inherits: inherits,
|
|
||||||
withAppended: withAppended,
|
|
||||||
maybeWrapAsError: maybeWrapAsError,
|
|
||||||
toFastProperties: toFastProperties,
|
|
||||||
filledRange: filledRange,
|
|
||||||
toString: safeToString,
|
|
||||||
canAttachTrace: canAttachTrace,
|
|
||||||
ensureErrorObject: ensureErrorObject,
|
|
||||||
originatesFromRejection: originatesFromRejection,
|
|
||||||
markAsOriginatingFromRejection: markAsOriginatingFromRejection,
|
|
||||||
classString: classString,
|
|
||||||
copyDescriptors: copyDescriptors,
|
|
||||||
isNode: isNode,
|
|
||||||
hasEnvVariables: hasEnvVariables,
|
|
||||||
env: env,
|
|
||||||
global: globalObject,
|
|
||||||
getNativePromise: getNativePromise,
|
|
||||||
contextBind: contextBind
|
|
||||||
};
|
|
||||||
ret.isRecentNode = ret.isNode && (function() {
|
|
||||||
var version;
|
|
||||||
if (process.versions && process.versions.node) {
|
|
||||||
version = process.versions.node.split(".").map(Number);
|
|
||||||
} else if (process.version) {
|
|
||||||
version = process.version.split(".").map(Number);
|
|
||||||
}
|
|
||||||
return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
|
|
||||||
})();
|
|
||||||
ret.nodeSupportsAsyncResource = ret.isNode && (function() {
|
|
||||||
var supportsAsync = false;
|
|
||||||
try {
|
|
||||||
var res = require("async_hooks").AsyncResource;
|
|
||||||
supportsAsync = typeof res.prototype.runInAsyncScope === "function";
|
|
||||||
} catch (e) {
|
|
||||||
supportsAsync = false;
|
|
||||||
}
|
|
||||||
return supportsAsync;
|
|
||||||
})();
|
|
||||||
|
|
||||||
if (ret.isNode) ret.toFastProperties(process);
|
|
||||||
|
|
||||||
try {throw new Error(); } catch (e) {ret.lastLineError = e;}
|
|
||||||
module.exports = ret;
|
|
||||||
78
node_modules/bluebird/package.json
generated
vendored
78
node_modules/bluebird/package.json
generated
vendored
@@ -1,78 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "bluebird",
|
|
||||||
"description": "Full featured Promises/A+ implementation with exceptionally good performance",
|
|
||||||
"version": "3.7.2",
|
|
||||||
"keywords": [
|
|
||||||
"promise",
|
|
||||||
"performance",
|
|
||||||
"promises",
|
|
||||||
"promises-a",
|
|
||||||
"promises-aplus",
|
|
||||||
"async",
|
|
||||||
"await",
|
|
||||||
"deferred",
|
|
||||||
"deferreds",
|
|
||||||
"future",
|
|
||||||
"flow control",
|
|
||||||
"dsl",
|
|
||||||
"fluent interface"
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"lint": "node scripts/jshint.js",
|
|
||||||
"test": "node --expose-gc tools/test.js",
|
|
||||||
"istanbul": "istanbul",
|
|
||||||
"prepublish": "npm run generate-browser-core && npm run generate-browser-full",
|
|
||||||
"generate-browser-full": "node tools/build.js --no-clean --no-debug --release --browser --minify",
|
|
||||||
"generate-browser-core": "node tools/build.js --features=core --no-debug --release --zalgo --browser --minify && mv js/browser/bluebird.js js/browser/bluebird.core.js && mv js/browser/bluebird.min.js js/browser/bluebird.core.min.js"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/petkaantonov/bluebird",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/petkaantonov/bluebird.git"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "http://github.com/petkaantonov/bluebird/issues"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"author": {
|
|
||||||
"name": "Petka Antonov",
|
|
||||||
"email": "petka_antonov@hotmail.com",
|
|
||||||
"url": "http://github.com/petkaantonov/"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"acorn": "^6.0.2",
|
|
||||||
"acorn-walk": "^6.1.0",
|
|
||||||
"baconjs": "^0.7.43",
|
|
||||||
"bluebird": "^2.9.2",
|
|
||||||
"body-parser": "^1.10.2",
|
|
||||||
"browserify": "^8.1.1",
|
|
||||||
"cli-table": "~0.3.1",
|
|
||||||
"co": "^4.2.0",
|
|
||||||
"cross-spawn": "^0.2.3",
|
|
||||||
"glob": "^4.3.2",
|
|
||||||
"grunt-saucelabs": "~8.4.1",
|
|
||||||
"highland": "^2.3.0",
|
|
||||||
"istanbul": "^0.3.5",
|
|
||||||
"jshint": "^2.6.0",
|
|
||||||
"jshint-stylish": "~0.2.0",
|
|
||||||
"kefir": "^2.4.1",
|
|
||||||
"mkdirp": "~0.5.0",
|
|
||||||
"mocha": "~2.1",
|
|
||||||
"open": "~0.0.5",
|
|
||||||
"optimist": "~0.6.1",
|
|
||||||
"rimraf": "~2.2.6",
|
|
||||||
"rx": "^2.3.25",
|
|
||||||
"serve-static": "^1.7.1",
|
|
||||||
"sinon": "~1.7.3",
|
|
||||||
"uglify-js": "~2.4.16"
|
|
||||||
},
|
|
||||||
"readmeFilename": "README.md",
|
|
||||||
"main": "./js/release/bluebird.js",
|
|
||||||
"webpack": "./js/release/bluebird.js",
|
|
||||||
"browser": "./js/browser/bluebird.js",
|
|
||||||
"files": [
|
|
||||||
"js/browser",
|
|
||||||
"js/release",
|
|
||||||
"LICENSE"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
2
node_modules/brace-expansion/.github/FUNDING.yml
generated
vendored
2
node_modules/brace-expansion/.github/FUNDING.yml
generated
vendored
@@ -1,2 +0,0 @@
|
|||||||
tidelift: "npm/brace-expansion"
|
|
||||||
patreon: juliangruber
|
|
||||||
21
node_modules/brace-expansion/LICENSE
generated
vendored
21
node_modules/brace-expansion/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
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.
|
|
||||||
135
node_modules/brace-expansion/README.md
generated
vendored
135
node_modules/brace-expansion/README.md
generated
vendored
@@ -1,135 +0,0 @@
|
|||||||
# brace-expansion
|
|
||||||
|
|
||||||
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
|
|
||||||
as known from sh/bash, in JavaScript.
|
|
||||||
|
|
||||||
[](http://travis-ci.org/juliangruber/brace-expansion)
|
|
||||||
[](https://www.npmjs.org/package/brace-expansion)
|
|
||||||
[](https://greenkeeper.io/)
|
|
||||||
|
|
||||||
[](https://ci.testling.com/juliangruber/brace-expansion)
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
var expand = require('brace-expansion');
|
|
||||||
|
|
||||||
expand('file-{a,b,c}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
|
||||||
|
|
||||||
expand('-v{,,}')
|
|
||||||
// => ['-v', '-v', '-v']
|
|
||||||
|
|
||||||
expand('file{0..2}.jpg')
|
|
||||||
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
|
|
||||||
|
|
||||||
expand('file-{a..c}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
|
||||||
|
|
||||||
expand('file{2..0}.jpg')
|
|
||||||
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
|
|
||||||
|
|
||||||
expand('file{0..4..2}.jpg')
|
|
||||||
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
|
|
||||||
|
|
||||||
expand('file-{a..e..2}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
|
|
||||||
|
|
||||||
expand('file{00..10..5}.jpg')
|
|
||||||
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
|
|
||||||
|
|
||||||
expand('{{A..C},{a..c}}')
|
|
||||||
// => ['A', 'B', 'C', 'a', 'b', 'c']
|
|
||||||
|
|
||||||
expand('ppp{,config,oe{,conf}}')
|
|
||||||
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
```js
|
|
||||||
var expand = require('brace-expansion');
|
|
||||||
```
|
|
||||||
|
|
||||||
### var expanded = expand(str)
|
|
||||||
|
|
||||||
Return an array of all possible and valid expansions of `str`. If none are
|
|
||||||
found, `[str]` is returned.
|
|
||||||
|
|
||||||
Valid expansions are:
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^(.*,)+(.+)?$/
|
|
||||||
// {a,b,...}
|
|
||||||
```
|
|
||||||
|
|
||||||
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
|
||||||
// {x..y[..incr]}
|
|
||||||
```
|
|
||||||
|
|
||||||
A numeric sequence from `x` to `y` inclusive, with optional increment.
|
|
||||||
If `x` or `y` start with a leading `0`, all the numbers will be padded
|
|
||||||
to have equal length. Negative numbers and backwards iteration work too.
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
|
||||||
// {x..y[..incr]}
|
|
||||||
```
|
|
||||||
|
|
||||||
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
|
|
||||||
`x` and `y` must be exactly one character, and if given, `incr` must be a
|
|
||||||
number.
|
|
||||||
|
|
||||||
For compatibility reasons, the string `${` is not eligible for brace expansion.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
With [npm](https://npmjs.org) do:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install brace-expansion
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
- [Julian Gruber](https://github.com/juliangruber)
|
|
||||||
- [Isaac Z. Schlueter](https://github.com/isaacs)
|
|
||||||
|
|
||||||
## Sponsors
|
|
||||||
|
|
||||||
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
|
|
||||||
|
|
||||||
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
|
|
||||||
|
|
||||||
## Security contact information
|
|
||||||
|
|
||||||
To report a security vulnerability, please use the
|
|
||||||
[Tidelift security contact](https://tidelift.com/security).
|
|
||||||
Tidelift will coordinate the fix and disclosure.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
(MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
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.
|
|
||||||
203
node_modules/brace-expansion/index.js
generated
vendored
203
node_modules/brace-expansion/index.js
generated
vendored
@@ -1,203 +0,0 @@
|
|||||||
var balanced = require('balanced-match');
|
|
||||||
|
|
||||||
module.exports = expandTop;
|
|
||||||
|
|
||||||
var escSlash = '\0SLASH'+Math.random()+'\0';
|
|
||||||
var escOpen = '\0OPEN'+Math.random()+'\0';
|
|
||||||
var escClose = '\0CLOSE'+Math.random()+'\0';
|
|
||||||
var escComma = '\0COMMA'+Math.random()+'\0';
|
|
||||||
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
|
||||||
|
|
||||||
function numeric(str) {
|
|
||||||
return parseInt(str, 10) == str
|
|
||||||
? parseInt(str, 10)
|
|
||||||
: str.charCodeAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapeBraces(str) {
|
|
||||||
return str.split('\\\\').join(escSlash)
|
|
||||||
.split('\\{').join(escOpen)
|
|
||||||
.split('\\}').join(escClose)
|
|
||||||
.split('\\,').join(escComma)
|
|
||||||
.split('\\.').join(escPeriod);
|
|
||||||
}
|
|
||||||
|
|
||||||
function unescapeBraces(str) {
|
|
||||||
return str.split(escSlash).join('\\')
|
|
||||||
.split(escOpen).join('{')
|
|
||||||
.split(escClose).join('}')
|
|
||||||
.split(escComma).join(',')
|
|
||||||
.split(escPeriod).join('.');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Basically just str.split(","), but handling cases
|
|
||||||
// where we have nested braced sections, which should be
|
|
||||||
// treated as individual members, like {a,{b,c},d}
|
|
||||||
function parseCommaParts(str) {
|
|
||||||
if (!str)
|
|
||||||
return [''];
|
|
||||||
|
|
||||||
var parts = [];
|
|
||||||
var m = balanced('{', '}', str);
|
|
||||||
|
|
||||||
if (!m)
|
|
||||||
return str.split(',');
|
|
||||||
|
|
||||||
var pre = m.pre;
|
|
||||||
var body = m.body;
|
|
||||||
var post = m.post;
|
|
||||||
var p = pre.split(',');
|
|
||||||
|
|
||||||
p[p.length-1] += '{' + body + '}';
|
|
||||||
var postParts = parseCommaParts(post);
|
|
||||||
if (post.length) {
|
|
||||||
p[p.length-1] += postParts.shift();
|
|
||||||
p.push.apply(p, postParts);
|
|
||||||
}
|
|
||||||
|
|
||||||
parts.push.apply(parts, p);
|
|
||||||
|
|
||||||
return parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
function expandTop(str) {
|
|
||||||
if (!str)
|
|
||||||
return [];
|
|
||||||
|
|
||||||
// I don't know why Bash 4.3 does this, but it does.
|
|
||||||
// Anything starting with {} will have the first two bytes preserved
|
|
||||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
||||||
// but a{},b}c will be expanded to [a}c,abc].
|
|
||||||
// One could argue that this is a bug in Bash, but since the goal of
|
|
||||||
// this module is to match Bash's rules, we escape a leading {}
|
|
||||||
if (str.substr(0, 2) === '{}') {
|
|
||||||
str = '\\{\\}' + str.substr(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return expand(escapeBraces(str), true).map(unescapeBraces);
|
|
||||||
}
|
|
||||||
|
|
||||||
function embrace(str) {
|
|
||||||
return '{' + str + '}';
|
|
||||||
}
|
|
||||||
function isPadded(el) {
|
|
||||||
return /^-?0\d/.test(el);
|
|
||||||
}
|
|
||||||
|
|
||||||
function lte(i, y) {
|
|
||||||
return i <= y;
|
|
||||||
}
|
|
||||||
function gte(i, y) {
|
|
||||||
return i >= y;
|
|
||||||
}
|
|
||||||
|
|
||||||
function expand(str, isTop) {
|
|
||||||
var expansions = [];
|
|
||||||
|
|
||||||
var m = balanced('{', '}', str);
|
|
||||||
if (!m) return [str];
|
|
||||||
|
|
||||||
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
||||||
var pre = m.pre;
|
|
||||||
var post = m.post.length
|
|
||||||
? expand(m.post, false)
|
|
||||||
: [''];
|
|
||||||
|
|
||||||
if (/\$$/.test(m.pre)) {
|
|
||||||
for (var k = 0; k < post.length; k++) {
|
|
||||||
var expansion = pre+ '{' + m.body + '}' + post[k];
|
|
||||||
expansions.push(expansion);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
||||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
||||||
var isSequence = isNumericSequence || isAlphaSequence;
|
|
||||||
var isOptions = m.body.indexOf(',') >= 0;
|
|
||||||
if (!isSequence && !isOptions) {
|
|
||||||
// {a},b}
|
|
||||||
if (m.post.match(/,.*\}/)) {
|
|
||||||
str = m.pre + '{' + m.body + escClose + m.post;
|
|
||||||
return expand(str);
|
|
||||||
}
|
|
||||||
return [str];
|
|
||||||
}
|
|
||||||
|
|
||||||
var n;
|
|
||||||
if (isSequence) {
|
|
||||||
n = m.body.split(/\.\./);
|
|
||||||
} else {
|
|
||||||
n = parseCommaParts(m.body);
|
|
||||||
if (n.length === 1) {
|
|
||||||
// x{{a,b}}y ==> x{a}y x{b}y
|
|
||||||
n = expand(n[0], false).map(embrace);
|
|
||||||
if (n.length === 1) {
|
|
||||||
return post.map(function(p) {
|
|
||||||
return m.pre + n[0] + p;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// at this point, n is the parts, and we know it's not a comma set
|
|
||||||
// with a single entry.
|
|
||||||
var N;
|
|
||||||
|
|
||||||
if (isSequence) {
|
|
||||||
var x = numeric(n[0]);
|
|
||||||
var y = numeric(n[1]);
|
|
||||||
var width = Math.max(n[0].length, n[1].length)
|
|
||||||
var incr = n.length == 3
|
|
||||||
? Math.abs(numeric(n[2]))
|
|
||||||
: 1;
|
|
||||||
var test = lte;
|
|
||||||
var reverse = y < x;
|
|
||||||
if (reverse) {
|
|
||||||
incr *= -1;
|
|
||||||
test = gte;
|
|
||||||
}
|
|
||||||
var pad = n.some(isPadded);
|
|
||||||
|
|
||||||
N = [];
|
|
||||||
|
|
||||||
for (var i = x; test(i, y); i += incr) {
|
|
||||||
var c;
|
|
||||||
if (isAlphaSequence) {
|
|
||||||
c = String.fromCharCode(i);
|
|
||||||
if (c === '\\')
|
|
||||||
c = '';
|
|
||||||
} else {
|
|
||||||
c = String(i);
|
|
||||||
if (pad) {
|
|
||||||
var need = width - c.length;
|
|
||||||
if (need > 0) {
|
|
||||||
var z = new Array(need + 1).join('0');
|
|
||||||
if (i < 0)
|
|
||||||
c = '-' + z + c.slice(1);
|
|
||||||
else
|
|
||||||
c = z + c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
N.push(c);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
N = [];
|
|
||||||
|
|
||||||
for (var j = 0; j < n.length; j++) {
|
|
||||||
N.push.apply(N, expand(n[j], false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var j = 0; j < N.length; j++) {
|
|
||||||
for (var k = 0; k < post.length; k++) {
|
|
||||||
var expansion = pre + N[j] + post[k];
|
|
||||||
if (!isTop || isSequence || expansion)
|
|
||||||
expansions.push(expansion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return expansions;
|
|
||||||
}
|
|
||||||
|
|
||||||
46
node_modules/brace-expansion/package.json
generated
vendored
46
node_modules/brace-expansion/package.json
generated
vendored
@@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "brace-expansion",
|
|
||||||
"description": "Brace expansion as known from sh/bash",
|
|
||||||
"version": "2.0.1",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/juliangruber/brace-expansion.git"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/juliangruber/brace-expansion",
|
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
|
||||||
"test": "tape test/*.js",
|
|
||||||
"gentest": "bash test/generate.sh",
|
|
||||||
"bench": "matcha test/perf/bench.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"balanced-match": "^1.0.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@c4312/matcha": "^1.3.1",
|
|
||||||
"tape": "^4.6.0"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": {
|
|
||||||
"name": "Julian Gruber",
|
|
||||||
"email": "mail@juliangruber.com",
|
|
||||||
"url": "http://juliangruber.com"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"testling": {
|
|
||||||
"files": "test/*.js",
|
|
||||||
"browsers": [
|
|
||||||
"ie/8..latest",
|
|
||||||
"firefox/20..latest",
|
|
||||||
"firefox/nightly",
|
|
||||||
"chrome/25..latest",
|
|
||||||
"chrome/canary",
|
|
||||||
"opera/12..latest",
|
|
||||||
"opera/next",
|
|
||||||
"safari/5.1..latest",
|
|
||||||
"ipad/6.0..latest",
|
|
||||||
"iphone/6.0..latest",
|
|
||||||
"android-browser/4.2..latest"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
17
node_modules/buffer-alloc-unsafe/index.js
generated
vendored
17
node_modules/buffer-alloc-unsafe/index.js
generated
vendored
@@ -1,17 +0,0 @@
|
|||||||
function allocUnsafe (size) {
|
|
||||||
if (typeof size !== 'number') {
|
|
||||||
throw new TypeError('"size" argument must be a number')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size < 0) {
|
|
||||||
throw new RangeError('"size" argument must not be negative')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Buffer.allocUnsafe) {
|
|
||||||
return Buffer.allocUnsafe(size)
|
|
||||||
} else {
|
|
||||||
return new Buffer(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = allocUnsafe
|
|
||||||
24
node_modules/buffer-alloc-unsafe/package.json
generated
vendored
24
node_modules/buffer-alloc-unsafe/package.json
generated
vendored
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "buffer-alloc-unsafe",
|
|
||||||
"version": "1.1.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": "LinusU/buffer-alloc-unsafe",
|
|
||||||
"files": [
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"test": "standard && node test"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"standard": "^7.1.2"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"allocUnsafe",
|
|
||||||
"allocate",
|
|
||||||
"buffer allocUnsafe",
|
|
||||||
"buffer unsafe allocate",
|
|
||||||
"buffer",
|
|
||||||
"ponyfill",
|
|
||||||
"unsafe allocate"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
46
node_modules/buffer-alloc-unsafe/readme.md
generated
vendored
46
node_modules/buffer-alloc-unsafe/readme.md
generated
vendored
@@ -1,46 +0,0 @@
|
|||||||
# Buffer Alloc Unsafe
|
|
||||||
|
|
||||||
A [ponyfill](https://ponyfill.com) for `Buffer.allocUnsafe`.
|
|
||||||
|
|
||||||
Works as Node.js: `v7.0.0` <br>
|
|
||||||
Works on Node.js: `v0.10.0`
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --save buffer-alloc-unsafe
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
const allocUnsafe = require('buffer-alloc-unsafe')
|
|
||||||
|
|
||||||
console.log(allocUnsafe(10))
|
|
||||||
//=> <Buffer 78 0c 80 03 01 00 00 00 05 00>
|
|
||||||
|
|
||||||
console.log(allocUnsafe(10))
|
|
||||||
//=> <Buffer 58 ed bf 5f ff 7f 00 00 01 00>
|
|
||||||
|
|
||||||
console.log(allocUnsafe(10))
|
|
||||||
//=> <Buffer 50 0c 80 03 01 00 00 00 0a 00>
|
|
||||||
|
|
||||||
allocUnsafe(-10)
|
|
||||||
//=> RangeError: "size" argument must not be negative
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### allocUnsafe(size)
|
|
||||||
|
|
||||||
- `size` <Integer> The desired length of the new `Buffer`
|
|
||||||
|
|
||||||
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must be
|
|
||||||
less than or equal to the value of `buffer.kMaxLength` and greater than or equal
|
|
||||||
to zero. Otherwise, a `RangeError` is thrown.
|
|
||||||
|
|
||||||
## See also
|
|
||||||
|
|
||||||
- [buffer-alloc](https://github.com/LinusU/buffer-alloc) A ponyfill for `Buffer.alloc`
|
|
||||||
- [buffer-fill](https://github.com/LinusU/buffer-fill) A ponyfill for `Buffer.fill`
|
|
||||||
- [buffer-from](https://github.com/LinusU/buffer-from) A ponyfill for `Buffer.from`
|
|
||||||
32
node_modules/buffer-alloc/index.js
generated
vendored
32
node_modules/buffer-alloc/index.js
generated
vendored
@@ -1,32 +0,0 @@
|
|||||||
var bufferFill = require('buffer-fill')
|
|
||||||
var allocUnsafe = require('buffer-alloc-unsafe')
|
|
||||||
|
|
||||||
module.exports = function alloc (size, fill, encoding) {
|
|
||||||
if (typeof size !== 'number') {
|
|
||||||
throw new TypeError('"size" argument must be a number')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size < 0) {
|
|
||||||
throw new RangeError('"size" argument must not be negative')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Buffer.alloc) {
|
|
||||||
return Buffer.alloc(size, fill, encoding)
|
|
||||||
}
|
|
||||||
|
|
||||||
var buffer = allocUnsafe(size)
|
|
||||||
|
|
||||||
if (size === 0) {
|
|
||||||
return buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fill === undefined) {
|
|
||||||
return bufferFill(buffer, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof encoding !== 'string') {
|
|
||||||
encoding = undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
return bufferFill(buffer, fill, encoding)
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user