safe-parse-list

0.1.1 • Public • Published

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.

Package Sidebar

Install

npm i safe-parse-list

Weekly Downloads

18

Version

0.1.1

License

ISC

Unpacked Size

3.59 kB

Total Files

4

Last publish

Collaborators

  • wesleytodd