-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e6e9a77
Showing
14 changed files
with
477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{json,remarkrc,eslintrc,sh}] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
coverage/ | ||
example.js | ||
space-separated-tokens.js | ||
space-separated-tokens.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "eslint:recommended", | ||
"rules": { | ||
"quotes": [2, "single"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
*.log | ||
coverage/ | ||
node_modules/ | ||
space-separated-tokens.js | ||
space-separated-tokens.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"excludeFiles": [ | ||
"coverage/", | ||
"node_modules/", | ||
"space-separated-tokens.js", | ||
"space-separated-tokens.min.js" | ||
], | ||
"preset": "yandex", | ||
"requireQuotedKeysInObjects": true, | ||
"disallowQuotedKeysInObjects": false, | ||
"maximumLineLength": { | ||
"value": 79, | ||
"allExcept": [ | ||
"regex", | ||
"urlComments" | ||
] | ||
}, | ||
"jsDoc": { | ||
"checkAnnotations": "jsdoc3", | ||
"checkParamExistence": true, | ||
"checkParamNames": true, | ||
"checkRedundantAccess": true, | ||
"checkRedundantParams": true, | ||
"checkRedundantReturns": true, | ||
"checkReturnTypes": true, | ||
"checkTypes": "strictNativeCase", | ||
"enforceExistence": true, | ||
"requireHyphenBeforeDescription": true, | ||
"requireNewlineAfterDescription": true, | ||
"requireParamDescription": true, | ||
"requireParamTypes": true, | ||
"requireReturnDescription": true, | ||
"requireReturnTypes": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"output": true, | ||
"plugins": [ | ||
"lint", | ||
"github", | ||
"comment-config", | ||
"usage", | ||
"validate-links" | ||
], | ||
"settings": { | ||
"bullet": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
language: node_js | ||
node_js: | ||
- '0.10' | ||
- '0.11' | ||
- '0.12' | ||
- '4.0' | ||
- '5.0' | ||
sudo: false | ||
after_script: npm install codecov.io && cat ./coverage/lcov.info | codecov | ||
deploy: | ||
- provider: npm | ||
email: tituswormer@gmail.com | ||
api_key: | ||
secure: Fmjc44swIvN12fiN++d+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QkfRHOHSgcC/FPMH1Iooupa9cH0x+YbqRj8SbA0vJQNn+OiuEQsMZWz96aShK3jZx6g61NN4EbjO3PtZ2wQKJLfJkDx11pu5K7CydAHu6Y8VyWu9TKF6sGFLDZHq9Baaov4wtfUxWnRX1KY5Ovhw218sgRTtIAD6f8jVsKSflttuIw7bSNHHnc9JvS5+mBTuR3e88EpuNuXjTwv0wmZdQC+h4sOdtWZlEYPfiFpwxPTn0VlNBUbaVM5pY5ba/pI9ICAKzSslo75C+hE61IHRNaSPv1lHqCtQqJxfjv/OJXFXB0TkJOVRHjvHeQtrjgjQ5Qd9Ie54= | ||
file: | ||
- "space-separated-tokens.js" | ||
- "space-separated-tokens.min.js" | ||
on: | ||
tags: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Dependencies: | ||
var spaceSeparated = require('./index.js'); | ||
|
||
// Parsing: | ||
var values = spaceSeparated.parse(' foo\tbar\nbaz '); | ||
|
||
// Yields: | ||
console.log('js', require('util').inspect(values)); | ||
|
||
// Compiling: | ||
var value = spaceSeparated.stringify(values); | ||
|
||
// Yields: | ||
console.log('js', require('util').inspect(value)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!--remark setext--> | ||
|
||
<!--lint disable no-multiple-toplevel-headings--> | ||
|
||
0.0.0 / 2016-02-22 | ||
================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2016 Titus Wormer | ||
* @license MIT | ||
* @module space-separated-tokens | ||
* @fileoverview Parse and stringify space-separated tokens. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/* eslint-env commonjs */ | ||
|
||
/* | ||
* Dependencies. | ||
*/ | ||
|
||
var trim = require('trim'); | ||
|
||
/* | ||
* Constants. | ||
*/ | ||
|
||
var EMPTY = ''; | ||
|
||
/* | ||
* Characters. | ||
*/ | ||
|
||
var C_SPACE = ' '; | ||
|
||
/* | ||
* Expressions. | ||
* | ||
* HTML white-space is slightly different from JavaScript’s | ||
* `\s`, as the latter includes vertical tabs. | ||
*/ | ||
|
||
var RE_WHITE_SPACE = /[\ \t\n\r\f]+/g; | ||
|
||
/** | ||
* Parse space-separated tokens to an array. | ||
* | ||
* @param {string} value - Attribute-value to parse. | ||
* @return {Array.<string>} - Tokens. | ||
*/ | ||
function parse(value) { | ||
var input = trim(String(value || EMPTY)); | ||
|
||
if (input === EMPTY) { | ||
return []; | ||
} | ||
|
||
return input.split(RE_WHITE_SPACE); | ||
} | ||
|
||
/** | ||
* Compile an array to space-separated tokens. | ||
* | ||
* @param {Array.<string>} values - Tokens. | ||
* @return {string} - Space-separated tokens. | ||
*/ | ||
function stringify(values) { | ||
return trim(values.join(C_SPACE)); | ||
} | ||
|
||
/* | ||
* Expose. | ||
*/ | ||
|
||
module.exports = { | ||
'parse': parse, | ||
'stringify': stringify | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"name": "space-separated-tokens", | ||
"version": "0.0.0", | ||
"description": "Parse and stringify space-separated tokens", | ||
"license": "MIT", | ||
"keywords": [ | ||
"dom", | ||
"html", | ||
"space", | ||
"separated", | ||
"tokens", | ||
"parse", | ||
"stringify" | ||
], | ||
"dependencies": { | ||
"trim": "0.0.1" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/space-separated-tokens.git" | ||
}, | ||
"bugs": "https://github.com/wooorm/space-separated-tokens/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
], | ||
"devDependencies": { | ||
"browserify": "^13.0.0", | ||
"eslint": "^2.0.0", | ||
"esmangle": "^1.0.1", | ||
"istanbul": "^0.4.0", | ||
"jscs": "^2.0.0", | ||
"jscs-jsdoc": "^1.0.0", | ||
"remark": "^4.0.0", | ||
"remark-comment-config": "^3.0.0", | ||
"remark-github": "^4.0.1", | ||
"remark-lint": "^3.0.0", | ||
"remark-usage": "^3.0.0", | ||
"remark-validate-links": "^3.0.0", | ||
"tape": "^4.4.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . --quiet --frail", | ||
"build-bundle": "browserify index.js --bare -s spaceSeparatedTokens > space-separated-tokens.js", | ||
"build-mangle": "esmangle space-separated-tokens.js > space-separated-tokens.min.js", | ||
"build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
"lint-api": "eslint .", | ||
"lint-style": "jscs --reporter inline .", | ||
"lint": "npm run lint-api && npm run lint-style", | ||
"test-api": "node test.js", | ||
"test-coverage": "istanbul cover test.js", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# space-separated-tokens [![Build Status][build-badge]][build-page] [![Coverage Status][coverage-badge]][coverage-page] | ||
|
||
Parse and stringify space-separated tokens according to the [spec][]. | ||
|
||
## Installation | ||
|
||
[npm][]: | ||
|
||
```bash | ||
npm install space-separated-tokens | ||
``` | ||
|
||
**space-separated-tokens** is also available as an AMD, CommonJS, and | ||
globals module, [uncompressed and compressed][releases]. | ||
|
||
## Usage | ||
|
||
Dependencies: | ||
|
||
```javascript | ||
var spaceSeparated = require('space-separated-tokens'); | ||
``` | ||
|
||
Parsing: | ||
|
||
```javascript | ||
var values = spaceSeparated.parse(' foo\tbar\nbaz '); | ||
``` | ||
|
||
Yields: | ||
|
||
```js | ||
[ 'foo', 'bar', 'baz' ] | ||
``` | ||
|
||
Compiling: | ||
|
||
```javascript | ||
var value = spaceSeparated.stringify(values); | ||
``` | ||
|
||
Yields: | ||
|
||
```js | ||
'foo bar baz' | ||
``` | ||
|
||
## API | ||
|
||
### `spaceSeparated.parse(value)` | ||
|
||
Parse space-separated tokens to an array of strings, according to the [spec][]. | ||
|
||
* `value` (`string`) — space-separated tokens. | ||
|
||
**Returns**: `Array.<string>` — List of tokens. | ||
|
||
### `spaceSeparated.stringify(values)` | ||
|
||
Compile an array of strings to space-separated tokens. | ||
Note that it’s not possible to specify empty or white-space only values. | ||
|
||
* `values` (`Array.<string>`) — List of tokens. | ||
|
||
**Returns**: `string` — Space-separated tokens. | ||
|
||
## License | ||
|
||
[MIT][license] © [Titus Wormer][author] | ||
|
||
<!-- Definition --> | ||
|
||
[build-badge]: https://img.shields.io/travis/wooorm/space-separated-tokens.svg | ||
|
||
[build-page]: https://travis-ci.org/wooorm/space-separated-tokens | ||
|
||
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/space-separated-tokens.svg | ||
|
||
[coverage-page]: https://codecov.io/github/wooorm/space-separated-tokens?branch=master | ||
|
||
[npm]: https://docs.npmjs.com/cli/install | ||
|
||
[releases]: https://github.com/wooorm/space-separated-tokens/releases | ||
|
||
[license]: LICENSE | ||
|
||
[author]: http://wooorm.com | ||
|
||
[spec]: https://html.spec.whatwg.org/#space-separated-tokens |
Oops, something went wrong.