Updating node_modules.

This commit is contained in:
Samuel Clay 2019-04-13 16:01:51 -04:00
parent 6c8097aa05
commit 3df1cbb401
54 changed files with 2724 additions and 1183 deletions

View file

@ -52,6 +52,7 @@ frontend public
use_backend node_socket if { path_beg /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_text if { path_beg /rss_feeds/original_text_fetcher/ }
use_backend nginx if { path_beg /media/ }
use_backend nginx if { path_beg /static/ }
use_backend nginx if { path_beg /favicon }
@ -76,6 +77,10 @@ backend node_favicon
balance roundrobin
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
balance roundrobin
option httpchk GET /_nginxchk

View file

@ -51,6 +51,7 @@ frontend public
use_backend node_socket if { path_beg /v2/socket.io/ }
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 /static/ }
use_backend nginx if { path_beg /favicon }
@ -77,7 +78,7 @@ backend node_favicon
backend node_text
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
{{ node_text }}

View file

@ -1,13 +1,12 @@
[program:node_text]
command=node node/text_server.js
command=node --experimental-modules node/original_text.js
directory=/srv/newsblur
environment=NODE_ENV=production
user=sclay
autostart=true
autorestart=true
#redirect_stderr=True
minfds = 10000
priority=991
stopsignal=HUP
stdout_logfile = /srv/newsblur/logs/text_server.log
stderr_logfile = /srv/newsblur/logs/error_text_server.log
stdout_logfile = /srv/newsblur/logs/original_text.log
stderr_logfile = /srv/newsblur/logs/error_original_text.log

7
fabfile.py vendored
View file

@ -785,13 +785,13 @@ def setup_staging():
run('touch logs/newsblur.log')
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')
# run('curl -L https://npmjs.org/install.sh | sudo sh')
# sudo('apt-get install npm')
sudo('npm install -g supervisor')
sudo('npm install -g @postlight/mercury-parser')
sudo('ufw allow 8888')
sudo('ufw allow 4040')
def config_node():
sudo('rm -fr /etc/supervisor/conf.d/node.conf')
@ -863,6 +863,7 @@ def setup_haproxy(debug=False):
if debug:
put('config/debug_haproxy.conf', '/etc/haproxy/haproxy.cfg', use_sudo=True)
else:
build_haproxy()
put(os.path.join(env.SECRETS_PATH, 'configs/haproxy.conf'),
'/etc/haproxy/haproxy.cfg', use_sudo=True)
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('/etc/init.d/haproxy stop')
run('sleep 1')
run('sleep 5')
sudo('/etc/init.d/haproxy start')
def config_haproxy(debug=False):

30
node/node_modules/qs/.editorconfig generated vendored Normal file
View 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
View file

@ -4,16 +4,18 @@
"extends": "@ljharb",
"rules": {
"complexity": [2, 25],
"consistent-return": [1],
"complexity": 0,
"consistent-return": 1,
"func-name-matching": 0,
"id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
"indent": [2, 4],
"max-params": [2, 11],
"max-statements": [2, 42],
"no-extra-parens": [1],
"no-continue": [1],
"max-lines-per-function": [2, { "max": 150 }],
"max-params": [2, 14],
"max-statements": [2, 52],
"multiline-comment-style": 0,
"no-continue": 1,
"no-magic-numbers": 0,
"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
View file

@ -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 doesnt break older node
- [Tests] Use precise dist for Node.js 0.6 runtime (#225)
- [Tests] make 0.6 required, now that its 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**
- [New] Add support for RFC 1738 (#174, #173)
- [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] 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**
- [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
- [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)
- [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)
- [New] allowDots option for `stringify` (#151)
- [Fix] "sort" option should work at a depth of 3 or more (#151)
- [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)
- Revert ES6 requirement and restore support for node down to v0.8.

View file

@ -1 +0,0 @@
Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md).

252
node/node_modules/qs/Readme.md generated vendored
View file

@ -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.
[![Build Status](https://api.travis-ci.org/ljharb/qs.svg)](http://travis-ci.org/ljharb/qs)
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).
@ -33,9 +39,9 @@ For example, the string `'foo[bar]=baz'` converts to:
```javascript
assert.deepEqual(qs.parse('foo[bar]=baz'), {
foo: {
bar: 'baz'
}
foo: {
bar: 'baz'
}
});
```
@ -57,7 +63,7 @@ URI encoded strings work too:
```javascript
assert.deepEqual(qs.parse('a%5Bb%5D=c'), {
a: { b: 'c' }
a: { b: 'c' }
});
```
@ -65,11 +71,11 @@ You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:
```javascript
assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), {
foo: {
bar: {
baz: 'foobarbaz'
foo: {
bar: {
baz: 'foobarbaz'
}
}
}
});
```
@ -78,19 +84,19 @@ By default, when nesting objects **qs** will only parse up to 5 children deep. T
```javascript
var expected = {
a: {
b: {
c: {
d: {
e: {
f: {
'[g][h][i]': 'j'
a: {
b: {
c: {
d: {
e: {
f: {
'[g][h][i]': 'j'
}
}
}
}
}
}
}
}
}
};
var string = 'a[b][c][d][e][f][g][h][i]=j';
assert.deepEqual(qs.parse(string), expected);
@ -112,6 +118,13 @@ var limited = qs.parse('a=b&c=d', { parameterLimit: 1 });
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:
```javascript
@ -133,6 +146,62 @@ var withDots = qs.parse('a.b=c', { allowDots: true });
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 &#10003; 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
**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
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
var withMaxIndex = qs.parse('a[100]=b');
@ -204,6 +273,13 @@ var arraysOfObjects = qs.parse('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
[](#preventEval)
@ -225,12 +301,21 @@ var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false });
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:
```javascript
var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str) {
// Passed in values `a`, `b`, `c`
return // Return encoded string
// Passed in values `a`, `b`, `c`
return // Return encoded string
}})
```
@ -240,8 +325,8 @@ Analogue to the `encoder` there is a `decoder` option for `parse` to override de
```javascript
var decoded = qs.parse('x=z', { decoder: function (str) {
// Passed in values `x`, `z`
return // Return decoded string
// Passed in values `x`, `z`
return // Return decoded string
}})
```
@ -261,7 +346,7 @@ qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false });
// '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
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
@ -270,6 +355,22 @@ qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
// 'a[]=b&a[]=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
// '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:
@ -278,12 +379,28 @@ Empty strings and null values will omit the value, but the equals sign (=) remai
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:
```javascript
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:
```javascript
@ -301,23 +418,32 @@ 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.
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:
```javascript
function filterFunc(prefix, value) {
if (prefix == 'b') {
// Return an `undefined` value to omit a property.
return;
}
if (prefix == 'e[f]') {
return value.getTime();
}
if (prefix == 'e[g][0]') {
return value * 2;
}
return value;
if (prefix == 'b') {
// Return an `undefined` value to omit a property.
return;
}
if (prefix == 'e[f]') {
return value.getTime();
}
if (prefix == 'e[g][0]') {
return value * 2;
}
return value;
}
qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: filterFunc });
// 'a=b&c=d&e[f]=123&e[g][0]=4'
@ -365,10 +491,40 @@ var nullsSkipped = qs.stringify({ a: 'b', c: null}, { skipNulls: true });
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
By default the encoding and decoding of characters is done in `utf-8`. If you
wish to encode querystrings to a different character set (i.e.
By default the encoding and decoding of characters is done in `utf-8`,
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
[`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 : '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

542
node/node_modules/qs/dist/qs.js generated vendored
View file

@ -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';
var replace = String.prototype.replace;
@ -42,32 +42,87 @@ var defaults = {
allowDots: false,
allowPrototypes: false,
arrayLimit: 20,
charset: 'utf-8',
charsetSentinel: false,
comma: false,
decoder: utils.decode,
delimiter: '&',
depth: 5,
ignoreQueryPrefix: false,
interpretNumericEntities: false,
parameterLimit: 1000,
parseArrays: true,
plainObjects: false,
strictNullHandling: false
};
var parseValues = function parseValues(str, options) {
var obj = {};
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
var interpretNumericEntities = function (str) {
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
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('&#10003;')
// 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 pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
var bracketEqualsPos = part.indexOf(']=');
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
var key, val;
if (pos === -1) {
key = options.decoder(part);
key = options.decoder(part, defaults.decoder, charset);
val = options.strictNullHandling ? null : '';
} else {
key = options.decoder(part.slice(0, pos));
val = options.decoder(part.slice(pos + 1));
key = options.decoder(part.slice(0, pos), defaults.decoder, charset);
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)) {
obj[key] = [].concat(obj[key]).concat(val);
obj[key] = utils.combine(obj[key], val);
} else {
obj[key] = val;
}
@ -76,68 +131,71 @@ var parseValues = function parseValues(str, options) {
return obj;
};
var parseObject = function parseObject(chain, val, options) {
if (!chain.length) {
return val;
}
var parseObject = function (chain, val, options) {
var leaf = val;
var root = chain.shift();
for (var i = chain.length - 1; i >= 0; --i) {
var obj;
var root = chain[i];
var obj;
if (root === '[]') {
obj = [];
obj = obj.concat(parseObject(chain, val, options));
} else {
obj = options.plainObjects ? Object.create(null) : {};
var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
var index = parseInt(cleanRoot, 10);
if (
!isNaN(index) &&
root !== cleanRoot &&
String(index) === cleanRoot &&
index >= 0 &&
(options.parseArrays && index <= options.arrayLimit)
) {
obj = [];
obj[index] = parseObject(chain, val, options);
if (root === '[]' && options.parseArrays) {
obj = [].concat(leaf);
} else {
obj[cleanRoot] = parseObject(chain, val, options);
obj = options.plainObjects ? Object.create(null) : {};
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
var index = parseInt(cleanRoot, 10);
if (!options.parseArrays && cleanRoot === '') {
obj = { 0: leaf };
} else if (
!isNaN(index)
&& root !== cleanRoot
&& String(index) === cleanRoot
&& index >= 0
&& (options.parseArrays && index <= options.arrayLimit)
) {
obj = [];
obj[index] = leaf;
} else {
obj[cleanRoot] = leaf;
}
}
leaf = obj;
}
return obj;
return leaf;
};
var parseKeys = function parseKeys(givenKey, val, options) {
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
if (!givenKey) {
return;
}
// 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
var parent = /^([^\[\]]*)/;
var child = /(\[[^\[\]]*\])/g;
var brackets = /(\[[^[\]]*])/;
var child = /(\[[^[\]]*])/g;
// 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
var keys = [];
if (segment[1]) {
// If we aren't using plain objects, optionally prefix keys
// that would overwrite object prototype properties
if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
if (parent) {
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {
return;
}
}
keys.push(segment[1]);
keys.push(parent);
}
// 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;
while ((segment = child.exec(key)) !== null && i < options.depth) {
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) {
continue;
return;
}
}
keys.push(segment[1]);
@ -162,23 +220,41 @@ var parseKeys = function parseKeys(givenKey, val, options) {
return parseObject(keys, val, options);
};
module.exports = function (str, opts) {
var options = opts || {};
var normalizeParseOptions = function normalizeParseOptions(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.');
}
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
options.parseArrays = options.parseArrays !== false;
options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');
}
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
return {
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
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') {
return options.plainObjects ? Object.create(null) : {};
@ -204,41 +280,75 @@ module.exports = function (str, opts) {
var utils = require('./utils');
var formats = require('./formats');
var has = Object.prototype.hasOwnProperty;
var arrayPrefixGenerators = {
brackets: function brackets(prefix) {
brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
return prefix + '[]';
},
indices: function indices(prefix, key) {
comma: 'comma',
indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
return prefix + '[' + key + ']';
},
repeat: function repeat(prefix) {
repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
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 defaults = {
addQueryPrefix: false,
allowDots: false,
charset: 'utf-8',
charsetSentinel: false,
delimiter: '&',
encode: true,
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);
},
skipNulls: 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;
if (typeof filter === 'function') {
obj = filter(prefix, obj);
} else if (obj instanceof Date) {
obj = serializeDate(obj);
} else if (obj === null) {
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
obj = obj.join(',');
}
if (obj === null) {
if (strictNullHandling) {
return encoder ? encoder(prefix) : prefix;
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix;
}
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 (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))];
}
@ -258,7 +369,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
}
var objKeys;
if (Array.isArray(filter)) {
if (isArray(filter)) {
objKeys = filter;
} else {
var keys = Object.keys(obj);
@ -272,10 +383,10 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
continue;
}
if (Array.isArray(obj)) {
values = values.concat(stringify(
if (isArray(obj)) {
pushToArray(values, stringify(
obj[key],
generateArrayPrefix(prefix, key),
typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix,
generateArrayPrefix,
strictNullHandling,
skipNulls,
@ -284,10 +395,12 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
sort,
allowDots,
serializeDate,
formatter
formatter,
encodeValuesOnly,
charset
));
} else {
values = values.concat(stringify(
pushToArray(values, stringify(
obj[key],
prefix + (allowDots ? '.' + key : '[' + key + ']'),
generateArrayPrefix,
@ -298,7 +411,9 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
sort,
allowDots,
serializeDate,
formatter
formatter,
encodeValuesOnly,
charset
));
}
}
@ -306,34 +421,63 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
return values;
};
module.exports = function (object, opts) {
var obj = object;
var options = opts || {};
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 normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
if (!opts) {
return defaults;
}
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.');
}
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') {
filter = options.filter;
obj = filter('', obj);
} else if (Array.isArray(options.filter)) {
} else if (isArray(options.filter)) {
filter = options.filter;
objKeys = filter;
}
@ -345,10 +489,10 @@ module.exports = function (object, opts) {
}
var arrayFormat;
if (options.arrayFormat in arrayPrefixGenerators) {
arrayFormat = options.arrayFormat;
} else if ('indices' in options) {
arrayFormat = options.indices ? 'indices' : 'repeat';
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
arrayFormat = opts.arrayFormat;
} else if (opts && 'indices' in opts) {
arrayFormat = opts.indices ? 'indices' : 'repeat';
} else {
arrayFormat = 'indices';
}
@ -359,39 +503,54 @@ module.exports = function (object, opts) {
objKeys = Object.keys(obj);
}
if (sort) {
objKeys.sort(sort);
if (options.sort) {
objKeys.sort(options.sort);
}
for (var i = 0; i < objKeys.length; ++i) {
var key = objKeys[i];
if (skipNulls && obj[key] === null) {
if (options.skipNulls && obj[key] === null) {
continue;
}
keys = keys.concat(stringify(
pushToArray(keys, stringify(
obj[key],
key,
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots,
serializeDate,
formatter
options.strictNullHandling,
options.skipNulls,
options.encode ? options.encoder : null,
options.filter,
options.sort,
options.allowDots,
options.serializeDate,
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('&#10003;'), 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){
'use strict';
var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
var hexTable = (function () {
var array = [];
@ -402,7 +561,26 @@ var hexTable = (function () {
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) : {};
for (var i = 0; i < source.length; ++i) {
if (typeof source[i] !== 'undefined') {
@ -413,16 +591,18 @@ exports.arrayToObject = function (source, options) {
return obj;
};
exports.merge = function (target, source, options) {
var merge = function merge(target, source, options) {
if (!source) {
return target;
}
if (typeof source !== 'object') {
if (Array.isArray(target)) {
if (isArray(target)) {
target.push(source);
} else if (typeof target === 'object') {
target[source] = true;
} else if (target && typeof target === 'object') {
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
target[source] = true;
}
} else {
return [target, source];
}
@ -430,20 +610,21 @@ exports.merge = function (target, source, options) {
return target;
}
if (typeof target !== 'object') {
if (!target || typeof target !== 'object') {
return [target].concat(source);
}
var mergeTarget = target;
if (Array.isArray(target) && !Array.isArray(source)) {
mergeTarget = exports.arrayToObject(target, options);
if (isArray(target) && !isArray(source)) {
mergeTarget = arrayToObject(target, options);
}
if (Array.isArray(target) && Array.isArray(source)) {
if (isArray(target) && isArray(source)) {
source.forEach(function (item, i) {
if (has.call(target, i)) {
if (target[i] && typeof target[i] === 'object') {
target[i] = exports.merge(target[i], item, options);
var targetItem = target[i];
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
target[i] = merge(targetItem, item, options);
} else {
target.push(item);
}
@ -457,8 +638,8 @@ exports.merge = function (target, source, options) {
return Object.keys(source).reduce(function (acc, key) {
var value = source[key];
if (Object.prototype.hasOwnProperty.call(acc, key)) {
acc[key] = exports.merge(acc[key], value, options);
if (has.call(acc, key)) {
acc[key] = merge(acc[key], value, options);
} else {
acc[key] = value;
}
@ -466,15 +647,28 @@ exports.merge = function (target, source, options) {
}, 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 {
return decodeURIComponent(str.replace(/\+/g, ' '));
return decodeURIComponent(strWithoutPlus);
} 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.
// It has been adapted here for stricter adherence to RFC 3986
if (str.length === 0) {
@ -483,18 +677,24 @@ exports.encode = function (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 = '';
for (var i = 0; i < string.length; ++i) {
var c = string.charCodeAt(i);
if (
c === 0x2D || // -
c === 0x2E || // .
c === 0x5F || // _
c === 0x7E || // ~
(c >= 0x30 && c <= 0x39) || // 0-9
(c >= 0x41 && c <= 0x5A) || // a-z
(c >= 0x61 && c <= 0x7A) // A-Z
c === 0x2D // -
|| c === 0x2E // .
|| c === 0x5F // _
|| c === 0x7E // ~
|| (c >= 0x30 && c <= 0x39) // 0-9
|| (c >= 0x41 && c <= 0x5A) // a-z
|| (c >= 0x61 && c <= 0x7A) // A-Z
) {
out += string.charAt(i);
continue;
@ -517,58 +717,66 @@ exports.encode = function (str) {
i += 1;
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;
};
exports.compact = function (obj, references) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
var compact = function compact(value) {
var queue = [{ obj: { o: value }, prop: 'o' }];
var refs = [];
var refs = references || [];
var lookup = refs.indexOf(obj);
if (lookup !== -1) {
return refs[lookup];
}
for (var i = 0; i < queue.length; ++i) {
var item = queue[i];
var obj = item.obj[item.prop];
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]);
var keys = Object.keys(obj);
for (var j = 0; j < keys.length; ++j) {
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 compacted;
}
var keys = Object.keys(obj);
keys.forEach(function (key) {
obj[key] = exports.compact(obj[key], refs);
});
compactQueue(queue);
return obj;
return value;
};
exports.isRegExp = function (obj) {
var isRegExp = function isRegExp(obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
exports.isBuffer = function (obj) {
if (obj === null || typeof obj === 'undefined') {
var isBuffer = function isBuffer(obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
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)
});
});

0
node/node_modules/qs/lib/index.js generated vendored Executable file → Normal file
View file

192
node/node_modules/qs/lib/parse.js generated vendored Executable file → Normal file
View file

@ -8,32 +8,87 @@ var defaults = {
allowDots: false,
allowPrototypes: false,
arrayLimit: 20,
charset: 'utf-8',
charsetSentinel: false,
comma: false,
decoder: utils.decode,
delimiter: '&',
depth: 5,
ignoreQueryPrefix: false,
interpretNumericEntities: false,
parameterLimit: 1000,
parseArrays: true,
plainObjects: false,
strictNullHandling: false
};
var parseValues = function parseValues(str, options) {
var obj = {};
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
var interpretNumericEntities = function (str) {
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
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('&#10003;')
// 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 pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
var bracketEqualsPos = part.indexOf(']=');
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
var key, val;
if (pos === -1) {
key = options.decoder(part);
key = options.decoder(part, defaults.decoder, charset);
val = options.strictNullHandling ? null : '';
} else {
key = options.decoder(part.slice(0, pos));
val = options.decoder(part.slice(pos + 1));
key = options.decoder(part.slice(0, pos), defaults.decoder, charset);
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)) {
obj[key] = [].concat(obj[key]).concat(val);
obj[key] = utils.combine(obj[key], val);
} else {
obj[key] = val;
}
@ -42,68 +97,71 @@ var parseValues = function parseValues(str, options) {
return obj;
};
var parseObject = function parseObject(chain, val, options) {
if (!chain.length) {
return val;
}
var parseObject = function (chain, val, options) {
var leaf = val;
var root = chain.shift();
for (var i = chain.length - 1; i >= 0; --i) {
var obj;
var root = chain[i];
var obj;
if (root === '[]') {
obj = [];
obj = obj.concat(parseObject(chain, val, options));
} else {
obj = options.plainObjects ? Object.create(null) : {};
var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
var index = parseInt(cleanRoot, 10);
if (
!isNaN(index) &&
root !== cleanRoot &&
String(index) === cleanRoot &&
index >= 0 &&
(options.parseArrays && index <= options.arrayLimit)
) {
obj = [];
obj[index] = parseObject(chain, val, options);
if (root === '[]' && options.parseArrays) {
obj = [].concat(leaf);
} else {
obj[cleanRoot] = parseObject(chain, val, options);
obj = options.plainObjects ? Object.create(null) : {};
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
var index = parseInt(cleanRoot, 10);
if (!options.parseArrays && cleanRoot === '') {
obj = { 0: leaf };
} else if (
!isNaN(index)
&& root !== cleanRoot
&& String(index) === cleanRoot
&& index >= 0
&& (options.parseArrays && index <= options.arrayLimit)
) {
obj = [];
obj[index] = leaf;
} else {
obj[cleanRoot] = leaf;
}
}
leaf = obj;
}
return obj;
return leaf;
};
var parseKeys = function parseKeys(givenKey, val, options) {
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
if (!givenKey) {
return;
}
// 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
var parent = /^([^\[\]]*)/;
var child = /(\[[^\[\]]*\])/g;
var brackets = /(\[[^[\]]*])/;
var child = /(\[[^[\]]*])/g;
// 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
var keys = [];
if (segment[1]) {
// If we aren't using plain objects, optionally prefix keys
// that would overwrite object prototype properties
if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
if (parent) {
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {
return;
}
}
keys.push(segment[1]);
keys.push(parent);
}
// 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;
while ((segment = child.exec(key)) !== null && i < options.depth) {
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) {
continue;
return;
}
}
keys.push(segment[1]);
@ -128,23 +186,41 @@ var parseKeys = function parseKeys(givenKey, val, options) {
return parseObject(keys, val, options);
};
module.exports = function (str, opts) {
var options = opts || {};
var normalizeParseOptions = function normalizeParseOptions(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.');
}
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
options.parseArrays = options.parseArrays !== false;
options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');
}
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
return {
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
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') {
return options.plainObjects ? Object.create(null) : {};

188
node/node_modules/qs/lib/stringify.js generated vendored Executable file → Normal file
View file

@ -2,41 +2,75 @@
var utils = require('./utils');
var formats = require('./formats');
var has = Object.prototype.hasOwnProperty;
var arrayPrefixGenerators = {
brackets: function brackets(prefix) {
brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
return prefix + '[]';
},
indices: function indices(prefix, key) {
comma: 'comma',
indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
return prefix + '[' + key + ']';
},
repeat: function repeat(prefix) {
repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
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 defaults = {
addQueryPrefix: false,
allowDots: false,
charset: 'utf-8',
charsetSentinel: false,
delimiter: '&',
encode: true,
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);
},
skipNulls: 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;
if (typeof filter === 'function') {
obj = filter(prefix, obj);
} else if (obj instanceof Date) {
obj = serializeDate(obj);
} else if (obj === null) {
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
obj = obj.join(',');
}
if (obj === null) {
if (strictNullHandling) {
return encoder ? encoder(prefix) : prefix;
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix;
}
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 (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))];
}
@ -56,7 +91,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
}
var objKeys;
if (Array.isArray(filter)) {
if (isArray(filter)) {
objKeys = filter;
} else {
var keys = Object.keys(obj);
@ -70,10 +105,10 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
continue;
}
if (Array.isArray(obj)) {
values = values.concat(stringify(
if (isArray(obj)) {
pushToArray(values, stringify(
obj[key],
generateArrayPrefix(prefix, key),
typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix,
generateArrayPrefix,
strictNullHandling,
skipNulls,
@ -82,10 +117,12 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
sort,
allowDots,
serializeDate,
formatter
formatter,
encodeValuesOnly,
charset
));
} else {
values = values.concat(stringify(
pushToArray(values, stringify(
obj[key],
prefix + (allowDots ? '.' + key : '[' + key + ']'),
generateArrayPrefix,
@ -96,7 +133,9 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
sort,
allowDots,
serializeDate,
formatter
formatter,
encodeValuesOnly,
charset
));
}
}
@ -104,34 +143,63 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu
return values;
};
module.exports = function (object, opts) {
var obj = object;
var options = opts || {};
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 normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
if (!opts) {
return defaults;
}
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.');
}
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') {
filter = options.filter;
obj = filter('', obj);
} else if (Array.isArray(options.filter)) {
} else if (isArray(options.filter)) {
filter = options.filter;
objKeys = filter;
}
@ -143,10 +211,10 @@ module.exports = function (object, opts) {
}
var arrayFormat;
if (options.arrayFormat in arrayPrefixGenerators) {
arrayFormat = options.arrayFormat;
} else if ('indices' in options) {
arrayFormat = options.indices ? 'indices' : 'repeat';
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
arrayFormat = opts.arrayFormat;
} else if (opts && 'indices' in opts) {
arrayFormat = opts.indices ? 'indices' : 'repeat';
} else {
arrayFormat = 'indices';
}
@ -157,31 +225,45 @@ module.exports = function (object, opts) {
objKeys = Object.keys(obj);
}
if (sort) {
objKeys.sort(sort);
if (options.sort) {
objKeys.sort(options.sort);
}
for (var i = 0; i < objKeys.length; ++i) {
var key = objKeys[i];
if (skipNulls && obj[key] === null) {
if (options.skipNulls && obj[key] === null) {
continue;
}
keys = keys.concat(stringify(
pushToArray(keys, stringify(
obj[key],
key,
generateArrayPrefix,
strictNullHandling,
skipNulls,
encoder,
filter,
sort,
allowDots,
serializeDate,
formatter
options.strictNullHandling,
options.skipNulls,
options.encode ? options.encoder : null,
options.filter,
options.sort,
options.allowDots,
options.serializeDate,
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('&#10003;'), 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 : '';
};

158
node/node_modules/qs/lib/utils.js generated vendored Executable file → Normal file
View file

@ -1,6 +1,7 @@
'use strict';
var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
var hexTable = (function () {
var array = [];
@ -11,7 +12,26 @@ var hexTable = (function () {
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) : {};
for (var i = 0; i < source.length; ++i) {
if (typeof source[i] !== 'undefined') {
@ -22,16 +42,18 @@ exports.arrayToObject = function (source, options) {
return obj;
};
exports.merge = function (target, source, options) {
var merge = function merge(target, source, options) {
if (!source) {
return target;
}
if (typeof source !== 'object') {
if (Array.isArray(target)) {
if (isArray(target)) {
target.push(source);
} else if (typeof target === 'object') {
target[source] = true;
} else if (target && typeof target === 'object') {
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
target[source] = true;
}
} else {
return [target, source];
}
@ -39,20 +61,21 @@ exports.merge = function (target, source, options) {
return target;
}
if (typeof target !== 'object') {
if (!target || typeof target !== 'object') {
return [target].concat(source);
}
var mergeTarget = target;
if (Array.isArray(target) && !Array.isArray(source)) {
mergeTarget = exports.arrayToObject(target, options);
if (isArray(target) && !isArray(source)) {
mergeTarget = arrayToObject(target, options);
}
if (Array.isArray(target) && Array.isArray(source)) {
if (isArray(target) && isArray(source)) {
source.forEach(function (item, i) {
if (has.call(target, i)) {
if (target[i] && typeof target[i] === 'object') {
target[i] = exports.merge(target[i], item, options);
var targetItem = target[i];
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
target[i] = merge(targetItem, item, options);
} else {
target.push(item);
}
@ -66,8 +89,8 @@ exports.merge = function (target, source, options) {
return Object.keys(source).reduce(function (acc, key) {
var value = source[key];
if (Object.prototype.hasOwnProperty.call(acc, key)) {
acc[key] = exports.merge(acc[key], value, options);
if (has.call(acc, key)) {
acc[key] = merge(acc[key], value, options);
} else {
acc[key] = value;
}
@ -75,15 +98,28 @@ exports.merge = function (target, source, options) {
}, 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 {
return decodeURIComponent(str.replace(/\+/g, ' '));
return decodeURIComponent(strWithoutPlus);
} 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.
// It has been adapted here for stricter adherence to RFC 3986
if (str.length === 0) {
@ -92,18 +128,24 @@ exports.encode = function (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 = '';
for (var i = 0; i < string.length; ++i) {
var c = string.charCodeAt(i);
if (
c === 0x2D || // -
c === 0x2E || // .
c === 0x5F || // _
c === 0x7E || // ~
(c >= 0x30 && c <= 0x39) || // 0-9
(c >= 0x41 && c <= 0x5A) || // a-z
(c >= 0x61 && c <= 0x7A) // A-Z
c === 0x2D // -
|| c === 0x2E // .
|| c === 0x5F // _
|| c === 0x7E // ~
|| (c >= 0x30 && c <= 0x39) // 0-9
|| (c >= 0x41 && c <= 0x5A) // a-z
|| (c >= 0x61 && c <= 0x7A) // A-Z
) {
out += string.charAt(i);
continue;
@ -126,55 +168,63 @@ exports.encode = function (str) {
i += 1;
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;
};
exports.compact = function (obj, references) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
var compact = function compact(value) {
var queue = [{ obj: { o: value }, prop: 'o' }];
var refs = [];
var refs = references || [];
var lookup = refs.indexOf(obj);
if (lookup !== -1) {
return refs[lookup];
}
for (var i = 0; i < queue.length; ++i) {
var item = queue[i];
var obj = item.obj[item.prop];
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]);
var keys = Object.keys(obj);
for (var j = 0; j < keys.length; ++j) {
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 compacted;
}
var keys = Object.keys(obj);
keys.forEach(function (key) {
obj[key] = exports.compact(obj[key], refs);
});
compactQueue(queue);
return obj;
return value;
};
exports.isRegExp = function (obj) {
var isRegExp = function isRegExp(obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
exports.isBuffer = function (obj) {
if (obj === null || typeof obj === 'undefined') {
var isBuffer = function isBuffer(obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
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
View file

@ -1,53 +1,32 @@
{
"_args": [
[
{
"raw": "qs@6.3.0",
"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,
"_from": "qs@6.7.0",
"_id": "qs@6.7.0",
"_inBundle": false,
"_integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==",
"_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": {},
"_requested": {
"raw": "qs@6.3.0",
"scope": null,
"escapedName": "qs",
"type": "version",
"registry": true,
"raw": "qs@6.7.0",
"name": "qs",
"rawSpec": "6.3.0",
"spec": "6.3.0",
"type": "version"
"escapedName": "qs",
"rawSpec": "6.7.0",
"saveSpec": null,
"fetchSpec": "6.7.0"
},
"_requiredBy": [
"#USER"
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz",
"_shasum": "f403b264f23bc01228c74131b407f18d5ea5d442",
"_shrinkwrap": null,
"_spec": "qs@6.3.0",
"_resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"_shasum": "41dc1a015e3d581f1621776be31afb2876a9b1bc",
"_spec": "qs@6.7.0",
"_where": "/Users/sclay/projects/newsblur/node",
"bugs": {
"url": "https://github.com/ljharb/qs/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Jordan Harband",
@ -56,53 +35,39 @@
}
],
"dependencies": {},
"deprecated": false,
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
"devDependencies": {
"@ljharb/eslint-config": "^8.0.0",
"browserify": "^13.1.0",
"covert": "^1.1.0",
"eslint": "^3.8.0",
"@ljharb/eslint-config": "^13.1.1",
"browserify": "^16.2.3",
"covert": "^1.1.1",
"editorconfig-tools": "^0.1.1",
"eslint": "^5.15.3",
"evalmd": "^0.0.17",
"iconv-lite": "^0.4.13",
"for-each": "^0.3.3",
"iconv-lite": "^0.4.24",
"mkdirp": "^0.5.1",
"parallelshell": "^2.0.0",
"qs-iconv": "^1.0.3",
"safe-publish-latest": "^1.1.1",
"tape": "^4.6.2"
},
"directories": {},
"dist": {
"shasum": "f403b264f23bc01228c74131b407f18d5ea5d442",
"tarball": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz"
"object-inspect": "^1.6.0",
"qs-iconv": "^1.0.4",
"safe-publish-latest": "^1.1.2",
"safer-buffer": "^2.1.2",
"tape": "^4.10.1"
},
"engines": {
"node": ">=0.6"
},
"gitHead": "8aa9c26f90335b5483a4f456dea9acbada8a881c",
"homepage": "https://github.com/ljharb/qs",
"keywords": [
"querystring",
"qs"
"qs",
"query",
"url",
"parse",
"stringify"
],
"license": "BSD-3-Clause",
"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",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/ljharb/qs.git"
@ -111,11 +76,12 @@
"coverage": "covert test",
"dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js",
"lint": "eslint lib/*.js test/*.js",
"postlint": "editorconfig-tools check * lib/* test/*",
"prepublish": "safe-publish-latest && npm run dist",
"pretest": "npm run --silent readme && npm run --silent lint",
"readme": "evalmd README.md",
"test": "npm run --silent coverage",
"tests-only": "node test"
},
"version": "6.3.0"
"version": "6.7.0"
}

10
node/node_modules/qs/test/.eslintrc generated vendored
View file

@ -1,9 +1,17 @@
{
"rules": {
"array-bracket-newline": 0,
"array-element-newline": 0,
"consistent-return": 2,
"function-paren-newline": 0,
"max-lines": 0,
"max-lines-per-function": 0,
"max-nested-callbacks": [2, 3],
"max-statements": 0,
"no-buffer-constructor": 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
View file

@ -2,7 +2,9 @@
var test = require('tape');
var qs = require('../');
var utils = require('../lib/utils');
var iconv = require('iconv-lite');
var SaferBuffer = require('safer-buffer').Buffer;
test('parse()', function (t) {
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[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[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.end();
});
@ -152,8 +154,6 @@ test('parse()', function (t) {
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) {
st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } });
st.end();
@ -232,11 +232,19 @@ test('parse()', function (t) {
});
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.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) {
st.deepEqual(qs.parse('[]=&a=b'), { 0: '', a: 'b' });
st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { 0: null, a: 'b' });
@ -257,7 +265,7 @@ test('parse()', function (t) {
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 = '';
Array.prototype.crash = '';
st.doesNotThrow(qs.parse.bind(null, 'a=b'));
@ -302,7 +310,21 @@ test('parse()', function (t) {
});
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();
});
@ -325,6 +347,15 @@ test('parse()', function (t) {
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) {
var input = {
'user.name': { 'pop[bob]': 3 },
@ -390,6 +421,33 @@ test('parse()', function (t) {
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) {
var a = Object.create(null);
a.b = 'c';
@ -413,9 +471,71 @@ test('parse()', function (t) {
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) {
st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } }, { prototype: false });
st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { 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' });
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();
});
@ -444,16 +564,113 @@ test('parse()', function (t) {
result.push(parseInt(parts[1], 16));
parts = reg.exec(str);
}
return iconv.decode(new Buffer(result), 'shift_jis').toString();
return String(iconv.decode(SaferBuffer.from(result), 'shift_jis'));
}
}), { : '大阪府' });
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) {
st.throws(function () {
st['throws'](function () {
qs.parse({}, { decoder: 'string' });
}, new TypeError('Decoder has to be a function.'));
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: '&#9786;' });
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: '&#9786;' });
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
View file

@ -2,7 +2,9 @@
var test = require('tape');
var qs = require('../');
var utils = require('../lib/utils');
var iconv = require('iconv-lite');
var SaferBuffer = require('safer-buffer').Buffer;
test('stringify()', function (t) {
t.test('stringifies a querystring object', function (st) {
@ -17,6 +19,32 @@ test('stringify()', function (t) {
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) {
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');
@ -40,6 +68,11 @@ test('stringify()', function (t) {
'a%5B%5D=b&a%5B%5D=c&a%5B%5D=d',
'brackets => brackets'
);
st.equal(
qs.stringify({ a: ['b', 'c', 'd'] }, { arrayFormat: 'comma' }),
'a=b%2Cc%2Cd',
'comma => comma'
);
st.equal(
qs.stringify({ a: ['b', 'c', '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) {
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: '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.end();
});
@ -87,6 +121,14 @@ test('stringify()', function (t) {
'a.b[]=c&a.b[]=d',
'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(
qs.stringify(
{ a: { b: ['c', 'd'] } },
@ -101,12 +143,12 @@ test('stringify()', function (t) {
t.test('stringifies an object inside an array', function (st) {
st.equal(
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'
);
st.equal(
qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'brackets' }),
'a%5B%5D%5Bb%5D=c',
'a%5B%5D%5Bb%5D=c', // a[][b]=c
'brackets => brackets'
);
st.equal(
@ -325,8 +367,8 @@ test('stringify()', function (t) {
});
t.test('stringifies buffer values', function (st) {
st.equal(qs.stringify({ a: new Buffer('test') }), 'a=test');
st.equal(qs.stringify({ a: { b: new Buffer('test') } }), 'a%5Bb%5D=test');
st.equal(qs.stringify({ a: SaferBuffer.from('test') }), 'a=test');
st.equal(qs.stringify({ a: { b: SaferBuffer.from('test') } }), 'a%5Bb%5D=test');
st.end();
});
@ -385,7 +427,7 @@ test('stringify()', function (t) {
st.equal(prefix, '', 'prefix is empty');
st.equal(value, obj);
} else if (prefix === 'c') {
return;
return void 0;
} else if (value instanceof Date) {
st.equal(prefix, 'e[f]');
return value.getTime();
@ -452,15 +494,25 @@ test('stringify()', function (t) {
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) {
st.throws(function () {
st['throws'](function () {
qs.stringify({}, { encoder: 'string' });
}, new TypeError('Encoder has to be a function.'));
st.end();
});
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) {
if (typeof buffer === 'string') {
return buffer;
@ -483,7 +535,7 @@ test('stringify()', function (t) {
mutatedDate.toISOString = function () {
throw new SyntaxError();
};
st.throws(function () {
st['throws'](function () {
mutatedDate.toISOString();
}, SyntaxError);
st.equal(
@ -525,7 +577,7 @@ test('stringify()', function (t) {
t.test('Edge cases and unknown formats', function (st) {
['UFO1234', false, 1234, null, {}, []].forEach(
function (format) {
st.throws(
st['throws'](
function () {
qs.stringify({ a: 'b c' }, { format: format });
},
@ -535,4 +587,93 @@ test('stringify()', function (t) {
);
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
View file

@ -1,9 +1,16 @@
'use strict';
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');
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');
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'] });
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();
});

View file

@ -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

View file

@ -1,9 +1,9 @@
language: node_js
sudo: false
node_js:
- "0.10"
- "0.12"
- "4"
- "5"
- "6"
- "8"
- "9"
- "10"
after_success:
- CODECLIMATE_REPO_TOKEN=b57723fafcf0516f275d6b380cd506fd082ea88d86507eb82c8abd489b9b9a09 node ./node_modules/.bin/codeclimate-test-reporter < coverage/lcov.info

View file

@ -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
Features

View file

@ -117,6 +117,28 @@
"keyStop": 2,
"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": {
"arity": -2,
"flags": [
@ -168,7 +190,7 @@
"step": 0
},
"debug": {
"arity": -1,
"arity": -2,
"flags": [
"admin",
"noscript"
@ -354,7 +376,18 @@
"georadius": {
"arity": -6,
"flags": [
"write"
"write",
"movablekeys"
],
"keyStart": 1,
"keyStop": 1,
"step": 1
},
"georadius_ro": {
"arity": -6,
"flags": [
"readonly",
"movablekeys"
],
"keyStart": 1,
"keyStop": 1,
@ -363,7 +396,18 @@
"georadiusbymember": {
"arity": -5,
"flags": [
"write"
"write",
"movablekeys"
],
"keyStart": 1,
"keyStop": 1,
"step": 1
},
"georadiusbymember_ro": {
"arity": -5,
"flags": [
"readonly",
"movablekeys"
],
"keyStart": 1,
"keyStop": 1,
@ -492,7 +536,8 @@
"hmget": {
"arity": -3,
"flags": [
"readonly"
"readonly",
"fast"
],
"keyStart": 1,
"keyStop": 1,
@ -502,7 +547,8 @@
"arity": -4,
"flags": [
"write",
"denyoom"
"denyoom",
"fast"
],
"keyStart": 1,
"keyStop": 1,
@ -529,7 +575,7 @@
"step": 1
},
"hset": {
"arity": 4,
"arity": -4,
"flags": [
"write",
"denyoom",
@ -755,7 +801,8 @@
"mget": {
"arity": -2,
"flags": [
"readonly"
"readonly",
"fast"
],
"keyStart": 1,
"keyStop": -1,
@ -777,9 +824,9 @@
"admin",
"noscript"
],
"keyStart": 1,
"keyStop": 1,
"step": 1
"keyStart": 0,
"keyStop": 0,
"step": 0
},
"monitor": {
"arity": 1,
@ -832,13 +879,13 @@
"step": 0
},
"object": {
"arity": 3,
"arity": -2,
"flags": [
"readonly"
],
"keyStart": 2,
"keyStop": 2,
"step": 2
"step": 1
},
"persist": {
"arity": 2,
@ -1588,6 +1635,135 @@
"keyStop": -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": {
"arity": -4,
"flags": [
@ -1651,6 +1827,26 @@
"keyStop": 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": {
"arity": -4,
"flags": [

View file

@ -1,6 +1,6 @@
'use strict'
var commands = require('./commands')
var commands = require('./commands.json')
/**
* Redis command list

View file

@ -1,48 +1,25 @@
{
"_args": [
[
{
"raw": "redis-commands@^1.2.0",
"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,
"_from": "redis-commands@^1.2.0",
"_id": "redis-commands@1.4.0",
"_inBundle": false,
"_integrity": "sha512-cu8EF+MtkwI4DLIT0x9P8qNTLFhQD4jLfxLR0cCNkeGzs87FN6879JOJwNQR/1zD7aSYNbU0hgsV9zGY71Itvw==",
"_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": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "redis-commands@^1.2.0",
"scope": null,
"escapedName": "redis-commands",
"name": "redis-commands",
"escapedName": "redis-commands",
"rawSpec": "^1.2.0",
"spec": ">=1.2.0 <2.0.0",
"type": "range"
"saveSpec": null,
"fetchSpec": "^1.2.0"
},
"_requiredBy": [
"/redis"
],
"_resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.0.tgz",
"_shasum": "4307d8094aee1315829ab6729b37b99f62365d63",
"_shrinkwrap": null,
"_resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.4.0.tgz",
"_shasum": "52f9cf99153efcce56a8f86af986bd04e988602f",
"_spec": "redis-commands@^1.2.0",
"_where": "/Users/sclay/projects/newsblur/node/node_modules/redis",
"author": {
@ -51,27 +28,22 @@
"url": "http://zihua.li"
},
"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",
"devDependencies": {
"chai": "^3.4.0",
"codeclimate-test-reporter": "^0.3.1",
"ioredis": "^2.0.0",
"chai": "^4.0.1",
"codeclimate-test-reporter": "^0.4.0",
"ioredis": "^3.0.0",
"istanbul": "^0.4.3",
"json-stable-stringify": "^1.0.0",
"mocha": "^3.0.0",
"snazzy": "^5.0.0",
"standard": "^8.0.0"
"mocha": "^5.0.0",
"safe-stable-stringify": "^1.0.0",
"snazzy": "^8.0.0",
"standard": "^11.0.0"
},
"directories": {},
"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",
"homepage": "https://github.com/NodeRedis/redis-commands",
"keywords": [
"redis",
"commands",
@ -79,19 +51,7 @@
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "bridgear",
"email": "ruben@bridgewater.de"
},
{
"name": "luin",
"email": "i@zihua.li"
}
],
"name": "redis-commands",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/NodeRedis/redis-commands.git"
@ -105,5 +65,5 @@
"pretest": "npm run lint",
"test": "mocha"
},
"version": "1.3.0"
"version": "1.4.0"
}

View file

@ -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])
})
})
})
})

View file

@ -1,6 +1,6 @@
var fs = require('fs')
var path = require('path')
var stringify = require('json-stable-stringify')
var stringify = require('safe-stable-stringify')
var commandPath = path.join(__dirname, '..', 'commands.json')
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')
}
// Use json-stable-stringify instead fo JSON.stringify
// Use safe-stable-stringify instead fo JSON.stringify
// for easier diffing
var content = stringify(commands, { space: ' ' })
var content = stringify(commands, null, ' ')
fs.writeFile(commandPath, content)
fs.writeFileSync(commandPath, content)
})

View file

@ -1,6 +0,0 @@
languages:
JavaScript: true
exclude_paths:
- "benchmark/index.js"
- "benchmark/old/javascript.js"
- "test/parsers.spec.js"

View file

@ -10,3 +10,6 @@ coverage
test
.travis.yml
.gitignore
*.log
.vscode
.codeclimate.yml

View file

@ -1,5 +1,4 @@
[![Build Status](https://travis-ci.org/NodeRedis/node-redis-parser.png?branch=master)](https://travis-ci.org/NodeRedis/node-redis-parser)
[![Code Climate](https://codeclimate.com/github/NodeRedis/node-redis-parser/badges/gpa.svg)](https://codeclimate.com/github/NodeRedis/node-redis-parser)
[![Test Coverage](https://codeclimate.com/github/NodeRedis/node-redis-parser/badges/coverage.svg)](https://codeclimate.com/github/NodeRedis/node-redis-parser/coverage)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
@ -21,7 +20,7 @@ var Parser = require('redis-parser');
var myParser = new Parser(options);
```
### Possible options
### Options
* `returnReply`: *function*; mandatory
* `returnError`: *function*; mandatory
@ -29,6 +28,21 @@ var myParser = new Parser(options);
* `returnBuffers`: *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
```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:
HIREDIS: $ multiple chunks in a bulk string x 867,643 ops/sec ±1.39% (82 runs sampled)
HIREDIS BUF: $ multiple chunks in a bulk string x 591,398 ops/sec ±1.48% (83 runs sampled)
JS PARSER: $ multiple chunks in a bulk string x 942,834 ops/sec ±0.87% (90 runs sampled)
JS PARSER BUF: $ multiple chunks in a bulk string x 1,081,096 ops/sec ±1.81% (85 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 608,869 ops/sec ±1.72% (85 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,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 BUF: + multiple chunks in a string x 902,391 ops/sec ±1.62% (88 runs sampled)
JS PARSER: + multiple chunks in a string x 1,936,709 ops/sec ±1.07% (90 runs sampled)
JS PARSER BUF: + multiple chunks in a string x 1,954,798 ops/sec ±0.84% (91 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 943,584 ops/sec ±1.62% (87 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 2,045,546 ops/sec ±0.78% (91 runs sampled)
HIREDIS: $ 4mb bulk string x 344 ops/sec ±1.40% (85 runs sampled)
HIREDIS BUF: $ 4mb bulk string x 555 ops/sec ±1.85% (80 runs sampled)
JS PARSER: $ 4mb bulk string x 834 ops/sec ±1.23% (81 runs sampled)
JS PARSER BUF: $ 4mb bulk string x 620 ops/sec ±2.40% (59 runs sampled)
HIREDIS: $ 4mb bulk string x 310 ops/sec ±1.58% (75 runs sampled)
HIREDIS BUF: $ 4mb bulk string x 471 ops/sec ±2.28% (78 runs sampled)
JS PARSER: $ 4mb bulk string x 747 ops/sec ±2.43% (85 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 BUF: + simple string x 993,081 ops/sec ±1.87% (83 runs sampled)
JS PARSER: + simple string x 4,431,517 ops/sec ±1.86% (88 runs sampled)
JS PARSER BUF: + simple string x 5,259,552 ops/sec ±0.61% (96 runs sampled)
HIREDIS: + simple string x 2,324,866 ops/sec ±1.61% (90 runs sampled)
HIREDIS BUF: + simple string x 1,085,823 ops/sec ±2.47% (82 runs sampled)
JS PARSER: + simple string x 4,567,358 ops/sec ±1.97% (81 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)
JS PARSER: : integer x 17,765,077 ops/sec ±0.53% (93 runs sampled)
JS PARSER STR: : integer x 13,110,365 ops/sec ±0.67% (91 runs sampled)
HIREDIS: : integer x 2,332,946 ops/sec ±0.47% (93 runs sampled)
JS PARSER: : integer x 17,730,449 ops/sec ±0.73% (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)
JS PARSER: : big integer x 10,277,063 ops/sec ±0.69% (91 runs sampled)
JS PARSER STR: : big integer x 4,492,626 ops/sec ±0.67% (94 runs sampled)
HIREDIS: : big integer x 2,012,572 ops/sec ±0.33% (93 runs sampled)
JS PARSER: : big integer x 10,210,923 ops/sec ±0.94% (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 BUF: * array x 13,893 ops/sec ±1.05% (85 runs sampled)
JS PARSER: * array x 50,825 ops/sec ±1.92% (80 runs sampled)
JS PARSER BUF: * array x 72,546 ops/sec ±0.80% (94 runs sampled)
HIREDIS: * array x 44,479 ops/sec ±0.55% (94 runs sampled)
HIREDIS BUF: * array x 14,391 ops/sec ±1.04% (86 runs sampled)
JS PARSER: * array x 53,796 ops/sec ±2.08% (79 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 BUF: * big array x 226 ops/sec ±3.21% (75 runs sampled)
JS PARSER: * big array x 201 ops/sec ±0.95% (83 runs sampled)
JS PARSER BUF: * big array x 244 ops/sec ±2.65% (81 runs sampled)
HIREDIS: * big nested array x 217 ops/sec ±0.97% (83 runs sampled)
HIREDIS BUF: * big nested array x 255 ops/sec ±2.28% (77 runs sampled)
JS PARSER: * big nested array x 242 ops/sec ±1.10% (85 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)
JS PARSER: - error x 155,225 ops/sec ±0.57% (95 runs sampled)
HIREDIS: - error x 78,821 ops/sec ±0.80% (93 runs sampled)
JS PARSER: - error x 143,382 ops/sec ±0.75% (92 runs sampled)
Platform info:
Ubuntu 16.10
Node.js 7.1.0
Node.js 7.4.0
Intel(R) Core(TM) i7-5600U CPU
## License

View file

@ -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
Features
@ -63,7 +100,7 @@ Bugfixes
## 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.
All Errors returned by the parser are from now on of class ReplyError

View file

@ -2,3 +2,5 @@
module.exports = require('./lib/parser')
module.exports.ReplyError = require('./lib/replyError')
module.exports.RedisError = require('./lib/redisError')
module.exports.ParserError = require('./lib/redisError')

View file

@ -1 +0,0 @@
v8-version,5,4,500,36,0

View file

@ -1 +0,0 @@
v8-version,5,4,500,36,0

View file

@ -2,20 +2,21 @@
var hiredis = require('hiredis')
var ReplyError = require('../lib/replyError')
var ParserError = require('../lib/parserError')
/**
* Parse data
* @param parser
* @returns {*}
*/
function parseData (parser) {
function parseData (parser, data) {
try {
return parser.reader.get()
} catch (err) {
// Protocol errors land here
// Reset the parser. Otherwise new commands can't be processed properly
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) {
this.reader.feed(data)
var reply = parseData(this)
var reply = parseData(this, data)
while (reply !== undefined) {
if (reply && reply.name === 'Error') {
@ -45,8 +46,17 @@ HiredisReplyParser.prototype.execute = function (data) {
} else {
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

View file

@ -3,11 +3,23 @@
var StringDecoder = require('string_decoder').StringDecoder
var decoder = new StringDecoder()
var ReplyError = require('./replyError')
var bufferPool = new Buffer(32 * 1024)
var ParserError = require('./parserError')
var bufferPool = bufferAlloc(32 * 1024)
var bufferOffset = 0
var interval = null
var counter = 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
@ -100,7 +112,7 @@ function convertBufferRange (parser, start, end) {
* @param parser
* @returns {*}
*/
function parseSimpleStringViaOffset (parser) {
function parseSimpleString (parser) {
var start = parser.offset
var offset = start
var buffer = parser.buffer
@ -173,7 +185,7 @@ function parseBulkString (parser) {
* @returns {Error}
*/
function parseError (parser) {
var string = parseSimpleStringViaOffset(parser)
var string = parseSimpleString(parser)
if (string !== undefined) {
if (parser.optionReturnBuffers === true) {
string = string.toString()
@ -209,13 +221,36 @@ function parseArray (parser) {
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
* @param parser
* @returns {*}
*/
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) {
var offset = parser.offset
if (parser.offset >= bufferLength) {
parser.arrayCache = responses
parser.arrayPos = i
parser.offset = offset
pushArrayCache(parser, responses, i)
return
}
var response = parseType(parser, parser.buffer[parser.offset++])
if (response === undefined) {
parser.arrayCache = responses
parser.arrayPos = i
parser.offset = offset
if (!parser.arrayCache.length) {
parser.offset = offset
}
pushArrayCache(parser, responses, i)
return
}
responses[i] = response
@ -262,16 +296,17 @@ function parseType (parser, type) {
case 58: // :
return parseInteger(parser)
case 43: // +
return parseSimpleStringViaOffset(parser)
return parseSimpleString(parser)
case 42: // *
return parseArray(parser)
case 45: // -
return parseError(parser)
default:
var err = new ReplyError('Protocol error, got ' + JSON.stringify(String.fromCharCode(type)) + ' as reply type byte', 20)
err.offset = parser.offset
err.buffer = JSON.stringify(parser.buffer)
return handleError(parser, err)
return handleError(parser, new ParserError(
'Protocol error, got ' + JSON.stringify(String.fromCharCode(type)) + ' as reply type byte',
JSON.stringify(parser.buffer),
parser.offset
))
}
}
@ -298,8 +333,9 @@ function JavascriptRedisParser (options) {
throw new TypeError('Please provide all return functions while initiating the parser')
}
for (var key in options) {
// eslint-disable-next-line valid-typeof
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') {
@ -318,44 +354,49 @@ function JavascriptRedisParser (options) {
this.returnFatalError = options.returnFatalError || options.returnError
this.returnReply = options.returnReply
this.name = 'javascript'
this.reset()
}
/**
* Reset the parser values to the initial state
*
* @returns {undefined}
*/
JavascriptRedisParser.prototype.reset = function () {
this.offset = 0
this.buffer = null
this.bigStrSize = 0
this.bigOffset = 0
this.totalChunkSize = 0
this.bufferCache = []
this.arrayCache = null
this.arrayPos = 0
this.arrayCache = []
this.arrayPos = []
}
/**
* Concat a bulk string containing multiple chunks
* Set the returnBuffers option
*
* 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
* @param buffer
* @returns {String}
* @param returnBuffers
* @returns {undefined}
*/
function concatBulkString (parser) {
var list = parser.bufferCache
var chunks = list.length
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--
JavascriptRedisParser.prototype.setReturnBuffers = function (returnBuffers) {
if (typeof returnBuffers !== 'boolean') {
throw new TypeError('The returnBuffers argument has to be a boolean')
}
var res = decoder.write(list[0].slice(parser.bigOffset))
for (var i = 1; i < chunks - 1; i++) {
res += decoder.write(list[i])
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')
}
res += decoder.end(list[i].slice(0, offset - 2))
return res
this.optionStringNumbers = stringNumbers
}
/**
@ -387,38 +428,89 @@ function decreaseBufferPool () {
}
/**
* Concat the collected chunks from parser.bufferCache
* @param parser
* Check if the requested size fits in the current bufferPool.
* If it does not, reset and increase the bufferPool accordingly.
*
* @param length
* @returns {Buffer}
* @returns {undefined}
*/
function concatBuffer (parser, length) {
var list = parser.bufferCache
var pos = bufferOffset
length -= parser.offset
function resizeBuffer (length) {
if (bufferPool.length < length + bufferOffset) {
// Increase the bufferPool size
var multiplier = length > 1024 * 1024 * 75 ? 2 : 3
if (bufferOffset > 1024 * 1024 * 120) {
if (bufferOffset > 1024 * 1024 * 111) {
bufferOffset = 1024 * 1024 * 50
}
bufferPool = new Buffer(length * multiplier + bufferOffset)
bufferPool = bufferAlloc(length * multiplier + bufferOffset)
bufferOffset = 0
counter++
pos = 0
if (interval === null) {
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)
pos += list[i].length
}
/**
* Concat a bulk string containing multiple chunks
*
* 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)
}
chunks--
offset = list[list.length - 2].length + offset
}
var buffer = bufferPool.slice(bufferOffset, length + bufferOffset)
bufferOffset += length
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}
*/
JavascriptRedisParser.prototype.execute = function execute (buffer) {
var arr
if (this.buffer === null) {
this.buffer = buffer
this.offset = 0
} else if (this.bigStrSize === 0) {
var oldLength = this.buffer.length
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)
buffer.copy(newBuffer, remainingLength, 0, buffer.length)
this.buffer = newBuffer
this.offset = 0
if (this.arrayCache) {
arr = parseArrayChunks(this)
if (this.arrayCache.length) {
var arr = parseArrayChunks(this)
if (!arr) {
return
}
this.returnReply(arr)
this.arrayCache = null
}
} else if (this.totalChunkSize + buffer.length >= this.bigStrSize) {
this.bufferCache.push(buffer)
if (this.optionReturnBuffers === false && !this.arrayCache) {
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.bufferCache = []
return
}
this.returnReply(arr)
this.arrayCache = null
}
}
var tmp = this.optionReturnBuffers ? concatBulkBuffer(this) : concatBulkString(this)
this.bigStrSize = 0
this.bufferCache = []
this.buffer = buffer
if (this.arrayCache.length) {
this.arrayCache[0][this.arrayPos[0]++] = tmp
tmp = parseArrayChunks(this)
if (!tmp) {
return
}
}
this.returnReply(tmp)
} else {
this.bufferCache.push(buffer)
this.totalChunkSize += buffer.length
@ -479,7 +562,7 @@ JavascriptRedisParser.prototype.execute = function execute (buffer) {
var type = this.buffer[this.offset++]
var response = parseType(this, type)
if (response === undefined) {
if (!this.arrayCache) {
if (!this.arrayCache.length) {
this.offset = offset
}
return

25
node/node_modules/redis-parser/lib/parserError.js generated vendored Normal file
View 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
View 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

View file

@ -1,23 +1,22 @@
'use strict'
var util = require('util')
var RedisError = require('./redisError')
var ADD_STACKTRACE = false
function ReplyError (message, newLimit) {
var limit = Error.stackTraceLimit
Error.stackTraceLimit = newLimit || 2
Error.call(this, message)
Error.captureStackTrace(this, this.constructor)
Error.stackTraceLimit = limit
Object.defineProperty(this, 'message', {
value: message || '',
writable: true
})
function ReplyError (message) {
var tmp = Error.stackTraceLimit
Error.stackTraceLimit = 2
RedisError.call(this, message, ADD_STACKTRACE)
Error.captureStackTrace(this, ReplyError)
Error.stackTraceLimit = tmp
}
util.inherits(ReplyError, Error)
util.inherits(ReplyError, RedisError)
Object.defineProperty(ReplyError.prototype, 'name', {
value: 'ReplyError',
configurable: true,
writable: true
})

View file

@ -1,49 +1,26 @@
{
"_args": [
[
{
"raw": "redis-parser@^2.0.0",
"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,
"_from": "redis-parser@^2.6.0",
"_id": "redis-parser@2.6.0",
"_inBundle": false,
"_integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=",
"_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": {},
"_requested": {
"raw": "redis-parser@^2.0.0",
"scope": null,
"escapedName": "redis-parser",
"type": "range",
"registry": true,
"raw": "redis-parser@^2.6.0",
"name": "redis-parser",
"rawSpec": "^2.0.0",
"spec": ">=2.0.0 <3.0.0",
"type": "range"
"escapedName": "redis-parser",
"rawSpec": "^2.6.0",
"saveSpec": null,
"fetchSpec": "^2.6.0"
},
"_requiredBy": [
"/redis"
],
"_resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.3.0.tgz",
"_shasum": "313a47965e49ee35ab3a86c93388b403d76237f6",
"_shrinkwrap": null,
"_spec": "redis-parser@^2.0.0",
"_resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz",
"_shasum": "52ed09dacac108f1a631c07e9b69941e7a19504b",
"_spec": "redis-parser@^2.6.0",
"_where": "/Users/sclay/projects/newsblur/node/node_modules/redis",
"author": {
"name": "Ruben Bridgewater"
@ -51,7 +28,8 @@
"bugs": {
"url": "https://github.com/NodeRedis/node-redis-parser/issues"
},
"dependencies": {},
"bundleDependencies": false,
"deprecated": false,
"description": "Javascript Redis protocol (RESP) parser",
"devDependencies": {
"benchmark": "^2.1.0",
@ -60,20 +38,15 @@
"intercept-stdout": "^0.1.2",
"istanbul": "^0.4.0",
"mocha": "^3.1.2",
"standard": "^8.5.0"
"standard": "^9.0.0"
},
"directories": {
"test": "test",
"lib": "lib"
},
"dist": {
"shasum": "313a47965e49ee35ab3a86c93388b403d76237f6",
"tarball": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.3.0.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"gitHead": "26be8f841e43afd4d1453ae21b55df129f2aa271",
"homepage": "https://github.com/NodeRedis/node-redis-parser#readme",
"keywords": [
"redis",
@ -88,15 +61,7 @@
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "bridgear",
"email": "ruben@bridgewater.de"
}
],
"name": "redis-parser",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/NodeRedis/node-redis-parser.git"
@ -105,8 +70,9 @@
"benchmark": "node ./benchmark",
"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",
"posttest": "standard && npm run coverage:check",
"lint": "standard --fix",
"posttest": "npm run lint && npm run coverage:check",
"test": "npm run coverage"
},
"version": "2.3.0"
"version": "2.6.0"
}

397
node/node_modules/redis/README.md generated vendored
View file

@ -6,7 +6,8 @@ redis - a node.js redis client
[![Windows Tests](https://img.shields.io/appveyor/ci/BridgeAR/node-redis/master.svg?label=Windows%20Tests)](https://ci.appveyor.com/project/BridgeAR/node-redis/branch/master)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](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:
@ -48,13 +49,16 @@ This will display:
1: hashtest 2
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.
From v.2.6 on the API supports camelCase and 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.
Note that the API is entirely asynchronous. To get data back from the server,
you'll need to use a callback. From v.2.6 on the API supports camelCase and
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
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
var redis = require('redis');
@ -100,7 +104,8 @@ client.set("some 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
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)
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.
Please be aware that sending null, undefined and Boolean values will result in the value coerced to a string!
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. 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
@ -122,8 +143,9 @@ Please be aware that sending null, undefined and Boolean values will result in t
### "ready"
`client` will emit `ready` once a connection is established. Commands issued before the `ready` event are queued,
then replayed just before this event is emitted.
`client` will emit `ready` once a connection is established. Commands issued
before the `ready` event are queued, then replayed just before this event is
emitted.
### "connect"
@ -131,13 +153,16 @@ then replayed just before this event is emitted.
### "reconnecting"
`client` will emit `reconnecting` when trying to reconnect to the Redis server after losing the connection. Listeners
are passed an object containing `delay` (in ms) and `attempt` (the attempt #) attributes.
`client` will emit `reconnecting` when trying to reconnect to the Redis server
after losing the connection. Listeners are passed an object containing `delay`
(in ms) and `attempt` (the attempt #) attributes.
### "error"
`client` will emit `error` when encountering an error connecting to the Redis 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.
`client` will emit `error` when encountering an error connecting to the Redis
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.
@ -147,33 +172,41 @@ So please attach the error listener to node_redis.
### "drain" (deprecated)
`client` will emit `drain` when the TCP connection to the Redis server has been buffering, but is now
writable. This event can be used to stream commands in to Redis and adapt to backpressure.
`client` will emit `drain` when the TCP connection to the Redis server has been
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.
That way you can decide when to reduce your send rate and resume sending commands when you get `drain`.
If the stream is buffering `client.should_buffer` is set to true. Otherwise the
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).
If false is returned the stream had to buffer.
You can also check the return value of each command as it will also return the
backpressure indicator (deprecated). If false is returned the stream had to
buffer.
### "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)
`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()
If you have `redis-server` running on the same machine as node, then the 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:
If you have `redis-server` running on the same machine as node, then the
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(unix_socket[, options])`
* `redis.createClient(redis_url[, 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
| 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. |
| 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. |
| 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). |
| 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. |
@ -221,34 +254,38 @@ client.quit();
```
retry_strategy example
```js
var client = redis.createClient({
retry_strategy: function (options) {
if (options.error.code === 'ECONNREFUSED') {
// End reconnecting on a specific error and flush all commands with a individual error
if (options.error && options.error.code === 'ECONNREFUSED') {
// End reconnecting on a specific error and flush all commands with
// a individual error
return new Error('The server refused the connection');
}
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');
}
if (options.times_connected > 10) {
if (options.attempt > 10) {
// End reconnecting with built in error
return undefined;
}
// reconnect after
return Math.max(options.attempt * 100, 3000);
return Math.min(options.attempt * 100, 3000);
}
});
```
## client.auth(password[, callback])
When connecting to a Redis server that requires authentication, the `AUTH` command must be sent as the
first command after connecting. This can be tricky to coordinate with reconnections, the ready check,
etc. To make this easier, `client.auth()` stashes `password` and will send it after each connection,
including reconnections. `callback` is invoked only once, after the response to the very first
`AUTH` command sent.
When connecting to a Redis server that requires authentication, the `AUTH`
command must be sent as the first command after connecting. This can be tricky
to coordinate with reconnections, the ready check, etc. To make this easier,
`client.auth()` stashes `password` and will send it after each connection,
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
you are doing this wrong, `client` will emit an error that looks
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
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`.
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.
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`. 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()
This sends the quit command to the redis server and ends cleanly right after all running commands were properly handled.
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
resulting in further reconnections! All offline commands are going to be flushed with an error in that case.
This sends the quit command to the redis server and ends cleanly right after all
running commands were properly handled. If this is called while reconnecting
(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)
Forcibly close the connection to the Redis server. Note that this does not wait until all replies have been parsed.
If you want to exit cleanly, call `client.quit()` as mentioned above.
Forcibly close the connection to the Redis server. Note that this does not wait
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.
If you set flush to false all still running commands will silently fail.
You should set flush to true, if you are not absolutely sure you do not care
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
want to do this:
This example closes the connection to the Redis server before the replies have
been read. You probably don't want to do this:
```js
var redis = require("redis"),
@ -296,10 +342,19 @@ client.get("foo_rand000000000000", function (err, reply) {
## Error handling (>= v.2.6)
All redis errors are returned as `ReplyError`.
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.
They are all aggregated and a single error is emitted in that case.
Currently the following error subclasses exist:
* `RedisError`: _All errors_ returned by the client
* `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:
```js
@ -311,10 +366,11 @@ client.on('error', function (err) {
assert(err instanceof Error);
assert(err instanceof redis.AbortError);
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');
});
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.strictEqual(err.command, 'SET');
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.get('foo');
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;
});
});
@ -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`).
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___
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.
A `CONNECTION_BROKEN` error code is used in case node_redis gives up to reconnect.
node_redis returns a `NR_CLOSED` error code if the clients connection dropped.
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()
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
var redis = require("redis")
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.get("foo", function (err, value){
@ -361,13 +426,15 @@ client.get("foo", function (err, value){
## 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.
When dealing with hash values, there are a couple of useful exceptions to this.
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. When
dealing with hash values, there are a couple of useful exceptions to this.
### 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
with the responses using JavaScript syntax.
The reply from an HGETALL command will be converted into a JavaScript Object by
`node_redis`. That way you can interact with the responses using JavaScript
syntax.
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])
@ -435,11 +503,13 @@ sub.on("message", function (channel, message) {
sub.subscribe("a nice channel");
```
When a client issues a `SUBSCRIBE` or `PSUBSCRIBE`, that connection is put into a "subscriber" mode.
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
set is empty, the connection is put back into regular mode.
When a client issues a `SUBSCRIBE` or `PSUBSCRIBE`, that connection is put into
a "subscriber" mode. 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 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
@ -452,47 +522,57 @@ Listeners are passed the channel name as `channel` and the message as `message`.
### "pmessage" (pattern, channel, message)
Client will emit `pmessage` for every message received that matches an active subscription pattern.
Listeners are passed the original pattern used with `PSUBSCRIBE` as `pattern`, the sending channel
name as `channel`, and the message as `message`.
Client will emit `pmessage` for every message received that matches an active
subscription pattern. Listeners are passed the original pattern used with
`PSUBSCRIBE` as `pattern`, the sending channel name as `channel`, and the
message as `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.
If you listen to the `message` event at the same time as the `message_buffer`, it is always going to emit a string.
This is the same as the `message` event with the exception, that it is always
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)
This is the same as the `pmessage` event with the exception, that it is always 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.
This is the same as the `pmessage` event with the exception, that it is always
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)
Client will emit `subscribe` in response to a `SUBSCRIBE` command. Listeners are passed the
channel name as `channel` and the new count of subscriptions for this client as `count`.
Client will emit `subscribe` in response to a `SUBSCRIBE` command. Listeners are
passed the channel name as `channel` and the new count of subscriptions for this
client as `count`.
### "psubscribe" (pattern, count)
Client will emit `psubscribe` in response to a `PSUBSCRIBE` command. Listeners are passed the
original pattern as `pattern`, and the new count of subscriptions for this client as `count`.
Client will emit `psubscribe` in response to a `PSUBSCRIBE` command. Listeners
are passed the original pattern as `pattern`, and the new count of subscriptions
for this client as `count`.
### "unsubscribe" (channel, count)
Client will emit `unsubscribe` in response to a `UNSUBSCRIBE` command. Listeners are passed the
channel name as `channel` and the new count of 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 will emit `unsubscribe` in response to a `UNSUBSCRIBE` command. Listeners
are passed the channel name as `channel` and the new count of subscriptions for
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)
Client will emit `punsubscribe` in response to a `PUNSUBSCRIBE` command. Listeners are passed the
channel name as `channel` and the new count of 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 will emit `punsubscribe` in response to a `PUNSUBSCRIBE` command.
Listeners are passed the channel name as `channel` and the new count of
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])
`MULTI` commands are queued up until an `EXEC` is issued, and then all commands are run atomically by
Redis. The interface in `node_redis` is to return an 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)).
`MULTI` commands are queued up until an `EXEC` is issued, and then all commands
are run atomically by Redis. The interface in `node_redis` is to return an
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
var redis = require("./index"),
@ -526,15 +606,20 @@ client.multi()
### Multi.exec([callback])
`client.multi()` is a constructor that returns a `Multi` object. `Multi` objects share all of the
same command methods as `client` objects do. Commands are queued up inside the `Multi` object
until `Multi.exec()` is invoked.
`client.multi()` is a constructor that returns a `Multi` object. `Multi` objects
share all of the same command methods as `client` objects do. Commands are
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 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.
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 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
commands while still sending regular client command as in this example:
You can either chain together `MULTI` commands as in the above example, or you
can queue individual commands while still sending regular client command as in
this example:
```js
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
of commands and arguments to the constructor:
In addition to adding commands to the `MULTI` queue individually, you can also
pass an array of commands and arguments to the constructor:
```js
var redis = require("redis"),
@ -572,26 +657,36 @@ client.multi([
### 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])
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
Redis. The interface in `node_redis` is to return an individual `Batch` object by calling `client.batch()`.
The only difference 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.
`BATCH` commands are queued up until an `EXEC` is issued, and then all commands
are run atomically by Redis. The interface in `node_redis` is to return an
individual `Batch` object by calling `client.batch()`. The only difference
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
Redis supports the `MONITOR` command, which lets you see all commands received by the Redis server
across all client connections, including from other client libraries and other computers.
Redis supports the `MONITOR` command, which lets you see all commands received
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.
The callback for the `monitor` event takes a timestamp from the Redis server, an array of command arguments and the raw monitoring string.
A `monitor` event is going to be emitted for every command fired from any client
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:
@ -613,10 +708,11 @@ Some other things you might like to know about.
## client.server_info
After the ready probe completes, the results from the INFO command are saved in the `client.server_info`
object.
After the ready probe completes, the results from the INFO command are saved in
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
'2.3.0'
@ -655,12 +751,15 @@ the second word as first parameter:
## 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.
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.
Duplicate all current options and return a new redisClient instance. All options
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
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.
var Redis=require('redis');
@ -681,17 +780,25 @@ non-blocking ones may be queued up until after the blocking ones finish.
};
get();
brpop();
Another reason to use duplicate() is when multiple DBs on the same server are
Another reason to use duplicate() is when multiple DBs on the same server are
accessed via the redis SELECT command. Each DB could use its own connection.
## 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,
you can use `send_command()` to send arbitrary commands to Redis.
The command_name has to be lower case.
All Redis commands have been added to the `client` object. However, if new
commands are introduced before this library is updated or if you want to add
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
@ -699,19 +806,23 @@ Boolean tracking the state of the connection to the Redis server.
## 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
enforce some kind of maximum queue depth for commands while connected.
The number of commands that have been sent to the Redis server but not yet
replied to. You can use this to enforce some kind of maximum queue depth for
commands while connected.
## client.offline_queue_length
The number of commands that have been queued up for a future connection. You can use this to enforce
some kind of maximum queue depth for pre-connection commands.
The number of commands that have been queued up for a future connection. You can
use this to enforce some kind of maximum queue depth for pre-connection
commands.
### 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:
```js
var args = [ 'myzset', 1, 'one', 2, 'two', 3, 'three', 99, 'ninety-nine' ];
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`.
This is also going to result in good stack traces opposed to useless ones 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`).
This is also going to result in good stack traces opposed to useless ones
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___:
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)
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
@ -831,10 +946,20 @@ Many [others](https://github.com/NodeRedis/node_redis/graphs/contributors) contr
### 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.

66
node/node_modules/redis/changelog.md generated vendored
View file

@ -1,24 +1,66 @@
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
Bugfixes
- Do not change the tls setting to camel_case
- Fix domain handling in combination with the offline queue (2.5.3 regression)
- Do not change the tls setting to camel_case
- Fix domain handling in combination with the offline queue (2.5.3 regression)
## v.2.6.2 - 16 Jun, 2016
Bugfixes
- Fixed individual callbacks of a transaction not being called (2.6.0 regression)
- Fixed individual callbacks of a transaction not being called (2.6.0 regression)
## v.2.6.1 - 02 Jun, 2016
Bugfixes
- Fixed invalid function name being exported
- Fixed invalid function name being exported
## v.2.6.0 - 01 Jun, 2016
@ -100,7 +142,7 @@ Features
- 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
- 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
- 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
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.
@ -163,7 +205,7 @@ Features
- 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
- 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 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))
@ -178,9 +220,9 @@ Bugfixes
- 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
- 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 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 rename_commands and prefix option not working together
- 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 .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
- 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
- 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

38
node/node_modules/redis/index.js generated vendored
View file

@ -120,7 +120,7 @@ function RedisClient (options, stream) {
if ('max_attempts' in options) {
self.warn(
'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.'
);
}
@ -156,8 +156,6 @@ function RedisClient (options, stream) {
this.buffers = options.return_buffers || options.detect_buffers;
this.options = options;
this.reply = 'ON'; // Returning replies is the default
// Init parser
this.reply_parser = create_parser(this);
this.create_stream();
// 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) {
@ -171,10 +169,16 @@ function RedisClient (options, stream) {
'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.'
);
} 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.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 () {
var self = this;
// Init parser
this.reply_parser = create_parser(this);
if (this.options.stream) {
// Only add the listeners once in case of a reconnect try (that won't work)
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
if (this.auth_pass !== undefined) {
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;
}
};
@ -791,9 +803,6 @@ function return_pub_sub (self, 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) {
var replyStr;
if (this.buffers && Buffer.isBuffer(reply)) {
@ -801,8 +810,7 @@ RedisClient.prototype.return_reply = function (reply) {
} else {
replyStr = reply;
}
// While reconnecting the redis server does not recognize the client as in monitor mode anymore
// Therefore the monitor command has to finish before it catches further commands
// If in monitor mode, all normal commands are still working and we only want to emit the streamlined commands
if (typeof replyStr === 'string' && utils.monitor_regex.test(replyStr)) {
var timestamp = replyStr.slice(0, replyStr.indexOf(' '));
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];
}
}
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];
}
// 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.Multi = require('./lib/multi');
exports.AbortError = errorClasses.AbortError;
exports.RedisError = Parser.RedisError;
exports.ParserError = Parser.ParserError;
exports.ReplyError = Parser.ReplyError;
exports.AggregateError = errorClasses.AggregateError;
// Add all redis commands / node_redis api to the client
require('./lib/individualCommands');
require('./lib/extendedApi');
require('./lib/commands');
//enables adding new commands (for modules and new commands)
exports.addCommand = exports.add_command = require('./lib/commands');

View file

@ -17,11 +17,7 @@ var changeFunctionName = (function () {
}
}());
// TODO: Rewrite this including the invidual commands into a Commands class
// that provided a functionality to add new commands to the client
commands.list.forEach(function (command) {
var addCommand = function (command) {
// Some rare Redis commands use special characters in their command name
// Convert those to a underscore to prevent using invalid function names
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));
};
// 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) {
Object.defineProperty(RedisClient.prototype[command], 'name', {
value: commandName
@ -104,10 +104,18 @@ commands.list.forEach(function (command) {
this.queue.push(new Command(command, arr, callback));
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) {
Object.defineProperty(Multi.prototype[command], 'name', {
value: commandName
});
}
}
});
};
commands.list.forEach(addCommand);
module.exports = addCommand;

View file

@ -23,7 +23,8 @@ module.exports = function createClient (port_arg, host_arg, options) {
} else if (typeof port_arg === 'string' || port_arg && port_arg.url) {
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]]]
if (parsed.slashes) { // We require slashes
@ -59,7 +60,7 @@ module.exports = function createClient (port_arg, host_arg, options) {
} else if (parsed.hostname) {
throw new RangeError('The redis url must begin with slashes "//" or contain slashes after the redis protocol');
} else {
options.path = port_arg;
options.path = url;
}
} else if (typeof port_arg === 'object' || port_arg === undefined) {

View file

@ -1,42 +1,55 @@
'use strict';
var util = require('util');
var assert = require('assert');
var RedisError = require('redis-parser').RedisError;
var ADD_STACKTRACE = false;
function AbortError (obj) {
Error.captureStackTrace(this, this.constructor);
function AbortError (obj, stack) {
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', {
value: obj.message || '',
configurable: true,
writable: true
});
if (stack || stack === undefined) {
Error.captureStackTrace(this, AbortError);
}
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
this[key] = obj[key];
}
}
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', {
value: obj.message || '',
configurable: true,
writable: true
});
Error.captureStackTrace(this, AggregateError);
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
this[key] = obj[key];
}
}
util.inherits(AbortError, Error);
util.inherits(AbortError, RedisError);
util.inherits(AggregateError, AbortError);
Object.defineProperty(AbortError.prototype, 'name', {
value: 'AbortError',
// configurable: true,
configurable: true,
writable: true
});
Object.defineProperty(AggregateError.prototype, 'name', {
value: 'AggregateError',
// configurable: true,
configurable: true,
writable: true
});

View file

@ -16,6 +16,7 @@ RedisClient.prototype.send_command = RedisClient.prototype.sendCommand = functio
if (typeof command !== 'string') {
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 (args === undefined || args === null) {
args = [];
@ -32,9 +33,9 @@ RedisClient.prototype.send_command = RedisClient.prototype.sendCommand = functio
// 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
// 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
// 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
if (command === 'multi' || typeof this[command] !== 'function') {
return this.internal_send_command(new Command(command, args, callback));

View file

@ -398,7 +398,7 @@ RedisClient.prototype.subscribe = RedisClient.prototype.SUBSCRIBE = function sub
callback,
i = 0;
if (Array.isArray(arguments[0])) {
arr = arguments[0];
arr = arguments[0].slice(0);
callback = arguments[1];
} else {
len = arguments.length;
@ -425,7 +425,7 @@ Multi.prototype.subscribe = Multi.prototype.SUBSCRIBE = function subscribe () {
callback,
i = 0;
if (Array.isArray(arguments[0])) {
arr = arguments[0];
arr = arguments[0].slice(0);
callback = arguments[1];
} else {
len = arguments.length;
@ -453,7 +453,7 @@ RedisClient.prototype.unsubscribe = RedisClient.prototype.UNSUBSCRIBE = function
callback,
i = 0;
if (Array.isArray(arguments[0])) {
arr = arguments[0];
arr = arguments[0].slice(0);
callback = arguments[1];
} else {
len = arguments.length;
@ -481,7 +481,7 @@ Multi.prototype.unsubscribe = Multi.prototype.UNSUBSCRIBE = function unsubscribe
callback,
i = 0;
if (Array.isArray(arguments[0])) {
arr = arguments[0];
arr = arguments[0].slice(0);
callback = arguments[1];
} else {
len = arguments.length;
@ -510,7 +510,7 @@ RedisClient.prototype.psubscribe = RedisClient.prototype.PSUBSCRIBE = function p
callback,
i = 0;
if (Array.isArray(arguments[0])) {
arr = arguments[0];
arr = arguments[0].slice(0);
callback = arguments[1];
} else {
len = arguments.length;
@ -537,7 +537,7 @@ Multi.prototype.psubscribe = Multi.prototype.PSUBSCRIBE = function psubscribe ()
callback,
i = 0;
if (Array.isArray(arguments[0])) {
arr = arguments[0];
arr = arguments[0].slice(0);
callback = arguments[1];
} else {
len = arguments.length;
@ -565,7 +565,7 @@ RedisClient.prototype.punsubscribe = RedisClient.prototype.PUNSUBSCRIBE = functi
callback,
i = 0;
if (Array.isArray(arguments[0])) {
arr = arguments[0];
arr = arguments[0].slice(0);
callback = arguments[1];
} else {
len = arguments.length;
@ -593,7 +593,7 @@ Multi.prototype.punsubscribe = Multi.prototype.PUNSUBSCRIBE = function punsubscr
callback,
i = 0;
if (Array.isArray(arguments[0])) {
arr = arguments[0];
arr = arguments[0].slice(0);
callback = arguments[1];
} else {
len = arguments.length;

View file

@ -127,7 +127,7 @@ module.exports = {
reply_to_object: replyToObject,
print: print,
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,
callback_or_emit: callbackOrEmit,
reply_in_order: replyInOrder

93
node/node_modules/redis/package.json generated vendored
View file

@ -1,49 +1,27 @@
{
"_args": [
[
{
"raw": "redis@2.6.3",
"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,
"_from": "redis@2.8.0",
"_id": "redis@2.8.0",
"_inBundle": false,
"_integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==",
"_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": {},
"_requested": {
"raw": "redis@2.6.3",
"scope": null,
"escapedName": "redis",
"type": "version",
"registry": true,
"raw": "redis@2.8.0",
"name": "redis",
"rawSpec": "2.6.3",
"spec": "2.6.3",
"type": "version"
"escapedName": "redis",
"rawSpec": "2.8.0",
"saveSpec": null,
"fetchSpec": "2.8.0"
},
"_requiredBy": [
"#USER"
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/redis/-/redis-2.6.3.tgz",
"_shasum": "84305b92553c6a1f09c7c47c30b11ace7dbb7ad4",
"_shrinkwrap": null,
"_spec": "redis@2.6.3",
"_resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz",
"_shasum": "202288e3f58c49f6079d97af7a10e1303ae14b02",
"_spec": "redis@2.8.0",
"_where": "/Users/sclay/projects/newsblur/node",
"author": {
"name": "Matt Ranney",
@ -52,20 +30,22 @@
"bugs": {
"url": "https://github.com/NodeRedis/node_redis/issues"
},
"bundleDependencies": false,
"dependencies": {
"double-ended-queue": "^2.1.0-0",
"redis-commands": "^1.2.0",
"redis-parser": "^2.0.0"
"redis-parser": "^2.6.0"
},
"deprecated": false,
"description": "Redis client library",
"devDependencies": {
"bluebird": "^3.0.2",
"coveralls": "^2.11.2",
"eslint": "^2.5.0",
"eslint": "^4.2.0",
"intercept-stdout": "~0.1.2",
"metrics": "^0.1.9",
"mocha": "^2.3.2",
"nyc": "^8.3.0",
"mocha": "^3.1.2",
"nyc": "^10.0.0",
"tcp-port-used": "^0.1.2",
"uuid": "^2.0.1",
"win-spawn": "^2.0.0"
@ -74,14 +54,9 @@
"example": "examples",
"test": "test"
},
"dist": {
"shasum": "84305b92553c6a1f09c7c47c30b11ace7dbb7ad4",
"tarball": "https://registry.npmjs.org/redis/-/redis-2.6.3.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"gitHead": "be07c12fbd039b7b3b1cb5a71f06e24464bc0593",
"homepage": "https://github.com/NodeRedis/node_redis",
"keywords": [
"database",
@ -96,27 +71,7 @@
],
"license": "MIT",
"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",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "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",
"coverage": "nyc report --reporter=html",
"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"
},
"version": "2.6.3"
"version": "2.8.0"
}

View file

@ -16,14 +16,18 @@ else
app.get /\/rss_feeds\/original_text_fetcher\/?/, (req, res) =>
res.setHeader 'Content-Type', 'application/json'
if req.query.test
return res.end "OK"
url = req.query.url
if !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'
if not DEV and (!api_key or api_key.indexOf "djtXZrSIEfDa3Dex9FQ9AR" == -1)
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) =>
log.debug "Fetched: #{url}"

View file

@ -27,17 +27,20 @@
return function(req, res) {
var api_key, url;
res.setHeader('Content-Type', 'application/json');
if (req.query.test) {
return res.end("OK");
}
url = req.query.url;
if (!url) {
log.debug("Missing url");
res.end(JSON.stringify({
return res.end(JSON.stringify({
error: "Missing `url` query parameter."
}));
}
api_key = req.header('x-api-key');
if (!DEV && (!api_key || api_key.indexOf("djtXZrSIEfDa3Dex9FQ9AR" === -1))) {
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."
}));
}

26
node/package-lock.json generated
View file

@ -1661,9 +1661,9 @@
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"qs": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz",
"integrity": "sha1-9AOyZPI7wBIox0ExtAfxjV6l1EI="
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
},
"querystring": {
"version": "0.2.0",
@ -1700,24 +1700,24 @@
}
},
"redis": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/redis/-/redis-2.6.3.tgz",
"integrity": "sha1-hDBbklU8ah8Jx8R8MLEazn27etQ=",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz",
"integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==",
"requires": {
"double-ended-queue": "^2.1.0-0",
"redis-commands": "^1.2.0",
"redis-parser": "^2.0.0"
"redis-parser": "^2.6.0"
}
},
"redis-commands": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.0.tgz",
"integrity": "sha1-QwfYCUruExWCmrZymze5n2I2XWM="
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.4.0.tgz",
"integrity": "sha512-cu8EF+MtkwI4DLIT0x9P8qNTLFhQD4jLfxLR0cCNkeGzs87FN6879JOJwNQR/1zD7aSYNbU0hgsV9zGY71Itvw=="
},
"redis-parser": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.3.0.tgz",
"integrity": "sha1-MTpHll5J7jWrOobJM4i0A9diN/Y="
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz",
"integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs="
},
"regenerator-runtime": {
"version": "0.13.2",

View file

@ -9,8 +9,8 @@
"express": "^4.16.4",
"mkdirp": "^0.5.1",
"mongodb": "^2.2.36",
"qs": "^6.3.0",
"redis": "^2.6.3",
"qs": "^6.7.0",
"redis": "^2.8.0",
"socket.io": "^2.2.0",
"socket.io-client": "^2.2.0",
"supervisor": "^0.12.0"