Skip to content

Commit 961ce5e

Browse files
committed
first commit
0 parents  commit 961ce5e

11 files changed

+294
-0
lines changed

.editorconfig

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
end_of_line = lf
7+
charset = utf-8
8+
indent_size = 2
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
insert_final_newline = false
15+
16+
[{,test/}{actual,fixtures}/**]
17+
trim_trailing_whitespace = false
18+
insert_final_newline = false
19+
20+
[templates/**]
21+
trim_trailing_whitespace = false
22+
insert_final_newline = false

.gitattributes

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Enforce Unix newlines
2+
* text eol=lf
3+
4+
# binaries
5+
*.ai binary
6+
*.psd binary
7+
*.jpg binary
8+
*.gif binary
9+
*.png binary
10+
*.jpeg binary

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.DS_Store
2+
*.sublime-*
3+
_gh_pages
4+
bower_components
5+
node_modules
6+
npm-debug.log
7+
actual
8+
test/actual
9+
temp
10+
tmp
11+
TODO.md
12+
vendor
13+
.idea
14+
benchmark
15+
coverage

.jshintrc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"asi": false,
3+
"boss": true,
4+
"curly": true,
5+
"eqeqeq": true,
6+
"eqnull": true,
7+
"esnext": true,
8+
"immed": true,
9+
"latedef": false,
10+
"laxcomma": false,
11+
"mocha": true,
12+
"newcap": true,
13+
"noarg": true,
14+
"node": true,
15+
"sub": true,
16+
"undef": true,
17+
"unused": true
18+
}

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- "0.10"
5+
- "0.12"
6+
- "0.13"
7+
- "iojs"
8+
matrix:
9+
fast_finish: true
10+
allow_failures:
11+
- node_js: "0.13"

.verb.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# {%= name %} {%= badge("fury") %}
2+
3+
> {%= description %}
4+
5+
## Install
6+
{%= include("install-npm", {save: true}) %}
7+
8+
## Usage
9+
10+
```js
11+
var split = require('{%= name %}');
12+
13+
split('a.b.c');
14+
//=> ['a', 'b', 'c']
15+
```
16+
17+
**respects escaped characters**
18+
19+
```js
20+
split('a.b.c\\.d');
21+
//=> ['a', 'b', 'c.d']
22+
```
23+
24+
## Related projects
25+
{%= related(verb.related.list, {remove: name}) %}
26+
27+
## Running tests
28+
{%= include("tests") %}
29+
30+
## Contributing
31+
{%= include("contributing") %}
32+
33+
## Author
34+
{%= include("author") %}
35+
36+
## License
37+
{%= copyright() %}
38+
{%= license() %}
39+
40+
***
41+
42+
{%= include("footer") %}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015, Jon Schlinkert.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# split-string [![NPM version](https://badge.fury.io/js/split-string.svg)](http://badge.fury.io/js/split-string)
2+
3+
> Split a string on a character except when the character is escaped.
4+
5+
## Install
6+
7+
Install with [npm](https://www.npmjs.com/)
8+
9+
```sh
10+
$ npm i split-string --save
11+
```
12+
13+
## Usage
14+
15+
```js
16+
var split = require('split-string');
17+
18+
split('a.b.c');
19+
//=> ['a', 'b', 'c']
20+
```
21+
22+
**respects escaped characters**
23+
24+
```js
25+
split('a.b.c\\.d');
26+
//=> ['a', 'b', 'c.d']
27+
```
28+
29+
## Related projects
30+
31+
* [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)
32+
* [randomatic](https://www.npmjs.com/package/randomatic): Generate randomized strings of a specified length, fast. Only the length is necessary, but you… [more](https://www.npmjs.com/package/randomatic) | [homepage](https://github.com/jonschlinkert/randomatic)
33+
* [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)
34+
* [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)
35+
36+
## Running tests
37+
38+
Install dev dependencies:
39+
40+
```sh
41+
$ npm i -d && npm test
42+
```
43+
44+
## Contributing
45+
46+
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/split-string/issues/new).
47+
48+
## Author
49+
50+
**Jon Schlinkert**
51+
52+
+ [github/jonschlinkert](https://github.com/jonschlinkert)
53+
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
54+
55+
## License
56+
57+
Copyright © 2015 Jon Schlinkert
58+
Released under the MIT license.
59+
60+
***
61+
62+
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 26, 2015._

index.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*!
2+
* split-string <https://github.com/jonschlinkert/split-string>
3+
*
4+
* Copyright (c) 2015, Jon Schlinkert.
5+
* Licensed under the MIT License.
6+
*/
7+
8+
'use strict';
9+
10+
var nonchar = require('noncharacters');
11+
12+
function split(str, ch) {
13+
if (typeof str !== 'string') {
14+
throw new TypeError('expected a string.');
15+
}
16+
ch = ch || '.';
17+
var esc = str.split('\\' + ch).join(nonchar);
18+
var segs = esc.split(ch);
19+
var len = segs.length, i = -1;
20+
var res = [];
21+
while (++i < len) {
22+
res.push(segs[i].split(nonchar).join(ch));
23+
}
24+
return res;
25+
}
26+
27+
/**
28+
* expose `split`
29+
*/
30+
31+
module.exports = split;

package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "split-string",
3+
"description": "Split a string on a character except when the character is escaped.",
4+
"version": "0.1.0",
5+
"homepage": "https://github.com/jonschlinkert/split-string",
6+
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7+
"repository": "jonschlinkert/split-string",
8+
"bugs": {
9+
"url": "https://github.com/jonschlinkert/split-string/issues"
10+
},
11+
"license": "MIT",
12+
"files": [
13+
"index.js"
14+
],
15+
"main": "index.js",
16+
"engines": {
17+
"node": ">=0.10.0"
18+
},
19+
"scripts": {
20+
"test": "mocha"
21+
},
22+
"dependencies": {
23+
"noncharacters": "^1.1.0"
24+
},
25+
"devDependencies": {
26+
"mocha": "*"
27+
},
28+
"keywords": [],
29+
"verb": {
30+
"related": {
31+
"list": [
32+
"repeat-string",
33+
"randomatic",
34+
"deromanize",
35+
"romanize"
36+
]
37+
}
38+
}
39+
}

test.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
/* deps: mocha */
4+
var assert = require('assert');
5+
var split = require('./');
6+
7+
describe('split', function () {
8+
it('should split a string on the given character:', function () {
9+
assert.deepEqual(split('a/b/c', '/'), ['a', 'b', 'c']);
10+
});
11+
12+
it('should not split on an escaped character:', function () {
13+
assert.deepEqual(split('a/b/c\\/d', '/'), ['a', 'b', 'c/d']);
14+
});
15+
16+
it('should split a string on dots by default:', function () {
17+
assert.deepEqual(split('a.b.c'), ['a', 'b', 'c']);
18+
});
19+
20+
it('should not split on escaped dots:', function () {
21+
assert.deepEqual(split('a.b.c\\.d'), ['a', 'b', 'c.d']);
22+
});
23+
});

0 commit comments

Comments
 (0)