0.1.1 • Published 4 years ago

safe-parse-list v0.1.1

Weekly downloads
85
License
ISC
Repository
github
Last release
4 years ago

Parse comma delimited string to array

NPM Version NPM Downloads JS Standard Style GitHub Sponsor

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.