Skip to content

Commit e684222

Browse files
committed
first commit
0 parents  commit e684222

16 files changed

+313
-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

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# {%= name %} {%= badge("fury") %}
2+
3+
> {%= description %}
4+
5+
## Install
6+
{%= include("install-npm", {save: true}) %}
7+
8+
## Usage
9+
10+
```js
11+
var regex = require('{%= name %}')();
12+
13+
regex.test(' foo ');
14+
//=> false
15+
16+
regex.test(' ');
17+
//=> true
18+
```
19+
20+
## Other regex projects
21+
{%= related(verb.related.list) %}
22+
23+
## Running tests
24+
{%= include("tests") %}
25+
26+
## Contributing
27+
{%= include("contributing") %}
28+
29+
## Author
30+
{%= include("author") %}
31+
32+
## License
33+
{%= copyright() %}
34+
{%= license() %}
35+
36+
***
37+
38+
{%= 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

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# whitespace-regex [![NPM version](https://badge.fury.io/js/whitespace-regex.svg)](http://badge.fury.io/js/whitespace-regex)
2+
3+
> Regular expression for matching the whitespace in a string.
4+
5+
## Install
6+
7+
Install with [npm](https://www.npmjs.com/)
8+
9+
```sh
10+
$ npm i whitespace-regex --save
11+
```
12+
13+
## Usage
14+
15+
```js
16+
var regex = require('whitespace-regex')();
17+
18+
regex.test(' foo ');
19+
//=> false
20+
21+
regex.test(' ');
22+
//=> true
23+
```
24+
25+
## Other regex projects
26+
27+
* [copyright-regex](https://www.npmjs.com/package/copyright-regex): Regex for matching and parsing copyright statements. | [homepage](https://github.com/regexps/copyright-regex)
28+
* [is-equal-regex](https://www.npmjs.com/package/is-equal-regex): Returns true if regular expression A is equal to regex B. Compares the expression and… [more](https://www.npmjs.com/package/is-equal-regex) | [homepage](https://github.com/jonschlinkert/is-equal-regex)
29+
* [todo-regex](https://www.npmjs.com/package/todo-regex): Regular expression for matching TODO statements in a string. | [homepage](https://github.com/regexps/todo-regex)
30+
31+
## Running tests
32+
33+
Install dev dependencies:
34+
35+
```sh
36+
$ npm i -d && npm test
37+
```
38+
39+
## Contributing
40+
41+
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/whitespace-regex/issues/new).
42+
43+
## Author
44+
45+
**Jon Schlinkert**
46+
47+
+ [github/jonschlinkert](https://github.com/jonschlinkert)
48+
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
49+
50+
## License
51+
52+
Copyright © 2015 Jon Schlinkert
53+
Released under the MIT license.
54+
55+
***
56+
57+
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 22, 2015._

index.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*!
2+
* whitespace-regex <https://github.com/jonschlinkert/whitespace-regex>
3+
*
4+
* Copyright (c) 2014 Jon Schlinkert, contributors.
5+
* Licensed under the MIT license.
6+
*/
7+
8+
'use strict';
9+
10+
module.exports = function regex() {
11+
return /^[\s\f\n\r\t\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff\x09\x0a\x0b\x0c\x0d\x20\xa0]+$/;
12+
};

package.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "whitespace-regex",
3+
"description": "Regular expression for matching the whitespace in a string.",
4+
"version": "0.1.0",
5+
"homepage": "https://github.com/jonschlinkert/whitespace-regex",
6+
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7+
"repository": "jonschlinkert/whitespace-regex",
8+
"bugs": {
9+
"url": "https://github.com/jonschlinkert/whitespace-regex/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+
"devDependencies": {
24+
"mocha": "*"
25+
},
26+
"keywords": [],
27+
"verb": {
28+
"related": {
29+
"list": [
30+
"todo-regex",
31+
"is-equal-regex",
32+
"copyright-regex"
33+
]
34+
}
35+
}
36+
}

test/fixtures/multiline.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
4+
5+
6+
7+
8+
9+

test/fixtures/spaces.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

test/fixtures/tabs.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

test/fixtures/text.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
4+
5+
6+
s

test/fixtures/varied.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
4+
5+

test/test.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
require('mocha');
3+
var fs = require('fs');
4+
var assert = require('assert');
5+
var regex = require('..');
6+
7+
function isWhitespace(str) {
8+
return regex().test(str);
9+
}
10+
11+
function read(name) {
12+
return fs.readFileSync('test/fixtures/' + name, 'utf8');
13+
}
14+
15+
describe('when non-whitespace exists:', function () {
16+
it('should return false.', function () {
17+
assert(!isWhitespace('foo'));
18+
});
19+
20+
it('should return false.', function () {
21+
assert(!isWhitespace(read('text.txt')));
22+
});
23+
});
24+
25+
describe('when non-whitespace exists:', function () {
26+
it('should return true for spaces', function () {
27+
assert(isWhitespace(' '));
28+
});
29+
it('should return true for spaces', function () {
30+
assert(isWhitespace(read('spaces.txt')));
31+
});
32+
it('should return true for tabs', function () {
33+
assert(isWhitespace(read('tabs.txt')));
34+
});
35+
it('should return true for newlines and spaces', function () {
36+
assert(isWhitespace(read('multiline.txt')));
37+
});
38+
it('should return true for varied spaces, newlines, and tabs', function () {
39+
assert(isWhitespace(read('varied.txt')));
40+
});
41+
});
42+
43+
describe('ES5-compliant whitespace', function () {
44+
it('should be true for all expected whitespace values', function () {
45+
assert(isWhitespace("\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"));
46+
});
47+
48+
it('should not be true for the zero-width space', function () {
49+
assert(!isWhitespace('\u200b'));
50+
});
51+
});

0 commit comments

Comments
 (0)