redis-splitargs
v1.0.2
Published
Splitting arguments like a ninja
Downloads
63,678
Readme
splitargs
Splitting Redis arguments as redis-cli
Install
$ npm install redis-splitargs
Usage
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();