feat: adding linter for commits
This commit is contained in:
21
node_modules/compare-func/LICENSE
generated
vendored
Normal file
21
node_modules/compare-func/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Steve Mao
|
||||
|
||||
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.
|
70
node_modules/compare-func/README.md
generated
vendored
Normal file
70
node_modules/compare-func/README.md
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url]
|
||||
|
||||
> Get a compare function for array to sort
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save compare-func
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var compareFunc = require('compare-func');
|
||||
|
||||
// sort by an object property
|
||||
[{x: 'b'}, {x: 'a'}, {x: 'c'}].sort(compareFunc('x'));
|
||||
//=> [{x: 'a'}, {x: 'b'}, {x: 'c'}]
|
||||
|
||||
// sort by a nested object property
|
||||
[{x: {y: 'b'}}, {x: {y: 'a'}}].sort(compareFunc('x.y'));
|
||||
//=> [{x: {y: 'a'}}, {x: {y: 'b'}}]
|
||||
|
||||
// sort by the `x` propery, then `y`
|
||||
[{x: 'c', y: 'c'}, {x: 'b', y: 'a'}, {x: 'b', y: 'b'}].sort(compareFunc(['x', 'y']));
|
||||
//=> [{x: 'b', y: 'a'}, {x: 'b', y: 'b'}, {x: 'c', y: 'c'}]
|
||||
|
||||
// sort by the returned value
|
||||
[{x: 'b'}, {x: 'a'}, {x: 'c'}].sort(compareFunc(function(el) {
|
||||
return el.x;
|
||||
}));
|
||||
//=> [{x: 'a'}, {x: 'b'}, {x: 'c'}]
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### compareFunc([property])
|
||||
|
||||
Returns a compare function for array to sort
|
||||
|
||||
#### property
|
||||
|
||||
Type: `string`, `function` or `array` of either
|
||||
|
||||
If missing it sorts on itself.
|
||||
|
||||
The string can be a [dot path](https://github.com/sindresorhus/dot-prop) to a nested object property.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [sort-on](https://github.com/sindresorhus/sort-on) - Sort an array on an object property
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Steve Mao](https://github.com/stevemao)
|
||||
|
||||
|
||||
[npm-image]: https://badge.fury.io/js/compare-func.svg
|
||||
[npm-url]: https://npmjs.org/package/compare-func
|
||||
[travis-image]: https://travis-ci.org/stevemao/compare-func.svg?branch=master
|
||||
[travis-url]: https://travis-ci.org/stevemao/compare-func
|
||||
[daviddm-image]: https://david-dm.org/stevemao/compare-func.svg?theme=shields.io
|
||||
[daviddm-url]: https://david-dm.org/stevemao/compare-func
|
||||
[coveralls-image]: https://coveralls.io/repos/stevemao/compare-func/badge.svg
|
||||
[coveralls-url]: https://coveralls.io/r/stevemao/compare-func
|
42
node_modules/compare-func/index.js
generated
vendored
Normal file
42
node_modules/compare-func/index.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
var arrayify = require('array-ify');
|
||||
var dotPropGet = require('dot-prop').get;
|
||||
|
||||
function compareFunc(prop) {
|
||||
return function(a, b) {
|
||||
var ret = 0;
|
||||
|
||||
arrayify(prop).some(function(el) {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
if (typeof el === 'function') {
|
||||
x = el(a);
|
||||
y = el(b);
|
||||
} else if (typeof el === 'string') {
|
||||
x = dotPropGet(a, el);
|
||||
y = dotPropGet(b, el);
|
||||
} else {
|
||||
x = a;
|
||||
y = b;
|
||||
}
|
||||
|
||||
if (x === y) {
|
||||
ret = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof x === 'string' && typeof y === 'string') {
|
||||
ret = x.localeCompare(y);
|
||||
return ret !== 0;
|
||||
}
|
||||
|
||||
ret = x < y ? -1 : 1;
|
||||
return true;
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = compareFunc;
|
47
node_modules/compare-func/package.json
generated
vendored
Normal file
47
node_modules/compare-func/package.json
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "compare-func",
|
||||
"version": "2.0.0",
|
||||
"description": "Get a compare function for array to sort",
|
||||
"homepage": "https://github.com/stevemao/compare-func",
|
||||
"author": {
|
||||
"name": "Steve Mao",
|
||||
"email": "maochenyan@gmail.com",
|
||||
"url": "https://github.com/stevemao"
|
||||
},
|
||||
"repository": "stevemao/compare-func",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"compare-func",
|
||||
"arr",
|
||||
"array",
|
||||
"by",
|
||||
"compare",
|
||||
"dot",
|
||||
"get",
|
||||
"obj",
|
||||
"object",
|
||||
"prop",
|
||||
"property",
|
||||
"sort",
|
||||
"sorting"
|
||||
],
|
||||
"dependencies": {
|
||||
"array-ify": "^1.0.0",
|
||||
"dot-prop": "^5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coveralls": "^2.11.2",
|
||||
"istanbul": "^0.4.4",
|
||||
"jscs": "^3.0.5",
|
||||
"jshint": "^2.7.0",
|
||||
"mocha": "^7.1.2"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "istanbul cover _mocha -- -R spec && rm -rf ./coverage",
|
||||
"lint": "jshint *.js --exclude node_modules && jscs *.js",
|
||||
"test": "npm run-script lint && mocha"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user