Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johno/comma-split
Split comma delimited strings into an array.
https://github.com/johno/comma-split
Last synced: 2 months ago
JSON representation
Split comma delimited strings into an array.
- Host: GitHub
- URL: https://github.com/johno/comma-split
- Owner: johno
- License: mit
- Created: 2015-01-23T18:08:28.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-14T17:47:59.000Z (over 9 years ago)
- Last Synced: 2024-10-22T03:00:22.753Z (3 months ago)
- Language: JavaScript
- Size: 146 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# comma-split [![Build Status](https://secure.travis-ci.org/johnotander/comma-split.png?branch=master)](https://travis-ci.org/johnotander/comma-split)
Split comma delimited strings into an array. Optional handling for trailing
and/or leading whitespace.## Installation
```bash
npm install --save comma-split
```## Usage
```javascript
var commaSplit = require('comma-split');commaSplit('some, string,\r\r\n\tdelimited\n,by, commas');
// => ['some','string','delimited','by','commas']commaSplit('some, string,\r\r\n\tdelimited\n,by, commas', { ignoreWhitespace: true });
// => ['some',' string','\r\r\n\tdelimited\n','by',' commas']commaSplit('some, string,\r\r\n\tdelimited\n,by, commas', { ignoreTrailingWhitespace: true });
// => ['some','string','delimited\n','by','commas']commaSplit('some, string,\r\r\n\tdelimited\n,by, commas', { ignoreLeadingWhitespace: true });
// => ['some',' string','\r\r\n\tdelimited','by',' commas']commaSplit(',,some, string,\r\r\n\tdelimited\n,by, commas,');
// => ['','','some','string','delimited','by','commas','']commaSplit(',,some, string,\r\r\n\tdelimited\n,by, commas, ,,', { ignoreBlank: true });
// => [some','string','delimited','by','commas']commaSplit('some, string, with,a, dupe, dupe', { ignoreDuplicate: true });
// => [some','string','with', 'a', 'dupe'']
```### Options
* `ignoreWhitespace`:`boolean` - Ignore leading and trailing whitespace.
* `ignoreTrailingWhitespace`:`boolean` - Ignore trailing whitespace.
* `ignoreLeadingWhitespace`:`boolean` - Ignore leading whitespace.
* `ignoreDuplicate`:`boolean` - Ignore duplicate elements.## License
MIT
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull RequestCrafted with <3 by John Otander ([@4lpine](https://twitter.com/4lpine)).
This package was initially generated with [yeoman](http://yeoman.io) and the [p generator](https://github.com/johnotander/generator-p.git).