https://github.com/luin/splitargs
Splitting Redis arguments as redis-cli
https://github.com/luin/splitargs
Last synced: over 1 year ago
JSON representation
Splitting Redis arguments as redis-cli
- Host: GitHub
- URL: https://github.com/luin/splitargs
- Owner: luin
- License: mit
- Created: 2016-03-25T12:51:13.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-05-07T13:19:31.000Z (about 2 years ago)
- Last Synced: 2025-03-01T00:53:10.216Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# splitargs
Splitting Redis arguments as redis-cli
## Install
```shell
$ npm install redis-splitargs
```
## Usage
```javascript
const s = require("redis-splitargs");
expect(s("set foo bar")).to.eql(["set", "foo", "bar"]);
expect(s('set "foo bar"')).to.eql(["set", "foo bar"]);
expect(s('set "foo bar\\" baz"')).to.eql(["set", 'foo bar" baz']);
expect(s("set \\ bar")).to.eql(["set", "\\", "bar"]);
expect(s(" set foo \r \n bar \v ")).to.eql(["set", "foo", "bar"]);
expect(s('"set" "foo" "bar"')).to.eql(["set", "foo", "bar"]);
expect(function () {
s('set foo "bar');
}).to.throw();
expect(function () {
s('set foo "bar"dsf');
}).to.throw();
expect(function () {
s("set foo 'bar");
}).to.throw();
```