npm.io
3.1.0 • Published 7 years ago

smart-splitter

Licence
MIT
Version
3.1.0
Deps
0
Size
7 kB
Vulns
0
Weekly
0

Smart Splitter

GitHub release npm Travis (.com)

Split strings the smarter way.

Why?

A developer might parse arguments using String#split, but this falls apart as soon as multi-word arguments need to be parsed:

"--force -m hey!".split(" "); // It works...
"--force -m 'hello world'".split(" "); // Nope: [..., "'hello", "world'"]

Smart Splitter aims to solve this problem. Quoted text remains as one string and does not contain quotes:

smartSplit("--force -m 'hello world'"); // Nice: ["--force", "-m", "hello world"]