{"name":"split-string","description":"Split a string on a character except when the character is escaped.","version":"2.1.0","homepage":"https://github.com/jonschlinkert/split-string","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"contributors":[{"name":"Brian Woodward","email":"brian.woodward@gmail.com","url":"https://twitter.com/doowb"},{"name":"Jon Schlinkert","email":"jon.schlinkert@sellside.com","url":"http://twitter.com/jonschlinkert"}],"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/split-string.git"},"bugs":{"url":"https://github.com/jonschlinkert/split-string/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1"},"devDependencies":{"gulp-format-md":"^0.1.11","mocha":"^3.2.0","sections":"^0.1.10","update-sections":"^0.1.2"},"keywords":["character","escape","split","string"],"verb":{"toc":false,"layout":"default","titles":[".","Why use this?","install"],"related":{"list":["deromanize","randomatic","repeat-string","romanize"]},"tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"67234051a8b9064c49f0b3df36a1a66c8e09083a","_id":"split-string@2.1.0","_shasum":"15a5fcbf9aeccf34c1edc884161f3852673e1b73","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.7.3","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"15a5fcbf9aeccf34c1edc884161f3852673e1b73","tarball":"http://registry-npm.ywwl.com/split-string/download/split-string-2.1.0.tgz","integrity":"sha512-rP+LSkzUdtCubK8gF3uObYCpK6/fTBxt8cBv2e+LIlE2DlAycAP3J4S1+/tdxXJO4VuIwkQLXiWz5AkgeVRyDQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCqY+qPlpHSm/UydFfe3fHNrXRnmR/xcvv1zJ0oPGufnwIhAPzS5Gu8HwryX1GCrFskcF+rRg1IiiXCDREqCnN+MOYZ"}],"size":4073,"noattachment":false,"key":"/split-string/-/split-string-2.1.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/split-string-2.1.0.tgz_1493269826373_0.8184628051239997"},"directories":{},"readme":"# split-string [![NPM version](https://img.shields.io/npm/v/split-string.svg?style=flat)](https://www.npmjs.com/package/split-string) [![NPM monthly downloads](https://img.shields.io/npm/dm/split-string.svg?style=flat)](https://npmjs.org/package/split-string) [![NPM total downloads](https://img.shields.io/npm/dt/split-string.svg?style=flat)](https://npmjs.org/package/split-string) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/split-string.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/split-string)\n\n> Easy way to split a string on a given character unless it's quoted or escaped.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save split-string\n```\n\n## Usage\n\n```js\nconst split = require('split-string');\n\nconsole.log(split('a.b.c'));\n//=> ['a', 'b', 'c']\n\n// respects escaped characters\nconsole.log(split('a.b.c\\\\.d'));\n//=> ['a', 'b', 'c.d']\n\n// respects double-quoted strings\nconsole.log(split('a.\"b.c.d\".e'));\n//=> ['a', '\"b.c.d\"', 'e']\n```\n\n## Options\n\n### options.quotes\n\n**Type**: `Array|Boolean`\n\n**Default**: `[]`\n\n**Description**\n\nTell split-string not to split inside any of the quote characters specified on the quotes option. Each character signifies both the \"opening\" and \"closing\" character to use.\n\n```js\n// default behavior\nconsole.log(split('a.b.\"c.d.e.f.g\".h.i'));\n//=> [ 'a', 'b', '\"c', 'd', 'e', 'f', 'g\"', 'h', 'i' ]\n\n// with quotes\nconsole.log(split('a.b.\"c.d.e.f.g\".h.i', { quotes: ['\"'] }));\n//=> [ 'a', 'b', '\"c.d.e.f.g\"', 'h', 'i' ]\n\n// escaped quotes will be ignored\nconsole.log(split('a.b.\\\\\"c.d.\"e.f.g\".h.i', { quotes: ['\"'] }));\n//=> [ 'a', 'b', '\"c', 'd', '\"e.f.g\"', 'h', 'i' ]\n\n// example of how to exclude non-escaped quotes from the result\nlet keep = (value, state) => {\n  return value !== '\\\\' && (value !== '\"' || state.prev() === '\\\\');\n};\nconsole.log(split('a.b.\\\\\"c.d.\"e.f.g\".h.i', { quotes: ['\"'], keep }));\n//=> [ 'a', 'b', '\"c', 'd', 'e.f.g', 'h', 'i' ]\n```\n\n## Options\n\n### options.brackets\n\n**Type**: `Object|Boolean`\n\n**Default**: `{}`\n\n**Description**\n\nBy default, no special significance is given to bracket-like characters (such as square brackets, curly braces, angle brackets, and so on).\n\n```js\n// default behavior\nconsole.log(split('a.{b.c}.{d.e}'));\n//=> [ 'a', '{b', 'c}', '{d', 'e}' ]\n```\n\nWhen `options.brackets` is `true`, the following brackets types are supported:\n\n```js\n{\n  '<': '>',\n  '(': ')',\n  '[': ']',\n  '{': '}'\n}\n```\n\nFor example:\n\n```js\nconsole.log(split('a.{b.c}.{d.e}', { brackets: true }));\n//=> [ 'a', '{b.c}', '{d.e}' ]\n```\n\nAlternatively, an object of brackets may be passed, where each key is the _opening bracket_ and each value is the corresponding _closing bracket_. Note that the key and value **must be different characters**. If you want to use the same character for both open and close, use the [quotes option](#optionsquotes).\n\n**Examples**\n\n```js\n// no bracket support by default\nconsole.log(split('a.{b.c}.[d.e].f'));\n//=> [ 'a', '{b', 'c}', '[d', 'e]', 'f' ]\n\n// tell split-string not to split inside curly braces\nconsole.log(split('a.{b.c}.[d.e].f', { brackets: { '{': '}' }}));\n//=> [ 'a', '{b.c}', '[d', 'e]', 'f' ]\n\n// tell split-string not to split inside any of these types: \"<>{}[]()\"\nconsole.log(split('a.{b.c}.[d.e].f', { brackets: true }));\n//=> [ 'a', '{b.c}', '[d.e]', 'f' ]\n\n// ...nested brackets are also supported\nconsole.log(split('a.{b.{c.d}.e}.f', { brackets: true }));\n//=> [ 'a', '{b.{c.d}.e}', 'f' ]\n\n// tell split-string not to split inside the given custom types\nconsole.log(split('«a.b».⟨c.d⟩.[e.f]', { brackets: { '«': '»', '⟨': '⟩' } }));\n//=> [ '«a.b»', '⟨c.d⟩', '[e', 'f]' ]\n```\n\n### options.keep\n\n**Type**: `function`\n\n**Default**: Function that returns true if the character is not `\\\\`.\n\nFunction that returns true when a character should be retained in the result.\n\n**Example**\n\n```js\nconsole.log(split('a.b\\\\.c')); //=> ['a', 'b.c']\n\n// keep all characters\nconsole.log(split('a.b.\\\\c', { keep: () => true })); //=> ['a', 'b\\.c']\n```\n\n### options.separator\n\n**Type**: `string`\n\n**Default**: `.`\n\nThe character to split on.\n\n**Example**\n\n```js\nconsole.log(split('a.b,c', { separator: ',' })); //=> ['a.b', 'c']\n```\n\n## Split function\n\nOptionally pass a function as the last argument to tell split-string whether or not to split when the specified separator is encountered.\n\n**Example**\n\n```js\n// only split on \".\" when the \"previous\" character is \"a\"\nconsole.log(split('a.b.c.a.d.e', state => state.prev() === 'a'));\n//=> [ 'a', 'b.c.a', 'd.e' ]\n```\n\nThe `state` object exposes the following properties:\n\n* `input` - (String) The un-modified, user-defined input string\n* `separator` - (String) the specified separator to split on.\n* `index` - (Number) The current cursor position\n* `value` - (String) The character at the current index\n* `bos` - (Function) Returns true if position is at the beginning-of-string\n* `eos` - (Function) Returns true if position is at the end-of-string\n* `prev` - (Function) Returns the previously scanned character\n* `next` - (Function) Returns the next character after the current position\n* `block` - (Object) The \"current\" AST node.\n* `stack` - (Array) AST nodes\n\n## About\n\n<details>\n<summary><strong>Contributing</strong></summary>\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n</details>\n\n<details>\n<summary><strong>Running Tests</strong></summary>\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install && npm test\n```\n\n</details>\n\n<details>\n<summary><strong>Building docs</strong></summary>\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme && verb\n```\n\n</details>\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [deromanize](https://www.npmjs.com/package/deromanize): Convert roman numerals to arabic numbers (useful for books, outlines, documentation, slide decks, etc) | [homepage](https://github.com/jonschlinkert/deromanize \"Convert roman numerals to arabic numbers (useful for books, outlines, documentation, slide decks, etc)\")\n* [randomatic](https://www.npmjs.com/package/randomatic): Generate randomized strings of a specified length using simple character sequences. The original generate-password. | [homepage](https://github.com/jonschlinkert/randomatic \"Generate randomized strings of a specified length using simple character sequences. The original generate-password.\")\n* [repeat-string](https://www.npmjs.com/package/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string. | [homepage](https://github.com/jonschlinkert/repeat-string \"Repeat the given string n times. Fastest implementation for repeating a string.\")\n* [romanize](https://www.npmjs.com/package/romanize): Convert numbers to roman numerals (useful for books, outlines, documentation, slide decks, etc) | [homepage](https://github.com/jonschlinkert/romanize \"Convert numbers to roman numerals (useful for books, outlines, documentation, slide decks, etc)\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 56 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 12 | [doowb](https://github.com/doowb) |  \n| 6  | [Ovyerus](https://github.com/Ovyerus) |  \n| 1  | [silverwind](https://github.com/silverwind) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 22, 2019._","publish_time":1493269828408,"_cnpm_publish_time":1493269828408,"dist-tags":{"latest":"6.1.0"}}