safe-parse-list
v0.1.1
Published
Safely parse a string into an array, split by delimiter
Downloads
123
Maintainers
Readme
Parse comma delimited string to array
Usage
$ npm install safe-parse-list
const split = require('safe-parse-list')
split('1,2,3') // ['1', '2', '3']
split('1, 2, 3') // ['1', '2', '3']
split('1,\t2,\t3') // ['1', '2', '3']
split('1,\t\t2,\t 3') // ['1', '2', '3']
split('1,22 22,3') // ['1', '22 22', '3']
// Other delimteters or whitespace chars
split('1 2 3', {
whitespace: [],
delimiters: [' ']
}) // ['1', '2', '3']
Why is this module "safe"?
Usually this type of thing is done with a Regular Expression. This has some problems. This package implements the loop trim implementation used to solve most of these ReDOS issues.