[INIT] initial commit
This commit is contained in:
commit
85dae96927
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
data/*
|
||||
15
node_modules/.bin/acorn
generated
vendored
Normal file
15
node_modules/.bin/acorn
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../acorn/bin/acorn" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../acorn/bin/acorn" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/acorn.cmd
generated
vendored
Normal file
17
node_modules/.bin/acorn.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\acorn\bin\acorn" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/acorn.ps1
generated
vendored
Normal file
18
node_modules/.bin/acorn.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../acorn/bin/acorn" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/browserslist
generated
vendored
Normal file
15
node_modules/.bin/browserslist
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../browserslist/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../browserslist/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/browserslist.cmd
generated
vendored
Normal file
17
node_modules/.bin/browserslist.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\browserslist\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/browserslist.ps1
generated
vendored
Normal file
18
node_modules/.bin/browserslist.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../browserslist/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../browserslist/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/envinfo
generated
vendored
Normal file
15
node_modules/.bin/envinfo
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../envinfo/dist/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../envinfo/dist/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/envinfo.cmd
generated
vendored
Normal file
17
node_modules/.bin/envinfo.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\envinfo\dist\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/envinfo.ps1
generated
vendored
Normal file
18
node_modules/.bin/envinfo.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../envinfo/dist/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../envinfo/dist/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/errno
generated
vendored
Normal file
15
node_modules/.bin/errno
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../errno/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../errno/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/errno.cmd
generated
vendored
Normal file
17
node_modules/.bin/errno.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\errno\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/errno.ps1
generated
vendored
Normal file
18
node_modules/.bin/errno.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../errno/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../errno/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/flat
generated
vendored
Normal file
15
node_modules/.bin/flat
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../flat/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../flat/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/flat.cmd
generated
vendored
Normal file
17
node_modules/.bin/flat.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\flat\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/flat.ps1
generated
vendored
Normal file
18
node_modules/.bin/flat.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../flat/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../flat/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/import-local-fixture
generated
vendored
Normal file
15
node_modules/.bin/import-local-fixture
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../import-local/fixtures/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../import-local/fixtures/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/import-local-fixture.cmd
generated
vendored
Normal file
17
node_modules/.bin/import-local-fixture.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\import-local\fixtures\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/import-local-fixture.ps1
generated
vendored
Normal file
18
node_modules/.bin/import-local-fixture.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../import-local/fixtures/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../import-local/fixtures/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/json5
generated
vendored
Normal file
15
node_modules/.bin/json5
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../json5/lib/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../json5/lib/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/json5.cmd
generated
vendored
Normal file
17
node_modules/.bin/json5.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\json5\lib\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/json5.ps1
generated
vendored
Normal file
18
node_modules/.bin/json5.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/mime
generated
vendored
Normal file
15
node_modules/.bin/mime
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../mime/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../mime/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/mime.cmd
generated
vendored
Normal file
17
node_modules/.bin/mime.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\mime\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/mime.ps1
generated
vendored
Normal file
18
node_modules/.bin/mime.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../mime/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/nanoid
generated
vendored
Normal file
15
node_modules/.bin/nanoid
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../nanoid/bin/nanoid.cjs" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../nanoid/bin/nanoid.cjs" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/nanoid.cmd
generated
vendored
Normal file
17
node_modules/.bin/nanoid.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\nanoid\bin\nanoid.cjs" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/nanoid.ps1
generated
vendored
Normal file
18
node_modules/.bin/nanoid.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/node-which
generated
vendored
Normal file
15
node_modules/.bin/node-which
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../which/bin/node-which" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../which/bin/node-which" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/node-which.cmd
generated
vendored
Normal file
17
node_modules/.bin/node-which.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\which\bin\node-which" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/node-which.ps1
generated
vendored
Normal file
18
node_modules/.bin/node-which.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../which/bin/node-which" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/resolve
generated
vendored
Normal file
15
node_modules/.bin/resolve
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../resolve/bin/resolve" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../resolve/bin/resolve" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/resolve.cmd
generated
vendored
Normal file
17
node_modules/.bin/resolve.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\resolve\bin\resolve" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/resolve.ps1
generated
vendored
Normal file
18
node_modules/.bin/resolve.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../resolve/bin/resolve" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../resolve/bin/resolve" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/semver
generated
vendored
Normal file
15
node_modules/.bin/semver
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../semver/bin/semver.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/semver.cmd
generated
vendored
Normal file
17
node_modules/.bin/semver.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\semver\bin\semver.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/semver.ps1
generated
vendored
Normal file
18
node_modules/.bin/semver.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/terser
generated
vendored
Normal file
15
node_modules/.bin/terser
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../terser/bin/terser" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../terser/bin/terser" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/terser.cmd
generated
vendored
Normal file
17
node_modules/.bin/terser.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\terser\bin\terser" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/terser.ps1
generated
vendored
Normal file
18
node_modules/.bin/terser.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../terser/bin/terser" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../terser/bin/terser" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/update-browserslist-db
generated
vendored
Normal file
15
node_modules/.bin/update-browserslist-db
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../update-browserslist-db/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../update-browserslist-db/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/update-browserslist-db.cmd
generated
vendored
Normal file
17
node_modules/.bin/update-browserslist-db.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\update-browserslist-db\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/update-browserslist-db.ps1
generated
vendored
Normal file
18
node_modules/.bin/update-browserslist-db.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../update-browserslist-db/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../update-browserslist-db/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
15
node_modules/.bin/webpack
generated
vendored
Normal file
15
node_modules/.bin/webpack
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../webpack/bin/webpack.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../webpack/bin/webpack.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
15
node_modules/.bin/webpack-cli
generated
vendored
Normal file
15
node_modules/.bin/webpack-cli
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/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
|
||||
"$basedir/node" "$basedir/../webpack-cli/bin/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../webpack-cli/bin/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
17
node_modules/.bin/webpack-cli.cmd
generated
vendored
Normal file
17
node_modules/.bin/webpack-cli.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\webpack-cli\bin\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/webpack-cli.ps1
generated
vendored
Normal file
18
node_modules/.bin/webpack-cli.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../webpack-cli/bin/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../webpack-cli/bin/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
17
node_modules/.bin/webpack.cmd
generated
vendored
Normal file
17
node_modules/.bin/webpack.cmd
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\webpack\bin\webpack.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
18
node_modules/.bin/webpack.ps1
generated
vendored
Normal file
18
node_modules/.bin/webpack.ps1
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#!/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") {
|
||||
& "$basedir/node$exe" "$basedir/../webpack/bin/webpack.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../webpack/bin/webpack.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
26
node_modules/@colors/colors/LICENSE
generated
vendored
Normal file
26
node_modules/@colors/colors/LICENSE
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
MIT License
|
||||
|
||||
Original Library
|
||||
- Copyright (c) Marak Squires
|
||||
|
||||
Additional Functionality
|
||||
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
- Copyright (c) DABH (https://github.com/DABH)
|
||||
|
||||
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.
|
||||
219
node_modules/@colors/colors/README.md
generated
vendored
Normal file
219
node_modules/@colors/colors/README.md
generated
vendored
Normal file
@ -0,0 +1,219 @@
|
||||
# @colors/colors ("colors.js")
|
||||
[](https://github.com/DABH/colors.js/actions/workflows/ci.yml)
|
||||
[](https://www.npmjs.org/package/@colors/colors)
|
||||
|
||||
Please check out the [roadmap](ROADMAP.md) for upcoming features and releases. Please open Issues to provide feedback.
|
||||
|
||||
## get color and style in your node.js console
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
npm install @colors/colors
|
||||
|
||||
## colors and styles!
|
||||
|
||||
### text colors
|
||||
|
||||
- black
|
||||
- red
|
||||
- green
|
||||
- yellow
|
||||
- blue
|
||||
- magenta
|
||||
- cyan
|
||||
- white
|
||||
- gray
|
||||
- grey
|
||||
|
||||
### bright text colors
|
||||
|
||||
- brightRed
|
||||
- brightGreen
|
||||
- brightYellow
|
||||
- brightBlue
|
||||
- brightMagenta
|
||||
- brightCyan
|
||||
- brightWhite
|
||||
|
||||
### background colors
|
||||
|
||||
- bgBlack
|
||||
- bgRed
|
||||
- bgGreen
|
||||
- bgYellow
|
||||
- bgBlue
|
||||
- bgMagenta
|
||||
- bgCyan
|
||||
- bgWhite
|
||||
- bgGray
|
||||
- bgGrey
|
||||
|
||||
### bright background colors
|
||||
|
||||
- bgBrightRed
|
||||
- bgBrightGreen
|
||||
- bgBrightYellow
|
||||
- bgBrightBlue
|
||||
- bgBrightMagenta
|
||||
- bgBrightCyan
|
||||
- bgBrightWhite
|
||||
|
||||
### styles
|
||||
|
||||
- reset
|
||||
- bold
|
||||
- dim
|
||||
- italic
|
||||
- underline
|
||||
- inverse
|
||||
- hidden
|
||||
- strikethrough
|
||||
|
||||
### extras
|
||||
|
||||
- rainbow
|
||||
- zebra
|
||||
- america
|
||||
- trap
|
||||
- random
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
By popular demand, `@colors/colors` now ships with two types of usages!
|
||||
|
||||
The super nifty way
|
||||
|
||||
```js
|
||||
var colors = require('@colors/colors');
|
||||
|
||||
console.log('hello'.green); // outputs green text
|
||||
console.log('i like cake and pies'.underline.red); // outputs red underlined text
|
||||
console.log('inverse the color'.inverse); // inverses the color
|
||||
console.log('OMG Rainbows!'.rainbow); // rainbow
|
||||
console.log('Run the trap'.trap); // Drops the bass
|
||||
|
||||
```
|
||||
|
||||
or a slightly less nifty way which doesn't extend `String.prototype`
|
||||
|
||||
```js
|
||||
var colors = require('@colors/colors/safe');
|
||||
|
||||
console.log(colors.green('hello')); // outputs green text
|
||||
console.log(colors.red.underline('i like cake and pies')); // outputs red underlined text
|
||||
console.log(colors.inverse('inverse the color')); // inverses the color
|
||||
console.log(colors.rainbow('OMG Rainbows!')); // rainbow
|
||||
console.log(colors.trap('Run the trap')); // Drops the bass
|
||||
|
||||
```
|
||||
|
||||
I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
|
||||
|
||||
If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.
|
||||
|
||||
## Enabling/Disabling Colors
|
||||
|
||||
The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
|
||||
|
||||
```bash
|
||||
node myapp.js --no-color
|
||||
node myapp.js --color=false
|
||||
|
||||
node myapp.js --color
|
||||
node myapp.js --color=true
|
||||
node myapp.js --color=always
|
||||
|
||||
FORCE_COLOR=1 node myapp.js
|
||||
```
|
||||
|
||||
Or in code:
|
||||
|
||||
```javascript
|
||||
var colors = require('@colors/colors');
|
||||
colors.enable();
|
||||
colors.disable();
|
||||
```
|
||||
|
||||
## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
|
||||
|
||||
```js
|
||||
var name = 'Beowulf';
|
||||
console.log(colors.green('Hello %s'), name);
|
||||
// outputs -> 'Hello Beowulf'
|
||||
```
|
||||
|
||||
## Custom themes
|
||||
|
||||
### Using standard API
|
||||
|
||||
```js
|
||||
|
||||
var colors = require('@colors/colors');
|
||||
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log("this is an error".error);
|
||||
|
||||
// outputs yellow text
|
||||
console.log("this is a warning".warn);
|
||||
```
|
||||
|
||||
### Using string safe API
|
||||
|
||||
```js
|
||||
var colors = require('@colors/colors/safe');
|
||||
|
||||
// set single property
|
||||
var error = colors.red;
|
||||
error('this is red');
|
||||
|
||||
// set theme
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log(colors.error("this is an error"));
|
||||
|
||||
// outputs yellow text
|
||||
console.log(colors.warn("this is a warning"));
|
||||
|
||||
```
|
||||
|
||||
### Combining Colors
|
||||
|
||||
```javascript
|
||||
var colors = require('@colors/colors');
|
||||
|
||||
colors.setTheme({
|
||||
custom: ['red', 'underline']
|
||||
});
|
||||
|
||||
console.log('test'.custom);
|
||||
```
|
||||
|
||||
*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
|
||||
83
node_modules/@colors/colors/examples/normal-usage.js
generated
vendored
Normal file
83
node_modules/@colors/colors/examples/normal-usage.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
var colors = require('../lib/index');
|
||||
|
||||
console.log('First some yellow text'.yellow);
|
||||
|
||||
console.log('Underline that text'.yellow.underline);
|
||||
|
||||
console.log('Make it bold and red'.red.bold);
|
||||
|
||||
console.log(('Double Raindows All Day Long').rainbow);
|
||||
|
||||
console.log('Drop the bass'.trap);
|
||||
|
||||
console.log('DROP THE RAINBOW BASS'.trap.rainbow);
|
||||
|
||||
// styles not widely supported
|
||||
console.log('Chains are also cool.'.bold.italic.underline.red);
|
||||
|
||||
// styles not widely supported
|
||||
console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse
|
||||
+ ' styles! '.yellow.bold);
|
||||
console.log('Zebras are so fun!'.zebra);
|
||||
|
||||
//
|
||||
// Remark: .strikethrough may not work with Mac OS Terminal App
|
||||
//
|
||||
console.log('This is ' + 'not'.strikethrough + ' fun.');
|
||||
|
||||
console.log('Background color attack!'.black.bgWhite);
|
||||
console.log('Use random styles on everything!'.random);
|
||||
console.log('America, Heck Yeah!'.america);
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
console.log('Blindingly '.brightCyan + 'bright? '.brightRed + 'Why '.brightYellow + 'not?!'.brightGreen);
|
||||
|
||||
console.log('Setting themes is useful');
|
||||
|
||||
//
|
||||
// Custom themes
|
||||
//
|
||||
console.log('Generic logging theme as JSON'.green.bold.underline);
|
||||
// Load theme with JSON literal
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red',
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log('this is an error'.error);
|
||||
|
||||
// outputs yellow text
|
||||
console.log('this is a warning'.warn);
|
||||
|
||||
// outputs grey text
|
||||
console.log('this is an input'.input);
|
||||
|
||||
console.log('Generic logging theme as file'.green.bold.underline);
|
||||
|
||||
// Load a theme from file
|
||||
try {
|
||||
colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
// outputs red text
|
||||
console.log('this is an error'.error);
|
||||
|
||||
// outputs yellow text
|
||||
console.log('this is a warning'.warn);
|
||||
|
||||
// outputs grey text
|
||||
console.log('this is an input'.input);
|
||||
|
||||
// console.log("Don't summon".zalgo)
|
||||
|
||||
80
node_modules/@colors/colors/examples/safe-string.js
generated
vendored
Normal file
80
node_modules/@colors/colors/examples/safe-string.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
var colors = require('../safe');
|
||||
|
||||
console.log(colors.yellow('First some yellow text'));
|
||||
|
||||
console.log(colors.yellow.underline('Underline that text'));
|
||||
|
||||
console.log(colors.red.bold('Make it bold and red'));
|
||||
|
||||
console.log(colors.rainbow('Double Raindows All Day Long'));
|
||||
|
||||
console.log(colors.trap('Drop the bass'));
|
||||
|
||||
console.log(colors.rainbow(colors.trap('DROP THE RAINBOW BASS')));
|
||||
|
||||
// styles not widely supported
|
||||
console.log(colors.bold.italic.underline.red('Chains are also cool.'));
|
||||
|
||||
// styles not widely supported
|
||||
console.log(colors.green('So ') + colors.underline('are') + ' '
|
||||
+ colors.inverse('inverse') + colors.yellow.bold(' styles! '));
|
||||
|
||||
console.log(colors.zebra('Zebras are so fun!'));
|
||||
|
||||
console.log('This is ' + colors.strikethrough('not') + ' fun.');
|
||||
|
||||
|
||||
console.log(colors.black.bgWhite('Background color attack!'));
|
||||
console.log(colors.random('Use random styles on everything!'));
|
||||
console.log(colors.america('America, Heck Yeah!'));
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
console.log(colors.brightCyan('Blindingly ') + colors.brightRed('bright? ') + colors.brightYellow('Why ') + colors.brightGreen('not?!'));
|
||||
|
||||
console.log('Setting themes is useful');
|
||||
|
||||
//
|
||||
// Custom themes
|
||||
//
|
||||
// console.log('Generic logging theme as JSON'.green.bold.underline);
|
||||
// Load theme with JSON literal
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'blue',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red',
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log(colors.error('this is an error'));
|
||||
|
||||
// outputs yellow text
|
||||
console.log(colors.warn('this is a warning'));
|
||||
|
||||
// outputs blue text
|
||||
console.log(colors.input('this is an input'));
|
||||
|
||||
|
||||
// console.log('Generic logging theme as file'.green.bold.underline);
|
||||
|
||||
// Load a theme from file
|
||||
colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
|
||||
|
||||
// outputs red text
|
||||
console.log(colors.error('this is an error'));
|
||||
|
||||
// outputs yellow text
|
||||
console.log(colors.warn('this is a warning'));
|
||||
|
||||
// outputs grey text
|
||||
console.log(colors.input('this is an input'));
|
||||
|
||||
// console.log(colors.zalgo("Don't summon him"))
|
||||
|
||||
|
||||
184
node_modules/@colors/colors/index.d.ts
generated
vendored
Normal file
184
node_modules/@colors/colors/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
// Type definitions for @colors/colors 1.4+
|
||||
// Project: https://github.com/Marak/colors.js
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Staffan Eketorp <https://github.com/staeke>
|
||||
// Definitions: https://github.com/DABH/colors.js
|
||||
|
||||
export interface Color {
|
||||
(text: string): string;
|
||||
|
||||
strip: Color;
|
||||
stripColors: Color;
|
||||
|
||||
black: Color;
|
||||
red: Color;
|
||||
green: Color;
|
||||
yellow: Color;
|
||||
blue: Color;
|
||||
magenta: Color;
|
||||
cyan: Color;
|
||||
white: Color;
|
||||
gray: Color;
|
||||
grey: Color;
|
||||
|
||||
brightRed: Color;
|
||||
brightGreen: Color;
|
||||
brightYellow: Color;
|
||||
brightBlue: Color;
|
||||
brightMagenta: Color;
|
||||
brightCyan: Color;
|
||||
brightWhite: Color;
|
||||
|
||||
bgBlack: Color;
|
||||
bgRed: Color;
|
||||
bgGreen: Color;
|
||||
bgYellow: Color;
|
||||
bgBlue: Color;
|
||||
bgMagenta: Color;
|
||||
bgCyan: Color;
|
||||
bgWhite: Color;
|
||||
|
||||
bgBrightRed: Color;
|
||||
bgBrightGreen: Color;
|
||||
bgBrightYellow: Color;
|
||||
bgBrightBlue: Color;
|
||||
bgBrightMagenta: Color;
|
||||
bgBrightCyan: Color;
|
||||
bgBrightWhite: Color;
|
||||
|
||||
reset: Color;
|
||||
bold: Color;
|
||||
dim: Color;
|
||||
italic: Color;
|
||||
underline: Color;
|
||||
inverse: Color;
|
||||
hidden: Color;
|
||||
strikethrough: Color;
|
||||
|
||||
rainbow: Color;
|
||||
zebra: Color;
|
||||
america: Color;
|
||||
trap: Color;
|
||||
random: Color;
|
||||
zalgo: Color;
|
||||
}
|
||||
|
||||
export function enable(): void;
|
||||
export function disable(): void;
|
||||
export function setTheme(theme: any): void;
|
||||
|
||||
export let enabled: boolean;
|
||||
|
||||
export const strip: Color;
|
||||
export const stripColors: Color;
|
||||
|
||||
export const black: Color;
|
||||
export const red: Color;
|
||||
export const green: Color;
|
||||
export const yellow: Color;
|
||||
export const blue: Color;
|
||||
export const magenta: Color;
|
||||
export const cyan: Color;
|
||||
export const white: Color;
|
||||
export const gray: Color;
|
||||
export const grey: Color;
|
||||
|
||||
export const brightRed: Color;
|
||||
export const brightGreen: Color;
|
||||
export const brightYellow: Color;
|
||||
export const brightBlue: Color;
|
||||
export const brightMagenta: Color;
|
||||
export const brightCyan: Color;
|
||||
export const brightWhite: Color;
|
||||
|
||||
export const bgBlack: Color;
|
||||
export const bgRed: Color;
|
||||
export const bgGreen: Color;
|
||||
export const bgYellow: Color;
|
||||
export const bgBlue: Color;
|
||||
export const bgMagenta: Color;
|
||||
export const bgCyan: Color;
|
||||
export const bgWhite: Color;
|
||||
|
||||
export const bgBrightRed: Color;
|
||||
export const bgBrightGreen: Color;
|
||||
export const bgBrightYellow: Color;
|
||||
export const bgBrightBlue: Color;
|
||||
export const bgBrightMagenta: Color;
|
||||
export const bgBrightCyan: Color;
|
||||
export const bgBrightWhite: Color;
|
||||
|
||||
export const reset: Color;
|
||||
export const bold: Color;
|
||||
export const dim: Color;
|
||||
export const italic: Color;
|
||||
export const underline: Color;
|
||||
export const inverse: Color;
|
||||
export const hidden: Color;
|
||||
export const strikethrough: Color;
|
||||
|
||||
export const rainbow: Color;
|
||||
export const zebra: Color;
|
||||
export const america: Color;
|
||||
export const trap: Color;
|
||||
export const random: Color;
|
||||
export const zalgo: Color;
|
||||
|
||||
declare global {
|
||||
interface String {
|
||||
strip: string;
|
||||
stripColors: string;
|
||||
|
||||
black: string;
|
||||
red: string;
|
||||
green: string;
|
||||
yellow: string;
|
||||
blue: string;
|
||||
magenta: string;
|
||||
cyan: string;
|
||||
white: string;
|
||||
gray: string;
|
||||
grey: string;
|
||||
|
||||
brightRed: string;
|
||||
brightGreen: string;
|
||||
brightYellow: string;
|
||||
brightBlue: string;
|
||||
brightMagenta: string;
|
||||
brightCyan: string;
|
||||
brightWhite: string;
|
||||
|
||||
bgBlack: string;
|
||||
bgRed: string;
|
||||
bgGreen: string;
|
||||
bgYellow: string;
|
||||
bgBlue: string;
|
||||
bgMagenta: string;
|
||||
bgCyan: string;
|
||||
bgWhite: string;
|
||||
|
||||
bgBrightRed: string;
|
||||
bgBrightGreen: string;
|
||||
bgBrightYellow: string;
|
||||
bgBrightBlue: string;
|
||||
bgBrightMagenta: string;
|
||||
bgBrightCyan: string;
|
||||
bgBrightWhite: string;
|
||||
|
||||
reset: string;
|
||||
// @ts-ignore
|
||||
bold: string;
|
||||
dim: string;
|
||||
italic: string;
|
||||
underline: string;
|
||||
inverse: string;
|
||||
hidden: string;
|
||||
strikethrough: string;
|
||||
|
||||
rainbow: string;
|
||||
zebra: string;
|
||||
america: string;
|
||||
trap: string;
|
||||
random: string;
|
||||
zalgo: string;
|
||||
}
|
||||
}
|
||||
211
node_modules/@colors/colors/lib/colors.js
generated
vendored
Normal file
211
node_modules/@colors/colors/lib/colors.js
generated
vendored
Normal file
@ -0,0 +1,211 @@
|
||||
/*
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Original Library
|
||||
- Copyright (c) Marak Squires
|
||||
|
||||
Additional functionality
|
||||
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
|
||||
|
||||
*/
|
||||
|
||||
var colors = {};
|
||||
module['exports'] = colors;
|
||||
|
||||
colors.themes = {};
|
||||
|
||||
var util = require('util');
|
||||
var ansiStyles = colors.styles = require('./styles');
|
||||
var defineProps = Object.defineProperties;
|
||||
var newLineRegex = new RegExp(/[\r\n]+/g);
|
||||
|
||||
colors.supportsColor = require('./system/supports-colors').supportsColor;
|
||||
|
||||
if (typeof colors.enabled === 'undefined') {
|
||||
colors.enabled = colors.supportsColor() !== false;
|
||||
}
|
||||
|
||||
colors.enable = function() {
|
||||
colors.enabled = true;
|
||||
};
|
||||
|
||||
colors.disable = function() {
|
||||
colors.enabled = false;
|
||||
};
|
||||
|
||||
colors.stripColors = colors.strip = function(str) {
|
||||
return ('' + str).replace(/\x1B\[\d+m/g, '');
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var stylize = colors.stylize = function stylize(str, style) {
|
||||
if (!colors.enabled) {
|
||||
return str+'';
|
||||
}
|
||||
|
||||
var styleMap = ansiStyles[style];
|
||||
|
||||
// Stylize should work for non-ANSI styles, too
|
||||
if (!styleMap && style in colors) {
|
||||
// Style maps like trap operate as functions on strings;
|
||||
// they don't have properties like open or close.
|
||||
return colors[style](str);
|
||||
}
|
||||
|
||||
return styleMap.open + str + styleMap.close;
|
||||
};
|
||||
|
||||
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
||||
var escapeStringRegexp = function(str) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
return str.replace(matchOperatorsRe, '\\$&');
|
||||
};
|
||||
|
||||
function build(_styles) {
|
||||
var builder = function builder() {
|
||||
return applyStyle.apply(builder, arguments);
|
||||
};
|
||||
builder._styles = _styles;
|
||||
// __proto__ is used because we must return a function, but there is
|
||||
// no way to create a function with a different prototype.
|
||||
builder.__proto__ = proto;
|
||||
return builder;
|
||||
}
|
||||
|
||||
var styles = (function() {
|
||||
var ret = {};
|
||||
ansiStyles.grey = ansiStyles.gray;
|
||||
Object.keys(ansiStyles).forEach(function(key) {
|
||||
ansiStyles[key].closeRe =
|
||||
new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
|
||||
ret[key] = {
|
||||
get: function() {
|
||||
return build(this._styles.concat(key));
|
||||
},
|
||||
};
|
||||
});
|
||||
return ret;
|
||||
})();
|
||||
|
||||
var proto = defineProps(function colors() {}, styles);
|
||||
|
||||
function applyStyle() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
|
||||
var str = args.map(function(arg) {
|
||||
// Use weak equality check so we can colorize null/undefined in safe mode
|
||||
if (arg != null && arg.constructor === String) {
|
||||
return arg;
|
||||
} else {
|
||||
return util.inspect(arg);
|
||||
}
|
||||
}).join(' ');
|
||||
|
||||
if (!colors.enabled || !str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
var newLinesPresent = str.indexOf('\n') != -1;
|
||||
|
||||
var nestedStyles = this._styles;
|
||||
|
||||
var i = nestedStyles.length;
|
||||
while (i--) {
|
||||
var code = ansiStyles[nestedStyles[i]];
|
||||
str = code.open + str.replace(code.closeRe, code.open) + code.close;
|
||||
if (newLinesPresent) {
|
||||
str = str.replace(newLineRegex, function(match) {
|
||||
return code.close + match + code.open;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
colors.setTheme = function(theme) {
|
||||
if (typeof theme === 'string') {
|
||||
console.log('colors.setTheme now only accepts an object, not a string. ' +
|
||||
'If you are trying to set a theme from a file, it is now your (the ' +
|
||||
'caller\'s) responsibility to require the file. The old syntax ' +
|
||||
'looked like colors.setTheme(__dirname + ' +
|
||||
'\'/../themes/generic-logging.js\'); The new syntax looks like '+
|
||||
'colors.setTheme(require(__dirname + ' +
|
||||
'\'/../themes/generic-logging.js\'));');
|
||||
return;
|
||||
}
|
||||
for (var style in theme) {
|
||||
(function(style) {
|
||||
colors[style] = function(str) {
|
||||
if (typeof theme[style] === 'object') {
|
||||
var out = str;
|
||||
for (var i in theme[style]) {
|
||||
out = colors[theme[style][i]](out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
return colors[theme[style]](str);
|
||||
};
|
||||
})(style);
|
||||
}
|
||||
};
|
||||
|
||||
function init() {
|
||||
var ret = {};
|
||||
Object.keys(styles).forEach(function(name) {
|
||||
ret[name] = {
|
||||
get: function() {
|
||||
return build([name]);
|
||||
},
|
||||
};
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
var sequencer = function sequencer(map, str) {
|
||||
var exploded = str.split('');
|
||||
exploded = exploded.map(map);
|
||||
return exploded.join('');
|
||||
};
|
||||
|
||||
// custom formatter methods
|
||||
colors.trap = require('./custom/trap');
|
||||
colors.zalgo = require('./custom/zalgo');
|
||||
|
||||
// maps
|
||||
colors.maps = {};
|
||||
colors.maps.america = require('./maps/america')(colors);
|
||||
colors.maps.zebra = require('./maps/zebra')(colors);
|
||||
colors.maps.rainbow = require('./maps/rainbow')(colors);
|
||||
colors.maps.random = require('./maps/random')(colors);
|
||||
|
||||
for (var map in colors.maps) {
|
||||
(function(map) {
|
||||
colors[map] = function(str) {
|
||||
return sequencer(colors.maps[map], str);
|
||||
};
|
||||
})(map);
|
||||
}
|
||||
|
||||
defineProps(colors, init());
|
||||
46
node_modules/@colors/colors/lib/custom/trap.js
generated
vendored
Normal file
46
node_modules/@colors/colors/lib/custom/trap.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
module['exports'] = function runTheTrap(text, options) {
|
||||
var result = '';
|
||||
text = text || 'Run the trap, drop the bass';
|
||||
text = text.split('');
|
||||
var trap = {
|
||||
a: ['\u0040', '\u0104', '\u023a', '\u0245', '\u0394', '\u039b', '\u0414'],
|
||||
b: ['\u00df', '\u0181', '\u0243', '\u026e', '\u03b2', '\u0e3f'],
|
||||
c: ['\u00a9', '\u023b', '\u03fe'],
|
||||
d: ['\u00d0', '\u018a', '\u0500', '\u0501', '\u0502', '\u0503'],
|
||||
e: ['\u00cb', '\u0115', '\u018e', '\u0258', '\u03a3', '\u03be', '\u04bc',
|
||||
'\u0a6c'],
|
||||
f: ['\u04fa'],
|
||||
g: ['\u0262'],
|
||||
h: ['\u0126', '\u0195', '\u04a2', '\u04ba', '\u04c7', '\u050a'],
|
||||
i: ['\u0f0f'],
|
||||
j: ['\u0134'],
|
||||
k: ['\u0138', '\u04a0', '\u04c3', '\u051e'],
|
||||
l: ['\u0139'],
|
||||
m: ['\u028d', '\u04cd', '\u04ce', '\u0520', '\u0521', '\u0d69'],
|
||||
n: ['\u00d1', '\u014b', '\u019d', '\u0376', '\u03a0', '\u048a'],
|
||||
o: ['\u00d8', '\u00f5', '\u00f8', '\u01fe', '\u0298', '\u047a', '\u05dd',
|
||||
'\u06dd', '\u0e4f'],
|
||||
p: ['\u01f7', '\u048e'],
|
||||
q: ['\u09cd'],
|
||||
r: ['\u00ae', '\u01a6', '\u0210', '\u024c', '\u0280', '\u042f'],
|
||||
s: ['\u00a7', '\u03de', '\u03df', '\u03e8'],
|
||||
t: ['\u0141', '\u0166', '\u0373'],
|
||||
u: ['\u01b1', '\u054d'],
|
||||
v: ['\u05d8'],
|
||||
w: ['\u0428', '\u0460', '\u047c', '\u0d70'],
|
||||
x: ['\u04b2', '\u04fe', '\u04fc', '\u04fd'],
|
||||
y: ['\u00a5', '\u04b0', '\u04cb'],
|
||||
z: ['\u01b5', '\u0240'],
|
||||
};
|
||||
text.forEach(function(c) {
|
||||
c = c.toLowerCase();
|
||||
var chars = trap[c] || [' '];
|
||||
var rand = Math.floor(Math.random() * chars.length);
|
||||
if (typeof trap[c] !== 'undefined') {
|
||||
result += trap[c][rand];
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
||||
110
node_modules/@colors/colors/lib/custom/zalgo.js
generated
vendored
Normal file
110
node_modules/@colors/colors/lib/custom/zalgo.js
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
// please no
|
||||
module['exports'] = function zalgo(text, options) {
|
||||
text = text || ' he is here ';
|
||||
var soul = {
|
||||
'up': [
|
||||
'̍', '̎', '̄', '̅',
|
||||
'̿', '̑', '̆', '̐',
|
||||
'͒', '͗', '͑', '̇',
|
||||
'̈', '̊', '͂', '̓',
|
||||
'̈', '͊', '͋', '͌',
|
||||
'̃', '̂', '̌', '͐',
|
||||
'̀', '́', '̋', '̏',
|
||||
'̒', '̓', '̔', '̽',
|
||||
'̉', 'ͣ', 'ͤ', 'ͥ',
|
||||
'ͦ', 'ͧ', 'ͨ', 'ͩ',
|
||||
'ͪ', 'ͫ', 'ͬ', 'ͭ',
|
||||
'ͮ', 'ͯ', '̾', '͛',
|
||||
'͆', '̚',
|
||||
],
|
||||
'down': [
|
||||
'̖', '̗', '̘', '̙',
|
||||
'̜', '̝', '̞', '̟',
|
||||
'̠', '̤', '̥', '̦',
|
||||
'̩', '̪', '̫', '̬',
|
||||
'̭', '̮', '̯', '̰',
|
||||
'̱', '̲', '̳', '̹',
|
||||
'̺', '̻', '̼', 'ͅ',
|
||||
'͇', '͈', '͉', '͍',
|
||||
'͎', '͓', '͔', '͕',
|
||||
'͖', '͙', '͚', '̣',
|
||||
],
|
||||
'mid': [
|
||||
'̕', '̛', '̀', '́',
|
||||
'͘', '̡', '̢', '̧',
|
||||
'̨', '̴', '̵', '̶',
|
||||
'͜', '͝', '͞',
|
||||
'͟', '͠', '͢', '̸',
|
||||
'̷', '͡', ' ҉',
|
||||
],
|
||||
};
|
||||
var all = [].concat(soul.up, soul.down, soul.mid);
|
||||
|
||||
function randomNumber(range) {
|
||||
var r = Math.floor(Math.random() * range);
|
||||
return r;
|
||||
}
|
||||
|
||||
function isChar(character) {
|
||||
var bool = false;
|
||||
all.filter(function(i) {
|
||||
bool = (i === character);
|
||||
});
|
||||
return bool;
|
||||
}
|
||||
|
||||
|
||||
function heComes(text, options) {
|
||||
var result = '';
|
||||
var counts;
|
||||
var l;
|
||||
options = options || {};
|
||||
options['up'] =
|
||||
typeof options['up'] !== 'undefined' ? options['up'] : true;
|
||||
options['mid'] =
|
||||
typeof options['mid'] !== 'undefined' ? options['mid'] : true;
|
||||
options['down'] =
|
||||
typeof options['down'] !== 'undefined' ? options['down'] : true;
|
||||
options['size'] =
|
||||
typeof options['size'] !== 'undefined' ? options['size'] : 'maxi';
|
||||
text = text.split('');
|
||||
for (l in text) {
|
||||
if (isChar(l)) {
|
||||
continue;
|
||||
}
|
||||
result = result + text[l];
|
||||
counts = {'up': 0, 'down': 0, 'mid': 0};
|
||||
switch (options.size) {
|
||||
case 'mini':
|
||||
counts.up = randomNumber(8);
|
||||
counts.mid = randomNumber(2);
|
||||
counts.down = randomNumber(8);
|
||||
break;
|
||||
case 'maxi':
|
||||
counts.up = randomNumber(16) + 3;
|
||||
counts.mid = randomNumber(4) + 1;
|
||||
counts.down = randomNumber(64) + 3;
|
||||
break;
|
||||
default:
|
||||
counts.up = randomNumber(8) + 1;
|
||||
counts.mid = randomNumber(6) / 2;
|
||||
counts.down = randomNumber(8) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
var arr = ['up', 'mid', 'down'];
|
||||
for (var d in arr) {
|
||||
var index = arr[d];
|
||||
for (var i = 0; i <= counts[index]; i++) {
|
||||
if (options[index]) {
|
||||
result = result + soul[index][randomNumber(soul[index].length)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// don't summon him
|
||||
return heComes(text, options);
|
||||
};
|
||||
|
||||
110
node_modules/@colors/colors/lib/extendStringPrototype.js
generated
vendored
Normal file
110
node_modules/@colors/colors/lib/extendStringPrototype.js
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
var colors = require('./colors');
|
||||
|
||||
module['exports'] = function() {
|
||||
//
|
||||
// Extends prototype of native string object to allow for "foo".red syntax
|
||||
//
|
||||
var addProperty = function(color, func) {
|
||||
String.prototype.__defineGetter__(color, func);
|
||||
};
|
||||
|
||||
addProperty('strip', function() {
|
||||
return colors.strip(this);
|
||||
});
|
||||
|
||||
addProperty('stripColors', function() {
|
||||
return colors.strip(this);
|
||||
});
|
||||
|
||||
addProperty('trap', function() {
|
||||
return colors.trap(this);
|
||||
});
|
||||
|
||||
addProperty('zalgo', function() {
|
||||
return colors.zalgo(this);
|
||||
});
|
||||
|
||||
addProperty('zebra', function() {
|
||||
return colors.zebra(this);
|
||||
});
|
||||
|
||||
addProperty('rainbow', function() {
|
||||
return colors.rainbow(this);
|
||||
});
|
||||
|
||||
addProperty('random', function() {
|
||||
return colors.random(this);
|
||||
});
|
||||
|
||||
addProperty('america', function() {
|
||||
return colors.america(this);
|
||||
});
|
||||
|
||||
//
|
||||
// Iterate through all default styles and colors
|
||||
//
|
||||
var x = Object.keys(colors.styles);
|
||||
x.forEach(function(style) {
|
||||
addProperty(style, function() {
|
||||
return colors.stylize(this, style);
|
||||
});
|
||||
});
|
||||
|
||||
function applyTheme(theme) {
|
||||
//
|
||||
// Remark: This is a list of methods that exist
|
||||
// on String that you should not overwrite.
|
||||
//
|
||||
var stringPrototypeBlacklist = [
|
||||
'__defineGetter__', '__defineSetter__', '__lookupGetter__',
|
||||
'__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty',
|
||||
'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString',
|
||||
'valueOf', 'charCodeAt', 'indexOf', 'lastIndexOf', 'length',
|
||||
'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice',
|
||||
'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase',
|
||||
'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight',
|
||||
];
|
||||
|
||||
Object.keys(theme).forEach(function(prop) {
|
||||
if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
|
||||
console.log('warn: '.red + ('String.prototype' + prop).magenta +
|
||||
' is probably something you don\'t want to override. ' +
|
||||
'Ignoring style name');
|
||||
} else {
|
||||
if (typeof(theme[prop]) === 'string') {
|
||||
colors[prop] = colors[theme[prop]];
|
||||
addProperty(prop, function() {
|
||||
return colors[prop](this);
|
||||
});
|
||||
} else {
|
||||
var themePropApplicator = function(str) {
|
||||
var ret = str || this;
|
||||
for (var t = 0; t < theme[prop].length; t++) {
|
||||
ret = colors[theme[prop][t]](ret);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
addProperty(prop, themePropApplicator);
|
||||
colors[prop] = function(str) {
|
||||
return themePropApplicator(str);
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
colors.setTheme = function(theme) {
|
||||
if (typeof theme === 'string') {
|
||||
console.log('colors.setTheme now only accepts an object, not a string. ' +
|
||||
'If you are trying to set a theme from a file, it is now your (the ' +
|
||||
'caller\'s) responsibility to require the file. The old syntax ' +
|
||||
'looked like colors.setTheme(__dirname + ' +
|
||||
'\'/../themes/generic-logging.js\'); The new syntax looks like '+
|
||||
'colors.setTheme(require(__dirname + ' +
|
||||
'\'/../themes/generic-logging.js\'));');
|
||||
return;
|
||||
} else {
|
||||
applyTheme(theme);
|
||||
}
|
||||
};
|
||||
};
|
||||
13
node_modules/@colors/colors/lib/index.js
generated
vendored
Normal file
13
node_modules/@colors/colors/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
var colors = require('./colors');
|
||||
module['exports'] = colors;
|
||||
|
||||
// Remark: By default, colors will add style properties to String.prototype.
|
||||
//
|
||||
// If you don't wish to extend String.prototype, you can do this instead and
|
||||
// native String will not be touched:
|
||||
//
|
||||
// var colors = require('@colors/colors/safe');
|
||||
// colors.red("foo")
|
||||
//
|
||||
//
|
||||
require('./extendStringPrototype')();
|
||||
10
node_modules/@colors/colors/lib/maps/america.js
generated
vendored
Normal file
10
node_modules/@colors/colors/lib/maps/america.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
module['exports'] = function(colors) {
|
||||
return function(letter, i, exploded) {
|
||||
if (letter === ' ') return letter;
|
||||
switch (i%3) {
|
||||
case 0: return colors.red(letter);
|
||||
case 1: return colors.white(letter);
|
||||
case 2: return colors.blue(letter);
|
||||
}
|
||||
};
|
||||
};
|
||||
12
node_modules/@colors/colors/lib/maps/rainbow.js
generated
vendored
Normal file
12
node_modules/@colors/colors/lib/maps/rainbow.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
module['exports'] = function(colors) {
|
||||
// RoY G BiV
|
||||
var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta'];
|
||||
return function(letter, i, exploded) {
|
||||
if (letter === ' ') {
|
||||
return letter;
|
||||
} else {
|
||||
return colors[rainbowColors[i++ % rainbowColors.length]](letter);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
11
node_modules/@colors/colors/lib/maps/random.js
generated
vendored
Normal file
11
node_modules/@colors/colors/lib/maps/random.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
module['exports'] = function(colors) {
|
||||
var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
|
||||
'blue', 'white', 'cyan', 'magenta', 'brightYellow', 'brightRed',
|
||||
'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan', 'brightMagenta'];
|
||||
return function(letter, i, exploded) {
|
||||
return letter === ' ' ? letter :
|
||||
colors[
|
||||
available[Math.round(Math.random() * (available.length - 2))]
|
||||
](letter);
|
||||
};
|
||||
};
|
||||
5
node_modules/@colors/colors/lib/maps/zebra.js
generated
vendored
Normal file
5
node_modules/@colors/colors/lib/maps/zebra.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
module['exports'] = function(colors) {
|
||||
return function(letter, i, exploded) {
|
||||
return i % 2 === 0 ? letter : colors.inverse(letter);
|
||||
};
|
||||
};
|
||||
95
node_modules/@colors/colors/lib/styles.js
generated
vendored
Normal file
95
node_modules/@colors/colors/lib/styles.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
|
||||
|
||||
*/
|
||||
|
||||
var styles = {};
|
||||
module['exports'] = styles;
|
||||
|
||||
var codes = {
|
||||
reset: [0, 0],
|
||||
|
||||
bold: [1, 22],
|
||||
dim: [2, 22],
|
||||
italic: [3, 23],
|
||||
underline: [4, 24],
|
||||
inverse: [7, 27],
|
||||
hidden: [8, 28],
|
||||
strikethrough: [9, 29],
|
||||
|
||||
black: [30, 39],
|
||||
red: [31, 39],
|
||||
green: [32, 39],
|
||||
yellow: [33, 39],
|
||||
blue: [34, 39],
|
||||
magenta: [35, 39],
|
||||
cyan: [36, 39],
|
||||
white: [37, 39],
|
||||
gray: [90, 39],
|
||||
grey: [90, 39],
|
||||
|
||||
brightRed: [91, 39],
|
||||
brightGreen: [92, 39],
|
||||
brightYellow: [93, 39],
|
||||
brightBlue: [94, 39],
|
||||
brightMagenta: [95, 39],
|
||||
brightCyan: [96, 39],
|
||||
brightWhite: [97, 39],
|
||||
|
||||
bgBlack: [40, 49],
|
||||
bgRed: [41, 49],
|
||||
bgGreen: [42, 49],
|
||||
bgYellow: [43, 49],
|
||||
bgBlue: [44, 49],
|
||||
bgMagenta: [45, 49],
|
||||
bgCyan: [46, 49],
|
||||
bgWhite: [47, 49],
|
||||
bgGray: [100, 49],
|
||||
bgGrey: [100, 49],
|
||||
|
||||
bgBrightRed: [101, 49],
|
||||
bgBrightGreen: [102, 49],
|
||||
bgBrightYellow: [103, 49],
|
||||
bgBrightBlue: [104, 49],
|
||||
bgBrightMagenta: [105, 49],
|
||||
bgBrightCyan: [106, 49],
|
||||
bgBrightWhite: [107, 49],
|
||||
|
||||
// legacy styles for colors pre v1.0.0
|
||||
blackBG: [40, 49],
|
||||
redBG: [41, 49],
|
||||
greenBG: [42, 49],
|
||||
yellowBG: [43, 49],
|
||||
blueBG: [44, 49],
|
||||
magentaBG: [45, 49],
|
||||
cyanBG: [46, 49],
|
||||
whiteBG: [47, 49],
|
||||
|
||||
};
|
||||
|
||||
Object.keys(codes).forEach(function(key) {
|
||||
var val = codes[key];
|
||||
var style = styles[key] = [];
|
||||
style.open = '\u001b[' + val[0] + 'm';
|
||||
style.close = '\u001b[' + val[1] + 'm';
|
||||
});
|
||||
35
node_modules/@colors/colors/lib/system/has-flag.js
generated
vendored
Normal file
35
node_modules/@colors/colors/lib/system/has-flag.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function(flag, argv) {
|
||||
argv = argv || process.argv || [];
|
||||
|
||||
var terminatorPos = argv.indexOf('--');
|
||||
var prefix = /^-{1,2}/.test(flag) ? '' : '--';
|
||||
var pos = argv.indexOf(prefix + flag);
|
||||
|
||||
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
||||
};
|
||||
151
node_modules/@colors/colors/lib/system/supports-colors.js
generated
vendored
Normal file
151
node_modules/@colors/colors/lib/system/supports-colors.js
generated
vendored
Normal file
@ -0,0 +1,151 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
|
||||
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var os = require('os');
|
||||
var hasFlag = require('./has-flag.js');
|
||||
|
||||
var env = process.env;
|
||||
|
||||
var forceColor = void 0;
|
||||
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
|
||||
forceColor = false;
|
||||
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true')
|
||||
|| hasFlag('color=always')) {
|
||||
forceColor = true;
|
||||
}
|
||||
if ('FORCE_COLOR' in env) {
|
||||
forceColor = env.FORCE_COLOR.length === 0
|
||||
|| parseInt(env.FORCE_COLOR, 10) !== 0;
|
||||
}
|
||||
|
||||
function translateLevel(level) {
|
||||
if (level === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return {
|
||||
level: level,
|
||||
hasBasic: true,
|
||||
has256: level >= 2,
|
||||
has16m: level >= 3,
|
||||
};
|
||||
}
|
||||
|
||||
function supportsColor(stream) {
|
||||
if (forceColor === false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hasFlag('color=16m') || hasFlag('color=full')
|
||||
|| hasFlag('color=truecolor')) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (hasFlag('color=256')) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (stream && !stream.isTTY && forceColor !== true) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var min = forceColor ? 1 : 0;
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Node.js 7.5.0 is the first version of Node.js to include a patch to
|
||||
// libuv that enables 256 color output on Windows. Anything earlier and it
|
||||
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
|
||||
// release, and Node.js 7 is not. Windows 10 build 10586 is the first
|
||||
// Windows release that supports 256 colors. Windows 10 build 14931 is the
|
||||
// first release that supports 16m/TrueColor.
|
||||
var osRelease = os.release().split('.');
|
||||
if (Number(process.versions.node.split('.')[0]) >= 8
|
||||
&& Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
||||
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('CI' in env) {
|
||||
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function(sign) {
|
||||
return sign in env;
|
||||
}) || env.CI_NAME === 'codeship') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
if ('TEAMCITY_VERSION' in env) {
|
||||
return (/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0
|
||||
);
|
||||
}
|
||||
|
||||
if ('TERM_PROGRAM' in env) {
|
||||
var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||
|
||||
switch (env.TERM_PROGRAM) {
|
||||
case 'iTerm.app':
|
||||
return version >= 3 ? 3 : 2;
|
||||
case 'Hyper':
|
||||
return 3;
|
||||
case 'Apple_Terminal':
|
||||
return 2;
|
||||
// No default
|
||||
}
|
||||
}
|
||||
|
||||
if (/-256(color)?$/i.test(env.TERM)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (env.TERM === 'dumb') {
|
||||
return min;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
function getSupportLevel(stream) {
|
||||
var level = supportsColor(stream);
|
||||
return translateLevel(level);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
supportsColor: getSupportLevel,
|
||||
stdout: getSupportLevel(process.stdout),
|
||||
stderr: getSupportLevel(process.stderr),
|
||||
};
|
||||
76
node_modules/@colors/colors/package.json
generated
vendored
Normal file
76
node_modules/@colors/colors/package.json
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"_from": "@colors/colors@^1.6.0",
|
||||
"_id": "@colors/colors@1.6.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==",
|
||||
"_location": "/@colors/colors",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@colors/colors@^1.6.0",
|
||||
"name": "@colors/colors",
|
||||
"escapedName": "@colors%2fcolors",
|
||||
"scope": "@colors",
|
||||
"rawSpec": "^1.6.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.6.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/logform",
|
||||
"/winston"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz",
|
||||
"_shasum": "ec6cd237440700bc23ca23087f513c75508958b0",
|
||||
"_spec": "@colors/colors@^1.6.0",
|
||||
"_where": "C:\\Users\\Wlad\\Desktop\\binance_bot\\node_modules\\winston",
|
||||
"author": {
|
||||
"name": "DABH"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/DABH/colors.js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "DABH",
|
||||
"url": "https://github.com/DABH"
|
||||
}
|
||||
],
|
||||
"deprecated": false,
|
||||
"description": "get colors in your node.js console",
|
||||
"devDependencies": {
|
||||
"eslint": "^8.9.0",
|
||||
"eslint-config-google": "^0.14.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.1.90"
|
||||
},
|
||||
"files": [
|
||||
"examples",
|
||||
"lib",
|
||||
"LICENSE",
|
||||
"safe.js",
|
||||
"themes",
|
||||
"index.d.ts",
|
||||
"safe.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/DABH/colors.js",
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"terminal",
|
||||
"colors"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "@colors/colors",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/DABH/colors.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint . --fix",
|
||||
"test": "export FORCE_COLOR=1 && node tests/basic-test.js && node tests/safe-test.js"
|
||||
},
|
||||
"version": "1.6.0"
|
||||
}
|
||||
64
node_modules/@colors/colors/safe.d.ts
generated
vendored
Normal file
64
node_modules/@colors/colors/safe.d.ts
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
// Type definitions for Colors.js 1.2
|
||||
// Project: https://github.com/Marak/colors.js
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Staffan Eketorp <https://github.com/staeke>
|
||||
// Definitions: https://github.com/Marak/colors.js
|
||||
|
||||
export const enabled: boolean;
|
||||
export function enable(): void;
|
||||
export function disable(): void;
|
||||
export function setTheme(theme: any): void;
|
||||
|
||||
export function strip(str: string): string;
|
||||
export function stripColors(str: string): string;
|
||||
|
||||
export function black(str: string): string;
|
||||
export function red(str: string): string;
|
||||
export function green(str: string): string;
|
||||
export function yellow(str: string): string;
|
||||
export function blue(str: string): string;
|
||||
export function magenta(str: string): string;
|
||||
export function cyan(str: string): string;
|
||||
export function white(str: string): string;
|
||||
export function gray(str: string): string;
|
||||
export function grey(str: string): string;
|
||||
|
||||
export function brightRed(str: string): string;
|
||||
export function brightGreen(str: string): string;
|
||||
export function brightYellow(str: string): string;
|
||||
export function brightBlue(str: string): string;
|
||||
export function brightMagenta(str: string): string;
|
||||
export function brightCyan(str: string): string;
|
||||
export function brightWhite(str: string): string;
|
||||
|
||||
export function bgBlack(str: string): string;
|
||||
export function bgRed(str: string): string;
|
||||
export function bgGreen(str: string): string;
|
||||
export function bgYellow(str: string): string;
|
||||
export function bgBlue(str: string): string;
|
||||
export function bgMagenta(str: string): string;
|
||||
export function bgCyan(str: string): string;
|
||||
export function bgWhite(str: string): string;
|
||||
|
||||
export function bgBrightRed(str: string): string;
|
||||
export function bgBrightGreen(str: string): string;
|
||||
export function bgBrightYellow(str: string): string;
|
||||
export function bgBrightBlue(str: string): string;
|
||||
export function bgBrightMagenta(str: string): string;
|
||||
export function bgBrightCyan(str: string): string;
|
||||
export function bgBrightWhite(str: string): string;
|
||||
|
||||
export function reset(str: string): string;
|
||||
export function bold(str: string): string;
|
||||
export function dim(str: string): string;
|
||||
export function italic(str: string): string;
|
||||
export function underline(str: string): string;
|
||||
export function inverse(str: string): string;
|
||||
export function hidden(str: string): string;
|
||||
export function strikethrough(str: string): string;
|
||||
|
||||
export function rainbow(str: string): string;
|
||||
export function zebra(str: string): string;
|
||||
export function america(str: string): string;
|
||||
export function trap(str: string): string;
|
||||
export function random(str: string): string;
|
||||
export function zalgo(str: string): string;
|
||||
10
node_modules/@colors/colors/safe.js
generated
vendored
Normal file
10
node_modules/@colors/colors/safe.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
//
|
||||
// Remark: Requiring this file will use the "safe" colors API,
|
||||
// which will not touch String.prototype.
|
||||
//
|
||||
// var colors = require('colors/safe');
|
||||
// colors.red("foo")
|
||||
//
|
||||
//
|
||||
var colors = require('./lib/colors');
|
||||
module['exports'] = colors;
|
||||
12
node_modules/@colors/colors/themes/generic-logging.js
generated
vendored
Normal file
12
node_modules/@colors/colors/themes/generic-logging.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
module['exports'] = {
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red',
|
||||
};
|
||||
26
node_modules/@dabh/diagnostics/CHANGELOG.md
generated
vendored
Normal file
26
node_modules/@dabh/diagnostics/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
# CHANGELOG
|
||||
|
||||
### 2.0.2
|
||||
|
||||
- Bump to kuler 2.0, which removes colornames as dependency, which we
|
||||
never used. So smaller install size, less dependencies for all.
|
||||
|
||||
### 2.0.1
|
||||
|
||||
- Use `storag-engine@3.0` which will automatically detect the correct
|
||||
AsyncStorage implementation.
|
||||
- The upgrade also fixes a bug where it the `debug` and `diagnostics` values
|
||||
to be JSON encoded instead of regular plain text.
|
||||
|
||||
### 2.0.0
|
||||
|
||||
- Documentation improvements.
|
||||
- Fixed a issue where async adapters were incorrectly detected.
|
||||
- Correctly inherit colors after applying colors the browser's console.
|
||||
|
||||
### 2.0.0-alpha
|
||||
|
||||
- Complete rewrite of all internals, now comes with separate builds for `browser`
|
||||
`node` and `react-native` as well as dedicated builds for `production` and
|
||||
`development` environments. Various utility methods and properties have
|
||||
been added to the returned logger to make your lives even easier.
|
||||
20
node_modules/@dabh/diagnostics/LICENSE
generated
vendored
Normal file
20
node_modules/@dabh/diagnostics/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Arnout Kazemier, Martijn Swaagman, the 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.
|
||||
473
node_modules/@dabh/diagnostics/README.md
generated
vendored
Normal file
473
node_modules/@dabh/diagnostics/README.md
generated
vendored
Normal file
@ -0,0 +1,473 @@
|
||||
# `diagnostics`
|
||||
|
||||
Diagnostics in the evolution of debug pattern that is used in the Node.js core,
|
||||
this extremely small but powerful technique can best be compared as feature
|
||||
flags for loggers. The created debug logger is disabled by default but can be
|
||||
enabled without changing a line of code, using flags.
|
||||
|
||||
- Allows debugging in multiple JavaScript environments such as Node.js, browsers
|
||||
and React-Native.
|
||||
- Separated development and production builds to minimize impact on your
|
||||
application when bundled.
|
||||
- Allows for customization of logger, messages, and much more.
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
The module is released in the public npm registry and can be installed by
|
||||
running:
|
||||
|
||||
```
|
||||
npm install --save @dabh/diagnostics
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Advanced usage](#advanced-usage)
|
||||
- [Production and development builds](#production-and-development-builds)
|
||||
- [WebPack](#webpack)
|
||||
- [Node.js](#nodejs)
|
||||
- [API](#api)
|
||||
- [.enabled](#enabled)
|
||||
- [.namespace](#namespace)
|
||||
- [.dev/prod](#devprod)
|
||||
- [set](#set)
|
||||
- [modify](#modify)
|
||||
- [use](#use)
|
||||
- [Modifiers](#modifiers)
|
||||
- [namespace](#namespace-1)
|
||||
- [Adapters](#adapters)
|
||||
- [process.env](#process-env)
|
||||
- [hash](#hash)
|
||||
- [localStorage](#localstorage)
|
||||
- [AsyncStorage](#asyncstorage)
|
||||
- [Loggers](#loggers)
|
||||
|
||||
### Introduction
|
||||
|
||||
To create a new logger simply `require` the `@dabh/diagnostics` module and call
|
||||
the returned function. It accepts 2 arguments:
|
||||
|
||||
1. `namespace` **Required** This is the namespace of your logger so we know if we need to
|
||||
enable your logger when a debug flag is used. Generally you use the name of
|
||||
your library or application as first root namespace. For example if you're
|
||||
building a parser in a library (example) you would set namespace
|
||||
`example:parser`.
|
||||
2. `options` An object with additional configuration for the logger.
|
||||
following keys are recognized:
|
||||
- `force` Force the logger to be enabled.
|
||||
- `colors` Colors are enabled by default for the logs, but you can set this
|
||||
option to `false` to disable it.
|
||||
|
||||
```js
|
||||
const debug = require('@dabh/diagnostics')('foo:bar:baz');
|
||||
const debug = require('@dabh/diagnostics')('foo:bar:baz', { options });
|
||||
|
||||
debug('this is a log message %s', 'that will only show up when enabled');
|
||||
debug('that is pretty neat', { log: 'more', data: 1337 });
|
||||
```
|
||||
|
||||
Unlike `console.log` statements that add and remove during your development
|
||||
lifecycle you create meaningful log statements that will give you insight in
|
||||
the library or application that you're developing.
|
||||
|
||||
The created debugger uses different "adapters" to extract the debug flag
|
||||
out of the JavaScript environment. To learn more about enabling the debug flag
|
||||
in your specific environment click on one of the enabled adapters below.
|
||||
|
||||
- **browser**: [localStorage](#localstorage), [hash](#hash)
|
||||
- **node.js**: [environment variables](#processenv)
|
||||
- **react-native**: [AsyncStorage](#asyncstorage)
|
||||
|
||||
Please note that the returned logger is fully configured out of the box, you
|
||||
do not need to set any of the adapters/modifiers your self, they are there
|
||||
for when you want more advanced control over the process. But if you want to
|
||||
learn more about that, read the next section.
|
||||
|
||||
### Advanced usage
|
||||
|
||||
There are 2 specific usage patterns for `diagnostic`, library developers who
|
||||
implement it as part of their modules and applications developers who either
|
||||
use it in their application or are searching for ways to consume the messages.
|
||||
|
||||
With the simple log interface as discussed in the [introduction](#introduction)
|
||||
section we make it easy for developers to add it as part of their libraries
|
||||
and applications, and with powerful [API](#api) we allow infinite customization
|
||||
by allowing custom adapters, loggers and modifiers to ensure that this library
|
||||
maintains relevant. These methods not only allow introduction of new loggers,
|
||||
but allow you think outside the box. For example you can maintain a history
|
||||
of past log messages, and output those when an uncaught exception happens in
|
||||
your application so you have additional context
|
||||
|
||||
```js
|
||||
const diagnostics = require('@dabh/diagnostics');
|
||||
|
||||
let index = 0;
|
||||
const limit = 200;
|
||||
const history = new Array(limit);
|
||||
|
||||
//
|
||||
// Force all `diagnostic` loggers to be enabled.
|
||||
//
|
||||
diagnostics.force = process.env.NODE_ENV === 'prod';
|
||||
diagnostics.set(function customLogger(meta, message) {
|
||||
history[index]= { meta, message, now: Date.now() };
|
||||
if (index++ === limit) index = 0;
|
||||
|
||||
//
|
||||
// We're running a development build, so output.
|
||||
//
|
||||
if (meta.dev) console.log.apply(console, message);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', async function (err) {
|
||||
await saveErrorToDisk(err, history);
|
||||
process.exit(1);
|
||||
});
|
||||
```
|
||||
|
||||
The small snippet above will maintain a 200 limited FIFO (First In First Out)
|
||||
queue of all debug messages that can be referenced when your application crashes
|
||||
|
||||
#### Production and development builds
|
||||
|
||||
When you `require` the `@dabh/diagnostics` module you will be given a logger that is
|
||||
optimized for `development` so it can provide the best developer experience
|
||||
possible.
|
||||
|
||||
The development logger enables all the [adapters](#adapters) for your
|
||||
JavaScript environment, adds a logger that outputs the messages to `console.log`
|
||||
and registers our message modifiers so log messages will be prefixed with the
|
||||
supplied namespace so you know where the log messages originates from.
|
||||
|
||||
The development logger does not have any adapter, modifier and logger enabled
|
||||
by default. This ensures that your log messages never accidentally show up in
|
||||
production. However this does not mean that it's not possible to get debug
|
||||
messages in production. You can `force` the debugger to be enabled, and
|
||||
supply a [custom logger](#loggers).
|
||||
|
||||
```js
|
||||
const diagnostics = require('@dabh/diagnostics');
|
||||
const debug = debug('foo:bar', { force: true });
|
||||
|
||||
//
|
||||
// Or enable _every_ diagnostic instance:
|
||||
//
|
||||
diagnostics.force = true;
|
||||
```
|
||||
|
||||
##### WebPack
|
||||
|
||||
WebPack has the concept of [mode](https://webpack.js.org/concepts/mode/#usage)'s
|
||||
which creates different
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
mode: 'development' // 'production'
|
||||
}
|
||||
```
|
||||
|
||||
When you are building your app using the WebPack CLI you can use the `--mode`
|
||||
flag:
|
||||
|
||||
```
|
||||
webpack --mode=production app.js -o /dist/bundle.js
|
||||
```
|
||||
|
||||
##### Node.js
|
||||
|
||||
When you are running your app using `Node.js` you should the `NODE_ENV`
|
||||
environment variable to `production` to ensure that you libraries that you
|
||||
import are optimized for production.
|
||||
|
||||
```
|
||||
NODE_ENV=production node app.js
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
The returned logger exposes some addition properties that can be used used in
|
||||
your application or library:
|
||||
|
||||
#### .enabled
|
||||
|
||||
The returned logger will have a `.enabled` property assigned to it. This boolean
|
||||
can be used to check if the logger was enabled:
|
||||
|
||||
```js
|
||||
const debug = require('@dabh/diagnostics')('foo:bar');
|
||||
|
||||
if (debug.enabled) {
|
||||
//
|
||||
// Do something special
|
||||
//
|
||||
}
|
||||
```
|
||||
|
||||
This property is exposed as:
|
||||
|
||||
- Property on the logger.
|
||||
- Property on the meta/options object.
|
||||
|
||||
#### .namespace
|
||||
|
||||
This is the namespace that you originally provided to the function.
|
||||
|
||||
```js
|
||||
const debug = require('@dabh/diagnostics')('foo:bar');
|
||||
|
||||
console.log(debug.namespace); // foo:bar
|
||||
```
|
||||
|
||||
This property is exposed as:
|
||||
|
||||
- Property on the logger.
|
||||
- Property on the meta/options object.
|
||||
|
||||
#### .dev/prod
|
||||
|
||||
There are different builds available of `diagnostics`, when you create a
|
||||
production build of your application using `NODE_ENV=production` you will be
|
||||
given an optimized, smaller build of `diagnostics` to reduce your bundle size.
|
||||
The `dev` and `prod` booleans on the returned logger indicate if you have a
|
||||
production or development version of the logger.
|
||||
|
||||
```js
|
||||
const debug = require('@dabh/diagnostics')('foo:bar');
|
||||
|
||||
if (debug.prod) {
|
||||
// do stuff
|
||||
}
|
||||
```
|
||||
|
||||
This property is exposed as:
|
||||
|
||||
- Property on the logger.
|
||||
- Property on the meta/options object.
|
||||
|
||||
#### set
|
||||
|
||||
Sets a new logger as default for **all** `diagnostic` instances. The passed
|
||||
argument should be a function that write the log messages to where ever you
|
||||
want. It receives 2 arguments:
|
||||
|
||||
1. `meta` An object with all the options that was provided to the original
|
||||
logger that wants to write the log message as well as properties of the
|
||||
debugger such as `prod`, `dev`, `namespace`, `enabled`. See [API](#api) for
|
||||
all exposed properties.
|
||||
2. `args` An array of the log messages that needs to be written.
|
||||
|
||||
```js
|
||||
const debug = require('@dabh/diagnostics')('foo:more:namespaces');
|
||||
|
||||
debug.use(function logger(meta, args) {
|
||||
console.log(meta);
|
||||
console.debug(...args);
|
||||
});
|
||||
```
|
||||
|
||||
This method is exposed as:
|
||||
|
||||
- Method on the logger.
|
||||
- Method on the meta/options object.
|
||||
- Method on `diagnostics` module.
|
||||
|
||||
#### modify
|
||||
|
||||
The modify method allows you add a new message modifier to **all** `diagnostic`
|
||||
instances. The passed argument should be a function that returns the passed
|
||||
message after modification. The function receives 2 arguments:
|
||||
|
||||
1. `message`, Array, the log message.
|
||||
2. `options`, Object, the options that were passed into the logger when it was
|
||||
initially created.
|
||||
|
||||
```js
|
||||
const debug = require('@dabh/diagnostics')('example:modifiers');
|
||||
|
||||
debug.modify(function (message, options) {
|
||||
return messages;
|
||||
});
|
||||
```
|
||||
|
||||
This method is exposed as:
|
||||
|
||||
- Method on the logger.
|
||||
- Method on the meta/options object.
|
||||
- Method on `diagnostics` module.
|
||||
|
||||
See [modifiers](#modifiers) for more information.
|
||||
|
||||
#### use
|
||||
|
||||
Adds a new `adapter` to **all** `diagnostic` instances. The passed argument
|
||||
should be a function returns a boolean that indicates if the passed in
|
||||
`namespace` is allowed to write log messages.
|
||||
|
||||
```js
|
||||
const diagnostics = require('@dabh/diagnostics');
|
||||
const debug = diagnostics('foo:bar');
|
||||
|
||||
debug.use(function (namespace) {
|
||||
return namespace === 'foo:bar';
|
||||
});
|
||||
```
|
||||
|
||||
This method is exposed as:
|
||||
|
||||
- Method on the logger.
|
||||
- Method on the meta/options object.
|
||||
- Method on `diagnostics` module.
|
||||
|
||||
See [adapters](#adapters) for more information.
|
||||
|
||||
### Modifiers
|
||||
|
||||
To be as flexible as possible when it comes to transforming messages we've
|
||||
come up with the concept of `modifiers` which can enhance the debug messages.
|
||||
This allows you to introduce functionality or details that you find important
|
||||
for debug messages, and doesn't require us to add additional bloat to the
|
||||
`diagnostic` core.
|
||||
|
||||
For example, you want the messages to be prefixed with the date-time of when
|
||||
the log message occured:
|
||||
|
||||
```js
|
||||
const diagnostics = require('@dabh/diagnostics');
|
||||
|
||||
diagnostics.modify(function datetime(args, options) {
|
||||
args.unshift(new Date());
|
||||
return args;
|
||||
});
|
||||
```
|
||||
|
||||
Now all messages will be prefixed with date that is outputted by `new Date()`.
|
||||
The following modifiers are shipped with `diagnostics` and are enabled in
|
||||
**development** mode only:
|
||||
|
||||
- [namespace](#namespace)
|
||||
|
||||
#### namespace
|
||||
|
||||
This modifier is enabled for all debug instances and prefixes the messages
|
||||
with the name of namespace under which it is logged. The namespace is colored
|
||||
using the `colorspace` module which groups similar namespaces under the same
|
||||
colorspace. You can have multiple namespaces for the debuggers where each
|
||||
namespace should be separated by a `:`
|
||||
|
||||
```
|
||||
foo
|
||||
foo:bar
|
||||
foo:bar:baz
|
||||
```
|
||||
|
||||
For console based output the `namespace-ansi` is used.
|
||||
|
||||
### Adapters
|
||||
|
||||
Adapters allows `diagnostics` to pull the `DEBUG` and `DIAGNOSTICS` environment
|
||||
variables from different sources. Not every JavaScript environment has a
|
||||
`process.env` that we can leverage. Adapters allows us to have different
|
||||
adapters for different environments. It means you can write your own custom
|
||||
adapter if needed as well.
|
||||
|
||||
The `adapter` function should be passed a function as argument, this function
|
||||
will receive the `namespace` of a logger as argument and it should return a
|
||||
boolean that indicates if that logger should be enabled or not.
|
||||
|
||||
```js
|
||||
const debug = require('@dabh/diagnostics')('example:namespace');
|
||||
|
||||
debug.adapter(require('@dabh/diagnostics/adapters/localstorage'));
|
||||
```
|
||||
|
||||
The modifiers are only enabled for `development`. The following adapters are
|
||||
available are available:
|
||||
|
||||
#### process.env
|
||||
|
||||
This adapter is enabled for `node.js`.
|
||||
|
||||
Uses the `DEBUG` or `DIAGNOSTICS` (both are recognized) environment variables to
|
||||
pass in debug flag:
|
||||
|
||||
**UNIX/Linux/Mac**
|
||||
```
|
||||
DEBUG=foo* node index.js
|
||||
```
|
||||
|
||||
Using environment variables on Windows is a bit different, and also depends on
|
||||
toolchain you are using:
|
||||
|
||||
**Windows**
|
||||
```
|
||||
set DEBUG=foo* & node index.js
|
||||
```
|
||||
|
||||
**Powershell**
|
||||
```
|
||||
$env:DEBUG='foo*';node index.js
|
||||
```
|
||||
|
||||
#### hash
|
||||
|
||||
This adapter is enabled for `browsers`.
|
||||
|
||||
This adapter uses the `window.location.hash` of as source for the environment
|
||||
variables. It assumes that hash is formatted using the same syntax as query
|
||||
strings:
|
||||
|
||||
```js
|
||||
http://example.com/foo/bar#debug=foo*
|
||||
```
|
||||
|
||||
It triggers on both the `debug=` and `diagnostics=` names.
|
||||
|
||||
#### localStorage
|
||||
|
||||
This adapter is enabled for `browsers`.
|
||||
|
||||
This adapter uses the `localStorage` of the browser to store the debug flags.
|
||||
You can set the debug flag your self in your application code, but you can
|
||||
also open browser WebInspector and enable it through the console.
|
||||
|
||||
```js
|
||||
localStorage.setItem('debug', 'foo*');
|
||||
```
|
||||
|
||||
It triggers on both the `debug` and `diagnostics` storage items. (Please note
|
||||
that these keys should be entered in lowercase)
|
||||
|
||||
#### AsyncStorage
|
||||
|
||||
This adapter is enabled for `react-native`.
|
||||
|
||||
This adapter uses the `AsyncStorage` API that is exposed by the `react-native`
|
||||
library to store and read the `debug` or `diagnostics` storage items.
|
||||
|
||||
```js
|
||||
import { AsyncStorage } from 'react-native';
|
||||
|
||||
AsyncStorage.setItem('debug', 'foo*');
|
||||
```
|
||||
|
||||
Unlike other adapters, this is the only adapter that is `async` so that means
|
||||
that we're not able to instantly determine if a created logger should be
|
||||
enabled or disabled. So when a logger is created in `react-native` we initially
|
||||
assume it's disabled, any message that send during period will be queued
|
||||
internally.
|
||||
|
||||
Once we've received the data from the `AsyncStorage` API we will determine
|
||||
if the logger should be enabled, flush the queued messages if needed and set
|
||||
all `enabled` properties accordingly on the returned logger.
|
||||
|
||||
### Loggers
|
||||
|
||||
By default it will log all messages to `console.log` in when the logger is
|
||||
enabled using the debug flag that is set using one of the adapters.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
11
node_modules/@dabh/diagnostics/adapters/hash.js
generated
vendored
Normal file
11
node_modules/@dabh/diagnostics/adapters/hash.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
var adapter = require('./');
|
||||
|
||||
/**
|
||||
* Extracts the values from process.env.
|
||||
*
|
||||
* @type {Function}
|
||||
* @public
|
||||
*/
|
||||
module.exports = adapter(function hash() {
|
||||
return /(debug|diagnostics)=([^&]+)/i.exec(window.location.hash)[2];
|
||||
});
|
||||
18
node_modules/@dabh/diagnostics/adapters/index.js
generated
vendored
Normal file
18
node_modules/@dabh/diagnostics/adapters/index.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
var enabled = require('enabled');
|
||||
|
||||
/**
|
||||
* Creates a new Adapter.
|
||||
*
|
||||
* @param {Function} fn Function that returns the value.
|
||||
* @returns {Function} The adapter logic.
|
||||
* @public
|
||||
*/
|
||||
module.exports = function create(fn) {
|
||||
return function adapter(namespace) {
|
||||
try {
|
||||
return enabled(namespace, fn());
|
||||
} catch (e) { /* Any failure means that we found nothing */ }
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
11
node_modules/@dabh/diagnostics/adapters/localstorage.js
generated
vendored
Normal file
11
node_modules/@dabh/diagnostics/adapters/localstorage.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
var adapter = require('./');
|
||||
|
||||
/**
|
||||
* Extracts the values from process.env.
|
||||
*
|
||||
* @type {Function}
|
||||
* @public
|
||||
*/
|
||||
module.exports = adapter(function storage() {
|
||||
return localStorage.getItem('debug') || localStorage.getItem('diagnostics');
|
||||
});
|
||||
11
node_modules/@dabh/diagnostics/adapters/process.env.js
generated
vendored
Normal file
11
node_modules/@dabh/diagnostics/adapters/process.env.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
var adapter = require('./');
|
||||
|
||||
/**
|
||||
* Extracts the values from process.env.
|
||||
*
|
||||
* @type {Function}
|
||||
* @public
|
||||
*/
|
||||
module.exports = adapter(function processenv() {
|
||||
return process.env.DEBUG || process.env.DIAGNOSTICS;
|
||||
});
|
||||
35
node_modules/@dabh/diagnostics/browser/development.js
generated
vendored
Normal file
35
node_modules/@dabh/diagnostics/browser/development.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
var create = require('../diagnostics');
|
||||
|
||||
/**
|
||||
* Create a new diagnostics logger.
|
||||
*
|
||||
* @param {String} namespace The namespace it should enable.
|
||||
* @param {Object} options Additional options.
|
||||
* @returns {Function} The logger.
|
||||
* @public
|
||||
*/
|
||||
var diagnostics = create(function dev(namespace, options) {
|
||||
options = options || {};
|
||||
options.namespace = namespace;
|
||||
options.prod = false;
|
||||
options.dev = true;
|
||||
|
||||
if (!dev.enabled(namespace) && !(options.force || dev.force)) {
|
||||
return dev.nope(options);
|
||||
}
|
||||
|
||||
return dev.yep(options);
|
||||
});
|
||||
|
||||
//
|
||||
// Configure the logger for the given environment.
|
||||
//
|
||||
diagnostics.modify(require('../modifiers/namespace'));
|
||||
diagnostics.use(require('../adapters/localstorage'));
|
||||
diagnostics.use(require('../adapters/hash'));
|
||||
diagnostics.set(require('../logger/console'));
|
||||
|
||||
//
|
||||
// Expose the diagnostics logger.
|
||||
//
|
||||
module.exports = diagnostics;
|
||||
8
node_modules/@dabh/diagnostics/browser/index.js
generated
vendored
Normal file
8
node_modules/@dabh/diagnostics/browser/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// Select the correct build version depending on the environment.
|
||||
//
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./production.js');
|
||||
} else {
|
||||
module.exports = require('./development.js');
|
||||
}
|
||||
6
node_modules/@dabh/diagnostics/browser/override.js
generated
vendored
Normal file
6
node_modules/@dabh/diagnostics/browser/override.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
var diagnostics = require('./');
|
||||
|
||||
//
|
||||
// No way to override `debug` with `diagnostics` in the browser.
|
||||
//
|
||||
module.exports = diagnostics;
|
||||
24
node_modules/@dabh/diagnostics/browser/production.js
generated
vendored
Normal file
24
node_modules/@dabh/diagnostics/browser/production.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
var create = require('../diagnostics');
|
||||
|
||||
/**
|
||||
* Create a new diagnostics logger.
|
||||
*
|
||||
* @param {String} namespace The namespace it should enable.
|
||||
* @param {Object} options Additional options.
|
||||
* @returns {Function} The logger.
|
||||
* @public
|
||||
*/
|
||||
var diagnostics = create(function prod(namespace, options) {
|
||||
options = options || {};
|
||||
options.namespace = namespace;
|
||||
options.prod = true;
|
||||
options.dev = false;
|
||||
|
||||
if (!(options.force || prod.force)) return prod.nope(options);
|
||||
return prod.yep(options);
|
||||
});
|
||||
|
||||
//
|
||||
// Expose the diagnostics logger.
|
||||
//
|
||||
module.exports = diagnostics;
|
||||
212
node_modules/@dabh/diagnostics/diagnostics.js
generated
vendored
Normal file
212
node_modules/@dabh/diagnostics/diagnostics.js
generated
vendored
Normal file
@ -0,0 +1,212 @@
|
||||
/**
|
||||
* Contains all configured adapters for the given environment.
|
||||
*
|
||||
* @type {Array}
|
||||
* @public
|
||||
*/
|
||||
var adapters = [];
|
||||
|
||||
/**
|
||||
* Contains all modifier functions.
|
||||
*
|
||||
* @typs {Array}
|
||||
* @public
|
||||
*/
|
||||
var modifiers = [];
|
||||
|
||||
/**
|
||||
* Our default logger.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
var logger = function devnull() {};
|
||||
|
||||
/**
|
||||
* Register a new adapter that will used to find environments.
|
||||
*
|
||||
* @param {Function} adapter A function that will return the possible env.
|
||||
* @returns {Boolean} Indication of a successful add.
|
||||
* @public
|
||||
*/
|
||||
function use(adapter) {
|
||||
if (~adapters.indexOf(adapter)) return false;
|
||||
|
||||
adapters.push(adapter);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a new log method.
|
||||
*
|
||||
* @param {Function} custom The log method.
|
||||
* @public
|
||||
*/
|
||||
function set(custom) {
|
||||
logger = custom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the namespace is allowed by any of our adapters.
|
||||
*
|
||||
* @param {String} namespace The namespace that needs to be enabled
|
||||
* @returns {Boolean|Promise} Indication if the namespace is enabled by our adapters.
|
||||
* @public
|
||||
*/
|
||||
function enabled(namespace) {
|
||||
var async = [];
|
||||
|
||||
for (var i = 0; i < adapters.length; i++) {
|
||||
if (adapters[i].async) {
|
||||
async.push(adapters[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (adapters[i](namespace)) return true;
|
||||
}
|
||||
|
||||
if (!async.length) return false;
|
||||
|
||||
//
|
||||
// Now that we know that we Async functions, we know we run in an ES6
|
||||
// environment and can use all the API's that they offer, in this case
|
||||
// we want to return a Promise so that we can `await` in React-Native
|
||||
// for an async adapter.
|
||||
//
|
||||
return new Promise(function pinky(resolve) {
|
||||
Promise.all(
|
||||
async.map(function prebind(fn) {
|
||||
return fn(namespace);
|
||||
})
|
||||
).then(function resolved(values) {
|
||||
resolve(values.some(Boolean));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new message modifier to the debugger.
|
||||
*
|
||||
* @param {Function} fn Modification function.
|
||||
* @returns {Boolean} Indication of a successful add.
|
||||
* @public
|
||||
*/
|
||||
function modify(fn) {
|
||||
if (~modifiers.indexOf(fn)) return false;
|
||||
|
||||
modifiers.push(fn);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to the supplied logger.
|
||||
*
|
||||
* @param {Object} meta Meta information about the log.
|
||||
* @param {Array} args Arguments for console.log.
|
||||
* @public
|
||||
*/
|
||||
function write() {
|
||||
logger.apply(logger, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the message with the modifiers.
|
||||
*
|
||||
* @param {Mixed} message The message to be transformed by modifers.
|
||||
* @returns {String} Transformed message.
|
||||
* @public
|
||||
*/
|
||||
function process(message) {
|
||||
for (var i = 0; i < modifiers.length; i++) {
|
||||
message = modifiers[i].apply(modifiers[i], arguments);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Introduce options to the logger function.
|
||||
*
|
||||
* @param {Function} fn Calback function.
|
||||
* @param {Object} options Properties to introduce on fn.
|
||||
* @returns {Function} The passed function
|
||||
* @public
|
||||
*/
|
||||
function introduce(fn, options) {
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
for (var key in options) {
|
||||
if (has.call(options, key)) {
|
||||
fn[key] = options[key];
|
||||
}
|
||||
}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nope, we're not allowed to write messages.
|
||||
*
|
||||
* @returns {Boolean} false
|
||||
* @public
|
||||
*/
|
||||
function nope(options) {
|
||||
options.enabled = false;
|
||||
options.modify = modify;
|
||||
options.set = set;
|
||||
options.use = use;
|
||||
|
||||
return introduce(function diagnopes() {
|
||||
return false;
|
||||
}, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Yep, we're allowed to write debug messages.
|
||||
*
|
||||
* @param {Object} options The options for the process.
|
||||
* @returns {Function} The function that does the logging.
|
||||
* @public
|
||||
*/
|
||||
function yep(options) {
|
||||
/**
|
||||
* The function that receives the actual debug information.
|
||||
*
|
||||
* @returns {Boolean} indication that we're logging.
|
||||
* @public
|
||||
*/
|
||||
function diagnostics() {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
|
||||
write.call(write, options, process(args, options));
|
||||
return true;
|
||||
}
|
||||
|
||||
options.enabled = true;
|
||||
options.modify = modify;
|
||||
options.set = set;
|
||||
options.use = use;
|
||||
|
||||
return introduce(diagnostics, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple helper function to introduce various of helper methods to our given
|
||||
* diagnostics function.
|
||||
*
|
||||
* @param {Function} diagnostics The diagnostics function.
|
||||
* @returns {Function} diagnostics
|
||||
* @public
|
||||
*/
|
||||
module.exports = function create(diagnostics) {
|
||||
diagnostics.introduce = introduce;
|
||||
diagnostics.enabled = enabled;
|
||||
diagnostics.process = process;
|
||||
diagnostics.modify = modify;
|
||||
diagnostics.write = write;
|
||||
diagnostics.nope = nope;
|
||||
diagnostics.yep = yep;
|
||||
diagnostics.set = set;
|
||||
diagnostics.use = use;
|
||||
|
||||
return diagnostics;
|
||||
}
|
||||
19
node_modules/@dabh/diagnostics/logger/console.js
generated
vendored
Normal file
19
node_modules/@dabh/diagnostics/logger/console.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* An idiot proof logger to be used as default. We've wrapped it in a try/catch
|
||||
* statement to ensure the environments without the `console` API do not crash
|
||||
* as well as an additional fix for ancient browsers like IE8 where the
|
||||
* `console.log` API doesn't have an `apply`, so we need to use the Function's
|
||||
* apply functionality to apply the arguments.
|
||||
*
|
||||
* @param {Object} meta Options of the logger.
|
||||
* @param {Array} messages The actuall message that needs to be logged.
|
||||
* @public
|
||||
*/
|
||||
module.exports = function (meta, messages) {
|
||||
//
|
||||
// So yea. IE8 doesn't have an apply so we need a work around to puke the
|
||||
// arguments in place.
|
||||
//
|
||||
try { Function.prototype.apply.call(console.log, console, messages); }
|
||||
catch (e) {}
|
||||
}
|
||||
20
node_modules/@dabh/diagnostics/modifiers/namespace-ansi.js
generated
vendored
Normal file
20
node_modules/@dabh/diagnostics/modifiers/namespace-ansi.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
var colorspace = require('colorspace');
|
||||
var kuler = require('kuler');
|
||||
|
||||
/**
|
||||
* Prefix the messages with a colored namespace.
|
||||
*
|
||||
* @param {Array} args The messages array that is getting written.
|
||||
* @param {Object} options Options for diagnostics.
|
||||
* @returns {Array} Altered messages array.
|
||||
* @public
|
||||
*/
|
||||
module.exports = function ansiModifier(args, options) {
|
||||
var namespace = options.namespace;
|
||||
var ansi = options.colors !== false
|
||||
? kuler(namespace +':', colorspace(namespace))
|
||||
: namespace +':';
|
||||
|
||||
args[0] = ansi +' '+ args[0];
|
||||
return args;
|
||||
};
|
||||
32
node_modules/@dabh/diagnostics/modifiers/namespace.js
generated
vendored
Normal file
32
node_modules/@dabh/diagnostics/modifiers/namespace.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
var colorspace = require('colorspace');
|
||||
|
||||
/**
|
||||
* Prefix the messages with a colored namespace.
|
||||
*
|
||||
* @param {Array} messages The messages array that is getting written.
|
||||
* @param {Object} options Options for diagnostics.
|
||||
* @returns {Array} Altered messages array.
|
||||
* @public
|
||||
*/
|
||||
module.exports = function colorNamespace(args, options) {
|
||||
var namespace = options.namespace;
|
||||
|
||||
if (options.colors === false) {
|
||||
args[0] = namespace +': '+ args[0];
|
||||
return args;
|
||||
}
|
||||
|
||||
var color = colorspace(namespace);
|
||||
|
||||
//
|
||||
// The console API supports a special %c formatter in browsers. This is used
|
||||
// to style console messages with any CSS styling, in our case we want to
|
||||
// use colorize the namespace for clarity. As these are formatters, and
|
||||
// we need to inject our CSS string as second messages argument so it
|
||||
// gets picked up correctly.
|
||||
//
|
||||
args[0] = '%c'+ namespace +':%c '+ args[0];
|
||||
args.splice(1, 0, 'color:'+ color, 'color:inherit');
|
||||
|
||||
return args;
|
||||
};
|
||||
36
node_modules/@dabh/diagnostics/node/development.js
generated
vendored
Normal file
36
node_modules/@dabh/diagnostics/node/development.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
var create = require('../diagnostics');
|
||||
var tty = require('tty').isatty(1);
|
||||
|
||||
/**
|
||||
* Create a new diagnostics logger.
|
||||
*
|
||||
* @param {String} namespace The namespace it should enable.
|
||||
* @param {Object} options Additional options.
|
||||
* @returns {Function} The logger.
|
||||
* @public
|
||||
*/
|
||||
var diagnostics = create(function dev(namespace, options) {
|
||||
options = options || {};
|
||||
options.colors = 'colors' in options ? options.colors : tty;
|
||||
options.namespace = namespace;
|
||||
options.prod = false;
|
||||
options.dev = true;
|
||||
|
||||
if (!dev.enabled(namespace) && !(options.force || dev.force)) {
|
||||
return dev.nope(options);
|
||||
}
|
||||
|
||||
return dev.yep(options);
|
||||
});
|
||||
|
||||
//
|
||||
// Configure the logger for the given environment.
|
||||
//
|
||||
diagnostics.modify(require('../modifiers/namespace-ansi'));
|
||||
diagnostics.use(require('../adapters/process.env'));
|
||||
diagnostics.set(require('../logger/console'));
|
||||
|
||||
//
|
||||
// Expose the diagnostics logger.
|
||||
//
|
||||
module.exports = diagnostics;
|
||||
8
node_modules/@dabh/diagnostics/node/index.js
generated
vendored
Normal file
8
node_modules/@dabh/diagnostics/node/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
//
|
||||
// Select the correct build version depending on the environment.
|
||||
//
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./production.js');
|
||||
} else {
|
||||
module.exports = require('./development.js');
|
||||
}
|
||||
21
node_modules/@dabh/diagnostics/node/override.js
generated
vendored
Normal file
21
node_modules/@dabh/diagnostics/node/override.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
const diagnostics = require('./');
|
||||
|
||||
//
|
||||
// Override the existing `debug` call so it will use `diagnostics` instead
|
||||
// of the `debug` module.
|
||||
//
|
||||
try {
|
||||
var key = require.resolve('debug');
|
||||
|
||||
require.cache[key] = {
|
||||
exports: diagnostics,
|
||||
filename: key,
|
||||
loaded: true,
|
||||
id: key
|
||||
};
|
||||
} catch (e) { /* We don't really care if it fails */ }
|
||||
|
||||
//
|
||||
// Export the default import as exports again.
|
||||
//
|
||||
module.exports = diagnostics;
|
||||
24
node_modules/@dabh/diagnostics/node/production.js
generated
vendored
Normal file
24
node_modules/@dabh/diagnostics/node/production.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
var create = require('../diagnostics');
|
||||
|
||||
/**
|
||||
* Create a new diagnostics logger.
|
||||
*
|
||||
* @param {String} namespace The namespace it should enable.
|
||||
* @param {Object} options Additional options.
|
||||
* @returns {Function} The logger.
|
||||
* @public
|
||||
*/
|
||||
var diagnostics = create(function prod(namespace, options) {
|
||||
options = options || {};
|
||||
options.namespace = namespace;
|
||||
options.prod = true;
|
||||
options.dev = false;
|
||||
|
||||
if (!(options.force || prod.force)) return prod.nope(options);
|
||||
return prod.yep(options);
|
||||
});
|
||||
|
||||
//
|
||||
// Expose the diagnostics logger.
|
||||
//
|
||||
module.exports = diagnostics;
|
||||
101
node_modules/@dabh/diagnostics/package.json
generated
vendored
Normal file
101
node_modules/@dabh/diagnostics/package.json
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
{
|
||||
"_from": "@dabh/diagnostics@^2.0.2",
|
||||
"_id": "@dabh/diagnostics@2.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==",
|
||||
"_location": "/@dabh/diagnostics",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@dabh/diagnostics@^2.0.2",
|
||||
"name": "@dabh/diagnostics",
|
||||
"escapedName": "@dabh%2fdiagnostics",
|
||||
"scope": "@dabh",
|
||||
"rawSpec": "^2.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/winston"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz",
|
||||
"_shasum": "7f7e97ee9a725dffc7808d93668cc984e1dc477a",
|
||||
"_spec": "@dabh/diagnostics@^2.0.2",
|
||||
"_where": "C:\\Users\\Wlad\\Desktop\\binance_bot\\node_modules\\winston",
|
||||
"author": {
|
||||
"name": "Arnout Kazemier"
|
||||
},
|
||||
"browser": "./browser",
|
||||
"bugs": {
|
||||
"url": "https://github.com/3rd-Eden/diagnostics/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Martijn Swaagman",
|
||||
"url": "https://github.com/swaagie"
|
||||
},
|
||||
{
|
||||
"name": "Jarrett Cruger",
|
||||
"url": "https://github.com/jcrugzz"
|
||||
},
|
||||
{
|
||||
"name": "Sevastos",
|
||||
"url": "https://github.com/sevastos"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"colorspace": "1.1.x",
|
||||
"enabled": "2.0.x",
|
||||
"kuler": "^2.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Tools for debugging your node.js modules and event loop",
|
||||
"devDependencies": {
|
||||
"assume": "2.3.x",
|
||||
"asyncstorageapi": "^1.0.2",
|
||||
"mocha": "9.2.x",
|
||||
"nyc": "^15.1.0",
|
||||
"objstorage": "^1.0.0",
|
||||
"pre-commit": "1.2.x",
|
||||
"require-poisoning": "^2.0.0",
|
||||
"webpack": "4.x",
|
||||
"webpack-bundle-size-analyzer": "^3.0.0",
|
||||
"webpack-cli": "3.x"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"homepage": "https://github.com/3rd-Eden/diagnostics",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"debugger",
|
||||
"debugging",
|
||||
"diagnostic",
|
||||
"diagnostics",
|
||||
"event",
|
||||
"loop",
|
||||
"metrics",
|
||||
"stats"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./node",
|
||||
"name": "@dabh/diagnostics",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/3rd-Eden/diagnostics.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "nyc --reporter=text --reporter=lcov npm run test:runner",
|
||||
"test:basic": "mocha --require test/mock.js test/*.test.js",
|
||||
"test:browser": "mocha --require test/mock test/browser.js",
|
||||
"test:node": "mocha --require test/mock test/node.js",
|
||||
"test:runner": "npm run test:basic && npm run test:node && npm run test:browser",
|
||||
"webpack:browser:dev": "webpack --mode=development browser/index.js -o /dev/null --json | webpack-bundle-size-analyzer",
|
||||
"webpack:browser:prod": "webpack --mode=production browser/index.js -o /dev/null --json | webpack-bundle-size-analyzer",
|
||||
"webpack:node:dev": "webpack --mode=development node/index.js -o /dev/null --json | webpack-bundle-size-analyzer",
|
||||
"webpack:node:prod": "webpack --mode=production node/index.js -o /dev/null --json | webpack-bundle-size-analyzer"
|
||||
},
|
||||
"version": "2.0.3"
|
||||
}
|
||||
21
node_modules/@discoveryjs/json-ext/LICENSE
generated
vendored
Normal file
21
node_modules/@discoveryjs/json-ext/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Roman Dvornov <rdvornov@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.
|
||||
256
node_modules/@discoveryjs/json-ext/README.md
generated
vendored
Normal file
256
node_modules/@discoveryjs/json-ext/README.md
generated
vendored
Normal file
@ -0,0 +1,256 @@
|
||||
# json-ext
|
||||
|
||||
[](https://www.npmjs.com/package/@discoveryjs/json-ext)
|
||||
[](https://github.com/discoveryjs/json-ext/actions/workflows/ci.yml)
|
||||
[](https://coveralls.io/github/discoveryjs/json-ext?)
|
||||
[](https://www.npmjs.com/package/@discoveryjs/json-ext)
|
||||
|
||||
A set of utilities that extend the use of JSON. Designed to be fast and memory efficient
|
||||
|
||||
Features:
|
||||
|
||||
- [x] `parseChunked()` – Parse JSON that comes by chunks (e.g. FS readable stream or fetch response stream)
|
||||
- [x] `stringifyStream()` – Stringify stream (Node.js)
|
||||
- [x] `stringifyInfo()` – Get estimated size and other facts of JSON.stringify() without converting a value to string
|
||||
- [ ] **TBD** Support for circular references
|
||||
- [ ] **TBD** Binary representation [branch](https://github.com/discoveryjs/json-ext/tree/binary)
|
||||
- [ ] **TBD** WHATWG [Streams](https://streams.spec.whatwg.org/) support
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install @discoveryjs/json-ext
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
- [parseChunked(chunkEmitter)](#parsechunkedchunkemitter)
|
||||
- [stringifyStream(value[, replacer[, space]])](#stringifystreamvalue-replacer-space)
|
||||
- [stringifyInfo(value[, replacer[, space[, options]]])](#stringifyinfovalue-replacer-space-options)
|
||||
- [Options](#options)
|
||||
- [async](#async)
|
||||
- [continueOnCircular](#continueoncircular)
|
||||
- [version](#version)
|
||||
|
||||
### parseChunked(chunkEmitter)
|
||||
|
||||
Works the same as [`JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) but takes `chunkEmitter` instead of string and returns [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
||||
|
||||
> NOTE: `reviver` parameter is not supported yet, but will be added in next releases.
|
||||
> NOTE: WHATWG streams aren't supported yet
|
||||
|
||||
When to use:
|
||||
- It's required to avoid freezing the main thread during big JSON parsing, since this process can be distributed in time
|
||||
- Huge JSON needs to be parsed (e.g. >500MB on Node.js)
|
||||
- Needed to reduce memory pressure. `JSON.parse()` needs to receive the entire JSON before parsing it. With `parseChunked()` you may parse JSON as first bytes of it comes. This approach helps to avoid storing a huge string in the memory at a single time point and following GC.
|
||||
|
||||
[Benchmark](https://github.com/discoveryjs/json-ext/tree/master/benchmarks#parse-chunked)
|
||||
|
||||
Usage:
|
||||
|
||||
```js
|
||||
const { parseChunked } = require('@discoveryjs/json-ext');
|
||||
|
||||
// as a regular Promise
|
||||
parseChunked(chunkEmitter)
|
||||
.then(data => {
|
||||
/* data is parsed JSON */
|
||||
});
|
||||
|
||||
// using await (keep in mind that not every runtime has a support for top level await)
|
||||
const data = await parseChunked(chunkEmitter);
|
||||
```
|
||||
|
||||
Parameter `chunkEmitter` can be:
|
||||
- [`ReadableStream`](https://nodejs.org/dist/latest-v14.x/docs/api/stream.html#stream_readable_streams) (Node.js only)
|
||||
```js
|
||||
const fs = require('fs');
|
||||
const { parseChunked } = require('@discoveryjs/json-ext');
|
||||
|
||||
parseChunked(fs.createReadStream('path/to/file.json'))
|
||||
```
|
||||
- Generator, async generator or function that returns iterable (chunks). Chunk might be a `string`, `Uint8Array` or `Buffer` (Node.js only):
|
||||
```js
|
||||
const { parseChunked } = require('@discoveryjs/json-ext');
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
// generator
|
||||
parseChunked(function*() {
|
||||
yield '{ "hello":';
|
||||
yield Buffer.from(' "wor'); // Node.js only
|
||||
yield encoder.encode('ld" }'); // returns Uint8Array(5) [ 108, 100, 34, 32, 125 ]
|
||||
});
|
||||
|
||||
// async generator
|
||||
parseChunked(async function*() {
|
||||
for await (const chunk of someAsyncSource) {
|
||||
yield chunk;
|
||||
}
|
||||
});
|
||||
|
||||
// function that returns iterable
|
||||
parseChunked(() => ['{ "hello":', ' "world"}'])
|
||||
```
|
||||
|
||||
Using with [fetch()](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API):
|
||||
|
||||
```js
|
||||
async function loadData(url) {
|
||||
const response = await fetch(url);
|
||||
const reader = response.body.getReader();
|
||||
|
||||
return parseChunked(async function*() {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
|
||||
yield value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadData('https://example.com/data.json')
|
||||
.then(data => {
|
||||
/* data is parsed JSON */
|
||||
})
|
||||
```
|
||||
|
||||
### stringifyStream(value[, replacer[, space]])
|
||||
|
||||
Works the same as [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify), but returns an instance of [`ReadableStream`](https://nodejs.org/dist/latest-v14.x/docs/api/stream.html#stream_readable_streams) instead of string.
|
||||
|
||||
> NOTE: WHATWG Streams aren't supported yet, so function available for Node.js only for now
|
||||
|
||||
Departs from JSON.stringify():
|
||||
- Outputs `null` when `JSON.stringify()` returns `undefined` (since streams may not emit `undefined`)
|
||||
- A promise is resolving and the resulting value is stringifying as a regular one
|
||||
- A stream in non-object mode is piping to output as is
|
||||
- A stream in object mode is piping to output as an array of objects
|
||||
|
||||
When to use:
|
||||
- Huge JSON needs to be generated (e.g. >500MB on Node.js)
|
||||
- Needed to reduce memory pressure. `JSON.stringify()` needs to generate the entire JSON before send or write it to somewhere. With `stringifyStream()` you may send a result to somewhere as first bytes of the result appears. This approach helps to avoid storing a huge string in the memory at a single time point.
|
||||
- The object being serialized contains Promises or Streams (see Usage for examples)
|
||||
|
||||
[Benchmark](https://github.com/discoveryjs/json-ext/tree/master/benchmarks#stream-stringifying)
|
||||
|
||||
Usage:
|
||||
|
||||
```js
|
||||
const { stringifyStream } = require('@discoveryjs/json-ext');
|
||||
|
||||
// handle events
|
||||
stringifyStream(data)
|
||||
.on('data', chunk => console.log(chunk))
|
||||
.on('error', error => consold.error(error))
|
||||
.on('finish', () => console.log('DONE!'));
|
||||
|
||||
// pipe into a stream
|
||||
stringifyStream(data)
|
||||
.pipe(writableStream);
|
||||
```
|
||||
|
||||
Using Promise or ReadableStream in serializing object:
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
const { stringifyStream } = require('@discoveryjs/json-ext');
|
||||
|
||||
// output will be
|
||||
// {"name":"example","willSerializeResolvedValue":42,"fromFile":[1, 2, 3],"at":{"any":{"level":"promise!"}}}
|
||||
stringifyStream({
|
||||
name: 'example',
|
||||
willSerializeResolvedValue: Promise.resolve(42),
|
||||
fromFile: fs.createReadStream('path/to/file.json'), // support file content is "[1, 2, 3]", it'll be inserted as it
|
||||
at: {
|
||||
any: {
|
||||
level: new Promise(resolve => setTimeout(() => resolve('promise!'), 100))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// in case several async requests are used in object, it's prefered
|
||||
// to put fastest requests first, because in this case
|
||||
stringifyStream({
|
||||
foo: fetch('http://example.com/request_takes_2s').then(req => req.json()),
|
||||
bar: fetch('http://example.com/request_takes_5s').then(req => req.json())
|
||||
});
|
||||
```
|
||||
|
||||
Using with [`WritableStream`](https://nodejs.org/dist/latest-v14.x/docs/api/stream.html#stream_writable_streams) (Node.js only):
|
||||
|
||||
```js
|
||||
const fs = require('fs');
|
||||
const { stringifyStream } = require('@discoveryjs/json-ext');
|
||||
|
||||
// pipe into a console
|
||||
stringifyStream(data)
|
||||
.pipe(process.stdout);
|
||||
|
||||
// pipe into a file
|
||||
stringifyStream(data)
|
||||
.pipe(fs.createWriteStream('path/to/file.json'));
|
||||
|
||||
// wrapping into a Promise
|
||||
new Promise((resolve, reject) => {
|
||||
stringifyStream(data)
|
||||
.on('error', reject)
|
||||
.pipe(stream)
|
||||
.on('error', reject)
|
||||
.on('finish', resolve);
|
||||
});
|
||||
```
|
||||
|
||||
### stringifyInfo(value[, replacer[, space[, options]]])
|
||||
|
||||
`value`, `replacer` and `space` arguments are the same as for `JSON.stringify()`.
|
||||
|
||||
Result is an object:
|
||||
|
||||
```js
|
||||
{
|
||||
minLength: Number, // minimal bytes when values is stringified
|
||||
circular: [...], // list of circular references
|
||||
duplicate: [...], // list of objects that occur more than once
|
||||
async: [...] // list of async values, i.e. promises and streams
|
||||
}
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
const { stringifyInfo } = require('@discoveryjs/json-ext');
|
||||
|
||||
console.log(
|
||||
stringifyInfo({ test: true }).minLength
|
||||
);
|
||||
// > 13
|
||||
// that equals '{"test":true}'.length
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
##### async
|
||||
|
||||
Type: `Boolean`
|
||||
Default: `false`
|
||||
|
||||
Collect async values (promises and streams) or not.
|
||||
|
||||
##### continueOnCircular
|
||||
|
||||
Type: `Boolean`
|
||||
Default: `false`
|
||||
|
||||
Stop collecting info for a value or not whenever circular reference is found. Setting option to `true` allows to find all circular references.
|
||||
|
||||
### version
|
||||
|
||||
The version of library, e.g. `"0.3.1"`.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
791
node_modules/@discoveryjs/json-ext/dist/json-ext.js
generated
vendored
Normal file
791
node_modules/@discoveryjs/json-ext/dist/json-ext.js
generated
vendored
Normal file
@ -0,0 +1,791 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jsonExt = factory());
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
var version = "0.5.7";
|
||||
|
||||
const PrimitiveType = 1;
|
||||
const ObjectType = 2;
|
||||
const ArrayType = 3;
|
||||
const PromiseType = 4;
|
||||
const ReadableStringType = 5;
|
||||
const ReadableObjectType = 6;
|
||||
// https://tc39.es/ecma262/#table-json-single-character-escapes
|
||||
const escapableCharCodeSubstitution$1 = { // JSON Single Character Escape Sequences
|
||||
0x08: '\\b',
|
||||
0x09: '\\t',
|
||||
0x0a: '\\n',
|
||||
0x0c: '\\f',
|
||||
0x0d: '\\r',
|
||||
0x22: '\\\"',
|
||||
0x5c: '\\\\'
|
||||
};
|
||||
|
||||
function isLeadingSurrogate$1(code) {
|
||||
return code >= 0xD800 && code <= 0xDBFF;
|
||||
}
|
||||
|
||||
function isTrailingSurrogate$1(code) {
|
||||
return code >= 0xDC00 && code <= 0xDFFF;
|
||||
}
|
||||
|
||||
function isReadableStream$1(value) {
|
||||
return (
|
||||
typeof value.pipe === 'function' &&
|
||||
typeof value._read === 'function' &&
|
||||
typeof value._readableState === 'object' && value._readableState !== null
|
||||
);
|
||||
}
|
||||
|
||||
function replaceValue$1(holder, key, value, replacer) {
|
||||
if (value && typeof value.toJSON === 'function') {
|
||||
value = value.toJSON();
|
||||
}
|
||||
|
||||
if (replacer !== null) {
|
||||
value = replacer.call(holder, String(key), value);
|
||||
}
|
||||
|
||||
switch (typeof value) {
|
||||
case 'function':
|
||||
case 'symbol':
|
||||
value = undefined;
|
||||
break;
|
||||
|
||||
case 'object':
|
||||
if (value !== null) {
|
||||
const cls = value.constructor;
|
||||
if (cls === String || cls === Number || cls === Boolean) {
|
||||
value = value.valueOf();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function getTypeNative$1(value) {
|
||||
if (value === null || typeof value !== 'object') {
|
||||
return PrimitiveType;
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return ArrayType;
|
||||
}
|
||||
|
||||
return ObjectType;
|
||||
}
|
||||
|
||||
function getTypeAsync$1(value) {
|
||||
if (value === null || typeof value !== 'object') {
|
||||
return PrimitiveType;
|
||||
}
|
||||
|
||||
if (typeof value.then === 'function') {
|
||||
return PromiseType;
|
||||
}
|
||||
|
||||
if (isReadableStream$1(value)) {
|
||||
return value._readableState.objectMode ? ReadableObjectType : ReadableStringType;
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return ArrayType;
|
||||
}
|
||||
|
||||
return ObjectType;
|
||||
}
|
||||
|
||||
function normalizeReplacer$1(replacer) {
|
||||
if (typeof replacer === 'function') {
|
||||
return replacer;
|
||||
}
|
||||
|
||||
if (Array.isArray(replacer)) {
|
||||
const allowlist = new Set(replacer
|
||||
.map(item => {
|
||||
const cls = item && item.constructor;
|
||||
return cls === String || cls === Number ? String(item) : null;
|
||||
})
|
||||
.filter(item => typeof item === 'string')
|
||||
);
|
||||
|
||||
return [...allowlist];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function normalizeSpace$1(space) {
|
||||
if (typeof space === 'number') {
|
||||
if (!Number.isFinite(space) || space < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ' '.repeat(Math.min(space, 10));
|
||||
}
|
||||
|
||||
if (typeof space === 'string') {
|
||||
return space.slice(0, 10) || false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var utils = {
|
||||
escapableCharCodeSubstitution: escapableCharCodeSubstitution$1,
|
||||
isLeadingSurrogate: isLeadingSurrogate$1,
|
||||
isTrailingSurrogate: isTrailingSurrogate$1,
|
||||
type: {
|
||||
PRIMITIVE: PrimitiveType,
|
||||
PROMISE: PromiseType,
|
||||
ARRAY: ArrayType,
|
||||
OBJECT: ObjectType,
|
||||
STRING_STREAM: ReadableStringType,
|
||||
OBJECT_STREAM: ReadableObjectType
|
||||
},
|
||||
|
||||
isReadableStream: isReadableStream$1,
|
||||
replaceValue: replaceValue$1,
|
||||
getTypeNative: getTypeNative$1,
|
||||
getTypeAsync: getTypeAsync$1,
|
||||
normalizeReplacer: normalizeReplacer$1,
|
||||
normalizeSpace: normalizeSpace$1
|
||||
};
|
||||
|
||||
const {
|
||||
normalizeReplacer,
|
||||
normalizeSpace,
|
||||
replaceValue,
|
||||
getTypeNative,
|
||||
getTypeAsync,
|
||||
isLeadingSurrogate,
|
||||
isTrailingSurrogate,
|
||||
escapableCharCodeSubstitution,
|
||||
type: {
|
||||
PRIMITIVE,
|
||||
OBJECT,
|
||||
ARRAY,
|
||||
PROMISE,
|
||||
STRING_STREAM,
|
||||
OBJECT_STREAM
|
||||
}
|
||||
} = utils;
|
||||
const charLength2048 = Array.from({ length: 2048 }).map((_, code) => {
|
||||
if (escapableCharCodeSubstitution.hasOwnProperty(code)) {
|
||||
return 2; // \X
|
||||
}
|
||||
|
||||
if (code < 0x20) {
|
||||
return 6; // \uXXXX
|
||||
}
|
||||
|
||||
return code < 128 ? 1 : 2; // UTF8 bytes
|
||||
});
|
||||
|
||||
function stringLength(str) {
|
||||
let len = 0;
|
||||
let prevLeadingSurrogate = false;
|
||||
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const code = str.charCodeAt(i);
|
||||
|
||||
if (code < 2048) {
|
||||
len += charLength2048[code];
|
||||
} else if (isLeadingSurrogate(code)) {
|
||||
len += 6; // \uXXXX since no pair with trailing surrogate yet
|
||||
prevLeadingSurrogate = true;
|
||||
continue;
|
||||
} else if (isTrailingSurrogate(code)) {
|
||||
len = prevLeadingSurrogate
|
||||
? len - 2 // surrogate pair (4 bytes), since we calculate prev leading surrogate as 6 bytes, substruct 2 bytes
|
||||
: len + 6; // \uXXXX
|
||||
} else {
|
||||
len += 3; // code >= 2048 is 3 bytes length for UTF8
|
||||
}
|
||||
|
||||
prevLeadingSurrogate = false;
|
||||
}
|
||||
|
||||
return len + 2; // +2 for quotes
|
||||
}
|
||||
|
||||
function primitiveLength(value) {
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
return stringLength(value);
|
||||
|
||||
case 'number':
|
||||
return Number.isFinite(value) ? String(value).length : 4 /* null */;
|
||||
|
||||
case 'boolean':
|
||||
return value ? 4 /* true */ : 5 /* false */;
|
||||
|
||||
case 'undefined':
|
||||
case 'object':
|
||||
return 4; /* null */
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function spaceLength(space) {
|
||||
space = normalizeSpace(space);
|
||||
return typeof space === 'string' ? space.length : 0;
|
||||
}
|
||||
|
||||
var stringifyInfo = function jsonStringifyInfo(value, replacer, space, options) {
|
||||
function walk(holder, key, value) {
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
|
||||
value = replaceValue(holder, key, value, replacer);
|
||||
|
||||
let type = getType(value);
|
||||
|
||||
// check for circular structure
|
||||
if (type !== PRIMITIVE && stack.has(value)) {
|
||||
circular.add(value);
|
||||
length += 4; // treat as null
|
||||
|
||||
if (!options.continueOnCircular) {
|
||||
stop = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case PRIMITIVE:
|
||||
if (value !== undefined || Array.isArray(holder)) {
|
||||
length += primitiveLength(value);
|
||||
} else if (holder === root) {
|
||||
length += 9; // FIXME: that's the length of undefined, should we normalize behaviour to convert it to null?
|
||||
}
|
||||
break;
|
||||
|
||||
case OBJECT: {
|
||||
if (visited.has(value)) {
|
||||
duplicate.add(value);
|
||||
length += visited.get(value);
|
||||
break;
|
||||
}
|
||||
|
||||
const valueLength = length;
|
||||
let entries = 0;
|
||||
|
||||
length += 2; // {}
|
||||
|
||||
stack.add(value);
|
||||
|
||||
for (const key in value) {
|
||||
if (hasOwnProperty.call(value, key) && (allowlist === null || allowlist.has(key))) {
|
||||
const prevLength = length;
|
||||
walk(value, key, value[key]);
|
||||
|
||||
if (prevLength !== length) {
|
||||
// value is printed
|
||||
length += stringLength(key) + 1; // "key":
|
||||
entries++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entries > 1) {
|
||||
length += entries - 1; // commas
|
||||
}
|
||||
|
||||
stack.delete(value);
|
||||
|
||||
if (space > 0 && entries > 0) {
|
||||
length += (1 + (stack.size + 1) * space + 1) * entries; // for each key-value: \n{space}
|
||||
length += 1 + stack.size * space; // for }
|
||||
}
|
||||
|
||||
visited.set(value, length - valueLength);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ARRAY: {
|
||||
if (visited.has(value)) {
|
||||
duplicate.add(value);
|
||||
length += visited.get(value);
|
||||
break;
|
||||
}
|
||||
|
||||
const valueLength = length;
|
||||
|
||||
length += 2; // []
|
||||
|
||||
stack.add(value);
|
||||
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
walk(value, i, value[i]);
|
||||
}
|
||||
|
||||
if (value.length > 1) {
|
||||
length += value.length - 1; // commas
|
||||
}
|
||||
|
||||
stack.delete(value);
|
||||
|
||||
if (space > 0 && value.length > 0) {
|
||||
length += (1 + (stack.size + 1) * space) * value.length; // for each element: \n{space}
|
||||
length += 1 + stack.size * space; // for ]
|
||||
}
|
||||
|
||||
visited.set(value, length - valueLength);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PROMISE:
|
||||
case STRING_STREAM:
|
||||
async.add(value);
|
||||
break;
|
||||
|
||||
case OBJECT_STREAM:
|
||||
length += 2; // []
|
||||
async.add(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let allowlist = null;
|
||||
replacer = normalizeReplacer(replacer);
|
||||
|
||||
if (Array.isArray(replacer)) {
|
||||
allowlist = new Set(replacer);
|
||||
replacer = null;
|
||||
}
|
||||
|
||||
space = spaceLength(space);
|
||||
options = options || {};
|
||||
|
||||
const visited = new Map();
|
||||
const stack = new Set();
|
||||
const duplicate = new Set();
|
||||
const circular = new Set();
|
||||
const async = new Set();
|
||||
const getType = options.async ? getTypeAsync : getTypeNative;
|
||||
const root = { '': value };
|
||||
let stop = false;
|
||||
let length = 0;
|
||||
|
||||
walk(root, '', value);
|
||||
|
||||
return {
|
||||
minLength: isNaN(length) ? Infinity : length,
|
||||
circular: [...circular],
|
||||
duplicate: [...duplicate],
|
||||
async: [...async]
|
||||
};
|
||||
};
|
||||
|
||||
var stringifyStreamBrowser = () => {
|
||||
throw new Error('Method is not supported');
|
||||
};
|
||||
|
||||
var textDecoderBrowser = TextDecoder;
|
||||
|
||||
const { isReadableStream } = utils;
|
||||
|
||||
|
||||
const STACK_OBJECT = 1;
|
||||
const STACK_ARRAY = 2;
|
||||
const decoder = new textDecoderBrowser();
|
||||
|
||||
function isObject(value) {
|
||||
return value !== null && typeof value === 'object';
|
||||
}
|
||||
|
||||
function adjustPosition(error, parser) {
|
||||
if (error.name === 'SyntaxError' && parser.jsonParseOffset) {
|
||||
error.message = error.message.replace(/at position (\d+)/, (_, pos) =>
|
||||
'at position ' + (Number(pos) + parser.jsonParseOffset)
|
||||
);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
function append(array, elements) {
|
||||
// Note: Avoid to use array.push(...elements) since it may lead to
|
||||
// "RangeError: Maximum call stack size exceeded" for a long arrays
|
||||
const initialLength = array.length;
|
||||
array.length += elements.length;
|
||||
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
array[initialLength + i] = elements[i];
|
||||
}
|
||||
}
|
||||
|
||||
var parseChunked = function(chunkEmitter) {
|
||||
let parser = new ChunkParser();
|
||||
|
||||
if (isObject(chunkEmitter) && isReadableStream(chunkEmitter)) {
|
||||
return new Promise((resolve, reject) => {
|
||||
chunkEmitter
|
||||
.on('data', chunk => {
|
||||
try {
|
||||
parser.push(chunk);
|
||||
} catch (e) {
|
||||
reject(adjustPosition(e, parser));
|
||||
parser = null;
|
||||
}
|
||||
})
|
||||
.on('error', (e) => {
|
||||
parser = null;
|
||||
reject(e);
|
||||
})
|
||||
.on('end', () => {
|
||||
try {
|
||||
resolve(parser.finish());
|
||||
} catch (e) {
|
||||
reject(adjustPosition(e, parser));
|
||||
} finally {
|
||||
parser = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof chunkEmitter === 'function') {
|
||||
const iterator = chunkEmitter();
|
||||
|
||||
if (isObject(iterator) && (Symbol.iterator in iterator || Symbol.asyncIterator in iterator)) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
for await (const chunk of iterator) {
|
||||
parser.push(chunk);
|
||||
}
|
||||
|
||||
resolve(parser.finish());
|
||||
} catch (e) {
|
||||
reject(adjustPosition(e, parser));
|
||||
} finally {
|
||||
parser = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
'Chunk emitter should be readable stream, generator, ' +
|
||||
'async generator or function returning an iterable object'
|
||||
);
|
||||
};
|
||||
|
||||
class ChunkParser {
|
||||
constructor() {
|
||||
this.value = undefined;
|
||||
this.valueStack = null;
|
||||
|
||||
this.stack = new Array(100);
|
||||
this.lastFlushDepth = 0;
|
||||
this.flushDepth = 0;
|
||||
this.stateString = false;
|
||||
this.stateStringEscape = false;
|
||||
this.pendingByteSeq = null;
|
||||
this.pendingChunk = null;
|
||||
this.chunkOffset = 0;
|
||||
this.jsonParseOffset = 0;
|
||||
}
|
||||
|
||||
parseAndAppend(fragment, wrap) {
|
||||
// Append new entries or elements
|
||||
if (this.stack[this.lastFlushDepth - 1] === STACK_OBJECT) {
|
||||
if (wrap) {
|
||||
this.jsonParseOffset--;
|
||||
fragment = '{' + fragment + '}';
|
||||
}
|
||||
|
||||
Object.assign(this.valueStack.value, JSON.parse(fragment));
|
||||
} else {
|
||||
if (wrap) {
|
||||
this.jsonParseOffset--;
|
||||
fragment = '[' + fragment + ']';
|
||||
}
|
||||
|
||||
append(this.valueStack.value, JSON.parse(fragment));
|
||||
}
|
||||
}
|
||||
|
||||
prepareAddition(fragment) {
|
||||
const { value } = this.valueStack;
|
||||
const expectComma = Array.isArray(value)
|
||||
? value.length !== 0
|
||||
: Object.keys(value).length !== 0;
|
||||
|
||||
if (expectComma) {
|
||||
// Skip a comma at the beginning of fragment, otherwise it would
|
||||
// fail to parse
|
||||
if (fragment[0] === ',') {
|
||||
this.jsonParseOffset++;
|
||||
return fragment.slice(1);
|
||||
}
|
||||
|
||||
// When value (an object or array) is not empty and a fragment
|
||||
// doesn't start with a comma, a single valid fragment starting
|
||||
// is a closing bracket. If it's not, a prefix is adding to fail
|
||||
// parsing. Otherwise, the sequence of chunks can be successfully
|
||||
// parsed, although it should not, e.g. ["[{}", "{}]"]
|
||||
if (fragment[0] !== '}' && fragment[0] !== ']') {
|
||||
this.jsonParseOffset -= 3;
|
||||
return '[[]' + fragment;
|
||||
}
|
||||
}
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
flush(chunk, start, end) {
|
||||
let fragment = chunk.slice(start, end);
|
||||
|
||||
// Save position correction an error in JSON.parse() if any
|
||||
this.jsonParseOffset = this.chunkOffset + start;
|
||||
|
||||
// Prepend pending chunk if any
|
||||
if (this.pendingChunk !== null) {
|
||||
fragment = this.pendingChunk + fragment;
|
||||
this.jsonParseOffset -= this.pendingChunk.length;
|
||||
this.pendingChunk = null;
|
||||
}
|
||||
|
||||
if (this.flushDepth === this.lastFlushDepth) {
|
||||
// Depth didn't changed, so it's a root value or entry/element set
|
||||
if (this.flushDepth > 0) {
|
||||
this.parseAndAppend(this.prepareAddition(fragment), true);
|
||||
} else {
|
||||
// That's an entire value on a top level
|
||||
this.value = JSON.parse(fragment);
|
||||
this.valueStack = {
|
||||
value: this.value,
|
||||
prev: null
|
||||
};
|
||||
}
|
||||
} else if (this.flushDepth > this.lastFlushDepth) {
|
||||
// Add missed closing brackets/parentheses
|
||||
for (let i = this.flushDepth - 1; i >= this.lastFlushDepth; i--) {
|
||||
fragment += this.stack[i] === STACK_OBJECT ? '}' : ']';
|
||||
}
|
||||
|
||||
if (this.lastFlushDepth === 0) {
|
||||
// That's a root value
|
||||
this.value = JSON.parse(fragment);
|
||||
this.valueStack = {
|
||||
value: this.value,
|
||||
prev: null
|
||||
};
|
||||
} else {
|
||||
this.parseAndAppend(this.prepareAddition(fragment), true);
|
||||
}
|
||||
|
||||
// Move down to the depths to the last object/array, which is current now
|
||||
for (let i = this.lastFlushDepth || 1; i < this.flushDepth; i++) {
|
||||
let value = this.valueStack.value;
|
||||
|
||||
if (this.stack[i - 1] === STACK_OBJECT) {
|
||||
// find last entry
|
||||
let key;
|
||||
// eslint-disable-next-line curly
|
||||
for (key in value);
|
||||
value = value[key];
|
||||
} else {
|
||||
// last element
|
||||
value = value[value.length - 1];
|
||||
}
|
||||
|
||||
this.valueStack = {
|
||||
value,
|
||||
prev: this.valueStack
|
||||
};
|
||||
}
|
||||
} else /* this.flushDepth < this.lastFlushDepth */ {
|
||||
fragment = this.prepareAddition(fragment);
|
||||
|
||||
// Add missed opening brackets/parentheses
|
||||
for (let i = this.lastFlushDepth - 1; i >= this.flushDepth; i--) {
|
||||
this.jsonParseOffset--;
|
||||
fragment = (this.stack[i] === STACK_OBJECT ? '{' : '[') + fragment;
|
||||
}
|
||||
|
||||
this.parseAndAppend(fragment, false);
|
||||
|
||||
for (let i = this.lastFlushDepth - 1; i >= this.flushDepth; i--) {
|
||||
this.valueStack = this.valueStack.prev;
|
||||
}
|
||||
}
|
||||
|
||||
this.lastFlushDepth = this.flushDepth;
|
||||
}
|
||||
|
||||
push(chunk) {
|
||||
if (typeof chunk !== 'string') {
|
||||
// Suppose chunk is Buffer or Uint8Array
|
||||
|
||||
// Prepend uncompleted byte sequence if any
|
||||
if (this.pendingByteSeq !== null) {
|
||||
const origRawChunk = chunk;
|
||||
chunk = new Uint8Array(this.pendingByteSeq.length + origRawChunk.length);
|
||||
chunk.set(this.pendingByteSeq);
|
||||
chunk.set(origRawChunk, this.pendingByteSeq.length);
|
||||
this.pendingByteSeq = null;
|
||||
}
|
||||
|
||||
// In case Buffer/Uint8Array, an input is encoded in UTF8
|
||||
// Seek for parts of uncompleted UTF8 symbol on the ending
|
||||
// This makes sense only if we expect more chunks and last char is not multi-bytes
|
||||
if (chunk[chunk.length - 1] > 127) {
|
||||
for (let seqLength = 0; seqLength < chunk.length; seqLength++) {
|
||||
const byte = chunk[chunk.length - 1 - seqLength];
|
||||
|
||||
// 10xxxxxx - 2nd, 3rd or 4th byte
|
||||
// 110xxxxx – first byte of 2-byte sequence
|
||||
// 1110xxxx - first byte of 3-byte sequence
|
||||
// 11110xxx - first byte of 4-byte sequence
|
||||
if (byte >> 6 === 3) {
|
||||
seqLength++;
|
||||
|
||||
// If the sequence is really incomplete, then preserve it
|
||||
// for the future chunk and cut off it from the current chunk
|
||||
if ((seqLength !== 4 && byte >> 3 === 0b11110) ||
|
||||
(seqLength !== 3 && byte >> 4 === 0b1110) ||
|
||||
(seqLength !== 2 && byte >> 5 === 0b110)) {
|
||||
this.pendingByteSeq = chunk.slice(chunk.length - seqLength);
|
||||
chunk = chunk.slice(0, -seqLength);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert chunk to a string, since single decode per chunk
|
||||
// is much effective than decode multiple small substrings
|
||||
chunk = decoder.decode(chunk);
|
||||
}
|
||||
|
||||
const chunkLength = chunk.length;
|
||||
let lastFlushPoint = 0;
|
||||
let flushPoint = 0;
|
||||
|
||||
// Main scan loop
|
||||
scan: for (let i = 0; i < chunkLength; i++) {
|
||||
if (this.stateString) {
|
||||
for (; i < chunkLength; i++) {
|
||||
if (this.stateStringEscape) {
|
||||
this.stateStringEscape = false;
|
||||
} else {
|
||||
switch (chunk.charCodeAt(i)) {
|
||||
case 0x22: /* " */
|
||||
this.stateString = false;
|
||||
continue scan;
|
||||
|
||||
case 0x5C: /* \ */
|
||||
this.stateStringEscape = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch (chunk.charCodeAt(i)) {
|
||||
case 0x22: /* " */
|
||||
this.stateString = true;
|
||||
this.stateStringEscape = false;
|
||||
break;
|
||||
|
||||
case 0x2C: /* , */
|
||||
flushPoint = i;
|
||||
break;
|
||||
|
||||
case 0x7B: /* { */
|
||||
// Open an object
|
||||
flushPoint = i + 1;
|
||||
this.stack[this.flushDepth++] = STACK_OBJECT;
|
||||
break;
|
||||
|
||||
case 0x5B: /* [ */
|
||||
// Open an array
|
||||
flushPoint = i + 1;
|
||||
this.stack[this.flushDepth++] = STACK_ARRAY;
|
||||
break;
|
||||
|
||||
case 0x5D: /* ] */
|
||||
case 0x7D: /* } */
|
||||
// Close an object or array
|
||||
flushPoint = i + 1;
|
||||
this.flushDepth--;
|
||||
|
||||
if (this.flushDepth < this.lastFlushDepth) {
|
||||
this.flush(chunk, lastFlushPoint, flushPoint);
|
||||
lastFlushPoint = flushPoint;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x09: /* \t */
|
||||
case 0x0A: /* \n */
|
||||
case 0x0D: /* \r */
|
||||
case 0x20: /* space */
|
||||
// Move points forward when they points on current position and it's a whitespace
|
||||
if (lastFlushPoint === i) {
|
||||
lastFlushPoint++;
|
||||
}
|
||||
|
||||
if (flushPoint === i) {
|
||||
flushPoint++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (flushPoint > lastFlushPoint) {
|
||||
this.flush(chunk, lastFlushPoint, flushPoint);
|
||||
}
|
||||
|
||||
// Produce pendingChunk if something left
|
||||
if (flushPoint < chunkLength) {
|
||||
if (this.pendingChunk !== null) {
|
||||
// When there is already a pending chunk then no flush happened,
|
||||
// appending entire chunk to pending one
|
||||
this.pendingChunk += chunk;
|
||||
} else {
|
||||
// Create a pending chunk, it will start with non-whitespace since
|
||||
// flushPoint was moved forward away from whitespaces on scan
|
||||
this.pendingChunk = chunk.slice(flushPoint, chunkLength);
|
||||
}
|
||||
}
|
||||
|
||||
this.chunkOffset += chunkLength;
|
||||
}
|
||||
|
||||
finish() {
|
||||
if (this.pendingChunk !== null) {
|
||||
this.flush('', 0, 0);
|
||||
this.pendingChunk = null;
|
||||
}
|
||||
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
var src = {
|
||||
version: version,
|
||||
stringifyInfo: stringifyInfo,
|
||||
stringifyStream: stringifyStreamBrowser,
|
||||
parseChunked: parseChunked
|
||||
};
|
||||
|
||||
return src;
|
||||
|
||||
}));
|
||||
1
node_modules/@discoveryjs/json-ext/dist/json-ext.min.js
generated
vendored
Normal file
1
node_modules/@discoveryjs/json-ext/dist/json-ext.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@discoveryjs/json-ext/dist/version.js
generated
vendored
Normal file
1
node_modules/@discoveryjs/json-ext/dist/version.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = "0.5.7";
|
||||
31
node_modules/@discoveryjs/json-ext/index.d.ts
generated
vendored
Normal file
31
node_modules/@discoveryjs/json-ext/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
declare module '@discoveryjs/json-ext' {
|
||||
import { Readable } from 'stream';
|
||||
|
||||
type TReplacer =
|
||||
| ((this: any, key: string, value: any) => any)
|
||||
| string[]
|
||||
| number[]
|
||||
| null;
|
||||
type TSpace = string | number | null;
|
||||
type TChunk = string | Buffer | Uint8Array;
|
||||
|
||||
export function parseChunked(input: Readable): Promise<any>;
|
||||
export function parseChunked(input: () => (Iterable<TChunk> | AsyncIterable<TChunk>)): Promise<any>;
|
||||
|
||||
export function stringifyStream(value: any, replacer?: TReplacer, space?: TSpace): Readable;
|
||||
|
||||
export function stringifyInfo(
|
||||
value: any,
|
||||
replacer?: TReplacer,
|
||||
space?: TSpace,
|
||||
options?: {
|
||||
async?: boolean;
|
||||
continueOnCircular?: boolean;
|
||||
}
|
||||
): {
|
||||
minLength: number;
|
||||
circular: any[];
|
||||
duplicate: any[];
|
||||
async: any[];
|
||||
};
|
||||
}
|
||||
93
node_modules/@discoveryjs/json-ext/package.json
generated
vendored
Normal file
93
node_modules/@discoveryjs/json-ext/package.json
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
{
|
||||
"_from": "@discoveryjs/json-ext@^0.5.0",
|
||||
"_id": "@discoveryjs/json-ext@0.5.7",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==",
|
||||
"_location": "/@discoveryjs/json-ext",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@discoveryjs/json-ext@^0.5.0",
|
||||
"name": "@discoveryjs/json-ext",
|
||||
"escapedName": "@discoveryjs%2fjson-ext",
|
||||
"scope": "@discoveryjs",
|
||||
"rawSpec": "^0.5.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.5.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/webpack-cli"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
|
||||
"_shasum": "1d572bfbbe14b7704e0ba0f39b74815b84870d70",
|
||||
"_spec": "@discoveryjs/json-ext@^0.5.0",
|
||||
"_where": "C:\\Users\\Wlad\\Desktop\\binance_bot_refactoring\\node_modules\\webpack-cli",
|
||||
"author": {
|
||||
"name": "Roman Dvornov",
|
||||
"email": "rdvornov@gmail.com",
|
||||
"url": "https://github.com/lahmatiy"
|
||||
},
|
||||
"browser": {
|
||||
"./src/stringify-stream.js": "./src/stringify-stream-browser.js",
|
||||
"./src/text-decoder.js": "./src/text-decoder-browser.js",
|
||||
"./src/version.js": "./dist/version.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discoveryjs/json-ext/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "A set of utilities that extend the use of JSON",
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^15.1.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||
"c8": "^7.10.0",
|
||||
"chalk": "^4.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.10.0",
|
||||
"mocha": "^8.4.0",
|
||||
"rollup": "^2.28.2",
|
||||
"rollup-plugin-terser": "^7.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/discoveryjs/json-ext#readme",
|
||||
"keywords": [
|
||||
"json",
|
||||
"utils",
|
||||
"stream",
|
||||
"async",
|
||||
"promise",
|
||||
"stringify",
|
||||
"info"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./src/index",
|
||||
"name": "@discoveryjs/json-ext",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/discoveryjs/json-ext.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup --config",
|
||||
"build-and-test": "npm run build && npm run test:dist",
|
||||
"coverage": "c8 --reporter=lcovonly npm test",
|
||||
"lint": "eslint src test",
|
||||
"lint-and-test": "npm run lint && npm test",
|
||||
"prepublishOnly": "npm run lint && npm test && npm run build-and-test",
|
||||
"test": "mocha --reporter progress",
|
||||
"test:all": "npm run test:src && npm run test:dist",
|
||||
"test:dist": "cross-env MODE=dist npm test && cross-env MODE=dist-min npm test",
|
||||
"test:src": "npm test"
|
||||
},
|
||||
"types": "./index.d.ts",
|
||||
"version": "0.5.7"
|
||||
}
|
||||
6
node_modules/@discoveryjs/json-ext/src/index.js
generated
vendored
Normal file
6
node_modules/@discoveryjs/json-ext/src/index.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
version: require('./version'),
|
||||
stringifyInfo: require('./stringify-info'),
|
||||
stringifyStream: require('./stringify-stream'),
|
||||
parseChunked: require('./parse-chunked')
|
||||
};
|
||||
384
node_modules/@discoveryjs/json-ext/src/parse-chunked.js
generated
vendored
Normal file
384
node_modules/@discoveryjs/json-ext/src/parse-chunked.js
generated
vendored
Normal file
@ -0,0 +1,384 @@
|
||||
const { isReadableStream } = require('./utils');
|
||||
const TextDecoder = require('./text-decoder');
|
||||
|
||||
const STACK_OBJECT = 1;
|
||||
const STACK_ARRAY = 2;
|
||||
const decoder = new TextDecoder();
|
||||
|
||||
function isObject(value) {
|
||||
return value !== null && typeof value === 'object';
|
||||
}
|
||||
|
||||
function adjustPosition(error, parser) {
|
||||
if (error.name === 'SyntaxError' && parser.jsonParseOffset) {
|
||||
error.message = error.message.replace(/at position (\d+)/, (_, pos) =>
|
||||
'at position ' + (Number(pos) + parser.jsonParseOffset)
|
||||
);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
function append(array, elements) {
|
||||
// Note: Avoid to use array.push(...elements) since it may lead to
|
||||
// "RangeError: Maximum call stack size exceeded" for a long arrays
|
||||
const initialLength = array.length;
|
||||
array.length += elements.length;
|
||||
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
array[initialLength + i] = elements[i];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(chunkEmitter) {
|
||||
let parser = new ChunkParser();
|
||||
|
||||
if (isObject(chunkEmitter) && isReadableStream(chunkEmitter)) {
|
||||
return new Promise((resolve, reject) => {
|
||||
chunkEmitter
|
||||
.on('data', chunk => {
|
||||
try {
|
||||
parser.push(chunk);
|
||||
} catch (e) {
|
||||
reject(adjustPosition(e, parser));
|
||||
parser = null;
|
||||
}
|
||||
})
|
||||
.on('error', (e) => {
|
||||
parser = null;
|
||||
reject(e);
|
||||
})
|
||||
.on('end', () => {
|
||||
try {
|
||||
resolve(parser.finish());
|
||||
} catch (e) {
|
||||
reject(adjustPosition(e, parser));
|
||||
} finally {
|
||||
parser = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof chunkEmitter === 'function') {
|
||||
const iterator = chunkEmitter();
|
||||
|
||||
if (isObject(iterator) && (Symbol.iterator in iterator || Symbol.asyncIterator in iterator)) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
for await (const chunk of iterator) {
|
||||
parser.push(chunk);
|
||||
}
|
||||
|
||||
resolve(parser.finish());
|
||||
} catch (e) {
|
||||
reject(adjustPosition(e, parser));
|
||||
} finally {
|
||||
parser = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
'Chunk emitter should be readable stream, generator, ' +
|
||||
'async generator or function returning an iterable object'
|
||||
);
|
||||
};
|
||||
|
||||
class ChunkParser {
|
||||
constructor() {
|
||||
this.value = undefined;
|
||||
this.valueStack = null;
|
||||
|
||||
this.stack = new Array(100);
|
||||
this.lastFlushDepth = 0;
|
||||
this.flushDepth = 0;
|
||||
this.stateString = false;
|
||||
this.stateStringEscape = false;
|
||||
this.pendingByteSeq = null;
|
||||
this.pendingChunk = null;
|
||||
this.chunkOffset = 0;
|
||||
this.jsonParseOffset = 0;
|
||||
}
|
||||
|
||||
parseAndAppend(fragment, wrap) {
|
||||
// Append new entries or elements
|
||||
if (this.stack[this.lastFlushDepth - 1] === STACK_OBJECT) {
|
||||
if (wrap) {
|
||||
this.jsonParseOffset--;
|
||||
fragment = '{' + fragment + '}';
|
||||
}
|
||||
|
||||
Object.assign(this.valueStack.value, JSON.parse(fragment));
|
||||
} else {
|
||||
if (wrap) {
|
||||
this.jsonParseOffset--;
|
||||
fragment = '[' + fragment + ']';
|
||||
}
|
||||
|
||||
append(this.valueStack.value, JSON.parse(fragment));
|
||||
}
|
||||
}
|
||||
|
||||
prepareAddition(fragment) {
|
||||
const { value } = this.valueStack;
|
||||
const expectComma = Array.isArray(value)
|
||||
? value.length !== 0
|
||||
: Object.keys(value).length !== 0;
|
||||
|
||||
if (expectComma) {
|
||||
// Skip a comma at the beginning of fragment, otherwise it would
|
||||
// fail to parse
|
||||
if (fragment[0] === ',') {
|
||||
this.jsonParseOffset++;
|
||||
return fragment.slice(1);
|
||||
}
|
||||
|
||||
// When value (an object or array) is not empty and a fragment
|
||||
// doesn't start with a comma, a single valid fragment starting
|
||||
// is a closing bracket. If it's not, a prefix is adding to fail
|
||||
// parsing. Otherwise, the sequence of chunks can be successfully
|
||||
// parsed, although it should not, e.g. ["[{}", "{}]"]
|
||||
if (fragment[0] !== '}' && fragment[0] !== ']') {
|
||||
this.jsonParseOffset -= 3;
|
||||
return '[[]' + fragment;
|
||||
}
|
||||
}
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
flush(chunk, start, end) {
|
||||
let fragment = chunk.slice(start, end);
|
||||
|
||||
// Save position correction an error in JSON.parse() if any
|
||||
this.jsonParseOffset = this.chunkOffset + start;
|
||||
|
||||
// Prepend pending chunk if any
|
||||
if (this.pendingChunk !== null) {
|
||||
fragment = this.pendingChunk + fragment;
|
||||
this.jsonParseOffset -= this.pendingChunk.length;
|
||||
this.pendingChunk = null;
|
||||
}
|
||||
|
||||
if (this.flushDepth === this.lastFlushDepth) {
|
||||
// Depth didn't changed, so it's a root value or entry/element set
|
||||
if (this.flushDepth > 0) {
|
||||
this.parseAndAppend(this.prepareAddition(fragment), true);
|
||||
} else {
|
||||
// That's an entire value on a top level
|
||||
this.value = JSON.parse(fragment);
|
||||
this.valueStack = {
|
||||
value: this.value,
|
||||
prev: null
|
||||
};
|
||||
}
|
||||
} else if (this.flushDepth > this.lastFlushDepth) {
|
||||
// Add missed closing brackets/parentheses
|
||||
for (let i = this.flushDepth - 1; i >= this.lastFlushDepth; i--) {
|
||||
fragment += this.stack[i] === STACK_OBJECT ? '}' : ']';
|
||||
}
|
||||
|
||||
if (this.lastFlushDepth === 0) {
|
||||
// That's a root value
|
||||
this.value = JSON.parse(fragment);
|
||||
this.valueStack = {
|
||||
value: this.value,
|
||||
prev: null
|
||||
};
|
||||
} else {
|
||||
this.parseAndAppend(this.prepareAddition(fragment), true);
|
||||
}
|
||||
|
||||
// Move down to the depths to the last object/array, which is current now
|
||||
for (let i = this.lastFlushDepth || 1; i < this.flushDepth; i++) {
|
||||
let value = this.valueStack.value;
|
||||
|
||||
if (this.stack[i - 1] === STACK_OBJECT) {
|
||||
// find last entry
|
||||
let key;
|
||||
// eslint-disable-next-line curly
|
||||
for (key in value);
|
||||
value = value[key];
|
||||
} else {
|
||||
// last element
|
||||
value = value[value.length - 1];
|
||||
}
|
||||
|
||||
this.valueStack = {
|
||||
value,
|
||||
prev: this.valueStack
|
||||
};
|
||||
}
|
||||
} else /* this.flushDepth < this.lastFlushDepth */ {
|
||||
fragment = this.prepareAddition(fragment);
|
||||
|
||||
// Add missed opening brackets/parentheses
|
||||
for (let i = this.lastFlushDepth - 1; i >= this.flushDepth; i--) {
|
||||
this.jsonParseOffset--;
|
||||
fragment = (this.stack[i] === STACK_OBJECT ? '{' : '[') + fragment;
|
||||
}
|
||||
|
||||
this.parseAndAppend(fragment, false);
|
||||
|
||||
for (let i = this.lastFlushDepth - 1; i >= this.flushDepth; i--) {
|
||||
this.valueStack = this.valueStack.prev;
|
||||
}
|
||||
}
|
||||
|
||||
this.lastFlushDepth = this.flushDepth;
|
||||
}
|
||||
|
||||
push(chunk) {
|
||||
if (typeof chunk !== 'string') {
|
||||
// Suppose chunk is Buffer or Uint8Array
|
||||
|
||||
// Prepend uncompleted byte sequence if any
|
||||
if (this.pendingByteSeq !== null) {
|
||||
const origRawChunk = chunk;
|
||||
chunk = new Uint8Array(this.pendingByteSeq.length + origRawChunk.length);
|
||||
chunk.set(this.pendingByteSeq);
|
||||
chunk.set(origRawChunk, this.pendingByteSeq.length);
|
||||
this.pendingByteSeq = null;
|
||||
}
|
||||
|
||||
// In case Buffer/Uint8Array, an input is encoded in UTF8
|
||||
// Seek for parts of uncompleted UTF8 symbol on the ending
|
||||
// This makes sense only if we expect more chunks and last char is not multi-bytes
|
||||
if (chunk[chunk.length - 1] > 127) {
|
||||
for (let seqLength = 0; seqLength < chunk.length; seqLength++) {
|
||||
const byte = chunk[chunk.length - 1 - seqLength];
|
||||
|
||||
// 10xxxxxx - 2nd, 3rd or 4th byte
|
||||
// 110xxxxx – first byte of 2-byte sequence
|
||||
// 1110xxxx - first byte of 3-byte sequence
|
||||
// 11110xxx - first byte of 4-byte sequence
|
||||
if (byte >> 6 === 3) {
|
||||
seqLength++;
|
||||
|
||||
// If the sequence is really incomplete, then preserve it
|
||||
// for the future chunk and cut off it from the current chunk
|
||||
if ((seqLength !== 4 && byte >> 3 === 0b11110) ||
|
||||
(seqLength !== 3 && byte >> 4 === 0b1110) ||
|
||||
(seqLength !== 2 && byte >> 5 === 0b110)) {
|
||||
this.pendingByteSeq = chunk.slice(chunk.length - seqLength);
|
||||
chunk = chunk.slice(0, -seqLength);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert chunk to a string, since single decode per chunk
|
||||
// is much effective than decode multiple small substrings
|
||||
chunk = decoder.decode(chunk);
|
||||
}
|
||||
|
||||
const chunkLength = chunk.length;
|
||||
let lastFlushPoint = 0;
|
||||
let flushPoint = 0;
|
||||
|
||||
// Main scan loop
|
||||
scan: for (let i = 0; i < chunkLength; i++) {
|
||||
if (this.stateString) {
|
||||
for (; i < chunkLength; i++) {
|
||||
if (this.stateStringEscape) {
|
||||
this.stateStringEscape = false;
|
||||
} else {
|
||||
switch (chunk.charCodeAt(i)) {
|
||||
case 0x22: /* " */
|
||||
this.stateString = false;
|
||||
continue scan;
|
||||
|
||||
case 0x5C: /* \ */
|
||||
this.stateStringEscape = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
switch (chunk.charCodeAt(i)) {
|
||||
case 0x22: /* " */
|
||||
this.stateString = true;
|
||||
this.stateStringEscape = false;
|
||||
break;
|
||||
|
||||
case 0x2C: /* , */
|
||||
flushPoint = i;
|
||||
break;
|
||||
|
||||
case 0x7B: /* { */
|
||||
// Open an object
|
||||
flushPoint = i + 1;
|
||||
this.stack[this.flushDepth++] = STACK_OBJECT;
|
||||
break;
|
||||
|
||||
case 0x5B: /* [ */
|
||||
// Open an array
|
||||
flushPoint = i + 1;
|
||||
this.stack[this.flushDepth++] = STACK_ARRAY;
|
||||
break;
|
||||
|
||||
case 0x5D: /* ] */
|
||||
case 0x7D: /* } */
|
||||
// Close an object or array
|
||||
flushPoint = i + 1;
|
||||
this.flushDepth--;
|
||||
|
||||
if (this.flushDepth < this.lastFlushDepth) {
|
||||
this.flush(chunk, lastFlushPoint, flushPoint);
|
||||
lastFlushPoint = flushPoint;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x09: /* \t */
|
||||
case 0x0A: /* \n */
|
||||
case 0x0D: /* \r */
|
||||
case 0x20: /* space */
|
||||
// Move points forward when they points on current position and it's a whitespace
|
||||
if (lastFlushPoint === i) {
|
||||
lastFlushPoint++;
|
||||
}
|
||||
|
||||
if (flushPoint === i) {
|
||||
flushPoint++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (flushPoint > lastFlushPoint) {
|
||||
this.flush(chunk, lastFlushPoint, flushPoint);
|
||||
}
|
||||
|
||||
// Produce pendingChunk if something left
|
||||
if (flushPoint < chunkLength) {
|
||||
if (this.pendingChunk !== null) {
|
||||
// When there is already a pending chunk then no flush happened,
|
||||
// appending entire chunk to pending one
|
||||
this.pendingChunk += chunk;
|
||||
} else {
|
||||
// Create a pending chunk, it will start with non-whitespace since
|
||||
// flushPoint was moved forward away from whitespaces on scan
|
||||
this.pendingChunk = chunk.slice(flushPoint, chunkLength);
|
||||
}
|
||||
}
|
||||
|
||||
this.chunkOffset += chunkLength;
|
||||
}
|
||||
|
||||
finish() {
|
||||
if (this.pendingChunk !== null) {
|
||||
this.flush('', 0, 0);
|
||||
this.pendingChunk = null;
|
||||
}
|
||||
|
||||
return this.value;
|
||||
}
|
||||
};
|
||||
231
node_modules/@discoveryjs/json-ext/src/stringify-info.js
generated
vendored
Normal file
231
node_modules/@discoveryjs/json-ext/src/stringify-info.js
generated
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
const {
|
||||
normalizeReplacer,
|
||||
normalizeSpace,
|
||||
replaceValue,
|
||||
getTypeNative,
|
||||
getTypeAsync,
|
||||
isLeadingSurrogate,
|
||||
isTrailingSurrogate,
|
||||
escapableCharCodeSubstitution,
|
||||
type: {
|
||||
PRIMITIVE,
|
||||
OBJECT,
|
||||
ARRAY,
|
||||
PROMISE,
|
||||
STRING_STREAM,
|
||||
OBJECT_STREAM
|
||||
}
|
||||
} = require('./utils');
|
||||
const charLength2048 = Array.from({ length: 2048 }).map((_, code) => {
|
||||
if (escapableCharCodeSubstitution.hasOwnProperty(code)) {
|
||||
return 2; // \X
|
||||
}
|
||||
|
||||
if (code < 0x20) {
|
||||
return 6; // \uXXXX
|
||||
}
|
||||
|
||||
return code < 128 ? 1 : 2; // UTF8 bytes
|
||||
});
|
||||
|
||||
function stringLength(str) {
|
||||
let len = 0;
|
||||
let prevLeadingSurrogate = false;
|
||||
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const code = str.charCodeAt(i);
|
||||
|
||||
if (code < 2048) {
|
||||
len += charLength2048[code];
|
||||
} else if (isLeadingSurrogate(code)) {
|
||||
len += 6; // \uXXXX since no pair with trailing surrogate yet
|
||||
prevLeadingSurrogate = true;
|
||||
continue;
|
||||
} else if (isTrailingSurrogate(code)) {
|
||||
len = prevLeadingSurrogate
|
||||
? len - 2 // surrogate pair (4 bytes), since we calculate prev leading surrogate as 6 bytes, substruct 2 bytes
|
||||
: len + 6; // \uXXXX
|
||||
} else {
|
||||
len += 3; // code >= 2048 is 3 bytes length for UTF8
|
||||
}
|
||||
|
||||
prevLeadingSurrogate = false;
|
||||
}
|
||||
|
||||
return len + 2; // +2 for quotes
|
||||
}
|
||||
|
||||
function primitiveLength(value) {
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
return stringLength(value);
|
||||
|
||||
case 'number':
|
||||
return Number.isFinite(value) ? String(value).length : 4 /* null */;
|
||||
|
||||
case 'boolean':
|
||||
return value ? 4 /* true */ : 5 /* false */;
|
||||
|
||||
case 'undefined':
|
||||
case 'object':
|
||||
return 4; /* null */
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function spaceLength(space) {
|
||||
space = normalizeSpace(space);
|
||||
return typeof space === 'string' ? space.length : 0;
|
||||
}
|
||||
|
||||
module.exports = function jsonStringifyInfo(value, replacer, space, options) {
|
||||
function walk(holder, key, value) {
|
||||
if (stop) {
|
||||
return;
|
||||
}
|
||||
|
||||
value = replaceValue(holder, key, value, replacer);
|
||||
|
||||
let type = getType(value);
|
||||
|
||||
// check for circular structure
|
||||
if (type !== PRIMITIVE && stack.has(value)) {
|
||||
circular.add(value);
|
||||
length += 4; // treat as null
|
||||
|
||||
if (!options.continueOnCircular) {
|
||||
stop = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case PRIMITIVE:
|
||||
if (value !== undefined || Array.isArray(holder)) {
|
||||
length += primitiveLength(value);
|
||||
} else if (holder === root) {
|
||||
length += 9; // FIXME: that's the length of undefined, should we normalize behaviour to convert it to null?
|
||||
}
|
||||
break;
|
||||
|
||||
case OBJECT: {
|
||||
if (visited.has(value)) {
|
||||
duplicate.add(value);
|
||||
length += visited.get(value);
|
||||
break;
|
||||
}
|
||||
|
||||
const valueLength = length;
|
||||
let entries = 0;
|
||||
|
||||
length += 2; // {}
|
||||
|
||||
stack.add(value);
|
||||
|
||||
for (const key in value) {
|
||||
if (hasOwnProperty.call(value, key) && (allowlist === null || allowlist.has(key))) {
|
||||
const prevLength = length;
|
||||
walk(value, key, value[key]);
|
||||
|
||||
if (prevLength !== length) {
|
||||
// value is printed
|
||||
length += stringLength(key) + 1; // "key":
|
||||
entries++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entries > 1) {
|
||||
length += entries - 1; // commas
|
||||
}
|
||||
|
||||
stack.delete(value);
|
||||
|
||||
if (space > 0 && entries > 0) {
|
||||
length += (1 + (stack.size + 1) * space + 1) * entries; // for each key-value: \n{space}
|
||||
length += 1 + stack.size * space; // for }
|
||||
}
|
||||
|
||||
visited.set(value, length - valueLength);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ARRAY: {
|
||||
if (visited.has(value)) {
|
||||
duplicate.add(value);
|
||||
length += visited.get(value);
|
||||
break;
|
||||
}
|
||||
|
||||
const valueLength = length;
|
||||
|
||||
length += 2; // []
|
||||
|
||||
stack.add(value);
|
||||
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
walk(value, i, value[i]);
|
||||
}
|
||||
|
||||
if (value.length > 1) {
|
||||
length += value.length - 1; // commas
|
||||
}
|
||||
|
||||
stack.delete(value);
|
||||
|
||||
if (space > 0 && value.length > 0) {
|
||||
length += (1 + (stack.size + 1) * space) * value.length; // for each element: \n{space}
|
||||
length += 1 + stack.size * space; // for ]
|
||||
}
|
||||
|
||||
visited.set(value, length - valueLength);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PROMISE:
|
||||
case STRING_STREAM:
|
||||
async.add(value);
|
||||
break;
|
||||
|
||||
case OBJECT_STREAM:
|
||||
length += 2; // []
|
||||
async.add(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let allowlist = null;
|
||||
replacer = normalizeReplacer(replacer);
|
||||
|
||||
if (Array.isArray(replacer)) {
|
||||
allowlist = new Set(replacer);
|
||||
replacer = null;
|
||||
}
|
||||
|
||||
space = spaceLength(space);
|
||||
options = options || {};
|
||||
|
||||
const visited = new Map();
|
||||
const stack = new Set();
|
||||
const duplicate = new Set();
|
||||
const circular = new Set();
|
||||
const async = new Set();
|
||||
const getType = options.async ? getTypeAsync : getTypeNative;
|
||||
const root = { '': value };
|
||||
let stop = false;
|
||||
let length = 0;
|
||||
|
||||
walk(root, '', value);
|
||||
|
||||
return {
|
||||
minLength: isNaN(length) ? Infinity : length,
|
||||
circular: [...circular],
|
||||
duplicate: [...duplicate],
|
||||
async: [...async]
|
||||
};
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user