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 3af2f31
Showing
11 changed files
with
261 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,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.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,42 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"rules": { | ||
// warnings | ||
"no-unused-expressions": 1, | ||
"no-warning-comments": 1, | ||
"no-native-reassign": 1, | ||
"no-invalid-regexp": 1, | ||
"no-fallthrough": 1, | ||
"no-debugger": 1, | ||
"no-console": 1, | ||
"no-empty": 1, | ||
"radix": 1, | ||
|
||
// errors | ||
"no-shadow-restricted-names": 2, | ||
"handle-callback-err": 2, | ||
"no-self-compare": 2, | ||
"no-empty-class": 2, | ||
"no-unused-vars": 2, | ||
"no-dupe-keys": 2, | ||
"valid-typeof": 2, | ||
"no-undef": 2, | ||
|
||
// stylistic errors | ||
"quotes": [2, "single", "avoid-escape"], | ||
"no-space-before-semi": 2, | ||
"space-unary-word-ops": 2, | ||
"no-spaced-func": 2, | ||
"yoda": "always", | ||
"new-cap": 2, | ||
|
||
// mute | ||
"no-use-before-define": 0, | ||
"eol-last": 0, | ||
"strict": 0, | ||
"eqeqeq": 0, | ||
"curly": 0 | ||
} | ||
} |
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 @@ | ||
# tmp files | ||
lib-cov | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
|
||
# tmp folders | ||
pids/ | ||
logs/ | ||
results/ | ||
coverage/ | ||
|
||
# node.js | ||
node_modules/ | ||
npm-debug.log | ||
|
||
# osx | ||
.DS_Store |
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 @@ | ||
node_js: | ||
- "0.10" | ||
- "0.11" | ||
language: node_js | ||
script: "make test-travis" | ||
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" |
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,2 @@ | ||
# 1.0.0 / 2014-09-06 | ||
- init |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 | ||
|
||
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,33 @@ | ||
SRC = index.js | ||
|
||
include node_modules/make-lint/index.mk | ||
|
||
LINT_CONFIG = .eslintrc | ||
TESTS = test.js | ||
|
||
test: lint | ||
@NODE_ENV=test ./node_modules/.bin/mocha \ | ||
--require should \ | ||
$(TESTS) \ | ||
--bail | ||
|
||
test-cov: | ||
@NODE_ENV=test node \ | ||
node_modules/.bin/istanbul cover \ | ||
./node_modules/.bin/_mocha \ | ||
-- -u exports \ | ||
--require should \ | ||
$(TESTS) \ | ||
--bail | ||
|
||
test-travis: | ||
@NODE_ENV=test node \ | ||
node_modules/.bin/istanbul cover \ | ||
./node_modules/.bin/_mocha \ | ||
--report lcovonly \ | ||
-- -u exports \ | ||
--require should \ | ||
$(TESTS) \ | ||
--bail | ||
|
||
.PHONY: test |
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,33 @@ | ||
# css-class-concat | ||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Downloads][downloads-image]][downloads-url] | ||
|
||
Concatenate css classes into a single string, and remove all prepending class | ||
dots. Preps strings to be used within html tags. | ||
|
||
## Installation | ||
```bash | ||
npm install css-class-concat | ||
``` | ||
|
||
## Usage | ||
```js | ||
var classConcat = require('css-class-concat'); | ||
|
||
classConcat(['.foo', 'bar', 'barre', '.bazze-foo']); | ||
// => 'foo bar barre bazze-foo' | ||
``` | ||
|
||
## License | ||
[MIT](https://tldrlegal.com/license/mit-license) | ||
|
||
[npm-image]: https://img.shields.io/npm/v/css-class-concat.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/css-class-concat | ||
[travis-image]: https://img.shields.io/travis/yoshuawuyts/css-class-concat.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/yoshuawuyts/css-class-concat | ||
[coveralls-image]: https://img.shields.io/coveralls/yoshuawuyts/css-class-concat.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/yoshuawuyts/css-class-concat?branch=master | ||
[downloads-image]: http://img.shields.io/npm/dm/css-class-concat.svg?style=flat-square | ||
[downloads-url]: https://npmjs.org/package/css-class-concat |
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,28 @@ | ||
/** | ||
* Module dependencies | ||
*/ | ||
|
||
var assert = require('assert'); | ||
|
||
/** | ||
* Expose `concat()`. | ||
*/ | ||
|
||
module.exports = concat; | ||
|
||
/** | ||
* Concatenate css classes into | ||
* a single string. | ||
* | ||
* @param {String[]} arr | ||
* @return {String} | ||
* @api public | ||
*/ | ||
|
||
function concat(arr) { | ||
assert(Array.isArray(arr), 'css-class-concat: arr should be an array of strings'); | ||
|
||
return arr.reduce(function(prev, curr, i) { | ||
return prev + curr.replace(/(\.)/g, '') + (arr.length - 1 == i ? '' : ' '); | ||
}, ''); | ||
} |
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,30 @@ | ||
{ | ||
"name": "css-class-concat", | ||
"version": "1.0.0", | ||
"description": "Concatenate css classes into a single string and remove all prepending class dots", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"repository": "yoshuawuyts/css-class-concat", | ||
"keywords": [ | ||
"css", | ||
"strip", | ||
"dot", | ||
"concat" | ||
], | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"istanbul": "^0.3.2", | ||
"make-lint": "^1.0.1", | ||
"mocha": "^1.21.4", | ||
"should": "^4.0.4" | ||
}, | ||
"files": [ | ||
"lib", | ||
"LICENSE", | ||
"index.js", | ||
"HISTORY.md" | ||
] | ||
} |
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,31 @@ | ||
/*eslint no-unused-expressions: 0*/ | ||
|
||
/** | ||
* Module dependencies | ||
*/ | ||
|
||
var concat = require('./index'); | ||
|
||
/** | ||
* Test | ||
*/ | ||
|
||
describe('css-class-concat', function() { | ||
it('should assert argument types', function() { | ||
concat.bind(concat, 'foo') | ||
.should.throw('css-class-concat: arr should be an array of strings'); | ||
|
||
concat.bind(concat, ['foo', 'bar']) | ||
.should.not.throw('css-class-concat: arr should be an array of strings'); | ||
}); | ||
|
||
it('should concatenate classes', function() { | ||
concat(['foo', 'bar', 'baz']) | ||
.should.eql('foo bar baz'); | ||
}); | ||
|
||
it('should remove prepending dots', function() { | ||
concat(['.foo', 'bar', '.baz-ba']) | ||
.should.eql('foo bar baz-ba'); | ||
}); | ||
}); |