redis 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/heroku/index.js +14 -0
- package/heroku/node_modules/.package-lock.json +57 -0
- package/heroku/node_modules/denque/CHANGELOG.md +4 -0
- package/heroku/node_modules/denque/LICENSE +13 -0
- package/heroku/node_modules/denque/README.md +362 -0
- package/heroku/node_modules/denque/index.d.ts +31 -0
- package/heroku/node_modules/denque/index.js +443 -0
- package/heroku/node_modules/denque/package.json +55 -0
- package/heroku/node_modules/redis/.deepsource.toml +9 -0
- package/heroku/node_modules/redis/CHANGELOG.md +880 -0
- package/heroku/node_modules/redis/LICENSE +24 -0
- package/heroku/node_modules/redis/README.md +1009 -0
- package/{a.js → heroku/node_modules/redis/a.js} +0 -0
- package/heroku/node_modules/redis/index.js +1039 -0
- package/heroku/node_modules/redis/lib/command.js +16 -0
- package/heroku/node_modules/redis/lib/commands.js +105 -0
- package/heroku/node_modules/redis/lib/createClient.js +88 -0
- package/heroku/node_modules/redis/lib/customErrors.js +58 -0
- package/heroku/node_modules/redis/lib/debug.js +13 -0
- package/heroku/node_modules/redis/lib/extendedApi.js +113 -0
- package/heroku/node_modules/redis/lib/individualCommands.js +629 -0
- package/heroku/node_modules/redis/lib/multi.js +187 -0
- package/heroku/node_modules/redis/lib/utils.js +134 -0
- package/{npm → heroku/node_modules/redis/npm} +0 -0
- package/heroku/node_modules/redis/package.json +77 -0
- package/heroku/node_modules/redis-commands/LICENSE +22 -0
- package/heroku/node_modules/redis-commands/README.md +51 -0
- package/heroku/node_modules/redis-commands/changelog.md +83 -0
- package/heroku/node_modules/redis-commands/commands.json +2334 -0
- package/heroku/node_modules/redis-commands/index.js +168 -0
- package/heroku/node_modules/redis-commands/package.json +41 -0
- package/heroku/node_modules/redis-commands/tools/build.js +62 -0
- package/heroku/node_modules/redis-errors/LICENSE +22 -0
- package/heroku/node_modules/redis-errors/README.md +116 -0
- package/heroku/node_modules/redis-errors/index.js +7 -0
- package/heroku/node_modules/redis-errors/lib/modern.js +59 -0
- package/heroku/node_modules/redis-errors/lib/old.js +119 -0
- package/heroku/node_modules/redis-errors/package.json +41 -0
- package/heroku/node_modules/redis-parser/LICENSE +22 -0
- package/heroku/node_modules/redis-parser/README.md +166 -0
- package/heroku/node_modules/redis-parser/changelog.md +156 -0
- package/heroku/node_modules/redis-parser/index.js +3 -0
- package/heroku/node_modules/redis-parser/lib/parser.js +552 -0
- package/heroku/node_modules/redis-parser/package.json +53 -0
- package/heroku/package.json +9 -0
- package/lib/utils.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
var commands = require('./commands.json')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Redis command list
|
|
7
|
+
*
|
|
8
|
+
* All commands are lowercased.
|
|
9
|
+
*
|
|
10
|
+
* @var {string[]}
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
exports.list = Object.keys(commands)
|
|
14
|
+
|
|
15
|
+
var flags = {}
|
|
16
|
+
exports.list.forEach(function (commandName) {
|
|
17
|
+
flags[commandName] = commands[commandName].flags.reduce(function (flags, flag) {
|
|
18
|
+
flags[flag] = true
|
|
19
|
+
return flags
|
|
20
|
+
}, {})
|
|
21
|
+
})
|
|
22
|
+
/**
|
|
23
|
+
* Check if the command exists
|
|
24
|
+
*
|
|
25
|
+
* @param {string} commandName - the command name
|
|
26
|
+
* @return {boolean} result
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
exports.exists = function (commandName) {
|
|
30
|
+
return Boolean(commands[commandName])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check if the command has the flag
|
|
35
|
+
*
|
|
36
|
+
* Some of possible flags: readonly, noscript, loading
|
|
37
|
+
* @param {string} commandName - the command name
|
|
38
|
+
* @param {string} flag - the flag to check
|
|
39
|
+
* @return {boolean} result
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
exports.hasFlag = function (commandName, flag) {
|
|
43
|
+
if (!flags[commandName]) {
|
|
44
|
+
throw new Error('Unknown command ' + commandName)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return Boolean(flags[commandName][flag])
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get indexes of keys in the command arguments
|
|
52
|
+
*
|
|
53
|
+
* @param {string} commandName - the command name
|
|
54
|
+
* @param {string[]} args - the arguments of the command
|
|
55
|
+
* @param {object} [options] - options
|
|
56
|
+
* @param {boolean} [options.parseExternalKey] - parse external keys
|
|
57
|
+
* @return {number[]} - the list of the index
|
|
58
|
+
* @public
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```javascript
|
|
62
|
+
* getKeyIndexes('set', ['key', 'value']) // [0]
|
|
63
|
+
* getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
exports.getKeyIndexes = function (commandName, args, options) {
|
|
67
|
+
var command = commands[commandName]
|
|
68
|
+
if (!command) {
|
|
69
|
+
throw new Error('Unknown command ' + commandName)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!Array.isArray(args)) {
|
|
73
|
+
throw new Error('Expect args to be an array')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var keys = []
|
|
77
|
+
var i, keyStart, keyStop, parseExternalKey
|
|
78
|
+
switch (commandName) {
|
|
79
|
+
case 'zunionstore':
|
|
80
|
+
case 'zinterstore':
|
|
81
|
+
keys.push(0)
|
|
82
|
+
// fall through
|
|
83
|
+
case 'eval':
|
|
84
|
+
case 'evalsha':
|
|
85
|
+
keyStop = Number(args[1]) + 2
|
|
86
|
+
for (i = 2; i < keyStop; i++) {
|
|
87
|
+
keys.push(i)
|
|
88
|
+
}
|
|
89
|
+
break
|
|
90
|
+
case 'sort':
|
|
91
|
+
parseExternalKey = options && options.parseExternalKey
|
|
92
|
+
keys.push(0)
|
|
93
|
+
for (i = 1; i < args.length - 1; i++) {
|
|
94
|
+
if (typeof args[i] !== 'string') {
|
|
95
|
+
continue
|
|
96
|
+
}
|
|
97
|
+
var directive = args[i].toUpperCase()
|
|
98
|
+
if (directive === 'GET') {
|
|
99
|
+
i += 1
|
|
100
|
+
if (args[i] !== '#') {
|
|
101
|
+
if (parseExternalKey) {
|
|
102
|
+
keys.push([i, getExternalKeyNameLength(args[i])])
|
|
103
|
+
} else {
|
|
104
|
+
keys.push(i)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} else if (directive === 'BY') {
|
|
108
|
+
i += 1
|
|
109
|
+
if (parseExternalKey) {
|
|
110
|
+
keys.push([i, getExternalKeyNameLength(args[i])])
|
|
111
|
+
} else {
|
|
112
|
+
keys.push(i)
|
|
113
|
+
}
|
|
114
|
+
} else if (directive === 'STORE') {
|
|
115
|
+
i += 1
|
|
116
|
+
keys.push(i)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
break
|
|
120
|
+
case 'migrate':
|
|
121
|
+
if (args[2] === '') {
|
|
122
|
+
for (i = 5; i < args.length - 1; i++) {
|
|
123
|
+
if (args[i].toUpperCase() === 'KEYS') {
|
|
124
|
+
for (var j = i + 1; j < args.length; j++) {
|
|
125
|
+
keys.push(j)
|
|
126
|
+
}
|
|
127
|
+
break
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
keys.push(2)
|
|
132
|
+
}
|
|
133
|
+
break
|
|
134
|
+
case 'xreadgroup':
|
|
135
|
+
case 'xread':
|
|
136
|
+
// Keys are 1st half of the args after STREAMS argument.
|
|
137
|
+
for (i = commandName === 'xread' ? 0 : 3; i < args.length - 1; i++) {
|
|
138
|
+
if (String(args[i]).toUpperCase() === 'STREAMS') {
|
|
139
|
+
for (j = i + 1; j <= i + ((args.length - 1 - i) / 2); j++) {
|
|
140
|
+
keys.push(j)
|
|
141
|
+
}
|
|
142
|
+
break
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
break
|
|
146
|
+
default:
|
|
147
|
+
// Step has to be at least one in this case, otherwise the command does
|
|
148
|
+
// not contain a key.
|
|
149
|
+
if (command.step > 0) {
|
|
150
|
+
keyStart = command.keyStart - 1
|
|
151
|
+
keyStop = command.keyStop > 0 ? command.keyStop : args.length + command.keyStop + 1
|
|
152
|
+
for (i = keyStart; i < keyStop; i += command.step) {
|
|
153
|
+
keys.push(i)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
break
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return keys
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function getExternalKeyNameLength (key) {
|
|
163
|
+
if (typeof key !== 'string') {
|
|
164
|
+
key = String(key)
|
|
165
|
+
}
|
|
166
|
+
var hashPos = key.indexOf('->')
|
|
167
|
+
return hashPos === -1 ? key.length : hashPos
|
|
168
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "redis-commands",
|
|
3
|
+
"version": "1.7.0",
|
|
4
|
+
"description": "Redis commands",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"pretest": "npm run lint",
|
|
8
|
+
"test": "mocha",
|
|
9
|
+
"posttest": "npm run coverage && npm run coverage:check",
|
|
10
|
+
"coverage": "node ./node_modules/istanbul/lib/cli.js cover --preserve-comments ./node_modules/mocha/bin/_mocha -- -R spec",
|
|
11
|
+
"coverage:check": "node ./node_modules/istanbul/lib/cli.js check-coverage --branch 100 --statement 100",
|
|
12
|
+
"build": "node tools/build",
|
|
13
|
+
"lint": "standard --fix --verbose | snazzy"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/NodeRedis/redis-commands.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"redis",
|
|
21
|
+
"commands",
|
|
22
|
+
"prefix"
|
|
23
|
+
],
|
|
24
|
+
"author": "luin <i@zihua.li> (http://zihua.li)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/NodeRedis/redis-commands/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/NodeRedis/redis-commands",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"chai": "^4.0.1",
|
|
32
|
+
"codeclimate-test-reporter": "^0.5.1",
|
|
33
|
+
"ioredis": "^4.9.0",
|
|
34
|
+
"istanbul": "^0.4.3",
|
|
35
|
+
"safe-stable-stringify": "^1.0.0",
|
|
36
|
+
"mocha": "^6.0.0",
|
|
37
|
+
"snazzy": "^8.0.0",
|
|
38
|
+
"standard": "^12.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {}
|
|
41
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var fs = require('fs')
|
|
2
|
+
var path = require('path')
|
|
3
|
+
var stringify = require('safe-stable-stringify')
|
|
4
|
+
var commandPath = path.join(__dirname, '..', 'commands.json')
|
|
5
|
+
var redisCommands = require('../')
|
|
6
|
+
|
|
7
|
+
var Redis = require('ioredis')
|
|
8
|
+
var redis = new Redis(process.env.REDIS_URI)
|
|
9
|
+
|
|
10
|
+
redis.command().then(function (res) {
|
|
11
|
+
redis.disconnect()
|
|
12
|
+
|
|
13
|
+
// Find all special handled cases
|
|
14
|
+
var movableKeys = String(redisCommands.getKeyIndexes).match(/case '[a-z-]+':/g).map(function (entry) {
|
|
15
|
+
return entry.replace(/^case '|':$/g, '')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
var commands = res.reduce(function (prev, current) {
|
|
19
|
+
var currentCommandPos = movableKeys.indexOf(current[0])
|
|
20
|
+
if (currentCommandPos !== -1 && current[2].indexOf('movablekeys') !== -1) {
|
|
21
|
+
movableKeys.splice(currentCommandPos, 1)
|
|
22
|
+
}
|
|
23
|
+
// https://github.com/antirez/redis/issues/2598
|
|
24
|
+
if (current[0] === 'brpop' && current[4] === 1) {
|
|
25
|
+
current[4] = -2
|
|
26
|
+
}
|
|
27
|
+
prev[current[0]] = {
|
|
28
|
+
arity: current[1] || 1, // https://github.com/antirez/redis/pull/2986
|
|
29
|
+
flags: current[2],
|
|
30
|
+
keyStart: current[3],
|
|
31
|
+
keyStop: current[4],
|
|
32
|
+
step: current[5]
|
|
33
|
+
}
|
|
34
|
+
return prev
|
|
35
|
+
}, {})
|
|
36
|
+
|
|
37
|
+
// Future proof. Redis might implement this at some point
|
|
38
|
+
// https://github.com/antirez/redis/pull/2982
|
|
39
|
+
if (!commands.quit) {
|
|
40
|
+
commands.quit = {
|
|
41
|
+
arity: 1,
|
|
42
|
+
flags: [
|
|
43
|
+
'loading',
|
|
44
|
+
'stale',
|
|
45
|
+
'readonly'
|
|
46
|
+
],
|
|
47
|
+
keyStart: 0,
|
|
48
|
+
keyStop: 0,
|
|
49
|
+
step: 0
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (movableKeys.length !== 0) {
|
|
54
|
+
throw new Error('Not all commands (\'' + movableKeys.join('\', \'') + '\') with the "movablekeys" flag are handled in the code')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Use safe-stable-stringify instead fo JSON.stringify
|
|
58
|
+
// for easier diffing
|
|
59
|
+
var content = stringify(commands, null, ' ')
|
|
60
|
+
|
|
61
|
+
fs.writeFileSync(commandPath, content)
|
|
62
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Ruben Bridgewater
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
[](http://standardjs.com/)
|
|
2
|
+
|
|
3
|
+
# redis-errors
|
|
4
|
+
|
|
5
|
+
All error classes used in [node_redis](https://github.com/NodeRedis/node_redis)
|
|
6
|
+
from v.3.0.0 are in here. They can be required as needed.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
Install with [NPM](https://npmjs.org/):
|
|
11
|
+
|
|
12
|
+
npm install redis-errors
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
const { ReplyError, InterruptError } = require('redis-errors');
|
|
18
|
+
|
|
19
|
+
// Using async await
|
|
20
|
+
try {
|
|
21
|
+
await client.set('foo') // Missing value
|
|
22
|
+
} catch (err) {
|
|
23
|
+
if (err instanceof InterruptError) {
|
|
24
|
+
console.error('Command might have been processed')
|
|
25
|
+
}
|
|
26
|
+
if (err instanceof ReplyError) {
|
|
27
|
+
// ...
|
|
28
|
+
}
|
|
29
|
+
throw err
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Using callbacks
|
|
33
|
+
client.set('foo', (err, res) => {
|
|
34
|
+
if (err) {
|
|
35
|
+
if (err instanceof InterruptError) {
|
|
36
|
+
// ...
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Error classes
|
|
43
|
+
|
|
44
|
+
All errors returned by NodeRedis use own Error classes. You can distinguish
|
|
45
|
+
different errors easily by checking for these classes.
|
|
46
|
+
|
|
47
|
+
To know what caused the error they might contain properties to know in more
|
|
48
|
+
detail what happened.
|
|
49
|
+
|
|
50
|
+
Each error contains a `message`, a `name` and a `stack` property. Please be aware
|
|
51
|
+
that the stack might not be useful due to the async nature and is in those cases
|
|
52
|
+
therefore limited to two frames.
|
|
53
|
+
|
|
54
|
+
There might be more not yet documented properties as well. Please feel free to
|
|
55
|
+
open a pull request to document those as well.
|
|
56
|
+
|
|
57
|
+
#### RedisError
|
|
58
|
+
|
|
59
|
+
`Properties`:
|
|
60
|
+
|
|
61
|
+
Properties depend on the individual error.
|
|
62
|
+
|
|
63
|
+
All errors returned by NodeRedis (client) are `RedisError`s.
|
|
64
|
+
Subclass of `Error`
|
|
65
|
+
|
|
66
|
+
#### ReplyError
|
|
67
|
+
|
|
68
|
+
`Properties`:
|
|
69
|
+
|
|
70
|
+
* `args`: The arguments passed to the command.
|
|
71
|
+
* `command`: The command name.
|
|
72
|
+
* `code`: The `Redis` error code. Redis itself uses some internal error codes.
|
|
73
|
+
|
|
74
|
+
All errors returned by Redis itself (server) will be a `ReplyError`.
|
|
75
|
+
Subclass of `RedisError`
|
|
76
|
+
|
|
77
|
+
#### ParserError
|
|
78
|
+
|
|
79
|
+
`Properties`:
|
|
80
|
+
|
|
81
|
+
* `buffer`: The raw buffer input stringified.
|
|
82
|
+
* `offset`: The character count where the parsing error occurred.
|
|
83
|
+
|
|
84
|
+
Parsing errors are returned as `ParserError`.
|
|
85
|
+
Subclass of `RedisError`
|
|
86
|
+
**Note:** If you encounter one of these please report that error including the
|
|
87
|
+
attached `offset` and `buffer` properties!
|
|
88
|
+
|
|
89
|
+
#### AbortError
|
|
90
|
+
|
|
91
|
+
`Properties`:
|
|
92
|
+
|
|
93
|
+
* `args`: The arguments passed to the command.
|
|
94
|
+
* `command`: The command name.
|
|
95
|
+
|
|
96
|
+
If a command was not yet executed but rejected, it'll return a `AbortError`.
|
|
97
|
+
Subclass of `RedisError`
|
|
98
|
+
|
|
99
|
+
#### InterruptError
|
|
100
|
+
|
|
101
|
+
`Properties`:
|
|
102
|
+
|
|
103
|
+
* `args`: The arguments passed to the command.
|
|
104
|
+
* `command`: The command name.
|
|
105
|
+
* `origin`: The original error that caused the interrupt
|
|
106
|
+
|
|
107
|
+
All executed commands that could not fulfill (e.g. network drop while
|
|
108
|
+
executing) return a `InterruptError`.
|
|
109
|
+
Subclass of `AbortError`
|
|
110
|
+
**Note:** Interrupt errors can happen for multiple reasons that are out of the
|
|
111
|
+
scope of NodeRedis itself. There is nothing that can be done on library side
|
|
112
|
+
to prevent those.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const assert = require('assert')
|
|
4
|
+
|
|
5
|
+
class RedisError extends Error {
|
|
6
|
+
get name () {
|
|
7
|
+
return this.constructor.name
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class ParserError extends RedisError {
|
|
12
|
+
constructor (message, buffer, offset) {
|
|
13
|
+
assert(buffer)
|
|
14
|
+
assert.strictEqual(typeof offset, 'number')
|
|
15
|
+
|
|
16
|
+
const tmp = Error.stackTraceLimit
|
|
17
|
+
Error.stackTraceLimit = 2
|
|
18
|
+
super(message)
|
|
19
|
+
Error.stackTraceLimit = tmp
|
|
20
|
+
this.offset = offset
|
|
21
|
+
this.buffer = buffer
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get name () {
|
|
25
|
+
return this.constructor.name
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class ReplyError extends RedisError {
|
|
30
|
+
constructor (message) {
|
|
31
|
+
const tmp = Error.stackTraceLimit
|
|
32
|
+
Error.stackTraceLimit = 2
|
|
33
|
+
super(message)
|
|
34
|
+
Error.stackTraceLimit = tmp
|
|
35
|
+
}
|
|
36
|
+
get name () {
|
|
37
|
+
return this.constructor.name
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class AbortError extends RedisError {
|
|
42
|
+
get name () {
|
|
43
|
+
return this.constructor.name
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class InterruptError extends AbortError {
|
|
48
|
+
get name () {
|
|
49
|
+
return this.constructor.name
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
RedisError,
|
|
55
|
+
ParserError,
|
|
56
|
+
ReplyError,
|
|
57
|
+
AbortError,
|
|
58
|
+
InterruptError
|
|
59
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const assert = require('assert')
|
|
4
|
+
const util = require('util')
|
|
5
|
+
|
|
6
|
+
// RedisError
|
|
7
|
+
|
|
8
|
+
function RedisError (message) {
|
|
9
|
+
Object.defineProperty(this, 'message', {
|
|
10
|
+
value: message || '',
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true
|
|
13
|
+
})
|
|
14
|
+
Error.captureStackTrace(this, this.constructor)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
util.inherits(RedisError, Error)
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(RedisError.prototype, 'name', {
|
|
20
|
+
value: 'RedisError',
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// ParserError
|
|
26
|
+
|
|
27
|
+
function ParserError (message, buffer, offset) {
|
|
28
|
+
assert(buffer)
|
|
29
|
+
assert.strictEqual(typeof offset, 'number')
|
|
30
|
+
|
|
31
|
+
Object.defineProperty(this, 'message', {
|
|
32
|
+
value: message || '',
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const tmp = Error.stackTraceLimit
|
|
38
|
+
Error.stackTraceLimit = 2
|
|
39
|
+
Error.captureStackTrace(this, this.constructor)
|
|
40
|
+
Error.stackTraceLimit = tmp
|
|
41
|
+
this.offset = offset
|
|
42
|
+
this.buffer = buffer
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
util.inherits(ParserError, RedisError)
|
|
46
|
+
|
|
47
|
+
Object.defineProperty(ParserError.prototype, 'name', {
|
|
48
|
+
value: 'ParserError',
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// ReplyError
|
|
54
|
+
|
|
55
|
+
function ReplyError (message) {
|
|
56
|
+
Object.defineProperty(this, 'message', {
|
|
57
|
+
value: message || '',
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true
|
|
60
|
+
})
|
|
61
|
+
const tmp = Error.stackTraceLimit
|
|
62
|
+
Error.stackTraceLimit = 2
|
|
63
|
+
Error.captureStackTrace(this, this.constructor)
|
|
64
|
+
Error.stackTraceLimit = tmp
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
util.inherits(ReplyError, RedisError)
|
|
68
|
+
|
|
69
|
+
Object.defineProperty(ReplyError.prototype, 'name', {
|
|
70
|
+
value: 'ReplyError',
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// AbortError
|
|
76
|
+
|
|
77
|
+
function AbortError (message) {
|
|
78
|
+
Object.defineProperty(this, 'message', {
|
|
79
|
+
value: message || '',
|
|
80
|
+
configurable: true,
|
|
81
|
+
writable: true
|
|
82
|
+
})
|
|
83
|
+
Error.captureStackTrace(this, this.constructor)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
util.inherits(AbortError, RedisError)
|
|
87
|
+
|
|
88
|
+
Object.defineProperty(AbortError.prototype, 'name', {
|
|
89
|
+
value: 'AbortError',
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// InterruptError
|
|
95
|
+
|
|
96
|
+
function InterruptError (message) {
|
|
97
|
+
Object.defineProperty(this, 'message', {
|
|
98
|
+
value: message || '',
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true
|
|
101
|
+
})
|
|
102
|
+
Error.captureStackTrace(this, this.constructor)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
util.inherits(InterruptError, AbortError)
|
|
106
|
+
|
|
107
|
+
Object.defineProperty(InterruptError.prototype, 'name', {
|
|
108
|
+
value: 'InterruptError',
|
|
109
|
+
configurable: true,
|
|
110
|
+
writable: true
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
module.exports = {
|
|
114
|
+
RedisError,
|
|
115
|
+
ParserError,
|
|
116
|
+
ReplyError,
|
|
117
|
+
AbortError,
|
|
118
|
+
InterruptError
|
|
119
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "redis-errors",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Error classes used in node_redis",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "npm run coverage",
|
|
8
|
+
"lint": "standard --fix",
|
|
9
|
+
"posttest": "npm run lint && npm run coverage:check",
|
|
10
|
+
"coverage": "node ./node_modules/istanbul/lib/cli.js cover --preserve-comments ./node_modules/mocha/bin/_mocha -- -R spec",
|
|
11
|
+
"coverage:check": "node ./node_modules/istanbul/lib/cli.js check-coverage --statement 100"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/NodeRedis/redis-errors.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"redis",
|
|
19
|
+
"javascript",
|
|
20
|
+
"node",
|
|
21
|
+
"error"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=4"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"istanbul": "^0.4.0",
|
|
28
|
+
"mocha": "^3.1.2",
|
|
29
|
+
"standard": "^10.0.0"
|
|
30
|
+
},
|
|
31
|
+
"author": "Ruben Bridgewater",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/NodeRedis/redis-errors/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/NodeRedis/redis-errors#readme",
|
|
37
|
+
"directories": {
|
|
38
|
+
"test": "test",
|
|
39
|
+
"lib": "lib"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 NodeRedis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|