mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-25 05:52:02 +02:00
Initial commit
This commit is contained in:
22
node_modules/redis-commands/LICENSE
generated
vendored
Normal file
22
node_modules/redis-commands/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 NodeRedis
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
51
node_modules/redis-commands/README.md
generated
vendored
Normal file
51
node_modules/redis-commands/README.md
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
# Redis Commands
|
||||
|
||||
[](https://travis-ci.org/NodeRedis/redis-commands)
|
||||
[](https://codeclimate.com/github/NodeRedis/redis-commands)
|
||||
[](https://codeclimate.com/github/NodeRedis/redis-commands/coverage)
|
||||
|
||||
This module exports all the commands that Redis supports.
|
||||
|
||||
## Install
|
||||
|
||||
```shell
|
||||
$ npm install redis-commands
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var commands = require('redis-commands');
|
||||
```
|
||||
|
||||
`.list` is an array contains all the lowercased commands:
|
||||
|
||||
```javascript
|
||||
commands.list.forEach(function (command) {
|
||||
console.log(command);
|
||||
});
|
||||
```
|
||||
|
||||
`.exists()` is used to check if the command exists:
|
||||
|
||||
```javascript
|
||||
commands.exists('set') // true
|
||||
commands.exists('other-command') // false
|
||||
```
|
||||
|
||||
`.hasFlag()` is used to check if the command has the flag:
|
||||
|
||||
```javascript
|
||||
commands.hasFlag('set', 'readonly') // false
|
||||
```
|
||||
|
||||
`.getKeyIndexes()` is used to get the indexes of keys in the command arguments:
|
||||
|
||||
```javascript
|
||||
commands.getKeyIndexes('set', ['key', 'value']) // [0]
|
||||
commands.getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
|
||||
```
|
||||
|
||||
## Acknowledgment
|
||||
|
||||
Thank [@Yuan Chuan](https://github.com/yuanchuan) for the package name. The original redis-commands is renamed to [@yuanchuan/redis-commands](https://www.npmjs.com/package/@yuanchuan/redis-commands).
|
71
node_modules/redis-commands/changelog.md
generated
vendored
Normal file
71
node_modules/redis-commands/changelog.md
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
## v.1.5.0 - 10 May, 2019
|
||||
|
||||
Features
|
||||
|
||||
- Updated the commands list
|
||||
- Added support for `XREAD` and `XREADGROUP` in `.getKeyIndexes()`
|
||||
|
||||
## v.1.4.0 - 8 Oct, 2018
|
||||
|
||||
Features
|
||||
|
||||
- Updated the commands list
|
||||
|
||||
## 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
|
||||
|
||||
- Rebuild the commands with the newest Redis unstable release
|
||||
|
||||
## v.1.2.0 - 21 Apr, 2016
|
||||
|
||||
Features
|
||||
|
||||
- Added support for `MIGRATE [...] KEYS key1, key2` (Redis >= v.3.0.6)
|
||||
- Added build sanity check for unhandled commands with moveable keys
|
||||
- Rebuild the commands with the newest unstable release
|
||||
- Improved performance of .getKeyIndexes()
|
||||
|
||||
Bugfix
|
||||
|
||||
- Fixed command command returning the wrong arity due to a Redis bug
|
||||
- Fixed brpop command returning the wrong keystop due to a Redis bug
|
||||
|
||||
## v.1.1.0 - 09 Feb, 2016
|
||||
|
||||
Features
|
||||
|
||||
- Added .exists() to check for command existence
|
||||
- Improved performance of .hasFlag()
|
2042
node_modules/redis-commands/commands.json
generated
vendored
Normal file
2042
node_modules/redis-commands/commands.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
168
node_modules/redis-commands/index.js
generated
vendored
Normal file
168
node_modules/redis-commands/index.js
generated
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
'use strict'
|
||||
|
||||
var commands = require('./commands.json')
|
||||
|
||||
/**
|
||||
* Redis command list
|
||||
*
|
||||
* All commands are lowercased.
|
||||
*
|
||||
* @var {string[]}
|
||||
* @public
|
||||
*/
|
||||
exports.list = Object.keys(commands)
|
||||
|
||||
var flags = {}
|
||||
exports.list.forEach(function (commandName) {
|
||||
flags[commandName] = commands[commandName].flags.reduce(function (flags, flag) {
|
||||
flags[flag] = true
|
||||
return flags
|
||||
}, {})
|
||||
})
|
||||
/**
|
||||
* Check if the command exists
|
||||
*
|
||||
* @param {string} commandName - the command name
|
||||
* @return {boolean} result
|
||||
* @public
|
||||
*/
|
||||
exports.exists = function (commandName) {
|
||||
return Boolean(commands[commandName])
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the command has the flag
|
||||
*
|
||||
* Some of possible flags: readonly, noscript, loading
|
||||
* @param {string} commandName - the command name
|
||||
* @param {string} flag - the flag to check
|
||||
* @return {boolean} result
|
||||
* @public
|
||||
*/
|
||||
exports.hasFlag = function (commandName, flag) {
|
||||
if (!flags[commandName]) {
|
||||
throw new Error('Unknown command ' + commandName)
|
||||
}
|
||||
|
||||
return Boolean(flags[commandName][flag])
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indexes of keys in the command arguments
|
||||
*
|
||||
* @param {string} commandName - the command name
|
||||
* @param {string[]} args - the arguments of the command
|
||||
* @param {object} [options] - options
|
||||
* @param {boolean} [options.parseExternalKey] - parse external keys
|
||||
* @return {number[]} - the list of the index
|
||||
* @public
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* getKeyIndexes('set', ['key', 'value']) // [0]
|
||||
* getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
|
||||
* ```
|
||||
*/
|
||||
exports.getKeyIndexes = function (commandName, args, options) {
|
||||
var command = commands[commandName]
|
||||
if (!command) {
|
||||
throw new Error('Unknown command ' + commandName)
|
||||
}
|
||||
|
||||
if (!Array.isArray(args)) {
|
||||
throw new Error('Expect args to be an array')
|
||||
}
|
||||
|
||||
var keys = []
|
||||
var i, keyStart, keyStop, parseExternalKey
|
||||
switch (commandName) {
|
||||
case 'zunionstore':
|
||||
case 'zinterstore':
|
||||
keys.push(0)
|
||||
// fall through
|
||||
case 'eval':
|
||||
case 'evalsha':
|
||||
keyStop = Number(args[1]) + 2
|
||||
for (i = 2; i < keyStop; i++) {
|
||||
keys.push(i)
|
||||
}
|
||||
break
|
||||
case 'sort':
|
||||
parseExternalKey = options && options.parseExternalKey
|
||||
keys.push(0)
|
||||
for (i = 1; i < args.length - 1; i++) {
|
||||
if (typeof args[i] !== 'string') {
|
||||
continue
|
||||
}
|
||||
var directive = args[i].toUpperCase()
|
||||
if (directive === 'GET') {
|
||||
i += 1
|
||||
if (args[i] !== '#') {
|
||||
if (parseExternalKey) {
|
||||
keys.push([i, getExternalKeyNameLength(args[i])])
|
||||
} else {
|
||||
keys.push(i)
|
||||
}
|
||||
}
|
||||
} else if (directive === 'BY') {
|
||||
i += 1
|
||||
if (parseExternalKey) {
|
||||
keys.push([i, getExternalKeyNameLength(args[i])])
|
||||
} else {
|
||||
keys.push(i)
|
||||
}
|
||||
} else if (directive === 'STORE') {
|
||||
i += 1
|
||||
keys.push(i)
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'migrate':
|
||||
if (args[2] === '') {
|
||||
for (i = 5; i < args.length - 1; i++) {
|
||||
if (args[i].toUpperCase() === 'KEYS') {
|
||||
for (var j = i + 1; j < args.length; j++) {
|
||||
keys.push(j)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
keys.push(2)
|
||||
}
|
||||
break
|
||||
case 'xreadgroup':
|
||||
case 'xread':
|
||||
// Keys are 1st half of the args after STREAMS argument.
|
||||
for (i = commandName === 'xread' ? 0 : 3; i < args.length - 1; i++) {
|
||||
if (String(args[i]).toUpperCase() === 'STREAMS') {
|
||||
for (j = i + 1; j <= i + ((args.length - 1 - i) / 2); j++) {
|
||||
keys.push(j)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
default:
|
||||
// Step has to be at least one in this case, otherwise the command does
|
||||
// not contain a key.
|
||||
if (command.step > 0) {
|
||||
keyStart = command.keyStart - 1
|
||||
keyStop = command.keyStop > 0 ? command.keyStop : args.length + command.keyStop + 1
|
||||
for (i = keyStart; i < keyStop; i += command.step) {
|
||||
keys.push(i)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
function getExternalKeyNameLength (key) {
|
||||
if (typeof key !== 'string') {
|
||||
key = String(key)
|
||||
}
|
||||
var hashPos = key.indexOf('->')
|
||||
return hashPos === -1 ? key.length : hashPos
|
||||
}
|
69
node_modules/redis-commands/package.json
generated
vendored
Normal file
69
node_modules/redis-commands/package.json
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"_from": "redis-commands@^1.2.0",
|
||||
"_id": "redis-commands@1.5.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-6KxamqpZ468MeQC3bkWmCB1fp56XL64D4Kf0zJSwDZbVLLm7KFkoIcHrgRvQ+sk8dnhySs7+yBg94yIkAK7aJg==",
|
||||
"_location": "/redis-commands",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "redis-commands@^1.2.0",
|
||||
"name": "redis-commands",
|
||||
"escapedName": "redis-commands",
|
||||
"rawSpec": "^1.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/redis"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.5.0.tgz",
|
||||
"_shasum": "80d2e20698fe688f227127ff9e5164a7dd17e785",
|
||||
"_spec": "redis-commands@^1.2.0",
|
||||
"_where": "/home/runner/Socketio-Chat-Template/node_modules/redis",
|
||||
"author": {
|
||||
"name": "luin",
|
||||
"email": "i@zihua.li",
|
||||
"url": "http://zihua.li"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/NodeRedis/redis-commands/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Redis commands",
|
||||
"devDependencies": {
|
||||
"chai": "^4.0.1",
|
||||
"codeclimate-test-reporter": "^0.5.1",
|
||||
"ioredis": "^4.9.0",
|
||||
"istanbul": "^0.4.3",
|
||||
"mocha": "^6.0.0",
|
||||
"safe-stable-stringify": "^1.0.0",
|
||||
"snazzy": "^8.0.0",
|
||||
"standard": "^12.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/NodeRedis/redis-commands",
|
||||
"keywords": [
|
||||
"redis",
|
||||
"commands",
|
||||
"prefix"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "redis-commands",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/NodeRedis/redis-commands.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node tools/build",
|
||||
"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",
|
||||
"lint": "standard --fix --verbose | snazzy",
|
||||
"posttest": "npm run coverage && npm run coverage:check",
|
||||
"pretest": "npm run lint",
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.5.0"
|
||||
}
|
62
node_modules/redis-commands/tools/build.js
generated
vendored
Normal file
62
node_modules/redis-commands/tools/build.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var stringify = require('safe-stable-stringify')
|
||||
var commandPath = path.join(__dirname, '..', 'commands.json')
|
||||
var redisCommands = require('../')
|
||||
|
||||
var Redis = require('ioredis')
|
||||
var redis = new Redis(process.env.REDIS_URI)
|
||||
|
||||
redis.command().then(function (res) {
|
||||
redis.disconnect()
|
||||
|
||||
// Find all special handled cases
|
||||
var movableKeys = String(redisCommands.getKeyIndexes).match(/case '[a-z-]+':/g).map(function (entry) {
|
||||
return entry.replace(/^case '|':$/g, '')
|
||||
})
|
||||
|
||||
var commands = res.reduce(function (prev, current) {
|
||||
var currentCommandPos = movableKeys.indexOf(current[0])
|
||||
if (currentCommandPos !== -1 && current[2].indexOf('movablekeys') !== -1) {
|
||||
movableKeys.splice(currentCommandPos, 1)
|
||||
}
|
||||
// https://github.com/antirez/redis/issues/2598
|
||||
if (current[0] === 'brpop' && current[4] === 1) {
|
||||
current[4] = -2
|
||||
}
|
||||
prev[current[0]] = {
|
||||
arity: current[1] || 1, // https://github.com/antirez/redis/pull/2986
|
||||
flags: current[2],
|
||||
keyStart: current[3],
|
||||
keyStop: current[4],
|
||||
step: current[5]
|
||||
}
|
||||
return prev
|
||||
}, {})
|
||||
|
||||
// Future proof. Redis might implement this at some point
|
||||
// https://github.com/antirez/redis/pull/2982
|
||||
if (!commands.quit) {
|
||||
commands.quit = {
|
||||
arity: 1,
|
||||
flags: [
|
||||
'loading',
|
||||
'stale',
|
||||
'readonly'
|
||||
],
|
||||
keyStart: 0,
|
||||
keyStop: 0,
|
||||
step: 0
|
||||
}
|
||||
}
|
||||
|
||||
if (movableKeys.length !== 0) {
|
||||
throw new Error('Not all commands (\'' + movableKeys.join('\', \'') + '\') with the "movablekeys" flag are handled in the code')
|
||||
}
|
||||
|
||||
// Use safe-stable-stringify instead fo JSON.stringify
|
||||
// for easier diffing
|
||||
var content = stringify(commands, null, ' ')
|
||||
|
||||
fs.writeFileSync(commandPath, content)
|
||||
})
|
Reference in New Issue
Block a user