mirror of
https://github.com/viq/NewsBlur.git
synced 2025-04-13 09:38:09 +00:00
Updating node_modules.
This commit is contained in:
parent
6c8097aa05
commit
3df1cbb401
54 changed files with 2724 additions and 1183 deletions
|
@ -52,6 +52,7 @@ frontend public
|
||||||
use_backend node_socket if { path_beg /socket.io/ }
|
use_backend node_socket if { path_beg /socket.io/ }
|
||||||
use_backend node_socket2 if { path_beg /v2/socket.io/ }
|
use_backend node_socket2 if { path_beg /v2/socket.io/ }
|
||||||
use_backend node_favicon if { path_beg /rss_feeds/icon/ }
|
use_backend node_favicon if { path_beg /rss_feeds/icon/ }
|
||||||
|
use_backend node_text if { path_beg /rss_feeds/original_text_fetcher/ }
|
||||||
use_backend nginx if { path_beg /media/ }
|
use_backend nginx if { path_beg /media/ }
|
||||||
use_backend nginx if { path_beg /static/ }
|
use_backend nginx if { path_beg /static/ }
|
||||||
use_backend nginx if { path_beg /favicon }
|
use_backend nginx if { path_beg /favicon }
|
||||||
|
@ -76,6 +77,10 @@ backend node_favicon
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
server nodedebug 127.0.0.1:81 check inter 2000ms
|
server nodedebug 127.0.0.1:81 check inter 2000ms
|
||||||
|
|
||||||
|
backend node_text
|
||||||
|
balance roundrobin
|
||||||
|
server nodedebug 127.0.0.1:4040 check inter 2000ms
|
||||||
|
|
||||||
backend nginx
|
backend nginx
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
option httpchk GET /_nginxchk
|
option httpchk GET /_nginxchk
|
||||||
|
|
|
@ -51,6 +51,7 @@ frontend public
|
||||||
|
|
||||||
use_backend node_socket if { path_beg /v2/socket.io/ }
|
use_backend node_socket if { path_beg /v2/socket.io/ }
|
||||||
use_backend node_favicon if { path_beg /rss_feeds/icon/ }
|
use_backend node_favicon if { path_beg /rss_feeds/icon/ }
|
||||||
|
use_backend node_text if { path_beg /rss_feeds/original_text_fetcher/ }
|
||||||
use_backend nginx if { path_beg /media/ }
|
use_backend nginx if { path_beg /media/ }
|
||||||
use_backend nginx if { path_beg /static/ }
|
use_backend nginx if { path_beg /static/ }
|
||||||
use_backend nginx if { path_beg /favicon }
|
use_backend nginx if { path_beg /favicon }
|
||||||
|
@ -77,7 +78,7 @@ backend node_favicon
|
||||||
|
|
||||||
backend node_text
|
backend node_text
|
||||||
http-check expect rstatus 200|503
|
http-check expect rstatus 200|503
|
||||||
option httpchk GET /rss_feeds/original_text_fetcher
|
option httpchk GET /rss_feeds/original_text_fetcher?test=1
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
{{ node_text }}
|
{{ node_text }}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
[program:node_text]
|
[program:node_text]
|
||||||
command=node node/text_server.js
|
command=node --experimental-modules node/original_text.js
|
||||||
directory=/srv/newsblur
|
directory=/srv/newsblur
|
||||||
environment=NODE_ENV=production
|
environment=NODE_ENV=production
|
||||||
user=sclay
|
user=sclay
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
#redirect_stderr=True
|
#redirect_stderr=True
|
||||||
minfds = 10000
|
|
||||||
priority=991
|
priority=991
|
||||||
stopsignal=HUP
|
stopsignal=HUP
|
||||||
stdout_logfile = /srv/newsblur/logs/text_server.log
|
stdout_logfile = /srv/newsblur/logs/original_text.log
|
||||||
stderr_logfile = /srv/newsblur/logs/error_text_server.log
|
stderr_logfile = /srv/newsblur/logs/error_original_text.log
|
||||||
|
|
7
fabfile.py
vendored
7
fabfile.py
vendored
|
@ -785,13 +785,13 @@ def setup_staging():
|
||||||
run('touch logs/newsblur.log')
|
run('touch logs/newsblur.log')
|
||||||
|
|
||||||
def setup_node_app():
|
def setup_node_app():
|
||||||
sudo('curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -')
|
sudo('curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -')
|
||||||
sudo('apt-get install -y nodejs')
|
sudo('apt-get install -y nodejs')
|
||||||
# run('curl -L https://npmjs.org/install.sh | sudo sh')
|
# run('curl -L https://npmjs.org/install.sh | sudo sh')
|
||||||
# sudo('apt-get install npm')
|
# sudo('apt-get install npm')
|
||||||
sudo('npm install -g supervisor')
|
sudo('npm install -g supervisor')
|
||||||
sudo('npm install -g @postlight/mercury-parser')
|
|
||||||
sudo('ufw allow 8888')
|
sudo('ufw allow 8888')
|
||||||
|
sudo('ufw allow 4040')
|
||||||
|
|
||||||
def config_node():
|
def config_node():
|
||||||
sudo('rm -fr /etc/supervisor/conf.d/node.conf')
|
sudo('rm -fr /etc/supervisor/conf.d/node.conf')
|
||||||
|
@ -863,6 +863,7 @@ def setup_haproxy(debug=False):
|
||||||
if debug:
|
if debug:
|
||||||
put('config/debug_haproxy.conf', '/etc/haproxy/haproxy.cfg', use_sudo=True)
|
put('config/debug_haproxy.conf', '/etc/haproxy/haproxy.cfg', use_sudo=True)
|
||||||
else:
|
else:
|
||||||
|
build_haproxy()
|
||||||
put(os.path.join(env.SECRETS_PATH, 'configs/haproxy.conf'),
|
put(os.path.join(env.SECRETS_PATH, 'configs/haproxy.conf'),
|
||||||
'/etc/haproxy/haproxy.cfg', use_sudo=True)
|
'/etc/haproxy/haproxy.cfg', use_sudo=True)
|
||||||
sudo('echo "ENABLED=1" | sudo tee /etc/default/haproxy')
|
sudo('echo "ENABLED=1" | sudo tee /etc/default/haproxy')
|
||||||
|
@ -874,7 +875,7 @@ def setup_haproxy(debug=False):
|
||||||
sudo('update-rc.d -f haproxy defaults')
|
sudo('update-rc.d -f haproxy defaults')
|
||||||
|
|
||||||
sudo('/etc/init.d/haproxy stop')
|
sudo('/etc/init.d/haproxy stop')
|
||||||
run('sleep 1')
|
run('sleep 5')
|
||||||
sudo('/etc/init.d/haproxy start')
|
sudo('/etc/init.d/haproxy start')
|
||||||
|
|
||||||
def config_haproxy(debug=False):
|
def config_haproxy(debug=False):
|
||||||
|
|
30
node/node_modules/qs/.editorconfig
generated
vendored
Normal file
30
node/node_modules/qs/.editorconfig
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
max_line_length = 160
|
||||||
|
|
||||||
|
[test/*]
|
||||||
|
max_line_length = off
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
|
||||||
|
[*.json]
|
||||||
|
max_line_length = off
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
max_line_length = off
|
||||||
|
|
||||||
|
[CHANGELOG.md]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[LICENSE]
|
||||||
|
indent_size = 2
|
||||||
|
max_line_length = off
|
16
node/node_modules/qs/.eslintrc
generated
vendored
16
node/node_modules/qs/.eslintrc
generated
vendored
|
@ -4,16 +4,18 @@
|
||||||
"extends": "@ljharb",
|
"extends": "@ljharb",
|
||||||
|
|
||||||
"rules": {
|
"rules": {
|
||||||
"complexity": [2, 25],
|
"complexity": 0,
|
||||||
"consistent-return": [1],
|
"consistent-return": 1,
|
||||||
|
"func-name-matching": 0,
|
||||||
"id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
|
"id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
|
||||||
"indent": [2, 4],
|
"indent": [2, 4],
|
||||||
"max-params": [2, 11],
|
"max-lines-per-function": [2, { "max": 150 }],
|
||||||
"max-statements": [2, 42],
|
"max-params": [2, 14],
|
||||||
"no-extra-parens": [1],
|
"max-statements": [2, 52],
|
||||||
"no-continue": [1],
|
"multiline-comment-style": 0,
|
||||||
|
"no-continue": 1,
|
||||||
"no-magic-numbers": 0,
|
"no-magic-numbers": 0,
|
||||||
"no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
|
"no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
|
||||||
"operator-linebreak": 1
|
"operator-linebreak": [2, "before"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
112
node/node_modules/qs/CHANGELOG.md
generated
vendored
112
node/node_modules/qs/CHANGELOG.md
generated
vendored
|
@ -1,3 +1,87 @@
|
||||||
|
## **6.7.0**
|
||||||
|
- [New] `stringify`/`parse`: add `comma` as an `arrayFormat` option (#276, #219)
|
||||||
|
- [Fix] correctly parse nested arrays (#212)
|
||||||
|
- [Fix] `utils.merge`: avoid a crash with a null target and a truthy non-array source, also with an array source
|
||||||
|
- [Robustness] `stringify`: cache `Object.prototype.hasOwnProperty`
|
||||||
|
- [Refactor] `utils`: `isBuffer`: small tweak; add tests
|
||||||
|
- [Refactor] use cached `Array.isArray`
|
||||||
|
- [Refactor] `parse`/`stringify`: make a function to normalize the options
|
||||||
|
- [Refactor] `utils`: reduce observable [[Get]]s
|
||||||
|
- [Refactor] `stringify`/`utils`: cache `Array.isArray`
|
||||||
|
- [Tests] always use `String(x)` over `x.toString()`
|
||||||
|
- [Tests] fix Buffer tests to work in node < 4.5 and node < 5.10
|
||||||
|
- [Tests] temporarily allow coverage to fail
|
||||||
|
|
||||||
|
## **6.6.0**
|
||||||
|
- [New] Add support for iso-8859-1, utf8 "sentinel" and numeric entities (#268)
|
||||||
|
- [New] move two-value combine to a `utils` function (#189)
|
||||||
|
- [Fix] `stringify`: fix a crash with `strictNullHandling` and a custom `filter`/`serializeDate` (#279)
|
||||||
|
- [Fix] when `parseArrays` is false, properly handle keys ending in `[]` (#260)
|
||||||
|
- [Fix] `stringify`: do not crash in an obscure combo of `interpretNumericEntities`, a bad custom `decoder`, & `iso-8859-1`
|
||||||
|
- [Fix] `utils`: `merge`: fix crash when `source` is a truthy primitive & no options are provided
|
||||||
|
- [refactor] `stringify`: Avoid arr = arr.concat(...), push to the existing instance (#269)
|
||||||
|
- [Refactor] `parse`: only need to reassign the var once
|
||||||
|
- [Refactor] `parse`/`stringify`: clean up `charset` options checking; fix defaults
|
||||||
|
- [Refactor] add missing defaults
|
||||||
|
- [Refactor] `parse`: one less `concat` call
|
||||||
|
- [Refactor] `utils`: `compactQueue`: make it explicitly side-effecting
|
||||||
|
- [Dev Deps] update `browserify`, `eslint`, `@ljharb/eslint-config`, `iconv-lite`, `safe-publish-latest`, `tape`
|
||||||
|
- [Tests] up to `node` `v10.10`, `v9.11`, `v8.12`, `v6.14`, `v4.9`; pin included builds to LTS
|
||||||
|
|
||||||
|
## **6.5.2**
|
||||||
|
- [Fix] use `safer-buffer` instead of `Buffer` constructor
|
||||||
|
- [Refactor] utils: `module.exports` one thing, instead of mutating `exports` (#230)
|
||||||
|
- [Dev Deps] update `browserify`, `eslint`, `iconv-lite`, `safer-buffer`, `tape`, `browserify`
|
||||||
|
|
||||||
|
## **6.5.1**
|
||||||
|
- [Fix] Fix parsing & compacting very deep objects (#224)
|
||||||
|
- [Refactor] name utils functions
|
||||||
|
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`
|
||||||
|
- [Tests] up to `node` `v8.4`; use `nvm install-latest-npm` so newer npm doesn’t break older node
|
||||||
|
- [Tests] Use precise dist for Node.js 0.6 runtime (#225)
|
||||||
|
- [Tests] make 0.6 required, now that it’s passing
|
||||||
|
- [Tests] on `node` `v8.2`; fix npm on node 0.6
|
||||||
|
|
||||||
|
## **6.5.0**
|
||||||
|
- [New] add `utils.assign`
|
||||||
|
- [New] pass default encoder/decoder to custom encoder/decoder functions (#206)
|
||||||
|
- [New] `parse`/`stringify`: add `ignoreQueryPrefix`/`addQueryPrefix` options, respectively (#213)
|
||||||
|
- [Fix] Handle stringifying empty objects with addQueryPrefix (#217)
|
||||||
|
- [Fix] do not mutate `options` argument (#207)
|
||||||
|
- [Refactor] `parse`: cache index to reuse in else statement (#182)
|
||||||
|
- [Docs] add various badges to readme (#208)
|
||||||
|
- [Dev Deps] update `eslint`, `browserify`, `iconv-lite`, `tape`
|
||||||
|
- [Tests] up to `node` `v8.1`, `v7.10`, `v6.11`; npm v4.6 breaks on node < v1; npm v5+ breaks on node < v4
|
||||||
|
- [Tests] add `editorconfig-tools`
|
||||||
|
|
||||||
|
## **6.4.0**
|
||||||
|
- [New] `qs.stringify`: add `encodeValuesOnly` option
|
||||||
|
- [Fix] follow `allowPrototypes` option during merge (#201, #201)
|
||||||
|
- [Fix] support keys starting with brackets (#202, #200)
|
||||||
|
- [Fix] chmod a-x
|
||||||
|
- [Dev Deps] update `eslint`
|
||||||
|
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||||
|
- [eslint] reduce warnings
|
||||||
|
|
||||||
|
## **6.3.2**
|
||||||
|
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
||||||
|
- [Dev Deps] update `eslint`
|
||||||
|
- [Fix] chmod a-x
|
||||||
|
- [Fix] support keys starting with brackets (#202, #200)
|
||||||
|
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||||
|
|
||||||
|
## **6.3.1**
|
||||||
|
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!)
|
||||||
|
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `iconv-lite`, `qs-iconv`, `tape`
|
||||||
|
- [Tests] on all node minors; improve test matrix
|
||||||
|
- [Docs] document stringify option `allowDots` (#195)
|
||||||
|
- [Docs] add empty object and array values example (#195)
|
||||||
|
- [Docs] Fix minor inconsistency/typo (#192)
|
||||||
|
- [Docs] document stringify option `sort` (#191)
|
||||||
|
- [Refactor] `stringify`: throw faster with an invalid encoder
|
||||||
|
- [Refactor] remove unnecessary escapes (#184)
|
||||||
|
- Remove contributing.md, since `qs` is no longer part of `hapi` (#183)
|
||||||
|
|
||||||
## **6.3.0**
|
## **6.3.0**
|
||||||
- [New] Add support for RFC 1738 (#174, #173)
|
- [New] Add support for RFC 1738 (#174, #173)
|
||||||
- [New] `stringify`: Add `serializeDate` option to customize Date serialization (#159)
|
- [New] `stringify`: Add `serializeDate` option to customize Date serialization (#159)
|
||||||
|
@ -12,6 +96,15 @@
|
||||||
- [Tests] skip Object.create tests when null objects are not available
|
- [Tests] skip Object.create tests when null objects are not available
|
||||||
- [Tests] Turn on eslint for test files (#175)
|
- [Tests] Turn on eslint for test files (#175)
|
||||||
|
|
||||||
|
## **6.2.3**
|
||||||
|
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
||||||
|
- [Fix] chmod a-x
|
||||||
|
- [Fix] support keys starting with brackets (#202, #200)
|
||||||
|
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||||
|
|
||||||
|
## **6.2.2**
|
||||||
|
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
|
||||||
|
|
||||||
## **6.2.1**
|
## **6.2.1**
|
||||||
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
|
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
|
||||||
- [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call`
|
- [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call`
|
||||||
|
@ -24,11 +117,30 @@
|
||||||
- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
|
- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
|
||||||
- [Fix] fix compacting of nested sparse arrays (#150)
|
- [Fix] fix compacting of nested sparse arrays (#150)
|
||||||
|
|
||||||
|
## **6.1.2
|
||||||
|
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
||||||
|
- [Fix] chmod a-x
|
||||||
|
- [Fix] support keys starting with brackets (#202, #200)
|
||||||
|
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||||
|
|
||||||
|
## **6.1.1**
|
||||||
|
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
|
||||||
|
|
||||||
## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed)
|
## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed)
|
||||||
- [New] allowDots option for `stringify` (#151)
|
- [New] allowDots option for `stringify` (#151)
|
||||||
- [Fix] "sort" option should work at a depth of 3 or more (#151)
|
- [Fix] "sort" option should work at a depth of 3 or more (#151)
|
||||||
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
|
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
|
||||||
|
|
||||||
|
## **6.0.4**
|
||||||
|
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
|
||||||
|
- [Fix] chmod a-x
|
||||||
|
- [Fix] support keys starting with brackets (#202, #200)
|
||||||
|
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
|
||||||
|
|
||||||
|
## **6.0.3**
|
||||||
|
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
|
||||||
|
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
|
||||||
|
|
||||||
## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed)
|
## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed)
|
||||||
- Revert ES6 requirement and restore support for node down to v0.8.
|
- Revert ES6 requirement and restore support for node down to v0.8.
|
||||||
|
|
||||||
|
|
1
node/node_modules/qs/CONTRIBUTING.md
generated
vendored
1
node/node_modules/qs/CONTRIBUTING.md
generated
vendored
|
@ -1 +0,0 @@
|
||||||
Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md).
|
|
186
node/node_modules/qs/Readme.md
generated
vendored
186
node/node_modules/qs/Readme.md
generated
vendored
|
@ -1,9 +1,15 @@
|
||||||
# qs
|
# qs <sup>[![Version Badge][2]][1]</sup>
|
||||||
|
|
||||||
|
[![Build Status][3]][4]
|
||||||
|
[![dependency status][5]][6]
|
||||||
|
[![dev dependency status][7]][8]
|
||||||
|
[![License][license-image]][license-url]
|
||||||
|
[![Downloads][downloads-image]][downloads-url]
|
||||||
|
|
||||||
|
[![npm badge][11]][1]
|
||||||
|
|
||||||
A querystring parsing and stringifying library with some added security.
|
A querystring parsing and stringifying library with some added security.
|
||||||
|
|
||||||
[](http://travis-ci.org/ljharb/qs)
|
|
||||||
|
|
||||||
Lead Maintainer: [Jordan Harband](https://github.com/ljharb)
|
Lead Maintainer: [Jordan Harband](https://github.com/ljharb)
|
||||||
|
|
||||||
The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring).
|
The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring).
|
||||||
|
@ -112,6 +118,13 @@ var limited = qs.parse('a=b&c=d', { parameterLimit: 1 });
|
||||||
assert.deepEqual(limited, { a: 'b' });
|
assert.deepEqual(limited, { a: 'b' });
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To bypass the leading question mark, use `ignoreQueryPrefix`:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var prefixed = qs.parse('?a=b&c=d', { ignoreQueryPrefix: true });
|
||||||
|
assert.deepEqual(prefixed, { a: 'b', c: 'd' });
|
||||||
|
```
|
||||||
|
|
||||||
An optional delimiter can also be passed:
|
An optional delimiter can also be passed:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -133,6 +146,62 @@ var withDots = qs.parse('a.b=c', { allowDots: true });
|
||||||
assert.deepEqual(withDots, { a: { b: 'c' } });
|
assert.deepEqual(withDots, { a: { b: 'c' } });
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you have to deal with legacy browsers or services, there's
|
||||||
|
also support for decoding percent-encoded octets as iso-8859-1:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var oldCharset = qs.parse('a=%A7', { charset: 'iso-8859-1' });
|
||||||
|
assert.deepEqual(oldCharset, { a: '§' });
|
||||||
|
```
|
||||||
|
|
||||||
|
Some services add an initial `utf8=✓` value to forms so that old
|
||||||
|
Internet Explorer versions are more likely to submit the form as
|
||||||
|
utf-8. Additionally, the server can check the value against wrong
|
||||||
|
encodings of the checkmark character and detect that a query string
|
||||||
|
or `application/x-www-form-urlencoded` body was *not* sent as
|
||||||
|
utf-8, eg. if the form had an `accept-charset` parameter or the
|
||||||
|
containing page had a different character set.
|
||||||
|
|
||||||
|
**qs** supports this mechanism via the `charsetSentinel` option.
|
||||||
|
If specified, the `utf8` parameter will be omitted from the
|
||||||
|
returned object. It will be used to switch to `iso-8859-1`/`utf-8`
|
||||||
|
mode depending on how the checkmark is encoded.
|
||||||
|
|
||||||
|
**Important**: When you specify both the `charset` option and the
|
||||||
|
`charsetSentinel` option, the `charset` will be overridden when
|
||||||
|
the request contains a `utf8` parameter from which the actual
|
||||||
|
charset can be deduced. In that sense the `charset` will behave
|
||||||
|
as the default charset rather than the authoritative charset.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var detectedAsUtf8 = qs.parse('utf8=%E2%9C%93&a=%C3%B8', {
|
||||||
|
charset: 'iso-8859-1',
|
||||||
|
charsetSentinel: true
|
||||||
|
});
|
||||||
|
assert.deepEqual(detectedAsUtf8, { a: 'ø' });
|
||||||
|
|
||||||
|
// Browsers encode the checkmark as ✓ when submitting as iso-8859-1:
|
||||||
|
var detectedAsIso8859_1 = qs.parse('utf8=%26%2310003%3B&a=%F8', {
|
||||||
|
charset: 'utf-8',
|
||||||
|
charsetSentinel: true
|
||||||
|
});
|
||||||
|
assert.deepEqual(detectedAsIso8859_1, { a: 'ø' });
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to decode the `&#...;` syntax to the actual character,
|
||||||
|
you can specify the `interpretNumericEntities` option as well:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var detectedAsIso8859_1 = qs.parse('a=%26%239786%3B', {
|
||||||
|
charset: 'iso-8859-1',
|
||||||
|
interpretNumericEntities: true
|
||||||
|
});
|
||||||
|
assert.deepEqual(detectedAsIso8859_1, { a: '☺' });
|
||||||
|
```
|
||||||
|
|
||||||
|
It also works when the charset has been detected in `charsetSentinel`
|
||||||
|
mode.
|
||||||
|
|
||||||
### Parsing Arrays
|
### Parsing Arrays
|
||||||
|
|
||||||
**qs** can also parse arrays using a similar `[]` notation:
|
**qs** can also parse arrays using a similar `[]` notation:
|
||||||
|
@ -169,7 +238,7 @@ assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] });
|
||||||
```
|
```
|
||||||
|
|
||||||
**qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will
|
**qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will
|
||||||
instead be converted to an object with the index as the key:
|
instead be converted to an object with the index as the key. This is needed to handle cases when someone sent, for example, `a[999999999]` and it will take significant time to iterate over this huge array.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var withMaxIndex = qs.parse('a[100]=b');
|
var withMaxIndex = qs.parse('a[100]=b');
|
||||||
|
@ -204,6 +273,13 @@ var arraysOfObjects = qs.parse('a[][b]=c');
|
||||||
assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] });
|
assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] });
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Some people use comma to join array, **qs** can parse it:
|
||||||
|
```javascript
|
||||||
|
var arraysOfObjects = qs.parse('a=b,c', { comma: true })
|
||||||
|
assert.deepEqual(arraysOfObjects, { a: ['b', 'c'] })
|
||||||
|
```
|
||||||
|
(_this cannot convert nested objects, such as `a={b:1},{c:d}`_)
|
||||||
|
|
||||||
### Stringifying
|
### Stringifying
|
||||||
|
|
||||||
[](#preventEval)
|
[](#preventEval)
|
||||||
|
@ -225,6 +301,15 @@ var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false });
|
||||||
assert.equal(unencoded, 'a[b]=c');
|
assert.equal(unencoded, 'a[b]=c');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`:
|
||||||
|
```javascript
|
||||||
|
var encodedValues = qs.stringify(
|
||||||
|
{ a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
|
||||||
|
{ encodeValuesOnly: true }
|
||||||
|
);
|
||||||
|
assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
|
||||||
|
```
|
||||||
|
|
||||||
This encoding can also be replaced by a custom encoding method set as `encoder` option:
|
This encoding can also be replaced by a custom encoding method set as `encoder` option:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -261,7 +346,7 @@ qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false });
|
||||||
// 'a=b&a=c&a=d'
|
// 'a=b&a=c&a=d'
|
||||||
```
|
```
|
||||||
|
|
||||||
You may use the `arrayFormat` option to specify the format of the output array
|
You may use the `arrayFormat` option to specify the format of the output array:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
|
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
|
||||||
|
@ -270,6 +355,22 @@ qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
|
||||||
// 'a[]=b&a[]=c'
|
// 'a[]=b&a[]=c'
|
||||||
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
|
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
|
||||||
// 'a=b&a=c'
|
// 'a=b&a=c'
|
||||||
|
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' })
|
||||||
|
// 'a=b,c'
|
||||||
|
```
|
||||||
|
|
||||||
|
When objects are stringified, by default they use bracket notation:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
qs.stringify({ a: { b: { c: 'd', e: 'f' } } });
|
||||||
|
// 'a[b][c]=d&a[b][e]=f'
|
||||||
|
```
|
||||||
|
|
||||||
|
You may override this to use dot notation by setting the `allowDots` option to `true`:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
qs.stringify({ a: { b: { c: 'd', e: 'f' } } }, { allowDots: true });
|
||||||
|
// 'a.b.c=d&a.b.e=f'
|
||||||
```
|
```
|
||||||
|
|
||||||
Empty strings and null values will omit the value, but the equals sign (=) remains in place:
|
Empty strings and null values will omit the value, but the equals sign (=) remains in place:
|
||||||
|
@ -278,12 +379,28 @@ Empty strings and null values will omit the value, but the equals sign (=) remai
|
||||||
assert.equal(qs.stringify({ a: '' }), 'a=');
|
assert.equal(qs.stringify({ a: '' }), 'a=');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Key with no values (such as an empty object or array) will return nothing:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
assert.equal(qs.stringify({ a: [] }), '');
|
||||||
|
assert.equal(qs.stringify({ a: {} }), '');
|
||||||
|
assert.equal(qs.stringify({ a: [{}] }), '');
|
||||||
|
assert.equal(qs.stringify({ a: { b: []} }), '');
|
||||||
|
assert.equal(qs.stringify({ a: { b: {}} }), '');
|
||||||
|
```
|
||||||
|
|
||||||
Properties that are set to `undefined` will be omitted entirely:
|
Properties that are set to `undefined` will be omitted entirely:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
assert.equal(qs.stringify({ a: null, b: undefined }), 'a=');
|
assert.equal(qs.stringify({ a: null, b: undefined }), 'a=');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The query string may optionally be prepended with a question mark:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
assert.equal(qs.stringify({ a: 'b', c: 'd' }, { addQueryPrefix: true }), '?a=b&c=d');
|
||||||
|
```
|
||||||
|
|
||||||
The delimiter may be overridden with stringify as well:
|
The delimiter may be overridden with stringify as well:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -301,6 +418,15 @@ assert.equal(
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You may use the `sort` option to affect the order of parameter keys:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
function alphabeticalSort(a, b) {
|
||||||
|
return a.localeCompare(b);
|
||||||
|
}
|
||||||
|
assert.equal(qs.stringify({ a: 'c', z: 'y', b : 'f' }, { sort: alphabeticalSort }), 'a=c&b=f&z=y');
|
||||||
|
```
|
||||||
|
|
||||||
Finally, you can use the `filter` option to restrict which keys will be included in the stringified output.
|
Finally, you can use the `filter` option to restrict which keys will be included in the stringified output.
|
||||||
If you pass a function, it will be called for each key to obtain the replacement value. Otherwise, if you
|
If you pass a function, it will be called for each key to obtain the replacement value. Otherwise, if you
|
||||||
pass an array, it will be used to select properties and array indices for stringification:
|
pass an array, it will be used to select properties and array indices for stringification:
|
||||||
|
@ -365,10 +491,40 @@ var nullsSkipped = qs.stringify({ a: 'b', c: null}, { skipNulls: true });
|
||||||
assert.equal(nullsSkipped, 'a=b');
|
assert.equal(nullsSkipped, 'a=b');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you're communicating with legacy systems, you can switch to `iso-8859-1`
|
||||||
|
using the `charset` option:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var iso = qs.stringify({ æ: 'æ' }, { charset: 'iso-8859-1' });
|
||||||
|
assert.equal(iso, '%E6=%E6');
|
||||||
|
```
|
||||||
|
|
||||||
|
Characters that don't exist in `iso-8859-1` will be converted to numeric
|
||||||
|
entities, similar to what browsers do:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var numeric = qs.stringify({ a: '☺' }, { charset: 'iso-8859-1' });
|
||||||
|
assert.equal(numeric, 'a=%26%239786%3B');
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use the `charsetSentinel` option to announce the character by
|
||||||
|
including an `utf8=✓` parameter with the proper encoding if the checkmark,
|
||||||
|
similar to what Ruby on Rails and others do when submitting forms.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var sentinel = qs.stringify({ a: '☺' }, { charsetSentinel: true });
|
||||||
|
assert.equal(sentinel, 'utf8=%E2%9C%93&a=%E2%98%BA');
|
||||||
|
|
||||||
|
var isoSentinel = qs.stringify({ a: 'æ' }, { charsetSentinel: true, charset: 'iso-8859-1' });
|
||||||
|
assert.equal(isoSentinel, 'utf8=%26%2310003%3B&a=%E6');
|
||||||
|
```
|
||||||
|
|
||||||
### Dealing with special character sets
|
### Dealing with special character sets
|
||||||
|
|
||||||
By default the encoding and decoding of characters is done in `utf-8`. If you
|
By default the encoding and decoding of characters is done in `utf-8`,
|
||||||
wish to encode querystrings to a different character set (i.e.
|
and `iso-8859-1` support is also built in via the `charset` parameter.
|
||||||
|
|
||||||
|
If you wish to encode querystrings to a different character set (i.e.
|
||||||
[Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the
|
[Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the
|
||||||
[`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library:
|
[`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library:
|
||||||
|
|
||||||
|
@ -396,3 +552,19 @@ assert.equal(qs.stringify({ a: 'b c' }), 'a=b%20c');
|
||||||
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c');
|
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c');
|
||||||
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c');
|
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
[1]: https://npmjs.org/package/qs
|
||||||
|
[2]: http://versionbadg.es/ljharb/qs.svg
|
||||||
|
[3]: https://api.travis-ci.org/ljharb/qs.svg
|
||||||
|
[4]: https://travis-ci.org/ljharb/qs
|
||||||
|
[5]: https://david-dm.org/ljharb/qs.svg
|
||||||
|
[6]: https://david-dm.org/ljharb/qs
|
||||||
|
[7]: https://david-dm.org/ljharb/qs/dev-status.svg
|
||||||
|
[8]: https://david-dm.org/ljharb/qs?type=dev
|
||||||
|
[9]: https://ci.testling.com/ljharb/qs.png
|
||||||
|
[10]: https://ci.testling.com/ljharb/qs
|
||||||
|
[11]: https://nodei.co/npm/qs.png?downloads=true&stars=true
|
||||||
|
[license-image]: http://img.shields.io/npm/l/qs.svg
|
||||||
|
[license-url]: LICENSE
|
||||||
|
[downloads-image]: http://img.shields.io/npm/dm/qs.svg
|
||||||
|
[downloads-url]: http://npm-stat.com/charts.html?package=qs
|
||||||
|
|
534
node/node_modules/qs/dist/qs.js
generated
vendored
534
node/node_modules/qs/dist/qs.js
generated
vendored
|
@ -1,4 +1,4 @@
|
||||||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var replace = String.prototype.replace;
|
var replace = String.prototype.replace;
|
||||||
|
@ -42,32 +42,87 @@ var defaults = {
|
||||||
allowDots: false,
|
allowDots: false,
|
||||||
allowPrototypes: false,
|
allowPrototypes: false,
|
||||||
arrayLimit: 20,
|
arrayLimit: 20,
|
||||||
|
charset: 'utf-8',
|
||||||
|
charsetSentinel: false,
|
||||||
|
comma: false,
|
||||||
decoder: utils.decode,
|
decoder: utils.decode,
|
||||||
delimiter: '&',
|
delimiter: '&',
|
||||||
depth: 5,
|
depth: 5,
|
||||||
|
ignoreQueryPrefix: false,
|
||||||
|
interpretNumericEntities: false,
|
||||||
parameterLimit: 1000,
|
parameterLimit: 1000,
|
||||||
|
parseArrays: true,
|
||||||
plainObjects: false,
|
plainObjects: false,
|
||||||
strictNullHandling: false
|
strictNullHandling: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var parseValues = function parseValues(str, options) {
|
var interpretNumericEntities = function (str) {
|
||||||
var obj = {};
|
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
||||||
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
|
return String.fromCharCode(parseInt(numberStr, 10));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
for (var i = 0; i < parts.length; ++i) {
|
// This is what browsers will submit when the ✓ character occurs in an
|
||||||
|
// application/x-www-form-urlencoded body and the encoding of the page containing
|
||||||
|
// the form is iso-8859-1, or when the submitted form has an accept-charset
|
||||||
|
// attribute of iso-8859-1. Presumably also with other charsets that do not contain
|
||||||
|
// the ✓ character, such as us-ascii.
|
||||||
|
var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')
|
||||||
|
|
||||||
|
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
|
||||||
|
var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
|
||||||
|
|
||||||
|
var parseValues = function parseQueryStringValues(str, options) {
|
||||||
|
var obj = {};
|
||||||
|
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
||||||
|
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
||||||
|
var parts = cleanStr.split(options.delimiter, limit);
|
||||||
|
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
|
||||||
|
var i;
|
||||||
|
|
||||||
|
var charset = options.charset;
|
||||||
|
if (options.charsetSentinel) {
|
||||||
|
for (i = 0; i < parts.length; ++i) {
|
||||||
|
if (parts[i].indexOf('utf8=') === 0) {
|
||||||
|
if (parts[i] === charsetSentinel) {
|
||||||
|
charset = 'utf-8';
|
||||||
|
} else if (parts[i] === isoSentinel) {
|
||||||
|
charset = 'iso-8859-1';
|
||||||
|
}
|
||||||
|
skipIndex = i;
|
||||||
|
i = parts.length; // The eslint settings do not allow break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < parts.length; ++i) {
|
||||||
|
if (i === skipIndex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var part = parts[i];
|
var part = parts[i];
|
||||||
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
|
|
||||||
|
var bracketEqualsPos = part.indexOf(']=');
|
||||||
|
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
||||||
|
|
||||||
var key, val;
|
var key, val;
|
||||||
if (pos === -1) {
|
if (pos === -1) {
|
||||||
key = options.decoder(part);
|
key = options.decoder(part, defaults.decoder, charset);
|
||||||
val = options.strictNullHandling ? null : '';
|
val = options.strictNullHandling ? null : '';
|
||||||
} else {
|
} else {
|
||||||
key = options.decoder(part.slice(0, pos));
|
key = options.decoder(part.slice(0, pos), defaults.decoder, charset);
|
||||||
val = options.decoder(part.slice(pos + 1));
|
val = options.decoder(part.slice(pos + 1), defaults.decoder, charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
|
||||||
|
val = interpretNumericEntities(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val && options.comma && val.indexOf(',') > -1) {
|
||||||
|
val = val.split(',');
|
||||||
|
}
|
||||||
|
|
||||||
if (has.call(obj, key)) {
|
if (has.call(obj, key)) {
|
||||||
obj[key] = [].concat(obj[key]).concat(val);
|
obj[key] = utils.combine(obj[key], val);
|
||||||
} else {
|
} else {
|
||||||
obj[key] = val;
|
obj[key] = val;
|
||||||
}
|
}
|
||||||
|
@ -76,68 +131,71 @@ var parseValues = function parseValues(str, options) {
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
var parseObject = function parseObject(chain, val, options) {
|
var parseObject = function (chain, val, options) {
|
||||||
if (!chain.length) {
|
var leaf = val;
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
var root = chain.shift();
|
|
||||||
|
|
||||||
|
for (var i = chain.length - 1; i >= 0; --i) {
|
||||||
var obj;
|
var obj;
|
||||||
if (root === '[]') {
|
var root = chain[i];
|
||||||
obj = [];
|
|
||||||
obj = obj.concat(parseObject(chain, val, options));
|
if (root === '[]' && options.parseArrays) {
|
||||||
|
obj = [].concat(leaf);
|
||||||
} else {
|
} else {
|
||||||
obj = options.plainObjects ? Object.create(null) : {};
|
obj = options.plainObjects ? Object.create(null) : {};
|
||||||
var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
|
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
||||||
var index = parseInt(cleanRoot, 10);
|
var index = parseInt(cleanRoot, 10);
|
||||||
if (
|
if (!options.parseArrays && cleanRoot === '') {
|
||||||
!isNaN(index) &&
|
obj = { 0: leaf };
|
||||||
root !== cleanRoot &&
|
} else if (
|
||||||
String(index) === cleanRoot &&
|
!isNaN(index)
|
||||||
index >= 0 &&
|
&& root !== cleanRoot
|
||||||
(options.parseArrays && index <= options.arrayLimit)
|
&& String(index) === cleanRoot
|
||||||
|
&& index >= 0
|
||||||
|
&& (options.parseArrays && index <= options.arrayLimit)
|
||||||
) {
|
) {
|
||||||
obj = [];
|
obj = [];
|
||||||
obj[index] = parseObject(chain, val, options);
|
obj[index] = leaf;
|
||||||
} else {
|
} else {
|
||||||
obj[cleanRoot] = parseObject(chain, val, options);
|
obj[cleanRoot] = leaf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
leaf = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
return leaf;
|
||||||
};
|
};
|
||||||
|
|
||||||
var parseKeys = function parseKeys(givenKey, val, options) {
|
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
|
||||||
if (!givenKey) {
|
if (!givenKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform dot notation to bracket notation
|
// Transform dot notation to bracket notation
|
||||||
var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey;
|
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
||||||
|
|
||||||
// The regex chunks
|
// The regex chunks
|
||||||
|
|
||||||
var parent = /^([^\[\]]*)/;
|
var brackets = /(\[[^[\]]*])/;
|
||||||
var child = /(\[[^\[\]]*\])/g;
|
var child = /(\[[^[\]]*])/g;
|
||||||
|
|
||||||
// Get the parent
|
// Get the parent
|
||||||
|
|
||||||
var segment = parent.exec(key);
|
var segment = brackets.exec(key);
|
||||||
|
var parent = segment ? key.slice(0, segment.index) : key;
|
||||||
|
|
||||||
// Stash the parent if it exists
|
// Stash the parent if it exists
|
||||||
|
|
||||||
var keys = [];
|
var keys = [];
|
||||||
if (segment[1]) {
|
if (parent) {
|
||||||
// If we aren't using plain objects, optionally prefix keys
|
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
|
||||||
// that would overwrite object prototype properties
|
if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
||||||
if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
|
|
||||||
if (!options.allowPrototypes) {
|
if (!options.allowPrototypes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keys.push(segment[1]);
|
keys.push(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through children appending to the array until we hit depth
|
// Loop through children appending to the array until we hit depth
|
||||||
|
@ -145,9 +203,9 @@ var parseKeys = function parseKeys(givenKey, val, options) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
||||||
i += 1;
|
i += 1;
|
||||||
if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) {
|
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
|
||||||
if (!options.allowPrototypes) {
|
if (!options.allowPrototypes) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
keys.push(segment[1]);
|
keys.push(segment[1]);
|
||||||
|
@ -162,23 +220,41 @@ var parseKeys = function parseKeys(givenKey, val, options) {
|
||||||
return parseObject(keys, val, options);
|
return parseObject(keys, val, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = function (str, opts) {
|
var normalizeParseOptions = function normalizeParseOptions(opts) {
|
||||||
var options = opts || {};
|
if (!opts) {
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
|
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
|
||||||
throw new TypeError('Decoder has to be a function.');
|
throw new TypeError('Decoder has to be a function.');
|
||||||
}
|
}
|
||||||
|
|
||||||
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
||||||
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
|
throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');
|
||||||
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
|
}
|
||||||
options.parseArrays = options.parseArrays !== false;
|
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
|
||||||
options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
|
|
||||||
options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
|
return {
|
||||||
options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
||||||
options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
|
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
|
||||||
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
|
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
|
||||||
options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
|
charset: charset,
|
||||||
|
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
||||||
|
comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
|
||||||
|
decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
|
||||||
|
delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
|
||||||
|
depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth,
|
||||||
|
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
|
||||||
|
interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
|
||||||
|
parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
|
||||||
|
parseArrays: opts.parseArrays !== false,
|
||||||
|
plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
|
||||||
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = function (str, opts) {
|
||||||
|
var options = normalizeParseOptions(opts);
|
||||||
|
|
||||||
if (str === '' || str === null || typeof str === 'undefined') {
|
if (str === '' || str === null || typeof str === 'undefined') {
|
||||||
return options.plainObjects ? Object.create(null) : {};
|
return options.plainObjects ? Object.create(null) : {};
|
||||||
|
@ -204,41 +280,75 @@ module.exports = function (str, opts) {
|
||||||
|
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
var formats = require('./formats');
|
var formats = require('./formats');
|
||||||
|
var has = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
var arrayPrefixGenerators = {
|
var arrayPrefixGenerators = {
|
||||||
brackets: function brackets(prefix) {
|
brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
|
||||||
return prefix + '[]';
|
return prefix + '[]';
|
||||||
},
|
},
|
||||||
indices: function indices(prefix, key) {
|
comma: 'comma',
|
||||||
|
indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
|
||||||
return prefix + '[' + key + ']';
|
return prefix + '[' + key + ']';
|
||||||
},
|
},
|
||||||
repeat: function repeat(prefix) {
|
repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var isArray = Array.isArray;
|
||||||
|
var push = Array.prototype.push;
|
||||||
|
var pushToArray = function (arr, valueOrArray) {
|
||||||
|
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
||||||
|
};
|
||||||
|
|
||||||
var toISO = Date.prototype.toISOString;
|
var toISO = Date.prototype.toISOString;
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
|
addQueryPrefix: false,
|
||||||
|
allowDots: false,
|
||||||
|
charset: 'utf-8',
|
||||||
|
charsetSentinel: false,
|
||||||
delimiter: '&',
|
delimiter: '&',
|
||||||
encode: true,
|
encode: true,
|
||||||
encoder: utils.encode,
|
encoder: utils.encode,
|
||||||
serializeDate: function serializeDate(date) {
|
encodeValuesOnly: false,
|
||||||
|
formatter: formats.formatters[formats['default']],
|
||||||
|
// deprecated
|
||||||
|
indices: false,
|
||||||
|
serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching
|
||||||
return toISO.call(date);
|
return toISO.call(date);
|
||||||
},
|
},
|
||||||
skipNulls: false,
|
skipNulls: false,
|
||||||
strictNullHandling: false
|
strictNullHandling: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, formatter) {
|
var stringify = function stringify( // eslint-disable-line func-name-matching
|
||||||
|
object,
|
||||||
|
prefix,
|
||||||
|
generateArrayPrefix,
|
||||||
|
strictNullHandling,
|
||||||
|
skipNulls,
|
||||||
|
encoder,
|
||||||
|
filter,
|
||||||
|
sort,
|
||||||
|
allowDots,
|
||||||
|
serializeDate,
|
||||||
|
formatter,
|
||||||
|
encodeValuesOnly,
|
||||||
|
charset
|
||||||
|
) {
|
||||||
var obj = object;
|
var obj = object;
|
||||||
if (typeof filter === 'function') {
|
if (typeof filter === 'function') {
|
||||||
obj = filter(prefix, obj);
|
obj = filter(prefix, obj);
|
||||||
} else if (obj instanceof Date) {
|
} else if (obj instanceof Date) {
|
||||||
obj = serializeDate(obj);
|
obj = serializeDate(obj);
|
||||||
} else if (obj === null) {
|
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
||||||
|
obj = obj.join(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj === null) {
|
||||||
if (strictNullHandling) {
|
if (strictNullHandling) {
|
||||||
return encoder ? encoder(prefix) : prefix;
|
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = '';
|
obj = '';
|
||||||
|
@ -246,7 +356,8 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
|
|
||||||
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
|
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
|
||||||
if (encoder) {
|
if (encoder) {
|
||||||
return [formatter(encoder(prefix)) + '=' + formatter(encoder(obj))];
|
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset);
|
||||||
|
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset))];
|
||||||
}
|
}
|
||||||
return [formatter(prefix) + '=' + formatter(String(obj))];
|
return [formatter(prefix) + '=' + formatter(String(obj))];
|
||||||
}
|
}
|
||||||
|
@ -258,7 +369,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
}
|
}
|
||||||
|
|
||||||
var objKeys;
|
var objKeys;
|
||||||
if (Array.isArray(filter)) {
|
if (isArray(filter)) {
|
||||||
objKeys = filter;
|
objKeys = filter;
|
||||||
} else {
|
} else {
|
||||||
var keys = Object.keys(obj);
|
var keys = Object.keys(obj);
|
||||||
|
@ -272,10 +383,10 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(obj)) {
|
if (isArray(obj)) {
|
||||||
values = values.concat(stringify(
|
pushToArray(values, stringify(
|
||||||
obj[key],
|
obj[key],
|
||||||
generateArrayPrefix(prefix, key),
|
typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix,
|
||||||
generateArrayPrefix,
|
generateArrayPrefix,
|
||||||
strictNullHandling,
|
strictNullHandling,
|
||||||
skipNulls,
|
skipNulls,
|
||||||
|
@ -284,10 +395,12 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
sort,
|
sort,
|
||||||
allowDots,
|
allowDots,
|
||||||
serializeDate,
|
serializeDate,
|
||||||
formatter
|
formatter,
|
||||||
|
encodeValuesOnly,
|
||||||
|
charset
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
values = values.concat(stringify(
|
pushToArray(values, stringify(
|
||||||
obj[key],
|
obj[key],
|
||||||
prefix + (allowDots ? '.' + key : '[' + key + ']'),
|
prefix + (allowDots ? '.' + key : '[' + key + ']'),
|
||||||
generateArrayPrefix,
|
generateArrayPrefix,
|
||||||
|
@ -298,7 +411,9 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
sort,
|
sort,
|
||||||
allowDots,
|
allowDots,
|
||||||
serializeDate,
|
serializeDate,
|
||||||
formatter
|
formatter,
|
||||||
|
encodeValuesOnly,
|
||||||
|
charset
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,34 +421,63 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
return values;
|
return values;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = function (object, opts) {
|
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
||||||
var obj = object;
|
if (!opts) {
|
||||||
var options = opts || {};
|
return defaults;
|
||||||
var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
|
|
||||||
var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
|
|
||||||
var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
|
|
||||||
var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
|
|
||||||
var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null;
|
|
||||||
var sort = typeof options.sort === 'function' ? options.sort : null;
|
|
||||||
var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
|
|
||||||
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
|
|
||||||
if (typeof options.format === 'undefined') {
|
|
||||||
options.format = formats.default;
|
|
||||||
} else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
|
|
||||||
throw new TypeError('Unknown format option provided.');
|
|
||||||
}
|
}
|
||||||
var formatter = formats.formatters[options.format];
|
|
||||||
var objKeys;
|
|
||||||
var filter;
|
|
||||||
|
|
||||||
if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
|
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
|
||||||
throw new TypeError('Encoder has to be a function.');
|
throw new TypeError('Encoder has to be a function.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var charset = opts.charset || defaults.charset;
|
||||||
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
||||||
|
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
||||||
|
}
|
||||||
|
|
||||||
|
var format = formats['default'];
|
||||||
|
if (typeof opts.format !== 'undefined') {
|
||||||
|
if (!has.call(formats.formatters, opts.format)) {
|
||||||
|
throw new TypeError('Unknown format option provided.');
|
||||||
|
}
|
||||||
|
format = opts.format;
|
||||||
|
}
|
||||||
|
var formatter = formats.formatters[format];
|
||||||
|
|
||||||
|
var filter = defaults.filter;
|
||||||
|
if (typeof opts.filter === 'function' || isArray(opts.filter)) {
|
||||||
|
filter = opts.filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
|
||||||
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
||||||
|
charset: charset,
|
||||||
|
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
||||||
|
delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
|
||||||
|
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
|
||||||
|
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
|
||||||
|
encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
|
||||||
|
filter: filter,
|
||||||
|
formatter: formatter,
|
||||||
|
serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
|
||||||
|
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
|
||||||
|
sort: typeof opts.sort === 'function' ? opts.sort : null,
|
||||||
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = function (object, opts) {
|
||||||
|
var obj = object;
|
||||||
|
var options = normalizeStringifyOptions(opts);
|
||||||
|
|
||||||
|
var objKeys;
|
||||||
|
var filter;
|
||||||
|
|
||||||
if (typeof options.filter === 'function') {
|
if (typeof options.filter === 'function') {
|
||||||
filter = options.filter;
|
filter = options.filter;
|
||||||
obj = filter('', obj);
|
obj = filter('', obj);
|
||||||
} else if (Array.isArray(options.filter)) {
|
} else if (isArray(options.filter)) {
|
||||||
filter = options.filter;
|
filter = options.filter;
|
||||||
objKeys = filter;
|
objKeys = filter;
|
||||||
}
|
}
|
||||||
|
@ -345,10 +489,10 @@ module.exports = function (object, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var arrayFormat;
|
var arrayFormat;
|
||||||
if (options.arrayFormat in arrayPrefixGenerators) {
|
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
|
||||||
arrayFormat = options.arrayFormat;
|
arrayFormat = opts.arrayFormat;
|
||||||
} else if ('indices' in options) {
|
} else if (opts && 'indices' in opts) {
|
||||||
arrayFormat = options.indices ? 'indices' : 'repeat';
|
arrayFormat = opts.indices ? 'indices' : 'repeat';
|
||||||
} else {
|
} else {
|
||||||
arrayFormat = 'indices';
|
arrayFormat = 'indices';
|
||||||
}
|
}
|
||||||
|
@ -359,39 +503,54 @@ module.exports = function (object, opts) {
|
||||||
objKeys = Object.keys(obj);
|
objKeys = Object.keys(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sort) {
|
if (options.sort) {
|
||||||
objKeys.sort(sort);
|
objKeys.sort(options.sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < objKeys.length; ++i) {
|
for (var i = 0; i < objKeys.length; ++i) {
|
||||||
var key = objKeys[i];
|
var key = objKeys[i];
|
||||||
|
|
||||||
if (skipNulls && obj[key] === null) {
|
if (options.skipNulls && obj[key] === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
pushToArray(keys, stringify(
|
||||||
keys = keys.concat(stringify(
|
|
||||||
obj[key],
|
obj[key],
|
||||||
key,
|
key,
|
||||||
generateArrayPrefix,
|
generateArrayPrefix,
|
||||||
strictNullHandling,
|
options.strictNullHandling,
|
||||||
skipNulls,
|
options.skipNulls,
|
||||||
encoder,
|
options.encode ? options.encoder : null,
|
||||||
filter,
|
options.filter,
|
||||||
sort,
|
options.sort,
|
||||||
allowDots,
|
options.allowDots,
|
||||||
serializeDate,
|
options.serializeDate,
|
||||||
formatter
|
options.formatter,
|
||||||
|
options.encodeValuesOnly,
|
||||||
|
options.charset
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return keys.join(delimiter);
|
var joined = keys.join(options.delimiter);
|
||||||
|
var prefix = options.addQueryPrefix === true ? '?' : '';
|
||||||
|
|
||||||
|
if (options.charsetSentinel) {
|
||||||
|
if (options.charset === 'iso-8859-1') {
|
||||||
|
// encodeURIComponent('✓'), the "numeric entity" representation of a checkmark
|
||||||
|
prefix += 'utf8=%26%2310003%3B&';
|
||||||
|
} else {
|
||||||
|
// encodeURIComponent('✓')
|
||||||
|
prefix += 'utf8=%E2%9C%93&';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return joined.length > 0 ? prefix + joined : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
},{"./formats":1,"./utils":5}],5:[function(require,module,exports){
|
},{"./formats":1,"./utils":5}],5:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var has = Object.prototype.hasOwnProperty;
|
var has = Object.prototype.hasOwnProperty;
|
||||||
|
var isArray = Array.isArray;
|
||||||
|
|
||||||
var hexTable = (function () {
|
var hexTable = (function () {
|
||||||
var array = [];
|
var array = [];
|
||||||
|
@ -402,7 +561,26 @@ var hexTable = (function () {
|
||||||
return array;
|
return array;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.arrayToObject = function (source, options) {
|
var compactQueue = function compactQueue(queue) {
|
||||||
|
while (queue.length > 1) {
|
||||||
|
var item = queue.pop();
|
||||||
|
var obj = item.obj[item.prop];
|
||||||
|
|
||||||
|
if (isArray(obj)) {
|
||||||
|
var compacted = [];
|
||||||
|
|
||||||
|
for (var j = 0; j < obj.length; ++j) {
|
||||||
|
if (typeof obj[j] !== 'undefined') {
|
||||||
|
compacted.push(obj[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
item.obj[item.prop] = compacted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var arrayToObject = function arrayToObject(source, options) {
|
||||||
var obj = options && options.plainObjects ? Object.create(null) : {};
|
var obj = options && options.plainObjects ? Object.create(null) : {};
|
||||||
for (var i = 0; i < source.length; ++i) {
|
for (var i = 0; i < source.length; ++i) {
|
||||||
if (typeof source[i] !== 'undefined') {
|
if (typeof source[i] !== 'undefined') {
|
||||||
|
@ -413,16 +591,18 @@ exports.arrayToObject = function (source, options) {
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.merge = function (target, source, options) {
|
var merge = function merge(target, source, options) {
|
||||||
if (!source) {
|
if (!source) {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof source !== 'object') {
|
if (typeof source !== 'object') {
|
||||||
if (Array.isArray(target)) {
|
if (isArray(target)) {
|
||||||
target.push(source);
|
target.push(source);
|
||||||
} else if (typeof target === 'object') {
|
} else if (target && typeof target === 'object') {
|
||||||
|
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
|
||||||
target[source] = true;
|
target[source] = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return [target, source];
|
return [target, source];
|
||||||
}
|
}
|
||||||
|
@ -430,20 +610,21 @@ exports.merge = function (target, source, options) {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof target !== 'object') {
|
if (!target || typeof target !== 'object') {
|
||||||
return [target].concat(source);
|
return [target].concat(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
var mergeTarget = target;
|
var mergeTarget = target;
|
||||||
if (Array.isArray(target) && !Array.isArray(source)) {
|
if (isArray(target) && !isArray(source)) {
|
||||||
mergeTarget = exports.arrayToObject(target, options);
|
mergeTarget = arrayToObject(target, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(target) && Array.isArray(source)) {
|
if (isArray(target) && isArray(source)) {
|
||||||
source.forEach(function (item, i) {
|
source.forEach(function (item, i) {
|
||||||
if (has.call(target, i)) {
|
if (has.call(target, i)) {
|
||||||
if (target[i] && typeof target[i] === 'object') {
|
var targetItem = target[i];
|
||||||
target[i] = exports.merge(target[i], item, options);
|
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
||||||
|
target[i] = merge(targetItem, item, options);
|
||||||
} else {
|
} else {
|
||||||
target.push(item);
|
target.push(item);
|
||||||
}
|
}
|
||||||
|
@ -457,8 +638,8 @@ exports.merge = function (target, source, options) {
|
||||||
return Object.keys(source).reduce(function (acc, key) {
|
return Object.keys(source).reduce(function (acc, key) {
|
||||||
var value = source[key];
|
var value = source[key];
|
||||||
|
|
||||||
if (Object.prototype.hasOwnProperty.call(acc, key)) {
|
if (has.call(acc, key)) {
|
||||||
acc[key] = exports.merge(acc[key], value, options);
|
acc[key] = merge(acc[key], value, options);
|
||||||
} else {
|
} else {
|
||||||
acc[key] = value;
|
acc[key] = value;
|
||||||
}
|
}
|
||||||
|
@ -466,15 +647,28 @@ exports.merge = function (target, source, options) {
|
||||||
}, mergeTarget);
|
}, mergeTarget);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.decode = function (str) {
|
var assign = function assignSingleSource(target, source) {
|
||||||
|
return Object.keys(source).reduce(function (acc, key) {
|
||||||
|
acc[key] = source[key];
|
||||||
|
return acc;
|
||||||
|
}, target);
|
||||||
|
};
|
||||||
|
|
||||||
|
var decode = function (str, decoder, charset) {
|
||||||
|
var strWithoutPlus = str.replace(/\+/g, ' ');
|
||||||
|
if (charset === 'iso-8859-1') {
|
||||||
|
// unescape never throws, no try...catch needed:
|
||||||
|
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
||||||
|
}
|
||||||
|
// utf-8
|
||||||
try {
|
try {
|
||||||
return decodeURIComponent(str.replace(/\+/g, ' '));
|
return decodeURIComponent(strWithoutPlus);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return str;
|
return strWithoutPlus;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.encode = function (str) {
|
var encode = function encode(str, defaultEncoder, charset) {
|
||||||
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
||||||
// It has been adapted here for stricter adherence to RFC 3986
|
// It has been adapted here for stricter adherence to RFC 3986
|
||||||
if (str.length === 0) {
|
if (str.length === 0) {
|
||||||
|
@ -483,18 +677,24 @@ exports.encode = function (str) {
|
||||||
|
|
||||||
var string = typeof str === 'string' ? str : String(str);
|
var string = typeof str === 'string' ? str : String(str);
|
||||||
|
|
||||||
|
if (charset === 'iso-8859-1') {
|
||||||
|
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
||||||
|
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var out = '';
|
var out = '';
|
||||||
for (var i = 0; i < string.length; ++i) {
|
for (var i = 0; i < string.length; ++i) {
|
||||||
var c = string.charCodeAt(i);
|
var c = string.charCodeAt(i);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
c === 0x2D || // -
|
c === 0x2D // -
|
||||||
c === 0x2E || // .
|
|| c === 0x2E // .
|
||||||
c === 0x5F || // _
|
|| c === 0x5F // _
|
||||||
c === 0x7E || // ~
|
|| c === 0x7E // ~
|
||||||
(c >= 0x30 && c <= 0x39) || // 0-9
|
|| (c >= 0x30 && c <= 0x39) // 0-9
|
||||||
(c >= 0x41 && c <= 0x5A) || // a-z
|
|| (c >= 0x41 && c <= 0x5A) // a-z
|
||||||
(c >= 0x61 && c <= 0x7A) // A-Z
|
|| (c >= 0x61 && c <= 0x7A) // A-Z
|
||||||
) {
|
) {
|
||||||
out += string.charAt(i);
|
out += string.charAt(i);
|
||||||
continue;
|
continue;
|
||||||
|
@ -517,58 +717,66 @@ exports.encode = function (str) {
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
||||||
out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)];
|
out += hexTable[0xF0 | (c >> 18)]
|
||||||
|
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
|
||||||
|
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
|
||||||
|
+ hexTable[0x80 | (c & 0x3F)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.compact = function (obj, references) {
|
var compact = function compact(value) {
|
||||||
if (typeof obj !== 'object' || obj === null) {
|
var queue = [{ obj: { o: value }, prop: 'o' }];
|
||||||
return obj;
|
var refs = [];
|
||||||
}
|
|
||||||
|
|
||||||
var refs = references || [];
|
for (var i = 0; i < queue.length; ++i) {
|
||||||
var lookup = refs.indexOf(obj);
|
var item = queue[i];
|
||||||
if (lookup !== -1) {
|
var obj = item.obj[item.prop];
|
||||||
return refs[lookup];
|
|
||||||
}
|
|
||||||
|
|
||||||
refs.push(obj);
|
|
||||||
|
|
||||||
if (Array.isArray(obj)) {
|
|
||||||
var compacted = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < obj.length; ++i) {
|
|
||||||
if (obj[i] && typeof obj[i] === 'object') {
|
|
||||||
compacted.push(exports.compact(obj[i], refs));
|
|
||||||
} else if (typeof obj[i] !== 'undefined') {
|
|
||||||
compacted.push(obj[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return compacted;
|
|
||||||
}
|
|
||||||
|
|
||||||
var keys = Object.keys(obj);
|
var keys = Object.keys(obj);
|
||||||
keys.forEach(function (key) {
|
for (var j = 0; j < keys.length; ++j) {
|
||||||
obj[key] = exports.compact(obj[key], refs);
|
var key = keys[j];
|
||||||
});
|
var val = obj[key];
|
||||||
|
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
||||||
|
queue.push({ obj: obj, prop: key });
|
||||||
|
refs.push(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
compactQueue(queue);
|
||||||
|
|
||||||
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.isRegExp = function (obj) {
|
var isRegExp = function isRegExp(obj) {
|
||||||
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.isBuffer = function (obj) {
|
var isBuffer = function isBuffer(obj) {
|
||||||
if (obj === null || typeof obj === 'undefined') {
|
if (!obj || typeof obj !== 'object') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var combine = function combine(a, b) {
|
||||||
|
return [].concat(a, b);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
arrayToObject: arrayToObject,
|
||||||
|
assign: assign,
|
||||||
|
combine: combine,
|
||||||
|
compact: compact,
|
||||||
|
decode: decode,
|
||||||
|
encode: encode,
|
||||||
|
isBuffer: isBuffer,
|
||||||
|
isRegExp: isRegExp,
|
||||||
|
merge: merge
|
||||||
|
};
|
||||||
|
|
||||||
},{}]},{},[2])(2)
|
},{}]},{},[2])(2)
|
||||||
});
|
});
|
0
node/node_modules/qs/lib/index.js
generated
vendored
Executable file → Normal file
0
node/node_modules/qs/lib/index.js
generated
vendored
Executable file → Normal file
182
node/node_modules/qs/lib/parse.js
generated
vendored
Executable file → Normal file
182
node/node_modules/qs/lib/parse.js
generated
vendored
Executable file → Normal file
|
@ -8,32 +8,87 @@ var defaults = {
|
||||||
allowDots: false,
|
allowDots: false,
|
||||||
allowPrototypes: false,
|
allowPrototypes: false,
|
||||||
arrayLimit: 20,
|
arrayLimit: 20,
|
||||||
|
charset: 'utf-8',
|
||||||
|
charsetSentinel: false,
|
||||||
|
comma: false,
|
||||||
decoder: utils.decode,
|
decoder: utils.decode,
|
||||||
delimiter: '&',
|
delimiter: '&',
|
||||||
depth: 5,
|
depth: 5,
|
||||||
|
ignoreQueryPrefix: false,
|
||||||
|
interpretNumericEntities: false,
|
||||||
parameterLimit: 1000,
|
parameterLimit: 1000,
|
||||||
|
parseArrays: true,
|
||||||
plainObjects: false,
|
plainObjects: false,
|
||||||
strictNullHandling: false
|
strictNullHandling: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var parseValues = function parseValues(str, options) {
|
var interpretNumericEntities = function (str) {
|
||||||
var obj = {};
|
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
||||||
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
|
return String.fromCharCode(parseInt(numberStr, 10));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
for (var i = 0; i < parts.length; ++i) {
|
// This is what browsers will submit when the ✓ character occurs in an
|
||||||
|
// application/x-www-form-urlencoded body and the encoding of the page containing
|
||||||
|
// the form is iso-8859-1, or when the submitted form has an accept-charset
|
||||||
|
// attribute of iso-8859-1. Presumably also with other charsets that do not contain
|
||||||
|
// the ✓ character, such as us-ascii.
|
||||||
|
var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')
|
||||||
|
|
||||||
|
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
|
||||||
|
var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
|
||||||
|
|
||||||
|
var parseValues = function parseQueryStringValues(str, options) {
|
||||||
|
var obj = {};
|
||||||
|
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
||||||
|
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
||||||
|
var parts = cleanStr.split(options.delimiter, limit);
|
||||||
|
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
|
||||||
|
var i;
|
||||||
|
|
||||||
|
var charset = options.charset;
|
||||||
|
if (options.charsetSentinel) {
|
||||||
|
for (i = 0; i < parts.length; ++i) {
|
||||||
|
if (parts[i].indexOf('utf8=') === 0) {
|
||||||
|
if (parts[i] === charsetSentinel) {
|
||||||
|
charset = 'utf-8';
|
||||||
|
} else if (parts[i] === isoSentinel) {
|
||||||
|
charset = 'iso-8859-1';
|
||||||
|
}
|
||||||
|
skipIndex = i;
|
||||||
|
i = parts.length; // The eslint settings do not allow break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < parts.length; ++i) {
|
||||||
|
if (i === skipIndex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var part = parts[i];
|
var part = parts[i];
|
||||||
var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
|
|
||||||
|
var bracketEqualsPos = part.indexOf(']=');
|
||||||
|
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
||||||
|
|
||||||
var key, val;
|
var key, val;
|
||||||
if (pos === -1) {
|
if (pos === -1) {
|
||||||
key = options.decoder(part);
|
key = options.decoder(part, defaults.decoder, charset);
|
||||||
val = options.strictNullHandling ? null : '';
|
val = options.strictNullHandling ? null : '';
|
||||||
} else {
|
} else {
|
||||||
key = options.decoder(part.slice(0, pos));
|
key = options.decoder(part.slice(0, pos), defaults.decoder, charset);
|
||||||
val = options.decoder(part.slice(pos + 1));
|
val = options.decoder(part.slice(pos + 1), defaults.decoder, charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
|
||||||
|
val = interpretNumericEntities(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val && options.comma && val.indexOf(',') > -1) {
|
||||||
|
val = val.split(',');
|
||||||
|
}
|
||||||
|
|
||||||
if (has.call(obj, key)) {
|
if (has.call(obj, key)) {
|
||||||
obj[key] = [].concat(obj[key]).concat(val);
|
obj[key] = utils.combine(obj[key], val);
|
||||||
} else {
|
} else {
|
||||||
obj[key] = val;
|
obj[key] = val;
|
||||||
}
|
}
|
||||||
|
@ -42,68 +97,71 @@ var parseValues = function parseValues(str, options) {
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
var parseObject = function parseObject(chain, val, options) {
|
var parseObject = function (chain, val, options) {
|
||||||
if (!chain.length) {
|
var leaf = val;
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
var root = chain.shift();
|
|
||||||
|
|
||||||
|
for (var i = chain.length - 1; i >= 0; --i) {
|
||||||
var obj;
|
var obj;
|
||||||
if (root === '[]') {
|
var root = chain[i];
|
||||||
obj = [];
|
|
||||||
obj = obj.concat(parseObject(chain, val, options));
|
if (root === '[]' && options.parseArrays) {
|
||||||
|
obj = [].concat(leaf);
|
||||||
} else {
|
} else {
|
||||||
obj = options.plainObjects ? Object.create(null) : {};
|
obj = options.plainObjects ? Object.create(null) : {};
|
||||||
var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
|
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
||||||
var index = parseInt(cleanRoot, 10);
|
var index = parseInt(cleanRoot, 10);
|
||||||
if (
|
if (!options.parseArrays && cleanRoot === '') {
|
||||||
!isNaN(index) &&
|
obj = { 0: leaf };
|
||||||
root !== cleanRoot &&
|
} else if (
|
||||||
String(index) === cleanRoot &&
|
!isNaN(index)
|
||||||
index >= 0 &&
|
&& root !== cleanRoot
|
||||||
(options.parseArrays && index <= options.arrayLimit)
|
&& String(index) === cleanRoot
|
||||||
|
&& index >= 0
|
||||||
|
&& (options.parseArrays && index <= options.arrayLimit)
|
||||||
) {
|
) {
|
||||||
obj = [];
|
obj = [];
|
||||||
obj[index] = parseObject(chain, val, options);
|
obj[index] = leaf;
|
||||||
} else {
|
} else {
|
||||||
obj[cleanRoot] = parseObject(chain, val, options);
|
obj[cleanRoot] = leaf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
leaf = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
return leaf;
|
||||||
};
|
};
|
||||||
|
|
||||||
var parseKeys = function parseKeys(givenKey, val, options) {
|
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
|
||||||
if (!givenKey) {
|
if (!givenKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform dot notation to bracket notation
|
// Transform dot notation to bracket notation
|
||||||
var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey;
|
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
||||||
|
|
||||||
// The regex chunks
|
// The regex chunks
|
||||||
|
|
||||||
var parent = /^([^\[\]]*)/;
|
var brackets = /(\[[^[\]]*])/;
|
||||||
var child = /(\[[^\[\]]*\])/g;
|
var child = /(\[[^[\]]*])/g;
|
||||||
|
|
||||||
// Get the parent
|
// Get the parent
|
||||||
|
|
||||||
var segment = parent.exec(key);
|
var segment = brackets.exec(key);
|
||||||
|
var parent = segment ? key.slice(0, segment.index) : key;
|
||||||
|
|
||||||
// Stash the parent if it exists
|
// Stash the parent if it exists
|
||||||
|
|
||||||
var keys = [];
|
var keys = [];
|
||||||
if (segment[1]) {
|
if (parent) {
|
||||||
// If we aren't using plain objects, optionally prefix keys
|
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
|
||||||
// that would overwrite object prototype properties
|
if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
||||||
if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
|
|
||||||
if (!options.allowPrototypes) {
|
if (!options.allowPrototypes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keys.push(segment[1]);
|
keys.push(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through children appending to the array until we hit depth
|
// Loop through children appending to the array until we hit depth
|
||||||
|
@ -111,9 +169,9 @@ var parseKeys = function parseKeys(givenKey, val, options) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
while ((segment = child.exec(key)) !== null && i < options.depth) {
|
||||||
i += 1;
|
i += 1;
|
||||||
if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) {
|
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
|
||||||
if (!options.allowPrototypes) {
|
if (!options.allowPrototypes) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
keys.push(segment[1]);
|
keys.push(segment[1]);
|
||||||
|
@ -128,23 +186,41 @@ var parseKeys = function parseKeys(givenKey, val, options) {
|
||||||
return parseObject(keys, val, options);
|
return parseObject(keys, val, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = function (str, opts) {
|
var normalizeParseOptions = function normalizeParseOptions(opts) {
|
||||||
var options = opts || {};
|
if (!opts) {
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
|
|
||||||
if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
|
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
|
||||||
throw new TypeError('Decoder has to be a function.');
|
throw new TypeError('Decoder has to be a function.');
|
||||||
}
|
}
|
||||||
|
|
||||||
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
||||||
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
|
throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');
|
||||||
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
|
}
|
||||||
options.parseArrays = options.parseArrays !== false;
|
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
|
||||||
options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
|
|
||||||
options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
|
return {
|
||||||
options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
||||||
options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
|
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
|
||||||
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
|
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
|
||||||
options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
|
charset: charset,
|
||||||
|
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
||||||
|
comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
|
||||||
|
decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
|
||||||
|
delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
|
||||||
|
depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth,
|
||||||
|
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
|
||||||
|
interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
|
||||||
|
parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
|
||||||
|
parseArrays: opts.parseArrays !== false,
|
||||||
|
plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
|
||||||
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = function (str, opts) {
|
||||||
|
var options = normalizeParseOptions(opts);
|
||||||
|
|
||||||
if (str === '' || str === null || typeof str === 'undefined') {
|
if (str === '' || str === null || typeof str === 'undefined') {
|
||||||
return options.plainObjects ? Object.create(null) : {};
|
return options.plainObjects ? Object.create(null) : {};
|
||||||
|
|
188
node/node_modules/qs/lib/stringify.js
generated
vendored
Executable file → Normal file
188
node/node_modules/qs/lib/stringify.js
generated
vendored
Executable file → Normal file
|
@ -2,41 +2,75 @@
|
||||||
|
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
var formats = require('./formats');
|
var formats = require('./formats');
|
||||||
|
var has = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
var arrayPrefixGenerators = {
|
var arrayPrefixGenerators = {
|
||||||
brackets: function brackets(prefix) {
|
brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
|
||||||
return prefix + '[]';
|
return prefix + '[]';
|
||||||
},
|
},
|
||||||
indices: function indices(prefix, key) {
|
comma: 'comma',
|
||||||
|
indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
|
||||||
return prefix + '[' + key + ']';
|
return prefix + '[' + key + ']';
|
||||||
},
|
},
|
||||||
repeat: function repeat(prefix) {
|
repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var isArray = Array.isArray;
|
||||||
|
var push = Array.prototype.push;
|
||||||
|
var pushToArray = function (arr, valueOrArray) {
|
||||||
|
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
||||||
|
};
|
||||||
|
|
||||||
var toISO = Date.prototype.toISOString;
|
var toISO = Date.prototype.toISOString;
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
|
addQueryPrefix: false,
|
||||||
|
allowDots: false,
|
||||||
|
charset: 'utf-8',
|
||||||
|
charsetSentinel: false,
|
||||||
delimiter: '&',
|
delimiter: '&',
|
||||||
encode: true,
|
encode: true,
|
||||||
encoder: utils.encode,
|
encoder: utils.encode,
|
||||||
serializeDate: function serializeDate(date) {
|
encodeValuesOnly: false,
|
||||||
|
formatter: formats.formatters[formats['default']],
|
||||||
|
// deprecated
|
||||||
|
indices: false,
|
||||||
|
serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching
|
||||||
return toISO.call(date);
|
return toISO.call(date);
|
||||||
},
|
},
|
||||||
skipNulls: false,
|
skipNulls: false,
|
||||||
strictNullHandling: false
|
strictNullHandling: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, formatter) {
|
var stringify = function stringify( // eslint-disable-line func-name-matching
|
||||||
|
object,
|
||||||
|
prefix,
|
||||||
|
generateArrayPrefix,
|
||||||
|
strictNullHandling,
|
||||||
|
skipNulls,
|
||||||
|
encoder,
|
||||||
|
filter,
|
||||||
|
sort,
|
||||||
|
allowDots,
|
||||||
|
serializeDate,
|
||||||
|
formatter,
|
||||||
|
encodeValuesOnly,
|
||||||
|
charset
|
||||||
|
) {
|
||||||
var obj = object;
|
var obj = object;
|
||||||
if (typeof filter === 'function') {
|
if (typeof filter === 'function') {
|
||||||
obj = filter(prefix, obj);
|
obj = filter(prefix, obj);
|
||||||
} else if (obj instanceof Date) {
|
} else if (obj instanceof Date) {
|
||||||
obj = serializeDate(obj);
|
obj = serializeDate(obj);
|
||||||
} else if (obj === null) {
|
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
||||||
|
obj = obj.join(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj === null) {
|
||||||
if (strictNullHandling) {
|
if (strictNullHandling) {
|
||||||
return encoder ? encoder(prefix) : prefix;
|
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = '';
|
obj = '';
|
||||||
|
@ -44,7 +78,8 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
|
|
||||||
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
|
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
|
||||||
if (encoder) {
|
if (encoder) {
|
||||||
return [formatter(encoder(prefix)) + '=' + formatter(encoder(obj))];
|
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset);
|
||||||
|
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset))];
|
||||||
}
|
}
|
||||||
return [formatter(prefix) + '=' + formatter(String(obj))];
|
return [formatter(prefix) + '=' + formatter(String(obj))];
|
||||||
}
|
}
|
||||||
|
@ -56,7 +91,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
}
|
}
|
||||||
|
|
||||||
var objKeys;
|
var objKeys;
|
||||||
if (Array.isArray(filter)) {
|
if (isArray(filter)) {
|
||||||
objKeys = filter;
|
objKeys = filter;
|
||||||
} else {
|
} else {
|
||||||
var keys = Object.keys(obj);
|
var keys = Object.keys(obj);
|
||||||
|
@ -70,10 +105,10 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(obj)) {
|
if (isArray(obj)) {
|
||||||
values = values.concat(stringify(
|
pushToArray(values, stringify(
|
||||||
obj[key],
|
obj[key],
|
||||||
generateArrayPrefix(prefix, key),
|
typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix,
|
||||||
generateArrayPrefix,
|
generateArrayPrefix,
|
||||||
strictNullHandling,
|
strictNullHandling,
|
||||||
skipNulls,
|
skipNulls,
|
||||||
|
@ -82,10 +117,12 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
sort,
|
sort,
|
||||||
allowDots,
|
allowDots,
|
||||||
serializeDate,
|
serializeDate,
|
||||||
formatter
|
formatter,
|
||||||
|
encodeValuesOnly,
|
||||||
|
charset
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
values = values.concat(stringify(
|
pushToArray(values, stringify(
|
||||||
obj[key],
|
obj[key],
|
||||||
prefix + (allowDots ? '.' + key : '[' + key + ']'),
|
prefix + (allowDots ? '.' + key : '[' + key + ']'),
|
||||||
generateArrayPrefix,
|
generateArrayPrefix,
|
||||||
|
@ -96,7 +133,9 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
sort,
|
sort,
|
||||||
allowDots,
|
allowDots,
|
||||||
serializeDate,
|
serializeDate,
|
||||||
formatter
|
formatter,
|
||||||
|
encodeValuesOnly,
|
||||||
|
charset
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,34 +143,63 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
|
||||||
return values;
|
return values;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = function (object, opts) {
|
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
||||||
var obj = object;
|
if (!opts) {
|
||||||
var options = opts || {};
|
return defaults;
|
||||||
var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
|
|
||||||
var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
|
|
||||||
var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
|
|
||||||
var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
|
|
||||||
var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null;
|
|
||||||
var sort = typeof options.sort === 'function' ? options.sort : null;
|
|
||||||
var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
|
|
||||||
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
|
|
||||||
if (typeof options.format === 'undefined') {
|
|
||||||
options.format = formats.default;
|
|
||||||
} else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
|
|
||||||
throw new TypeError('Unknown format option provided.');
|
|
||||||
}
|
}
|
||||||
var formatter = formats.formatters[options.format];
|
|
||||||
var objKeys;
|
|
||||||
var filter;
|
|
||||||
|
|
||||||
if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
|
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
|
||||||
throw new TypeError('Encoder has to be a function.');
|
throw new TypeError('Encoder has to be a function.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var charset = opts.charset || defaults.charset;
|
||||||
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
||||||
|
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
||||||
|
}
|
||||||
|
|
||||||
|
var format = formats['default'];
|
||||||
|
if (typeof opts.format !== 'undefined') {
|
||||||
|
if (!has.call(formats.formatters, opts.format)) {
|
||||||
|
throw new TypeError('Unknown format option provided.');
|
||||||
|
}
|
||||||
|
format = opts.format;
|
||||||
|
}
|
||||||
|
var formatter = formats.formatters[format];
|
||||||
|
|
||||||
|
var filter = defaults.filter;
|
||||||
|
if (typeof opts.filter === 'function' || isArray(opts.filter)) {
|
||||||
|
filter = opts.filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
|
||||||
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
||||||
|
charset: charset,
|
||||||
|
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
||||||
|
delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
|
||||||
|
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
|
||||||
|
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
|
||||||
|
encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
|
||||||
|
filter: filter,
|
||||||
|
formatter: formatter,
|
||||||
|
serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
|
||||||
|
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
|
||||||
|
sort: typeof opts.sort === 'function' ? opts.sort : null,
|
||||||
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = function (object, opts) {
|
||||||
|
var obj = object;
|
||||||
|
var options = normalizeStringifyOptions(opts);
|
||||||
|
|
||||||
|
var objKeys;
|
||||||
|
var filter;
|
||||||
|
|
||||||
if (typeof options.filter === 'function') {
|
if (typeof options.filter === 'function') {
|
||||||
filter = options.filter;
|
filter = options.filter;
|
||||||
obj = filter('', obj);
|
obj = filter('', obj);
|
||||||
} else if (Array.isArray(options.filter)) {
|
} else if (isArray(options.filter)) {
|
||||||
filter = options.filter;
|
filter = options.filter;
|
||||||
objKeys = filter;
|
objKeys = filter;
|
||||||
}
|
}
|
||||||
|
@ -143,10 +211,10 @@ module.exports = function (object, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var arrayFormat;
|
var arrayFormat;
|
||||||
if (options.arrayFormat in arrayPrefixGenerators) {
|
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
|
||||||
arrayFormat = options.arrayFormat;
|
arrayFormat = opts.arrayFormat;
|
||||||
} else if ('indices' in options) {
|
} else if (opts && 'indices' in opts) {
|
||||||
arrayFormat = options.indices ? 'indices' : 'repeat';
|
arrayFormat = opts.indices ? 'indices' : 'repeat';
|
||||||
} else {
|
} else {
|
||||||
arrayFormat = 'indices';
|
arrayFormat = 'indices';
|
||||||
}
|
}
|
||||||
|
@ -157,31 +225,45 @@ module.exports = function (object, opts) {
|
||||||
objKeys = Object.keys(obj);
|
objKeys = Object.keys(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sort) {
|
if (options.sort) {
|
||||||
objKeys.sort(sort);
|
objKeys.sort(options.sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < objKeys.length; ++i) {
|
for (var i = 0; i < objKeys.length; ++i) {
|
||||||
var key = objKeys[i];
|
var key = objKeys[i];
|
||||||
|
|
||||||
if (skipNulls && obj[key] === null) {
|
if (options.skipNulls && obj[key] === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
pushToArray(keys, stringify(
|
||||||
keys = keys.concat(stringify(
|
|
||||||
obj[key],
|
obj[key],
|
||||||
key,
|
key,
|
||||||
generateArrayPrefix,
|
generateArrayPrefix,
|
||||||
strictNullHandling,
|
options.strictNullHandling,
|
||||||
skipNulls,
|
options.skipNulls,
|
||||||
encoder,
|
options.encode ? options.encoder : null,
|
||||||
filter,
|
options.filter,
|
||||||
sort,
|
options.sort,
|
||||||
allowDots,
|
options.allowDots,
|
||||||
serializeDate,
|
options.serializeDate,
|
||||||
formatter
|
options.formatter,
|
||||||
|
options.encodeValuesOnly,
|
||||||
|
options.charset
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return keys.join(delimiter);
|
var joined = keys.join(options.delimiter);
|
||||||
|
var prefix = options.addQueryPrefix === true ? '?' : '';
|
||||||
|
|
||||||
|
if (options.charsetSentinel) {
|
||||||
|
if (options.charset === 'iso-8859-1') {
|
||||||
|
// encodeURIComponent('✓'), the "numeric entity" representation of a checkmark
|
||||||
|
prefix += 'utf8=%26%2310003%3B&';
|
||||||
|
} else {
|
||||||
|
// encodeURIComponent('✓')
|
||||||
|
prefix += 'utf8=%E2%9C%93&';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return joined.length > 0 ? prefix + joined : '';
|
||||||
};
|
};
|
||||||
|
|
162
node/node_modules/qs/lib/utils.js
generated
vendored
Executable file → Normal file
162
node/node_modules/qs/lib/utils.js
generated
vendored
Executable file → Normal file
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var has = Object.prototype.hasOwnProperty;
|
var has = Object.prototype.hasOwnProperty;
|
||||||
|
var isArray = Array.isArray;
|
||||||
|
|
||||||
var hexTable = (function () {
|
var hexTable = (function () {
|
||||||
var array = [];
|
var array = [];
|
||||||
|
@ -11,7 +12,26 @@ var hexTable = (function () {
|
||||||
return array;
|
return array;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.arrayToObject = function (source, options) {
|
var compactQueue = function compactQueue(queue) {
|
||||||
|
while (queue.length > 1) {
|
||||||
|
var item = queue.pop();
|
||||||
|
var obj = item.obj[item.prop];
|
||||||
|
|
||||||
|
if (isArray(obj)) {
|
||||||
|
var compacted = [];
|
||||||
|
|
||||||
|
for (var j = 0; j < obj.length; ++j) {
|
||||||
|
if (typeof obj[j] !== 'undefined') {
|
||||||
|
compacted.push(obj[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
item.obj[item.prop] = compacted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var arrayToObject = function arrayToObject(source, options) {
|
||||||
var obj = options && options.plainObjects ? Object.create(null) : {};
|
var obj = options && options.plainObjects ? Object.create(null) : {};
|
||||||
for (var i = 0; i < source.length; ++i) {
|
for (var i = 0; i < source.length; ++i) {
|
||||||
if (typeof source[i] !== 'undefined') {
|
if (typeof source[i] !== 'undefined') {
|
||||||
|
@ -22,16 +42,18 @@ exports.arrayToObject = function (source, options) {
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.merge = function (target, source, options) {
|
var merge = function merge(target, source, options) {
|
||||||
if (!source) {
|
if (!source) {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof source !== 'object') {
|
if (typeof source !== 'object') {
|
||||||
if (Array.isArray(target)) {
|
if (isArray(target)) {
|
||||||
target.push(source);
|
target.push(source);
|
||||||
} else if (typeof target === 'object') {
|
} else if (target && typeof target === 'object') {
|
||||||
|
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
|
||||||
target[source] = true;
|
target[source] = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return [target, source];
|
return [target, source];
|
||||||
}
|
}
|
||||||
|
@ -39,20 +61,21 @@ exports.merge = function (target, source, options) {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof target !== 'object') {
|
if (!target || typeof target !== 'object') {
|
||||||
return [target].concat(source);
|
return [target].concat(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
var mergeTarget = target;
|
var mergeTarget = target;
|
||||||
if (Array.isArray(target) && !Array.isArray(source)) {
|
if (isArray(target) && !isArray(source)) {
|
||||||
mergeTarget = exports.arrayToObject(target, options);
|
mergeTarget = arrayToObject(target, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(target) && Array.isArray(source)) {
|
if (isArray(target) && isArray(source)) {
|
||||||
source.forEach(function (item, i) {
|
source.forEach(function (item, i) {
|
||||||
if (has.call(target, i)) {
|
if (has.call(target, i)) {
|
||||||
if (target[i] && typeof target[i] === 'object') {
|
var targetItem = target[i];
|
||||||
target[i] = exports.merge(target[i], item, options);
|
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
||||||
|
target[i] = merge(targetItem, item, options);
|
||||||
} else {
|
} else {
|
||||||
target.push(item);
|
target.push(item);
|
||||||
}
|
}
|
||||||
|
@ -66,8 +89,8 @@ exports.merge = function (target, source, options) {
|
||||||
return Object.keys(source).reduce(function (acc, key) {
|
return Object.keys(source).reduce(function (acc, key) {
|
||||||
var value = source[key];
|
var value = source[key];
|
||||||
|
|
||||||
if (Object.prototype.hasOwnProperty.call(acc, key)) {
|
if (has.call(acc, key)) {
|
||||||
acc[key] = exports.merge(acc[key], value, options);
|
acc[key] = merge(acc[key], value, options);
|
||||||
} else {
|
} else {
|
||||||
acc[key] = value;
|
acc[key] = value;
|
||||||
}
|
}
|
||||||
|
@ -75,15 +98,28 @@ exports.merge = function (target, source, options) {
|
||||||
}, mergeTarget);
|
}, mergeTarget);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.decode = function (str) {
|
var assign = function assignSingleSource(target, source) {
|
||||||
|
return Object.keys(source).reduce(function (acc, key) {
|
||||||
|
acc[key] = source[key];
|
||||||
|
return acc;
|
||||||
|
}, target);
|
||||||
|
};
|
||||||
|
|
||||||
|
var decode = function (str, decoder, charset) {
|
||||||
|
var strWithoutPlus = str.replace(/\+/g, ' ');
|
||||||
|
if (charset === 'iso-8859-1') {
|
||||||
|
// unescape never throws, no try...catch needed:
|
||||||
|
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
||||||
|
}
|
||||||
|
// utf-8
|
||||||
try {
|
try {
|
||||||
return decodeURIComponent(str.replace(/\+/g, ' '));
|
return decodeURIComponent(strWithoutPlus);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return str;
|
return strWithoutPlus;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.encode = function (str) {
|
var encode = function encode(str, defaultEncoder, charset) {
|
||||||
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
||||||
// It has been adapted here for stricter adherence to RFC 3986
|
// It has been adapted here for stricter adherence to RFC 3986
|
||||||
if (str.length === 0) {
|
if (str.length === 0) {
|
||||||
|
@ -92,18 +128,24 @@ exports.encode = function (str) {
|
||||||
|
|
||||||
var string = typeof str === 'string' ? str : String(str);
|
var string = typeof str === 'string' ? str : String(str);
|
||||||
|
|
||||||
|
if (charset === 'iso-8859-1') {
|
||||||
|
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
||||||
|
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var out = '';
|
var out = '';
|
||||||
for (var i = 0; i < string.length; ++i) {
|
for (var i = 0; i < string.length; ++i) {
|
||||||
var c = string.charCodeAt(i);
|
var c = string.charCodeAt(i);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
c === 0x2D || // -
|
c === 0x2D // -
|
||||||
c === 0x2E || // .
|
|| c === 0x2E // .
|
||||||
c === 0x5F || // _
|
|| c === 0x5F // _
|
||||||
c === 0x7E || // ~
|
|| c === 0x7E // ~
|
||||||
(c >= 0x30 && c <= 0x39) || // 0-9
|
|| (c >= 0x30 && c <= 0x39) // 0-9
|
||||||
(c >= 0x41 && c <= 0x5A) || // a-z
|
|| (c >= 0x41 && c <= 0x5A) // a-z
|
||||||
(c >= 0x61 && c <= 0x7A) // A-Z
|
|| (c >= 0x61 && c <= 0x7A) // A-Z
|
||||||
) {
|
) {
|
||||||
out += string.charAt(i);
|
out += string.charAt(i);
|
||||||
continue;
|
continue;
|
||||||
|
@ -126,55 +168,63 @@ exports.encode = function (str) {
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
||||||
out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)];
|
out += hexTable[0xF0 | (c >> 18)]
|
||||||
|
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
|
||||||
|
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
|
||||||
|
+ hexTable[0x80 | (c & 0x3F)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.compact = function (obj, references) {
|
var compact = function compact(value) {
|
||||||
if (typeof obj !== 'object' || obj === null) {
|
var queue = [{ obj: { o: value }, prop: 'o' }];
|
||||||
return obj;
|
var refs = [];
|
||||||
}
|
|
||||||
|
|
||||||
var refs = references || [];
|
for (var i = 0; i < queue.length; ++i) {
|
||||||
var lookup = refs.indexOf(obj);
|
var item = queue[i];
|
||||||
if (lookup !== -1) {
|
var obj = item.obj[item.prop];
|
||||||
return refs[lookup];
|
|
||||||
}
|
|
||||||
|
|
||||||
refs.push(obj);
|
|
||||||
|
|
||||||
if (Array.isArray(obj)) {
|
|
||||||
var compacted = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < obj.length; ++i) {
|
|
||||||
if (obj[i] && typeof obj[i] === 'object') {
|
|
||||||
compacted.push(exports.compact(obj[i], refs));
|
|
||||||
} else if (typeof obj[i] !== 'undefined') {
|
|
||||||
compacted.push(obj[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return compacted;
|
|
||||||
}
|
|
||||||
|
|
||||||
var keys = Object.keys(obj);
|
var keys = Object.keys(obj);
|
||||||
keys.forEach(function (key) {
|
for (var j = 0; j < keys.length; ++j) {
|
||||||
obj[key] = exports.compact(obj[key], refs);
|
var key = keys[j];
|
||||||
});
|
var val = obj[key];
|
||||||
|
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
||||||
|
queue.push({ obj: obj, prop: key });
|
||||||
|
refs.push(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
compactQueue(queue);
|
||||||
|
|
||||||
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.isRegExp = function (obj) {
|
var isRegExp = function isRegExp(obj) {
|
||||||
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.isBuffer = function (obj) {
|
var isBuffer = function isBuffer(obj) {
|
||||||
if (obj === null || typeof obj === 'undefined') {
|
if (!obj || typeof obj !== 'object') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var combine = function combine(a, b) {
|
||||||
|
return [].concat(a, b);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
arrayToObject: arrayToObject,
|
||||||
|
assign: assign,
|
||||||
|
combine: combine,
|
||||||
|
compact: compact,
|
||||||
|
decode: decode,
|
||||||
|
encode: encode,
|
||||||
|
isBuffer: isBuffer,
|
||||||
|
isRegExp: isRegExp,
|
||||||
|
merge: merge
|
||||||
|
};
|
||||||
|
|
108
node/node_modules/qs/package.json
generated
vendored
108
node/node_modules/qs/package.json
generated
vendored
|
@ -1,53 +1,32 @@
|
||||||
{
|
{
|
||||||
"_args": [
|
"_from": "qs@6.7.0",
|
||||||
[
|
"_id": "qs@6.7.0",
|
||||||
{
|
"_inBundle": false,
|
||||||
"raw": "qs@6.3.0",
|
"_integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==",
|
||||||
"scope": null,
|
|
||||||
"escapedName": "qs",
|
|
||||||
"name": "qs",
|
|
||||||
"rawSpec": "6.3.0",
|
|
||||||
"spec": "6.3.0",
|
|
||||||
"type": "version"
|
|
||||||
},
|
|
||||||
"/Users/sclay/projects/newsblur/node"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "qs@6.3.0",
|
|
||||||
"_id": "qs@6.3.0",
|
|
||||||
"_inCache": true,
|
|
||||||
"_location": "/qs",
|
"_location": "/qs",
|
||||||
"_nodeVersion": "6.6.0",
|
|
||||||
"_npmOperationalInternal": {
|
|
||||||
"host": "packages-16-east.internal.npmjs.com",
|
|
||||||
"tmp": "tmp/qs-6.3.0.tgz_1476663988179_0.7400497454218566"
|
|
||||||
},
|
|
||||||
"_npmUser": {
|
|
||||||
"name": "ljharb",
|
|
||||||
"email": "ljharb@gmail.com"
|
|
||||||
},
|
|
||||||
"_npmVersion": "3.10.3",
|
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
"raw": "qs@6.3.0",
|
"type": "version",
|
||||||
"scope": null,
|
"registry": true,
|
||||||
"escapedName": "qs",
|
"raw": "qs@6.7.0",
|
||||||
"name": "qs",
|
"name": "qs",
|
||||||
"rawSpec": "6.3.0",
|
"escapedName": "qs",
|
||||||
"spec": "6.3.0",
|
"rawSpec": "6.7.0",
|
||||||
"type": "version"
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "6.7.0"
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"#USER"
|
"#USER",
|
||||||
|
"/"
|
||||||
],
|
],
|
||||||
"_resolved": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz",
|
"_resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
|
||||||
"_shasum": "f403b264f23bc01228c74131b407f18d5ea5d442",
|
"_shasum": "41dc1a015e3d581f1621776be31afb2876a9b1bc",
|
||||||
"_shrinkwrap": null,
|
"_spec": "qs@6.7.0",
|
||||||
"_spec": "qs@6.3.0",
|
|
||||||
"_where": "/Users/sclay/projects/newsblur/node",
|
"_where": "/Users/sclay/projects/newsblur/node",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/ljharb/qs/issues"
|
"url": "https://github.com/ljharb/qs/issues"
|
||||||
},
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
"name": "Jordan Harband",
|
"name": "Jordan Harband",
|
||||||
|
@ -56,53 +35,39 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
|
"deprecated": false,
|
||||||
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
|
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ljharb/eslint-config": "^8.0.0",
|
"@ljharb/eslint-config": "^13.1.1",
|
||||||
"browserify": "^13.1.0",
|
"browserify": "^16.2.3",
|
||||||
"covert": "^1.1.0",
|
"covert": "^1.1.1",
|
||||||
"eslint": "^3.8.0",
|
"editorconfig-tools": "^0.1.1",
|
||||||
|
"eslint": "^5.15.3",
|
||||||
"evalmd": "^0.0.17",
|
"evalmd": "^0.0.17",
|
||||||
"iconv-lite": "^0.4.13",
|
"for-each": "^0.3.3",
|
||||||
|
"iconv-lite": "^0.4.24",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"parallelshell": "^2.0.0",
|
"object-inspect": "^1.6.0",
|
||||||
"qs-iconv": "^1.0.3",
|
"qs-iconv": "^1.0.4",
|
||||||
"safe-publish-latest": "^1.1.1",
|
"safe-publish-latest": "^1.1.2",
|
||||||
"tape": "^4.6.2"
|
"safer-buffer": "^2.1.2",
|
||||||
},
|
"tape": "^4.10.1"
|
||||||
"directories": {},
|
|
||||||
"dist": {
|
|
||||||
"shasum": "f403b264f23bc01228c74131b407f18d5ea5d442",
|
|
||||||
"tarball": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.6"
|
"node": ">=0.6"
|
||||||
},
|
},
|
||||||
"gitHead": "8aa9c26f90335b5483a4f456dea9acbada8a881c",
|
|
||||||
"homepage": "https://github.com/ljharb/qs",
|
"homepage": "https://github.com/ljharb/qs",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"querystring",
|
"querystring",
|
||||||
"qs"
|
"qs",
|
||||||
|
"query",
|
||||||
|
"url",
|
||||||
|
"parse",
|
||||||
|
"stringify"
|
||||||
],
|
],
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"maintainers": [
|
|
||||||
{
|
|
||||||
"name": "hueniverse",
|
|
||||||
"email": "eran@hammer.io"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "ljharb",
|
|
||||||
"email": "ljharb@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "nlf",
|
|
||||||
"email": "quitlahok@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "qs",
|
"name": "qs",
|
||||||
"optionalDependencies": {},
|
|
||||||
"readme": "ERROR: No README data found!",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/ljharb/qs.git"
|
"url": "git+https://github.com/ljharb/qs.git"
|
||||||
|
@ -111,11 +76,12 @@
|
||||||
"coverage": "covert test",
|
"coverage": "covert test",
|
||||||
"dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js",
|
"dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js",
|
||||||
"lint": "eslint lib/*.js test/*.js",
|
"lint": "eslint lib/*.js test/*.js",
|
||||||
|
"postlint": "editorconfig-tools check * lib/* test/*",
|
||||||
"prepublish": "safe-publish-latest && npm run dist",
|
"prepublish": "safe-publish-latest && npm run dist",
|
||||||
"pretest": "npm run --silent readme && npm run --silent lint",
|
"pretest": "npm run --silent readme && npm run --silent lint",
|
||||||
"readme": "evalmd README.md",
|
"readme": "evalmd README.md",
|
||||||
"test": "npm run --silent coverage",
|
"test": "npm run --silent coverage",
|
||||||
"tests-only": "node test"
|
"tests-only": "node test"
|
||||||
},
|
},
|
||||||
"version": "6.3.0"
|
"version": "6.7.0"
|
||||||
}
|
}
|
||||||
|
|
10
node/node_modules/qs/test/.eslintrc
generated
vendored
10
node/node_modules/qs/test/.eslintrc
generated
vendored
|
@ -1,9 +1,17 @@
|
||||||
{
|
{
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"array-bracket-newline": 0,
|
||||||
|
"array-element-newline": 0,
|
||||||
|
"consistent-return": 2,
|
||||||
|
"function-paren-newline": 0,
|
||||||
"max-lines": 0,
|
"max-lines": 0,
|
||||||
|
"max-lines-per-function": 0,
|
||||||
"max-nested-callbacks": [2, 3],
|
"max-nested-callbacks": [2, 3],
|
||||||
"max-statements": 0,
|
"max-statements": 0,
|
||||||
|
"no-buffer-constructor": 0,
|
||||||
"no-extend-native": 0,
|
"no-extend-native": 0,
|
||||||
"sort-keys": 1
|
"no-magic-numbers": 0,
|
||||||
|
"object-curly-newline": 0,
|
||||||
|
"sort-keys": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
239
node/node_modules/qs/test/parse.js
generated
vendored
Executable file → Normal file
239
node/node_modules/qs/test/parse.js
generated
vendored
Executable file → Normal file
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
var test = require('tape');
|
var test = require('tape');
|
||||||
var qs = require('../');
|
var qs = require('../');
|
||||||
|
var utils = require('../lib/utils');
|
||||||
var iconv = require('iconv-lite');
|
var iconv = require('iconv-lite');
|
||||||
|
var SaferBuffer = require('safer-buffer').Buffer;
|
||||||
|
|
||||||
test('parse()', function (t) {
|
test('parse()', function (t) {
|
||||||
t.test('parses a simple string', function (st) {
|
t.test('parses a simple string', function (st) {
|
||||||
|
@ -131,9 +133,9 @@ test('parse()', function (t) {
|
||||||
st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } });
|
st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } });
|
||||||
st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] });
|
st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] });
|
||||||
|
|
||||||
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', c: true, t: 'u' } });
|
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', t: 'u' } });
|
||||||
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { 0: 'b', t: 'u', hasOwnProperty: 'c' } });
|
st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { 0: 'b', t: 'u', hasOwnProperty: 'c' } });
|
||||||
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { 0: 'b', 1: 'c', x: 'y' } });
|
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { 0: 'b', x: 'y' } });
|
||||||
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { 0: 'b', hasOwnProperty: 'c', x: 'y' } });
|
st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { 0: 'b', hasOwnProperty: 'c', x: 'y' } });
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
@ -152,8 +154,6 @@ test('parse()', function (t) {
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
t.deepEqual(qs.parse('a[b]=c&a=d'), { a: { b: 'c', d: true } }, 'can add keys to objects');
|
|
||||||
|
|
||||||
t.test('correctly prunes undefined values when converting an array to an object', function (st) {
|
t.test('correctly prunes undefined values when converting an array to an object', function (st) {
|
||||||
st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } });
|
st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } });
|
||||||
st.end();
|
st.end();
|
||||||
|
@ -232,11 +232,19 @@ test('parse()', function (t) {
|
||||||
});
|
});
|
||||||
|
|
||||||
t.test('parses buffers correctly', function (st) {
|
t.test('parses buffers correctly', function (st) {
|
||||||
var b = new Buffer('test');
|
var b = SaferBuffer.from('test');
|
||||||
st.deepEqual(qs.parse({ a: b }), { a: b });
|
st.deepEqual(qs.parse({ a: b }), { a: b });
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('parses jquery-param strings', function (st) {
|
||||||
|
// readable = 'filter[0][]=int1&filter[0][]==&filter[0][]=77&filter[]=and&filter[2][]=int2&filter[2][]==&filter[2][]=8'
|
||||||
|
var encoded = 'filter%5B0%5D%5B%5D=int1&filter%5B0%5D%5B%5D=%3D&filter%5B0%5D%5B%5D=77&filter%5B%5D=and&filter%5B2%5D%5B%5D=int2&filter%5B2%5D%5B%5D=%3D&filter%5B2%5D%5B%5D=8';
|
||||||
|
var expected = { filter: [['int1', '=', '77'], 'and', ['int2', '=', '8']] };
|
||||||
|
st.deepEqual(qs.parse(encoded), expected);
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
t.test('continues parsing when no parent is found', function (st) {
|
t.test('continues parsing when no parent is found', function (st) {
|
||||||
st.deepEqual(qs.parse('[]=&a=b'), { 0: '', a: 'b' });
|
st.deepEqual(qs.parse('[]=&a=b'), { 0: '', a: 'b' });
|
||||||
st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { 0: null, a: 'b' });
|
st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { 0: null, a: 'b' });
|
||||||
|
@ -257,7 +265,7 @@ test('parse()', function (t) {
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
t.test('should not throw when a native prototype has an enumerable property', { parallel: false }, function (st) {
|
t.test('should not throw when a native prototype has an enumerable property', function (st) {
|
||||||
Object.prototype.crash = '';
|
Object.prototype.crash = '';
|
||||||
Array.prototype.crash = '';
|
Array.prototype.crash = '';
|
||||||
st.doesNotThrow(qs.parse.bind(null, 'a=b'));
|
st.doesNotThrow(qs.parse.bind(null, 'a=b'));
|
||||||
|
@ -302,7 +310,21 @@ test('parse()', function (t) {
|
||||||
});
|
});
|
||||||
|
|
||||||
t.test('allows disabling array parsing', function (st) {
|
t.test('allows disabling array parsing', function (st) {
|
||||||
st.deepEqual(qs.parse('a[0]=b&a[1]=c', { parseArrays: false }), { a: { 0: 'b', 1: 'c' } });
|
var indices = qs.parse('a[0]=b&a[1]=c', { parseArrays: false });
|
||||||
|
st.deepEqual(indices, { a: { 0: 'b', 1: 'c' } });
|
||||||
|
st.equal(Array.isArray(indices.a), false, 'parseArrays:false, indices case is not an array');
|
||||||
|
|
||||||
|
var emptyBrackets = qs.parse('a[]=b', { parseArrays: false });
|
||||||
|
st.deepEqual(emptyBrackets, { a: { 0: 'b' } });
|
||||||
|
st.equal(Array.isArray(emptyBrackets.a), false, 'parseArrays:false, empty brackets case is not an array');
|
||||||
|
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('allows for query string prefix', function (st) {
|
||||||
|
st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
|
||||||
|
st.deepEqual(qs.parse('foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
|
||||||
|
st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: false }), { '?foo': 'bar' });
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -325,6 +347,15 @@ test('parse()', function (t) {
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('parses string with comma as array divider', function (st) {
|
||||||
|
st.deepEqual(qs.parse('foo=bar,tee', { comma: true }), { foo: ['bar', 'tee'] });
|
||||||
|
st.deepEqual(qs.parse('foo[bar]=coffee,tee', { comma: true }), { foo: { bar: ['coffee', 'tee'] } });
|
||||||
|
st.deepEqual(qs.parse('foo=', { comma: true }), { foo: '' });
|
||||||
|
st.deepEqual(qs.parse('foo', { comma: true }), { foo: '' });
|
||||||
|
st.deepEqual(qs.parse('foo', { comma: true, strictNullHandling: true }), { foo: null });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
t.test('parses an object in dot notation', function (st) {
|
t.test('parses an object in dot notation', function (st) {
|
||||||
var input = {
|
var input = {
|
||||||
'user.name': { 'pop[bob]': 3 },
|
'user.name': { 'pop[bob]': 3 },
|
||||||
|
@ -390,6 +421,33 @@ test('parse()', function (t) {
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('does not crash when parsing deep objects', function (st) {
|
||||||
|
var parsed;
|
||||||
|
var str = 'foo';
|
||||||
|
|
||||||
|
for (var i = 0; i < 5000; i++) {
|
||||||
|
str += '[p]';
|
||||||
|
}
|
||||||
|
|
||||||
|
str += '=bar';
|
||||||
|
|
||||||
|
st.doesNotThrow(function () {
|
||||||
|
parsed = qs.parse(str, { depth: 5000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
st.equal('foo' in parsed, true, 'parsed has "foo" property');
|
||||||
|
|
||||||
|
var depth = 0;
|
||||||
|
var ref = parsed.foo;
|
||||||
|
while ((ref = ref.p)) {
|
||||||
|
depth += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
st.equal(depth, 5000, 'parsed is 5000 properties deep');
|
||||||
|
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
t.test('parses null objects correctly', { skip: !Object.create }, function (st) {
|
t.test('parses null objects correctly', { skip: !Object.create }, function (st) {
|
||||||
var a = Object.create(null);
|
var a = Object.create(null);
|
||||||
a.b = 'c';
|
a.b = 'c';
|
||||||
|
@ -413,9 +471,71 @@ test('parse()', function (t) {
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('does not allow overwriting prototype properties', function (st) {
|
||||||
|
st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: false }), {});
|
||||||
|
st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: false }), {});
|
||||||
|
|
||||||
|
st.deepEqual(
|
||||||
|
qs.parse('toString', { allowPrototypes: false }),
|
||||||
|
{},
|
||||||
|
'bare "toString" results in {}'
|
||||||
|
);
|
||||||
|
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
t.test('can allow overwriting prototype properties', function (st) {
|
t.test('can allow overwriting prototype properties', function (st) {
|
||||||
st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } }, { prototype: false });
|
st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } });
|
||||||
st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' }, { prototype: false });
|
st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' });
|
||||||
|
|
||||||
|
st.deepEqual(
|
||||||
|
qs.parse('toString', { allowPrototypes: true }),
|
||||||
|
{ toString: '' },
|
||||||
|
'bare "toString" results in { toString: "" }'
|
||||||
|
);
|
||||||
|
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('params starting with a closing bracket', function (st) {
|
||||||
|
st.deepEqual(qs.parse(']=toString'), { ']': 'toString' });
|
||||||
|
st.deepEqual(qs.parse(']]=toString'), { ']]': 'toString' });
|
||||||
|
st.deepEqual(qs.parse(']hello]=toString'), { ']hello]': 'toString' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('params starting with a starting bracket', function (st) {
|
||||||
|
st.deepEqual(qs.parse('[=toString'), { '[': 'toString' });
|
||||||
|
st.deepEqual(qs.parse('[[=toString'), { '[[': 'toString' });
|
||||||
|
st.deepEqual(qs.parse('[hello[=toString'), { '[hello[': 'toString' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('add keys to objects', function (st) {
|
||||||
|
st.deepEqual(
|
||||||
|
qs.parse('a[b]=c&a=d'),
|
||||||
|
{ a: { b: 'c', d: true } },
|
||||||
|
'can add keys to objects'
|
||||||
|
);
|
||||||
|
|
||||||
|
st.deepEqual(
|
||||||
|
qs.parse('a[b]=c&a=toString'),
|
||||||
|
{ a: { b: 'c' } },
|
||||||
|
'can not overwrite prototype'
|
||||||
|
);
|
||||||
|
|
||||||
|
st.deepEqual(
|
||||||
|
qs.parse('a[b]=c&a=toString', { allowPrototypes: true }),
|
||||||
|
{ a: { b: 'c', toString: true } },
|
||||||
|
'can overwrite prototype with allowPrototypes true'
|
||||||
|
);
|
||||||
|
|
||||||
|
st.deepEqual(
|
||||||
|
qs.parse('a[b]=c&a=toString', { plainObjects: true }),
|
||||||
|
{ a: { b: 'c', toString: true } },
|
||||||
|
'can overwrite prototype with plainObjects true'
|
||||||
|
);
|
||||||
|
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -444,16 +564,113 @@ test('parse()', function (t) {
|
||||||
result.push(parseInt(parts[1], 16));
|
result.push(parseInt(parts[1], 16));
|
||||||
parts = reg.exec(str);
|
parts = reg.exec(str);
|
||||||
}
|
}
|
||||||
return iconv.decode(new Buffer(result), 'shift_jis').toString();
|
return String(iconv.decode(SaferBuffer.from(result), 'shift_jis'));
|
||||||
}
|
}
|
||||||
}), { 県: '大阪府' });
|
}), { 県: '大阪府' });
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('receives the default decoder as a second argument', function (st) {
|
||||||
|
st.plan(1);
|
||||||
|
qs.parse('a', {
|
||||||
|
decoder: function (str, defaultDecoder) {
|
||||||
|
st.equal(defaultDecoder, utils.decode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
t.test('throws error with wrong decoder', function (st) {
|
t.test('throws error with wrong decoder', function (st) {
|
||||||
st.throws(function () {
|
st['throws'](function () {
|
||||||
qs.parse({}, { decoder: 'string' });
|
qs.parse({}, { decoder: 'string' });
|
||||||
}, new TypeError('Decoder has to be a function.'));
|
}, new TypeError('Decoder has to be a function.'));
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('does not mutate the options argument', function (st) {
|
||||||
|
var options = {};
|
||||||
|
qs.parse('a[b]=true', options);
|
||||||
|
st.deepEqual(options, {});
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('throws if an invalid charset is specified', function (st) {
|
||||||
|
st['throws'](function () {
|
||||||
|
qs.parse('a=b', { charset: 'foobar' });
|
||||||
|
}, new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'));
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('parses an iso-8859-1 string if asked to', function (st) {
|
||||||
|
st.deepEqual(qs.parse('%A2=%BD', { charset: 'iso-8859-1' }), { '¢': '½' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
var urlEncodedCheckmarkInUtf8 = '%E2%9C%93';
|
||||||
|
var urlEncodedOSlashInUtf8 = '%C3%B8';
|
||||||
|
var urlEncodedNumCheckmark = '%26%2310003%3B';
|
||||||
|
var urlEncodedNumSmiley = '%26%239786%3B';
|
||||||
|
|
||||||
|
t.test('prefers an utf-8 charset specified by the utf8 sentinel to a default charset of iso-8859-1', function (st) {
|
||||||
|
st.deepEqual(qs.parse('utf8=' + urlEncodedCheckmarkInUtf8 + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'iso-8859-1' }), { ø: 'ø' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('prefers an iso-8859-1 charset specified by the utf8 sentinel to a default charset of utf-8', function (st) {
|
||||||
|
st.deepEqual(qs.parse('utf8=' + urlEncodedNumCheckmark + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'utf-8' }), { 'ø': 'ø' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('does not require the utf8 sentinel to be defined before the parameters whose decoding it affects', function (st) {
|
||||||
|
st.deepEqual(qs.parse('a=' + urlEncodedOSlashInUtf8 + '&utf8=' + urlEncodedNumCheckmark, { charsetSentinel: true, charset: 'utf-8' }), { a: 'ø' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('should ignore an utf8 sentinel with an unknown value', function (st) {
|
||||||
|
st.deepEqual(qs.parse('utf8=foo&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'utf-8' }), { ø: 'ø' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('uses the utf8 sentinel to switch to utf-8 when no default charset is given', function (st) {
|
||||||
|
st.deepEqual(qs.parse('utf8=' + urlEncodedCheckmarkInUtf8 + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true }), { ø: 'ø' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('uses the utf8 sentinel to switch to iso-8859-1 when no default charset is given', function (st) {
|
||||||
|
st.deepEqual(qs.parse('utf8=' + urlEncodedNumCheckmark + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true }), { 'ø': 'ø' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('interprets numeric entities in iso-8859-1 when `interpretNumericEntities`', function (st) {
|
||||||
|
st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'iso-8859-1', interpretNumericEntities: true }), { foo: '☺' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('handles a custom decoder returning `null`, in the `iso-8859-1` charset, when `interpretNumericEntities`', function (st) {
|
||||||
|
st.deepEqual(qs.parse('foo=&bar=' + urlEncodedNumSmiley, {
|
||||||
|
charset: 'iso-8859-1',
|
||||||
|
decoder: function (str, defaultDecoder, charset) {
|
||||||
|
return str ? defaultDecoder(str, defaultDecoder, charset) : null;
|
||||||
|
},
|
||||||
|
interpretNumericEntities: true
|
||||||
|
}), { foo: null, bar: '☺' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('does not interpret numeric entities in iso-8859-1 when `interpretNumericEntities` is absent', function (st) {
|
||||||
|
st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'iso-8859-1' }), { foo: '☺' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('does not interpret numeric entities when the charset is utf-8, even when `interpretNumericEntities`', function (st) {
|
||||||
|
st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'utf-8', interpretNumericEntities: true }), { foo: '☺' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('does not interpret %uXXXX syntax in iso-8859-1 mode', function (st) {
|
||||||
|
st.deepEqual(qs.parse('%u263A=%u263A', { charset: 'iso-8859-1' }), { '%u263A': '%u263A' });
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
159
node/node_modules/qs/test/stringify.js
generated
vendored
Executable file → Normal file
159
node/node_modules/qs/test/stringify.js
generated
vendored
Executable file → Normal file
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
var test = require('tape');
|
var test = require('tape');
|
||||||
var qs = require('../');
|
var qs = require('../');
|
||||||
|
var utils = require('../lib/utils');
|
||||||
var iconv = require('iconv-lite');
|
var iconv = require('iconv-lite');
|
||||||
|
var SaferBuffer = require('safer-buffer').Buffer;
|
||||||
|
|
||||||
test('stringify()', function (t) {
|
test('stringify()', function (t) {
|
||||||
t.test('stringifies a querystring object', function (st) {
|
t.test('stringifies a querystring object', function (st) {
|
||||||
|
@ -17,6 +19,32 @@ test('stringify()', function (t) {
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('stringifies falsy values', function (st) {
|
||||||
|
st.equal(qs.stringify(undefined), '');
|
||||||
|
st.equal(qs.stringify(null), '');
|
||||||
|
st.equal(qs.stringify(null, { strictNullHandling: true }), '');
|
||||||
|
st.equal(qs.stringify(false), '');
|
||||||
|
st.equal(qs.stringify(0), '');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('adds query prefix', function (st) {
|
||||||
|
st.equal(qs.stringify({ a: 'b' }, { addQueryPrefix: true }), '?a=b');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('with query prefix, outputs blank string given an empty object', function (st) {
|
||||||
|
st.equal(qs.stringify({}, { addQueryPrefix: true }), '');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('stringifies nested falsy values', function (st) {
|
||||||
|
st.equal(qs.stringify({ a: { b: { c: null } } }), 'a%5Bb%5D%5Bc%5D=');
|
||||||
|
st.equal(qs.stringify({ a: { b: { c: null } } }, { strictNullHandling: true }), 'a%5Bb%5D%5Bc%5D');
|
||||||
|
st.equal(qs.stringify({ a: { b: { c: false } } }), 'a%5Bb%5D%5Bc%5D=false');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
t.test('stringifies a nested object', function (st) {
|
t.test('stringifies a nested object', function (st) {
|
||||||
st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c');
|
st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c');
|
||||||
st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e');
|
st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e');
|
||||||
|
@ -40,6 +68,11 @@ test('stringify()', function (t) {
|
||||||
'a%5B%5D=b&a%5B%5D=c&a%5B%5D=d',
|
'a%5B%5D=b&a%5B%5D=c&a%5B%5D=d',
|
||||||
'brackets => brackets'
|
'brackets => brackets'
|
||||||
);
|
);
|
||||||
|
st.equal(
|
||||||
|
qs.stringify({ a: ['b', 'c', 'd'] }, { arrayFormat: 'comma' }),
|
||||||
|
'a=b%2Cc%2Cd',
|
||||||
|
'comma => comma'
|
||||||
|
);
|
||||||
st.equal(
|
st.equal(
|
||||||
qs.stringify({ a: ['b', 'c', 'd'] }),
|
qs.stringify({ a: ['b', 'c', 'd'] }),
|
||||||
'a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d',
|
'a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d',
|
||||||
|
@ -66,6 +99,7 @@ test('stringify()', function (t) {
|
||||||
t.test('stringifies a nested array value', function (st) {
|
t.test('stringifies a nested array value', function (st) {
|
||||||
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { arrayFormat: 'indices' }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d');
|
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { arrayFormat: 'indices' }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d');
|
||||||
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { arrayFormat: 'brackets' }), 'a%5Bb%5D%5B%5D=c&a%5Bb%5D%5B%5D=d');
|
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { arrayFormat: 'brackets' }), 'a%5Bb%5D%5B%5D=c&a%5Bb%5D%5B%5D=d');
|
||||||
|
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { arrayFormat: 'comma' }), 'a%5Bb%5D=c%2Cd'); // a[b]=c,d
|
||||||
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d');
|
st.equal(qs.stringify({ a: { b: ['c', 'd'] } }), 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d');
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
@ -87,6 +121,14 @@ test('stringify()', function (t) {
|
||||||
'a.b[]=c&a.b[]=d',
|
'a.b[]=c&a.b[]=d',
|
||||||
'brackets: stringifies with dots + brackets'
|
'brackets: stringifies with dots + brackets'
|
||||||
);
|
);
|
||||||
|
st.equal(
|
||||||
|
qs.stringify(
|
||||||
|
{ a: { b: ['c', 'd'] } },
|
||||||
|
{ allowDots: true, encode: false, arrayFormat: 'comma' }
|
||||||
|
),
|
||||||
|
'a.b=c,d',
|
||||||
|
'comma: stringifies with dots + comma'
|
||||||
|
);
|
||||||
st.equal(
|
st.equal(
|
||||||
qs.stringify(
|
qs.stringify(
|
||||||
{ a: { b: ['c', 'd'] } },
|
{ a: { b: ['c', 'd'] } },
|
||||||
|
@ -101,12 +143,12 @@ test('stringify()', function (t) {
|
||||||
t.test('stringifies an object inside an array', function (st) {
|
t.test('stringifies an object inside an array', function (st) {
|
||||||
st.equal(
|
st.equal(
|
||||||
qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'indices' }),
|
qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'indices' }),
|
||||||
'a%5B0%5D%5Bb%5D=c',
|
'a%5B0%5D%5Bb%5D=c', // a[0][b]=c
|
||||||
'indices => brackets'
|
'indices => brackets'
|
||||||
);
|
);
|
||||||
st.equal(
|
st.equal(
|
||||||
qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'brackets' }),
|
qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'brackets' }),
|
||||||
'a%5B%5D%5Bb%5D=c',
|
'a%5B%5D%5Bb%5D=c', // a[][b]=c
|
||||||
'brackets => brackets'
|
'brackets => brackets'
|
||||||
);
|
);
|
||||||
st.equal(
|
st.equal(
|
||||||
|
@ -325,8 +367,8 @@ test('stringify()', function (t) {
|
||||||
});
|
});
|
||||||
|
|
||||||
t.test('stringifies buffer values', function (st) {
|
t.test('stringifies buffer values', function (st) {
|
||||||
st.equal(qs.stringify({ a: new Buffer('test') }), 'a=test');
|
st.equal(qs.stringify({ a: SaferBuffer.from('test') }), 'a=test');
|
||||||
st.equal(qs.stringify({ a: { b: new Buffer('test') } }), 'a%5Bb%5D=test');
|
st.equal(qs.stringify({ a: { b: SaferBuffer.from('test') } }), 'a%5Bb%5D=test');
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -385,7 +427,7 @@ test('stringify()', function (t) {
|
||||||
st.equal(prefix, '', 'prefix is empty');
|
st.equal(prefix, '', 'prefix is empty');
|
||||||
st.equal(value, obj);
|
st.equal(value, obj);
|
||||||
} else if (prefix === 'c') {
|
} else if (prefix === 'c') {
|
||||||
return;
|
return void 0;
|
||||||
} else if (value instanceof Date) {
|
} else if (value instanceof Date) {
|
||||||
st.equal(prefix, 'e[f]');
|
st.equal(prefix, 'e[f]');
|
||||||
return value.getTime();
|
return value.getTime();
|
||||||
|
@ -452,15 +494,25 @@ test('stringify()', function (t) {
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('receives the default encoder as a second argument', function (st) {
|
||||||
|
st.plan(2);
|
||||||
|
qs.stringify({ a: 1 }, {
|
||||||
|
encoder: function (str, defaultEncoder) {
|
||||||
|
st.equal(defaultEncoder, utils.encode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
t.test('throws error with wrong encoder', function (st) {
|
t.test('throws error with wrong encoder', function (st) {
|
||||||
st.throws(function () {
|
st['throws'](function () {
|
||||||
qs.stringify({}, { encoder: 'string' });
|
qs.stringify({}, { encoder: 'string' });
|
||||||
}, new TypeError('Encoder has to be a function.'));
|
}, new TypeError('Encoder has to be a function.'));
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
t.test('can use custom encoder for a buffer object', { skip: typeof Buffer === 'undefined' }, function (st) {
|
t.test('can use custom encoder for a buffer object', { skip: typeof Buffer === 'undefined' }, function (st) {
|
||||||
st.equal(qs.stringify({ a: new Buffer([1]) }, {
|
st.equal(qs.stringify({ a: SaferBuffer.from([1]) }, {
|
||||||
encoder: function (buffer) {
|
encoder: function (buffer) {
|
||||||
if (typeof buffer === 'string') {
|
if (typeof buffer === 'string') {
|
||||||
return buffer;
|
return buffer;
|
||||||
|
@ -483,7 +535,7 @@ test('stringify()', function (t) {
|
||||||
mutatedDate.toISOString = function () {
|
mutatedDate.toISOString = function () {
|
||||||
throw new SyntaxError();
|
throw new SyntaxError();
|
||||||
};
|
};
|
||||||
st.throws(function () {
|
st['throws'](function () {
|
||||||
mutatedDate.toISOString();
|
mutatedDate.toISOString();
|
||||||
}, SyntaxError);
|
}, SyntaxError);
|
||||||
st.equal(
|
st.equal(
|
||||||
|
@ -525,7 +577,7 @@ test('stringify()', function (t) {
|
||||||
t.test('Edge cases and unknown formats', function (st) {
|
t.test('Edge cases and unknown formats', function (st) {
|
||||||
['UFO1234', false, 1234, null, {}, []].forEach(
|
['UFO1234', false, 1234, null, {}, []].forEach(
|
||||||
function (format) {
|
function (format) {
|
||||||
st.throws(
|
st['throws'](
|
||||||
function () {
|
function () {
|
||||||
qs.stringify({ a: 'b c' }, { format: format });
|
qs.stringify({ a: 'b c' }, { format: format });
|
||||||
},
|
},
|
||||||
|
@ -535,4 +587,93 @@ test('stringify()', function (t) {
|
||||||
);
|
);
|
||||||
st.end();
|
st.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
t.test('encodeValuesOnly', function (st) {
|
||||||
|
st.equal(
|
||||||
|
qs.stringify(
|
||||||
|
{ a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
|
||||||
|
{ encodeValuesOnly: true }
|
||||||
|
),
|
||||||
|
'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h'
|
||||||
|
);
|
||||||
|
st.equal(
|
||||||
|
qs.stringify(
|
||||||
|
{ a: 'b', c: ['d', 'e'], f: [['g'], ['h']] }
|
||||||
|
),
|
||||||
|
'a=b&c%5B0%5D=d&c%5B1%5D=e&f%5B0%5D%5B0%5D=g&f%5B1%5D%5B0%5D=h'
|
||||||
|
);
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('encodeValuesOnly - strictNullHandling', function (st) {
|
||||||
|
st.equal(
|
||||||
|
qs.stringify(
|
||||||
|
{ a: { b: null } },
|
||||||
|
{ encodeValuesOnly: true, strictNullHandling: true }
|
||||||
|
),
|
||||||
|
'a[b]'
|
||||||
|
);
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('throws if an invalid charset is specified', function (st) {
|
||||||
|
st['throws'](function () {
|
||||||
|
qs.stringify({ a: 'b' }, { charset: 'foobar' });
|
||||||
|
}, new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'));
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('respects a charset of iso-8859-1', function (st) {
|
||||||
|
st.equal(qs.stringify({ æ: 'æ' }, { charset: 'iso-8859-1' }), '%E6=%E6');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('encodes unrepresentable chars as numeric entities in iso-8859-1 mode', function (st) {
|
||||||
|
st.equal(qs.stringify({ a: '☺' }, { charset: 'iso-8859-1' }), 'a=%26%239786%3B');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('respects an explicit charset of utf-8 (the default)', function (st) {
|
||||||
|
st.equal(qs.stringify({ a: 'æ' }, { charset: 'utf-8' }), 'a=%C3%A6');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('adds the right sentinel when instructed to and the charset is utf-8', function (st) {
|
||||||
|
st.equal(qs.stringify({ a: 'æ' }, { charsetSentinel: true, charset: 'utf-8' }), 'utf8=%E2%9C%93&a=%C3%A6');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('adds the right sentinel when instructed to and the charset is iso-8859-1', function (st) {
|
||||||
|
st.equal(qs.stringify({ a: 'æ' }, { charsetSentinel: true, charset: 'iso-8859-1' }), 'utf8=%26%2310003%3B&a=%E6');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('does not mutate the options argument', function (st) {
|
||||||
|
var options = {};
|
||||||
|
qs.stringify({}, options);
|
||||||
|
st.deepEqual(options, {});
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('strictNullHandling works with custom filter', function (st) {
|
||||||
|
var filter = function (prefix, value) {
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
var options = { strictNullHandling: true, filter: filter };
|
||||||
|
st.equal(qs.stringify({ key: null }, options), 'key');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('strictNullHandling works with null serializeDate', function (st) {
|
||||||
|
var serializeDate = function () {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
var options = { strictNullHandling: true, serializeDate: serializeDate };
|
||||||
|
var date = new Date();
|
||||||
|
st.equal(qs.stringify({ key: date }, options), 'key');
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
114
node/node_modules/qs/test/utils.js
generated
vendored
Executable file → Normal file
114
node/node_modules/qs/test/utils.js
generated
vendored
Executable file → Normal file
|
@ -1,9 +1,16 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var test = require('tape');
|
var test = require('tape');
|
||||||
|
var inspect = require('object-inspect');
|
||||||
|
var SaferBuffer = require('safer-buffer').Buffer;
|
||||||
|
var forEach = require('for-each');
|
||||||
var utils = require('../lib/utils');
|
var utils = require('../lib/utils');
|
||||||
|
|
||||||
test('merge()', function (t) {
|
test('merge()', function (t) {
|
||||||
|
t.deepEqual(utils.merge(null, true), [null, true], 'merges true into null');
|
||||||
|
|
||||||
|
t.deepEqual(utils.merge(null, [42]), [null, 42], 'merges null into an array');
|
||||||
|
|
||||||
t.deepEqual(utils.merge({ a: 'b' }, { a: 'c' }), { a: ['b', 'c'] }, 'merges two objects with the same key');
|
t.deepEqual(utils.merge({ a: 'b' }, { a: 'c' }), { a: ['b', 'c'] }, 'merges two objects with the same key');
|
||||||
|
|
||||||
var oneMerged = utils.merge({ foo: 'bar' }, { foo: { first: '123' } });
|
var oneMerged = utils.merge({ foo: 'bar' }, { foo: { first: '123' } });
|
||||||
|
@ -18,5 +25,112 @@ test('merge()', function (t) {
|
||||||
var nestedArrays = utils.merge({ foo: ['baz'] }, { foo: ['bar', 'xyzzy'] });
|
var nestedArrays = utils.merge({ foo: ['baz'] }, { foo: ['bar', 'xyzzy'] });
|
||||||
t.deepEqual(nestedArrays, { foo: ['baz', 'bar', 'xyzzy'] });
|
t.deepEqual(nestedArrays, { foo: ['baz', 'bar', 'xyzzy'] });
|
||||||
|
|
||||||
|
var noOptionsNonObjectSource = utils.merge({ foo: 'baz' }, 'bar');
|
||||||
|
t.deepEqual(noOptionsNonObjectSource, { foo: 'baz', bar: true });
|
||||||
|
|
||||||
|
t.test(
|
||||||
|
'avoids invoking array setters unnecessarily',
|
||||||
|
{ skip: typeof Object.defineProperty !== 'function' },
|
||||||
|
function (st) {
|
||||||
|
var setCount = 0;
|
||||||
|
var getCount = 0;
|
||||||
|
var observed = [];
|
||||||
|
Object.defineProperty(observed, 0, {
|
||||||
|
get: function () {
|
||||||
|
getCount += 1;
|
||||||
|
return { bar: 'baz' };
|
||||||
|
},
|
||||||
|
set: function () { setCount += 1; }
|
||||||
|
});
|
||||||
|
utils.merge(observed, [null]);
|
||||||
|
st.equal(setCount, 0);
|
||||||
|
st.equal(getCount, 1);
|
||||||
|
observed[0] = observed[0]; // eslint-disable-line no-self-assign
|
||||||
|
st.equal(setCount, 1);
|
||||||
|
st.equal(getCount, 2);
|
||||||
|
st.end();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('assign()', function (t) {
|
||||||
|
var target = { a: 1, b: 2 };
|
||||||
|
var source = { b: 3, c: 4 };
|
||||||
|
var result = utils.assign(target, source);
|
||||||
|
|
||||||
|
t.equal(result, target, 'returns the target');
|
||||||
|
t.deepEqual(target, { a: 1, b: 3, c: 4 }, 'target and source are merged');
|
||||||
|
t.deepEqual(source, { b: 3, c: 4 }, 'source is untouched');
|
||||||
|
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('combine()', function (t) {
|
||||||
|
t.test('both arrays', function (st) {
|
||||||
|
var a = [1];
|
||||||
|
var b = [2];
|
||||||
|
var combined = utils.combine(a, b);
|
||||||
|
|
||||||
|
st.deepEqual(a, [1], 'a is not mutated');
|
||||||
|
st.deepEqual(b, [2], 'b is not mutated');
|
||||||
|
st.notEqual(a, combined, 'a !== combined');
|
||||||
|
st.notEqual(b, combined, 'b !== combined');
|
||||||
|
st.deepEqual(combined, [1, 2], 'combined is a + b');
|
||||||
|
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('one array, one non-array', function (st) {
|
||||||
|
var aN = 1;
|
||||||
|
var a = [aN];
|
||||||
|
var bN = 2;
|
||||||
|
var b = [bN];
|
||||||
|
|
||||||
|
var combinedAnB = utils.combine(aN, b);
|
||||||
|
st.deepEqual(b, [bN], 'b is not mutated');
|
||||||
|
st.notEqual(aN, combinedAnB, 'aN + b !== aN');
|
||||||
|
st.notEqual(a, combinedAnB, 'aN + b !== a');
|
||||||
|
st.notEqual(bN, combinedAnB, 'aN + b !== bN');
|
||||||
|
st.notEqual(b, combinedAnB, 'aN + b !== b');
|
||||||
|
st.deepEqual([1, 2], combinedAnB, 'first argument is array-wrapped when not an array');
|
||||||
|
|
||||||
|
var combinedABn = utils.combine(a, bN);
|
||||||
|
st.deepEqual(a, [aN], 'a is not mutated');
|
||||||
|
st.notEqual(aN, combinedABn, 'a + bN !== aN');
|
||||||
|
st.notEqual(a, combinedABn, 'a + bN !== a');
|
||||||
|
st.notEqual(bN, combinedABn, 'a + bN !== bN');
|
||||||
|
st.notEqual(b, combinedABn, 'a + bN !== b');
|
||||||
|
st.deepEqual([1, 2], combinedABn, 'second argument is array-wrapped when not an array');
|
||||||
|
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.test('neither is an array', function (st) {
|
||||||
|
var combined = utils.combine(1, 2);
|
||||||
|
st.notEqual(1, combined, '1 + 2 !== 1');
|
||||||
|
st.notEqual(2, combined, '1 + 2 !== 2');
|
||||||
|
st.deepEqual([1, 2], combined, 'both arguments are array-wrapped when not an array');
|
||||||
|
|
||||||
|
st.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('isBuffer()', function (t) {
|
||||||
|
forEach([null, undefined, true, false, '', 'abc', 42, 0, NaN, {}, [], function () {}, /a/g], function (x) {
|
||||||
|
t.equal(utils.isBuffer(x), false, inspect(x) + ' is not a buffer');
|
||||||
|
});
|
||||||
|
|
||||||
|
var fakeBuffer = { constructor: Buffer };
|
||||||
|
t.equal(utils.isBuffer(fakeBuffer), false, 'fake buffer is not a buffer');
|
||||||
|
|
||||||
|
var saferBuffer = SaferBuffer.from('abc');
|
||||||
|
t.equal(utils.isBuffer(saferBuffer), true, 'SaferBuffer instance is a buffer');
|
||||||
|
|
||||||
|
var buffer = Buffer.from ? Buffer.from('abc') : new Buffer('abc');
|
||||||
|
t.equal(utils.isBuffer(buffer), true, 'real Buffer instance is a buffer');
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
29
node/node_modules/redis-commands/.npmignore
generated
vendored
29
node/node_modules/redis-commands/.npmignore
generated
vendored
|
@ -1,29 +0,0 @@
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.rdb
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
|
|
||||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directory
|
|
||||||
# Commenting this out is preferred by some people, see
|
|
||||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
|
|
||||||
node_modules
|
|
||||||
|
|
||||||
# Users Environment Variables
|
|
||||||
.lock-wscript
|
|
8
node/node_modules/redis-commands/.travis.yml
generated
vendored
8
node/node_modules/redis-commands/.travis.yml
generated
vendored
|
@ -1,9 +1,9 @@
|
||||||
language: node_js
|
language: node_js
|
||||||
sudo: false
|
sudo: false
|
||||||
node_js:
|
node_js:
|
||||||
- "0.10"
|
- "6"
|
||||||
- "0.12"
|
- "8"
|
||||||
- "4"
|
- "9"
|
||||||
- "5"
|
- "10"
|
||||||
after_success:
|
after_success:
|
||||||
- CODECLIMATE_REPO_TOKEN=b57723fafcf0516f275d6b380cd506fd082ea88d86507eb82c8abd489b9b9a09 node ./node_modules/.bin/codeclimate-test-reporter < coverage/lcov.info
|
- CODECLIMATE_REPO_TOKEN=b57723fafcf0516f275d6b380cd506fd082ea88d86507eb82c8abd489b9b9a09 node ./node_modules/.bin/codeclimate-test-reporter < coverage/lcov.info
|
||||||
|
|
32
node/node_modules/redis-commands/changelog.md
generated
vendored
32
node/node_modules/redis-commands/changelog.md
generated
vendored
|
@ -1,3 +1,35 @@
|
||||||
|
## v.1.3.5 - 28 Feb, 2018
|
||||||
|
|
||||||
|
Bugfix
|
||||||
|
|
||||||
|
- Rebuild the commands with the latest stable release.
|
||||||
|
In v.1.3.3 the wrong Redis version was used.
|
||||||
|
|
||||||
|
## v.1.3.4 - 26 Feb, 2018
|
||||||
|
|
||||||
|
Chore
|
||||||
|
|
||||||
|
- Removed coverage folder from npm
|
||||||
|
|
||||||
|
## v.1.3.3 - 24 Feb, 2018
|
||||||
|
|
||||||
|
Features
|
||||||
|
|
||||||
|
- Rebuild the commands
|
||||||
|
|
||||||
|
## v.1.3.2 - 24 Feb, 2018
|
||||||
|
|
||||||
|
Chore
|
||||||
|
|
||||||
|
- Updated dependencies
|
||||||
|
- Fixed typos
|
||||||
|
|
||||||
|
## v.1.3.1 - 25 Jan, 2017
|
||||||
|
|
||||||
|
Bugfix
|
||||||
|
|
||||||
|
- Fix require for for webpack
|
||||||
|
|
||||||
## v.1.3.0 - 20 Oct, 2016
|
## v.1.3.0 - 20 Oct, 2016
|
||||||
|
|
||||||
Features
|
Features
|
||||||
|
|
220
node/node_modules/redis-commands/commands.json
generated
vendored
220
node/node_modules/redis-commands/commands.json
generated
vendored
|
@ -117,6 +117,28 @@
|
||||||
"keyStop": 2,
|
"keyStop": 2,
|
||||||
"step": 1
|
"step": 1
|
||||||
},
|
},
|
||||||
|
"bzpopmax": {
|
||||||
|
"arity": -2,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"noscript",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": -2,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"bzpopmin": {
|
||||||
|
"arity": -2,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"noscript",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": -2,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
"client": {
|
"client": {
|
||||||
"arity": -2,
|
"arity": -2,
|
||||||
"flags": [
|
"flags": [
|
||||||
|
@ -168,7 +190,7 @@
|
||||||
"step": 0
|
"step": 0
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"arity": -1,
|
"arity": -2,
|
||||||
"flags": [
|
"flags": [
|
||||||
"admin",
|
"admin",
|
||||||
"noscript"
|
"noscript"
|
||||||
|
@ -354,7 +376,18 @@
|
||||||
"georadius": {
|
"georadius": {
|
||||||
"arity": -6,
|
"arity": -6,
|
||||||
"flags": [
|
"flags": [
|
||||||
"write"
|
"write",
|
||||||
|
"movablekeys"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"georadius_ro": {
|
||||||
|
"arity": -6,
|
||||||
|
"flags": [
|
||||||
|
"readonly",
|
||||||
|
"movablekeys"
|
||||||
],
|
],
|
||||||
"keyStart": 1,
|
"keyStart": 1,
|
||||||
"keyStop": 1,
|
"keyStop": 1,
|
||||||
|
@ -363,7 +396,18 @@
|
||||||
"georadiusbymember": {
|
"georadiusbymember": {
|
||||||
"arity": -5,
|
"arity": -5,
|
||||||
"flags": [
|
"flags": [
|
||||||
"write"
|
"write",
|
||||||
|
"movablekeys"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"georadiusbymember_ro": {
|
||||||
|
"arity": -5,
|
||||||
|
"flags": [
|
||||||
|
"readonly",
|
||||||
|
"movablekeys"
|
||||||
],
|
],
|
||||||
"keyStart": 1,
|
"keyStart": 1,
|
||||||
"keyStop": 1,
|
"keyStop": 1,
|
||||||
|
@ -492,7 +536,8 @@
|
||||||
"hmget": {
|
"hmget": {
|
||||||
"arity": -3,
|
"arity": -3,
|
||||||
"flags": [
|
"flags": [
|
||||||
"readonly"
|
"readonly",
|
||||||
|
"fast"
|
||||||
],
|
],
|
||||||
"keyStart": 1,
|
"keyStart": 1,
|
||||||
"keyStop": 1,
|
"keyStop": 1,
|
||||||
|
@ -502,7 +547,8 @@
|
||||||
"arity": -4,
|
"arity": -4,
|
||||||
"flags": [
|
"flags": [
|
||||||
"write",
|
"write",
|
||||||
"denyoom"
|
"denyoom",
|
||||||
|
"fast"
|
||||||
],
|
],
|
||||||
"keyStart": 1,
|
"keyStart": 1,
|
||||||
"keyStop": 1,
|
"keyStop": 1,
|
||||||
|
@ -529,7 +575,7 @@
|
||||||
"step": 1
|
"step": 1
|
||||||
},
|
},
|
||||||
"hset": {
|
"hset": {
|
||||||
"arity": 4,
|
"arity": -4,
|
||||||
"flags": [
|
"flags": [
|
||||||
"write",
|
"write",
|
||||||
"denyoom",
|
"denyoom",
|
||||||
|
@ -755,7 +801,8 @@
|
||||||
"mget": {
|
"mget": {
|
||||||
"arity": -2,
|
"arity": -2,
|
||||||
"flags": [
|
"flags": [
|
||||||
"readonly"
|
"readonly",
|
||||||
|
"fast"
|
||||||
],
|
],
|
||||||
"keyStart": 1,
|
"keyStart": 1,
|
||||||
"keyStop": -1,
|
"keyStop": -1,
|
||||||
|
@ -777,9 +824,9 @@
|
||||||
"admin",
|
"admin",
|
||||||
"noscript"
|
"noscript"
|
||||||
],
|
],
|
||||||
"keyStart": 1,
|
"keyStart": 0,
|
||||||
"keyStop": 1,
|
"keyStop": 0,
|
||||||
"step": 1
|
"step": 0
|
||||||
},
|
},
|
||||||
"monitor": {
|
"monitor": {
|
||||||
"arity": 1,
|
"arity": 1,
|
||||||
|
@ -832,13 +879,13 @@
|
||||||
"step": 0
|
"step": 0
|
||||||
},
|
},
|
||||||
"object": {
|
"object": {
|
||||||
"arity": 3,
|
"arity": -2,
|
||||||
"flags": [
|
"flags": [
|
||||||
"readonly"
|
"readonly"
|
||||||
],
|
],
|
||||||
"keyStart": 2,
|
"keyStart": 2,
|
||||||
"keyStop": 2,
|
"keyStop": 2,
|
||||||
"step": 2
|
"step": 1
|
||||||
},
|
},
|
||||||
"persist": {
|
"persist": {
|
||||||
"arity": 2,
|
"arity": 2,
|
||||||
|
@ -1588,6 +1635,135 @@
|
||||||
"keyStop": -1,
|
"keyStop": -1,
|
||||||
"step": 1
|
"step": 1
|
||||||
},
|
},
|
||||||
|
"xack": {
|
||||||
|
"arity": -3,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xadd": {
|
||||||
|
"arity": -5,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"denyoom",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xclaim": {
|
||||||
|
"arity": -5,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xdel": {
|
||||||
|
"arity": -2,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xgroup": {
|
||||||
|
"arity": -2,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"denyoom"
|
||||||
|
],
|
||||||
|
"keyStart": 2,
|
||||||
|
"keyStop": 2,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xinfo": {
|
||||||
|
"arity": -2,
|
||||||
|
"flags": [
|
||||||
|
"readonly"
|
||||||
|
],
|
||||||
|
"keyStart": 2,
|
||||||
|
"keyStop": 2,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xlen": {
|
||||||
|
"arity": 2,
|
||||||
|
"flags": [
|
||||||
|
"readonly",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xpending": {
|
||||||
|
"arity": -3,
|
||||||
|
"flags": [
|
||||||
|
"readonly"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xrange": {
|
||||||
|
"arity": -4,
|
||||||
|
"flags": [
|
||||||
|
"readonly"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xread": {
|
||||||
|
"arity": -3,
|
||||||
|
"flags": [
|
||||||
|
"readonly",
|
||||||
|
"noscript",
|
||||||
|
"movablekeys"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xreadgroup": {
|
||||||
|
"arity": -3,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"noscript",
|
||||||
|
"movablekeys"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xrevrange": {
|
||||||
|
"arity": -4,
|
||||||
|
"flags": [
|
||||||
|
"readonly"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"xtrim": {
|
||||||
|
"arity": -2,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": 1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
"zadd": {
|
"zadd": {
|
||||||
"arity": -4,
|
"arity": -4,
|
||||||
"flags": [
|
"flags": [
|
||||||
|
@ -1651,6 +1827,26 @@
|
||||||
"keyStop": 1,
|
"keyStop": 1,
|
||||||
"step": 1
|
"step": 1
|
||||||
},
|
},
|
||||||
|
"zpopmax": {
|
||||||
|
"arity": -2,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": -1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
|
"zpopmin": {
|
||||||
|
"arity": -2,
|
||||||
|
"flags": [
|
||||||
|
"write",
|
||||||
|
"fast"
|
||||||
|
],
|
||||||
|
"keyStart": 1,
|
||||||
|
"keyStop": -1,
|
||||||
|
"step": 1
|
||||||
|
},
|
||||||
"zrange": {
|
"zrange": {
|
||||||
"arity": -4,
|
"arity": -4,
|
||||||
"flags": [
|
"flags": [
|
||||||
|
|
2
node/node_modules/redis-commands/index.js
generated
vendored
2
node/node_modules/redis-commands/index.js
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var commands = require('./commands')
|
var commands = require('./commands.json')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis command list
|
* Redis command list
|
||||||
|
|
86
node/node_modules/redis-commands/package.json
generated
vendored
86
node/node_modules/redis-commands/package.json
generated
vendored
|
@ -1,48 +1,25 @@
|
||||||
{
|
{
|
||||||
"_args": [
|
"_from": "redis-commands@^1.2.0",
|
||||||
[
|
"_id": "redis-commands@1.4.0",
|
||||||
{
|
"_inBundle": false,
|
||||||
"raw": "redis-commands@^1.2.0",
|
"_integrity": "sha512-cu8EF+MtkwI4DLIT0x9P8qNTLFhQD4jLfxLR0cCNkeGzs87FN6879JOJwNQR/1zD7aSYNbU0hgsV9zGY71Itvw==",
|
||||||
"scope": null,
|
|
||||||
"escapedName": "redis-commands",
|
|
||||||
"name": "redis-commands",
|
|
||||||
"rawSpec": "^1.2.0",
|
|
||||||
"spec": ">=1.2.0 <2.0.0",
|
|
||||||
"type": "range"
|
|
||||||
},
|
|
||||||
"/Users/sclay/projects/newsblur/node/node_modules/redis"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "redis-commands@>=1.2.0 <2.0.0",
|
|
||||||
"_id": "redis-commands@1.3.0",
|
|
||||||
"_inCache": true,
|
|
||||||
"_location": "/redis-commands",
|
"_location": "/redis-commands",
|
||||||
"_nodeVersion": "6.8.0",
|
|
||||||
"_npmOperationalInternal": {
|
|
||||||
"host": "packages-12-west.internal.npmjs.com",
|
|
||||||
"tmp": "tmp/redis-commands-1.3.0.tgz_1476993178910_0.8879043820779771"
|
|
||||||
},
|
|
||||||
"_npmUser": {
|
|
||||||
"name": "bridgear",
|
|
||||||
"email": "ruben@bridgewater.de"
|
|
||||||
},
|
|
||||||
"_npmVersion": "3.10.8",
|
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
|
"type": "range",
|
||||||
|
"registry": true,
|
||||||
"raw": "redis-commands@^1.2.0",
|
"raw": "redis-commands@^1.2.0",
|
||||||
"scope": null,
|
|
||||||
"escapedName": "redis-commands",
|
|
||||||
"name": "redis-commands",
|
"name": "redis-commands",
|
||||||
|
"escapedName": "redis-commands",
|
||||||
"rawSpec": "^1.2.0",
|
"rawSpec": "^1.2.0",
|
||||||
"spec": ">=1.2.0 <2.0.0",
|
"saveSpec": null,
|
||||||
"type": "range"
|
"fetchSpec": "^1.2.0"
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/redis"
|
"/redis"
|
||||||
],
|
],
|
||||||
"_resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.0.tgz",
|
"_resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.4.0.tgz",
|
||||||
"_shasum": "4307d8094aee1315829ab6729b37b99f62365d63",
|
"_shasum": "52f9cf99153efcce56a8f86af986bd04e988602f",
|
||||||
"_shrinkwrap": null,
|
|
||||||
"_spec": "redis-commands@^1.2.0",
|
"_spec": "redis-commands@^1.2.0",
|
||||||
"_where": "/Users/sclay/projects/newsblur/node/node_modules/redis",
|
"_where": "/Users/sclay/projects/newsblur/node/node_modules/redis",
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -51,27 +28,22 @@
|
||||||
"url": "http://zihua.li"
|
"url": "http://zihua.li"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/NodeRedis/redis-commonds/issues"
|
"url": "https://github.com/NodeRedis/redis-commands/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"bundleDependencies": false,
|
||||||
|
"deprecated": false,
|
||||||
"description": "Redis commands",
|
"description": "Redis commands",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.4.0",
|
"chai": "^4.0.1",
|
||||||
"codeclimate-test-reporter": "^0.3.1",
|
"codeclimate-test-reporter": "^0.4.0",
|
||||||
"ioredis": "^2.0.0",
|
"ioredis": "^3.0.0",
|
||||||
"istanbul": "^0.4.3",
|
"istanbul": "^0.4.3",
|
||||||
"json-stable-stringify": "^1.0.0",
|
"mocha": "^5.0.0",
|
||||||
"mocha": "^3.0.0",
|
"safe-stable-stringify": "^1.0.0",
|
||||||
"snazzy": "^5.0.0",
|
"snazzy": "^8.0.0",
|
||||||
"standard": "^8.0.0"
|
"standard": "^11.0.0"
|
||||||
},
|
},
|
||||||
"directories": {},
|
"homepage": "https://github.com/NodeRedis/redis-commands",
|
||||||
"dist": {
|
|
||||||
"shasum": "4307d8094aee1315829ab6729b37b99f62365d63",
|
|
||||||
"tarball": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.0.tgz"
|
|
||||||
},
|
|
||||||
"gitHead": "a3ea72da0064b90f83b5d4728b60d0bb3021ed6a",
|
|
||||||
"homepage": "https://github.com/NodeRedis/redis-commonds",
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"redis",
|
"redis",
|
||||||
"commands",
|
"commands",
|
||||||
|
@ -79,19 +51,7 @@
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"maintainers": [
|
|
||||||
{
|
|
||||||
"name": "bridgear",
|
|
||||||
"email": "ruben@bridgewater.de"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "luin",
|
|
||||||
"email": "i@zihua.li"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "redis-commands",
|
"name": "redis-commands",
|
||||||
"optionalDependencies": {},
|
|
||||||
"readme": "ERROR: No README data found!",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/NodeRedis/redis-commands.git"
|
"url": "git+https://github.com/NodeRedis/redis-commands.git"
|
||||||
|
@ -105,5 +65,5 @@
|
||||||
"pretest": "npm run lint",
|
"pretest": "npm run lint",
|
||||||
"test": "mocha"
|
"test": "mocha"
|
||||||
},
|
},
|
||||||
"version": "1.3.0"
|
"version": "1.4.0"
|
||||||
}
|
}
|
||||||
|
|
120
node/node_modules/redis-commands/test/index.js
generated
vendored
120
node/node_modules/redis-commands/test/index.js
generated
vendored
|
@ -1,120 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
/* global describe, it */
|
|
||||||
|
|
||||||
var commands = require('..')
|
|
||||||
var expect = require('chai').expect
|
|
||||||
|
|
||||||
describe('redis-commands', function () {
|
|
||||||
describe('.list', function () {
|
|
||||||
it('should be an array', function () {
|
|
||||||
expect(commands.list).to.be.instanceof(Array)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should ensure every command is lowercase', function () {
|
|
||||||
commands.list.forEach(function (command) {
|
|
||||||
expect(command.toLowerCase()).to.eql(command)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should ensure quit command is added to the commands list', function () {
|
|
||||||
expect(commands.list.indexOf('quit')).not.to.eql(-1)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should not contain multi-word commands', function () {
|
|
||||||
commands.list.forEach(function (command) {
|
|
||||||
expect(command.indexOf(' ')).to.eql(-1)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('.exists()', function () {
|
|
||||||
it('should return true for existing commands', function () {
|
|
||||||
expect(commands.exists('set')).to.eql(true)
|
|
||||||
expect(commands.exists('get')).to.eql(true)
|
|
||||||
expect(commands.exists('cluster')).to.eql(true)
|
|
||||||
expect(commands.exists('quit')).to.eql(true)
|
|
||||||
expect(commands.exists('config')).to.eql(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return false for non-existing commands', function () {
|
|
||||||
expect(commands.exists('SET')).to.eql(false)
|
|
||||||
expect(commands.exists('set get')).to.eql(false)
|
|
||||||
expect(commands.exists('other-command')).to.eql(false)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('.hasFlag()', function () {
|
|
||||||
it('should return true if the command has the flag', function () {
|
|
||||||
expect(commands.hasFlag('set', 'write')).to.eql(true)
|
|
||||||
expect(commands.hasFlag('set', 'denyoom')).to.eql(true)
|
|
||||||
expect(commands.hasFlag('select', 'fast')).to.eql(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return false otherwise', function () {
|
|
||||||
expect(commands.hasFlag('set', 'fast')).to.eql(false)
|
|
||||||
expect(commands.hasFlag('set', 'readonly')).to.eql(false)
|
|
||||||
expect(commands.hasFlag('select', 'denyoom')).to.eql(false)
|
|
||||||
expect(commands.hasFlag('quit', 'denyoom')).to.eql(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should throw on unknown commands', function () {
|
|
||||||
expect(function () { commands.hasFlag('UNKNOWN') }).to.throw(Error)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('.getKeyIndexes()', function () {
|
|
||||||
var index = commands.getKeyIndexes
|
|
||||||
|
|
||||||
it('should throw on unknown commands', function () {
|
|
||||||
expect(function () { index('UNKNOWN') }).to.throw(Error)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should throw on faulty args', function () {
|
|
||||||
expect(function () { index('get', 'foo') }).to.throw(Error)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return an empty array if no keys exist', function () {
|
|
||||||
expect(index('auth', [])).to.eql([])
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should return key indexes', function () {
|
|
||||||
expect(index('set', ['foo', 'bar'])).to.eql([0])
|
|
||||||
expect(index('del', ['foo'])).to.eql([0])
|
|
||||||
expect(index('get', ['foo'])).to.eql([0])
|
|
||||||
expect(index('mget', ['foo', 'bar'])).to.eql([0, 1])
|
|
||||||
expect(index('mset', ['foo', 'v1', 'bar', 'v2'])).to.eql([0, 2])
|
|
||||||
expect(index('hmset', ['key', 'foo', 'v1', 'bar', 'v2'])).to.eql([0])
|
|
||||||
expect(index('blpop', ['key1', 'key2', '17'])).to.eql([0, 1])
|
|
||||||
expect(index('evalsha', ['23123', '2', 'foo', 'bar', 'zoo'])).to.eql([2, 3])
|
|
||||||
expect(index('sort', ['key'])).to.eql([0])
|
|
||||||
expect(index('zunionstore', ['out', '2', 'zset1', 'zset2', 'WEIGHTS', '2', '3'])).to.eql([0, 2, 3])
|
|
||||||
expect(index('migrate', ['127.0.0.1', 6379, 'foo', 0, 0, 'COPY'])).to.eql([2])
|
|
||||||
expect(index('migrate', ['127.0.0.1', 6379, '', 0, 0, 'REPLACE', 'KEYS', 'foo', 'bar'])).to.eql([7, 8])
|
|
||||||
expect(index('migrate', ['127.0.0.1', 6379, '', 0, 0, 'KEYS', 'foo', 'bar'])).to.eql([6, 7])
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should support numeric argument', function () {
|
|
||||||
expect(index('evalsha', ['23123', 2, 'foo', 'bar', 'zoo'])).to.eql([2, 3])
|
|
||||||
expect(index('zinterstore', ['out', 2, 'zset1', 'zset2', 'WEIGHTS', 2, 3])).to.eql([0, 2, 3])
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('disable parseExternalKey', function () {
|
|
||||||
it('should not parse external keys', function () {
|
|
||||||
expect(index('sort', ['key', 'BY', 'hash:*->field'])).to.eql([0, 2])
|
|
||||||
expect(index('sort', ['key', 'BY', 'hash:*->field', 'LIMIT', 2, 3, 'GET', 'gk', 'GET', '#', 'Get', 'gh->f*', 'DESC', 'ALPHA', 'STORE', 'store'])).to.eql([0, 2, 7, 11, 15])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('enable parseExternalKey', function () {
|
|
||||||
it('should parse external keys', function () {
|
|
||||||
expect(index('sort', ['key', 'BY', 'hash:*->field'], {
|
|
||||||
parseExternalKey: true
|
|
||||||
})).to.eql([0, [2, 6]])
|
|
||||||
expect(index('sort', ['key', 'BY', 'hash:*->field', 'LIMIT', 2, 3, 'GET', new Buffer('gk'), 'GET', '#', 'Get', 'gh->f*', 'DESC', 'ALPHA', 'STORE', 'store'], {
|
|
||||||
parseExternalKey: true
|
|
||||||
})).to.eql([0, [2, 6], [7, 2], [11, 2], 15])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
8
node/node_modules/redis-commands/tools/build.js
generated
vendored
8
node/node_modules/redis-commands/tools/build.js
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
var stringify = require('json-stable-stringify')
|
var stringify = require('safe-stable-stringify')
|
||||||
var commandPath = path.join(__dirname, '..', 'commands.json')
|
var commandPath = path.join(__dirname, '..', 'commands.json')
|
||||||
var redisCommands = require('../')
|
var redisCommands = require('../')
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ redis.command().then(function (res) {
|
||||||
throw new Error('Not all commands (\'' + movableKeys.join('\', \'') + '\') with the "movablekeys" flag are handled in the code')
|
throw new Error('Not all commands (\'' + movableKeys.join('\', \'') + '\') with the "movablekeys" flag are handled in the code')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use json-stable-stringify instead fo JSON.stringify
|
// Use safe-stable-stringify instead fo JSON.stringify
|
||||||
// for easier diffing
|
// for easier diffing
|
||||||
var content = stringify(commands, { space: ' ' })
|
var content = stringify(commands, null, ' ')
|
||||||
|
|
||||||
fs.writeFile(commandPath, content)
|
fs.writeFileSync(commandPath, content)
|
||||||
})
|
})
|
||||||
|
|
6
node/node_modules/redis-parser/.codeclimate.yml
generated
vendored
6
node/node_modules/redis-parser/.codeclimate.yml
generated
vendored
|
@ -1,6 +0,0 @@
|
||||||
languages:
|
|
||||||
JavaScript: true
|
|
||||||
exclude_paths:
|
|
||||||
- "benchmark/index.js"
|
|
||||||
- "benchmark/old/javascript.js"
|
|
||||||
- "test/parsers.spec.js"
|
|
3
node/node_modules/redis-parser/.npmignore
generated
vendored
3
node/node_modules/redis-parser/.npmignore
generated
vendored
|
@ -10,3 +10,6 @@ coverage
|
||||||
test
|
test
|
||||||
.travis.yml
|
.travis.yml
|
||||||
.gitignore
|
.gitignore
|
||||||
|
*.log
|
||||||
|
.vscode
|
||||||
|
.codeclimate.yml
|
84
node/node_modules/redis-parser/README.md
generated
vendored
84
node/node_modules/redis-parser/README.md
generated
vendored
|
@ -1,5 +1,4 @@
|
||||||
[](https://travis-ci.org/NodeRedis/node-redis-parser)
|
[](https://travis-ci.org/NodeRedis/node-redis-parser)
|
||||||
[](https://codeclimate.com/github/NodeRedis/node-redis-parser)
|
|
||||||
[](https://codeclimate.com/github/NodeRedis/node-redis-parser/coverage)
|
[](https://codeclimate.com/github/NodeRedis/node-redis-parser/coverage)
|
||||||
[](http://standardjs.com/)
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
|
@ -21,7 +20,7 @@ var Parser = require('redis-parser');
|
||||||
var myParser = new Parser(options);
|
var myParser = new Parser(options);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Possible options
|
### Options
|
||||||
|
|
||||||
* `returnReply`: *function*; mandatory
|
* `returnReply`: *function*; mandatory
|
||||||
* `returnError`: *function*; mandatory
|
* `returnError`: *function*; mandatory
|
||||||
|
@ -29,6 +28,21 @@ var myParser = new Parser(options);
|
||||||
* `returnBuffers`: *boolean*; optional, defaults to false
|
* `returnBuffers`: *boolean*; optional, defaults to false
|
||||||
* `stringNumbers`: *boolean*; optional, defaults to false
|
* `stringNumbers`: *boolean*; optional, defaults to false
|
||||||
|
|
||||||
|
### Functions
|
||||||
|
|
||||||
|
* `reset()`: reset the parser to it's initial state
|
||||||
|
* `setReturnBuffers(boolean)`: (JSParser only) set the returnBuffers option on/off without resetting the parser
|
||||||
|
* `setStringNumbers(boolean)`: (JSParser only) set the stringNumbers option on/off without resetting the parser
|
||||||
|
|
||||||
|
### Error classes
|
||||||
|
|
||||||
|
* `RedisError` sub class of Error
|
||||||
|
* `ReplyError` sub class of RedisError
|
||||||
|
* `ParserError` sub class of RedisError
|
||||||
|
|
||||||
|
All Redis errors will be returned as `ReplyErrors` while a parser error is returned as `ParserError`.
|
||||||
|
All error classes are exported by the parser.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
@ -98,50 +112,50 @@ The parser is highly optimized but there may still be further optimizations poss
|
||||||
|
|
||||||
Currently the benchmark compares the performance against the hiredis parser:
|
Currently the benchmark compares the performance against the hiredis parser:
|
||||||
|
|
||||||
HIREDIS: $ multiple chunks in a bulk string x 867,643 ops/sec ±1.39% (82 runs sampled)
|
HIREDIS: $ multiple chunks in a bulk string x 859,880 ops/sec ±1.22% (82 runs sampled)
|
||||||
HIREDIS BUF: $ multiple chunks in a bulk string x 591,398 ops/sec ±1.48% (83 runs sampled)
|
HIREDIS BUF: $ multiple chunks in a bulk string x 608,869 ops/sec ±1.72% (85 runs sampled)
|
||||||
JS PARSER: $ multiple chunks in a bulk string x 942,834 ops/sec ±0.87% (90 runs sampled)
|
JS PARSER: $ multiple chunks in a bulk string x 910,590 ops/sec ±0.87% (89 runs sampled)
|
||||||
JS PARSER BUF: $ multiple chunks in a bulk string x 1,081,096 ops/sec ±1.81% (85 runs sampled)
|
JS PARSER BUF: $ multiple chunks in a bulk string x 1,299,507 ops/sec ±2.18% (84 runs sampled)
|
||||||
|
|
||||||
HIREDIS: + multiple chunks in a string x 1,785,222 ops/sec ±0.59% (92 runs sampled)
|
HIREDIS: + multiple chunks in a string x 1,787,203 ops/sec ±0.58% (96 runs sampled)
|
||||||
HIREDIS BUF: + multiple chunks in a string x 902,391 ops/sec ±1.62% (88 runs sampled)
|
HIREDIS BUF: + multiple chunks in a string x 943,584 ops/sec ±1.62% (87 runs sampled)
|
||||||
JS PARSER: + multiple chunks in a string x 1,936,709 ops/sec ±1.07% (90 runs sampled)
|
JS PARSER: + multiple chunks in a string x 2,008,264 ops/sec ±1.01% (91 runs sampled)
|
||||||
JS PARSER BUF: + multiple chunks in a string x 1,954,798 ops/sec ±0.84% (91 runs sampled)
|
JS PARSER BUF: + multiple chunks in a string x 2,045,546 ops/sec ±0.78% (91 runs sampled)
|
||||||
|
|
||||||
HIREDIS: $ 4mb bulk string x 344 ops/sec ±1.40% (85 runs sampled)
|
HIREDIS: $ 4mb bulk string x 310 ops/sec ±1.58% (75 runs sampled)
|
||||||
HIREDIS BUF: $ 4mb bulk string x 555 ops/sec ±1.85% (80 runs sampled)
|
HIREDIS BUF: $ 4mb bulk string x 471 ops/sec ±2.28% (78 runs sampled)
|
||||||
JS PARSER: $ 4mb bulk string x 834 ops/sec ±1.23% (81 runs sampled)
|
JS PARSER: $ 4mb bulk string x 747 ops/sec ±2.43% (85 runs sampled)
|
||||||
JS PARSER BUF: $ 4mb bulk string x 620 ops/sec ±2.40% (59 runs sampled)
|
JS PARSER BUF: $ 4mb bulk string x 846 ops/sec ±5.52% (72 runs sampled)
|
||||||
|
|
||||||
HIREDIS: + simple string x 2,344,042 ops/sec ±1.45% (91 runs sampled)
|
HIREDIS: + simple string x 2,324,866 ops/sec ±1.61% (90 runs sampled)
|
||||||
HIREDIS BUF: + simple string x 993,081 ops/sec ±1.87% (83 runs sampled)
|
HIREDIS BUF: + simple string x 1,085,823 ops/sec ±2.47% (82 runs sampled)
|
||||||
JS PARSER: + simple string x 4,431,517 ops/sec ±1.86% (88 runs sampled)
|
JS PARSER: + simple string x 4,567,358 ops/sec ±1.97% (81 runs sampled)
|
||||||
JS PARSER BUF: + simple string x 5,259,552 ops/sec ±0.61% (96 runs sampled)
|
JS PARSER BUF: + simple string x 5,433,901 ops/sec ±0.66% (93 runs sampled)
|
||||||
|
|
||||||
HIREDIS: : integer x 2,376,642 ops/sec ±0.30% (92 runs sampled)
|
HIREDIS: : integer x 2,332,946 ops/sec ±0.47% (93 runs sampled)
|
||||||
JS PARSER: : integer x 17,765,077 ops/sec ±0.53% (93 runs sampled)
|
JS PARSER: : integer x 17,730,449 ops/sec ±0.73% (91 runs sampled)
|
||||||
JS PARSER STR: : integer x 13,110,365 ops/sec ±0.67% (91 runs sampled)
|
JS PARSER STR: : integer x 12,942,037 ops/sec ±0.51% (92 runs sampled)
|
||||||
|
|
||||||
HIREDIS: : big integer x 2,010,124 ops/sec ±0.87% (86 runs sampled)
|
HIREDIS: : big integer x 2,012,572 ops/sec ±0.33% (93 runs sampled)
|
||||||
JS PARSER: : big integer x 10,277,063 ops/sec ±0.69% (91 runs sampled)
|
JS PARSER: : big integer x 10,210,923 ops/sec ±0.94% (94 runs sampled)
|
||||||
JS PARSER STR: : big integer x 4,492,626 ops/sec ±0.67% (94 runs sampled)
|
JS PARSER STR: : big integer x 4,453,320 ops/sec ±0.52% (94 runs sampled)
|
||||||
|
|
||||||
HIREDIS: * array x 43,763 ops/sec ±0.84% (94 runs sampled)
|
HIREDIS: * array x 44,479 ops/sec ±0.55% (94 runs sampled)
|
||||||
HIREDIS BUF: * array x 13,893 ops/sec ±1.05% (85 runs sampled)
|
HIREDIS BUF: * array x 14,391 ops/sec ±1.04% (86 runs sampled)
|
||||||
JS PARSER: * array x 50,825 ops/sec ±1.92% (80 runs sampled)
|
JS PARSER: * array x 53,796 ops/sec ±2.08% (79 runs sampled)
|
||||||
JS PARSER BUF: * array x 72,546 ops/sec ±0.80% (94 runs sampled)
|
JS PARSER BUF: * array x 72,428 ops/sec ±0.72% (93 runs sampled)
|
||||||
|
|
||||||
HIREDIS: * big array x 265 ops/sec ±1.46% (86 runs sampled)
|
HIREDIS: * big nested array x 217 ops/sec ±0.97% (83 runs sampled)
|
||||||
HIREDIS BUF: * big array x 226 ops/sec ±3.21% (75 runs sampled)
|
HIREDIS BUF: * big nested array x 255 ops/sec ±2.28% (77 runs sampled)
|
||||||
JS PARSER: * big array x 201 ops/sec ±0.95% (83 runs sampled)
|
JS PARSER: * big nested array x 242 ops/sec ±1.10% (85 runs sampled)
|
||||||
JS PARSER BUF: * big array x 244 ops/sec ±2.65% (81 runs sampled)
|
JS PARSER BUF: * big nested array x 375 ops/sec ±1.21% (88 runs sampled)
|
||||||
|
|
||||||
HIREDIS: - error x 81,563 ops/sec ±0.51% (93 runs sampled)
|
HIREDIS: - error x 78,821 ops/sec ±0.80% (93 runs sampled)
|
||||||
JS PARSER: - error x 155,225 ops/sec ±0.57% (95 runs sampled)
|
JS PARSER: - error x 143,382 ops/sec ±0.75% (92 runs sampled)
|
||||||
|
|
||||||
Platform info:
|
Platform info:
|
||||||
Ubuntu 16.10
|
Ubuntu 16.10
|
||||||
Node.js 7.1.0
|
Node.js 7.4.0
|
||||||
Intel(R) Core(TM) i7-5600U CPU
|
Intel(R) Core(TM) i7-5600U CPU
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
39
node/node_modules/redis-parser/changelog.md
generated
vendored
39
node/node_modules/redis-parser/changelog.md
generated
vendored
|
@ -1,3 +1,40 @@
|
||||||
|
## v.2.6.0 - 03 Apr, 2017
|
||||||
|
|
||||||
|
Internals
|
||||||
|
|
||||||
|
- Use Buffer.allocUnsafe instead of new Buffer() with modern Node.js versions
|
||||||
|
|
||||||
|
## v.2.5.0 - 11 Mar, 2017
|
||||||
|
|
||||||
|
Features
|
||||||
|
|
||||||
|
- Added a `ParserError` class to differentiate them to ReplyErrors. The class is also exported
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- All errors now show their error message again next to the error name in the stack trace
|
||||||
|
- ParserErrors now show the offset and buffer attributes while being logged
|
||||||
|
|
||||||
|
## v.2.4.1 - 05 Feb, 2017
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Fixed minimal memory consumption overhead for chunked buffers
|
||||||
|
|
||||||
|
## v.2.4.0 - 25 Jan, 2017
|
||||||
|
|
||||||
|
Features
|
||||||
|
|
||||||
|
- Added `reset` function to reset the parser to it's initial values
|
||||||
|
- Added `setReturnBuffers` function to reset the returnBuffers option (Only for the JSParser)
|
||||||
|
- Added `setStringNumbers` function to reset the stringNumbers option (Only for the JSParser)
|
||||||
|
- All Errors are now of sub classes of the new `RedisError` class. It is also exported.
|
||||||
|
- Improved bulk string chunked data handling performance
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Parsing time for big nested arrays is now linear
|
||||||
|
|
||||||
## v.2.3.0 - 25 Nov, 2016
|
## v.2.3.0 - 25 Nov, 2016
|
||||||
|
|
||||||
Features
|
Features
|
||||||
|
@ -63,7 +100,7 @@ Bugfixes
|
||||||
|
|
||||||
## v.2.0.0 - 29 May, 2016
|
## v.2.0.0 - 29 May, 2016
|
||||||
|
|
||||||
The javascript parser got completly rewritten by [Michael Diarmid](https://github.com/Salakar) and [Ruben Bridgewater](https://github.com/BridgeAR) and is now a lot faster than the hiredis parser.
|
The javascript parser got completely rewritten by [Michael Diarmid](https://github.com/Salakar) and [Ruben Bridgewater](https://github.com/BridgeAR) and is now a lot faster than the hiredis parser.
|
||||||
Therefore the hiredis parser was deprecated and should only be used for testing purposes and benchmarking comparison.
|
Therefore the hiredis parser was deprecated and should only be used for testing purposes and benchmarking comparison.
|
||||||
|
|
||||||
All Errors returned by the parser are from now on of class ReplyError
|
All Errors returned by the parser are from now on of class ReplyError
|
||||||
|
|
2
node/node_modules/redis-parser/index.js
generated
vendored
2
node/node_modules/redis-parser/index.js
generated
vendored
|
@ -2,3 +2,5 @@
|
||||||
|
|
||||||
module.exports = require('./lib/parser')
|
module.exports = require('./lib/parser')
|
||||||
module.exports.ReplyError = require('./lib/replyError')
|
module.exports.ReplyError = require('./lib/replyError')
|
||||||
|
module.exports.RedisError = require('./lib/redisError')
|
||||||
|
module.exports.ParserError = require('./lib/redisError')
|
||||||
|
|
1
node/node_modules/redis-parser/isolate-0x28e7b50-v8.log
generated
vendored
1
node/node_modules/redis-parser/isolate-0x28e7b50-v8.log
generated
vendored
|
@ -1 +0,0 @@
|
||||||
v8-version,5,4,500,36,0
|
|
1
node/node_modules/redis-parser/isolate-0x3615b50-v8.log
generated
vendored
1
node/node_modules/redis-parser/isolate-0x3615b50-v8.log
generated
vendored
|
@ -1 +0,0 @@
|
||||||
v8-version,5,4,500,36,0
|
|
18
node/node_modules/redis-parser/lib/hiredis.js
generated
vendored
18
node/node_modules/redis-parser/lib/hiredis.js
generated
vendored
|
@ -2,20 +2,21 @@
|
||||||
|
|
||||||
var hiredis = require('hiredis')
|
var hiredis = require('hiredis')
|
||||||
var ReplyError = require('../lib/replyError')
|
var ReplyError = require('../lib/replyError')
|
||||||
|
var ParserError = require('../lib/parserError')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse data
|
* Parse data
|
||||||
* @param parser
|
* @param parser
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function parseData (parser) {
|
function parseData (parser, data) {
|
||||||
try {
|
try {
|
||||||
return parser.reader.get()
|
return parser.reader.get()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Protocol errors land here
|
// Protocol errors land here
|
||||||
// Reset the parser. Otherwise new commands can't be processed properly
|
// Reset the parser. Otherwise new commands can't be processed properly
|
||||||
parser.reader = new hiredis.Reader(parser.options)
|
parser.reader = new hiredis.Reader(parser.options)
|
||||||
parser.returnFatalError(new ReplyError(err.message))
|
parser.returnFatalError(new ParserError(err.message, JSON.stringify(data), -1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ function HiredisReplyParser (options) {
|
||||||
|
|
||||||
HiredisReplyParser.prototype.execute = function (data) {
|
HiredisReplyParser.prototype.execute = function (data) {
|
||||||
this.reader.feed(data)
|
this.reader.feed(data)
|
||||||
var reply = parseData(this)
|
var reply = parseData(this, data)
|
||||||
|
|
||||||
while (reply !== undefined) {
|
while (reply !== undefined) {
|
||||||
if (reply && reply.name === 'Error') {
|
if (reply && reply.name === 'Error') {
|
||||||
|
@ -45,8 +46,17 @@ HiredisReplyParser.prototype.execute = function (data) {
|
||||||
} else {
|
} else {
|
||||||
this.returnReply(reply)
|
this.returnReply(reply)
|
||||||
}
|
}
|
||||||
reply = parseData(this)
|
reply = parseData(this, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the parser values to the initial state
|
||||||
|
*
|
||||||
|
* @returns {undefined}
|
||||||
|
*/
|
||||||
|
HiredisReplyParser.prototype.reset = function () {
|
||||||
|
this.reader = new hiredis.Reader(this.options)
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = HiredisReplyParser
|
module.exports = HiredisReplyParser
|
||||||
|
|
241
node/node_modules/redis-parser/lib/parser.js
generated
vendored
241
node/node_modules/redis-parser/lib/parser.js
generated
vendored
|
@ -3,11 +3,23 @@
|
||||||
var StringDecoder = require('string_decoder').StringDecoder
|
var StringDecoder = require('string_decoder').StringDecoder
|
||||||
var decoder = new StringDecoder()
|
var decoder = new StringDecoder()
|
||||||
var ReplyError = require('./replyError')
|
var ReplyError = require('./replyError')
|
||||||
var bufferPool = new Buffer(32 * 1024)
|
var ParserError = require('./parserError')
|
||||||
|
var bufferPool = bufferAlloc(32 * 1024)
|
||||||
var bufferOffset = 0
|
var bufferOffset = 0
|
||||||
var interval = null
|
var interval = null
|
||||||
var counter = 0
|
var counter = 0
|
||||||
var notDecreased = 0
|
var notDecreased = 0
|
||||||
|
var isModern = typeof Buffer.allocUnsafe === 'function'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For backwards compatibility
|
||||||
|
* @param len
|
||||||
|
* @returns {Buffer}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function bufferAlloc (len) {
|
||||||
|
return isModern ? Buffer.allocUnsafe(len) : new Buffer(len)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for lengths and numbers only, faster perf on arrays / bulks
|
* Used for lengths and numbers only, faster perf on arrays / bulks
|
||||||
|
@ -100,7 +112,7 @@ function convertBufferRange (parser, start, end) {
|
||||||
* @param parser
|
* @param parser
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function parseSimpleStringViaOffset (parser) {
|
function parseSimpleString (parser) {
|
||||||
var start = parser.offset
|
var start = parser.offset
|
||||||
var offset = start
|
var offset = start
|
||||||
var buffer = parser.buffer
|
var buffer = parser.buffer
|
||||||
|
@ -173,7 +185,7 @@ function parseBulkString (parser) {
|
||||||
* @returns {Error}
|
* @returns {Error}
|
||||||
*/
|
*/
|
||||||
function parseError (parser) {
|
function parseError (parser) {
|
||||||
var string = parseSimpleStringViaOffset(parser)
|
var string = parseSimpleString(parser)
|
||||||
if (string !== undefined) {
|
if (string !== undefined) {
|
||||||
if (parser.optionReturnBuffers === true) {
|
if (parser.optionReturnBuffers === true) {
|
||||||
string = string.toString()
|
string = string.toString()
|
||||||
|
@ -209,13 +221,36 @@ function parseArray (parser) {
|
||||||
return parseArrayElements(parser, responses, 0)
|
return parseArrayElements(parser, responses, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push a partly parsed array to the stack
|
||||||
|
*
|
||||||
|
* @param parser
|
||||||
|
* @param elem
|
||||||
|
* @param i
|
||||||
|
* @returns {undefined}
|
||||||
|
*/
|
||||||
|
function pushArrayCache (parser, elem, pos) {
|
||||||
|
parser.arrayCache.push(elem)
|
||||||
|
parser.arrayPos.push(pos)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse chunked redis array response
|
* Parse chunked redis array response
|
||||||
* @param parser
|
* @param parser
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function parseArrayChunks (parser) {
|
function parseArrayChunks (parser) {
|
||||||
return parseArrayElements(parser, parser.arrayCache, parser.arrayPos)
|
var tmp = parser.arrayCache.pop()
|
||||||
|
var pos = parser.arrayPos.pop()
|
||||||
|
if (parser.arrayCache.length) {
|
||||||
|
var res = parseArrayChunks(parser)
|
||||||
|
if (!res) {
|
||||||
|
pushArrayCache(parser, tmp, pos)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tmp[pos++] = res
|
||||||
|
}
|
||||||
|
return parseArrayElements(parser, tmp, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,16 +265,15 @@ function parseArrayElements (parser, responses, i) {
|
||||||
while (i < responses.length) {
|
while (i < responses.length) {
|
||||||
var offset = parser.offset
|
var offset = parser.offset
|
||||||
if (parser.offset >= bufferLength) {
|
if (parser.offset >= bufferLength) {
|
||||||
parser.arrayCache = responses
|
pushArrayCache(parser, responses, i)
|
||||||
parser.arrayPos = i
|
|
||||||
parser.offset = offset
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var response = parseType(parser, parser.buffer[parser.offset++])
|
var response = parseType(parser, parser.buffer[parser.offset++])
|
||||||
if (response === undefined) {
|
if (response === undefined) {
|
||||||
parser.arrayCache = responses
|
if (!parser.arrayCache.length) {
|
||||||
parser.arrayPos = i
|
|
||||||
parser.offset = offset
|
parser.offset = offset
|
||||||
|
}
|
||||||
|
pushArrayCache(parser, responses, i)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
responses[i] = response
|
responses[i] = response
|
||||||
|
@ -262,16 +296,17 @@ function parseType (parser, type) {
|
||||||
case 58: // :
|
case 58: // :
|
||||||
return parseInteger(parser)
|
return parseInteger(parser)
|
||||||
case 43: // +
|
case 43: // +
|
||||||
return parseSimpleStringViaOffset(parser)
|
return parseSimpleString(parser)
|
||||||
case 42: // *
|
case 42: // *
|
||||||
return parseArray(parser)
|
return parseArray(parser)
|
||||||
case 45: // -
|
case 45: // -
|
||||||
return parseError(parser)
|
return parseError(parser)
|
||||||
default:
|
default:
|
||||||
var err = new ReplyError('Protocol error, got ' + JSON.stringify(String.fromCharCode(type)) + ' as reply type byte', 20)
|
return handleError(parser, new ParserError(
|
||||||
err.offset = parser.offset
|
'Protocol error, got ' + JSON.stringify(String.fromCharCode(type)) + ' as reply type byte',
|
||||||
err.buffer = JSON.stringify(parser.buffer)
|
JSON.stringify(parser.buffer),
|
||||||
return handleError(parser, err)
|
parser.offset
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,8 +333,9 @@ function JavascriptRedisParser (options) {
|
||||||
throw new TypeError('Please provide all return functions while initiating the parser')
|
throw new TypeError('Please provide all return functions while initiating the parser')
|
||||||
}
|
}
|
||||||
for (var key in options) {
|
for (var key in options) {
|
||||||
|
// eslint-disable-next-line valid-typeof
|
||||||
if (optionTypes.hasOwnProperty(key) && typeof options[key] !== optionTypes[key]) {
|
if (optionTypes.hasOwnProperty(key) && typeof options[key] !== optionTypes[key]) {
|
||||||
throw new TypeError('The options argument contains the property "' + key + '" that is either unkown or of a wrong type')
|
throw new TypeError('The options argument contains the property "' + key + '" that is either unknown or of a wrong type')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.name === 'hiredis') {
|
if (options.name === 'hiredis') {
|
||||||
|
@ -318,44 +354,49 @@ function JavascriptRedisParser (options) {
|
||||||
this.returnFatalError = options.returnFatalError || options.returnError
|
this.returnFatalError = options.returnFatalError || options.returnError
|
||||||
this.returnReply = options.returnReply
|
this.returnReply = options.returnReply
|
||||||
this.name = 'javascript'
|
this.name = 'javascript'
|
||||||
|
this.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the parser values to the initial state
|
||||||
|
*
|
||||||
|
* @returns {undefined}
|
||||||
|
*/
|
||||||
|
JavascriptRedisParser.prototype.reset = function () {
|
||||||
this.offset = 0
|
this.offset = 0
|
||||||
this.buffer = null
|
this.buffer = null
|
||||||
this.bigStrSize = 0
|
this.bigStrSize = 0
|
||||||
this.bigOffset = 0
|
this.bigOffset = 0
|
||||||
this.totalChunkSize = 0
|
this.totalChunkSize = 0
|
||||||
this.bufferCache = []
|
this.bufferCache = []
|
||||||
this.arrayCache = null
|
this.arrayCache = []
|
||||||
this.arrayPos = 0
|
this.arrayPos = []
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concat a bulk string containing multiple chunks
|
* Set the returnBuffers option
|
||||||
*
|
*
|
||||||
* Notes:
|
* @param returnBuffers
|
||||||
* 1) The first chunk might contain the whole bulk string including the \r
|
* @returns {undefined}
|
||||||
* 2) We are only safe to fully add up elements that are neither the first nor any of the last two elements
|
|
||||||
*
|
|
||||||
* @param parser
|
|
||||||
* @param buffer
|
|
||||||
* @returns {String}
|
|
||||||
*/
|
*/
|
||||||
function concatBulkString (parser) {
|
JavascriptRedisParser.prototype.setReturnBuffers = function (returnBuffers) {
|
||||||
var list = parser.bufferCache
|
if (typeof returnBuffers !== 'boolean') {
|
||||||
var chunks = list.length
|
throw new TypeError('The returnBuffers argument has to be a boolean')
|
||||||
var offset = parser.bigStrSize - parser.totalChunkSize
|
|
||||||
parser.offset = offset
|
|
||||||
if (offset === 1) {
|
|
||||||
if (chunks === 2) {
|
|
||||||
return list[0].toString('utf8', parser.bigOffset, list[0].length - 1)
|
|
||||||
}
|
}
|
||||||
chunks--
|
this.optionReturnBuffers = returnBuffers
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the stringNumbers option
|
||||||
|
*
|
||||||
|
* @param stringNumbers
|
||||||
|
* @returns {undefined}
|
||||||
|
*/
|
||||||
|
JavascriptRedisParser.prototype.setStringNumbers = function (stringNumbers) {
|
||||||
|
if (typeof stringNumbers !== 'boolean') {
|
||||||
|
throw new TypeError('The stringNumbers argument has to be a boolean')
|
||||||
}
|
}
|
||||||
var res = decoder.write(list[0].slice(parser.bigOffset))
|
this.optionStringNumbers = stringNumbers
|
||||||
for (var i = 1; i < chunks - 1; i++) {
|
|
||||||
res += decoder.write(list[i])
|
|
||||||
}
|
|
||||||
res += decoder.end(list[i].slice(0, offset - 2))
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -387,38 +428,89 @@ function decreaseBufferPool () {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concat the collected chunks from parser.bufferCache
|
* Check if the requested size fits in the current bufferPool.
|
||||||
* @param parser
|
* If it does not, reset and increase the bufferPool accordingly.
|
||||||
|
*
|
||||||
* @param length
|
* @param length
|
||||||
* @returns {Buffer}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
function concatBuffer (parser, length) {
|
function resizeBuffer (length) {
|
||||||
var list = parser.bufferCache
|
|
||||||
var pos = bufferOffset
|
|
||||||
length -= parser.offset
|
|
||||||
if (bufferPool.length < length + bufferOffset) {
|
if (bufferPool.length < length + bufferOffset) {
|
||||||
// Increase the bufferPool size
|
|
||||||
var multiplier = length > 1024 * 1024 * 75 ? 2 : 3
|
var multiplier = length > 1024 * 1024 * 75 ? 2 : 3
|
||||||
if (bufferOffset > 1024 * 1024 * 120) {
|
if (bufferOffset > 1024 * 1024 * 111) {
|
||||||
bufferOffset = 1024 * 1024 * 50
|
bufferOffset = 1024 * 1024 * 50
|
||||||
}
|
}
|
||||||
bufferPool = new Buffer(length * multiplier + bufferOffset)
|
bufferPool = bufferAlloc(length * multiplier + bufferOffset)
|
||||||
bufferOffset = 0
|
bufferOffset = 0
|
||||||
counter++
|
counter++
|
||||||
pos = 0
|
|
||||||
if (interval === null) {
|
if (interval === null) {
|
||||||
interval = setInterval(decreaseBufferPool, 50)
|
interval = setInterval(decreaseBufferPool, 50)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list[0].copy(bufferPool, pos, parser.offset, list[0].length)
|
}
|
||||||
pos += list[0].length - parser.offset
|
|
||||||
for (var i = 1; i < list.length; i++) {
|
/**
|
||||||
list[i].copy(bufferPool, pos)
|
* Concat a bulk string containing multiple chunks
|
||||||
pos += list[i].length
|
*
|
||||||
|
* Notes:
|
||||||
|
* 1) The first chunk might contain the whole bulk string including the \r
|
||||||
|
* 2) We are only safe to fully add up elements that are neither the first nor any of the last two elements
|
||||||
|
*
|
||||||
|
* @param parser
|
||||||
|
* @returns {String}
|
||||||
|
*/
|
||||||
|
function concatBulkString (parser) {
|
||||||
|
var list = parser.bufferCache
|
||||||
|
var chunks = list.length
|
||||||
|
var offset = parser.bigStrSize - parser.totalChunkSize
|
||||||
|
parser.offset = offset
|
||||||
|
if (offset <= 2) {
|
||||||
|
if (chunks === 2) {
|
||||||
|
return list[0].toString('utf8', parser.bigOffset, list[0].length + offset - 2)
|
||||||
}
|
}
|
||||||
var buffer = bufferPool.slice(bufferOffset, length + bufferOffset)
|
chunks--
|
||||||
bufferOffset += length
|
offset = list[list.length - 2].length + offset
|
||||||
return buffer
|
}
|
||||||
|
var res = decoder.write(list[0].slice(parser.bigOffset))
|
||||||
|
for (var i = 1; i < chunks - 1; i++) {
|
||||||
|
res += decoder.write(list[i])
|
||||||
|
}
|
||||||
|
res += decoder.end(list[i].slice(0, offset - 2))
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Concat the collected chunks from parser.bufferCache.
|
||||||
|
*
|
||||||
|
* Increases the bufferPool size beforehand if necessary.
|
||||||
|
*
|
||||||
|
* @param parser
|
||||||
|
* @returns {Buffer}
|
||||||
|
*/
|
||||||
|
function concatBulkBuffer (parser) {
|
||||||
|
var list = parser.bufferCache
|
||||||
|
var chunks = list.length
|
||||||
|
var length = parser.bigStrSize - parser.bigOffset - 2
|
||||||
|
var offset = parser.bigStrSize - parser.totalChunkSize
|
||||||
|
parser.offset = offset
|
||||||
|
if (offset <= 2) {
|
||||||
|
if (chunks === 2) {
|
||||||
|
return list[0].slice(parser.bigOffset, list[0].length + offset - 2)
|
||||||
|
}
|
||||||
|
chunks--
|
||||||
|
offset = list[list.length - 2].length + offset
|
||||||
|
}
|
||||||
|
resizeBuffer(length)
|
||||||
|
var start = bufferOffset
|
||||||
|
list[0].copy(bufferPool, start, parser.bigOffset, list[0].length)
|
||||||
|
bufferOffset += list[0].length - parser.bigOffset
|
||||||
|
for (var i = 1; i < chunks - 1; i++) {
|
||||||
|
list[i].copy(bufferPool, bufferOffset)
|
||||||
|
bufferOffset += list[i].length
|
||||||
|
}
|
||||||
|
list[i].copy(bufferPool, bufferOffset, 0, offset - 2)
|
||||||
|
bufferOffset += offset - 2
|
||||||
|
return bufferPool.slice(start, bufferOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,47 +519,38 @@ function concatBuffer (parser, length) {
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
JavascriptRedisParser.prototype.execute = function execute (buffer) {
|
JavascriptRedisParser.prototype.execute = function execute (buffer) {
|
||||||
var arr
|
|
||||||
if (this.buffer === null) {
|
if (this.buffer === null) {
|
||||||
this.buffer = buffer
|
this.buffer = buffer
|
||||||
this.offset = 0
|
this.offset = 0
|
||||||
} else if (this.bigStrSize === 0) {
|
} else if (this.bigStrSize === 0) {
|
||||||
var oldLength = this.buffer.length
|
var oldLength = this.buffer.length
|
||||||
var remainingLength = oldLength - this.offset
|
var remainingLength = oldLength - this.offset
|
||||||
var newBuffer = new Buffer(remainingLength + buffer.length)
|
var newBuffer = bufferAlloc(remainingLength + buffer.length)
|
||||||
this.buffer.copy(newBuffer, 0, this.offset, oldLength)
|
this.buffer.copy(newBuffer, 0, this.offset, oldLength)
|
||||||
buffer.copy(newBuffer, remainingLength, 0, buffer.length)
|
buffer.copy(newBuffer, remainingLength, 0, buffer.length)
|
||||||
this.buffer = newBuffer
|
this.buffer = newBuffer
|
||||||
this.offset = 0
|
this.offset = 0
|
||||||
if (this.arrayCache) {
|
if (this.arrayCache.length) {
|
||||||
arr = parseArrayChunks(this)
|
var arr = parseArrayChunks(this)
|
||||||
if (!arr) {
|
if (!arr) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.returnReply(arr)
|
this.returnReply(arr)
|
||||||
this.arrayCache = null
|
|
||||||
}
|
}
|
||||||
} else if (this.totalChunkSize + buffer.length >= this.bigStrSize) {
|
} else if (this.totalChunkSize + buffer.length >= this.bigStrSize) {
|
||||||
this.bufferCache.push(buffer)
|
this.bufferCache.push(buffer)
|
||||||
if (this.optionReturnBuffers === false && !this.arrayCache) {
|
var tmp = this.optionReturnBuffers ? concatBulkBuffer(this) : concatBulkString(this)
|
||||||
this.returnReply(concatBulkString(this))
|
|
||||||
this.buffer = buffer
|
|
||||||
} else {
|
|
||||||
this.buffer = concatBuffer(this, this.totalChunkSize + buffer.length)
|
|
||||||
this.offset = 0
|
|
||||||
if (this.arrayCache) {
|
|
||||||
arr = parseArrayChunks(this)
|
|
||||||
if (!arr) {
|
|
||||||
this.bigStrSize = 0
|
this.bigStrSize = 0
|
||||||
this.bufferCache = []
|
this.bufferCache = []
|
||||||
|
this.buffer = buffer
|
||||||
|
if (this.arrayCache.length) {
|
||||||
|
this.arrayCache[0][this.arrayPos[0]++] = tmp
|
||||||
|
tmp = parseArrayChunks(this)
|
||||||
|
if (!tmp) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.returnReply(arr)
|
|
||||||
this.arrayCache = null
|
|
||||||
}
|
}
|
||||||
}
|
this.returnReply(tmp)
|
||||||
this.bigStrSize = 0
|
|
||||||
this.bufferCache = []
|
|
||||||
} else {
|
} else {
|
||||||
this.bufferCache.push(buffer)
|
this.bufferCache.push(buffer)
|
||||||
this.totalChunkSize += buffer.length
|
this.totalChunkSize += buffer.length
|
||||||
|
@ -479,7 +562,7 @@ JavascriptRedisParser.prototype.execute = function execute (buffer) {
|
||||||
var type = this.buffer[this.offset++]
|
var type = this.buffer[this.offset++]
|
||||||
var response = parseType(this, type)
|
var response = parseType(this, type)
|
||||||
if (response === undefined) {
|
if (response === undefined) {
|
||||||
if (!this.arrayCache) {
|
if (!this.arrayCache.length) {
|
||||||
this.offset = offset
|
this.offset = offset
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
25
node/node_modules/redis-parser/lib/parserError.js
generated
vendored
Normal file
25
node/node_modules/redis-parser/lib/parserError.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
var util = require('util')
|
||||||
|
var assert = require('assert')
|
||||||
|
var RedisError = require('./redisError')
|
||||||
|
var ADD_STACKTRACE = false
|
||||||
|
|
||||||
|
function ParserError (message, buffer, offset) {
|
||||||
|
assert(buffer)
|
||||||
|
assert.strictEqual(typeof offset, 'number')
|
||||||
|
RedisError.call(this, message, ADD_STACKTRACE)
|
||||||
|
this.offset = offset
|
||||||
|
this.buffer = buffer
|
||||||
|
Error.captureStackTrace(this, ParserError)
|
||||||
|
}
|
||||||
|
|
||||||
|
util.inherits(ParserError, RedisError)
|
||||||
|
|
||||||
|
Object.defineProperty(ParserError.prototype, 'name', {
|
||||||
|
value: 'ParserError',
|
||||||
|
configurable: true,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = ParserError
|
24
node/node_modules/redis-parser/lib/redisError.js
generated
vendored
Normal file
24
node/node_modules/redis-parser/lib/redisError.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
var util = require('util')
|
||||||
|
|
||||||
|
function RedisError (message, stack) {
|
||||||
|
Object.defineProperty(this, 'message', {
|
||||||
|
value: message || '',
|
||||||
|
configurable: true,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
if (stack || stack === undefined) {
|
||||||
|
Error.captureStackTrace(this, RedisError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
util.inherits(RedisError, Error)
|
||||||
|
|
||||||
|
Object.defineProperty(RedisError.prototype, 'name', {
|
||||||
|
value: 'RedisError',
|
||||||
|
configurable: true,
|
||||||
|
writable: true
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = RedisError
|
21
node/node_modules/redis-parser/lib/replyError.js
generated
vendored
21
node/node_modules/redis-parser/lib/replyError.js
generated
vendored
|
@ -1,23 +1,22 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var util = require('util')
|
var util = require('util')
|
||||||
|
var RedisError = require('./redisError')
|
||||||
|
var ADD_STACKTRACE = false
|
||||||
|
|
||||||
function ReplyError (message, newLimit) {
|
function ReplyError (message) {
|
||||||
var limit = Error.stackTraceLimit
|
var tmp = Error.stackTraceLimit
|
||||||
Error.stackTraceLimit = newLimit || 2
|
Error.stackTraceLimit = 2
|
||||||
Error.call(this, message)
|
RedisError.call(this, message, ADD_STACKTRACE)
|
||||||
Error.captureStackTrace(this, this.constructor)
|
Error.captureStackTrace(this, ReplyError)
|
||||||
Error.stackTraceLimit = limit
|
Error.stackTraceLimit = tmp
|
||||||
Object.defineProperty(this, 'message', {
|
|
||||||
value: message || '',
|
|
||||||
writable: true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
util.inherits(ReplyError, Error)
|
util.inherits(ReplyError, RedisError)
|
||||||
|
|
||||||
Object.defineProperty(ReplyError.prototype, 'name', {
|
Object.defineProperty(ReplyError.prototype, 'name', {
|
||||||
value: 'ReplyError',
|
value: 'ReplyError',
|
||||||
|
configurable: true,
|
||||||
writable: true
|
writable: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
74
node/node_modules/redis-parser/package.json
generated
vendored
74
node/node_modules/redis-parser/package.json
generated
vendored
|
@ -1,49 +1,26 @@
|
||||||
{
|
{
|
||||||
"_args": [
|
"_from": "redis-parser@^2.6.0",
|
||||||
[
|
"_id": "redis-parser@2.6.0",
|
||||||
{
|
"_inBundle": false,
|
||||||
"raw": "redis-parser@^2.0.0",
|
"_integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=",
|
||||||
"scope": null,
|
|
||||||
"escapedName": "redis-parser",
|
|
||||||
"name": "redis-parser",
|
|
||||||
"rawSpec": "^2.0.0",
|
|
||||||
"spec": ">=2.0.0 <3.0.0",
|
|
||||||
"type": "range"
|
|
||||||
},
|
|
||||||
"/Users/sclay/projects/newsblur/node/node_modules/redis"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "redis-parser@>=2.0.0 <3.0.0",
|
|
||||||
"_id": "redis-parser@2.3.0",
|
|
||||||
"_inCache": true,
|
|
||||||
"_location": "/redis-parser",
|
"_location": "/redis-parser",
|
||||||
"_nodeVersion": "7.1.0",
|
|
||||||
"_npmOperationalInternal": {
|
|
||||||
"host": "packages-18-east.internal.npmjs.com",
|
|
||||||
"tmp": "tmp/redis-parser-2.3.0.tgz_1480100588628_0.9477839153259993"
|
|
||||||
},
|
|
||||||
"_npmUser": {
|
|
||||||
"name": "bridgear",
|
|
||||||
"email": "ruben@bridgewater.de"
|
|
||||||
},
|
|
||||||
"_npmVersion": "3.10.9",
|
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
"raw": "redis-parser@^2.0.0",
|
"type": "range",
|
||||||
"scope": null,
|
"registry": true,
|
||||||
"escapedName": "redis-parser",
|
"raw": "redis-parser@^2.6.0",
|
||||||
"name": "redis-parser",
|
"name": "redis-parser",
|
||||||
"rawSpec": "^2.0.0",
|
"escapedName": "redis-parser",
|
||||||
"spec": ">=2.0.0 <3.0.0",
|
"rawSpec": "^2.6.0",
|
||||||
"type": "range"
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "^2.6.0"
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"/redis"
|
"/redis"
|
||||||
],
|
],
|
||||||
"_resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.3.0.tgz",
|
"_resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz",
|
||||||
"_shasum": "313a47965e49ee35ab3a86c93388b403d76237f6",
|
"_shasum": "52ed09dacac108f1a631c07e9b69941e7a19504b",
|
||||||
"_shrinkwrap": null,
|
"_spec": "redis-parser@^2.6.0",
|
||||||
"_spec": "redis-parser@^2.0.0",
|
|
||||||
"_where": "/Users/sclay/projects/newsblur/node/node_modules/redis",
|
"_where": "/Users/sclay/projects/newsblur/node/node_modules/redis",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Ruben Bridgewater"
|
"name": "Ruben Bridgewater"
|
||||||
|
@ -51,7 +28,8 @@
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/NodeRedis/node-redis-parser/issues"
|
"url": "https://github.com/NodeRedis/node-redis-parser/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"bundleDependencies": false,
|
||||||
|
"deprecated": false,
|
||||||
"description": "Javascript Redis protocol (RESP) parser",
|
"description": "Javascript Redis protocol (RESP) parser",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"benchmark": "^2.1.0",
|
"benchmark": "^2.1.0",
|
||||||
|
@ -60,20 +38,15 @@
|
||||||
"intercept-stdout": "^0.1.2",
|
"intercept-stdout": "^0.1.2",
|
||||||
"istanbul": "^0.4.0",
|
"istanbul": "^0.4.0",
|
||||||
"mocha": "^3.1.2",
|
"mocha": "^3.1.2",
|
||||||
"standard": "^8.5.0"
|
"standard": "^9.0.0"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test",
|
"test": "test",
|
||||||
"lib": "lib"
|
"lib": "lib"
|
||||||
},
|
},
|
||||||
"dist": {
|
|
||||||
"shasum": "313a47965e49ee35ab3a86c93388b403d76237f6",
|
|
||||||
"tarball": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.3.0.tgz"
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
},
|
},
|
||||||
"gitHead": "26be8f841e43afd4d1453ae21b55df129f2aa271",
|
|
||||||
"homepage": "https://github.com/NodeRedis/node-redis-parser#readme",
|
"homepage": "https://github.com/NodeRedis/node-redis-parser#readme",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"redis",
|
"redis",
|
||||||
|
@ -88,15 +61,7 @@
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"maintainers": [
|
|
||||||
{
|
|
||||||
"name": "bridgear",
|
|
||||||
"email": "ruben@bridgewater.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "redis-parser",
|
"name": "redis-parser",
|
||||||
"optionalDependencies": {},
|
|
||||||
"readme": "ERROR: No README data found!",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/NodeRedis/node-redis-parser.git"
|
"url": "git+https://github.com/NodeRedis/node-redis-parser.git"
|
||||||
|
@ -105,8 +70,9 @@
|
||||||
"benchmark": "node ./benchmark",
|
"benchmark": "node ./benchmark",
|
||||||
"coverage": "node ./node_modules/istanbul/lib/cli.js cover --preserve-comments ./node_modules/mocha/bin/_mocha -- -R spec",
|
"coverage": "node ./node_modules/istanbul/lib/cli.js cover --preserve-comments ./node_modules/mocha/bin/_mocha -- -R spec",
|
||||||
"coverage:check": "node ./node_modules/istanbul/lib/cli.js check-coverage --branch 100 --statement 100",
|
"coverage:check": "node ./node_modules/istanbul/lib/cli.js check-coverage --branch 100 --statement 100",
|
||||||
"posttest": "standard && npm run coverage:check",
|
"lint": "standard --fix",
|
||||||
|
"posttest": "npm run lint && npm run coverage:check",
|
||||||
"test": "npm run coverage"
|
"test": "npm run coverage"
|
||||||
},
|
},
|
||||||
"version": "2.3.0"
|
"version": "2.6.0"
|
||||||
}
|
}
|
||||||
|
|
389
node/node_modules/redis/README.md
generated
vendored
389
node/node_modules/redis/README.md
generated
vendored
|
@ -6,7 +6,8 @@ redis - a node.js redis client
|
||||||
[](https://ci.appveyor.com/project/BridgeAR/node-redis/branch/master)
|
[](https://ci.appveyor.com/project/BridgeAR/node-redis/branch/master)
|
||||||
[](https://gitter.im/NodeRedis/node_redis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
[](https://gitter.im/NodeRedis/node_redis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||||
|
|
||||||
This is a complete and feature rich Redis client for node.js. __It supports all Redis commands__ and focuses on high performance.
|
This is a complete and feature rich Redis client for node.js. __It supports all
|
||||||
|
Redis commands__ and focuses on high performance.
|
||||||
|
|
||||||
Install with:
|
Install with:
|
||||||
|
|
||||||
|
@ -48,13 +49,16 @@ This will display:
|
||||||
1: hashtest 2
|
1: hashtest 2
|
||||||
mjr:~/work/node_redis (master)$
|
mjr:~/work/node_redis (master)$
|
||||||
|
|
||||||
Note that the API is entirely asynchronous. To get data back from the server, you'll need to use a callback.
|
Note that the API is entirely asynchronous. To get data back from the server,
|
||||||
From v.2.6 on the API supports camelCase and snake_case and all options / variables / events etc. can be used either way.
|
you'll need to use a callback. From v.2.6 on the API supports camelCase and
|
||||||
It is recommended to use camelCase as this is the default for the Node.js landscape.
|
snake_case and all options / variables / events etc. can be used either way. It
|
||||||
|
is recommended to use camelCase as this is the default for the Node.js
|
||||||
|
landscape.
|
||||||
|
|
||||||
### Promises
|
### Promises
|
||||||
|
|
||||||
You can also use node_redis with promises by promisifying node_redis with [bluebird](https://github.com/petkaantonov/bluebird) as in:
|
You can also use node_redis with promises by promisifying node_redis with
|
||||||
|
[bluebird](https://github.com/petkaantonov/bluebird) as in:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var redis = require('redis');
|
var redis = require('redis');
|
||||||
|
@ -100,7 +104,8 @@ client.set("some key", "some val");
|
||||||
client.set(["some other key", "some val"]);
|
client.set(["some other key", "some val"]);
|
||||||
```
|
```
|
||||||
|
|
||||||
If the key is missing, reply will be null. Only if the [Redis Command Reference](http://redis.io/commands) states something else it will not be null.
|
If the key is missing, reply will be null. Only if the [Redis Command
|
||||||
|
Reference](http://redis.io/commands) states something else it will not be null.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
client.get("missingkey", function(err, reply) {
|
client.get("missingkey", function(err, reply) {
|
||||||
|
@ -111,8 +116,24 @@ client.get("missingkey", function(err, reply) {
|
||||||
|
|
||||||
For a list of Redis commands, see [Redis Command Reference](http://redis.io/commands)
|
For a list of Redis commands, see [Redis Command Reference](http://redis.io/commands)
|
||||||
|
|
||||||
Minimal parsing is done on the replies. Commands that return a integer return JavaScript Numbers, arrays return JavaScript Array. `HGETALL` returns an Object keyed by the hash keys. All strings will either be returned as string or as buffer depending on your setting.
|
Minimal parsing is done on the replies. Commands that return a integer return
|
||||||
Please be aware that sending null, undefined and Boolean values will result in the value coerced to a string!
|
JavaScript Numbers, arrays return JavaScript Array. `HGETALL` returns an Object
|
||||||
|
keyed by the hash keys. All strings will either be returned as string or as
|
||||||
|
buffer depending on your setting. Please be aware that sending null, undefined
|
||||||
|
and Boolean values will result in the value coerced to a string!
|
||||||
|
|
||||||
|
# Redis Commands
|
||||||
|
|
||||||
|
This library is a 1 to 1 mapping to [Redis commands](https://redis.io/commands).
|
||||||
|
It is not a cache library so please refer to Redis commands page for full usage
|
||||||
|
details.
|
||||||
|
|
||||||
|
Example setting key to auto expire using [SET command](https://redis.io/commands/set)
|
||||||
|
|
||||||
|
```js
|
||||||
|
// this key will expire after 10 seconds
|
||||||
|
client.set('key', 'value!', 'EX', 10);
|
||||||
|
```
|
||||||
|
|
||||||
# API
|
# API
|
||||||
|
|
||||||
|
@ -122,8 +143,9 @@ Please be aware that sending null, undefined and Boolean values will result in t
|
||||||
|
|
||||||
### "ready"
|
### "ready"
|
||||||
|
|
||||||
`client` will emit `ready` once a connection is established. Commands issued before the `ready` event are queued,
|
`client` will emit `ready` once a connection is established. Commands issued
|
||||||
then replayed just before this event is emitted.
|
before the `ready` event are queued, then replayed just before this event is
|
||||||
|
emitted.
|
||||||
|
|
||||||
### "connect"
|
### "connect"
|
||||||
|
|
||||||
|
@ -131,13 +153,16 @@ then replayed just before this event is emitted.
|
||||||
|
|
||||||
### "reconnecting"
|
### "reconnecting"
|
||||||
|
|
||||||
`client` will emit `reconnecting` when trying to reconnect to the Redis server after losing the connection. Listeners
|
`client` will emit `reconnecting` when trying to reconnect to the Redis server
|
||||||
are passed an object containing `delay` (in ms) and `attempt` (the attempt #) attributes.
|
after losing the connection. Listeners are passed an object containing `delay`
|
||||||
|
(in ms) and `attempt` (the attempt #) attributes.
|
||||||
|
|
||||||
### "error"
|
### "error"
|
||||||
|
|
||||||
`client` will emit `error` when encountering an error connecting to the Redis server or when any other in node_redis occurs.
|
`client` will emit `error` when encountering an error connecting to the Redis
|
||||||
If you use a command without callback and encounter a ReplyError it is going to be emitted to the error listener.
|
server or when any other in node_redis occurs. If you use a command without
|
||||||
|
callback and encounter a ReplyError it is going to be emitted to the error
|
||||||
|
listener.
|
||||||
|
|
||||||
So please attach the error listener to node_redis.
|
So please attach the error listener to node_redis.
|
||||||
|
|
||||||
|
@ -147,33 +172,41 @@ So please attach the error listener to node_redis.
|
||||||
|
|
||||||
### "drain" (deprecated)
|
### "drain" (deprecated)
|
||||||
|
|
||||||
`client` will emit `drain` when the TCP connection to the Redis server has been buffering, but is now
|
`client` will emit `drain` when the TCP connection to the Redis server has been
|
||||||
writable. This event can be used to stream commands in to Redis and adapt to backpressure.
|
buffering, but is now writable. This event can be used to stream commands in to
|
||||||
|
Redis and adapt to backpressure.
|
||||||
|
|
||||||
If the stream is buffering `client.should_buffer` is set to true. Otherwise the variable is always set to false.
|
If the stream is buffering `client.should_buffer` is set to true. Otherwise the
|
||||||
That way you can decide when to reduce your send rate and resume sending commands when you get `drain`.
|
variable is always set to false. That way you can decide when to reduce your
|
||||||
|
send rate and resume sending commands when you get `drain`.
|
||||||
|
|
||||||
You can also check the return value of each command as it will also return the backpressure indicator (deprecated).
|
You can also check the return value of each command as it will also return the
|
||||||
If false is returned the stream had to buffer.
|
backpressure indicator (deprecated). If false is returned the stream had to
|
||||||
|
buffer.
|
||||||
|
|
||||||
### "warning"
|
### "warning"
|
||||||
|
|
||||||
`client` will emit `warning` when password was set but none is needed and if a deprecated option / function / similar is used.
|
`client` will emit `warning` when password was set but none is needed and if a
|
||||||
|
deprecated option / function / similar is used.
|
||||||
|
|
||||||
### "idle" (deprecated)
|
### "idle" (deprecated)
|
||||||
|
|
||||||
`client` will emit `idle` when there are no outstanding commands that are awaiting a response.
|
`client` will emit `idle` when there are no outstanding commands that are
|
||||||
|
awaiting a response.
|
||||||
|
|
||||||
## redis.createClient()
|
## redis.createClient()
|
||||||
If you have `redis-server` running on the same machine as node, then the defaults for
|
If you have `redis-server` running on the same machine as node, then the
|
||||||
port and host are probably fine and you don't need to supply any arguments. `createClient()` returns a `RedisClient` object. Otherwise, `createClient()` accepts these arguments:
|
defaults for port and host are probably fine and you don't need to supply any
|
||||||
|
arguments. `createClient()` returns a `RedisClient` object. Otherwise,
|
||||||
|
`createClient()` accepts these arguments:
|
||||||
|
|
||||||
* `redis.createClient([options])`
|
* `redis.createClient([options])`
|
||||||
* `redis.createClient(unix_socket[, options])`
|
* `redis.createClient(unix_socket[, options])`
|
||||||
* `redis.createClient(redis_url[, options])`
|
* `redis.createClient(redis_url[, options])`
|
||||||
* `redis.createClient(port[, host][, options])`
|
* `redis.createClient(port[, host][, options])`
|
||||||
|
|
||||||
__Tip:__ If the Redis server runs on the same machine as the client consider using unix sockets if possible to increase throughput.
|
__Tip:__ If the Redis server runs on the same machine as the client consider
|
||||||
|
using unix sockets if possible to increase throughput.
|
||||||
|
|
||||||
#### `options` object properties
|
#### `options` object properties
|
||||||
| Property | Default | Description |
|
| Property | Default | Description |
|
||||||
|
@ -197,7 +230,7 @@ __Tip:__ If the Redis server runs on the same machine as the client consider usi
|
||||||
| db | null | If set, client will run Redis `select` command on connect. |
|
| db | null | If set, client will run Redis `select` command on connect. |
|
||||||
| family | IPv4 | You can force using IPv6 if you set the family to 'IPv6'. See Node.js [net](https://nodejs.org/api/net.html) or [dns](https://nodejs.org/api/dns.html) modules on how to use the family type. |
|
| family | IPv4 | You can force using IPv6 if you set the family to 'IPv6'. See Node.js [net](https://nodejs.org/api/net.html) or [dns](https://nodejs.org/api/dns.html) modules on how to use the family type. |
|
||||||
| disable_resubscribing | false | If set to `true`, a client won't resubscribe after disconnecting. |
|
| disable_resubscribing | false | If set to `true`, a client won't resubscribe after disconnecting. |
|
||||||
| rename_commands | null | Passing an object with renamed commands to use instead of the original functions. See the [Redis security topics](http://redis.io/topics/security) for more info. |
|
| rename_commands | null | Passing an object with renamed commands to use instead of the original functions. For example, if you renamed the command KEYS to "DO-NOT-USE" then the rename_commands object would be: `{ KEYS : "DO-NOT-USE" }` . See the [Redis security topics](http://redis.io/topics/security) for more info. |
|
||||||
| tls | null | An object containing options to pass to [tls.connect](http://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback) to set up a TLS connection to Redis (if, for example, it is set up to be accessible via a tunnel). |
|
| tls | null | An object containing options to pass to [tls.connect](http://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback) to set up a TLS connection to Redis (if, for example, it is set up to be accessible via a tunnel). |
|
||||||
| prefix | null | A string used to prefix all used keys (e.g. `namespace:test`). Please be aware that the `keys` command will not be prefixed. The `keys` command has a "pattern" as argument and no key and it would be impossible to determine the existing keys in Redis if this would be prefixed. |
|
| prefix | null | A string used to prefix all used keys (e.g. `namespace:test`). Please be aware that the `keys` command will not be prefixed. The `keys` command has a "pattern" as argument and no key and it would be impossible to determine the existing keys in Redis if this would be prefixed. |
|
||||||
| retry_strategy | function | A function that receives an options object as parameter including the retry `attempt`, the `total_retry_time` indicating how much time passed since the last time connected, the `error` why the connection was lost and the number of `times_connected` in total. If you return a number from this function, the retry will happen exactly after that time in milliseconds. If you return a non-number, no further retry will happen and all offline commands are flushed with errors. Return an error to return that specific error to all offline commands. Example below. |
|
| retry_strategy | function | A function that receives an options object as parameter including the retry `attempt`, the `total_retry_time` indicating how much time passed since the last time connected, the `error` why the connection was lost and the number of `times_connected` in total. If you return a number from this function, the retry will happen exactly after that time in milliseconds. If you return a non-number, no further retry will happen and all offline commands are flushed with errors. Return an error to return that specific error to all offline commands. Example below. |
|
||||||
|
@ -221,34 +254,38 @@ client.quit();
|
||||||
```
|
```
|
||||||
|
|
||||||
retry_strategy example
|
retry_strategy example
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var client = redis.createClient({
|
var client = redis.createClient({
|
||||||
retry_strategy: function (options) {
|
retry_strategy: function (options) {
|
||||||
if (options.error.code === 'ECONNREFUSED') {
|
if (options.error && options.error.code === 'ECONNREFUSED') {
|
||||||
// End reconnecting on a specific error and flush all commands with a individual error
|
// End reconnecting on a specific error and flush all commands with
|
||||||
|
// a individual error
|
||||||
return new Error('The server refused the connection');
|
return new Error('The server refused the connection');
|
||||||
}
|
}
|
||||||
if (options.total_retry_time > 1000 * 60 * 60) {
|
if (options.total_retry_time > 1000 * 60 * 60) {
|
||||||
// End reconnecting after a specific timeout and flush all commands with a individual error
|
// End reconnecting after a specific timeout and flush all commands
|
||||||
|
// with a individual error
|
||||||
return new Error('Retry time exhausted');
|
return new Error('Retry time exhausted');
|
||||||
}
|
}
|
||||||
if (options.times_connected > 10) {
|
if (options.attempt > 10) {
|
||||||
// End reconnecting with built in error
|
// End reconnecting with built in error
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
// reconnect after
|
// reconnect after
|
||||||
return Math.max(options.attempt * 100, 3000);
|
return Math.min(options.attempt * 100, 3000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## client.auth(password[, callback])
|
## client.auth(password[, callback])
|
||||||
|
|
||||||
When connecting to a Redis server that requires authentication, the `AUTH` command must be sent as the
|
When connecting to a Redis server that requires authentication, the `AUTH`
|
||||||
first command after connecting. This can be tricky to coordinate with reconnections, the ready check,
|
command must be sent as the first command after connecting. This can be tricky
|
||||||
etc. To make this easier, `client.auth()` stashes `password` and will send it after each connection,
|
to coordinate with reconnections, the ready check, etc. To make this easier,
|
||||||
including reconnections. `callback` is invoked only once, after the response to the very first
|
`client.auth()` stashes `password` and will send it after each connection,
|
||||||
`AUTH` command sent.
|
including reconnections. `callback` is invoked only once, after the response to
|
||||||
|
the very first `AUTH` command sent.
|
||||||
NOTE: Your call to `client.auth()` should not be inside the ready handler. If
|
NOTE: Your call to `client.auth()` should not be inside the ready handler. If
|
||||||
you are doing this wrong, `client` will emit an error that looks
|
you are doing this wrong, `client` will emit an error that looks
|
||||||
something like this `Error: Ready check failed: ERR operation not permitted`.
|
something like this `Error: Ready check failed: ERR operation not permitted`.
|
||||||
|
@ -257,25 +294,34 @@ something like this `Error: Ready check failed: ERR operation not permitted`.
|
||||||
|
|
||||||
### stream
|
### stream
|
||||||
|
|
||||||
The client exposed the used [stream](https://nodejs.org/api/stream.html) in `client.stream` and if the stream or client had to [buffer](https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback) the command in `client.should_buffer`.
|
The client exposed the used [stream](https://nodejs.org/api/stream.html) in
|
||||||
In combination this can be used to implement backpressure by checking the buffer state before sending a command and listening to the stream [drain](https://nodejs.org/api/stream.html#stream_event_drain) event.
|
`client.stream` and if the stream or client had to
|
||||||
|
[buffer](https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback)
|
||||||
|
the command in `client.should_buffer`. In combination this can be used to
|
||||||
|
implement backpressure by checking the buffer state before sending a command and
|
||||||
|
listening to the stream
|
||||||
|
[drain](https://nodejs.org/api/stream.html#stream_event_drain) event.
|
||||||
|
|
||||||
## client.quit()
|
## client.quit()
|
||||||
|
|
||||||
This sends the quit command to the redis server and ends cleanly right after all running commands were properly handled.
|
This sends the quit command to the redis server and ends cleanly right after all
|
||||||
If this is called while reconnecting (and therefor no connection to the redis server exists) it is going to end the connection right away instead of
|
running commands were properly handled. If this is called while reconnecting
|
||||||
resulting in further reconnections! All offline commands are going to be flushed with an error in that case.
|
(and therefore no connection to the redis server exists) it is going to end the
|
||||||
|
connection right away instead of resulting in further reconnections! All offline
|
||||||
|
commands are going to be flushed with an error in that case.
|
||||||
|
|
||||||
## client.end(flush)
|
## client.end(flush)
|
||||||
|
|
||||||
Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.
|
Forcibly close the connection to the Redis server. Note that this does not wait
|
||||||
If you want to exit cleanly, call `client.quit()` as mentioned above.
|
until all replies have been parsed. If you want to exit cleanly, call
|
||||||
|
`client.quit()` as mentioned above.
|
||||||
|
|
||||||
You should set flush to true, if you are not absolutely sure you do not care about any other commands.
|
You should set flush to true, if you are not absolutely sure you do not care
|
||||||
If you set flush to false all still running commands will silently fail.
|
about any other commands. If you set flush to false all still running commands
|
||||||
|
will silently fail.
|
||||||
|
|
||||||
This example closes the connection to the Redis server before the replies have been read. You probably don't
|
This example closes the connection to the Redis server before the replies have
|
||||||
want to do this:
|
been read. You probably don't want to do this:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var redis = require("redis"),
|
var redis = require("redis"),
|
||||||
|
@ -296,10 +342,19 @@ client.get("foo_rand000000000000", function (err, reply) {
|
||||||
|
|
||||||
## Error handling (>= v.2.6)
|
## Error handling (>= v.2.6)
|
||||||
|
|
||||||
All redis errors are returned as `ReplyError`.
|
Currently the following error subclasses exist:
|
||||||
All unresolved commands that get rejected due to what ever reason return a `AbortError`.
|
|
||||||
As subclass of the `AbortError` a `AggregateError` exists. This is emitted in case multiple unresolved commands without callback got rejected in debug_mode.
|
* `RedisError`: _All errors_ returned by the client
|
||||||
They are all aggregated and a single error is emitted in that case.
|
* `ReplyError` subclass of `RedisError`: All errors returned by __Redis__ itself
|
||||||
|
* `AbortError` subclass of `RedisError`: All commands that could not finish due
|
||||||
|
to what ever reason
|
||||||
|
* `ParserError` subclass of `RedisError`: Returned in case of a parser error
|
||||||
|
(this should not happen)
|
||||||
|
* `AggregateError` subclass of `AbortError`: Emitted in case multiple unresolved
|
||||||
|
commands without callback got rejected in debug_mode instead of lots of
|
||||||
|
`AbortError`s.
|
||||||
|
|
||||||
|
All error classes are exported by the module.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```js
|
```js
|
||||||
|
@ -311,10 +366,11 @@ client.on('error', function (err) {
|
||||||
assert(err instanceof Error);
|
assert(err instanceof Error);
|
||||||
assert(err instanceof redis.AbortError);
|
assert(err instanceof redis.AbortError);
|
||||||
assert(err instanceof redis.AggregateError);
|
assert(err instanceof redis.AggregateError);
|
||||||
assert.strictEqual(err.errors.length, 2); // The set and get got aggregated in here
|
// The set and get get aggregated in here
|
||||||
|
assert.strictEqual(err.errors.length, 2);
|
||||||
assert.strictEqual(err.code, 'NR_CLOSED');
|
assert.strictEqual(err.code, 'NR_CLOSED');
|
||||||
});
|
});
|
||||||
client.set('foo', 123, 'bar', function (err, res) { // To many arguments
|
client.set('foo', 123, 'bar', function (err, res) { // Too many arguments
|
||||||
assert(err instanceof redis.ReplyError); // => true
|
assert(err instanceof redis.ReplyError); // => true
|
||||||
assert.strictEqual(err.command, 'SET');
|
assert.strictEqual(err.command, 'SET');
|
||||||
assert.deepStrictEqual(err.args, ['foo', 123, 'bar']);
|
assert.deepStrictEqual(err.args, ['foo', 123, 'bar']);
|
||||||
|
@ -323,7 +379,8 @@ client.set('foo', 123, 'bar', function (err, res) { // To many arguments
|
||||||
client.set('foo', 'bar');
|
client.set('foo', 'bar');
|
||||||
client.get('foo');
|
client.get('foo');
|
||||||
process.nextTick(function () {
|
process.nextTick(function () {
|
||||||
client.end(true); // Force closing the connection while the command did not yet return
|
// Force closing the connection while the command did not yet return
|
||||||
|
client.end(true);
|
||||||
redis.debug_mode = false;
|
redis.debug_mode = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -332,25 +389,33 @@ client.set('foo', 123, 'bar', function (err, res) { // To many arguments
|
||||||
|
|
||||||
Every `ReplyError` contains the `command` name in all-caps and the arguments (`args`).
|
Every `ReplyError` contains the `command` name in all-caps and the arguments (`args`).
|
||||||
|
|
||||||
If node_redis emits a library error because of another error, the triggering error is added to the returned error as `origin` attribute.
|
If node_redis emits a library error because of another error, the triggering
|
||||||
|
error is added to the returned error as `origin` attribute.
|
||||||
|
|
||||||
___Error codes___
|
___Error codes___
|
||||||
|
|
||||||
node_redis returns a `NR_CLOSED` error code if the clients connection dropped. If a command unresolved command got rejected a `UNERCTAIN_STATE` code is returned.
|
node_redis returns a `NR_CLOSED` error code if the clients connection dropped.
|
||||||
A `CONNECTION_BROKEN` error code is used in case node_redis gives up to reconnect.
|
If a command unresolved command got rejected a `UNCERTAIN_STATE` code is
|
||||||
|
returned. A `CONNECTION_BROKEN` error code is used in case node_redis gives up
|
||||||
|
to reconnect.
|
||||||
|
|
||||||
## client.unref()
|
## client.unref()
|
||||||
|
|
||||||
Call `unref()` on the underlying socket connection to the Redis server, allowing the program to exit once no more commands are pending.
|
Call `unref()` on the underlying socket connection to the Redis server, allowing
|
||||||
|
the program to exit once no more commands are pending.
|
||||||
|
|
||||||
This is an **experimental** feature, and only supports a subset of the Redis protocol. Any commands where client state is saved on the Redis server, e.g. `*SUBSCRIBE` or the blocking `BL*` commands will *NOT* work with `.unref()`.
|
This is an **experimental** feature, and only supports a subset of the Redis
|
||||||
|
protocol. Any commands where client state is saved on the Redis server, e.g.
|
||||||
|
`*SUBSCRIBE` or the blocking `BL*` commands will *NOT* work with `.unref()`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var redis = require("redis")
|
var redis = require("redis")
|
||||||
var client = redis.createClient()
|
var client = redis.createClient()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Calling unref() will allow this program to exit immediately after the get command finishes. Otherwise the client would hang as long as the client-server connection is alive.
|
Calling unref() will allow this program to exit immediately after the get
|
||||||
|
command finishes. Otherwise the client would hang as long as the
|
||||||
|
client-server connection is alive.
|
||||||
*/
|
*/
|
||||||
client.unref()
|
client.unref()
|
||||||
client.get("foo", function (err, value){
|
client.get("foo", function (err, value){
|
||||||
|
@ -361,13 +426,15 @@ client.get("foo", function (err, value){
|
||||||
|
|
||||||
## Friendlier hash commands
|
## Friendlier hash commands
|
||||||
|
|
||||||
Most Redis commands take a single String or an Array of Strings as arguments, and replies are sent back as a single String or an Array of Strings.
|
Most Redis commands take a single String or an Array of Strings as arguments,
|
||||||
When dealing with hash values, there are a couple of useful exceptions to this.
|
and replies are sent back as a single String or an Array of Strings. When
|
||||||
|
dealing with hash values, there are a couple of useful exceptions to this.
|
||||||
|
|
||||||
### client.hgetall(hash, callback)
|
### client.hgetall(hash, callback)
|
||||||
|
|
||||||
The reply from an HGETALL command will be converted into a JavaScript Object by `node_redis`. That way you can interact
|
The reply from an HGETALL command will be converted into a JavaScript Object by
|
||||||
with the responses using JavaScript syntax.
|
`node_redis`. That way you can interact with the responses using JavaScript
|
||||||
|
syntax.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -395,7 +462,8 @@ client.HMSET(key2, {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
The properties and values of this Object will be set as keys and values in the Redis hash.
|
The properties and values of this Object will be set as keys and values in the
|
||||||
|
Redis hash.
|
||||||
|
|
||||||
### client.hmset(hash, key1, val1, ... keyn, valn, [callback])
|
### client.hmset(hash, key1, val1, ... keyn, valn, [callback])
|
||||||
|
|
||||||
|
@ -435,11 +503,13 @@ sub.on("message", function (channel, message) {
|
||||||
sub.subscribe("a nice channel");
|
sub.subscribe("a nice channel");
|
||||||
```
|
```
|
||||||
|
|
||||||
When a client issues a `SUBSCRIBE` or `PSUBSCRIBE`, that connection is put into a "subscriber" mode.
|
When a client issues a `SUBSCRIBE` or `PSUBSCRIBE`, that connection is put into
|
||||||
At that point, only commands that modify the subscription set are valid and quit (and depending on the redis version ping as well). When the subscription
|
a "subscriber" mode. At that point, only commands that modify the subscription
|
||||||
set is empty, the connection is put back into regular mode.
|
set are valid and quit (and depending on the redis version ping as well). When
|
||||||
|
the subscription set is empty, the connection is put back into regular mode.
|
||||||
|
|
||||||
If you need to send regular commands to Redis while in subscriber mode, just open another connection with a new client (hint: use `client.duplicate()`).
|
If you need to send regular commands to Redis while in subscriber mode, just
|
||||||
|
open another connection with a new client (hint: use `client.duplicate()`).
|
||||||
|
|
||||||
## Subscriber Events
|
## Subscriber Events
|
||||||
|
|
||||||
|
@ -452,47 +522,57 @@ Listeners are passed the channel name as `channel` and the message as `message`.
|
||||||
|
|
||||||
### "pmessage" (pattern, channel, message)
|
### "pmessage" (pattern, channel, message)
|
||||||
|
|
||||||
Client will emit `pmessage` for every message received that matches an active subscription pattern.
|
Client will emit `pmessage` for every message received that matches an active
|
||||||
Listeners are passed the original pattern used with `PSUBSCRIBE` as `pattern`, the sending channel
|
subscription pattern. Listeners are passed the original pattern used with
|
||||||
name as `channel`, and the message as `message`.
|
`PSUBSCRIBE` as `pattern`, the sending channel name as `channel`, and the
|
||||||
|
message as `message`.
|
||||||
|
|
||||||
### "message_buffer" (channel, message)
|
### "message_buffer" (channel, message)
|
||||||
|
|
||||||
This is the same as the `message` event with the exception, that it is always going to emit a buffer.
|
This is the same as the `message` event with the exception, that it is always
|
||||||
If you listen to the `message` event at the same time as the `message_buffer`, it is always going to emit a string.
|
going to emit a buffer. If you listen to the `message` event at the same time as
|
||||||
|
the `message_buffer`, it is always going to emit a string.
|
||||||
|
|
||||||
### "pmessage_buffer" (pattern, channel, message)
|
### "pmessage_buffer" (pattern, channel, message)
|
||||||
|
|
||||||
This is the same as the `pmessage` event with the exception, that it is always going to emit a buffer.
|
This is the same as the `pmessage` event with the exception, that it is always
|
||||||
If you listen to the `pmessage` event at the same time as the `pmessage_buffer`, it is always going to emit a string.
|
going to emit a buffer. If you listen to the `pmessage` event at the same time
|
||||||
|
as the `pmessage_buffer`, it is always going to emit a string.
|
||||||
|
|
||||||
### "subscribe" (channel, count)
|
### "subscribe" (channel, count)
|
||||||
|
|
||||||
Client will emit `subscribe` in response to a `SUBSCRIBE` command. Listeners are passed the
|
Client will emit `subscribe` in response to a `SUBSCRIBE` command. Listeners are
|
||||||
channel name as `channel` and the new count of subscriptions for this client as `count`.
|
passed the channel name as `channel` and the new count of subscriptions for this
|
||||||
|
client as `count`.
|
||||||
|
|
||||||
### "psubscribe" (pattern, count)
|
### "psubscribe" (pattern, count)
|
||||||
|
|
||||||
Client will emit `psubscribe` in response to a `PSUBSCRIBE` command. Listeners are passed the
|
Client will emit `psubscribe` in response to a `PSUBSCRIBE` command. Listeners
|
||||||
original pattern as `pattern`, and the new count of subscriptions for this client as `count`.
|
are passed the original pattern as `pattern`, and the new count of subscriptions
|
||||||
|
for this client as `count`.
|
||||||
|
|
||||||
### "unsubscribe" (channel, count)
|
### "unsubscribe" (channel, count)
|
||||||
|
|
||||||
Client will emit `unsubscribe` in response to a `UNSUBSCRIBE` command. Listeners are passed the
|
Client will emit `unsubscribe` in response to a `UNSUBSCRIBE` command. Listeners
|
||||||
channel name as `channel` and the new count of subscriptions for this client as `count`. When
|
are passed the channel name as `channel` and the new count of subscriptions for
|
||||||
`count` is 0, this client has left subscriber mode and no more subscriber events will be emitted.
|
this client as `count`. When `count` is 0, this client has left subscriber mode
|
||||||
|
and no more subscriber events will be emitted.
|
||||||
|
|
||||||
### "punsubscribe" (pattern, count)
|
### "punsubscribe" (pattern, count)
|
||||||
|
|
||||||
Client will emit `punsubscribe` in response to a `PUNSUBSCRIBE` command. Listeners are passed the
|
Client will emit `punsubscribe` in response to a `PUNSUBSCRIBE` command.
|
||||||
channel name as `channel` and the new count of subscriptions for this client as `count`. When
|
Listeners are passed the channel name as `channel` and the new count of
|
||||||
`count` is 0, this client has left subscriber mode and no more subscriber events will be emitted.
|
subscriptions for this client as `count`. When `count` is 0, this client has
|
||||||
|
left subscriber mode and no more subscriber events will be emitted.
|
||||||
|
|
||||||
## client.multi([commands])
|
## client.multi([commands])
|
||||||
|
|
||||||
`MULTI` commands are queued up until an `EXEC` is issued, and then all commands are run atomically by
|
`MULTI` commands are queued up until an `EXEC` is issued, and then all commands
|
||||||
Redis. The interface in `node_redis` is to return an individual `Multi` object by calling `client.multi()`.
|
are run atomically by Redis. The interface in `node_redis` is to return an
|
||||||
If any command fails to queue, all commands are rolled back and none is going to be executed (For further information look at [transactions](http://redis.io/topics/transactions)).
|
individual `Multi` object by calling `client.multi()`. If any command fails to
|
||||||
|
queue, all commands are rolled back and none is going to be executed (For
|
||||||
|
further information look at
|
||||||
|
[transactions](http://redis.io/topics/transactions)).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var redis = require("./index"),
|
var redis = require("./index"),
|
||||||
|
@ -526,15 +606,20 @@ client.multi()
|
||||||
|
|
||||||
### Multi.exec([callback])
|
### Multi.exec([callback])
|
||||||
|
|
||||||
`client.multi()` is a constructor that returns a `Multi` object. `Multi` objects share all of the
|
`client.multi()` is a constructor that returns a `Multi` object. `Multi` objects
|
||||||
same command methods as `client` objects do. Commands are queued up inside the `Multi` object
|
share all of the same command methods as `client` objects do. Commands are
|
||||||
until `Multi.exec()` is invoked.
|
queued up inside the `Multi` object until `Multi.exec()` is invoked.
|
||||||
|
|
||||||
If your code contains an syntax error an EXECABORT error is going to be thrown and all commands are going to be aborted. That error contains a `.errors` property that contains the concret errors.
|
If your code contains an syntax error an EXECABORT error is going to be thrown
|
||||||
If all commands were queued successfully and an error is thrown by redis while processing the commands that error is going to be returned in the result array! No other command is going to be aborted though than the onces failing.
|
and all commands are going to be aborted. That error contains a `.errors`
|
||||||
|
property that contains the concrete errors.
|
||||||
|
If all commands were queued successfully and an error is thrown by redis while
|
||||||
|
processing the commands that error is going to be returned in the result array!
|
||||||
|
No other command is going to be aborted though than the onces failing.
|
||||||
|
|
||||||
You can either chain together `MULTI` commands as in the above example, or you can queue individual
|
You can either chain together `MULTI` commands as in the above example, or you
|
||||||
commands while still sending regular client command as in this example:
|
can queue individual commands while still sending regular client command as in
|
||||||
|
this example:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var redis = require("redis"),
|
var redis = require("redis"),
|
||||||
|
@ -554,8 +639,8 @@ multi.exec(function (err, replies) {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
In addition to adding commands to the `MULTI` queue individually, you can also pass an array
|
In addition to adding commands to the `MULTI` queue individually, you can also
|
||||||
of commands and arguments to the constructor:
|
pass an array of commands and arguments to the constructor:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var redis = require("redis"),
|
var redis = require("redis"),
|
||||||
|
@ -572,26 +657,36 @@ client.multi([
|
||||||
|
|
||||||
### Multi.exec_atomic([callback])
|
### Multi.exec_atomic([callback])
|
||||||
|
|
||||||
Identical to Multi.exec but with the difference that executing a single command will not use transactions.
|
Identical to Multi.exec but with the difference that executing a single command
|
||||||
|
will not use transactions.
|
||||||
|
|
||||||
## client.batch([commands])
|
## client.batch([commands])
|
||||||
|
|
||||||
Identical to .multi without transactions. This is recommended if you want to execute many commands at once but don't have to rely on transactions.
|
Identical to .multi without transactions. This is recommended if you want to
|
||||||
|
execute many commands at once but don't have to rely on transactions.
|
||||||
|
|
||||||
`BATCH` commands are queued up until an `EXEC` is issued, and then all commands are run atomically by
|
`BATCH` commands are queued up until an `EXEC` is issued, and then all commands
|
||||||
Redis. The interface in `node_redis` is to return an individual `Batch` object by calling `client.batch()`.
|
are run atomically by Redis. The interface in `node_redis` is to return an
|
||||||
The only difference between .batch and .multi is that no transaction is going to be used.
|
individual `Batch` object by calling `client.batch()`. The only difference
|
||||||
Be aware that the errors are - just like in multi statements - in the result. Otherwise both, errors and results could be returned at the same time.
|
between .batch and .multi is that no transaction is going to be used.
|
||||||
|
Be aware that the errors are - just like in multi statements - in the result.
|
||||||
|
Otherwise both, errors and results could be returned at the same time.
|
||||||
|
|
||||||
If you fire many commands at once this is going to boost the execution speed significantly compared to fireing the same commands in a loop without waiting for the result! See the benchmarks for further comparison. Please remember that all commands are kept in memory until they are fired.
|
If you fire many commands at once this is going to boost the execution speed
|
||||||
|
significantly compared to firing the same commands in a loop without waiting for
|
||||||
|
the result! See the benchmarks for further comparison. Please remember that all
|
||||||
|
commands are kept in memory until they are fired.
|
||||||
|
|
||||||
## Monitor mode
|
## Monitor mode
|
||||||
|
|
||||||
Redis supports the `MONITOR` command, which lets you see all commands received by the Redis server
|
Redis supports the `MONITOR` command, which lets you see all commands received
|
||||||
across all client connections, including from other client libraries and other computers.
|
by the Redis server across all client connections, including from other client
|
||||||
|
libraries and other computers.
|
||||||
|
|
||||||
A `monitor` event is going to be emitted for every command fired from any client connected to the server including the monitoring client itself.
|
A `monitor` event is going to be emitted for every command fired from any client
|
||||||
The callback for the `monitor` event takes a timestamp from the Redis server, an array of command arguments and the raw monitoring string.
|
connected to the server including the monitoring client itself. The callback for
|
||||||
|
the `monitor` event takes a timestamp from the Redis server, an array of command
|
||||||
|
arguments and the raw monitoring string.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -613,10 +708,11 @@ Some other things you might like to know about.
|
||||||
|
|
||||||
## client.server_info
|
## client.server_info
|
||||||
|
|
||||||
After the ready probe completes, the results from the INFO command are saved in the `client.server_info`
|
After the ready probe completes, the results from the INFO command are saved in
|
||||||
object.
|
the `client.server_info` object.
|
||||||
|
|
||||||
The `versions` key contains an array of the elements of the version string for easy comparison.
|
The `versions` key contains an array of the elements of the version string for
|
||||||
|
easy comparison.
|
||||||
|
|
||||||
> client.server_info.redis_version
|
> client.server_info.redis_version
|
||||||
'2.3.0'
|
'2.3.0'
|
||||||
|
@ -655,10 +751,13 @@ the second word as first parameter:
|
||||||
|
|
||||||
## client.duplicate([options][, callback])
|
## client.duplicate([options][, callback])
|
||||||
|
|
||||||
Duplicate all current options and return a new redisClient instance. All options passed to the duplicate function are going to replace the original option.
|
Duplicate all current options and return a new redisClient instance. All options
|
||||||
If you pass a callback, duplicate is going to wait until the client is ready and returns it in the callback. If an error occurs in the meanwhile, that is going to return an error instead in the callback.
|
passed to the duplicate function are going to replace the original option. If
|
||||||
|
you pass a callback, duplicate is going to wait until the client is ready and
|
||||||
|
returns it in the callback. If an error occurs in the meanwhile, that is going
|
||||||
|
to return an error instead in the callback.
|
||||||
|
|
||||||
One example of when to use duplicate() would be to accomodate the connection-
|
One example of when to use duplicate() would be to accommodate the connection-
|
||||||
blocking redis commands BRPOP, BLPOP, and BRPOPLPUSH. If these commands
|
blocking redis commands BRPOP, BLPOP, and BRPOPLPUSH. If these commands
|
||||||
are used on the same redisClient instance as non-blocking commands, the
|
are used on the same redisClient instance as non-blocking commands, the
|
||||||
non-blocking ones may be queued up until after the blocking ones finish.
|
non-blocking ones may be queued up until after the blocking ones finish.
|
||||||
|
@ -687,11 +786,19 @@ accessed via the redis SELECT command. Each DB could use its own connection.
|
||||||
|
|
||||||
## client.send_command(command_name[, [args][, callback]])
|
## client.send_command(command_name[, [args][, callback]])
|
||||||
|
|
||||||
All Redis commands have been added to the `client` object. However, if new commands are introduced before this library is updated,
|
All Redis commands have been added to the `client` object. However, if new
|
||||||
you can use `send_command()` to send arbitrary commands to Redis.
|
commands are introduced before this library is updated or if you want to add
|
||||||
The command_name has to be lower case.
|
individual commands you can use `send_command()` to send arbitrary commands to
|
||||||
|
Redis.
|
||||||
|
|
||||||
All commands are sent as multi-bulk commands. `args` can either be an Array of arguments, or omitted / set to undefined.
|
All commands are sent as multi-bulk commands. `args` can either be an Array of
|
||||||
|
arguments, or omitted / set to undefined.
|
||||||
|
|
||||||
|
## client.add_command(command_name)
|
||||||
|
|
||||||
|
Calling add_command will add a new command to the prototype. The exact command
|
||||||
|
name will be used when calling using this new command. Using arbitrary arguments
|
||||||
|
is possible as with any other command.
|
||||||
|
|
||||||
## client.connected
|
## client.connected
|
||||||
|
|
||||||
|
@ -699,19 +806,23 @@ Boolean tracking the state of the connection to the Redis server.
|
||||||
|
|
||||||
## client.command_queue_length
|
## client.command_queue_length
|
||||||
|
|
||||||
The number of commands that have been sent to the Redis server but not yet replied to. You can use this to
|
The number of commands that have been sent to the Redis server but not yet
|
||||||
enforce some kind of maximum queue depth for commands while connected.
|
replied to. You can use this to enforce some kind of maximum queue depth for
|
||||||
|
commands while connected.
|
||||||
|
|
||||||
## client.offline_queue_length
|
## client.offline_queue_length
|
||||||
|
|
||||||
The number of commands that have been queued up for a future connection. You can use this to enforce
|
The number of commands that have been queued up for a future connection. You can
|
||||||
some kind of maximum queue depth for pre-connection commands.
|
use this to enforce some kind of maximum queue depth for pre-connection
|
||||||
|
commands.
|
||||||
|
|
||||||
### Commands with Optional and Keyword arguments
|
### Commands with Optional and Keyword arguments
|
||||||
|
|
||||||
This applies to anything that uses an optional `[WITHSCORES]` or `[LIMIT offset count]` in the [redis.io/commands](http://redis.io/commands) documentation.
|
This applies to anything that uses an optional `[WITHSCORES]` or `[LIMIT offset
|
||||||
|
count]` in the [redis.io/commands](http://redis.io/commands) documentation.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var args = [ 'myzset', 1, 'one', 2, 'two', 3, 'three', 99, 'ninety-nine' ];
|
var args = [ 'myzset', 1, 'one', 2, 'two', 3, 'three', 99, 'ninety-nine' ];
|
||||||
client.zadd(args, function (err, response) {
|
client.zadd(args, function (err, response) {
|
||||||
|
@ -784,10 +895,13 @@ clients: 1, NodeJS: 6.2.0, Redis: 3.2.0, parser: javascript, connected by: tcp
|
||||||
|
|
||||||
To get debug output run your `node_redis` application with `NODE_DEBUG=redis`.
|
To get debug output run your `node_redis` application with `NODE_DEBUG=redis`.
|
||||||
|
|
||||||
This is also going to result in good stack traces opposed to useless ones otherwise for any async operation.
|
This is also going to result in good stack traces opposed to useless ones
|
||||||
If you only want to have good stack traces but not the debug output run your application in development mode instead (`NODE_ENV=development`).
|
otherwise for any async operation.
|
||||||
|
If you only want to have good stack traces but not the debug output run your
|
||||||
|
application in development mode instead (`NODE_ENV=development`).
|
||||||
|
|
||||||
Good stack traces are only activated in development and debug mode as this results in a significant performance penalty.
|
Good stack traces are only activated in development and debug mode as this
|
||||||
|
results in a significant performance penalty.
|
||||||
|
|
||||||
___Comparison___:
|
___Comparison___:
|
||||||
Useless stack trace:
|
Useless stack trace:
|
||||||
|
@ -823,7 +937,8 @@ The original author of node_redis is [Matthew Ranney](https://github.com/mranney
|
||||||
|
|
||||||
The current lead maintainer is [Ruben Bridgewater](https://github.com/BridgeAR)
|
The current lead maintainer is [Ruben Bridgewater](https://github.com/BridgeAR)
|
||||||
|
|
||||||
Many [others](https://github.com/NodeRedis/node_redis/graphs/contributors) contributed to `node_redis` too. Thanks to all of them!
|
Many [others](https://github.com/NodeRedis/node_redis/graphs/contributors)
|
||||||
|
contributed to `node_redis` too. Thanks to all of them!
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -831,10 +946,20 @@ Many [others](https://github.com/NodeRedis/node_redis/graphs/contributors) contr
|
||||||
|
|
||||||
### Consolidation: It's time for celebration
|
### Consolidation: It's time for celebration
|
||||||
|
|
||||||
Right now there are two great redis clients around and both have some advantages above each other. We speak about ioredis and node_redis. So after talking to each other about how we could improve in working together we (that is @luin and @BridgeAR) decided to work towards a single library on the long run. But step by step.
|
Right now there are two great redis clients around and both have some advantages
|
||||||
|
above each other. We speak about ioredis and node_redis. So after talking to
|
||||||
|
each other about how we could improve in working together we (that is @luin and
|
||||||
|
@BridgeAR) decided to work towards a single library on the long run. But step by
|
||||||
|
step.
|
||||||
|
|
||||||
First of all, we want to split small parts of our libraries into others so that we're both able to use the same code. Those libraries are going to be maintained under the NodeRedis organization. This is going to reduce the maintance overhead, allows others to use the very same code, if they need it and it's way easyer for others to contribute to both libraries.
|
First of all, we want to split small parts of our libraries into others so that
|
||||||
|
we're both able to use the same code. Those libraries are going to be maintained
|
||||||
|
under the NodeRedis organization. This is going to reduce the maintenance
|
||||||
|
overhead, allows others to use the very same code, if they need it and it's way
|
||||||
|
easyer for others to contribute to both libraries.
|
||||||
|
|
||||||
We're very happy about this step towards working together as we both want to give you the best redis experience possible.
|
We're very happy about this step towards working together as we both want to
|
||||||
|
give you the best redis experience possible.
|
||||||
|
|
||||||
If you want to join our cause by help maintaining something, please don't hesitate to contact either one of us.
|
If you want to join our cause by help maintaining something, please don't
|
||||||
|
hesitate to contact either one of us.
|
||||||
|
|
58
node/node_modules/redis/changelog.md
generated
vendored
58
node/node_modules/redis/changelog.md
generated
vendored
|
@ -1,5 +1,47 @@
|
||||||
Changelog
|
# Changelog
|
||||||
=========
|
|
||||||
|
## v.2.8.0 - 31 Jul, 2017
|
||||||
|
|
||||||
|
Features
|
||||||
|
|
||||||
|
- Accept UPPER_CASE commands in send_command
|
||||||
|
- Add arbitrary commands to the prototype by using `Redis.addCommand(name)`
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Fixed not always copying subscribe unsubscribe arguments
|
||||||
|
- Fixed emitting internal errors while reconnecting with auth
|
||||||
|
- Fixed crashing with invalid url option
|
||||||
|
|
||||||
|
## v.2.7.1 - 14 Mar, 2017
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Fixed monitor mode not working in combination with IPv6 (2.6.0 regression)
|
||||||
|
|
||||||
|
## v.2.7.0 - 11 Mar, 2017
|
||||||
|
|
||||||
|
Features
|
||||||
|
|
||||||
|
- All returned errors are from now a subclass of `RedisError`.
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Fixed rename_commands not accepting `null` as value
|
||||||
|
- Fixed `AbortError`s and `AggregateError`s not showing the error message in the stack trace
|
||||||
|
|
||||||
|
## v.2.6.5 - 15 Jan, 2017
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Fixed parser not being reset in case the redis connection closed ASAP for overcoming of output buffer limits
|
||||||
|
- Fixed parser reset if (p)message_buffer listener is attached
|
||||||
|
|
||||||
|
## v.2.6.4 - 12 Jan, 2017
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
- Fixed monitor mode not working in combination with IPv6, sockets or lua scripts (2.6.0 regression)
|
||||||
|
|
||||||
## v.2.6.3 - 31 Oct, 2016
|
## v.2.6.3 - 31 Oct, 2016
|
||||||
|
|
||||||
|
@ -100,7 +142,7 @@ Features
|
||||||
- Monitor and pub sub mode now work together with the offline queue
|
- Monitor and pub sub mode now work together with the offline queue
|
||||||
- All commands that were send after a connection loss are now going to be send after reconnecting
|
- All commands that were send after a connection loss are now going to be send after reconnecting
|
||||||
- Activating monitor mode does now work together with arbitrary commands including pub sub mode
|
- Activating monitor mode does now work together with arbitrary commands including pub sub mode
|
||||||
- Pub sub mode is completly rewritten and all known issues fixed
|
- Pub sub mode is completely rewritten and all known issues fixed
|
||||||
- Added `string_numbers` option to get back strings instead of numbers
|
- Added `string_numbers` option to get back strings instead of numbers
|
||||||
- Quit command is from now on always going to end the connection properly
|
- Quit command is from now on always going to end the connection properly
|
||||||
|
|
||||||
|
@ -143,7 +185,7 @@ Same changelog as the pre-release
|
||||||
|
|
||||||
## v.2.5.0-1 - 07 Mar, 2016
|
## v.2.5.0-1 - 07 Mar, 2016
|
||||||
|
|
||||||
This is a big release with some substaintual underlining changes. Therefor this is released as a pre-release and I encourage anyone who's able to, to test this out.
|
This is a big release with some substantial underlining changes. Therefor this is released as a pre-release and I encourage anyone who's able to, to test this out.
|
||||||
|
|
||||||
It took way to long to release this one and the next release cycles will be shorter again.
|
It took way to long to release this one and the next release cycles will be shorter again.
|
||||||
|
|
||||||
|
@ -163,7 +205,7 @@ Features
|
||||||
- Added a `warning` emitter that receives node_redis warnings like auth not required and deprecation messages
|
- Added a `warning` emitter that receives node_redis warnings like auth not required and deprecation messages
|
||||||
- Added a `retry_strategy` option that replaces all reconnect options
|
- Added a `retry_strategy` option that replaces all reconnect options
|
||||||
- The reconnecting event from now on also receives:
|
- The reconnecting event from now on also receives:
|
||||||
- The error message why the reconnect happend (params.error)
|
- The error message why the reconnect happened (params.error)
|
||||||
- The amount of times the client was connected (params.times_connected)
|
- The amount of times the client was connected (params.times_connected)
|
||||||
- The total reconnecting time since the last time connected (params.total_retry_time)
|
- The total reconnecting time since the last time connected (params.total_retry_time)
|
||||||
- Always respect the command execution order no matter if the reply could be returned sync or not (former exceptions: [#937](https://github.com/NodeRedis/node_redis/issues/937#issuecomment-167525939))
|
- Always respect the command execution order no matter if the reply could be returned sync or not (former exceptions: [#937](https://github.com/NodeRedis/node_redis/issues/937#issuecomment-167525939))
|
||||||
|
@ -178,9 +220,9 @@ Bugfixes
|
||||||
- Fixed do not run toString on an array argument and throw a "invalid data" error instead
|
- Fixed do not run toString on an array argument and throw a "invalid data" error instead
|
||||||
- This is not considered as breaking change, as this is likely a error in your code and if you want to have such a behavior you should handle this beforehand
|
- This is not considered as breaking change, as this is likely a error in your code and if you want to have such a behavior you should handle this beforehand
|
||||||
- The same applies to Map / Set and individual Object types
|
- The same applies to Map / Set and individual Object types
|
||||||
- Fixed redis url not accepting the protocol being omitted or protocols other than the redis protocol for convienence
|
- Fixed redis url not accepting the protocol being omitted or protocols other than the redis protocol for convenience
|
||||||
- Fixed parsing the db keyspace even if the first database does not begin with a zero
|
- Fixed parsing the db keyspace even if the first database does not begin with a zero
|
||||||
- Fixed handling of errors occuring while receiving pub sub messages
|
- Fixed handling of errors occurring while receiving pub sub messages
|
||||||
- Fixed huge string pipelines crashing NodeJS (Pipeline size above 256mb)
|
- Fixed huge string pipelines crashing NodeJS (Pipeline size above 256mb)
|
||||||
- Fixed rename_commands and prefix option not working together
|
- Fixed rename_commands and prefix option not working together
|
||||||
- Fixed ready being emitted to early in case a slave is still syncing / master down
|
- Fixed ready being emitted to early in case a slave is still syncing / master down
|
||||||
|
@ -193,7 +235,7 @@ Deprecations
|
||||||
- Using SET or SETEX with a undefined or null value will from now on also result in converting the value to "null" / "undefined" to have a consistent behavior. This is not considered as breaking change, as it returned an error earlier.
|
- Using SET or SETEX with a undefined or null value will from now on also result in converting the value to "null" / "undefined" to have a consistent behavior. This is not considered as breaking change, as it returned an error earlier.
|
||||||
- Using .end(flush) without the flush parameter is deprecated and the flush parameter should explicitly be used
|
- Using .end(flush) without the flush parameter is deprecated and the flush parameter should explicitly be used
|
||||||
- From v.3.0.0 on using .end without flush will result in an error
|
- From v.3.0.0 on using .end without flush will result in an error
|
||||||
- Using .end without flush means that any command that did not yet return is going to silently fail. Therefor this is considered harmfull and you should explicitly silence such errors if you are sure you want this
|
- Using .end without flush means that any command that did not yet return is going to silently fail. Therefor this is considered harmful and you should explicitly silence such errors if you are sure you want this
|
||||||
- Depending on the return value of a command to detect the backpressure is deprecated
|
- Depending on the return value of a command to detect the backpressure is deprecated
|
||||||
- From version 3.0.0 on node_redis might not return true / false as a return value anymore. Please rely on client.should_buffer instead
|
- From version 3.0.0 on node_redis might not return true / false as a return value anymore. Please rely on client.should_buffer instead
|
||||||
- The `socket_nodelay` option is deprecated and will be removed in v.3.0.0
|
- The `socket_nodelay` option is deprecated and will be removed in v.3.0.0
|
||||||
|
|
38
node/node_modules/redis/index.js
generated
vendored
38
node/node_modules/redis/index.js
generated
vendored
|
@ -120,7 +120,7 @@ function RedisClient (options, stream) {
|
||||||
if ('max_attempts' in options) {
|
if ('max_attempts' in options) {
|
||||||
self.warn(
|
self.warn(
|
||||||
'max_attempts is deprecated and will be removed in v.3.0.0.\n' +
|
'max_attempts is deprecated and will be removed in v.3.0.0.\n' +
|
||||||
'To reduce the amount of options and the improve the reconnection handling please use the new `retry_strategy` option instead.\n' +
|
'To reduce the number of options and to improve the reconnection handling please use the new `retry_strategy` option instead.\n' +
|
||||||
'This replaces the max_attempts and retry_max_delay option.'
|
'This replaces the max_attempts and retry_max_delay option.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -156,8 +156,6 @@ function RedisClient (options, stream) {
|
||||||
this.buffers = options.return_buffers || options.detect_buffers;
|
this.buffers = options.return_buffers || options.detect_buffers;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.reply = 'ON'; // Returning replies is the default
|
this.reply = 'ON'; // Returning replies is the default
|
||||||
// Init parser
|
|
||||||
this.reply_parser = create_parser(this);
|
|
||||||
this.create_stream();
|
this.create_stream();
|
||||||
// The listeners will not be attached right away, so let's print the deprecation message while the listener is attached
|
// The listeners will not be attached right away, so let's print the deprecation message while the listener is attached
|
||||||
this.on('newListener', function (event) {
|
this.on('newListener', function (event) {
|
||||||
|
@ -171,10 +169,16 @@ function RedisClient (options, stream) {
|
||||||
'The drain event listener is deprecated and will be removed in v.3.0.0.\n' +
|
'The drain event listener is deprecated and will be removed in v.3.0.0.\n' +
|
||||||
'If you want to keep on listening to this event please listen to the stream drain event directly.'
|
'If you want to keep on listening to this event please listen to the stream drain event directly.'
|
||||||
);
|
);
|
||||||
} else if (event === 'message_buffer' || event === 'pmessage_buffer' || event === 'messageBuffer' || event === 'pmessageBuffer' && !this.buffers) {
|
} else if ((event === 'message_buffer' || event === 'pmessage_buffer' || event === 'messageBuffer' || event === 'pmessageBuffer') && !this.buffers && !this.message_buffers) {
|
||||||
|
if (this.reply_parser.name !== 'javascript') {
|
||||||
|
return this.warn(
|
||||||
|
'You attached the "' + event + '" listener without the returnBuffers option set to true.\n' +
|
||||||
|
'Please use the JavaScript parser or set the returnBuffers option to true to return buffers.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.reply_parser.optionReturnBuffers = true;
|
||||||
this.message_buffers = true;
|
this.message_buffers = true;
|
||||||
this.handle_reply = handle_detect_buffers_reply;
|
this.handle_reply = handle_detect_buffers_reply;
|
||||||
this.reply_parser = create_parser(this);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -224,6 +228,9 @@ function create_parser (self) {
|
||||||
RedisClient.prototype.create_stream = function () {
|
RedisClient.prototype.create_stream = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
// Init parser
|
||||||
|
this.reply_parser = create_parser(this);
|
||||||
|
|
||||||
if (this.options.stream) {
|
if (this.options.stream) {
|
||||||
// Only add the listeners once in case of a reconnect try (that won't work)
|
// Only add the listeners once in case of a reconnect try (that won't work)
|
||||||
if (this.stream) {
|
if (this.stream) {
|
||||||
|
@ -297,7 +304,12 @@ RedisClient.prototype.create_stream = function () {
|
||||||
// Fire the command before redis is connected to be sure it's the first fired command
|
// Fire the command before redis is connected to be sure it's the first fired command
|
||||||
if (this.auth_pass !== undefined) {
|
if (this.auth_pass !== undefined) {
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
this.auth(this.auth_pass);
|
// Fail silently as we might not be able to connect
|
||||||
|
this.auth(this.auth_pass, function (err) {
|
||||||
|
if (err && err.code !== 'UNCERTAIN_STATE') {
|
||||||
|
self.emit('error', err);
|
||||||
|
}
|
||||||
|
});
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -791,9 +803,6 @@ function return_pub_sub (self, reply) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RedisClient.prototype.return_reply = function (reply) {
|
RedisClient.prototype.return_reply = function (reply) {
|
||||||
// If in monitor mode, all normal commands are still working and we only want to emit the streamlined commands
|
|
||||||
// As this is not the average use case and monitor is expensive anyway, let's change the code here, to improve
|
|
||||||
// the average performance of all other commands in case of no monitor mode
|
|
||||||
if (this.monitoring) {
|
if (this.monitoring) {
|
||||||
var replyStr;
|
var replyStr;
|
||||||
if (this.buffers && Buffer.isBuffer(reply)) {
|
if (this.buffers && Buffer.isBuffer(reply)) {
|
||||||
|
@ -801,8 +810,7 @@ RedisClient.prototype.return_reply = function (reply) {
|
||||||
} else {
|
} else {
|
||||||
replyStr = reply;
|
replyStr = reply;
|
||||||
}
|
}
|
||||||
// While reconnecting the redis server does not recognize the client as in monitor mode anymore
|
// If in monitor mode, all normal commands are still working and we only want to emit the streamlined commands
|
||||||
// Therefore the monitor command has to finish before it catches further commands
|
|
||||||
if (typeof replyStr === 'string' && utils.monitor_regex.test(replyStr)) {
|
if (typeof replyStr === 'string' && utils.monitor_regex.test(replyStr)) {
|
||||||
var timestamp = replyStr.slice(0, replyStr.indexOf(' '));
|
var timestamp = replyStr.slice(0, replyStr.indexOf(' '));
|
||||||
var args = replyStr.slice(replyStr.indexOf('"') + 1, -1).split('" "').map(function (elem) {
|
var args = replyStr.slice(replyStr.indexOf('"') + 1, -1).split('" "').map(function (elem) {
|
||||||
|
@ -928,7 +936,7 @@ RedisClient.prototype.internal_send_command = function (command_obj) {
|
||||||
args_copy[i] = this.options.prefix + args_copy[i];
|
args_copy[i] = this.options.prefix + args_copy[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof this.options.rename_commands !== 'undefined' && this.options.rename_commands[command]) {
|
if (this.options.rename_commands && this.options.rename_commands[command]) {
|
||||||
command = this.options.rename_commands[command];
|
command = this.options.rename_commands[command];
|
||||||
}
|
}
|
||||||
// Always use 'Multi bulk commands', but if passed any Buffer args, then do multiple writes, one for each arg.
|
// Always use 'Multi bulk commands', but if passed any Buffer args, then do multiple writes, one for each arg.
|
||||||
|
@ -1084,10 +1092,14 @@ exports.RedisClient = RedisClient;
|
||||||
exports.print = utils.print;
|
exports.print = utils.print;
|
||||||
exports.Multi = require('./lib/multi');
|
exports.Multi = require('./lib/multi');
|
||||||
exports.AbortError = errorClasses.AbortError;
|
exports.AbortError = errorClasses.AbortError;
|
||||||
|
exports.RedisError = Parser.RedisError;
|
||||||
|
exports.ParserError = Parser.ParserError;
|
||||||
exports.ReplyError = Parser.ReplyError;
|
exports.ReplyError = Parser.ReplyError;
|
||||||
exports.AggregateError = errorClasses.AggregateError;
|
exports.AggregateError = errorClasses.AggregateError;
|
||||||
|
|
||||||
// Add all redis commands / node_redis api to the client
|
// Add all redis commands / node_redis api to the client
|
||||||
require('./lib/individualCommands');
|
require('./lib/individualCommands');
|
||||||
require('./lib/extendedApi');
|
require('./lib/extendedApi');
|
||||||
require('./lib/commands');
|
|
||||||
|
//enables adding new commands (for modules and new commands)
|
||||||
|
exports.addCommand = exports.add_command = require('./lib/commands');
|
20
node/node_modules/redis/lib/commands.js
generated
vendored
20
node/node_modules/redis/lib/commands.js
generated
vendored
|
@ -17,11 +17,7 @@ var changeFunctionName = (function () {
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|
||||||
// TODO: Rewrite this including the invidual commands into a Commands class
|
var addCommand = function (command) {
|
||||||
// that provided a functionality to add new commands to the client
|
|
||||||
|
|
||||||
commands.list.forEach(function (command) {
|
|
||||||
|
|
||||||
// Some rare Redis commands use special characters in their command name
|
// Some rare Redis commands use special characters in their command name
|
||||||
// Convert those to a underscore to prevent using invalid function names
|
// Convert those to a underscore to prevent using invalid function names
|
||||||
var commandName = command.replace(/(?:^([0-9])|[^a-zA-Z0-9_$])/g, '_$1');
|
var commandName = command.replace(/(?:^([0-9])|[^a-zA-Z0-9_$])/g, '_$1');
|
||||||
|
@ -61,6 +57,10 @@ commands.list.forEach(function (command) {
|
||||||
}
|
}
|
||||||
return this.internal_send_command(new Command(command, arr, callback));
|
return this.internal_send_command(new Command(command, arr, callback));
|
||||||
};
|
};
|
||||||
|
// Alias special function names (e.g. NR.RUN becomes NR_RUN and nr_run)
|
||||||
|
if (commandName !== command) {
|
||||||
|
RedisClient.prototype[commandName.toUpperCase()] = RedisClient.prototype[commandName] = RedisClient.prototype[command];
|
||||||
|
}
|
||||||
if (changeFunctionName) {
|
if (changeFunctionName) {
|
||||||
Object.defineProperty(RedisClient.prototype[command], 'name', {
|
Object.defineProperty(RedisClient.prototype[command], 'name', {
|
||||||
value: commandName
|
value: commandName
|
||||||
|
@ -104,10 +104,18 @@ commands.list.forEach(function (command) {
|
||||||
this.queue.push(new Command(command, arr, callback));
|
this.queue.push(new Command(command, arr, callback));
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
// Alias special function names (e.g. NR.RUN becomes NR_RUN and nr_run)
|
||||||
|
if (commandName !== command) {
|
||||||
|
Multi.prototype[commandName.toUpperCase()] = Multi.prototype[commandName] = Multi.prototype[command];
|
||||||
|
}
|
||||||
if (changeFunctionName) {
|
if (changeFunctionName) {
|
||||||
Object.defineProperty(Multi.prototype[command], 'name', {
|
Object.defineProperty(Multi.prototype[command], 'name', {
|
||||||
value: commandName
|
value: commandName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
commands.list.forEach(addCommand);
|
||||||
|
|
||||||
|
module.exports = addCommand;
|
||||||
|
|
5
node/node_modules/redis/lib/createClient.js
generated
vendored
5
node/node_modules/redis/lib/createClient.js
generated
vendored
|
@ -23,7 +23,8 @@ module.exports = function createClient (port_arg, host_arg, options) {
|
||||||
} else if (typeof port_arg === 'string' || port_arg && port_arg.url) {
|
} else if (typeof port_arg === 'string' || port_arg && port_arg.url) {
|
||||||
|
|
||||||
options = utils.clone(port_arg.url ? port_arg : host_arg || options);
|
options = utils.clone(port_arg.url ? port_arg : host_arg || options);
|
||||||
var parsed = URL.parse(port_arg.url || port_arg, true, true);
|
var url = port_arg.url || port_arg;
|
||||||
|
var parsed = URL.parse(url, true, true);
|
||||||
|
|
||||||
// [redis:]//[[user][:password]@][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]
|
// [redis:]//[[user][:password]@][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]
|
||||||
if (parsed.slashes) { // We require slashes
|
if (parsed.slashes) { // We require slashes
|
||||||
|
@ -59,7 +60,7 @@ module.exports = function createClient (port_arg, host_arg, options) {
|
||||||
} else if (parsed.hostname) {
|
} else if (parsed.hostname) {
|
||||||
throw new RangeError('The redis url must begin with slashes "//" or contain slashes after the redis protocol');
|
throw new RangeError('The redis url must begin with slashes "//" or contain slashes after the redis protocol');
|
||||||
} else {
|
} else {
|
||||||
options.path = port_arg;
|
options.path = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (typeof port_arg === 'object' || port_arg === undefined) {
|
} else if (typeof port_arg === 'object' || port_arg === undefined) {
|
||||||
|
|
25
node/node_modules/redis/lib/customErrors.js
generated
vendored
25
node/node_modules/redis/lib/customErrors.js
generated
vendored
|
@ -1,42 +1,55 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
var assert = require('assert');
|
||||||
|
var RedisError = require('redis-parser').RedisError;
|
||||||
|
var ADD_STACKTRACE = false;
|
||||||
|
|
||||||
function AbortError (obj) {
|
function AbortError (obj, stack) {
|
||||||
Error.captureStackTrace(this, this.constructor);
|
assert(obj, 'The options argument is required');
|
||||||
|
assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object');
|
||||||
|
|
||||||
|
RedisError.call(this, obj.message, ADD_STACKTRACE);
|
||||||
Object.defineProperty(this, 'message', {
|
Object.defineProperty(this, 'message', {
|
||||||
value: obj.message || '',
|
value: obj.message || '',
|
||||||
configurable: true,
|
configurable: true,
|
||||||
writable: true
|
writable: true
|
||||||
});
|
});
|
||||||
|
if (stack || stack === undefined) {
|
||||||
|
Error.captureStackTrace(this, AbortError);
|
||||||
|
}
|
||||||
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
|
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
|
||||||
this[key] = obj[key];
|
this[key] = obj[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function AggregateError (obj) {
|
function AggregateError (obj) {
|
||||||
Error.captureStackTrace(this, this.constructor);
|
assert(obj, 'The options argument is required');
|
||||||
|
assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object');
|
||||||
|
|
||||||
|
AbortError.call(this, obj, ADD_STACKTRACE);
|
||||||
Object.defineProperty(this, 'message', {
|
Object.defineProperty(this, 'message', {
|
||||||
value: obj.message || '',
|
value: obj.message || '',
|
||||||
configurable: true,
|
configurable: true,
|
||||||
writable: true
|
writable: true
|
||||||
});
|
});
|
||||||
|
Error.captureStackTrace(this, AggregateError);
|
||||||
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
|
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
|
||||||
this[key] = obj[key];
|
this[key] = obj[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
util.inherits(AbortError, Error);
|
util.inherits(AbortError, RedisError);
|
||||||
util.inherits(AggregateError, AbortError);
|
util.inherits(AggregateError, AbortError);
|
||||||
|
|
||||||
Object.defineProperty(AbortError.prototype, 'name', {
|
Object.defineProperty(AbortError.prototype, 'name', {
|
||||||
value: 'AbortError',
|
value: 'AbortError',
|
||||||
// configurable: true,
|
configurable: true,
|
||||||
writable: true
|
writable: true
|
||||||
});
|
});
|
||||||
Object.defineProperty(AggregateError.prototype, 'name', {
|
Object.defineProperty(AggregateError.prototype, 'name', {
|
||||||
value: 'AggregateError',
|
value: 'AggregateError',
|
||||||
// configurable: true,
|
configurable: true,
|
||||||
writable: true
|
writable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
5
node/node_modules/redis/lib/extendedApi.js
generated
vendored
5
node/node_modules/redis/lib/extendedApi.js
generated
vendored
|
@ -16,6 +16,7 @@ RedisClient.prototype.send_command = RedisClient.prototype.sendCommand = functio
|
||||||
if (typeof command !== 'string') {
|
if (typeof command !== 'string') {
|
||||||
throw new TypeError('Wrong input type "' + (command !== null && command !== undefined ? command.constructor.name : command) + '" for command name');
|
throw new TypeError('Wrong input type "' + (command !== null && command !== undefined ? command.constructor.name : command) + '" for command name');
|
||||||
}
|
}
|
||||||
|
command = command.toLowerCase();
|
||||||
if (!Array.isArray(args)) {
|
if (!Array.isArray(args)) {
|
||||||
if (args === undefined || args === null) {
|
if (args === undefined || args === null) {
|
||||||
args = [];
|
args = [];
|
||||||
|
@ -32,9 +33,9 @@ RedisClient.prototype.send_command = RedisClient.prototype.sendCommand = functio
|
||||||
|
|
||||||
// Using the raw multi command is only possible with this function
|
// Using the raw multi command is only possible with this function
|
||||||
// If the command is not yet added to the client, the internal function should be called right away
|
// If the command is not yet added to the client, the internal function should be called right away
|
||||||
// Otherwise we need to redirect the calls to make sure the interal functions don't get skipped
|
// Otherwise we need to redirect the calls to make sure the internal functions don't get skipped
|
||||||
// The internal functions could actually be used for any non hooked function
|
// The internal functions could actually be used for any non hooked function
|
||||||
// but this might change from time to time and at the moment there's no good way to distinguishe them
|
// but this might change from time to time and at the moment there's no good way to distinguish them
|
||||||
// from each other, so let's just do it do it this way for the time being
|
// from each other, so let's just do it do it this way for the time being
|
||||||
if (command === 'multi' || typeof this[command] !== 'function') {
|
if (command === 'multi' || typeof this[command] !== 'function') {
|
||||||
return this.internal_send_command(new Command(command, args, callback));
|
return this.internal_send_command(new Command(command, args, callback));
|
||||||
|
|
16
node/node_modules/redis/lib/individualCommands.js
generated
vendored
16
node/node_modules/redis/lib/individualCommands.js
generated
vendored
|
@ -398,7 +398,7 @@ RedisClient.prototype.subscribe = RedisClient.prototype.SUBSCRIBE = function sub
|
||||||
callback,
|
callback,
|
||||||
i = 0;
|
i = 0;
|
||||||
if (Array.isArray(arguments[0])) {
|
if (Array.isArray(arguments[0])) {
|
||||||
arr = arguments[0];
|
arr = arguments[0].slice(0);
|
||||||
callback = arguments[1];
|
callback = arguments[1];
|
||||||
} else {
|
} else {
|
||||||
len = arguments.length;
|
len = arguments.length;
|
||||||
|
@ -425,7 +425,7 @@ Multi.prototype.subscribe = Multi.prototype.SUBSCRIBE = function subscribe () {
|
||||||
callback,
|
callback,
|
||||||
i = 0;
|
i = 0;
|
||||||
if (Array.isArray(arguments[0])) {
|
if (Array.isArray(arguments[0])) {
|
||||||
arr = arguments[0];
|
arr = arguments[0].slice(0);
|
||||||
callback = arguments[1];
|
callback = arguments[1];
|
||||||
} else {
|
} else {
|
||||||
len = arguments.length;
|
len = arguments.length;
|
||||||
|
@ -453,7 +453,7 @@ RedisClient.prototype.unsubscribe = RedisClient.prototype.UNSUBSCRIBE = function
|
||||||
callback,
|
callback,
|
||||||
i = 0;
|
i = 0;
|
||||||
if (Array.isArray(arguments[0])) {
|
if (Array.isArray(arguments[0])) {
|
||||||
arr = arguments[0];
|
arr = arguments[0].slice(0);
|
||||||
callback = arguments[1];
|
callback = arguments[1];
|
||||||
} else {
|
} else {
|
||||||
len = arguments.length;
|
len = arguments.length;
|
||||||
|
@ -481,7 +481,7 @@ Multi.prototype.unsubscribe = Multi.prototype.UNSUBSCRIBE = function unsubscribe
|
||||||
callback,
|
callback,
|
||||||
i = 0;
|
i = 0;
|
||||||
if (Array.isArray(arguments[0])) {
|
if (Array.isArray(arguments[0])) {
|
||||||
arr = arguments[0];
|
arr = arguments[0].slice(0);
|
||||||
callback = arguments[1];
|
callback = arguments[1];
|
||||||
} else {
|
} else {
|
||||||
len = arguments.length;
|
len = arguments.length;
|
||||||
|
@ -510,7 +510,7 @@ RedisClient.prototype.psubscribe = RedisClient.prototype.PSUBSCRIBE = function p
|
||||||
callback,
|
callback,
|
||||||
i = 0;
|
i = 0;
|
||||||
if (Array.isArray(arguments[0])) {
|
if (Array.isArray(arguments[0])) {
|
||||||
arr = arguments[0];
|
arr = arguments[0].slice(0);
|
||||||
callback = arguments[1];
|
callback = arguments[1];
|
||||||
} else {
|
} else {
|
||||||
len = arguments.length;
|
len = arguments.length;
|
||||||
|
@ -537,7 +537,7 @@ Multi.prototype.psubscribe = Multi.prototype.PSUBSCRIBE = function psubscribe ()
|
||||||
callback,
|
callback,
|
||||||
i = 0;
|
i = 0;
|
||||||
if (Array.isArray(arguments[0])) {
|
if (Array.isArray(arguments[0])) {
|
||||||
arr = arguments[0];
|
arr = arguments[0].slice(0);
|
||||||
callback = arguments[1];
|
callback = arguments[1];
|
||||||
} else {
|
} else {
|
||||||
len = arguments.length;
|
len = arguments.length;
|
||||||
|
@ -565,7 +565,7 @@ RedisClient.prototype.punsubscribe = RedisClient.prototype.PUNSUBSCRIBE = functi
|
||||||
callback,
|
callback,
|
||||||
i = 0;
|
i = 0;
|
||||||
if (Array.isArray(arguments[0])) {
|
if (Array.isArray(arguments[0])) {
|
||||||
arr = arguments[0];
|
arr = arguments[0].slice(0);
|
||||||
callback = arguments[1];
|
callback = arguments[1];
|
||||||
} else {
|
} else {
|
||||||
len = arguments.length;
|
len = arguments.length;
|
||||||
|
@ -593,7 +593,7 @@ Multi.prototype.punsubscribe = Multi.prototype.PUNSUBSCRIBE = function punsubscr
|
||||||
callback,
|
callback,
|
||||||
i = 0;
|
i = 0;
|
||||||
if (Array.isArray(arguments[0])) {
|
if (Array.isArray(arguments[0])) {
|
||||||
arr = arguments[0];
|
arr = arguments[0].slice(0);
|
||||||
callback = arguments[1];
|
callback = arguments[1];
|
||||||
} else {
|
} else {
|
||||||
len = arguments.length;
|
len = arguments.length;
|
||||||
|
|
2
node/node_modules/redis/lib/utils.js
generated
vendored
2
node/node_modules/redis/lib/utils.js
generated
vendored
|
@ -127,7 +127,7 @@ module.exports = {
|
||||||
reply_to_object: replyToObject,
|
reply_to_object: replyToObject,
|
||||||
print: print,
|
print: print,
|
||||||
err_code: /^([A-Z]+)\s+(.+)$/,
|
err_code: /^([A-Z]+)\s+(.+)$/,
|
||||||
monitor_regex: /^[0-9]{10,11}\.[0-9]+ \[[0-9]{1,3} [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}:[0-9]{1,5}\].*/,
|
monitor_regex: /^[0-9]{10,11}\.[0-9]+ \[[0-9]+ .+\]( ".+?")+$/,
|
||||||
clone: convenienceClone,
|
clone: convenienceClone,
|
||||||
callback_or_emit: callbackOrEmit,
|
callback_or_emit: callbackOrEmit,
|
||||||
reply_in_order: replyInOrder
|
reply_in_order: replyInOrder
|
||||||
|
|
93
node/node_modules/redis/package.json
generated
vendored
93
node/node_modules/redis/package.json
generated
vendored
|
@ -1,49 +1,27 @@
|
||||||
{
|
{
|
||||||
"_args": [
|
"_from": "redis@2.8.0",
|
||||||
[
|
"_id": "redis@2.8.0",
|
||||||
{
|
"_inBundle": false,
|
||||||
"raw": "redis@2.6.3",
|
"_integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==",
|
||||||
"scope": null,
|
|
||||||
"escapedName": "redis",
|
|
||||||
"name": "redis",
|
|
||||||
"rawSpec": "2.6.3",
|
|
||||||
"spec": "2.6.3",
|
|
||||||
"type": "version"
|
|
||||||
},
|
|
||||||
"/Users/sclay/projects/newsblur/node"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "redis@2.6.3",
|
|
||||||
"_id": "redis@2.6.3",
|
|
||||||
"_inCache": true,
|
|
||||||
"_location": "/redis",
|
"_location": "/redis",
|
||||||
"_nodeVersion": "7.0.0",
|
|
||||||
"_npmOperationalInternal": {
|
|
||||||
"host": "packages-18-east.internal.npmjs.com",
|
|
||||||
"tmp": "tmp/redis-2.6.3.tgz_1477944575573_0.07418122352100909"
|
|
||||||
},
|
|
||||||
"_npmUser": {
|
|
||||||
"name": "bridgear",
|
|
||||||
"email": "ruben@bridgewater.de"
|
|
||||||
},
|
|
||||||
"_npmVersion": "3.10.8",
|
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
"raw": "redis@2.6.3",
|
"type": "version",
|
||||||
"scope": null,
|
"registry": true,
|
||||||
"escapedName": "redis",
|
"raw": "redis@2.8.0",
|
||||||
"name": "redis",
|
"name": "redis",
|
||||||
"rawSpec": "2.6.3",
|
"escapedName": "redis",
|
||||||
"spec": "2.6.3",
|
"rawSpec": "2.8.0",
|
||||||
"type": "version"
|
"saveSpec": null,
|
||||||
|
"fetchSpec": "2.8.0"
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
"#USER"
|
"#USER",
|
||||||
|
"/"
|
||||||
],
|
],
|
||||||
"_resolved": "https://registry.npmjs.org/redis/-/redis-2.6.3.tgz",
|
"_resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz",
|
||||||
"_shasum": "84305b92553c6a1f09c7c47c30b11ace7dbb7ad4",
|
"_shasum": "202288e3f58c49f6079d97af7a10e1303ae14b02",
|
||||||
"_shrinkwrap": null,
|
"_spec": "redis@2.8.0",
|
||||||
"_spec": "redis@2.6.3",
|
|
||||||
"_where": "/Users/sclay/projects/newsblur/node",
|
"_where": "/Users/sclay/projects/newsblur/node",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Matt Ranney",
|
"name": "Matt Ranney",
|
||||||
|
@ -52,20 +30,22 @@
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/NodeRedis/node_redis/issues"
|
"url": "https://github.com/NodeRedis/node_redis/issues"
|
||||||
},
|
},
|
||||||
|
"bundleDependencies": false,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"double-ended-queue": "^2.1.0-0",
|
"double-ended-queue": "^2.1.0-0",
|
||||||
"redis-commands": "^1.2.0",
|
"redis-commands": "^1.2.0",
|
||||||
"redis-parser": "^2.0.0"
|
"redis-parser": "^2.6.0"
|
||||||
},
|
},
|
||||||
|
"deprecated": false,
|
||||||
"description": "Redis client library",
|
"description": "Redis client library",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bluebird": "^3.0.2",
|
"bluebird": "^3.0.2",
|
||||||
"coveralls": "^2.11.2",
|
"coveralls": "^2.11.2",
|
||||||
"eslint": "^2.5.0",
|
"eslint": "^4.2.0",
|
||||||
"intercept-stdout": "~0.1.2",
|
"intercept-stdout": "~0.1.2",
|
||||||
"metrics": "^0.1.9",
|
"metrics": "^0.1.9",
|
||||||
"mocha": "^2.3.2",
|
"mocha": "^3.1.2",
|
||||||
"nyc": "^8.3.0",
|
"nyc": "^10.0.0",
|
||||||
"tcp-port-used": "^0.1.2",
|
"tcp-port-used": "^0.1.2",
|
||||||
"uuid": "^2.0.1",
|
"uuid": "^2.0.1",
|
||||||
"win-spawn": "^2.0.0"
|
"win-spawn": "^2.0.0"
|
||||||
|
@ -74,14 +54,9 @@
|
||||||
"example": "examples",
|
"example": "examples",
|
||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dist": {
|
|
||||||
"shasum": "84305b92553c6a1f09c7c47c30b11ace7dbb7ad4",
|
|
||||||
"tarball": "https://registry.npmjs.org/redis/-/redis-2.6.3.tgz"
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
},
|
},
|
||||||
"gitHead": "be07c12fbd039b7b3b1cb5a71f06e24464bc0593",
|
|
||||||
"homepage": "https://github.com/NodeRedis/node_redis",
|
"homepage": "https://github.com/NodeRedis/node_redis",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"database",
|
"database",
|
||||||
|
@ -96,27 +71,7 @@
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"maintainers": [
|
|
||||||
{
|
|
||||||
"name": "bcoe",
|
|
||||||
"email": "ben@npmjs.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "bridgear",
|
|
||||||
"email": "ruben@bridgewater.de"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "bryce",
|
|
||||||
"email": "bryce@ravenwall.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mjr",
|
|
||||||
"email": "mjr@ranney.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "redis",
|
"name": "redis",
|
||||||
"optionalDependencies": {},
|
|
||||||
"readme": "ERROR: No README data found!",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/NodeRedis/node_redis.git"
|
"url": "git://github.com/NodeRedis/node_redis.git"
|
||||||
|
@ -126,8 +81,8 @@
|
||||||
"compare": "node benchmarks/diff_multi_bench_output.js beforeBench.txt afterBench.txt",
|
"compare": "node benchmarks/diff_multi_bench_output.js beforeBench.txt afterBench.txt",
|
||||||
"coverage": "nyc report --reporter=html",
|
"coverage": "nyc report --reporter=html",
|
||||||
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
||||||
"posttest": "eslint . --fix && npm run coverage",
|
"lint": "eslint . --fix && npm run coverage",
|
||||||
"test": "nyc --cache mocha ./test/*.js ./test/commands/*.js --timeout=8000"
|
"test": "nyc --cache mocha ./test/*.js ./test/commands/*.js --timeout=8000"
|
||||||
},
|
},
|
||||||
"version": "2.6.3"
|
"version": "2.8.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,18 @@ else
|
||||||
|
|
||||||
app.get /\/rss_feeds\/original_text_fetcher\/?/, (req, res) =>
|
app.get /\/rss_feeds\/original_text_fetcher\/?/, (req, res) =>
|
||||||
res.setHeader 'Content-Type', 'application/json'
|
res.setHeader 'Content-Type', 'application/json'
|
||||||
|
if req.query.test
|
||||||
|
return res.end "OK"
|
||||||
|
|
||||||
url = req.query.url
|
url = req.query.url
|
||||||
if !url
|
if !url
|
||||||
log.debug "Missing url"
|
log.debug "Missing url"
|
||||||
res.end JSON.stringify error: "Missing `url` query parameter."
|
return res.end JSON.stringify error: "Missing `url` query parameter."
|
||||||
|
|
||||||
api_key = req.header 'x-api-key'
|
api_key = req.header 'x-api-key'
|
||||||
if not DEV and (!api_key or api_key.indexOf "djtXZrSIEfDa3Dex9FQ9AR" == -1)
|
if not DEV and (!api_key or api_key.indexOf "djtXZrSIEfDa3Dex9FQ9AR" == -1)
|
||||||
log.debug "Mismatched API key: #{url}"
|
log.debug "Mismatched API key: #{url}"
|
||||||
res.end JSON.stringify error: "Invalid API key. You need to set up your own Original Text server."
|
return res.end JSON.stringify error: "Invalid API key. You need to set up your own Original Text server."
|
||||||
|
|
||||||
Mercury.parse(url).then (result) =>
|
Mercury.parse(url).then (result) =>
|
||||||
log.debug "Fetched: #{url}"
|
log.debug "Fetched: #{url}"
|
||||||
|
|
|
@ -27,17 +27,20 @@
|
||||||
return function(req, res) {
|
return function(req, res) {
|
||||||
var api_key, url;
|
var api_key, url;
|
||||||
res.setHeader('Content-Type', 'application/json');
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
if (req.query.test) {
|
||||||
|
return res.end("OK");
|
||||||
|
}
|
||||||
url = req.query.url;
|
url = req.query.url;
|
||||||
if (!url) {
|
if (!url) {
|
||||||
log.debug("Missing url");
|
log.debug("Missing url");
|
||||||
res.end(JSON.stringify({
|
return res.end(JSON.stringify({
|
||||||
error: "Missing `url` query parameter."
|
error: "Missing `url` query parameter."
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
api_key = req.header('x-api-key');
|
api_key = req.header('x-api-key');
|
||||||
if (!DEV && (!api_key || api_key.indexOf("djtXZrSIEfDa3Dex9FQ9AR" === -1))) {
|
if (!DEV && (!api_key || api_key.indexOf("djtXZrSIEfDa3Dex9FQ9AR" === -1))) {
|
||||||
log.debug("Mismatched API key: " + url);
|
log.debug("Mismatched API key: " + url);
|
||||||
res.end(JSON.stringify({
|
return res.end(JSON.stringify({
|
||||||
error: "Invalid API key. You need to set up your own Original Text server."
|
error: "Invalid API key. You need to set up your own Original Text server."
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
26
node/package-lock.json
generated
26
node/package-lock.json
generated
|
@ -1661,9 +1661,9 @@
|
||||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
||||||
},
|
},
|
||||||
"qs": {
|
"qs": {
|
||||||
"version": "6.3.0",
|
"version": "6.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
|
||||||
"integrity": "sha1-9AOyZPI7wBIox0ExtAfxjV6l1EI="
|
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
|
||||||
},
|
},
|
||||||
"querystring": {
|
"querystring": {
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
|
@ -1700,24 +1700,24 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"redis": {
|
"redis": {
|
||||||
"version": "2.6.3",
|
"version": "2.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/redis/-/redis-2.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz",
|
||||||
"integrity": "sha1-hDBbklU8ah8Jx8R8MLEazn27etQ=",
|
"integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"double-ended-queue": "^2.1.0-0",
|
"double-ended-queue": "^2.1.0-0",
|
||||||
"redis-commands": "^1.2.0",
|
"redis-commands": "^1.2.0",
|
||||||
"redis-parser": "^2.0.0"
|
"redis-parser": "^2.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"redis-commands": {
|
"redis-commands": {
|
||||||
"version": "1.3.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.4.0.tgz",
|
||||||
"integrity": "sha1-QwfYCUruExWCmrZymze5n2I2XWM="
|
"integrity": "sha512-cu8EF+MtkwI4DLIT0x9P8qNTLFhQD4jLfxLR0cCNkeGzs87FN6879JOJwNQR/1zD7aSYNbU0hgsV9zGY71Itvw=="
|
||||||
},
|
},
|
||||||
"redis-parser": {
|
"redis-parser": {
|
||||||
"version": "2.3.0",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz",
|
||||||
"integrity": "sha1-MTpHll5J7jWrOobJM4i0A9diN/Y="
|
"integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs="
|
||||||
},
|
},
|
||||||
"regenerator-runtime": {
|
"regenerator-runtime": {
|
||||||
"version": "0.13.2",
|
"version": "0.13.2",
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"mongodb": "^2.2.36",
|
"mongodb": "^2.2.36",
|
||||||
"qs": "^6.3.0",
|
"qs": "^6.7.0",
|
||||||
"redis": "^2.6.3",
|
"redis": "^2.8.0",
|
||||||
"socket.io": "^2.2.0",
|
"socket.io": "^2.2.0",
|
||||||
"socket.io-client": "^2.2.0",
|
"socket.io-client": "^2.2.0",
|
||||||
"supervisor": "^0.12.0"
|
"supervisor": "^0.12.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue