Compare commits
105 Commits
Priyatham-
...
main
Author | SHA1 | Date |
---|---|---|
|
e736aa99fb | |
|
508cbf5d63 | |
|
521219bbbb | |
|
bd8c1d25a8 | |
|
1f8b82a3ea | |
|
5cc119b916 | |
|
ed392ef98d | |
|
3d688dfbc8 | |
|
01a1e2ceea | |
|
6099c144b3 | |
|
bc5052ba85 | |
|
f8f8ef9327 | |
|
80db290d4d | |
|
63a68d51e7 | |
|
950d4a9072 | |
|
8408889432 | |
|
54295a18f6 | |
|
3c360a9276 | |
|
7e7fb6d46a | |
|
235711d3d6 | |
|
88f2d51a33 | |
|
66e24f5d3c | |
|
a818be5766 | |
|
5867a8254b | |
|
05062286fd | |
|
0107bdfc5c | |
|
8819e41a80 | |
|
eab409b182 | |
|
e17b0fafe6 | |
|
eea8ce0794 | |
|
5cc0d61eef | |
|
220a268f34 | |
|
f253834592 | |
|
454160f415 | |
|
28cf8a7312 | |
|
e1ee20365f | |
|
412145b344 | |
|
e3e6d7d56a | |
|
927a691600 | |
|
b17a6f9860 | |
|
ec0dbdf6a9 | |
|
e4b977fe2a | |
|
eb8e51eb15 | |
|
15a99eb78b | |
|
24c2725e7e | |
|
3671d698aa | |
|
f68d98dd94 | |
|
6185934246 | |
|
98a999a827 | |
|
adac16075e | |
|
d6101762ff | |
|
3d3526b92c | |
|
a403761aed | |
|
d97bc4b0a0 | |
|
d2952f0af1 | |
|
1cfead2f8c | |
|
291821b5b6 | |
|
68eacf2750 | |
|
96e251f4f1 | |
|
9d0a2ad4db | |
|
e4369f03aa | |
|
56a9058455 | |
|
b063d663fb | |
|
2240d749a9 | |
|
5628545370 | |
|
63585484f7 | |
|
b91d2876e5 | |
|
fc457e7dc9 | |
|
e1e3753226 | |
|
e058b60645 | |
|
93894d5df7 | |
|
558875e639 | |
|
04ba320be7 | |
|
1d33a3c10c | |
|
b20ad70cfc | |
|
53d84550a8 | |
|
f818af6d34 | |
|
546cd70f54 | |
|
755d3e33d1 | |
|
d33aef5b77 | |
|
67119c0d9c | |
|
d883a6f25c | |
|
0e9afa7f42 | |
|
0916e3a295 | |
|
f60406e45f | |
|
f282801e87 | |
|
a70f9db8bc | |
|
2a2a92beac | |
|
50469e0ec0 | |
|
102f0f92b1 | |
|
b19ade697e | |
|
90c80c4dc8 | |
|
7f07090032 | |
|
b4def24a7e | |
|
10d50c9e28 | |
|
85a49269b4 | |
|
839aa37dfc | |
|
9559d40106 | |
|
be5004c1e0 | |
|
0268fa8a3d | |
|
841fa3a686 | |
|
f5909ebbe2 | |
|
dd644f5320 | |
|
9154bb7e16 | |
|
8c7bd27a71 |
3
.env
3
.env
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
MONGODB_CONNECTION_STRING = mongodb+srv://admin:ABxXFUBs5FMiAaDJ@form.iynew.mongodb.net/form?retryWrites=true&w=majority
|
|
||||||
JWT_SECRET = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
|
|
@ -1,11 +1,12 @@
|
||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
client/node_modules
|
||||||
/.pnp
|
client/.pnp
|
||||||
/.env
|
client/.env
|
||||||
.pnp.js
|
/client.pnp.js
|
||||||
|
server/node_modules
|
||||||
|
node_modules
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
.env.production.local
|
.env.production.local
|
||||||
|
.env
|
||||||
|
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
FROM gitpod/workspace-mongodb
|
|
||||||
|
|
||||||
# Install custom tools, runtimes, etc.
|
|
||||||
# For example "bastet", a command-line tetris clone:
|
|
||||||
# RUN brew install bastet
|
|
||||||
#
|
|
||||||
# More information: https://www.gitpod.io/docs/config-docker/
|
|
|
@ -1,6 +0,0 @@
|
||||||
image:
|
|
||||||
file: .gitpod.Dockerfile
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- init: npm install && npm run build
|
|
||||||
command: npm run start
|
|
|
@ -8,7 +8,7 @@
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
It's a packing and movers along with a conceriage service website.
|
It's a packing and movers along with a concierge service website.
|
||||||
To better connect both owners and tenants alike.
|
To better connect both owners and tenants alike.
|
||||||
It features a portal for both the parties to connect,communicate and choose the best deal.
|
It features a portal for both the parties to connect,communicate and choose the best deal.
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
const mongoose = require("mongoose");
|
|
||||||
const config = require('config');
|
|
||||||
const connectToDb = async () => {
|
|
||||||
try{
|
|
||||||
await mongoose.connect(
|
|
||||||
config.get('mongoURI'),
|
|
||||||
{
|
|
||||||
useCreateIndex:true,
|
|
||||||
useFindAndModify:true,
|
|
||||||
useUnifiedTopology:true,
|
|
||||||
useNewUrlParser: true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
console.log("mongo connection secure!");
|
|
||||||
|
|
||||||
} catch(error){
|
|
||||||
console.log(error);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = connectToDb;
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"mongoURI": "mongodb+srv://admin:ABxXFUBs5FMiAaDJ@form.iynew.mongodb.net/<dbname>?retryWrites=true&w=majority",
|
|
||||||
"jwtSecret": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
const jwt = require("jsonwebtoken");
|
|
||||||
const config = require("config");
|
|
||||||
|
|
||||||
const auth = (req, res, next) => {
|
|
||||||
try {
|
|
||||||
const token = req.header("x-auth-token");
|
|
||||||
if (!token)
|
|
||||||
return res
|
|
||||||
.status(401)
|
|
||||||
.json({ msg: "No authentication token, authorization denied." });
|
|
||||||
|
|
||||||
const verified = jwt.verify(token, config.get("jwtSecret") );
|
|
||||||
if (!verified)
|
|
||||||
return res
|
|
||||||
.status(401)
|
|
||||||
.json({ msg: "Token verification failed, authorization denied." });
|
|
||||||
|
|
||||||
req.user = verified.id;
|
|
||||||
next();
|
|
||||||
} catch (err) {
|
|
||||||
res.status(500).json({ error: err.message });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = auth;
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../is-ci/bin.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../is-ci/bin.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
|
@ -1,17 +0,0 @@
|
||||||
@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%\..\is-ci\bin.js" %*
|
|
||||||
ENDLOCAL
|
|
||||||
EXIT /b %errorlevel%
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
& "$basedir/node$exe" "$basedir/../is-ci/bin.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../is-ci/bin.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../json5/lib/cli.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../json5/lib/cli.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
|
@ -1,17 +0,0 @@
|
||||||
@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
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
& "$basedir/node$exe" "$basedir/../json5/lib/cli.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../json5/lib/cli.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../mime/cli.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../mime/cli.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
|
@ -1,17 +0,0 @@
|
||||||
@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
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../mime/cli.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../nodemon/bin/nodemon.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../nodemon/bin/nodemon.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
|
@ -1,17 +0,0 @@
|
||||||
@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%\..\nodemon\bin\nodemon.js" %*
|
|
||||||
ENDLOCAL
|
|
||||||
EXIT /b %errorlevel%
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
& "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../touch/bin/nodetouch.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../touch/bin/nodetouch.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
|
@ -1,17 +0,0 @@
|
||||||
@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%\..\touch\bin\nodetouch.js" %*
|
|
||||||
ENDLOCAL
|
|
||||||
EXIT /b %errorlevel%
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
& "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../nopt/bin/nopt.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../nopt/bin/nopt.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
|
@ -1,17 +0,0 @@
|
||||||
@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%\..\nopt\bin\nopt.js" %*
|
|
||||||
ENDLOCAL
|
|
||||||
EXIT /b %errorlevel%
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
& "$basedir/node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../rc/cli.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../rc/cli.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
|
@ -1,17 +0,0 @@
|
||||||
@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%\..\rc\cli.js" %*
|
|
||||||
ENDLOCAL
|
|
||||||
EXIT /b %errorlevel%
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
& "$basedir/node$exe" "$basedir/../rc/cli.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../rc/cli.js" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../semver/bin/semver" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
|
@ -1,17 +0,0 @@
|
||||||
@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" %*
|
|
||||||
ENDLOCAL
|
|
||||||
EXIT /b %errorlevel%
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../semver/bin/semver" $args
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
|
@ -1,132 +0,0 @@
|
||||||
/// <reference types="node" />
|
|
||||||
/// <reference lib="es2016" />
|
|
||||||
/// <reference lib="es2017.sharedmemory" />
|
|
||||||
/// <reference lib="esnext.asynciterable" />
|
|
||||||
/// <reference lib="dom" />
|
|
||||||
declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
||||||
declare type Primitive = null | undefined | string | number | boolean | Symbol;
|
|
||||||
export interface ArrayLike {
|
|
||||||
length: number;
|
|
||||||
}
|
|
||||||
export interface Class<T = unknown> {
|
|
||||||
new (...args: any[]): T;
|
|
||||||
}
|
|
||||||
declare type DomElement = object & {
|
|
||||||
nodeType: 1;
|
|
||||||
nodeName: string;
|
|
||||||
};
|
|
||||||
declare type NodeStream = object & {
|
|
||||||
pipe: Function;
|
|
||||||
};
|
|
||||||
export declare const enum TypeName {
|
|
||||||
null = "null",
|
|
||||||
boolean = "boolean",
|
|
||||||
undefined = "undefined",
|
|
||||||
string = "string",
|
|
||||||
number = "number",
|
|
||||||
symbol = "symbol",
|
|
||||||
Function = "Function",
|
|
||||||
GeneratorFunction = "GeneratorFunction",
|
|
||||||
AsyncFunction = "AsyncFunction",
|
|
||||||
Observable = "Observable",
|
|
||||||
Array = "Array",
|
|
||||||
Buffer = "Buffer",
|
|
||||||
Object = "Object",
|
|
||||||
RegExp = "RegExp",
|
|
||||||
Date = "Date",
|
|
||||||
Error = "Error",
|
|
||||||
Map = "Map",
|
|
||||||
Set = "Set",
|
|
||||||
WeakMap = "WeakMap",
|
|
||||||
WeakSet = "WeakSet",
|
|
||||||
Int8Array = "Int8Array",
|
|
||||||
Uint8Array = "Uint8Array",
|
|
||||||
Uint8ClampedArray = "Uint8ClampedArray",
|
|
||||||
Int16Array = "Int16Array",
|
|
||||||
Uint16Array = "Uint16Array",
|
|
||||||
Int32Array = "Int32Array",
|
|
||||||
Uint32Array = "Uint32Array",
|
|
||||||
Float32Array = "Float32Array",
|
|
||||||
Float64Array = "Float64Array",
|
|
||||||
ArrayBuffer = "ArrayBuffer",
|
|
||||||
SharedArrayBuffer = "SharedArrayBuffer",
|
|
||||||
DataView = "DataView",
|
|
||||||
Promise = "Promise",
|
|
||||||
URL = "URL"
|
|
||||||
}
|
|
||||||
declare function is(value: unknown): TypeName;
|
|
||||||
declare namespace is {
|
|
||||||
const undefined: (value: unknown) => value is undefined;
|
|
||||||
const string: (value: unknown) => value is string;
|
|
||||||
const number: (value: unknown) => value is number;
|
|
||||||
const function_: (value: unknown) => value is Function;
|
|
||||||
const null_: (value: unknown) => value is null;
|
|
||||||
const class_: (value: unknown) => value is Class<unknown>;
|
|
||||||
const boolean: (value: unknown) => value is boolean;
|
|
||||||
const symbol: (value: unknown) => value is Symbol;
|
|
||||||
const numericString: (value: unknown) => boolean;
|
|
||||||
const array: (arg: any) => arg is any[];
|
|
||||||
const buffer: (input: unknown) => input is Buffer;
|
|
||||||
const nullOrUndefined: (value: unknown) => value is null | undefined;
|
|
||||||
const object: (value: unknown) => value is object;
|
|
||||||
const iterable: (value: unknown) => value is IterableIterator<unknown>;
|
|
||||||
const asyncIterable: (value: unknown) => value is AsyncIterableIterator<unknown>;
|
|
||||||
const generator: (value: unknown) => value is Generator;
|
|
||||||
const nativePromise: (value: unknown) => value is Promise<unknown>;
|
|
||||||
const promise: (value: unknown) => value is Promise<unknown>;
|
|
||||||
const generatorFunction: (value: unknown) => value is GeneratorFunction;
|
|
||||||
const asyncFunction: (value: unknown) => value is Function;
|
|
||||||
const boundFunction: (value: unknown) => value is Function;
|
|
||||||
const regExp: (value: unknown) => value is RegExp;
|
|
||||||
const date: (value: unknown) => value is Date;
|
|
||||||
const error: (value: unknown) => value is Error;
|
|
||||||
const map: (value: unknown) => value is Map<unknown, unknown>;
|
|
||||||
const set: (value: unknown) => value is Set<unknown>;
|
|
||||||
const weakMap: (value: unknown) => value is WeakMap<object, unknown>;
|
|
||||||
const weakSet: (value: unknown) => value is WeakSet<object>;
|
|
||||||
const int8Array: (value: unknown) => value is Int8Array;
|
|
||||||
const uint8Array: (value: unknown) => value is Uint8Array;
|
|
||||||
const uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;
|
|
||||||
const int16Array: (value: unknown) => value is Int16Array;
|
|
||||||
const uint16Array: (value: unknown) => value is Uint16Array;
|
|
||||||
const int32Array: (value: unknown) => value is Int32Array;
|
|
||||||
const uint32Array: (value: unknown) => value is Uint32Array;
|
|
||||||
const float32Array: (value: unknown) => value is Float32Array;
|
|
||||||
const float64Array: (value: unknown) => value is Float64Array;
|
|
||||||
const arrayBuffer: (value: unknown) => value is ArrayBuffer;
|
|
||||||
const sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;
|
|
||||||
const dataView: (value: unknown) => value is DataView;
|
|
||||||
const directInstanceOf: <T>(instance: unknown, klass: Class<T>) => instance is T;
|
|
||||||
const urlInstance: (value: unknown) => value is URL;
|
|
||||||
const urlString: (value: unknown) => boolean;
|
|
||||||
const truthy: (value: unknown) => boolean;
|
|
||||||
const falsy: (value: unknown) => boolean;
|
|
||||||
const nan: (value: unknown) => boolean;
|
|
||||||
const primitive: (value: unknown) => value is Primitive;
|
|
||||||
const integer: (value: unknown) => value is number;
|
|
||||||
const safeInteger: (value: unknown) => value is number;
|
|
||||||
const plainObject: (value: unknown) => boolean;
|
|
||||||
const typedArray: (value: unknown) => value is TypedArray;
|
|
||||||
const arrayLike: (value: unknown) => value is ArrayLike;
|
|
||||||
const inRange: (value: number, range: number | number[]) => boolean;
|
|
||||||
const domElement: (value: unknown) => value is DomElement;
|
|
||||||
const observable: (value: unknown) => boolean;
|
|
||||||
const nodeStream: (value: unknown) => value is NodeStream;
|
|
||||||
const infinite: (value: unknown) => boolean;
|
|
||||||
const even: (value: number) => boolean;
|
|
||||||
const odd: (value: number) => boolean;
|
|
||||||
const emptyArray: (value: unknown) => boolean;
|
|
||||||
const nonEmptyArray: (value: unknown) => boolean;
|
|
||||||
const emptyString: (value: unknown) => boolean;
|
|
||||||
const nonEmptyString: (value: unknown) => boolean;
|
|
||||||
const emptyStringOrWhitespace: (value: unknown) => boolean;
|
|
||||||
const emptyObject: (value: unknown) => boolean;
|
|
||||||
const nonEmptyObject: (value: unknown) => boolean;
|
|
||||||
const emptySet: (value: unknown) => boolean;
|
|
||||||
const nonEmptySet: (value: unknown) => boolean;
|
|
||||||
const emptyMap: (value: unknown) => boolean;
|
|
||||||
const nonEmptyMap: (value: unknown) => boolean;
|
|
||||||
const any: (predicate: unknown, ...values: unknown[]) => boolean;
|
|
||||||
const all: (predicate: unknown, ...values: unknown[]) => boolean;
|
|
||||||
}
|
|
||||||
export default is;
|
|
|
@ -1,245 +0,0 @@
|
||||||
"use strict";
|
|
||||||
/// <reference lib="es2016"/>
|
|
||||||
/// <reference lib="es2017.sharedmemory"/>
|
|
||||||
/// <reference lib="esnext.asynciterable"/>
|
|
||||||
/// <reference lib="dom"/>
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// TODO: Use the `URL` global when targeting Node.js 10
|
|
||||||
// tslint:disable-next-line
|
|
||||||
const URLGlobal = typeof URL === 'undefined' ? require('url').URL : URL;
|
|
||||||
const toString = Object.prototype.toString;
|
|
||||||
const isOfType = (type) => (value) => typeof value === type;
|
|
||||||
const isBuffer = (input) => !is.nullOrUndefined(input) && !is.nullOrUndefined(input.constructor) && is.function_(input.constructor.isBuffer) && input.constructor.isBuffer(input);
|
|
||||||
const getObjectType = (value) => {
|
|
||||||
const objectName = toString.call(value).slice(8, -1);
|
|
||||||
if (objectName) {
|
|
||||||
return objectName;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
const isObjectOfType = (type) => (value) => getObjectType(value) === type;
|
|
||||||
function is(value) {
|
|
||||||
switch (value) {
|
|
||||||
case null:
|
|
||||||
return "null" /* null */;
|
|
||||||
case true:
|
|
||||||
case false:
|
|
||||||
return "boolean" /* boolean */;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
switch (typeof value) {
|
|
||||||
case 'undefined':
|
|
||||||
return "undefined" /* undefined */;
|
|
||||||
case 'string':
|
|
||||||
return "string" /* string */;
|
|
||||||
case 'number':
|
|
||||||
return "number" /* number */;
|
|
||||||
case 'symbol':
|
|
||||||
return "symbol" /* symbol */;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
if (is.function_(value)) {
|
|
||||||
return "Function" /* Function */;
|
|
||||||
}
|
|
||||||
if (is.observable(value)) {
|
|
||||||
return "Observable" /* Observable */;
|
|
||||||
}
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return "Array" /* Array */;
|
|
||||||
}
|
|
||||||
if (isBuffer(value)) {
|
|
||||||
return "Buffer" /* Buffer */;
|
|
||||||
}
|
|
||||||
const tagType = getObjectType(value);
|
|
||||||
if (tagType) {
|
|
||||||
return tagType;
|
|
||||||
}
|
|
||||||
if (value instanceof String || value instanceof Boolean || value instanceof Number) {
|
|
||||||
throw new TypeError('Please don\'t use object wrappers for primitive types');
|
|
||||||
}
|
|
||||||
return "Object" /* Object */;
|
|
||||||
}
|
|
||||||
(function (is) {
|
|
||||||
// tslint:disable-next-line:strict-type-predicates
|
|
||||||
const isObject = (value) => typeof value === 'object';
|
|
||||||
// tslint:disable:variable-name
|
|
||||||
is.undefined = isOfType('undefined');
|
|
||||||
is.string = isOfType('string');
|
|
||||||
is.number = isOfType('number');
|
|
||||||
is.function_ = isOfType('function');
|
|
||||||
// tslint:disable-next-line:strict-type-predicates
|
|
||||||
is.null_ = (value) => value === null;
|
|
||||||
is.class_ = (value) => is.function_(value) && value.toString().startsWith('class ');
|
|
||||||
is.boolean = (value) => value === true || value === false;
|
|
||||||
is.symbol = isOfType('symbol');
|
|
||||||
// tslint:enable:variable-name
|
|
||||||
is.numericString = (value) => is.string(value) && value.length > 0 && !Number.isNaN(Number(value));
|
|
||||||
is.array = Array.isArray;
|
|
||||||
is.buffer = isBuffer;
|
|
||||||
is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value);
|
|
||||||
is.object = (value) => !is.nullOrUndefined(value) && (is.function_(value) || isObject(value));
|
|
||||||
is.iterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.iterator]);
|
|
||||||
is.asyncIterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.asyncIterator]);
|
|
||||||
is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw);
|
|
||||||
is.nativePromise = (value) => isObjectOfType("Promise" /* Promise */)(value);
|
|
||||||
const hasPromiseAPI = (value) => !is.null_(value) &&
|
|
||||||
isObject(value) &&
|
|
||||||
is.function_(value.then) &&
|
|
||||||
is.function_(value.catch);
|
|
||||||
is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
|
|
||||||
is.generatorFunction = isObjectOfType("GeneratorFunction" /* GeneratorFunction */);
|
|
||||||
is.asyncFunction = isObjectOfType("AsyncFunction" /* AsyncFunction */);
|
|
||||||
is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype');
|
|
||||||
is.regExp = isObjectOfType("RegExp" /* RegExp */);
|
|
||||||
is.date = isObjectOfType("Date" /* Date */);
|
|
||||||
is.error = isObjectOfType("Error" /* Error */);
|
|
||||||
is.map = (value) => isObjectOfType("Map" /* Map */)(value);
|
|
||||||
is.set = (value) => isObjectOfType("Set" /* Set */)(value);
|
|
||||||
is.weakMap = (value) => isObjectOfType("WeakMap" /* WeakMap */)(value);
|
|
||||||
is.weakSet = (value) => isObjectOfType("WeakSet" /* WeakSet */)(value);
|
|
||||||
is.int8Array = isObjectOfType("Int8Array" /* Int8Array */);
|
|
||||||
is.uint8Array = isObjectOfType("Uint8Array" /* Uint8Array */);
|
|
||||||
is.uint8ClampedArray = isObjectOfType("Uint8ClampedArray" /* Uint8ClampedArray */);
|
|
||||||
is.int16Array = isObjectOfType("Int16Array" /* Int16Array */);
|
|
||||||
is.uint16Array = isObjectOfType("Uint16Array" /* Uint16Array */);
|
|
||||||
is.int32Array = isObjectOfType("Int32Array" /* Int32Array */);
|
|
||||||
is.uint32Array = isObjectOfType("Uint32Array" /* Uint32Array */);
|
|
||||||
is.float32Array = isObjectOfType("Float32Array" /* Float32Array */);
|
|
||||||
is.float64Array = isObjectOfType("Float64Array" /* Float64Array */);
|
|
||||||
is.arrayBuffer = isObjectOfType("ArrayBuffer" /* ArrayBuffer */);
|
|
||||||
is.sharedArrayBuffer = isObjectOfType("SharedArrayBuffer" /* SharedArrayBuffer */);
|
|
||||||
is.dataView = isObjectOfType("DataView" /* DataView */);
|
|
||||||
is.directInstanceOf = (instance, klass) => Object.getPrototypeOf(instance) === klass.prototype;
|
|
||||||
is.urlInstance = (value) => isObjectOfType("URL" /* URL */)(value);
|
|
||||||
is.urlString = (value) => {
|
|
||||||
if (!is.string(value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
new URLGlobal(value); // tslint:disable-line no-unused-expression
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (_a) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
is.truthy = (value) => Boolean(value);
|
|
||||||
is.falsy = (value) => !value;
|
|
||||||
is.nan = (value) => Number.isNaN(value);
|
|
||||||
const primitiveTypes = new Set([
|
|
||||||
'undefined',
|
|
||||||
'string',
|
|
||||||
'number',
|
|
||||||
'boolean',
|
|
||||||
'symbol'
|
|
||||||
]);
|
|
||||||
is.primitive = (value) => is.null_(value) || primitiveTypes.has(typeof value);
|
|
||||||
is.integer = (value) => Number.isInteger(value);
|
|
||||||
is.safeInteger = (value) => Number.isSafeInteger(value);
|
|
||||||
is.plainObject = (value) => {
|
|
||||||
// From: https://github.com/sindresorhus/is-plain-obj/blob/master/index.js
|
|
||||||
let prototype;
|
|
||||||
return getObjectType(value) === "Object" /* Object */ &&
|
|
||||||
(prototype = Object.getPrototypeOf(value), prototype === null || // tslint:disable-line:ban-comma-operator
|
|
||||||
prototype === Object.getPrototypeOf({}));
|
|
||||||
};
|
|
||||||
const typedArrayTypes = new Set([
|
|
||||||
"Int8Array" /* Int8Array */,
|
|
||||||
"Uint8Array" /* Uint8Array */,
|
|
||||||
"Uint8ClampedArray" /* Uint8ClampedArray */,
|
|
||||||
"Int16Array" /* Int16Array */,
|
|
||||||
"Uint16Array" /* Uint16Array */,
|
|
||||||
"Int32Array" /* Int32Array */,
|
|
||||||
"Uint32Array" /* Uint32Array */,
|
|
||||||
"Float32Array" /* Float32Array */,
|
|
||||||
"Float64Array" /* Float64Array */
|
|
||||||
]);
|
|
||||||
is.typedArray = (value) => {
|
|
||||||
const objectType = getObjectType(value);
|
|
||||||
if (objectType === null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return typedArrayTypes.has(objectType);
|
|
||||||
};
|
|
||||||
const isValidLength = (value) => is.safeInteger(value) && value > -1;
|
|
||||||
is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length);
|
|
||||||
is.inRange = (value, range) => {
|
|
||||||
if (is.number(range)) {
|
|
||||||
return value >= Math.min(0, range) && value <= Math.max(range, 0);
|
|
||||||
}
|
|
||||||
if (is.array(range) && range.length === 2) {
|
|
||||||
return value >= Math.min(...range) && value <= Math.max(...range);
|
|
||||||
}
|
|
||||||
throw new TypeError(`Invalid range: ${JSON.stringify(range)}`);
|
|
||||||
};
|
|
||||||
const NODE_TYPE_ELEMENT = 1;
|
|
||||||
const DOM_PROPERTIES_TO_CHECK = [
|
|
||||||
'innerHTML',
|
|
||||||
'ownerDocument',
|
|
||||||
'style',
|
|
||||||
'attributes',
|
|
||||||
'nodeValue'
|
|
||||||
];
|
|
||||||
is.domElement = (value) => is.object(value) && value.nodeType === NODE_TYPE_ELEMENT && is.string(value.nodeName) &&
|
|
||||||
!is.plainObject(value) && DOM_PROPERTIES_TO_CHECK.every(property => property in value);
|
|
||||||
is.observable = (value) => {
|
|
||||||
if (!value) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (value[Symbol.observable] && value === value[Symbol.observable]()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (value['@@observable'] && value === value['@@observable']()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
is.nodeStream = (value) => !is.nullOrUndefined(value) && isObject(value) && is.function_(value.pipe) && !is.observable(value);
|
|
||||||
is.infinite = (value) => value === Infinity || value === -Infinity;
|
|
||||||
const isAbsoluteMod2 = (rem) => (value) => is.integer(value) && Math.abs(value % 2) === rem;
|
|
||||||
is.even = isAbsoluteMod2(0);
|
|
||||||
is.odd = isAbsoluteMod2(1);
|
|
||||||
const isWhiteSpaceString = (value) => is.string(value) && /\S/.test(value) === false;
|
|
||||||
is.emptyArray = (value) => is.array(value) && value.length === 0;
|
|
||||||
is.nonEmptyArray = (value) => is.array(value) && value.length > 0;
|
|
||||||
is.emptyString = (value) => is.string(value) && value.length === 0;
|
|
||||||
is.nonEmptyString = (value) => is.string(value) && value.length > 0;
|
|
||||||
is.emptyStringOrWhitespace = (value) => is.emptyString(value) || isWhiteSpaceString(value);
|
|
||||||
is.emptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length === 0;
|
|
||||||
is.nonEmptyObject = (value) => is.object(value) && !is.map(value) && !is.set(value) && Object.keys(value).length > 0;
|
|
||||||
is.emptySet = (value) => is.set(value) && value.size === 0;
|
|
||||||
is.nonEmptySet = (value) => is.set(value) && value.size > 0;
|
|
||||||
is.emptyMap = (value) => is.map(value) && value.size === 0;
|
|
||||||
is.nonEmptyMap = (value) => is.map(value) && value.size > 0;
|
|
||||||
const predicateOnArray = (method, predicate, values) => {
|
|
||||||
if (is.function_(predicate) === false) {
|
|
||||||
throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
|
|
||||||
}
|
|
||||||
if (values.length === 0) {
|
|
||||||
throw new TypeError('Invalid number of values');
|
|
||||||
}
|
|
||||||
return method.call(values, predicate);
|
|
||||||
};
|
|
||||||
// tslint:disable variable-name
|
|
||||||
is.any = (predicate, ...values) => predicateOnArray(Array.prototype.some, predicate, values);
|
|
||||||
is.all = (predicate, ...values) => predicateOnArray(Array.prototype.every, predicate, values);
|
|
||||||
// tslint:enable variable-name
|
|
||||||
})(is || (is = {}));
|
|
||||||
// Some few keywords are reserved, but we'll populate them for Node.js users
|
|
||||||
// See https://github.com/Microsoft/TypeScript/issues/2536
|
|
||||||
Object.defineProperties(is, {
|
|
||||||
class: {
|
|
||||||
value: is.class_
|
|
||||||
},
|
|
||||||
function: {
|
|
||||||
value: is.function_
|
|
||||||
},
|
|
||||||
null: {
|
|
||||||
value: is.null_
|
|
||||||
}
|
|
||||||
});
|
|
||||||
exports.default = is;
|
|
||||||
// For CommonJS default export support
|
|
||||||
module.exports = is;
|
|
||||||
module.exports.default = is;
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
File diff suppressed because one or more lines are too long
|
@ -1,9 +0,0 @@
|
||||||
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.
|
|
|
@ -1,96 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "@sindresorhus/is@^0.14.0",
|
|
||||||
"_id": "@sindresorhus/is@0.14.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==",
|
|
||||||
"_location": "/@sindresorhus/is",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@sindresorhus/is@^0.14.0",
|
|
||||||
"name": "@sindresorhus/is",
|
|
||||||
"escapedName": "@sindresorhus%2fis",
|
|
||||||
"scope": "@sindresorhus",
|
|
||||||
"rawSpec": "^0.14.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^0.14.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/got"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
|
|
||||||
"_shasum": "9fb3a3cf3132328151f353de4632e01e52102bea",
|
|
||||||
"_spec": "@sindresorhus/is@^0.14.0",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\got",
|
|
||||||
"author": {
|
|
||||||
"name": "Sindre Sorhus",
|
|
||||||
"email": "sindresorhus@gmail.com",
|
|
||||||
"url": "sindresorhus.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/sindresorhus/is/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Type check values: `is.string('🦄') //=> true`",
|
|
||||||
"devDependencies": {
|
|
||||||
"@sindresorhus/tsconfig": "^0.1.0",
|
|
||||||
"@types/jsdom": "^11.12.0",
|
|
||||||
"@types/node": "^10.12.10",
|
|
||||||
"@types/tempy": "^0.2.0",
|
|
||||||
"@types/zen-observable": "^0.8.0",
|
|
||||||
"ava": "^0.25.0",
|
|
||||||
"del-cli": "^1.1.0",
|
|
||||||
"jsdom": "^11.6.2",
|
|
||||||
"rxjs": "^6.3.3",
|
|
||||||
"tempy": "^0.2.1",
|
|
||||||
"tslint": "^5.9.1",
|
|
||||||
"tslint-xo": "^0.10.0",
|
|
||||||
"typescript": "^3.2.1",
|
|
||||||
"zen-observable": "^0.8.8"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/sindresorhus/is#readme",
|
|
||||||
"keywords": [
|
|
||||||
"type",
|
|
||||||
"types",
|
|
||||||
"is",
|
|
||||||
"check",
|
|
||||||
"checking",
|
|
||||||
"validate",
|
|
||||||
"validation",
|
|
||||||
"utility",
|
|
||||||
"util",
|
|
||||||
"typeof",
|
|
||||||
"instanceof",
|
|
||||||
"object",
|
|
||||||
"assert",
|
|
||||||
"assertion",
|
|
||||||
"test",
|
|
||||||
"kind",
|
|
||||||
"primitive",
|
|
||||||
"verify",
|
|
||||||
"compare"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "dist/index.js",
|
|
||||||
"name": "@sindresorhus/is",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/sindresorhus/is.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "del dist && tsc",
|
|
||||||
"lint": "tslint --format stylish --project .",
|
|
||||||
"prepublish": "npm run build && del dist/tests",
|
|
||||||
"test": "npm run lint && npm run build && ava dist/tests"
|
|
||||||
},
|
|
||||||
"types": "dist/index.d.ts",
|
|
||||||
"version": "0.14.0"
|
|
||||||
}
|
|
|
@ -1,451 +0,0 @@
|
||||||
# is [](https://travis-ci.org/sindresorhus/is)
|
|
||||||
|
|
||||||
> Type check values: `is.string('🦄') //=> true`
|
|
||||||
|
|
||||||
<img src="header.gif" width="182" align="right">
|
|
||||||
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```
|
|
||||||
$ npm install @sindresorhus/is
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
const is = require('@sindresorhus/is');
|
|
||||||
|
|
||||||
is('🦄');
|
|
||||||
//=> 'string'
|
|
||||||
|
|
||||||
is(new Map());
|
|
||||||
//=> 'Map'
|
|
||||||
|
|
||||||
is.number(6);
|
|
||||||
//=> true
|
|
||||||
```
|
|
||||||
|
|
||||||
When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used to infer the correct type inside if-else statements.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
import is from '@sindresorhus/is';
|
|
||||||
|
|
||||||
const padLeft = (value: string, padding: string | number) => {
|
|
||||||
if (is.number(padding)) {
|
|
||||||
// `padding` is typed as `number`
|
|
||||||
return Array(padding + 1).join(' ') + value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is.string(padding)) {
|
|
||||||
// `padding` is typed as `string`
|
|
||||||
return padding + value;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new TypeError(`Expected 'padding' to be of type 'string' or 'number', got '${is(padding)}'.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
padLeft('🦄', 3);
|
|
||||||
//=> ' 🦄'
|
|
||||||
|
|
||||||
padLeft('🦄', '🌈');
|
|
||||||
//=> '🌈🦄'
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### is(value)
|
|
||||||
|
|
||||||
Returns the type of `value`.
|
|
||||||
|
|
||||||
Primitives are lowercase and object types are camelcase.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
- `'undefined'`
|
|
||||||
- `'null'`
|
|
||||||
- `'string'`
|
|
||||||
- `'symbol'`
|
|
||||||
- `'Array'`
|
|
||||||
- `'Function'`
|
|
||||||
- `'Object'`
|
|
||||||
|
|
||||||
Note: It will throw an error if you try to feed it object-wrapped primitives, as that's a bad practice. For example `new String('foo')`.
|
|
||||||
|
|
||||||
### is.{method}
|
|
||||||
|
|
||||||
All the below methods accept a value and returns a boolean for whether the value is of the desired type.
|
|
||||||
|
|
||||||
#### Primitives
|
|
||||||
|
|
||||||
##### .undefined(value)
|
|
||||||
##### .null(value)
|
|
||||||
##### .string(value)
|
|
||||||
##### .number(value)
|
|
||||||
##### .boolean(value)
|
|
||||||
##### .symbol(value)
|
|
||||||
|
|
||||||
#### Built-in types
|
|
||||||
|
|
||||||
##### .array(value)
|
|
||||||
##### .function(value)
|
|
||||||
##### .buffer(value)
|
|
||||||
##### .object(value)
|
|
||||||
|
|
||||||
Keep in mind that [functions are objects too](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions).
|
|
||||||
|
|
||||||
##### .numericString(value)
|
|
||||||
|
|
||||||
Returns `true` for a string that represents a number. For example, `'42'` and `'-8'`.
|
|
||||||
|
|
||||||
Note: `'NaN'` returns `false`, but `'Infinity'` and `'-Infinity'` return `true`.
|
|
||||||
|
|
||||||
##### .regExp(value)
|
|
||||||
##### .date(value)
|
|
||||||
##### .error(value)
|
|
||||||
##### .nativePromise(value)
|
|
||||||
##### .promise(value)
|
|
||||||
|
|
||||||
Returns `true` for any object with a `.then()` and `.catch()` method. Prefer this one over `.nativePromise()` as you usually want to allow userland promise implementations too.
|
|
||||||
|
|
||||||
##### .generator(value)
|
|
||||||
|
|
||||||
Returns `true` for any object that implements its own `.next()` and `.throw()` methods and has a function definition for `Symbol.iterator`.
|
|
||||||
|
|
||||||
##### .generatorFunction(value)
|
|
||||||
|
|
||||||
##### .asyncFunction(value)
|
|
||||||
|
|
||||||
Returns `true` for any `async` function that can be called with the `await` operator.
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.asyncFunction(async () => {});
|
|
||||||
// => true
|
|
||||||
|
|
||||||
is.asyncFunction(() => {});
|
|
||||||
// => false
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .boundFunction(value)
|
|
||||||
|
|
||||||
Returns `true` for any `bound` function.
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.boundFunction(() => {});
|
|
||||||
// => true
|
|
||||||
|
|
||||||
is.boundFunction(function () {}.bind(null));
|
|
||||||
// => true
|
|
||||||
|
|
||||||
is.boundFunction(function () {});
|
|
||||||
// => false
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .map(value)
|
|
||||||
##### .set(value)
|
|
||||||
##### .weakMap(value)
|
|
||||||
##### .weakSet(value)
|
|
||||||
|
|
||||||
#### Typed arrays
|
|
||||||
|
|
||||||
##### .int8Array(value)
|
|
||||||
##### .uint8Array(value)
|
|
||||||
##### .uint8ClampedArray(value)
|
|
||||||
##### .int16Array(value)
|
|
||||||
##### .uint16Array(value)
|
|
||||||
##### .int32Array(value)
|
|
||||||
##### .uint32Array(value)
|
|
||||||
##### .float32Array(value)
|
|
||||||
##### .float64Array(value)
|
|
||||||
|
|
||||||
#### Structured data
|
|
||||||
|
|
||||||
##### .arrayBuffer(value)
|
|
||||||
##### .sharedArrayBuffer(value)
|
|
||||||
##### .dataView(value)
|
|
||||||
|
|
||||||
#### Emptiness
|
|
||||||
|
|
||||||
##### .emptyString(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is a `string` and the `.length` is 0.
|
|
||||||
|
|
||||||
##### .nonEmptyString(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is a `string` and the `.length` is more than 0.
|
|
||||||
|
|
||||||
##### .emptyStringOrWhitespace(value)
|
|
||||||
|
|
||||||
Returns `true` if `is.emptyString(value)` or if it's a `string` that is all whitespace.
|
|
||||||
|
|
||||||
##### .emptyArray(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is an `Array` and the `.length` is 0.
|
|
||||||
|
|
||||||
##### .nonEmptyArray(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is an `Array` and the `.length` is more than 0.
|
|
||||||
|
|
||||||
##### .emptyObject(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
|
|
||||||
|
|
||||||
Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const object1 = {};
|
|
||||||
|
|
||||||
Object.defineProperty(object1, 'property1', {
|
|
||||||
value: 42,
|
|
||||||
writable: true,
|
|
||||||
enumerable: false,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
is.emptyObject(object1);
|
|
||||||
// => true
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .nonEmptyObject(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.
|
|
||||||
|
|
||||||
##### .emptySet(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is a `Set` and the `.size` is 0.
|
|
||||||
|
|
||||||
##### .nonEmptySet(Value)
|
|
||||||
|
|
||||||
Returns `true` if the value is a `Set` and the `.size` is more than 0.
|
|
||||||
|
|
||||||
##### .emptyMap(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is a `Map` and the `.size` is 0.
|
|
||||||
|
|
||||||
##### .nonEmptyMap(value)
|
|
||||||
|
|
||||||
Returns `true` if the value is a `Map` and the `.size` is more than 0.
|
|
||||||
|
|
||||||
#### Miscellaneous
|
|
||||||
|
|
||||||
##### .directInstanceOf(value, class)
|
|
||||||
|
|
||||||
Returns `true` if `value` is a direct instance of `class`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.directInstanceOf(new Error(), Error);
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
class UnicornError extends Error {}
|
|
||||||
|
|
||||||
is.directInstanceOf(new UnicornError(), Error);
|
|
||||||
//=> false
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .urlInstance(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is an instance of the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL).
|
|
||||||
|
|
||||||
```js
|
|
||||||
const url = new URL('https://example.com');
|
|
||||||
|
|
||||||
is.urlInstance(url);
|
|
||||||
//=> true
|
|
||||||
```
|
|
||||||
|
|
||||||
### .url(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is a URL string.
|
|
||||||
|
|
||||||
Note: this only does basic checking using the [`URL` class](https://developer.mozilla.org/en-US/docs/Web/API/URL) constructor.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const url = 'https://example.com';
|
|
||||||
|
|
||||||
is.url(url);
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
is.url(new URL(url));
|
|
||||||
//=> false
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .truthy(value)
|
|
||||||
|
|
||||||
Returns `true` for all values that evaluate to true in a boolean context:
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.truthy('🦄');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
is.truthy(undefined);
|
|
||||||
//=> false
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .falsy(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is one of: `false`, `0`, `''`, `null`, `undefined`, `NaN`.
|
|
||||||
|
|
||||||
##### .nan(value)
|
|
||||||
##### .nullOrUndefined(value)
|
|
||||||
##### .primitive(value)
|
|
||||||
|
|
||||||
JavaScript primitives are as follows: `null`, `undefined`, `string`, `number`, `boolean`, `symbol`.
|
|
||||||
|
|
||||||
##### .integer(value)
|
|
||||||
|
|
||||||
##### .safeInteger(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is a [safe integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
|
||||||
|
|
||||||
##### .plainObject(value)
|
|
||||||
|
|
||||||
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
|
||||||
|
|
||||||
##### .iterable(value)
|
|
||||||
##### .asyncIterable(value)
|
|
||||||
##### .class(value)
|
|
||||||
|
|
||||||
Returns `true` for instances created by a class.
|
|
||||||
|
|
||||||
##### .typedArray(value)
|
|
||||||
|
|
||||||
##### .arrayLike(value)
|
|
||||||
|
|
||||||
A `value` is array-like if it is not a function and has a `value.length` that is a safe integer greater than or equal to 0.
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.arrayLike(document.forms);
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
function foo() {
|
|
||||||
is.arrayLike(arguments);
|
|
||||||
//=> true
|
|
||||||
}
|
|
||||||
foo();
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .inRange(value, range)
|
|
||||||
|
|
||||||
Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.inRange(3, [0, 5]);
|
|
||||||
is.inRange(3, [5, 0]);
|
|
||||||
is.inRange(0, [-2, 2]);
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .inRange(value, upperBound)
|
|
||||||
|
|
||||||
Check if `value` (number) is in the range of `0` to `upperBound`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.inRange(3, 10);
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .domElement(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is a DOM Element.
|
|
||||||
|
|
||||||
##### .nodeStream(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is a Node.js [stream](https://nodejs.org/api/stream.html).
|
|
||||||
|
|
||||||
```js
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
is.nodeStream(fs.createReadStream('unicorn.png'));
|
|
||||||
//=> true
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .observable(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is an `Observable`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const {Observable} = require('rxjs');
|
|
||||||
|
|
||||||
is.observable(new Observable());
|
|
||||||
//=> true
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .infinite(value)
|
|
||||||
|
|
||||||
Check if `value` is `Infinity` or `-Infinity`.
|
|
||||||
|
|
||||||
##### .even(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is an even integer.
|
|
||||||
|
|
||||||
##### .odd(value)
|
|
||||||
|
|
||||||
Returns `true` if `value` is an odd integer.
|
|
||||||
|
|
||||||
##### .any(predicate, ...values)
|
|
||||||
|
|
||||||
Returns `true` if **any** of the input `values` returns true in the `predicate`:
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.any(is.string, {}, true, '🦄');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
is.any(is.boolean, 'unicorns', [], new Map());
|
|
||||||
//=> false
|
|
||||||
```
|
|
||||||
|
|
||||||
##### .all(predicate, ...values)
|
|
||||||
|
|
||||||
Returns `true` if **all** of the input `values` returns true in the `predicate`:
|
|
||||||
|
|
||||||
```js
|
|
||||||
is.all(is.object, {}, new Map(), new Set());
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
is.all(is.string, '🦄', [], 'unicorns');
|
|
||||||
//=> false
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## FAQ
|
|
||||||
|
|
||||||
### Why yet another type checking module?
|
|
||||||
|
|
||||||
There are hundreds of type checking modules on npm, unfortunately, I couldn't find any that fit my needs:
|
|
||||||
|
|
||||||
- Includes both type methods and ability to get the type
|
|
||||||
- Types of primitives returned as lowercase and object types as camelcase
|
|
||||||
- Covers all built-ins
|
|
||||||
- Unsurprising behavior
|
|
||||||
- Well-maintained
|
|
||||||
- Comprehensive test suite
|
|
||||||
|
|
||||||
For the ones I found, pick 3 of these.
|
|
||||||
|
|
||||||
The most common mistakes I noticed in these modules was using `instanceof` for type checking, forgetting that functions are objects, and omitting `symbol` as a primitive.
|
|
||||||
|
|
||||||
|
|
||||||
## Related
|
|
||||||
|
|
||||||
- [ow](https://github.com/sindresorhus/ow) - Function argument validation for humans
|
|
||||||
- [is-stream](https://github.com/sindresorhus/is-stream) - Check if something is a Node.js stream
|
|
||||||
- [is-observable](https://github.com/sindresorhus/is-observable) - Check if a value is an Observable
|
|
||||||
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
|
|
||||||
- [is-ip](https://github.com/sindresorhus/is-ip) - Check if a string is an IP address
|
|
||||||
- [is-array-sorted](https://github.com/sindresorhus/is-array-sorted) - Check if an Array is sorted
|
|
||||||
- [is-error-constructor](https://github.com/sindresorhus/is-error-constructor) - Check if a value is an error constructor
|
|
||||||
- [is-empty-iterable](https://github.com/sindresorhus/is-empty-iterable) - Check if an Iterable is empty
|
|
||||||
- [is-blob](https://github.com/sindresorhus/is-blob) - Check if a value is a Blob - File-like object of immutable, raw data
|
|
||||||
- [has-emoji](https://github.com/sindresorhus/has-emoji) - Check whether a string has any emoji
|
|
||||||
|
|
||||||
|
|
||||||
## Created by
|
|
||||||
|
|
||||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
||||||
- [Giora Guttsait](https://github.com/gioragutt)
|
|
||||||
- [Brandon Smith](https://github.com/brandon93s)
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT
|
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2018 Szymon Marczak
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -1,70 +0,0 @@
|
||||||
# http-timer
|
|
||||||
> Timings for HTTP requests
|
|
||||||
|
|
||||||
[](https://travis-ci.org/szmarczak/http-timer)
|
|
||||||
[](https://coveralls.io/github/szmarczak/http-timer?branch=master)
|
|
||||||
[](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
|
|
||||||
|
|
||||||
Inspired by the [`request` package](https://github.com/request/request).
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
```js
|
|
||||||
'use strict';
|
|
||||||
const https = require('https');
|
|
||||||
const timer = require('@szmarczak/http-timer');
|
|
||||||
|
|
||||||
const request = https.get('https://httpbin.org/anything');
|
|
||||||
const timings = timer(request);
|
|
||||||
|
|
||||||
request.on('response', response => {
|
|
||||||
response.on('data', () => {}); // Consume the data somehow
|
|
||||||
response.on('end', () => {
|
|
||||||
console.log(timings);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// { start: 1535708511443,
|
|
||||||
// socket: 1535708511444,
|
|
||||||
// lookup: 1535708511444,
|
|
||||||
// connect: 1535708511582,
|
|
||||||
// upload: 1535708511887,
|
|
||||||
// response: 1535708512037,
|
|
||||||
// end: 1535708512040,
|
|
||||||
// phases:
|
|
||||||
// { wait: 1,
|
|
||||||
// dns: 0,
|
|
||||||
// tcp: 138,
|
|
||||||
// request: 305,
|
|
||||||
// firstByte: 150,
|
|
||||||
// download: 3,
|
|
||||||
// total: 597 } }
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### timer(request)
|
|
||||||
|
|
||||||
Returns: `Object`
|
|
||||||
|
|
||||||
- `start` - Time when the request started.
|
|
||||||
- `socket` - Time when a socket was assigned to the request.
|
|
||||||
- `lookup` - Time when the DNS lookup finished.
|
|
||||||
- `connect` - Time when the socket successfully connected.
|
|
||||||
- `upload` - Time when the request finished uploading.
|
|
||||||
- `response` - Time when the request fired the `response` event.
|
|
||||||
- `end` - Time when the response fired the `end` event.
|
|
||||||
- `error` - Time when the request fired the `error` event.
|
|
||||||
- `phases`
|
|
||||||
- `wait` - `timings.socket - timings.start`
|
|
||||||
- `dns` - `timings.lookup - timings.socket`
|
|
||||||
- `tcp` - `timings.connect - timings.lookup`
|
|
||||||
- `request` - `timings.upload - timings.connect`
|
|
||||||
- `firstByte` - `timings.response - timings.upload`
|
|
||||||
- `download` - `timings.end - timings.response`
|
|
||||||
- `total` - `timings.end - timings.start` or `timings.error - timings.start`
|
|
||||||
|
|
||||||
**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT
|
|
|
@ -1,75 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "@szmarczak/http-timer@^1.1.2",
|
|
||||||
"_id": "@szmarczak/http-timer@1.1.2",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==",
|
|
||||||
"_location": "/@szmarczak/http-timer",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@szmarczak/http-timer@^1.1.2",
|
|
||||||
"name": "@szmarczak/http-timer",
|
|
||||||
"escapedName": "@szmarczak%2fhttp-timer",
|
|
||||||
"scope": "@szmarczak",
|
|
||||||
"rawSpec": "^1.1.2",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^1.1.2"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/got"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
|
|
||||||
"_shasum": "b1665e2c461a2cd92f4c1bbf50d5454de0d4b421",
|
|
||||||
"_spec": "@szmarczak/http-timer@^1.1.2",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\got",
|
|
||||||
"author": {
|
|
||||||
"name": "Szymon Marczak"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/szmarczak/http-timer/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"defer-to-connect": "^1.0.1"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Timings for HTTP requests",
|
|
||||||
"devDependencies": {
|
|
||||||
"ava": "^0.25.0",
|
|
||||||
"coveralls": "^3.0.2",
|
|
||||||
"nyc": "^12.0.2",
|
|
||||||
"p-event": "^2.1.0",
|
|
||||||
"xo": "^0.22.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"source"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/szmarczak/http-timer#readme",
|
|
||||||
"keywords": [
|
|
||||||
"http",
|
|
||||||
"https",
|
|
||||||
"timer",
|
|
||||||
"timings"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "source",
|
|
||||||
"name": "@szmarczak/http-timer",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/szmarczak/http-timer.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
|
||||||
"test": "xo && nyc ava"
|
|
||||||
},
|
|
||||||
"version": "1.1.2",
|
|
||||||
"xo": {
|
|
||||||
"rules": {
|
|
||||||
"unicorn/filename-case": "camelCase"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
'use strict';
|
|
||||||
const deferToConnect = require('defer-to-connect');
|
|
||||||
|
|
||||||
module.exports = request => {
|
|
||||||
const timings = {
|
|
||||||
start: Date.now(),
|
|
||||||
socket: null,
|
|
||||||
lookup: null,
|
|
||||||
connect: null,
|
|
||||||
upload: null,
|
|
||||||
response: null,
|
|
||||||
end: null,
|
|
||||||
error: null,
|
|
||||||
phases: {
|
|
||||||
wait: null,
|
|
||||||
dns: null,
|
|
||||||
tcp: null,
|
|
||||||
request: null,
|
|
||||||
firstByte: null,
|
|
||||||
download: null,
|
|
||||||
total: null
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleError = origin => {
|
|
||||||
const emit = origin.emit.bind(origin);
|
|
||||||
origin.emit = (event, ...args) => {
|
|
||||||
// Catches the `error` event
|
|
||||||
if (event === 'error') {
|
|
||||||
timings.error = Date.now();
|
|
||||||
timings.phases.total = timings.error - timings.start;
|
|
||||||
|
|
||||||
origin.emit = emit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Saves the original behavior
|
|
||||||
return emit(event, ...args);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
let uploadFinished = false;
|
|
||||||
const onUpload = () => {
|
|
||||||
timings.upload = Date.now();
|
|
||||||
timings.phases.request = timings.upload - timings.connect;
|
|
||||||
};
|
|
||||||
|
|
||||||
handleError(request);
|
|
||||||
|
|
||||||
request.once('socket', socket => {
|
|
||||||
timings.socket = Date.now();
|
|
||||||
timings.phases.wait = timings.socket - timings.start;
|
|
||||||
|
|
||||||
const lookupListener = () => {
|
|
||||||
timings.lookup = Date.now();
|
|
||||||
timings.phases.dns = timings.lookup - timings.socket;
|
|
||||||
};
|
|
||||||
|
|
||||||
socket.once('lookup', lookupListener);
|
|
||||||
|
|
||||||
deferToConnect(socket, () => {
|
|
||||||
timings.connect = Date.now();
|
|
||||||
|
|
||||||
if (timings.lookup === null) {
|
|
||||||
socket.removeListener('lookup', lookupListener);
|
|
||||||
timings.lookup = timings.connect;
|
|
||||||
timings.phases.dns = timings.lookup - timings.socket;
|
|
||||||
}
|
|
||||||
|
|
||||||
timings.phases.tcp = timings.connect - timings.lookup;
|
|
||||||
|
|
||||||
if (uploadFinished && !timings.upload) {
|
|
||||||
onUpload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
request.once('finish', () => {
|
|
||||||
uploadFinished = true;
|
|
||||||
|
|
||||||
if (timings.connect) {
|
|
||||||
onUpload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
request.once('response', response => {
|
|
||||||
timings.response = Date.now();
|
|
||||||
timings.phases.firstByte = timings.response - timings.upload;
|
|
||||||
|
|
||||||
handleError(response);
|
|
||||||
|
|
||||||
response.once('end', () => {
|
|
||||||
timings.end = Date.now();
|
|
||||||
timings.phases.download = timings.end - timings.response;
|
|
||||||
timings.phases.total = timings.end - timings.start;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return timings;
|
|
||||||
};
|
|
|
@ -1,46 +0,0 @@
|
||||||
This software is dual-licensed under the ISC and MIT licenses.
|
|
||||||
You may use this software under EITHER of the following licenses.
|
|
||||||
|
|
||||||
----------
|
|
||||||
|
|
||||||
The ISC License
|
|
||||||
|
|
||||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
||||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
----------
|
|
||||||
|
|
||||||
Copyright Isaac Z. Schlueter and Contributors
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
|
||||||
obtaining a copy of this software and associated documentation
|
|
||||||
files (the "Software"), to deal in the Software without
|
|
||||||
restriction, including without limitation the rights to use,
|
|
||||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
@ -1,23 +0,0 @@
|
||||||
# abbrev-js
|
|
||||||
|
|
||||||
Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
var abbrev = require("abbrev");
|
|
||||||
abbrev("foo", "fool", "folding", "flop");
|
|
||||||
|
|
||||||
// returns:
|
|
||||||
{ fl: 'flop'
|
|
||||||
, flo: 'flop'
|
|
||||||
, flop: 'flop'
|
|
||||||
, fol: 'folding'
|
|
||||||
, fold: 'folding'
|
|
||||||
, foldi: 'folding'
|
|
||||||
, foldin: 'folding'
|
|
||||||
, folding: 'folding'
|
|
||||||
, foo: 'foo'
|
|
||||||
, fool: 'fool'
|
|
||||||
}
|
|
||||||
|
|
||||||
This is handy for command-line scripts, or other cases where you want to be able to accept shorthands.
|
|
|
@ -1,61 +0,0 @@
|
||||||
module.exports = exports = abbrev.abbrev = abbrev
|
|
||||||
|
|
||||||
abbrev.monkeyPatch = monkeyPatch
|
|
||||||
|
|
||||||
function monkeyPatch () {
|
|
||||||
Object.defineProperty(Array.prototype, 'abbrev', {
|
|
||||||
value: function () { return abbrev(this) },
|
|
||||||
enumerable: false, configurable: true, writable: true
|
|
||||||
})
|
|
||||||
|
|
||||||
Object.defineProperty(Object.prototype, 'abbrev', {
|
|
||||||
value: function () { return abbrev(Object.keys(this)) },
|
|
||||||
enumerable: false, configurable: true, writable: true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function abbrev (list) {
|
|
||||||
if (arguments.length !== 1 || !Array.isArray(list)) {
|
|
||||||
list = Array.prototype.slice.call(arguments, 0)
|
|
||||||
}
|
|
||||||
for (var i = 0, l = list.length, args = [] ; i < l ; i ++) {
|
|
||||||
args[i] = typeof list[i] === "string" ? list[i] : String(list[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
// sort them lexicographically, so that they're next to their nearest kin
|
|
||||||
args = args.sort(lexSort)
|
|
||||||
|
|
||||||
// walk through each, seeing how much it has in common with the next and previous
|
|
||||||
var abbrevs = {}
|
|
||||||
, prev = ""
|
|
||||||
for (var i = 0, l = args.length ; i < l ; i ++) {
|
|
||||||
var current = args[i]
|
|
||||||
, next = args[i + 1] || ""
|
|
||||||
, nextMatches = true
|
|
||||||
, prevMatches = true
|
|
||||||
if (current === next) continue
|
|
||||||
for (var j = 0, cl = current.length ; j < cl ; j ++) {
|
|
||||||
var curChar = current.charAt(j)
|
|
||||||
nextMatches = nextMatches && curChar === next.charAt(j)
|
|
||||||
prevMatches = prevMatches && curChar === prev.charAt(j)
|
|
||||||
if (!nextMatches && !prevMatches) {
|
|
||||||
j ++
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prev = current
|
|
||||||
if (j === cl) {
|
|
||||||
abbrevs[current] = current
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for (var a = current.substr(0, j) ; j <= cl ; j ++) {
|
|
||||||
abbrevs[a] = current
|
|
||||||
a += current.charAt(j)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return abbrevs
|
|
||||||
}
|
|
||||||
|
|
||||||
function lexSort (a, b) {
|
|
||||||
return a === b ? 0 : a > b ? 1 : -1
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "abbrev@1",
|
|
||||||
"_id": "abbrev@1.1.1",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
|
|
||||||
"_location": "/abbrev",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "abbrev@1",
|
|
||||||
"name": "abbrev",
|
|
||||||
"escapedName": "abbrev",
|
|
||||||
"rawSpec": "1",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/nopt"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
|
|
||||||
"_shasum": "f8f2c887ad10bf67f634f005b6987fed3179aac8",
|
|
||||||
"_spec": "abbrev@1",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\nopt",
|
|
||||||
"author": {
|
|
||||||
"name": "Isaac Z. Schlueter",
|
|
||||||
"email": "i@izs.me"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/isaacs/abbrev-js/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Like ruby's abbrev module, but in js",
|
|
||||||
"devDependencies": {
|
|
||||||
"tap": "^10.1"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"abbrev.js"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/isaacs/abbrev-js#readme",
|
|
||||||
"license": "ISC",
|
|
||||||
"main": "abbrev.js",
|
|
||||||
"name": "abbrev",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+ssh://git@github.com/isaacs/abbrev-js.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"postpublish": "git push origin --all; git push origin --tags",
|
|
||||||
"postversion": "npm publish",
|
|
||||||
"preversion": "npm test",
|
|
||||||
"test": "tap test.js --100"
|
|
||||||
},
|
|
||||||
"version": "1.1.1"
|
|
||||||
}
|
|
|
@ -1,236 +0,0 @@
|
||||||
1.3.7 / 2019-04-29
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: negotiator@0.6.2
|
|
||||||
- Fix sorting charset, encoding, and language with extra parameters
|
|
||||||
|
|
||||||
1.3.6 / 2019-04-28
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.24
|
|
||||||
- deps: mime-db@~1.40.0
|
|
||||||
|
|
||||||
1.3.5 / 2018-02-28
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.18
|
|
||||||
- deps: mime-db@~1.33.0
|
|
||||||
|
|
||||||
1.3.4 / 2017-08-22
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.16
|
|
||||||
- deps: mime-db@~1.29.0
|
|
||||||
|
|
||||||
1.3.3 / 2016-05-02
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.11
|
|
||||||
- deps: mime-db@~1.23.0
|
|
||||||
* deps: negotiator@0.6.1
|
|
||||||
- perf: improve `Accept` parsing speed
|
|
||||||
- perf: improve `Accept-Charset` parsing speed
|
|
||||||
- perf: improve `Accept-Encoding` parsing speed
|
|
||||||
- perf: improve `Accept-Language` parsing speed
|
|
||||||
|
|
||||||
1.3.2 / 2016-03-08
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.10
|
|
||||||
- Fix extension of `application/dash+xml`
|
|
||||||
- Update primary extension for `audio/mp4`
|
|
||||||
- deps: mime-db@~1.22.0
|
|
||||||
|
|
||||||
1.3.1 / 2016-01-19
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.9
|
|
||||||
- deps: mime-db@~1.21.0
|
|
||||||
|
|
||||||
1.3.0 / 2015-09-29
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.7
|
|
||||||
- deps: mime-db@~1.19.0
|
|
||||||
* deps: negotiator@0.6.0
|
|
||||||
- Fix including type extensions in parameters in `Accept` parsing
|
|
||||||
- Fix parsing `Accept` parameters with quoted equals
|
|
||||||
- Fix parsing `Accept` parameters with quoted semicolons
|
|
||||||
- Lazy-load modules from main entry point
|
|
||||||
- perf: delay type concatenation until needed
|
|
||||||
- perf: enable strict mode
|
|
||||||
- perf: hoist regular expressions
|
|
||||||
- perf: remove closures getting spec properties
|
|
||||||
- perf: remove a closure from media type parsing
|
|
||||||
- perf: remove property delete from media type parsing
|
|
||||||
|
|
||||||
1.2.13 / 2015-09-06
|
|
||||||
===================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.6
|
|
||||||
- deps: mime-db@~1.18.0
|
|
||||||
|
|
||||||
1.2.12 / 2015-07-30
|
|
||||||
===================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.4
|
|
||||||
- deps: mime-db@~1.16.0
|
|
||||||
|
|
||||||
1.2.11 / 2015-07-16
|
|
||||||
===================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.3
|
|
||||||
- deps: mime-db@~1.15.0
|
|
||||||
|
|
||||||
1.2.10 / 2015-07-01
|
|
||||||
===================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.2
|
|
||||||
- deps: mime-db@~1.14.0
|
|
||||||
|
|
||||||
1.2.9 / 2015-06-08
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.1
|
|
||||||
- perf: fix deopt during mapping
|
|
||||||
|
|
||||||
1.2.8 / 2015-06-07
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.1.0
|
|
||||||
- deps: mime-db@~1.13.0
|
|
||||||
* perf: avoid argument reassignment & argument slice
|
|
||||||
* perf: avoid negotiator recursive construction
|
|
||||||
* perf: enable strict mode
|
|
||||||
* perf: remove unnecessary bitwise operator
|
|
||||||
|
|
||||||
1.2.7 / 2015-05-10
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: negotiator@0.5.3
|
|
||||||
- Fix media type parameter matching to be case-insensitive
|
|
||||||
|
|
||||||
1.2.6 / 2015-05-07
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.0.11
|
|
||||||
- deps: mime-db@~1.9.1
|
|
||||||
* deps: negotiator@0.5.2
|
|
||||||
- Fix comparing media types with quoted values
|
|
||||||
- Fix splitting media types with quoted commas
|
|
||||||
|
|
||||||
1.2.5 / 2015-03-13
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.0.10
|
|
||||||
- deps: mime-db@~1.8.0
|
|
||||||
|
|
||||||
1.2.4 / 2015-02-14
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Support Node.js 0.6
|
|
||||||
* deps: mime-types@~2.0.9
|
|
||||||
- deps: mime-db@~1.7.0
|
|
||||||
* deps: negotiator@0.5.1
|
|
||||||
- Fix preference sorting to be stable for long acceptable lists
|
|
||||||
|
|
||||||
1.2.3 / 2015-01-31
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.0.8
|
|
||||||
- deps: mime-db@~1.6.0
|
|
||||||
|
|
||||||
1.2.2 / 2014-12-30
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.0.7
|
|
||||||
- deps: mime-db@~1.5.0
|
|
||||||
|
|
||||||
1.2.1 / 2014-12-30
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.0.5
|
|
||||||
- deps: mime-db@~1.3.1
|
|
||||||
|
|
||||||
1.2.0 / 2014-12-19
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: negotiator@0.5.0
|
|
||||||
- Fix list return order when large accepted list
|
|
||||||
- Fix missing identity encoding when q=0 exists
|
|
||||||
- Remove dynamic building of Negotiator class
|
|
||||||
|
|
||||||
1.1.4 / 2014-12-10
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.0.4
|
|
||||||
- deps: mime-db@~1.3.0
|
|
||||||
|
|
||||||
1.1.3 / 2014-11-09
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.0.3
|
|
||||||
- deps: mime-db@~1.2.0
|
|
||||||
|
|
||||||
1.1.2 / 2014-10-14
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: negotiator@0.4.9
|
|
||||||
- Fix error when media type has invalid parameter
|
|
||||||
|
|
||||||
1.1.1 / 2014-09-28
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: mime-types@~2.0.2
|
|
||||||
- deps: mime-db@~1.1.0
|
|
||||||
* deps: negotiator@0.4.8
|
|
||||||
- Fix all negotiations to be case-insensitive
|
|
||||||
- Stable sort preferences of same quality according to client order
|
|
||||||
|
|
||||||
1.1.0 / 2014-09-02
|
|
||||||
==================
|
|
||||||
|
|
||||||
* update `mime-types`
|
|
||||||
|
|
||||||
1.0.7 / 2014-07-04
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix wrong type returned from `type` when match after unknown extension
|
|
||||||
|
|
||||||
1.0.6 / 2014-06-24
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: negotiator@0.4.7
|
|
||||||
|
|
||||||
1.0.5 / 2014-06-20
|
|
||||||
==================
|
|
||||||
|
|
||||||
* fix crash when unknown extension given
|
|
||||||
|
|
||||||
1.0.4 / 2014-06-19
|
|
||||||
==================
|
|
||||||
|
|
||||||
* use `mime-types`
|
|
||||||
|
|
||||||
1.0.3 / 2014-06-11
|
|
||||||
==================
|
|
||||||
|
|
||||||
* deps: negotiator@0.4.6
|
|
||||||
- Order by specificity when quality is the same
|
|
||||||
|
|
||||||
1.0.2 / 2014-05-29
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix interpretation when header not in request
|
|
||||||
* deps: pin negotiator@0.4.5
|
|
||||||
|
|
||||||
1.0.1 / 2014-01-18
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Identity encoding isn't always acceptable
|
|
||||||
* deps: negotiator@~0.4.0
|
|
||||||
|
|
||||||
1.0.0 / 2013-12-27
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Genesis
|
|
|
@ -1,23 +0,0 @@
|
||||||
(The MIT License)
|
|
||||||
|
|
||||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
|
||||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.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.
|
|
|
@ -1,142 +0,0 @@
|
||||||
# accepts
|
|
||||||
|
|
||||||
[![NPM Version][npm-version-image]][npm-url]
|
|
||||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
|
||||||
[![Node.js Version][node-version-image]][node-version-url]
|
|
||||||
[![Build Status][travis-image]][travis-url]
|
|
||||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
||||||
|
|
||||||
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
|
|
||||||
Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
|
|
||||||
|
|
||||||
In addition to negotiator, it allows:
|
|
||||||
|
|
||||||
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
|
|
||||||
as well as `('text/html', 'application/json')`.
|
|
||||||
- Allows type shorthands such as `json`.
|
|
||||||
- Returns `false` when no types match
|
|
||||||
- Treats non-existent headers as `*`
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
|
||||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
|
||||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
$ npm install accepts
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
<!-- eslint-disable no-unused-vars -->
|
|
||||||
|
|
||||||
```js
|
|
||||||
var accepts = require('accepts')
|
|
||||||
```
|
|
||||||
|
|
||||||
### accepts(req)
|
|
||||||
|
|
||||||
Create a new `Accepts` object for the given `req`.
|
|
||||||
|
|
||||||
#### .charset(charsets)
|
|
||||||
|
|
||||||
Return the first accepted charset. If nothing in `charsets` is accepted,
|
|
||||||
then `false` is returned.
|
|
||||||
|
|
||||||
#### .charsets()
|
|
||||||
|
|
||||||
Return the charsets that the request accepts, in the order of the client's
|
|
||||||
preference (most preferred first).
|
|
||||||
|
|
||||||
#### .encoding(encodings)
|
|
||||||
|
|
||||||
Return the first accepted encoding. If nothing in `encodings` is accepted,
|
|
||||||
then `false` is returned.
|
|
||||||
|
|
||||||
#### .encodings()
|
|
||||||
|
|
||||||
Return the encodings that the request accepts, in the order of the client's
|
|
||||||
preference (most preferred first).
|
|
||||||
|
|
||||||
#### .language(languages)
|
|
||||||
|
|
||||||
Return the first accepted language. If nothing in `languages` is accepted,
|
|
||||||
then `false` is returned.
|
|
||||||
|
|
||||||
#### .languages()
|
|
||||||
|
|
||||||
Return the languages that the request accepts, in the order of the client's
|
|
||||||
preference (most preferred first).
|
|
||||||
|
|
||||||
#### .type(types)
|
|
||||||
|
|
||||||
Return the first accepted type (and it is returned as the same text as what
|
|
||||||
appears in the `types` array). If nothing in `types` is accepted, then `false`
|
|
||||||
is returned.
|
|
||||||
|
|
||||||
The `types` array can contain full MIME types or file extensions. Any value
|
|
||||||
that is not a full MIME types is passed to `require('mime-types').lookup`.
|
|
||||||
|
|
||||||
#### .types()
|
|
||||||
|
|
||||||
Return the types that the request accepts, in the order of the client's
|
|
||||||
preference (most preferred first).
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
### Simple type negotiation
|
|
||||||
|
|
||||||
This simple example shows how to use `accepts` to return a different typed
|
|
||||||
respond body based on what the client wants to accept. The server lists it's
|
|
||||||
preferences in order and will get back the best match between the client and
|
|
||||||
server.
|
|
||||||
|
|
||||||
```js
|
|
||||||
var accepts = require('accepts')
|
|
||||||
var http = require('http')
|
|
||||||
|
|
||||||
function app (req, res) {
|
|
||||||
var accept = accepts(req)
|
|
||||||
|
|
||||||
// the order of this list is significant; should be server preferred order
|
|
||||||
switch (accept.type(['json', 'html'])) {
|
|
||||||
case 'json':
|
|
||||||
res.setHeader('Content-Type', 'application/json')
|
|
||||||
res.write('{"hello":"world!"}')
|
|
||||||
break
|
|
||||||
case 'html':
|
|
||||||
res.setHeader('Content-Type', 'text/html')
|
|
||||||
res.write('<b>hello, world!</b>')
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
// the fallback is text/plain, so no need to specify it above
|
|
||||||
res.setHeader('Content-Type', 'text/plain')
|
|
||||||
res.write('hello, world!')
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
res.end()
|
|
||||||
}
|
|
||||||
|
|
||||||
http.createServer(app).listen(3000)
|
|
||||||
```
|
|
||||||
|
|
||||||
You can test this out with the cURL program:
|
|
||||||
```sh
|
|
||||||
curl -I -H'Accept: text/html' http://localhost:3000/
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
[MIT](LICENSE)
|
|
||||||
|
|
||||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
|
|
||||||
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
|
|
||||||
[node-version-image]: https://badgen.net/npm/node/accepts
|
|
||||||
[node-version-url]: https://nodejs.org/en/download
|
|
||||||
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
|
|
||||||
[npm-url]: https://npmjs.org/package/accepts
|
|
||||||
[npm-version-image]: https://badgen.net/npm/v/accepts
|
|
||||||
[travis-image]: https://badgen.net/travis/jshttp/accepts/master
|
|
||||||
[travis-url]: https://travis-ci.org/jshttp/accepts
|
|
|
@ -1,238 +0,0 @@
|
||||||
/*!
|
|
||||||
* accepts
|
|
||||||
* Copyright(c) 2014 Jonathan Ong
|
|
||||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
||||||
* MIT Licensed
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module dependencies.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
var Negotiator = require('negotiator')
|
|
||||||
var mime = require('mime-types')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module exports.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = Accepts
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Accepts object for the given req.
|
|
||||||
*
|
|
||||||
* @param {object} req
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
|
|
||||||
function Accepts (req) {
|
|
||||||
if (!(this instanceof Accepts)) {
|
|
||||||
return new Accepts(req)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.headers = req.headers
|
|
||||||
this.negotiator = new Negotiator(req)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the given `type(s)` is acceptable, returning
|
|
||||||
* the best match when true, otherwise `undefined`, in which
|
|
||||||
* case you should respond with 406 "Not Acceptable".
|
|
||||||
*
|
|
||||||
* The `type` value may be a single mime type string
|
|
||||||
* such as "application/json", the extension name
|
|
||||||
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
|
||||||
* or array is given the _best_ match, if any is returned.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
*
|
|
||||||
* // Accept: text/html
|
|
||||||
* this.types('html');
|
|
||||||
* // => "html"
|
|
||||||
*
|
|
||||||
* // Accept: text/*, application/json
|
|
||||||
* this.types('html');
|
|
||||||
* // => "html"
|
|
||||||
* this.types('text/html');
|
|
||||||
* // => "text/html"
|
|
||||||
* this.types('json', 'text');
|
|
||||||
* // => "json"
|
|
||||||
* this.types('application/json');
|
|
||||||
* // => "application/json"
|
|
||||||
*
|
|
||||||
* // Accept: text/*, application/json
|
|
||||||
* this.types('image/png');
|
|
||||||
* this.types('png');
|
|
||||||
* // => undefined
|
|
||||||
*
|
|
||||||
* // Accept: text/*;q=.5, application/json
|
|
||||||
* this.types(['html', 'json']);
|
|
||||||
* this.types('html', 'json');
|
|
||||||
* // => "json"
|
|
||||||
*
|
|
||||||
* @param {String|Array} types...
|
|
||||||
* @return {String|Array|Boolean}
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
|
|
||||||
Accepts.prototype.type =
|
|
||||||
Accepts.prototype.types = function (types_) {
|
|
||||||
var types = types_
|
|
||||||
|
|
||||||
// support flattened arguments
|
|
||||||
if (types && !Array.isArray(types)) {
|
|
||||||
types = new Array(arguments.length)
|
|
||||||
for (var i = 0; i < types.length; i++) {
|
|
||||||
types[i] = arguments[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// no types, return all requested types
|
|
||||||
if (!types || types.length === 0) {
|
|
||||||
return this.negotiator.mediaTypes()
|
|
||||||
}
|
|
||||||
|
|
||||||
// no accept header, return first given type
|
|
||||||
if (!this.headers.accept) {
|
|
||||||
return types[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
var mimes = types.map(extToMime)
|
|
||||||
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
|
|
||||||
var first = accepts[0]
|
|
||||||
|
|
||||||
return first
|
|
||||||
? types[mimes.indexOf(first)]
|
|
||||||
: false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return accepted encodings or best fit based on `encodings`.
|
|
||||||
*
|
|
||||||
* Given `Accept-Encoding: gzip, deflate`
|
|
||||||
* an array sorted by quality is returned:
|
|
||||||
*
|
|
||||||
* ['gzip', 'deflate']
|
|
||||||
*
|
|
||||||
* @param {String|Array} encodings...
|
|
||||||
* @return {String|Array}
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
|
|
||||||
Accepts.prototype.encoding =
|
|
||||||
Accepts.prototype.encodings = function (encodings_) {
|
|
||||||
var encodings = encodings_
|
|
||||||
|
|
||||||
// support flattened arguments
|
|
||||||
if (encodings && !Array.isArray(encodings)) {
|
|
||||||
encodings = new Array(arguments.length)
|
|
||||||
for (var i = 0; i < encodings.length; i++) {
|
|
||||||
encodings[i] = arguments[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// no encodings, return all requested encodings
|
|
||||||
if (!encodings || encodings.length === 0) {
|
|
||||||
return this.negotiator.encodings()
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.negotiator.encodings(encodings)[0] || false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return accepted charsets or best fit based on `charsets`.
|
|
||||||
*
|
|
||||||
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
|
||||||
* an array sorted by quality is returned:
|
|
||||||
*
|
|
||||||
* ['utf-8', 'utf-7', 'iso-8859-1']
|
|
||||||
*
|
|
||||||
* @param {String|Array} charsets...
|
|
||||||
* @return {String|Array}
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
|
|
||||||
Accepts.prototype.charset =
|
|
||||||
Accepts.prototype.charsets = function (charsets_) {
|
|
||||||
var charsets = charsets_
|
|
||||||
|
|
||||||
// support flattened arguments
|
|
||||||
if (charsets && !Array.isArray(charsets)) {
|
|
||||||
charsets = new Array(arguments.length)
|
|
||||||
for (var i = 0; i < charsets.length; i++) {
|
|
||||||
charsets[i] = arguments[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// no charsets, return all requested charsets
|
|
||||||
if (!charsets || charsets.length === 0) {
|
|
||||||
return this.negotiator.charsets()
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.negotiator.charsets(charsets)[0] || false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return accepted languages or best fit based on `langs`.
|
|
||||||
*
|
|
||||||
* Given `Accept-Language: en;q=0.8, es, pt`
|
|
||||||
* an array sorted by quality is returned:
|
|
||||||
*
|
|
||||||
* ['es', 'pt', 'en']
|
|
||||||
*
|
|
||||||
* @param {String|Array} langs...
|
|
||||||
* @return {Array|String}
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
|
|
||||||
Accepts.prototype.lang =
|
|
||||||
Accepts.prototype.langs =
|
|
||||||
Accepts.prototype.language =
|
|
||||||
Accepts.prototype.languages = function (languages_) {
|
|
||||||
var languages = languages_
|
|
||||||
|
|
||||||
// support flattened arguments
|
|
||||||
if (languages && !Array.isArray(languages)) {
|
|
||||||
languages = new Array(arguments.length)
|
|
||||||
for (var i = 0; i < languages.length; i++) {
|
|
||||||
languages[i] = arguments[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// no languages, return all requested languages
|
|
||||||
if (!languages || languages.length === 0) {
|
|
||||||
return this.negotiator.languages()
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.negotiator.languages(languages)[0] || false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert extnames to mime.
|
|
||||||
*
|
|
||||||
* @param {String} type
|
|
||||||
* @return {String}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function extToMime (type) {
|
|
||||||
return type.indexOf('/') === -1
|
|
||||||
? mime.lookup(type)
|
|
||||||
: type
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if mime is valid.
|
|
||||||
*
|
|
||||||
* @param {String} type
|
|
||||||
* @return {String}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
|
|
||||||
function validMime (type) {
|
|
||||||
return typeof type === 'string'
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "accepts@~1.3.7",
|
|
||||||
"_id": "accepts@1.3.7",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
|
|
||||||
"_location": "/accepts",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "accepts@~1.3.7",
|
|
||||||
"name": "accepts",
|
|
||||||
"escapedName": "accepts",
|
|
||||||
"rawSpec": "~1.3.7",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "~1.3.7"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/express"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
|
|
||||||
"_shasum": "531bc726517a3b2b41f850021c6cc15eaab507cd",
|
|
||||||
"_spec": "accepts@~1.3.7",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\express",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/jshttp/accepts/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"contributors": [
|
|
||||||
{
|
|
||||||
"name": "Douglas Christopher Wilson",
|
|
||||||
"email": "doug@somethingdoug.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Jonathan Ong",
|
|
||||||
"email": "me@jongleberry.com",
|
|
||||||
"url": "http://jongleberry.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"mime-types": "~2.1.24",
|
|
||||||
"negotiator": "0.6.2"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Higher-level content negotiation",
|
|
||||||
"devDependencies": {
|
|
||||||
"deep-equal": "1.0.1",
|
|
||||||
"eslint": "5.16.0",
|
|
||||||
"eslint-config-standard": "12.0.0",
|
|
||||||
"eslint-plugin-import": "2.17.2",
|
|
||||||
"eslint-plugin-markdown": "1.0.0",
|
|
||||||
"eslint-plugin-node": "8.0.1",
|
|
||||||
"eslint-plugin-promise": "4.1.1",
|
|
||||||
"eslint-plugin-standard": "4.0.0",
|
|
||||||
"mocha": "6.1.4",
|
|
||||||
"nyc": "14.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.6"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"LICENSE",
|
|
||||||
"HISTORY.md",
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/jshttp/accepts#readme",
|
|
||||||
"keywords": [
|
|
||||||
"content",
|
|
||||||
"negotiation",
|
|
||||||
"accept",
|
|
||||||
"accepts"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"name": "accepts",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/jshttp/accepts.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"lint": "eslint --plugin markdown --ext js,md .",
|
|
||||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
|
||||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
|
||||||
"test-travis": "nyc --reporter=text npm test"
|
|
||||||
},
|
|
||||||
"version": "1.3.7"
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
# Change Log
|
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
||||||
|
|
||||||
<a name="3.0.0"></a>
|
|
||||||
# [3.0.0](https://github.com/nexdrew/ansi-align/compare/v2.0.0...v3.0.0) (2018-12-17)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **package:** update string-width to version 3.0.0 ([#50](https://github.com/nexdrew/ansi-align/issues/50)) ([67f0d8f](https://github.com/nexdrew/ansi-align/commit/67f0d8f))
|
|
||||||
|
|
||||||
|
|
||||||
### BREAKING CHANGES
|
|
||||||
|
|
||||||
* **package:** Node 4 no longer supported, please update to Node 6+ or use ansi-align@2.0.0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="2.0.0"></a>
|
|
||||||
# [2.0.0](https://github.com/nexdrew/ansi-align/compare/v1.1.0...v2.0.0) (2017-05-01)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* ES2015ify, dropping support for Node <4 ([#30](https://github.com/nexdrew/ansi-align/issues/30)) ([7b43f48](https://github.com/nexdrew/ansi-align/commit/7b43f48))
|
|
||||||
|
|
||||||
|
|
||||||
### BREAKING CHANGES
|
|
||||||
|
|
||||||
* Node 0.10 or 0.12 no longer supported, please update to Node 4+ or use ansi-align@1.1.0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="1.1.0"></a>
|
|
||||||
# [1.1.0](https://github.com/nexdrew/ansi-align/compare/v1.0.0...v1.1.0) (2016-06-06)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* support left-alignment as no-op ([#3](https://github.com/nexdrew/ansi-align/issues/3)) ([e581db6](https://github.com/nexdrew/ansi-align/commit/e581db6))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="1.0.0"></a>
|
|
||||||
# 1.0.0 (2016-04-30)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* initial commit ([1914d90](https://github.com/nexdrew/ansi-align/commit/1914d90))
|
|
|
@ -1,13 +0,0 @@
|
||||||
Copyright (c) 2016, Contributors
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
||||||
with or without fee is hereby granted, provided that the above copyright notice
|
|
||||||
and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
||||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
||||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
||||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
||||||
THIS SOFTWARE.
|
|
|
@ -1,80 +0,0 @@
|
||||||
# ansi-align
|
|
||||||
|
|
||||||
> align-text with ANSI support for CLIs
|
|
||||||
|
|
||||||
[](https://travis-ci.org/nexdrew/ansi-align)
|
|
||||||
[](https://coveralls.io/github/nexdrew/ansi-align?branch=master)
|
|
||||||
[](https://github.com/conventional-changelog/standard-version)
|
|
||||||
[](https://greenkeeper.io/)
|
|
||||||
|
|
||||||
Easily center- or right- align a block of text, carefully ignoring ANSI escape codes.
|
|
||||||
|
|
||||||
E.g. turn this:
|
|
||||||
|
|
||||||
<img width="281" alt="ansi text block no alignment :(" src="https://cloud.githubusercontent.com/assets/1929625/14937509/7c3076dc-0ed7-11e6-8c16-4f6a4ccc8346.png">
|
|
||||||
|
|
||||||
Into this:
|
|
||||||
|
|
||||||
<img width="278" alt="ansi text block center aligned!" src="https://cloud.githubusercontent.com/assets/1929625/14937510/7c3ca0b0-0ed7-11e6-8f0a-541ca39b6e0a.png">
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --save ansi-align
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
var ansiAlign = require('ansi-align')
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### `ansiAlign(text, [opts])`
|
|
||||||
|
|
||||||
Align the given text per the line with the greatest [`string-width`](https://github.com/sindresorhus/string-width), returning a new string (or array).
|
|
||||||
|
|
||||||
#### Arguments
|
|
||||||
|
|
||||||
- `text`: required, string or array
|
|
||||||
|
|
||||||
The text to align. If a string is given, it will be split using either the `opts.split` value or `'\n'` by default. If an array is given, a different array of modified strings will be returned.
|
|
||||||
|
|
||||||
- `opts`: optional, object
|
|
||||||
|
|
||||||
Options to change behavior, see below.
|
|
||||||
|
|
||||||
#### Options
|
|
||||||
|
|
||||||
- `opts.align`: string, default `'center'`
|
|
||||||
|
|
||||||
The alignment mode. Use `'center'` for center-alignment, `'right'` for right-alignment, or `'left'` for left-alignment. Note that the given `text` is assumed to be left-aligned already, so specifying `align: 'left'` just returns the `text` as is (no-op).
|
|
||||||
|
|
||||||
- `opts.split`: string or RegExp, default `'\n'`
|
|
||||||
|
|
||||||
The separator to use when splitting the text. Only used if text is given as a string.
|
|
||||||
|
|
||||||
- `opts.pad`: string, default `' '`
|
|
||||||
|
|
||||||
The value used to left-pad (prepend to) lines of lesser width. Will be repeated as necessary to adjust alignment to the line with the greatest width.
|
|
||||||
|
|
||||||
### `ansiAlign.center(text)`
|
|
||||||
|
|
||||||
Alias for `ansiAlign(text, { align: 'center' })`.
|
|
||||||
|
|
||||||
### `ansiAlign.right(text)`
|
|
||||||
|
|
||||||
Alias for `ansiAlign(text, { align: 'right' })`.
|
|
||||||
|
|
||||||
### `ansiAlign.left(text)`
|
|
||||||
|
|
||||||
Alias for `ansiAlign(text, { align: 'left' })`, which is a no-op.
|
|
||||||
|
|
||||||
## Similar Packages
|
|
||||||
|
|
||||||
- [`center-align`](https://github.com/jonschlinkert/center-align): Very close to this package, except it doesn't support ANSI codes.
|
|
||||||
- [`left-pad`](https://github.com/camwest/left-pad): Great for left-padding but does not support center alignment or ANSI codes.
|
|
||||||
- Pretty much anything by the [chalk](https://github.com/chalk) team
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
ISC © Contributors
|
|
|
@ -1,61 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const stringWidth = require('string-width')
|
|
||||||
|
|
||||||
function ansiAlign (text, opts) {
|
|
||||||
if (!text) return text
|
|
||||||
|
|
||||||
opts = opts || {}
|
|
||||||
const align = opts.align || 'center'
|
|
||||||
|
|
||||||
// short-circuit `align: 'left'` as no-op
|
|
||||||
if (align === 'left') return text
|
|
||||||
|
|
||||||
const split = opts.split || '\n'
|
|
||||||
const pad = opts.pad || ' '
|
|
||||||
const widthDiffFn = align !== 'right' ? halfDiff : fullDiff
|
|
||||||
|
|
||||||
let returnString = false
|
|
||||||
if (!Array.isArray(text)) {
|
|
||||||
returnString = true
|
|
||||||
text = String(text).split(split)
|
|
||||||
}
|
|
||||||
|
|
||||||
let width
|
|
||||||
let maxWidth = 0
|
|
||||||
text = text.map(function (str) {
|
|
||||||
str = String(str)
|
|
||||||
width = stringWidth(str)
|
|
||||||
maxWidth = Math.max(width, maxWidth)
|
|
||||||
return {
|
|
||||||
str,
|
|
||||||
width
|
|
||||||
}
|
|
||||||
}).map(function (obj) {
|
|
||||||
return new Array(widthDiffFn(maxWidth, obj.width) + 1).join(pad) + obj.str
|
|
||||||
})
|
|
||||||
|
|
||||||
return returnString ? text.join(split) : text
|
|
||||||
}
|
|
||||||
|
|
||||||
ansiAlign.left = function left (text) {
|
|
||||||
return ansiAlign(text, { align: 'left' })
|
|
||||||
}
|
|
||||||
|
|
||||||
ansiAlign.center = function center (text) {
|
|
||||||
return ansiAlign(text, { align: 'center' })
|
|
||||||
}
|
|
||||||
|
|
||||||
ansiAlign.right = function right (text) {
|
|
||||||
return ansiAlign(text, { align: 'right' })
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = ansiAlign
|
|
||||||
|
|
||||||
function halfDiff (maxWidth, curWidth) {
|
|
||||||
return Math.floor((maxWidth - curWidth) / 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
function fullDiff (maxWidth, curWidth) {
|
|
||||||
return maxWidth - curWidth
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
'use strict';
|
|
||||||
const stripAnsi = require('strip-ansi');
|
|
||||||
const isFullwidthCodePoint = require('is-fullwidth-code-point');
|
|
||||||
const emojiRegex = require('emoji-regex')();
|
|
||||||
|
|
||||||
module.exports = input => {
|
|
||||||
input = input.replace(emojiRegex, ' ');
|
|
||||||
|
|
||||||
if (typeof input !== 'string' || input.length === 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
input = stripAnsi(input);
|
|
||||||
|
|
||||||
let width = 0;
|
|
||||||
|
|
||||||
for (let i = 0; i < input.length; i++) {
|
|
||||||
const code = input.codePointAt(i);
|
|
||||||
|
|
||||||
// Ignore control characters
|
|
||||||
if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ignore combining characters
|
|
||||||
if (code >= 0x300 && code <= 0x36F) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Surrogates
|
|
||||||
if (code > 0xFFFF) {
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
width += isFullwidthCodePoint(code) ? 2 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return width;
|
|
||||||
};
|
|
|
@ -1,9 +0,0 @@
|
||||||
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.
|
|
|
@ -1,88 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "string-width@^3.0.0",
|
|
||||||
"_id": "string-width@3.1.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
|
|
||||||
"_location": "/ansi-align/string-width",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "string-width@^3.0.0",
|
|
||||||
"name": "string-width",
|
|
||||||
"escapedName": "string-width",
|
|
||||||
"rawSpec": "^3.0.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^3.0.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/ansi-align"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
|
|
||||||
"_shasum": "22767be21b62af1081574306f69ac51b62203961",
|
|
||||||
"_spec": "string-width@^3.0.0",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\ansi-align",
|
|
||||||
"author": {
|
|
||||||
"name": "Sindre Sorhus",
|
|
||||||
"email": "sindresorhus@gmail.com",
|
|
||||||
"url": "sindresorhus.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/sindresorhus/string-width/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"emoji-regex": "^7.0.1",
|
|
||||||
"is-fullwidth-code-point": "^2.0.0",
|
|
||||||
"strip-ansi": "^5.1.0"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Get the visual width of a string - the number of columns required to display it",
|
|
||||||
"devDependencies": {
|
|
||||||
"ava": "^1.0.1",
|
|
||||||
"xo": "^0.23.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/sindresorhus/string-width#readme",
|
|
||||||
"keywords": [
|
|
||||||
"string",
|
|
||||||
"str",
|
|
||||||
"character",
|
|
||||||
"char",
|
|
||||||
"unicode",
|
|
||||||
"width",
|
|
||||||
"visual",
|
|
||||||
"column",
|
|
||||||
"columns",
|
|
||||||
"fullwidth",
|
|
||||||
"full-width",
|
|
||||||
"full",
|
|
||||||
"ansi",
|
|
||||||
"escape",
|
|
||||||
"codes",
|
|
||||||
"cli",
|
|
||||||
"command-line",
|
|
||||||
"terminal",
|
|
||||||
"console",
|
|
||||||
"cjk",
|
|
||||||
"chinese",
|
|
||||||
"japanese",
|
|
||||||
"korean",
|
|
||||||
"fixed-width"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"name": "string-width",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/sindresorhus/string-width.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "xo && ava"
|
|
||||||
},
|
|
||||||
"version": "3.1.0"
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
# string-width [](https://travis-ci.org/sindresorhus/string-width)
|
|
||||||
|
|
||||||
> Get the visual width of a string - the number of columns required to display it
|
|
||||||
|
|
||||||
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
|
||||||
|
|
||||||
Useful to be able to measure the actual width of command-line output.
|
|
||||||
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```
|
|
||||||
$ npm install string-width
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
const stringWidth = require('string-width');
|
|
||||||
|
|
||||||
stringWidth('古');
|
|
||||||
//=> 2
|
|
||||||
|
|
||||||
stringWidth('\u001b[1m古\u001b[22m');
|
|
||||||
//=> 2
|
|
||||||
|
|
||||||
stringWidth('a');
|
|
||||||
//=> 1
|
|
||||||
|
|
||||||
stringWidth('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
|
|
||||||
// => 5
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Related
|
|
||||||
|
|
||||||
- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
|
|
||||||
- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
|
|
||||||
- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
|
|
@ -1,74 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "ansi-align@^3.0.0",
|
|
||||||
"_id": "ansi-align@3.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw==",
|
|
||||||
"_location": "/ansi-align",
|
|
||||||
"_phantomChildren": {
|
|
||||||
"emoji-regex": "7.0.3",
|
|
||||||
"is-fullwidth-code-point": "2.0.0",
|
|
||||||
"strip-ansi": "5.2.0"
|
|
||||||
},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "ansi-align@^3.0.0",
|
|
||||||
"name": "ansi-align",
|
|
||||||
"escapedName": "ansi-align",
|
|
||||||
"rawSpec": "^3.0.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^3.0.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/boxen"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.0.tgz",
|
|
||||||
"_shasum": "b536b371cf687caaef236c18d3e21fe3797467cb",
|
|
||||||
"_spec": "ansi-align@^3.0.0",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\boxen",
|
|
||||||
"author": {
|
|
||||||
"name": "nexdrew"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/nexdrew/ansi-align/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"string-width": "^3.0.0"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "align-text with ANSI support for CLIs",
|
|
||||||
"devDependencies": {
|
|
||||||
"ava": "^1.0.1",
|
|
||||||
"chalk": "^2.4.1",
|
|
||||||
"coveralls": "^3.0.2",
|
|
||||||
"nyc": "^13.1.0",
|
|
||||||
"standard": "^12.0.1",
|
|
||||||
"standard-version": "^4.4.0"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/nexdrew/ansi-align#readme",
|
|
||||||
"keywords": [
|
|
||||||
"ansi",
|
|
||||||
"align",
|
|
||||||
"cli",
|
|
||||||
"center",
|
|
||||||
"pad"
|
|
||||||
],
|
|
||||||
"license": "ISC",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "ansi-align",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/nexdrew/ansi-align.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
|
||||||
"pretest": "standard",
|
|
||||||
"release": "standard-version",
|
|
||||||
"test": "nyc ava"
|
|
||||||
},
|
|
||||||
"version": "3.0.0"
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = options => {
|
|
||||||
options = Object.assign({
|
|
||||||
onlyFirst: false
|
|
||||||
}, options);
|
|
||||||
|
|
||||||
const pattern = [
|
|
||||||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
||||||
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
|
||||||
].join('|');
|
|
||||||
|
|
||||||
return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
|
|
||||||
};
|
|
|
@ -1,9 +0,0 @@
|
||||||
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.
|
|
|
@ -1,85 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "ansi-regex@^4.1.0",
|
|
||||||
"_id": "ansi-regex@4.1.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
|
|
||||||
"_location": "/ansi-regex",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "ansi-regex@^4.1.0",
|
|
||||||
"name": "ansi-regex",
|
|
||||||
"escapedName": "ansi-regex",
|
|
||||||
"rawSpec": "^4.1.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^4.1.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/strip-ansi"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
|
|
||||||
"_shasum": "8b9f8f08cf1acb843756a839ca8c7e3168c51997",
|
|
||||||
"_spec": "ansi-regex@^4.1.0",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\strip-ansi",
|
|
||||||
"author": {
|
|
||||||
"name": "Sindre Sorhus",
|
|
||||||
"email": "sindresorhus@gmail.com",
|
|
||||||
"url": "sindresorhus.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/chalk/ansi-regex/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Regular expression for matching ANSI escape codes",
|
|
||||||
"devDependencies": {
|
|
||||||
"ava": "^0.25.0",
|
|
||||||
"xo": "^0.23.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/chalk/ansi-regex#readme",
|
|
||||||
"keywords": [
|
|
||||||
"ansi",
|
|
||||||
"styles",
|
|
||||||
"color",
|
|
||||||
"colour",
|
|
||||||
"colors",
|
|
||||||
"terminal",
|
|
||||||
"console",
|
|
||||||
"cli",
|
|
||||||
"string",
|
|
||||||
"tty",
|
|
||||||
"escape",
|
|
||||||
"formatting",
|
|
||||||
"rgb",
|
|
||||||
"256",
|
|
||||||
"shell",
|
|
||||||
"xterm",
|
|
||||||
"command-line",
|
|
||||||
"text",
|
|
||||||
"regex",
|
|
||||||
"regexp",
|
|
||||||
"re",
|
|
||||||
"match",
|
|
||||||
"test",
|
|
||||||
"find",
|
|
||||||
"pattern"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"name": "ansi-regex",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/chalk/ansi-regex.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "xo && ava",
|
|
||||||
"view-supported": "node fixtures/view-codes.js"
|
|
||||||
},
|
|
||||||
"version": "4.1.0"
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
# ansi-regex [](https://travis-ci.org/chalk/ansi-regex)
|
|
||||||
|
|
||||||
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
<b>
|
|
||||||
<a href="https://tidelift.com/subscription/pkg/npm-ansi-regex?utm_source=npm-ansi-regex&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
|
||||||
</b>
|
|
||||||
<br>
|
|
||||||
<sub>
|
|
||||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
||||||
</sub>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```
|
|
||||||
$ npm install ansi-regex
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
const ansiRegex = require('ansi-regex');
|
|
||||||
|
|
||||||
ansiRegex().test('\u001B[4mcake\u001B[0m');
|
|
||||||
//=> true
|
|
||||||
|
|
||||||
ansiRegex().test('cake');
|
|
||||||
//=> false
|
|
||||||
|
|
||||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
|
|
||||||
//=> ['\u001B[4m', '\u001B[0m']
|
|
||||||
|
|
||||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
|
|
||||||
//=> ['\u001B[4m']
|
|
||||||
|
|
||||||
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
|
|
||||||
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### ansiRegex([options])
|
|
||||||
|
|
||||||
Returns a regex for matching ANSI escape codes.
|
|
||||||
|
|
||||||
#### options
|
|
||||||
|
|
||||||
##### onlyFirst
|
|
||||||
|
|
||||||
Type: `boolean`<br>
|
|
||||||
Default: `false` *(Matches any ANSI escape codes in a string)*
|
|
||||||
|
|
||||||
Match only the first ANSI escape.
|
|
||||||
|
|
||||||
|
|
||||||
## FAQ
|
|
||||||
|
|
||||||
### Why do you test for codes not in the ECMA 48 standard?
|
|
||||||
|
|
||||||
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
|
|
||||||
|
|
||||||
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
|
|
||||||
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
|
||||||
|
|
||||||
|
|
||||||
## Maintainers
|
|
||||||
|
|
||||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
||||||
- [Josh Junon](https://github.com/qix-)
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT
|
|
|
@ -1,345 +0,0 @@
|
||||||
declare type CSSColor =
|
|
||||||
| 'aliceblue'
|
|
||||||
| 'antiquewhite'
|
|
||||||
| 'aqua'
|
|
||||||
| 'aquamarine'
|
|
||||||
| 'azure'
|
|
||||||
| 'beige'
|
|
||||||
| 'bisque'
|
|
||||||
| 'black'
|
|
||||||
| 'blanchedalmond'
|
|
||||||
| 'blue'
|
|
||||||
| 'blueviolet'
|
|
||||||
| 'brown'
|
|
||||||
| 'burlywood'
|
|
||||||
| 'cadetblue'
|
|
||||||
| 'chartreuse'
|
|
||||||
| 'chocolate'
|
|
||||||
| 'coral'
|
|
||||||
| 'cornflowerblue'
|
|
||||||
| 'cornsilk'
|
|
||||||
| 'crimson'
|
|
||||||
| 'cyan'
|
|
||||||
| 'darkblue'
|
|
||||||
| 'darkcyan'
|
|
||||||
| 'darkgoldenrod'
|
|
||||||
| 'darkgray'
|
|
||||||
| 'darkgreen'
|
|
||||||
| 'darkgrey'
|
|
||||||
| 'darkkhaki'
|
|
||||||
| 'darkmagenta'
|
|
||||||
| 'darkolivegreen'
|
|
||||||
| 'darkorange'
|
|
||||||
| 'darkorchid'
|
|
||||||
| 'darkred'
|
|
||||||
| 'darksalmon'
|
|
||||||
| 'darkseagreen'
|
|
||||||
| 'darkslateblue'
|
|
||||||
| 'darkslategray'
|
|
||||||
| 'darkslategrey'
|
|
||||||
| 'darkturquoise'
|
|
||||||
| 'darkviolet'
|
|
||||||
| 'deeppink'
|
|
||||||
| 'deepskyblue'
|
|
||||||
| 'dimgray'
|
|
||||||
| 'dimgrey'
|
|
||||||
| 'dodgerblue'
|
|
||||||
| 'firebrick'
|
|
||||||
| 'floralwhite'
|
|
||||||
| 'forestgreen'
|
|
||||||
| 'fuchsia'
|
|
||||||
| 'gainsboro'
|
|
||||||
| 'ghostwhite'
|
|
||||||
| 'gold'
|
|
||||||
| 'goldenrod'
|
|
||||||
| 'gray'
|
|
||||||
| 'green'
|
|
||||||
| 'greenyellow'
|
|
||||||
| 'grey'
|
|
||||||
| 'honeydew'
|
|
||||||
| 'hotpink'
|
|
||||||
| 'indianred'
|
|
||||||
| 'indigo'
|
|
||||||
| 'ivory'
|
|
||||||
| 'khaki'
|
|
||||||
| 'lavender'
|
|
||||||
| 'lavenderblush'
|
|
||||||
| 'lawngreen'
|
|
||||||
| 'lemonchiffon'
|
|
||||||
| 'lightblue'
|
|
||||||
| 'lightcoral'
|
|
||||||
| 'lightcyan'
|
|
||||||
| 'lightgoldenrodyellow'
|
|
||||||
| 'lightgray'
|
|
||||||
| 'lightgreen'
|
|
||||||
| 'lightgrey'
|
|
||||||
| 'lightpink'
|
|
||||||
| 'lightsalmon'
|
|
||||||
| 'lightseagreen'
|
|
||||||
| 'lightskyblue'
|
|
||||||
| 'lightslategray'
|
|
||||||
| 'lightslategrey'
|
|
||||||
| 'lightsteelblue'
|
|
||||||
| 'lightyellow'
|
|
||||||
| 'lime'
|
|
||||||
| 'limegreen'
|
|
||||||
| 'linen'
|
|
||||||
| 'magenta'
|
|
||||||
| 'maroon'
|
|
||||||
| 'mediumaquamarine'
|
|
||||||
| 'mediumblue'
|
|
||||||
| 'mediumorchid'
|
|
||||||
| 'mediumpurple'
|
|
||||||
| 'mediumseagreen'
|
|
||||||
| 'mediumslateblue'
|
|
||||||
| 'mediumspringgreen'
|
|
||||||
| 'mediumturquoise'
|
|
||||||
| 'mediumvioletred'
|
|
||||||
| 'midnightblue'
|
|
||||||
| 'mintcream'
|
|
||||||
| 'mistyrose'
|
|
||||||
| 'moccasin'
|
|
||||||
| 'navajowhite'
|
|
||||||
| 'navy'
|
|
||||||
| 'oldlace'
|
|
||||||
| 'olive'
|
|
||||||
| 'olivedrab'
|
|
||||||
| 'orange'
|
|
||||||
| 'orangered'
|
|
||||||
| 'orchid'
|
|
||||||
| 'palegoldenrod'
|
|
||||||
| 'palegreen'
|
|
||||||
| 'paleturquoise'
|
|
||||||
| 'palevioletred'
|
|
||||||
| 'papayawhip'
|
|
||||||
| 'peachpuff'
|
|
||||||
| 'peru'
|
|
||||||
| 'pink'
|
|
||||||
| 'plum'
|
|
||||||
| 'powderblue'
|
|
||||||
| 'purple'
|
|
||||||
| 'rebeccapurple'
|
|
||||||
| 'red'
|
|
||||||
| 'rosybrown'
|
|
||||||
| 'royalblue'
|
|
||||||
| 'saddlebrown'
|
|
||||||
| 'salmon'
|
|
||||||
| 'sandybrown'
|
|
||||||
| 'seagreen'
|
|
||||||
| 'seashell'
|
|
||||||
| 'sienna'
|
|
||||||
| 'silver'
|
|
||||||
| 'skyblue'
|
|
||||||
| 'slateblue'
|
|
||||||
| 'slategray'
|
|
||||||
| 'slategrey'
|
|
||||||
| 'snow'
|
|
||||||
| 'springgreen'
|
|
||||||
| 'steelblue'
|
|
||||||
| 'tan'
|
|
||||||
| 'teal'
|
|
||||||
| 'thistle'
|
|
||||||
| 'tomato'
|
|
||||||
| 'turquoise'
|
|
||||||
| 'violet'
|
|
||||||
| 'wheat'
|
|
||||||
| 'white'
|
|
||||||
| 'whitesmoke'
|
|
||||||
| 'yellow'
|
|
||||||
| 'yellowgreen';
|
|
||||||
|
|
||||||
declare namespace ansiStyles {
|
|
||||||
interface ColorConvert {
|
|
||||||
/**
|
|
||||||
The RGB color space.
|
|
||||||
|
|
||||||
@param red - (`0`-`255`)
|
|
||||||
@param green - (`0`-`255`)
|
|
||||||
@param blue - (`0`-`255`)
|
|
||||||
*/
|
|
||||||
rgb(red: number, green: number, blue: number): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The RGB HEX color space.
|
|
||||||
|
|
||||||
@param hex - A hexadecimal string containing RGB data.
|
|
||||||
*/
|
|
||||||
hex(hex: string): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param keyword - A CSS color name.
|
|
||||||
*/
|
|
||||||
keyword(keyword: CSSColor): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The HSL color space.
|
|
||||||
|
|
||||||
@param hue - (`0`-`360`)
|
|
||||||
@param saturation - (`0`-`100`)
|
|
||||||
@param lightness - (`0`-`100`)
|
|
||||||
*/
|
|
||||||
hsl(hue: number, saturation: number, lightness: number): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The HSV color space.
|
|
||||||
|
|
||||||
@param hue - (`0`-`360`)
|
|
||||||
@param saturation - (`0`-`100`)
|
|
||||||
@param value - (`0`-`100`)
|
|
||||||
*/
|
|
||||||
hsv(hue: number, saturation: number, value: number): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The HSV color space.
|
|
||||||
|
|
||||||
@param hue - (`0`-`360`)
|
|
||||||
@param whiteness - (`0`-`100`)
|
|
||||||
@param blackness - (`0`-`100`)
|
|
||||||
*/
|
|
||||||
hwb(hue: number, whiteness: number, blackness: number): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
|
|
||||||
*/
|
|
||||||
ansi(ansi: number): string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
|
||||||
*/
|
|
||||||
ansi256(ansi: number): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CSPair {
|
|
||||||
/**
|
|
||||||
The ANSI terminal control sequence for starting this style.
|
|
||||||
*/
|
|
||||||
readonly open: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The ANSI terminal control sequence for ending this style.
|
|
||||||
*/
|
|
||||||
readonly close: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ColorBase {
|
|
||||||
readonly ansi: ColorConvert;
|
|
||||||
readonly ansi256: ColorConvert;
|
|
||||||
readonly ansi16m: ColorConvert;
|
|
||||||
|
|
||||||
/**
|
|
||||||
The ANSI terminal control sequence for ending this color.
|
|
||||||
*/
|
|
||||||
readonly close: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Modifier {
|
|
||||||
/**
|
|
||||||
Resets the current color chain.
|
|
||||||
*/
|
|
||||||
readonly reset: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Make text bold.
|
|
||||||
*/
|
|
||||||
readonly bold: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Emitting only a small amount of light.
|
|
||||||
*/
|
|
||||||
readonly dim: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Make text italic. (Not widely supported)
|
|
||||||
*/
|
|
||||||
readonly italic: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Make text underline. (Not widely supported)
|
|
||||||
*/
|
|
||||||
readonly underline: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Inverse background and foreground colors.
|
|
||||||
*/
|
|
||||||
readonly inverse: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Prints the text, but makes it invisible.
|
|
||||||
*/
|
|
||||||
readonly hidden: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Puts a horizontal line through the center of the text. (Not widely supported)
|
|
||||||
*/
|
|
||||||
readonly strikethrough: CSPair;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ForegroundColor {
|
|
||||||
readonly black: CSPair;
|
|
||||||
readonly red: CSPair;
|
|
||||||
readonly green: CSPair;
|
|
||||||
readonly yellow: CSPair;
|
|
||||||
readonly blue: CSPair;
|
|
||||||
readonly cyan: CSPair;
|
|
||||||
readonly magenta: CSPair;
|
|
||||||
readonly white: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Alias for `blackBright`.
|
|
||||||
*/
|
|
||||||
readonly gray: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Alias for `blackBright`.
|
|
||||||
*/
|
|
||||||
readonly grey: CSPair;
|
|
||||||
|
|
||||||
readonly blackBright: CSPair;
|
|
||||||
readonly redBright: CSPair;
|
|
||||||
readonly greenBright: CSPair;
|
|
||||||
readonly yellowBright: CSPair;
|
|
||||||
readonly blueBright: CSPair;
|
|
||||||
readonly cyanBright: CSPair;
|
|
||||||
readonly magentaBright: CSPair;
|
|
||||||
readonly whiteBright: CSPair;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BackgroundColor {
|
|
||||||
readonly bgBlack: CSPair;
|
|
||||||
readonly bgRed: CSPair;
|
|
||||||
readonly bgGreen: CSPair;
|
|
||||||
readonly bgYellow: CSPair;
|
|
||||||
readonly bgBlue: CSPair;
|
|
||||||
readonly bgCyan: CSPair;
|
|
||||||
readonly bgMagenta: CSPair;
|
|
||||||
readonly bgWhite: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Alias for `bgBlackBright`.
|
|
||||||
*/
|
|
||||||
readonly bgGray: CSPair;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Alias for `bgBlackBright`.
|
|
||||||
*/
|
|
||||||
readonly bgGrey: CSPair;
|
|
||||||
|
|
||||||
readonly bgBlackBright: CSPair;
|
|
||||||
readonly bgRedBright: CSPair;
|
|
||||||
readonly bgGreenBright: CSPair;
|
|
||||||
readonly bgYellowBright: CSPair;
|
|
||||||
readonly bgBlueBright: CSPair;
|
|
||||||
readonly bgCyanBright: CSPair;
|
|
||||||
readonly bgMagentaBright: CSPair;
|
|
||||||
readonly bgWhiteBright: CSPair;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare const ansiStyles: {
|
|
||||||
readonly modifier: ansiStyles.Modifier;
|
|
||||||
readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
|
|
||||||
readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
|
|
||||||
readonly codes: ReadonlyMap<number, number>;
|
|
||||||
} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier;
|
|
||||||
|
|
||||||
export = ansiStyles;
|
|
|
@ -1,163 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
||||||
const code = fn(...args);
|
|
||||||
return `\u001B[${code + offset}m`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
||||||
const code = fn(...args);
|
|
||||||
return `\u001B[${38 + offset};5;${code}m`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
||||||
const rgb = fn(...args);
|
|
||||||
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ansi2ansi = n => n;
|
|
||||||
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
||||||
|
|
||||||
const setLazyProperty = (object, property, get) => {
|
|
||||||
Object.defineProperty(object, property, {
|
|
||||||
get: () => {
|
|
||||||
const value = get();
|
|
||||||
|
|
||||||
Object.defineProperty(object, property, {
|
|
||||||
value,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @type {typeof import('color-convert')} */
|
|
||||||
let colorConvert;
|
|
||||||
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
||||||
if (colorConvert === undefined) {
|
|
||||||
colorConvert = require('color-convert');
|
|
||||||
}
|
|
||||||
|
|
||||||
const offset = isBackground ? 10 : 0;
|
|
||||||
const styles = {};
|
|
||||||
|
|
||||||
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
|
||||||
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
|
||||||
if (sourceSpace === targetSpace) {
|
|
||||||
styles[name] = wrap(identity, offset);
|
|
||||||
} else if (typeof suite === 'object') {
|
|
||||||
styles[name] = wrap(suite[targetSpace], offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return styles;
|
|
||||||
};
|
|
||||||
|
|
||||||
function assembleStyles() {
|
|
||||||
const codes = new Map();
|
|
||||||
const styles = {
|
|
||||||
modifier: {
|
|
||||||
reset: [0, 0],
|
|
||||||
// 21 isn't widely supported and 22 does the same thing
|
|
||||||
bold: [1, 22],
|
|
||||||
dim: [2, 22],
|
|
||||||
italic: [3, 23],
|
|
||||||
underline: [4, 24],
|
|
||||||
inverse: [7, 27],
|
|
||||||
hidden: [8, 28],
|
|
||||||
strikethrough: [9, 29]
|
|
||||||
},
|
|
||||||
color: {
|
|
||||||
black: [30, 39],
|
|
||||||
red: [31, 39],
|
|
||||||
green: [32, 39],
|
|
||||||
yellow: [33, 39],
|
|
||||||
blue: [34, 39],
|
|
||||||
magenta: [35, 39],
|
|
||||||
cyan: [36, 39],
|
|
||||||
white: [37, 39],
|
|
||||||
|
|
||||||
// Bright color
|
|
||||||
blackBright: [90, 39],
|
|
||||||
redBright: [91, 39],
|
|
||||||
greenBright: [92, 39],
|
|
||||||
yellowBright: [93, 39],
|
|
||||||
blueBright: [94, 39],
|
|
||||||
magentaBright: [95, 39],
|
|
||||||
cyanBright: [96, 39],
|
|
||||||
whiteBright: [97, 39]
|
|
||||||
},
|
|
||||||
bgColor: {
|
|
||||||
bgBlack: [40, 49],
|
|
||||||
bgRed: [41, 49],
|
|
||||||
bgGreen: [42, 49],
|
|
||||||
bgYellow: [43, 49],
|
|
||||||
bgBlue: [44, 49],
|
|
||||||
bgMagenta: [45, 49],
|
|
||||||
bgCyan: [46, 49],
|
|
||||||
bgWhite: [47, 49],
|
|
||||||
|
|
||||||
// Bright color
|
|
||||||
bgBlackBright: [100, 49],
|
|
||||||
bgRedBright: [101, 49],
|
|
||||||
bgGreenBright: [102, 49],
|
|
||||||
bgYellowBright: [103, 49],
|
|
||||||
bgBlueBright: [104, 49],
|
|
||||||
bgMagentaBright: [105, 49],
|
|
||||||
bgCyanBright: [106, 49],
|
|
||||||
bgWhiteBright: [107, 49]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Alias bright black as gray (and grey)
|
|
||||||
styles.color.gray = styles.color.blackBright;
|
|
||||||
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
|
||||||
styles.color.grey = styles.color.blackBright;
|
|
||||||
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
|
||||||
|
|
||||||
for (const [groupName, group] of Object.entries(styles)) {
|
|
||||||
for (const [styleName, style] of Object.entries(group)) {
|
|
||||||
styles[styleName] = {
|
|
||||||
open: `\u001B[${style[0]}m`,
|
|
||||||
close: `\u001B[${style[1]}m`
|
|
||||||
};
|
|
||||||
|
|
||||||
group[styleName] = styles[styleName];
|
|
||||||
|
|
||||||
codes.set(style[0], style[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.defineProperty(styles, groupName, {
|
|
||||||
value: group,
|
|
||||||
enumerable: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.defineProperty(styles, 'codes', {
|
|
||||||
value: codes,
|
|
||||||
enumerable: false
|
|
||||||
});
|
|
||||||
|
|
||||||
styles.color.close = '\u001B[39m';
|
|
||||||
styles.bgColor.close = '\u001B[49m';
|
|
||||||
|
|
||||||
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
|
||||||
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
|
||||||
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
|
||||||
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
|
||||||
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
|
||||||
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
|
||||||
|
|
||||||
return styles;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the export immutable
|
|
||||||
Object.defineProperty(module, 'exports', {
|
|
||||||
enumerable: true,
|
|
||||||
get: assembleStyles
|
|
||||||
});
|
|
|
@ -1,9 +0,0 @@
|
||||||
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.
|
|
|
@ -1,88 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "ansi-styles@^4.1.0",
|
|
||||||
"_id": "ansi-styles@4.3.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
|
||||||
"_location": "/ansi-styles",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "ansi-styles@^4.1.0",
|
|
||||||
"name": "ansi-styles",
|
|
||||||
"escapedName": "ansi-styles",
|
|
||||||
"rawSpec": "^4.1.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^4.1.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/chalk"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
|
||||||
"_shasum": "edd803628ae71c04c85ae7a0906edad34b648937",
|
|
||||||
"_spec": "ansi-styles@^4.1.0",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\chalk",
|
|
||||||
"author": {
|
|
||||||
"name": "Sindre Sorhus",
|
|
||||||
"email": "sindresorhus@gmail.com",
|
|
||||||
"url": "sindresorhus.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/chalk/ansi-styles/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"color-convert": "^2.0.1"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "ANSI escape codes for styling strings in the terminal",
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/color-convert": "^1.9.0",
|
|
||||||
"ava": "^2.3.0",
|
|
||||||
"svg-term-cli": "^2.1.1",
|
|
||||||
"tsd": "^0.11.0",
|
|
||||||
"xo": "^0.25.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js",
|
|
||||||
"index.d.ts"
|
|
||||||
],
|
|
||||||
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
|
|
||||||
"homepage": "https://github.com/chalk/ansi-styles#readme",
|
|
||||||
"keywords": [
|
|
||||||
"ansi",
|
|
||||||
"styles",
|
|
||||||
"color",
|
|
||||||
"colour",
|
|
||||||
"colors",
|
|
||||||
"terminal",
|
|
||||||
"console",
|
|
||||||
"cli",
|
|
||||||
"string",
|
|
||||||
"tty",
|
|
||||||
"escape",
|
|
||||||
"formatting",
|
|
||||||
"rgb",
|
|
||||||
"256",
|
|
||||||
"shell",
|
|
||||||
"xterm",
|
|
||||||
"log",
|
|
||||||
"logging",
|
|
||||||
"command-line",
|
|
||||||
"text"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"name": "ansi-styles",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/chalk/ansi-styles.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor",
|
|
||||||
"test": "xo && ava && tsd"
|
|
||||||
},
|
|
||||||
"version": "4.3.0"
|
|
||||||
}
|
|
|
@ -1,152 +0,0 @@
|
||||||
# ansi-styles [](https://travis-ci.org/chalk/ansi-styles)
|
|
||||||
|
|
||||||
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
|
||||||
|
|
||||||
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
|
||||||
|
|
||||||
<img src="screenshot.svg" width="900">
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```
|
|
||||||
$ npm install ansi-styles
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
const style = require('ansi-styles');
|
|
||||||
|
|
||||||
console.log(`${style.green.open}Hello world!${style.green.close}`);
|
|
||||||
|
|
||||||
|
|
||||||
// Color conversion between 16/256/truecolor
|
|
||||||
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
|
|
||||||
// may be degraded to fit that color palette. This means terminals
|
|
||||||
// that do not support 16 million colors will best-match the
|
|
||||||
// original color.
|
|
||||||
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
|
|
||||||
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
|
|
||||||
console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close);
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
Each style has an `open` and `close` property.
|
|
||||||
|
|
||||||
## Styles
|
|
||||||
|
|
||||||
### Modifiers
|
|
||||||
|
|
||||||
- `reset`
|
|
||||||
- `bold`
|
|
||||||
- `dim`
|
|
||||||
- `italic` *(Not widely supported)*
|
|
||||||
- `underline`
|
|
||||||
- `inverse`
|
|
||||||
- `hidden`
|
|
||||||
- `strikethrough` *(Not widely supported)*
|
|
||||||
|
|
||||||
### Colors
|
|
||||||
|
|
||||||
- `black`
|
|
||||||
- `red`
|
|
||||||
- `green`
|
|
||||||
- `yellow`
|
|
||||||
- `blue`
|
|
||||||
- `magenta`
|
|
||||||
- `cyan`
|
|
||||||
- `white`
|
|
||||||
- `blackBright` (alias: `gray`, `grey`)
|
|
||||||
- `redBright`
|
|
||||||
- `greenBright`
|
|
||||||
- `yellowBright`
|
|
||||||
- `blueBright`
|
|
||||||
- `magentaBright`
|
|
||||||
- `cyanBright`
|
|
||||||
- `whiteBright`
|
|
||||||
|
|
||||||
### Background colors
|
|
||||||
|
|
||||||
- `bgBlack`
|
|
||||||
- `bgRed`
|
|
||||||
- `bgGreen`
|
|
||||||
- `bgYellow`
|
|
||||||
- `bgBlue`
|
|
||||||
- `bgMagenta`
|
|
||||||
- `bgCyan`
|
|
||||||
- `bgWhite`
|
|
||||||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
|
||||||
- `bgRedBright`
|
|
||||||
- `bgGreenBright`
|
|
||||||
- `bgYellowBright`
|
|
||||||
- `bgBlueBright`
|
|
||||||
- `bgMagentaBright`
|
|
||||||
- `bgCyanBright`
|
|
||||||
- `bgWhiteBright`
|
|
||||||
|
|
||||||
## Advanced usage
|
|
||||||
|
|
||||||
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
|
||||||
|
|
||||||
- `style.modifier`
|
|
||||||
- `style.color`
|
|
||||||
- `style.bgColor`
|
|
||||||
|
|
||||||
###### Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
console.log(style.color.green.open);
|
|
||||||
```
|
|
||||||
|
|
||||||
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
|
||||||
|
|
||||||
###### Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
console.log(style.codes.get(36));
|
|
||||||
//=> 39
|
|
||||||
```
|
|
||||||
|
|
||||||
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
|
|
||||||
|
|
||||||
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
|
|
||||||
|
|
||||||
The following color spaces from `color-convert` are supported:
|
|
||||||
|
|
||||||
- `rgb`
|
|
||||||
- `hex`
|
|
||||||
- `keyword`
|
|
||||||
- `hsl`
|
|
||||||
- `hsv`
|
|
||||||
- `hwb`
|
|
||||||
- `ansi`
|
|
||||||
- `ansi256`
|
|
||||||
|
|
||||||
To use these, call the associated conversion function with the intended output, for example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
|
|
||||||
style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
|
|
||||||
|
|
||||||
style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
|
||||||
style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
|
||||||
|
|
||||||
style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
|
|
||||||
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
|
|
||||||
```
|
|
||||||
|
|
||||||
## Related
|
|
||||||
|
|
||||||
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
|
||||||
|
|
||||||
## Maintainers
|
|
||||||
|
|
||||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
||||||
- [Josh Junon](https://github.com/qix-)
|
|
||||||
|
|
||||||
## For enterprise
|
|
||||||
|
|
||||||
Available as part of the Tidelift Subscription.
|
|
||||||
|
|
||||||
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
|
@ -1,15 +0,0 @@
|
||||||
The ISC License
|
|
||||||
|
|
||||||
Copyright (c) 2019 Elan Shanker, Paul Miller (https://paulmillr.com)
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
||||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
@ -1,87 +0,0 @@
|
||||||
anymatch [](https://travis-ci.org/micromatch/anymatch) [](https://coveralls.io/r/micromatch/anymatch?branch=master)
|
|
||||||
======
|
|
||||||
Javascript module to match a string against a regular expression, glob, string,
|
|
||||||
or function that takes the string as an argument and returns a truthy or falsy
|
|
||||||
value. The matcher can also be an array of any or all of these. Useful for
|
|
||||||
allowing a very flexible user-defined config to define things like file paths.
|
|
||||||
|
|
||||||
__Note: This module has Bash-parity, please be aware that Windows-style backslashes are not supported as separators. See https://github.com/micromatch/micromatch#backslashes for more information.__
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
```sh
|
|
||||||
npm install anymatch
|
|
||||||
```
|
|
||||||
|
|
||||||
#### anymatch(matchers, testString, [returnIndex], [options])
|
|
||||||
* __matchers__: (_Array|String|RegExp|Function_)
|
|
||||||
String to be directly matched, string with glob patterns, regular expression
|
|
||||||
test, function that takes the testString as an argument and returns a truthy
|
|
||||||
value if it should be matched, or an array of any number and mix of these types.
|
|
||||||
* __testString__: (_String|Array_) The string to test against the matchers. If
|
|
||||||
passed as an array, the first element of the array will be used as the
|
|
||||||
`testString` for non-function matchers, while the entire array will be applied
|
|
||||||
as the arguments for function matchers.
|
|
||||||
* __options__: (_Object_ [optional]_) Any of the [picomatch](https://github.com/micromatch/picomatch#options) options.
|
|
||||||
* __returnIndex__: (_Boolean [optional]_) If true, return the array index of
|
|
||||||
the first matcher that that testString matched, or -1 if no match, instead of a
|
|
||||||
boolean result.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const anymatch = require('anymatch');
|
|
||||||
|
|
||||||
const matchers = [ 'path/to/file.js', 'path/anyjs/**/*.js', /foo.js$/, string => string.includes('bar') && string.length > 10 ] ;
|
|
||||||
|
|
||||||
anymatch(matchers, 'path/to/file.js'); // true
|
|
||||||
anymatch(matchers, 'path/anyjs/baz.js'); // true
|
|
||||||
anymatch(matchers, 'path/to/foo.js'); // true
|
|
||||||
anymatch(matchers, 'path/to/bar.js'); // true
|
|
||||||
anymatch(matchers, 'bar.js'); // false
|
|
||||||
|
|
||||||
// returnIndex = true
|
|
||||||
anymatch(matchers, 'foo.js', {returnIndex: true}); // 2
|
|
||||||
anymatch(matchers, 'path/anyjs/foo.js', {returnIndex: true}); // 1
|
|
||||||
|
|
||||||
// any picomatc
|
|
||||||
|
|
||||||
// using globs to match directories and their children
|
|
||||||
anymatch('node_modules', 'node_modules'); // true
|
|
||||||
anymatch('node_modules', 'node_modules/somelib/index.js'); // false
|
|
||||||
anymatch('node_modules/**', 'node_modules/somelib/index.js'); // true
|
|
||||||
anymatch('node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // false
|
|
||||||
anymatch('**/node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // true
|
|
||||||
|
|
||||||
const matcher = anymatch(matchers);
|
|
||||||
['foo.js', 'bar.js'].filter(matcher); // [ 'foo.js' ]
|
|
||||||
anymatch master* ❯
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
#### anymatch(matchers)
|
|
||||||
You can also pass in only your matcher(s) to get a curried function that has
|
|
||||||
already been bound to the provided matching criteria. This can be used as an
|
|
||||||
`Array#filter` callback.
|
|
||||||
|
|
||||||
```js
|
|
||||||
var matcher = anymatch(matchers);
|
|
||||||
|
|
||||||
matcher('path/to/file.js'); // true
|
|
||||||
matcher('path/anyjs/baz.js', true); // 1
|
|
||||||
|
|
||||||
['foo.js', 'bar.js'].filter(matcher); // ['foo.js']
|
|
||||||
```
|
|
||||||
|
|
||||||
Changelog
|
|
||||||
----------
|
|
||||||
[See release notes page on GitHub](https://github.com/micromatch/anymatch/releases)
|
|
||||||
|
|
||||||
- **v3.0:** Removed `startIndex` and `endIndex` arguments. Node 8.x-only.
|
|
||||||
- **v2.0:** [micromatch](https://github.com/jonschlinkert/micromatch) moves away from minimatch-parity and inline with Bash. This includes handling backslashes differently (see https://github.com/micromatch/micromatch#backslashes for more information).
|
|
||||||
- **v1.2:** anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch)
|
|
||||||
for glob pattern matching. Issues with glob pattern matching should be
|
|
||||||
reported directly to the [micromatch issue tracker](https://github.com/jonschlinkert/micromatch/issues).
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
[ISC](https://raw.github.com/micromatch/anymatch/master/LICENSE)
|
|
|
@ -1,19 +0,0 @@
|
||||||
type AnymatchFn = (testString: string) => boolean;
|
|
||||||
type AnymatchPattern = string|RegExp|AnymatchFn;
|
|
||||||
type AnymatchMatcher = AnymatchPattern|AnymatchPattern[]
|
|
||||||
type AnymatchTester = {
|
|
||||||
(testString: string|any[], returnIndex: true): number;
|
|
||||||
(testString: string|any[]): boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
type PicomatchOptions = {dot: boolean};
|
|
||||||
|
|
||||||
declare const anymatch: {
|
|
||||||
(matchers: AnymatchMatcher): AnymatchTester;
|
|
||||||
(matchers: AnymatchMatcher, testString: string|any[], returnIndex: true | PicomatchOptions): number;
|
|
||||||
(matchers: AnymatchMatcher, testString: string|any[]): boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export {AnymatchMatcher as Matcher}
|
|
||||||
export {AnymatchTester as Tester}
|
|
||||||
export default anymatch
|
|
|
@ -1,102 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
|
|
||||||
const picomatch = require('picomatch');
|
|
||||||
const normalizePath = require('normalize-path');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {(testString: string) => boolean} AnymatchFn
|
|
||||||
* @typedef {string|RegExp|AnymatchFn} AnymatchPattern
|
|
||||||
* @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher
|
|
||||||
*/
|
|
||||||
const BANG = '!';
|
|
||||||
const DEFAULT_OPTIONS = {returnIndex: false};
|
|
||||||
const arrify = (item) => Array.isArray(item) ? item : [item];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {AnymatchPattern} matcher
|
|
||||||
* @param {object} options
|
|
||||||
* @returns {AnymatchFn}
|
|
||||||
*/
|
|
||||||
const createPattern = (matcher, options) => {
|
|
||||||
if (typeof matcher === 'function') {
|
|
||||||
return matcher;
|
|
||||||
}
|
|
||||||
if (typeof matcher === 'string') {
|
|
||||||
const glob = picomatch(matcher, options);
|
|
||||||
return (string) => matcher === string || glob(string);
|
|
||||||
}
|
|
||||||
if (matcher instanceof RegExp) {
|
|
||||||
return (string) => matcher.test(string);
|
|
||||||
}
|
|
||||||
return (string) => false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Array<Function>} patterns
|
|
||||||
* @param {Array<Function>} negPatterns
|
|
||||||
* @param {String|Array} args
|
|
||||||
* @param {Boolean} returnIndex
|
|
||||||
* @returns {boolean|number}
|
|
||||||
*/
|
|
||||||
const matchPatterns = (patterns, negPatterns, args, returnIndex) => {
|
|
||||||
const isList = Array.isArray(args);
|
|
||||||
const _path = isList ? args[0] : args;
|
|
||||||
if (!isList && typeof _path !== 'string') {
|
|
||||||
throw new TypeError('anymatch: second argument must be a string: got ' +
|
|
||||||
Object.prototype.toString.call(_path))
|
|
||||||
}
|
|
||||||
const path = normalizePath(_path);
|
|
||||||
|
|
||||||
for (let index = 0; index < negPatterns.length; index++) {
|
|
||||||
const nglob = negPatterns[index];
|
|
||||||
if (nglob(path)) {
|
|
||||||
return returnIndex ? -1 : false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const applied = isList && [path].concat(args.slice(1));
|
|
||||||
for (let index = 0; index < patterns.length; index++) {
|
|
||||||
const pattern = patterns[index];
|
|
||||||
if (isList ? pattern(...applied) : pattern(path)) {
|
|
||||||
return returnIndex ? index : true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnIndex ? -1 : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {AnymatchMatcher} matchers
|
|
||||||
* @param {Array|string} testString
|
|
||||||
* @param {object} options
|
|
||||||
* @returns {boolean|number|Function}
|
|
||||||
*/
|
|
||||||
const anymatch = (matchers, testString, options = DEFAULT_OPTIONS) => {
|
|
||||||
if (matchers == null) {
|
|
||||||
throw new TypeError('anymatch: specify first argument');
|
|
||||||
}
|
|
||||||
const opts = typeof options === 'boolean' ? {returnIndex: options} : options;
|
|
||||||
const returnIndex = opts.returnIndex || false;
|
|
||||||
|
|
||||||
// Early cache for matchers.
|
|
||||||
const mtchers = arrify(matchers);
|
|
||||||
const negatedGlobs = mtchers
|
|
||||||
.filter(item => typeof item === 'string' && item.charAt(0) === BANG)
|
|
||||||
.map(item => item.slice(1))
|
|
||||||
.map(item => picomatch(item, opts));
|
|
||||||
const patterns = mtchers.map(matcher => createPattern(matcher, opts));
|
|
||||||
|
|
||||||
if (testString == null) {
|
|
||||||
return (testString, ri = false) => {
|
|
||||||
const returnIndex = typeof ri === 'boolean' ? ri : false;
|
|
||||||
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
|
||||||
};
|
|
||||||
|
|
||||||
anymatch.default = anymatch;
|
|
||||||
module.exports = anymatch;
|
|
|
@ -1,76 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "anymatch@~3.1.1",
|
|
||||||
"_id": "anymatch@3.1.1",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==",
|
|
||||||
"_location": "/anymatch",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "anymatch@~3.1.1",
|
|
||||||
"name": "anymatch",
|
|
||||||
"escapedName": "anymatch",
|
|
||||||
"rawSpec": "~3.1.1",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "~3.1.1"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/chokidar"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz",
|
|
||||||
"_shasum": "c55ecf02185e2469259399310c173ce31233b142",
|
|
||||||
"_spec": "anymatch@~3.1.1",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\chokidar",
|
|
||||||
"author": {
|
|
||||||
"name": "Elan Shanker",
|
|
||||||
"url": "https://github.com/es128"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/micromatch/anymatch/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"normalize-path": "^3.0.0",
|
|
||||||
"picomatch": "^2.0.4"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions",
|
|
||||||
"devDependencies": {
|
|
||||||
"mocha": "^6.1.3",
|
|
||||||
"nyc": "^14.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 8"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js",
|
|
||||||
"index.d.ts"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/micromatch/anymatch",
|
|
||||||
"keywords": [
|
|
||||||
"match",
|
|
||||||
"any",
|
|
||||||
"string",
|
|
||||||
"file",
|
|
||||||
"fs",
|
|
||||||
"list",
|
|
||||||
"glob",
|
|
||||||
"regex",
|
|
||||||
"regexp",
|
|
||||||
"regular",
|
|
||||||
"expression",
|
|
||||||
"function"
|
|
||||||
],
|
|
||||||
"license": "ISC",
|
|
||||||
"name": "anymatch",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/micromatch/anymatch.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"mocha": "mocha",
|
|
||||||
"test": "nyc mocha"
|
|
||||||
},
|
|
||||||
"version": "3.1.1"
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.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.
|
|
|
@ -1,43 +0,0 @@
|
||||||
# Array Flatten
|
|
||||||
|
|
||||||
[![NPM version][npm-image]][npm-url]
|
|
||||||
[![NPM downloads][downloads-image]][downloads-url]
|
|
||||||
[![Build status][travis-image]][travis-url]
|
|
||||||
[![Test coverage][coveralls-image]][coveralls-url]
|
|
||||||
|
|
||||||
> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```
|
|
||||||
npm install array-flatten --save
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var flatten = require('array-flatten')
|
|
||||||
|
|
||||||
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
|
|
||||||
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
||||||
|
|
||||||
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
|
|
||||||
//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
flatten(arguments) //=> [1, 2, 3]
|
|
||||||
})(1, [2, 3])
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT
|
|
||||||
|
|
||||||
[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
|
|
||||||
[npm-url]: https://npmjs.org/package/array-flatten
|
|
||||||
[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
|
|
||||||
[downloads-url]: https://npmjs.org/package/array-flatten
|
|
||||||
[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
|
|
||||||
[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
|
|
||||||
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
|
|
||||||
[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
|
|
|
@ -1,64 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expose `arrayFlatten`.
|
|
||||||
*/
|
|
||||||
module.exports = arrayFlatten
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursive flatten function with depth.
|
|
||||||
*
|
|
||||||
* @param {Array} array
|
|
||||||
* @param {Array} result
|
|
||||||
* @param {Number} depth
|
|
||||||
* @return {Array}
|
|
||||||
*/
|
|
||||||
function flattenWithDepth (array, result, depth) {
|
|
||||||
for (var i = 0; i < array.length; i++) {
|
|
||||||
var value = array[i]
|
|
||||||
|
|
||||||
if (depth > 0 && Array.isArray(value)) {
|
|
||||||
flattenWithDepth(value, result, depth - 1)
|
|
||||||
} else {
|
|
||||||
result.push(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursive flatten function. Omitting depth is slightly faster.
|
|
||||||
*
|
|
||||||
* @param {Array} array
|
|
||||||
* @param {Array} result
|
|
||||||
* @return {Array}
|
|
||||||
*/
|
|
||||||
function flattenForever (array, result) {
|
|
||||||
for (var i = 0; i < array.length; i++) {
|
|
||||||
var value = array[i]
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
flattenForever(value, result)
|
|
||||||
} else {
|
|
||||||
result.push(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flatten an array, with the ability to define a depth.
|
|
||||||
*
|
|
||||||
* @param {Array} array
|
|
||||||
* @param {Number} depth
|
|
||||||
* @return {Array}
|
|
||||||
*/
|
|
||||||
function arrayFlatten (array, depth) {
|
|
||||||
if (depth == null) {
|
|
||||||
return flattenForever(array, [])
|
|
||||||
}
|
|
||||||
|
|
||||||
return flattenWithDepth(array, [], depth)
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "array-flatten@1.1.1",
|
|
||||||
"_id": "array-flatten@1.1.1",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=",
|
|
||||||
"_location": "/array-flatten",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "array-flatten@1.1.1",
|
|
||||||
"name": "array-flatten",
|
|
||||||
"escapedName": "array-flatten",
|
|
||||||
"rawSpec": "1.1.1",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.1.1"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/express"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
|
||||||
"_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2",
|
|
||||||
"_spec": "array-flatten@1.1.1",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\express",
|
|
||||||
"author": {
|
|
||||||
"name": "Blake Embrey",
|
|
||||||
"email": "hello@blakeembrey.com",
|
|
||||||
"url": "http://blakeembrey.me"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/blakeembrey/array-flatten/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Flatten an array of nested arrays into a single flat array",
|
|
||||||
"devDependencies": {
|
|
||||||
"istanbul": "^0.3.13",
|
|
||||||
"mocha": "^2.2.4",
|
|
||||||
"pre-commit": "^1.0.7",
|
|
||||||
"standard": "^3.7.3"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"array-flatten.js",
|
|
||||||
"LICENSE"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/blakeembrey/array-flatten",
|
|
||||||
"keywords": [
|
|
||||||
"array",
|
|
||||||
"flatten",
|
|
||||||
"arguments",
|
|
||||||
"depth"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "array-flatten.js",
|
|
||||||
"name": "array-flatten",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/blakeembrey/array-flatten.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "istanbul cover _mocha -- -R spec"
|
|
||||||
},
|
|
||||||
"version": "1.1.1"
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
test
|
|
||||||
.gitignore
|
|
||||||
.travis.yml
|
|
||||||
Makefile
|
|
||||||
example.js
|
|
|
@ -1,21 +0,0 @@
|
||||||
(MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
|
||||||
the Software without restriction, including without limitation the rights to
|
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
||||||
of the Software, and to permit persons to whom the Software is furnished to do
|
|
||||||
so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -1,91 +0,0 @@
|
||||||
# balanced-match
|
|
||||||
|
|
||||||
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
|
||||||
|
|
||||||
[](http://travis-ci.org/juliangruber/balanced-match)
|
|
||||||
[](https://www.npmjs.org/package/balanced-match)
|
|
||||||
|
|
||||||
[](https://ci.testling.com/juliangruber/balanced-match)
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
Get the first matching pair of braces:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var balanced = require('balanced-match');
|
|
||||||
|
|
||||||
console.log(balanced('{', '}', 'pre{in{nested}}post'));
|
|
||||||
console.log(balanced('{', '}', 'pre{first}between{second}post'));
|
|
||||||
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
|
|
||||||
```
|
|
||||||
|
|
||||||
The matches are:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ node example.js
|
|
||||||
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
|
|
||||||
{ start: 3,
|
|
||||||
end: 9,
|
|
||||||
pre: 'pre',
|
|
||||||
body: 'first',
|
|
||||||
post: 'between{second}post' }
|
|
||||||
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### var m = balanced(a, b, str)
|
|
||||||
|
|
||||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
|
||||||
object with those keys:
|
|
||||||
|
|
||||||
* **start** the index of the first match of `a`
|
|
||||||
* **end** the index of the matching `b`
|
|
||||||
* **pre** the preamble, `a` and `b` not included
|
|
||||||
* **body** the match, `a` and `b` not included
|
|
||||||
* **post** the postscript, `a` and `b` not included
|
|
||||||
|
|
||||||
If there's no match, `undefined` will be returned.
|
|
||||||
|
|
||||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
|
|
||||||
|
|
||||||
### var r = balanced.range(a, b, str)
|
|
||||||
|
|
||||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
|
||||||
array with indexes: `[ <a index>, <b index> ]`.
|
|
||||||
|
|
||||||
If there's no match, `undefined` will be returned.
|
|
||||||
|
|
||||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
With [npm](https://npmjs.org) do:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install balanced-match
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
(MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
|
||||||
the Software without restriction, including without limitation the rights to
|
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
||||||
of the Software, and to permit persons to whom the Software is furnished to do
|
|
||||||
so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -1,59 +0,0 @@
|
||||||
'use strict';
|
|
||||||
module.exports = balanced;
|
|
||||||
function balanced(a, b, str) {
|
|
||||||
if (a instanceof RegExp) a = maybeMatch(a, str);
|
|
||||||
if (b instanceof RegExp) b = maybeMatch(b, str);
|
|
||||||
|
|
||||||
var r = range(a, b, str);
|
|
||||||
|
|
||||||
return r && {
|
|
||||||
start: r[0],
|
|
||||||
end: r[1],
|
|
||||||
pre: str.slice(0, r[0]),
|
|
||||||
body: str.slice(r[0] + a.length, r[1]),
|
|
||||||
post: str.slice(r[1] + b.length)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function maybeMatch(reg, str) {
|
|
||||||
var m = str.match(reg);
|
|
||||||
return m ? m[0] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
balanced.range = range;
|
|
||||||
function range(a, b, str) {
|
|
||||||
var begs, beg, left, right, result;
|
|
||||||
var ai = str.indexOf(a);
|
|
||||||
var bi = str.indexOf(b, ai + 1);
|
|
||||||
var i = ai;
|
|
||||||
|
|
||||||
if (ai >= 0 && bi > 0) {
|
|
||||||
begs = [];
|
|
||||||
left = str.length;
|
|
||||||
|
|
||||||
while (i >= 0 && !result) {
|
|
||||||
if (i == ai) {
|
|
||||||
begs.push(i);
|
|
||||||
ai = str.indexOf(a, i + 1);
|
|
||||||
} else if (begs.length == 1) {
|
|
||||||
result = [ begs.pop(), bi ];
|
|
||||||
} else {
|
|
||||||
beg = begs.pop();
|
|
||||||
if (beg < left) {
|
|
||||||
left = beg;
|
|
||||||
right = bi;
|
|
||||||
}
|
|
||||||
|
|
||||||
bi = str.indexOf(b, i + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = ai < bi && ai >= 0 ? ai : bi;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (begs.length) {
|
|
||||||
result = [ left, right ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "balanced-match@^1.0.0",
|
|
||||||
"_id": "balanced-match@1.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
|
||||||
"_location": "/balanced-match",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "balanced-match@^1.0.0",
|
|
||||||
"name": "balanced-match",
|
|
||||||
"escapedName": "balanced-match",
|
|
||||||
"rawSpec": "^1.0.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^1.0.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/brace-expansion"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
|
||||||
"_shasum": "89b4d199ab2bee49de164ea02b89ce462d71b767",
|
|
||||||
"_spec": "balanced-match@^1.0.0",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth\\node_modules\\brace-expansion",
|
|
||||||
"author": {
|
|
||||||
"name": "Julian Gruber",
|
|
||||||
"email": "mail@juliangruber.com",
|
|
||||||
"url": "http://juliangruber.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/juliangruber/balanced-match/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
|
||||||
"devDependencies": {
|
|
||||||
"matcha": "^0.7.0",
|
|
||||||
"tape": "^4.6.0"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/juliangruber/balanced-match",
|
|
||||||
"keywords": [
|
|
||||||
"match",
|
|
||||||
"regexp",
|
|
||||||
"test",
|
|
||||||
"balanced",
|
|
||||||
"parse"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "balanced-match",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/juliangruber/balanced-match.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"bench": "make bench",
|
|
||||||
"test": "make test"
|
|
||||||
},
|
|
||||||
"testling": {
|
|
||||||
"files": "test/*.js",
|
|
||||||
"browsers": [
|
|
||||||
"ie/8..latest",
|
|
||||||
"firefox/20..latest",
|
|
||||||
"firefox/nightly",
|
|
||||||
"chrome/25..latest",
|
|
||||||
"chrome/canary",
|
|
||||||
"opera/12..latest",
|
|
||||||
"opera/next",
|
|
||||||
"safari/5.1..latest",
|
|
||||||
"ipad/6.0..latest",
|
|
||||||
"iphone/6.0..latest",
|
|
||||||
"android-browser/4.2..latest"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"version": "1.0.0"
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
node_modules/
|
|
||||||
npm-debug.log
|
|
||||||
debug.log
|
|
||||||
doco/
|
|
||||||
tests/bench.js
|
|
||||||
*.png
|
|
|
@ -1,18 +0,0 @@
|
||||||
language: node_js
|
|
||||||
|
|
||||||
node_js:
|
|
||||||
- 0.10
|
|
||||||
- 0.12
|
|
||||||
- 4
|
|
||||||
- 6
|
|
||||||
|
|
||||||
before_script: npm -g install testjs
|
|
||||||
|
|
||||||
env:
|
|
||||||
- CXX=g++-4.8
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"vsicons.presets.angular": false
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
bcrypt.js
|
|
||||||
---------
|
|
||||||
Copyright (c) 2012 Nevins Bartolomeo <nevins.bartolomeo@gmail.com>
|
|
||||||
Copyright (c) 2012 Shane Girish <shaneGirish@gmail.com>
|
|
||||||
Copyright (c) 2014 Daniel Wirtz <dcode@dcode.io>
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions
|
|
||||||
are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. The name of the author may not be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
isaac.js
|
|
||||||
--------
|
|
||||||
Copyright (c) 2012 Yves-Marie K. Rinquin
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
@ -1,251 +0,0 @@
|
||||||
bcrypt.js
|
|
||||||
=========
|
|
||||||
Optimized bcrypt in JavaScript with zero dependencies. Compatible to the C++ [bcrypt](https://npmjs.org/package/bcrypt)
|
|
||||||
binding on node.js and also working in the browser.
|
|
||||||
|
|
||||||
<a href="https://travis-ci.org/dcodeIO/bcrypt.js"><img alt="build static" src="https://travis-ci.org/dcodeIO/bcrypt.js.svg?branch=master" /></a> <a href="https://npmjs.org/package/bcryptjs"><img src="https://img.shields.io/npm/v/bcryptjs.svg" alt=""></a> <a href="https://npmjs.org/package/bcryptjs"><img src="https://img.shields.io/npm/dm/bcryptjs.svg" alt=""></a> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dcode%40dcode.io&item_name=Open%20Source%20Software%20Donation&item_number=dcodeIO%2Fbcrypt.js"><img alt="donate ❤" src="https://img.shields.io/badge/donate-❤-ff2244.svg"></a>
|
|
||||||
|
|
||||||
|
|
||||||
Security considerations
|
|
||||||
-----------------------
|
|
||||||
Besides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the
|
|
||||||
iteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with
|
|
||||||
increasing computation power. ([see](http://en.wikipedia.org/wiki/Bcrypt))
|
|
||||||
|
|
||||||
While bcrypt.js is compatible to the C++ bcrypt binding, it is written in pure JavaScript and thus slower ([about 30%](https://github.com/dcodeIO/bcrypt.js/wiki/Benchmark)), effectively reducing the number of iterations that can be
|
|
||||||
processed in an equal time span.
|
|
||||||
|
|
||||||
The maximum input length is 72 bytes (note that UTF8 encoded characters use up to 4 bytes) and the length of generated
|
|
||||||
hashes is 60 characters.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
The library is compatible with CommonJS and AMD loaders and is exposed globally as `dcodeIO.bcrypt` if neither is
|
|
||||||
available.
|
|
||||||
|
|
||||||
### node.js
|
|
||||||
|
|
||||||
On node.js, the inbuilt [crypto module](http://nodejs.org/api/crypto.html)'s randomBytes interface is used to obtain
|
|
||||||
secure random numbers.
|
|
||||||
|
|
||||||
`npm install bcryptjs`
|
|
||||||
|
|
||||||
```js
|
|
||||||
var bcrypt = require('bcryptjs');
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
### Browser
|
|
||||||
|
|
||||||
In the browser, bcrypt.js relies on [Web Crypto API](http://www.w3.org/TR/WebCryptoAPI)'s getRandomValues
|
|
||||||
interface to obtain secure random numbers. If no cryptographically secure source of randomness is available, you may
|
|
||||||
specify one through [bcrypt.setRandomFallback](https://github.com/dcodeIO/bcrypt.js#setrandomfallbackrandom).
|
|
||||||
|
|
||||||
```js
|
|
||||||
var bcrypt = dcodeIO.bcrypt;
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
```js
|
|
||||||
require.config({
|
|
||||||
paths: { "bcrypt": "/path/to/bcrypt.js" }
|
|
||||||
});
|
|
||||||
require(["bcrypt"], function(bcrypt) {
|
|
||||||
...
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Usage - Sync
|
|
||||||
------------
|
|
||||||
To hash a password:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var bcrypt = require('bcryptjs');
|
|
||||||
var salt = bcrypt.genSaltSync(10);
|
|
||||||
var hash = bcrypt.hashSync("B4c0/\/", salt);
|
|
||||||
// Store hash in your password DB.
|
|
||||||
```
|
|
||||||
|
|
||||||
To check a password:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// Load hash from your password DB.
|
|
||||||
bcrypt.compareSync("B4c0/\/", hash); // true
|
|
||||||
bcrypt.compareSync("not_bacon", hash); // false
|
|
||||||
```
|
|
||||||
|
|
||||||
Auto-gen a salt and hash:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var hash = bcrypt.hashSync('bacon', 8);
|
|
||||||
```
|
|
||||||
|
|
||||||
Usage - Async
|
|
||||||
-------------
|
|
||||||
To hash a password:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var bcrypt = require('bcryptjs');
|
|
||||||
bcrypt.genSalt(10, function(err, salt) {
|
|
||||||
bcrypt.hash("B4c0/\/", salt, function(err, hash) {
|
|
||||||
// Store hash in your password DB.
|
|
||||||
});
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
To check a password:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// Load hash from your password DB.
|
|
||||||
bcrypt.compare("B4c0/\/", hash, function(err, res) {
|
|
||||||
// res === true
|
|
||||||
});
|
|
||||||
bcrypt.compare("not_bacon", hash, function(err, res) {
|
|
||||||
// res === false
|
|
||||||
});
|
|
||||||
|
|
||||||
// As of bcryptjs 2.4.0, compare returns a promise if callback is omitted:
|
|
||||||
bcrypt.compare("B4c0/\/", hash).then((res) => {
|
|
||||||
// res === true
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Auto-gen a salt and hash:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
bcrypt.hash('bacon', 8, function(err, hash) {
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note:** Under the hood, asynchronisation splits a crypto operation into small chunks. After the completion of a chunk, the execution of the next chunk is placed on the back of [JS event loop queue](https://developer.mozilla.org/en/docs/Web/JavaScript/EventLoop), thus efficiently sharing the computational resources with the other operations in the queue.
|
|
||||||
|
|
||||||
API
|
|
||||||
---
|
|
||||||
### setRandomFallback(random)
|
|
||||||
|
|
||||||
Sets the pseudo random number generator to use as a fallback if neither node's `crypto` module nor the Web Crypto
|
|
||||||
API is available. Please note: It is highly important that the PRNG used is cryptographically secure and that it is
|
|
||||||
seeded properly!
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| random | *function(number):!Array.<number>* | Function taking the number of bytes to generate as its sole argument, returning the corresponding array of cryptographically secure random byte values.
|
|
||||||
| **@see** | | http://nodejs.org/api/crypto.html
|
|
||||||
| **@see** | | http://www.w3.org/TR/WebCryptoAPI/
|
|
||||||
|
|
||||||
**Hint:** You might use [isaac.js](https://github.com/rubycon/isaac.js) as a CSPRNG but you still have to make sure to
|
|
||||||
seed it properly.
|
|
||||||
|
|
||||||
### genSaltSync(rounds=, seed_length=)
|
|
||||||
|
|
||||||
Synchronously generates a salt.
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| rounds | *number* | Number of rounds to use, defaults to 10 if omitted
|
|
||||||
| seed_length | *number* | Not supported.
|
|
||||||
| **@returns** | *string* | Resulting salt
|
|
||||||
| **@throws** | *Error* | If a random fallback is required but not set
|
|
||||||
|
|
||||||
### genSalt(rounds=, seed_length=, callback)
|
|
||||||
|
|
||||||
Asynchronously generates a salt.
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| rounds | *number | function(Error, string=)* | Number of rounds to use, defaults to 10 if omitted
|
|
||||||
| seed_length | *number | function(Error, string=)* | Not supported.
|
|
||||||
| callback | *function(Error, string=)* | Callback receiving the error, if any, and the resulting salt
|
|
||||||
| **@returns** | *Promise* | If `callback` has been omitted
|
|
||||||
| **@throws** | *Error* | If `callback` is present but not a function
|
|
||||||
|
|
||||||
### hashSync(s, salt=)
|
|
||||||
|
|
||||||
Synchronously generates a hash for the given string.
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| s | *string* | String to hash
|
|
||||||
| salt | *number | string* | Salt length to generate or salt to use, default to 10
|
|
||||||
| **@returns** | *string* | Resulting hash
|
|
||||||
|
|
||||||
### hash(s, salt, callback, progressCallback=)
|
|
||||||
|
|
||||||
Asynchronously generates a hash for the given string.
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| s | *string* | String to hash
|
|
||||||
| salt | *number | string* | Salt length to generate or salt to use
|
|
||||||
| callback | *function(Error, string=)* | Callback receiving the error, if any, and the resulting hash
|
|
||||||
| progressCallback | *function(number)* | Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms.
|
|
||||||
| **@returns** | *Promise* | If `callback` has been omitted
|
|
||||||
| **@throws** | *Error* | If `callback` is present but not a function
|
|
||||||
|
|
||||||
### compareSync(s, hash)
|
|
||||||
|
|
||||||
Synchronously tests a string against a hash.
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| s | *string* | String to compare
|
|
||||||
| hash | *string* | Hash to test against
|
|
||||||
| **@returns** | *boolean* | true if matching, otherwise false
|
|
||||||
| **@throws** | *Error* | If an argument is illegal
|
|
||||||
|
|
||||||
### compare(s, hash, callback, progressCallback=)
|
|
||||||
|
|
||||||
Asynchronously compares the given data against the given hash.
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| s | *string* | Data to compare
|
|
||||||
| hash | *string* | Data to be compared to
|
|
||||||
| callback | *function(Error, boolean)* | Callback receiving the error, if any, otherwise the result
|
|
||||||
| progressCallback | *function(number)* | Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms.
|
|
||||||
| **@returns** | *Promise* | If `callback` has been omitted
|
|
||||||
| **@throws** | *Error* | If `callback` is present but not a function
|
|
||||||
|
|
||||||
### getRounds(hash)
|
|
||||||
|
|
||||||
Gets the number of rounds used to encrypt the specified hash.
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| hash | *string* | Hash to extract the used number of rounds from
|
|
||||||
| **@returns** | *number* | Number of rounds used
|
|
||||||
| **@throws** | *Error* | If `hash` is not a string
|
|
||||||
|
|
||||||
### getSalt(hash)
|
|
||||||
|
|
||||||
Gets the salt portion from a hash. Does not validate the hash.
|
|
||||||
|
|
||||||
| Parameter | Type | Description
|
|
||||||
|-----------------|-----------------|---------------
|
|
||||||
| hash | *string* | Hash to extract the salt from
|
|
||||||
| **@returns** | *string* | Extracted salt part
|
|
||||||
| **@throws** | *Error* | If `hash` is not a string or otherwise invalid
|
|
||||||
|
|
||||||
|
|
||||||
Command line
|
|
||||||
------------
|
|
||||||
`Usage: bcrypt <input> [salt]`
|
|
||||||
|
|
||||||
If the input has spaces inside, simply surround it with quotes.
|
|
||||||
|
|
||||||
Downloads
|
|
||||||
---------
|
|
||||||
* [Distributions](https://github.com/dcodeIO/bcrypt.js/tree/master/dist)
|
|
||||||
* [ZIP-Archive](https://github.com/dcodeIO/bcrypt.js/archive/master.zip)
|
|
||||||
* [Tarball](https://github.com/dcodeIO/bcrypt.js/tarball/master)
|
|
||||||
|
|
||||||
Credits
|
|
||||||
-------
|
|
||||||
Based on work started by Shane Girish at [bcrypt-nodejs](https://github.com/shaneGirish/bcrypt-nodejs) (MIT-licensed),
|
|
||||||
which is itself based on [javascript-bcrypt](http://code.google.com/p/javascript-bcrypt/) (New BSD-licensed).
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
New-BSD / MIT ([see](https://github.com/dcodeIO/bcrypt.js/blob/master/LICENSE))
|
|
|
@ -1,25 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
var path = require("path"),
|
|
||||||
bcrypt = require(path.join(__dirname, '..', 'index.js')),
|
|
||||||
pkg = require(path.join(__dirname, '..', 'package.json'));
|
|
||||||
|
|
||||||
if (process.argv.length < 3) {
|
|
||||||
process.stderr.write([ // No dependencies, so we do it from hand.
|
|
||||||
"",
|
|
||||||
" |_ _ _ _ |_",
|
|
||||||
" |_)(_| \\/|_)|_ v"+pkg['version']+" (c) "+pkg['author'],
|
|
||||||
" / | "
|
|
||||||
].join('\n')+'\n\n'+" Usage: "+path.basename(process.argv[1])+" <input> [rounds|salt]\n");
|
|
||||||
process.exit(1);
|
|
||||||
} else {
|
|
||||||
var salt;
|
|
||||||
if (process.argv.length > 3) {
|
|
||||||
salt = process.argv[3];
|
|
||||||
var rounds = parseInt(salt, 10);
|
|
||||||
if (rounds == salt)
|
|
||||||
salt = bcrypt.genSaltSync(rounds);
|
|
||||||
} else
|
|
||||||
salt = bcrypt.genSaltSync();
|
|
||||||
process.stdout.write(bcrypt.hashSync(process.argv[2], salt)+"\n");
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
{
|
|
||||||
"name": "bcryptjs",
|
|
||||||
"description": "Optimized bcrypt in plain JavaScript with zero dependencies.",
|
|
||||||
"version": "2.4.3",
|
|
||||||
"main": "dist/bcrypt.min.js",
|
|
||||||
"license": "New-BSD",
|
|
||||||
"homepage": "http://dcode.io/",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/dcodeIO/bcrypt.js.git"
|
|
||||||
},
|
|
||||||
"keywords": ["bcrypt", "password", "auth", "authentication", "encryption", "crypt", "crypto"],
|
|
||||||
"dependencies": {},
|
|
||||||
"devDependencies": {},
|
|
||||||
"ignore": [
|
|
||||||
"**/.*",
|
|
||||||
"node_modules",
|
|
||||||
"bower_components",
|
|
||||||
"test",
|
|
||||||
"tests"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
Distributions
|
|
||||||
=============
|
|
||||||
bcrypt.js is available as the following distributions:
|
|
||||||
|
|
||||||
* **[bcrypt.js](https://github.com/dcodeIO/bcrypt.js/blob/master/dist/bcrypt.js)**
|
|
||||||
contains the commented source code.
|
|
||||||
|
|
||||||
* **[bcrypt.min.js](https://github.com/dcodeIO/bcrypt.js/blob/master/dist/bcrypt.min.js)**
|
|
||||||
has been compiled with Closure Compiler using advanced optimizations.
|
|
||||||
|
|
||||||
* **[bcrypt.min.map](https://github.com/dcodeIO/bcrypt.js/blob/master/dist/bcrypt.min.map)**
|
|
||||||
contains the source map generated by Closure Compiler.
|
|
||||||
|
|
||||||
* **[bcrypt.min.js.gz](https://github.com/dcodeIO/bcrypt.js/blob/master/dist/bcrypt.min.js.gz)**
|
|
||||||
has also been gzipped using `-9`.
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
|
|
||||||
Released under the Apache License, Version 2.0
|
|
||||||
see: https://github.com/dcodeIO/bcrypt.js for details
|
|
||||||
*/
|
|
||||||
(function(u,r){"function"===typeof define&&define.amd?define([],r):"function"===typeof require&&"object"===typeof module&&module&&module.exports?module.exports=r():(u.dcodeIO=u.dcodeIO||{}).bcrypt=r()})(this,function(){function u(e){if("undefined"!==typeof module&&module&&module.exports)try{return require("crypto").randomBytes(e)}catch(d){}try{var c;(self.crypto||self.msCrypto).getRandomValues(c=new Uint32Array(e));return Array.prototype.slice.call(c)}catch(b){}if(!w)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");
|
|
||||||
return w(e)}function r(e,d){for(var c=0,b=0,a=0,f=e.length;a<f;++a)e.charCodeAt(a)===d.charCodeAt(a)?++c:++b;return 0>c?!1:0===b}function H(e){var d=[],c=0;I.encodeUTF16toUTF8(function(){return c>=e.length?null:e.charCodeAt(c++)},function(b){d.push(b)});return d}function x(e,d){var c=0,b=[],a,f;if(0>=d||d>e.length)throw Error("Illegal len: "+d);for(;c<d;){a=e[c++]&255;b.push(s[a>>2&63]);a=(a&3)<<4;if(c>=d){b.push(s[a&63]);break}f=e[c++]&255;a|=f>>4&15;b.push(s[a&63]);a=(f&15)<<2;if(c>=d){b.push(s[a&
|
|
||||||
63]);break}f=e[c++]&255;a|=f>>6&3;b.push(s[a&63]);b.push(s[f&63])}return b.join("")}function B(e,d){var c=0,b=e.length,a=0,f=[],g,m,h;if(0>=d)throw Error("Illegal len: "+d);for(;c<b-1&&a<d;){h=e.charCodeAt(c++);g=h<q.length?q[h]:-1;h=e.charCodeAt(c++);m=h<q.length?q[h]:-1;if(-1==g||-1==m)break;h=g<<2>>>0;h|=(m&48)>>4;f.push(z(h));if(++a>=d||c>=b)break;h=e.charCodeAt(c++);g=h<q.length?q[h]:-1;if(-1==g)break;h=(m&15)<<4>>>0;h|=(g&60)>>2;f.push(z(h));if(++a>=d||c>=b)break;h=e.charCodeAt(c++);m=h<q.length?
|
|
||||||
q[h]:-1;h=(g&3)<<6>>>0;h|=m;f.push(z(h));++a}b=[];for(c=0;c<a;c++)b.push(f[c].charCodeAt(0));return b}function v(e,d,c,b){var a,f=e[d],g=e[d+1],f=f^c[0];a=b[f>>>24];a+=b[256|f>>16&255];a^=b[512|f>>8&255];a+=b[768|f&255];g=g^a^c[1];a=b[g>>>24];a+=b[256|g>>16&255];a^=b[512|g>>8&255];a+=b[768|g&255];f=f^a^c[2];a=b[f>>>24];a+=b[256|f>>16&255];a^=b[512|f>>8&255];a+=b[768|f&255];g=g^a^c[3];a=b[g>>>24];a+=b[256|g>>16&255];a^=b[512|g>>8&255];a+=b[768|g&255];f=f^a^c[4];a=b[f>>>24];a+=b[256|f>>16&255];a^=b[512|
|
|
||||||
f>>8&255];a+=b[768|f&255];g=g^a^c[5];a=b[g>>>24];a+=b[256|g>>16&255];a^=b[512|g>>8&255];a+=b[768|g&255];f=f^a^c[6];a=b[f>>>24];a+=b[256|f>>16&255];a^=b[512|f>>8&255];a+=b[768|f&255];g=g^a^c[7];a=b[g>>>24];a+=b[256|g>>16&255];a^=b[512|g>>8&255];a+=b[768|g&255];f=f^a^c[8];a=b[f>>>24];a+=b[256|f>>16&255];a^=b[512|f>>8&255];a+=b[768|f&255];g=g^a^c[9];a=b[g>>>24];a+=b[256|g>>16&255];a^=b[512|g>>8&255];a+=b[768|g&255];f=f^a^c[10];a=b[f>>>24];a+=b[256|f>>16&255];a^=b[512|f>>8&255];a+=b[768|f&255];g=g^a^
|
|
||||||
c[11];a=b[g>>>24];a+=b[256|g>>16&255];a^=b[512|g>>8&255];a+=b[768|g&255];f=f^a^c[12];a=b[f>>>24];a+=b[256|f>>16&255];a^=b[512|f>>8&255];a+=b[768|f&255];g=g^a^c[13];a=b[g>>>24];a+=b[256|g>>16&255];a^=b[512|g>>8&255];a+=b[768|g&255];f=f^a^c[14];a=b[f>>>24];a+=b[256|f>>16&255];a^=b[512|f>>8&255];a+=b[768|f&255];g=g^a^c[15];a=b[g>>>24];a+=b[256|g>>16&255];a^=b[512|g>>8&255];a+=b[768|g&255];f=f^a^c[16];e[d]=g^c[17];e[d+1]=f;return e}function t(e,d){for(var c=0,b=0;4>c;++c)b=b<<8|e[d]&255,d=(d+1)%e.length;
|
|
||||||
return{key:b,offp:d}}function C(e,d,c){for(var b=0,a=[0,0],f=d.length,g=c.length,m,h=0;h<f;h++)m=t(e,b),b=m.offp,d[h]^=m.key;for(h=0;h<f;h+=2)a=v(a,0,d,c),d[h]=a[0],d[h+1]=a[1];for(h=0;h<g;h+=2)a=v(a,0,d,c),c[h]=a[0],c[h+1]=a[1]}function J(e,d,c,b){for(var a=0,f=[0,0],g=c.length,m=b.length,h,l=0;l<g;l++)h=t(d,a),a=h.offp,c[l]^=h.key;for(l=a=0;l<g;l+=2)h=t(e,a),a=h.offp,f[0]^=h.key,h=t(e,a),a=h.offp,f[1]^=h.key,f=v(f,0,c,b),c[l]=f[0],c[l+1]=f[1];for(l=0;l<m;l+=2)h=t(e,a),a=h.offp,f[0]^=h.key,h=t(e,
|
|
||||||
a),a=h.offp,f[1]^=h.key,f=v(f,0,c,b),b[l]=f[0],b[l+1]=f[1]}function D(e,d,c,b,a){function f(){a&&a(n/c);if(n<c)for(var h=Date.now();n<c&&!(n+=1,C(e,l,k),C(d,l,k),100<Date.now()-h););else{for(n=0;64>n;n++)for(y=0;y<m>>1;y++)v(g,y<<1,l,k);h=[];for(n=0;n<m;n++)h.push((g[n]>>24&255)>>>0),h.push((g[n]>>16&255)>>>0),h.push((g[n]>>8&255)>>>0),h.push((g[n]&255)>>>0);if(b){b(null,h);return}return h}b&&p(f)}var g=E.slice(),m=g.length,h;if(4>c||31<c){h=Error("Illegal number of rounds (4-31): "+c);if(b){p(b.bind(this,
|
|
||||||
h));return}throw h;}if(16!==d.length){h=Error("Illegal salt length: "+d.length+" != 16");if(b){p(b.bind(this,h));return}throw h;}c=1<<c>>>0;var l,k,n=0,y;Int32Array?(l=new Int32Array(F),k=new Int32Array(G)):(l=F.slice(),k=G.slice());J(d,e,l,k);if("undefined"!==typeof b)f();else for(;;)if("undefined"!==typeof(h=f()))return h||[]}function A(e,d,c,b){function a(a){var b=[];b.push("$2");"a"<=f&&b.push(f);b.push("$");10>l&&b.push("0");b.push(l.toString());b.push("$");b.push(x(k,k.length));b.push(x(a,4*
|
|
||||||
E.length-1));return b.join("")}if("string"!==typeof e||"string"!==typeof d){b=Error("Invalid string / salt: Not a string");if(c){p(c.bind(this,b));return}throw b;}var f,g;if("$"!==d.charAt(0)||"2"!==d.charAt(1)){b=Error("Invalid salt version: "+d.substring(0,2));if(c){p(c.bind(this,b));return}throw b;}if("$"===d.charAt(2))f=String.fromCharCode(0),g=3;else{f=d.charAt(2);if("a"!==f&&"b"!==f&&"y"!==f||"$"!==d.charAt(3)){b=Error("Invalid salt revision: "+d.substring(2,4));if(c){p(c.bind(this,b));return}throw b;
|
|
||||||
}g=4}if("$"<d.charAt(g+2)){b=Error("Missing salt rounds");if(c){p(c.bind(this,b));return}throw b;}var m=10*parseInt(d.substring(g,g+1),10),h=parseInt(d.substring(g+1,g+2),10),l=m+h;d=d.substring(g+3,g+25);e=H(e+("a"<=f?"\x00":""));var k=B(d,16);if("undefined"==typeof c)return a(D(e,k,l));D(e,k,l,function(b,d){b?c(b,null):c(null,a(d))},b)}var k={},w=null;try{u(1)}catch(K){}w=null;k.setRandomFallback=function(e){w=e};k.genSaltSync=function(e,d){e=e||10;if("number"!==typeof e)throw Error("Illegal arguments: "+
|
|
||||||
typeof e+", "+typeof d);4>e?e=4:31<e&&(e=31);var c=[];c.push("$2a$");10>e&&c.push("0");c.push(e.toString());c.push("$");c.push(x(u(16),16));return c.join("")};k.genSalt=function(e,d,c){function b(a){p(function(){try{a(null,k.genSaltSync(e))}catch(b){a(b)}})}"function"===typeof d&&(c=d,d=void 0);"function"===typeof e&&(c=e,e=void 0);if("undefined"===typeof e)e=10;else if("number"!==typeof e)throw Error("illegal arguments: "+typeof e);if(c){if("function"!==typeof c)throw Error("Illegal callback: "+
|
|
||||||
typeof c);b(c)}else return new Promise(function(a,c){b(function(b,d){b?c(b):a(d)})})};k.hashSync=function(e,d){"undefined"===typeof d&&(d=10);"number"===typeof d&&(d=k.genSaltSync(d));if("string"!==typeof e||"string"!==typeof d)throw Error("Illegal arguments: "+typeof e+", "+typeof d);return A(e,d)};k.hash=function(e,d,c,b){function a(a){"string"===typeof e&&"number"===typeof d?k.genSalt(d,function(c,d){A(e,d,a,b)}):"string"===typeof e&&"string"===typeof d?A(e,d,a,b):p(a.bind(this,Error("Illegal arguments: "+
|
|
||||||
typeof e+", "+typeof d)))}if(c){if("function"!==typeof c)throw Error("Illegal callback: "+typeof c);a(c)}else return new Promise(function(b,c){a(function(a,d){a?c(a):b(d)})})};k.compareSync=function(e,d){if("string"!==typeof e||"string"!==typeof d)throw Error("Illegal arguments: "+typeof e+", "+typeof d);return 60!==d.length?!1:r(k.hashSync(e,d.substr(0,d.length-31)),d)};k.compare=function(e,d,c,b){function a(a){"string"!==typeof e||"string"!==typeof d?p(a.bind(this,Error("Illegal arguments: "+typeof e+
|
|
||||||
", "+typeof d))):60!==d.length?p(a.bind(this,null,!1)):k.hash(e,d.substr(0,29),function(b,c){b?a(b):a(null,r(c,d))},b)}if(c){if("function"!==typeof c)throw Error("Illegal callback: "+typeof c);a(c)}else return new Promise(function(b,c){a(function(a,d){a?c(a):b(d)})})};k.getRounds=function(e){if("string"!==typeof e)throw Error("Illegal arguments: "+typeof e);return parseInt(e.split("$")[2],10)};k.getSalt=function(e){if("string"!==typeof e)throw Error("Illegal arguments: "+typeof e);if(60!==e.length)throw Error("Illegal hash length: "+
|
|
||||||
e.length+" != 60");return e.substring(0,29)};var p="undefined"!==typeof process&&process&&"function"===typeof process.nextTick?"function"===typeof setImmediate?setImmediate:process.nextTick:setTimeout,s="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),q=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,
|
|
||||||
13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],z=String.fromCharCode,I=function(){var e={MAX_CODEPOINT:1114111,encodeUTF8:function(d,c){var b=null;"number"===typeof d&&(b=d,d=function(){return null});for(;null!==b||null!==(b=d());)128>b?c(b&127):(2048>b?c(b>>6&31|192):(65536>b?c(b>>12&15|224):(c(b>>18&7|240),c(b>>12&63|128)),c(b>>6&63|128)),c(b&63|128)),b=null},decodeUTF8:function(d,c){for(var b,
|
|
||||||
a,f,e,k=function(a){a=a.slice(0,a.indexOf(null));var b=Error(a.toString());b.name="TruncatedError";b.bytes=a;throw b;};null!==(b=d());)if(0===(b&128))c(b);else if(192===(b&224))null===(a=d())&&k([b,a]),c((b&31)<<6|a&63);else if(224===(b&240))null!==(a=d())&&null!==(f=d())||k([b,a,f]),c((b&15)<<12|(a&63)<<6|f&63);else if(240===(b&248))null!==(a=d())&&null!==(f=d())&&null!==(e=d())||k([b,a,f,e]),c((b&7)<<18|(a&63)<<12|(f&63)<<6|e&63);else throw RangeError("Illegal starting byte: "+b);},UTF16toUTF8:function(d,
|
|
||||||
c){for(var b,a=null;null!==(b=null!==a?a:d());)55296<=b&&57343>=b&&null!==(a=d())&&56320<=a&&57343>=a?(c(1024*(b-55296)+a-56320+65536),a=null):c(b);null!==a&&c(a)},UTF8toUTF16:function(d,c){var b=null;"number"===typeof d&&(b=d,d=function(){return null});for(;null!==b||null!==(b=d());)65535>=b?c(b):(b-=65536,c((b>>10)+55296),c(b%1024+56320)),b=null},encodeUTF16toUTF8:function(d,c){e.UTF16toUTF8(d,function(b){e.encodeUTF8(b,c)})},decodeUTF8toUTF16:function(d,c){e.decodeUTF8(d,function(b){e.UTF8toUTF16(b,
|
|
||||||
c)})},calculateCodePoint:function(d){return 128>d?1:2048>d?2:65536>d?3:4},calculateUTF8:function(d){for(var c,b=0;null!==(c=d());)b+=e.calculateCodePoint(c);return b},calculateUTF16asUTF8:function(d){var c=0,b=0;e.UTF16toUTF8(d,function(a){++c;b+=e.calculateCodePoint(a)});return[c,b]}};return e}();Date.now=Date.now||function(){return+new Date};var F=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,
|
|
||||||
3041331479,2450970073,2306472731],G=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,
|
|
||||||
289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,
|
|
||||||
1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,
|
|
||||||
442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,
|
|
||||||
3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,
|
|
||||||
48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971E4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,
|
|
||||||
1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,
|
|
||||||
613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,
|
|
||||||
2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,
|
|
||||||
1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,
|
|
||||||
4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,
|
|
||||||
2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,
|
|
||||||
499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,
|
|
||||||
3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,
|
|
||||||
309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,
|
|
||||||
1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,
|
|
||||||
2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,
|
|
||||||
2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,
|
|
||||||
3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,
|
|
||||||
3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409E3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,
|
|
||||||
3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,
|
|
||||||
1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],E=[1332899944,1700884034,1701343084,1684370003,1668446532,
|
|
||||||
1869963892];k.encodeBase64=x;k.decodeBase64=B;return k});
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -1,91 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2012 The Closure Compiler Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @fileoverview Definitions for bcrypt.js 2.
|
|
||||||
* @externs
|
|
||||||
* @author Daniel Wirtz <dcode@dcode.io>
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<string,*>}
|
|
||||||
*/
|
|
||||||
var bcrypt = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?function(number):!Array.<number>} random
|
|
||||||
*/
|
|
||||||
bcrypt.setRandomFallback = function(random) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number=} rounds
|
|
||||||
* @param {number=} seed_length
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
bcrypt.genSaltSync = function(rounds, seed_length) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {(number|function(Error, ?string))=} rounds
|
|
||||||
* @param {(number|function(Error, ?string))=} seed_length
|
|
||||||
* @param {function(Error, string=)=} callback
|
|
||||||
*/
|
|
||||||
bcrypt.genSalt = function(rounds, seed_length, callback) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} s
|
|
||||||
* @param {(number|string)=} salt
|
|
||||||
* @returns {?string}
|
|
||||||
*/
|
|
||||||
bcrypt.hashSync = function(s, salt) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} s
|
|
||||||
* @param {number|string} salt
|
|
||||||
* @param {function(Error, string=)} callback
|
|
||||||
* @expose
|
|
||||||
*/
|
|
||||||
bcrypt.hash = function(s, salt, callback) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} s
|
|
||||||
* @param {string} hash
|
|
||||||
* @returns {boolean}
|
|
||||||
* @throws {Error}
|
|
||||||
*/
|
|
||||||
bcrypt.compareSync = function(s, hash) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} s
|
|
||||||
* @param {string} hash
|
|
||||||
* @param {function(Error, boolean)} callback
|
|
||||||
* @throws {Error}
|
|
||||||
*/
|
|
||||||
bcrypt.compare = function(s, hash, callback) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} hash
|
|
||||||
* @returns {number}
|
|
||||||
* @throws {Error}
|
|
||||||
*/
|
|
||||||
bcrypt.getRounds = function(hash) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} hash
|
|
||||||
* @returns {string}
|
|
||||||
* @throws {Error}
|
|
||||||
* @expose
|
|
||||||
*/
|
|
||||||
bcrypt.getSalt = function(hash) {};
|
|
|
@ -1,98 +0,0 @@
|
||||||
/**
|
|
||||||
* @fileoverview Minimal environment for bcrypt.js.
|
|
||||||
* @externs
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} moduleName
|
|
||||||
* returns {*}
|
|
||||||
*/
|
|
||||||
function require(moduleName) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
var Module = function() {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {*}
|
|
||||||
*/
|
|
||||||
Module.prototype.exports;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Module}
|
|
||||||
*/
|
|
||||||
var module;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
var __dirname;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<string,*>}
|
|
||||||
*/
|
|
||||||
var process = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {function()} func
|
|
||||||
*/
|
|
||||||
process.nextTick = function(func) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} s
|
|
||||||
* @constructor
|
|
||||||
* @extends Array
|
|
||||||
*/
|
|
||||||
var Buffer = function(s) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
BEGIN_NODE_INCLUDE
|
|
||||||
var crypto = require('crypto');
|
|
||||||
END_NODE_INCLUDE
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<string,*>}
|
|
||||||
*/
|
|
||||||
var crypto = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} n
|
|
||||||
* @returns {Array.<number>}
|
|
||||||
*/
|
|
||||||
crypto.randomBytes = function(n) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<string,*>}
|
|
||||||
*/
|
|
||||||
window.crypto = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Uint8Array|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array} array
|
|
||||||
*/
|
|
||||||
window.crypto.getRandomValues = function(array) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} name
|
|
||||||
* @param {function(...[*]):*} constructor
|
|
||||||
*/
|
|
||||||
var define = function(name, constructor) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
define.amd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {...*} var_args
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
String.fromCodePoint = function(var_args) {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} offset
|
|
||||||
* @returns {number}
|
|
||||||
*/
|
|
||||||
String.prototype.codePointAt = function(offset) {};
|
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 2012 Nevins Bartolomeo <nevins.bartolomeo@gmail.com>
|
|
||||||
Copyright (c) 2012 Shane Girish <shaneGirish@gmail.com>
|
|
||||||
Copyright (c) 2013 Daniel Wirtz <dcode@dcode.io>
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions
|
|
||||||
are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
3. The name of the author may not be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = require("./dist/bcrypt.js");
|
|
|
@ -1,94 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "bcryptjs",
|
|
||||||
"_id": "bcryptjs@2.4.3",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms=",
|
|
||||||
"_location": "/bcryptjs",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "bcryptjs",
|
|
||||||
"name": "bcryptjs",
|
|
||||||
"escapedName": "bcryptjs",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
|
|
||||||
"_shasum": "9ab5627b93e60621ff7cdac5da9733027df1d0cb",
|
|
||||||
"_spec": "bcryptjs",
|
|
||||||
"_where": "C:\\Priyathamwork\\locaft\\locaft\\auth",
|
|
||||||
"author": {
|
|
||||||
"name": "Daniel Wirtz",
|
|
||||||
"email": "dcode@dcode.io"
|
|
||||||
},
|
|
||||||
"browser": "dist/bcrypt.js",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/dcodeIO/bcrypt.js/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"contributors": [
|
|
||||||
{
|
|
||||||
"name": "Shane Girish",
|
|
||||||
"email": "shaneGirish@gmail.com",
|
|
||||||
"url": "https://github.com/shaneGirish"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Alex Murray",
|
|
||||||
"url": "https://github.com/alexmurray"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Nicolas Pelletier",
|
|
||||||
"url": "https://github.com/NicolasPelletier"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Josh Rogers",
|
|
||||||
"url": "https://github.com/geekymole"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Noah Isaacson",
|
|
||||||
"email": "noah@nisaacson.com",
|
|
||||||
"url": "https://github.com/nisaacson"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dependencies": {},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.",
|
|
||||||
"devDependencies": {
|
|
||||||
"bcrypt": "latest",
|
|
||||||
"closurecompiler": "~1",
|
|
||||||
"metascript": "~0.18",
|
|
||||||
"testjs": "~1",
|
|
||||||
"utfx": "~1"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/dcodeIO/bcrypt.js#readme",
|
|
||||||
"keywords": [
|
|
||||||
"bcrypt",
|
|
||||||
"password",
|
|
||||||
"auth",
|
|
||||||
"authentication",
|
|
||||||
"encryption",
|
|
||||||
"crypt",
|
|
||||||
"crypto"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "bcryptjs",
|
|
||||||
"repository": {
|
|
||||||
"type": "url",
|
|
||||||
"url": "git+https://github.com/dcodeIO/bcrypt.js.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "node scripts/build.js",
|
|
||||||
"compile": "node node_modules/closurecompiler/bin/ccjs dist/bcrypt.js --compilation_level=SIMPLE_OPTIMIZATIONS --create_source_map=dist/bcrypt.min.map > dist/bcrypt.min.js",
|
|
||||||
"compress": "gzip -c -9 dist/bcrypt.min.js > dist/bcrypt.min.js.gz",
|
|
||||||
"make": "npm run build && npm run compile && npm run compress && npm test",
|
|
||||||
"test": "node node_modules/testjs/bin/testjs"
|
|
||||||
},
|
|
||||||
"version": "2.4.3"
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
var MetaScript = require("metascript"),
|
|
||||||
path = require("path"),
|
|
||||||
fs = require("fs");
|
|
||||||
|
|
||||||
var rootDir = path.join(__dirname, ".."),
|
|
||||||
srcDir = path.join(rootDir, "src"),
|
|
||||||
distDir = path.join(rootDir, "dist"),
|
|
||||||
pkg = require(path.join(rootDir, "package.json")),
|
|
||||||
filename;
|
|
||||||
|
|
||||||
var scope = {
|
|
||||||
VERSION: pkg.version,
|
|
||||||
ISAAC: false
|
|
||||||
};
|
|
||||||
|
|
||||||
// Make standard build
|
|
||||||
console.log("Building bcrypt.js with scope", JSON.stringify(scope, null, 2));
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(distDir, "bcrypt.js"),
|
|
||||||
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Make isaac build - see: https://github.com/dcodeIO/bcrypt.js/issues/16
|
|
||||||
/* scope.ISAAC = true;
|
|
||||||
console.log("Building bcrypt-isaac.js with scope", JSON.stringify(scope, null, 2));
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(distDir, "bcrypt-isaac.js"),
|
|
||||||
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "bcrypt.js")), filename, scope, srcDir)
|
|
||||||
); */
|
|
||||||
|
|
||||||
// Update bower.json
|
|
||||||
scope = { VERSION: pkg.version };
|
|
||||||
console.log("Updating bower.json with scope", JSON.stringify(scope, null, 2));
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(rootDir, "bower.json"),
|
|
||||||
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "bower.json")), filename, scope, srcDir)
|
|
||||||
);
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue