This commit is contained in:
14
node_modules/sort-object/.gitattributes
generated
vendored
Normal file
14
node_modules/sort-object/.gitattributes
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# Enforce Unix newlines
|
||||
*.* text eol=lf
|
||||
*.css text eol=lf
|
||||
*.html text eol=lf
|
||||
*.js text eol=lf
|
||||
*.json text eol=lf
|
||||
*.less text eol=lf
|
||||
*.md text eol=lf
|
||||
*.yml text eol=lf
|
||||
|
||||
*.jpg binary
|
||||
*.gif binary
|
||||
*.png binary
|
||||
*.jpeg binary
|
||||
22
node_modules/sort-object/.jshintrc
generated
vendored
Normal file
22
node_modules/sort-object/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"esnext": true,
|
||||
"boss": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"eqnull": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"node": true,
|
||||
"sub": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"globals": {
|
||||
"define": true,
|
||||
"before": true,
|
||||
"after": true,
|
||||
"describe": true,
|
||||
"it": true
|
||||
}
|
||||
}
|
||||
52
node_modules/sort-object/.npmignore
generated
vendored
Normal file
52
node_modules/sort-object/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
# Numerous always-ignore extensions
|
||||
*.csv
|
||||
*.dat
|
||||
*.diff
|
||||
*.err
|
||||
*.gz
|
||||
*.log
|
||||
*.orig
|
||||
*.out
|
||||
*.pid
|
||||
*.rar
|
||||
*.rej
|
||||
*.seed
|
||||
*.swo
|
||||
*.swp
|
||||
*.vi
|
||||
*.yo-rc.json
|
||||
*.zip
|
||||
*~
|
||||
.ruby-version
|
||||
lib-cov
|
||||
npm-debug.log
|
||||
|
||||
# Always-ignore dirs
|
||||
/bower_components/
|
||||
/node_modules/
|
||||
/temp/
|
||||
/tmp/
|
||||
/vendor/
|
||||
_gh_pages
|
||||
|
||||
# OS or Editor folders
|
||||
*.esproj
|
||||
*.komodoproject
|
||||
.komodotools
|
||||
*.sublime-*
|
||||
._*
|
||||
.cache
|
||||
.DS_Store
|
||||
.idea
|
||||
.project
|
||||
.settings
|
||||
.tmproj
|
||||
nbproject
|
||||
Thumbs.db
|
||||
|
||||
# grunt-html-validation
|
||||
validation-status.json
|
||||
validation-report.json
|
||||
|
||||
# misc
|
||||
TODO.md
|
||||
110
node_modules/sort-object/.verbrc.md
generated
vendored
Normal file
110
node_modules/sort-object/.verbrc.md
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
---
|
||||
username: doowb
|
||||
---
|
||||
# {%= name %} {%= badge("fury") %}
|
||||
|
||||
> {%= description %}
|
||||
|
||||
## Install
|
||||
{%= include("install-npm", {save: true}) %}
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var sortObj = require('{%= name %}');
|
||||
```
|
||||
|
||||
By default, the keys on an object will be sorted in descending order:
|
||||
|
||||
```js
|
||||
console.log(sortObj({a: 1, c: 2, b: 3}));
|
||||
//=> {a: 1, b: 3, c: 2}
|
||||
```
|
||||
|
||||
The second param can be an object of `options` OR an array of `keys`:
|
||||
|
||||
**object**
|
||||
|
||||
```js
|
||||
console.log(sortObj({a: 1, c: 2, b: 3}, {keys: ['a', 'b']}));
|
||||
//=> {a: 1, b: 3}
|
||||
```
|
||||
|
||||
**array**
|
||||
|
||||
```js
|
||||
console.log(sortObj({a: 1, c: 2, b: 3}, ['a', 'c']));
|
||||
//=> {a: 1, c: 2}
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
* `keys` {Array} The returned object will contain only the specified keys, in the same order.
|
||||
* `sort` {Function} Sort function to sort the keys using JavaScript's `.sort()` method.
|
||||
* `sortOrder` {String} Valid values are `desc` or `asc`, case insensitive.
|
||||
* `sortBy` {String} Sort function that is passed the entire object, rather than just the keys - as with the `.sort()` method.
|
||||
|
||||
### options.keys
|
||||
|
||||
Create a new object with only the given keys.
|
||||
|
||||
```js
|
||||
var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
|
||||
console.log(sortObj(o, {keys: ['a', 'b']}));
|
||||
|
||||
//=> {a: 1, b: 3}
|
||||
```
|
||||
|
||||
### options.sort
|
||||
|
||||
Function to be passed to javascript's `.sort()` method:
|
||||
|
||||
```js
|
||||
var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
|
||||
var obj = sortObj(o, {
|
||||
sort: function (a, b) {
|
||||
return a < b ? -1 : 1;
|
||||
}
|
||||
});
|
||||
console.log(obj);
|
||||
//=> {a: 1, b: 3, c: 2, d: 4, e: 5}
|
||||
```
|
||||
|
||||
### options.sortOrder
|
||||
|
||||
Valid values are `desc` or `asc`, case insensitive:
|
||||
|
||||
```js
|
||||
var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
|
||||
console.log(sortObj(o, {sortOrder: 'ASC'}));
|
||||
//=> {e: 5, d: 4, c: 3, b: 2, a: 1}
|
||||
```
|
||||
|
||||
### options.sortBy
|
||||
|
||||
Function that returns an array of keys to sort by:
|
||||
|
||||
```js
|
||||
var old = {one: 'aa', two: 'bc', three: 'ab'};
|
||||
var o = sortObj(old, {
|
||||
sortBy: function (obj) {
|
||||
var arr = [];
|
||||
Object.keys(obj).filter(function(key) {
|
||||
if (/^a/.test(obj[key])) arr.push(key);
|
||||
});
|
||||
return arr.reverse();
|
||||
}
|
||||
});
|
||||
//=> {three: 'ab', one: 'aa'}
|
||||
```
|
||||
|
||||
## Author
|
||||
{%= include("author") %}
|
||||
|
||||
## License
|
||||
{%= copyright() %}
|
||||
{%= license() %}
|
||||
|
||||
***
|
||||
|
||||
{%= include("footer") %}
|
||||
22
node_modules/sort-object/LICENSE-MIT
generated
vendored
Normal file
22
node_modules/sort-object/LICENSE-MIT
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2014 Brian Woodward, Jon Schlinkert, contributors.
|
||||
|
||||
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.
|
||||
115
node_modules/sort-object/README.md
generated
vendored
Normal file
115
node_modules/sort-object/README.md
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
# sort-object [](http://badge.fury.io/js/sort-object)
|
||||
|
||||
> Sort the keys in an object.
|
||||
|
||||
## Install
|
||||
#### Install with [npm](npmjs.org)
|
||||
|
||||
```bash
|
||||
npm i sort-object --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var sortObj = require('sort-object');
|
||||
```
|
||||
|
||||
By default, the keys on an object will be sorted in descending order:
|
||||
|
||||
```js
|
||||
console.log(sortObj({a: 1, c: 2, b: 3}));
|
||||
//=> {a: 1, b: 3, c: 2}
|
||||
```
|
||||
|
||||
The second param can be an object of `options` OR an array of `keys`:
|
||||
|
||||
**object**
|
||||
|
||||
```js
|
||||
console.log(sortObj({a: 1, c: 2, b: 3}, {keys: ['a', 'b']}));
|
||||
//=> {a: 1, b: 3}
|
||||
```
|
||||
|
||||
**array**
|
||||
|
||||
```js
|
||||
console.log(sortObj({a: 1, c: 2, b: 3}, ['a', 'c']));
|
||||
//=> {a: 1, c: 2}
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
* `keys` {Array} The returned object will contain only the specified keys, in the same order.
|
||||
* `sort` {Function} Sort function to sort the keys using JavaScript's `.sort()` method.
|
||||
* `sortOrder` {String} Valid values are `desc` or `asc`, case insensitive.
|
||||
* `sortBy` {String} Sort function that is passed the entire object, rather than just the keys - as with the `.sort()` method.
|
||||
|
||||
### options.keys
|
||||
|
||||
Create a new object with only the given keys.
|
||||
|
||||
```js
|
||||
var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
|
||||
console.log(sortObj(o, {keys: ['a', 'b']}));
|
||||
|
||||
//=> {a: 1, b: 3}
|
||||
```
|
||||
|
||||
### options.sort
|
||||
|
||||
Function to be passed to javascript's `.sort()` method:
|
||||
|
||||
```js
|
||||
var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
|
||||
var obj = sortObj(o, {
|
||||
sort: function (a, b) {
|
||||
return a < b ? -1 : 1;
|
||||
}
|
||||
});
|
||||
console.log(obj);
|
||||
//=> {a: 1, b: 3, c: 2, d: 4, e: 5}
|
||||
```
|
||||
|
||||
### options.sortOrder
|
||||
|
||||
Valid values are `desc` or `asc`, case insensitive:
|
||||
|
||||
```js
|
||||
var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
|
||||
console.log(sortObj(o, {sortOrder: 'ASC'}));
|
||||
//=> {e: 5, d: 4, c: 3, b: 2, a: 1}
|
||||
```
|
||||
|
||||
### options.sortBy
|
||||
|
||||
Function that returns an array of keys to sort by:
|
||||
|
||||
```js
|
||||
var old = {one: 'aa', two: 'bc', three: 'ab'};
|
||||
var o = sortObj(old, {
|
||||
sortBy: function (obj) {
|
||||
var arr = [];
|
||||
Object.keys(obj).filter(function(key) {
|
||||
if (/^a/.test(obj[key])) arr.push(key);
|
||||
});
|
||||
return arr.reverse();
|
||||
}
|
||||
});
|
||||
//=> {three: 'ab', one: 'aa'}
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Brian Woodward**
|
||||
|
||||
+ [github/doowb](https://github.com/doowb)
|
||||
+ [twitter/doowb](http://twitter.com/doowb)
|
||||
|
||||
## License
|
||||
Copyright (c) 2014 Brian Woodward, contributors.
|
||||
Released under the MIT license
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 24, 2014._
|
||||
66
node_modules/sort-object/index.js
generated
vendored
Normal file
66
node_modules/sort-object/index.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/*!
|
||||
* sort-keys <https://github.com/helpers/sort-keys>
|
||||
*
|
||||
* Copyright (c) 2014 Brian Woodward, Jon Schlinkert, contributors.
|
||||
* Licensed under the MIT License
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var sortDesc = require('sort-desc');
|
||||
var sortAsc = require('sort-asc');
|
||||
|
||||
|
||||
module.exports = function (obj, options) {
|
||||
var sort = {desc: sortDesc, asc: sortAsc};
|
||||
var fn, opts = {}, keys = Object.keys(obj);
|
||||
|
||||
// if `options` is an array, assume it's keys
|
||||
if (Array.isArray(options)) {
|
||||
opts.keys = options;
|
||||
options = {};
|
||||
|
||||
// if `options` is a function, assume it's a sorting function
|
||||
} else if (typeof options === 'function') {
|
||||
fn = options;
|
||||
} else {
|
||||
for (var opt in options) {
|
||||
if (options.hasOwnProperty(opt)) {
|
||||
opts[opt] = options[opt]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Default sort order is descending
|
||||
fn = opts.sort || sortDesc;
|
||||
|
||||
if (Boolean(opts.sortOrder)) {
|
||||
fn = sort[opts.sortOrder.toLowerCase()];
|
||||
}
|
||||
|
||||
if (Boolean(opts.sortBy)) {
|
||||
keys = opts.sortBy(obj);
|
||||
fn = null;
|
||||
}
|
||||
|
||||
if (Boolean(opts.keys)) {
|
||||
keys = opts.keys;
|
||||
if (!opts.sort && !opts.sortOrder && !opts.sortBy) {
|
||||
fn = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (fn) {
|
||||
keys = keys.sort(fn);
|
||||
}
|
||||
|
||||
var o = {};
|
||||
var len = keys.length;
|
||||
var i = -1;
|
||||
|
||||
while (++i < len) {
|
||||
o[keys[i]] = obj[keys[i]];
|
||||
}
|
||||
|
||||
return o;
|
||||
};
|
||||
61
node_modules/sort-object/package.json
generated
vendored
Normal file
61
node_modules/sort-object/package.json
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "sort-object",
|
||||
"description": "Sort the keys in an object.",
|
||||
"version": "0.3.2",
|
||||
"homepage": "https://github.com/helpers/sort-object",
|
||||
"author": {
|
||||
"name": "Brian Woodward",
|
||||
"url": "https://github.com/doowb"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/helpers/sort-object.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/helpers/sort-object/issues"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Jon Schlinkert",
|
||||
"url": "https://github.com/helpers"
|
||||
}
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/helpers/sort-object/blob/master/LICENSE-MIT"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
"arr",
|
||||
"array",
|
||||
"function",
|
||||
"js",
|
||||
"key",
|
||||
"keys",
|
||||
"obj",
|
||||
"object",
|
||||
"order",
|
||||
"re",
|
||||
"re-order",
|
||||
"sort",
|
||||
"util",
|
||||
"utils"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha -R spec"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "^4.0.4",
|
||||
"verb": "^0.2.15"
|
||||
},
|
||||
"dependencies": {
|
||||
"sort-asc": "^0.1.0",
|
||||
"sort-desc": "^0.1.1"
|
||||
}
|
||||
}
|
||||
125
node_modules/sort-object/test.js
generated
vendored
Normal file
125
node_modules/sort-object/test.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
/*!
|
||||
* sort-keys <https://github.com/helpers/sort-keys>
|
||||
*
|
||||
* Copyright (c) 2014 Brian Woodward, Jon Schlinkert, contributors.
|
||||
* Licensed under the MIT License
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var should = require('should');
|
||||
var assert = require('assert');
|
||||
var sortAsc = require('sort-asc');
|
||||
var sortDesc = require('sort-desc');
|
||||
var sortObj = require('./');
|
||||
|
||||
describe('sort object', function () {
|
||||
it('should create a new object with only the given keys.', function () {
|
||||
var o = {a: 1, c: 2, b: 3};
|
||||
var actual = sortObj(o, {keys: ['a', 'b']});
|
||||
|
||||
Object.keys(actual)[0].should.equal('a');
|
||||
Object.keys(actual)[1].should.equal('b');
|
||||
actual.should.not.have.property('c');
|
||||
});
|
||||
|
||||
it('should sort the keys on an object with alphabetical keys', function () {
|
||||
var o = {a: 1, c: 2, b: 3};
|
||||
var actual = sortObj(o);
|
||||
|
||||
Object.keys(actual)[0].should.equal('a');
|
||||
Object.keys(actual)[1].should.equal('b');
|
||||
Object.keys(actual)[2].should.equal('c');
|
||||
});
|
||||
|
||||
it('should sort the keys on an object with numerical keys', function () {
|
||||
var o = {1: 1, 3: 3, 2: 2};
|
||||
var actual = sortObj(o);
|
||||
|
||||
Object.keys(actual)[0].should.equal('1');
|
||||
Object.keys(actual)[1].should.equal('2');
|
||||
Object.keys(actual)[2].should.equal('3');
|
||||
});
|
||||
|
||||
it('should sort the keys on an object in descending order.', function () {
|
||||
var o = {a: 1, c: 2, b: 3};
|
||||
var actual = sortObj(o, {sortOrder: 'desc'});
|
||||
|
||||
Object.keys(actual)[0].should.equal('a');
|
||||
Object.keys(actual)[1].should.equal('b');
|
||||
Object.keys(actual)[2].should.equal('c');
|
||||
});
|
||||
|
||||
it('should sort the keys on an object in ascending order.', function () {
|
||||
var o = {a: 1, c: 2, b: 3};
|
||||
var actual = sortObj(o, {sortOrder: 'asc'});
|
||||
|
||||
Object.keys(actual)[0].should.equal('c');
|
||||
Object.keys(actual)[1].should.equal('b');
|
||||
Object.keys(actual)[2].should.equal('a');
|
||||
});
|
||||
|
||||
it('should sort the keys using a custom function.', function () {
|
||||
var o = {a: 1, c: 2, e: 5, d: 4, b: 3};
|
||||
var actual = sortObj(o, {
|
||||
sort: function (a, b) {
|
||||
return a < b ? -1 : 1;
|
||||
}
|
||||
});
|
||||
actual.should.eql({a: 1, b: 3, c: 2, d: 4, e: 5});
|
||||
|
||||
Object.keys(actual)[0].should.equal('a');
|
||||
Object.keys(actual)[1].should.equal('b');
|
||||
Object.keys(actual)[2].should.equal('c');
|
||||
});
|
||||
|
||||
it('should sort keys to the order in the given array.', function () {
|
||||
var o = sortObj({a: 'a', b: 'b', c: 'c'}, ['c', 'a', 'b']);
|
||||
|
||||
Object.keys(o)[0].should.equal('c');
|
||||
Object.keys(o)[1].should.equal('a');
|
||||
Object.keys(o)[2].should.equal('b');
|
||||
});
|
||||
|
||||
it('should use a function to sort keys in the given array.', function () {
|
||||
var o = sortObj({a: 'a', b: 'b', c: 'c'}, {
|
||||
keys: ['c', 'a'],
|
||||
sort: sortDesc
|
||||
});
|
||||
|
||||
Object.keys(o)[0].should.equal('a');
|
||||
Object.keys(o)[1].should.equal('c');
|
||||
o.should.not.have.property('b');
|
||||
});
|
||||
|
||||
it('should use a function to sort keys in the given array.', function () {
|
||||
var o = sortObj({a: 'a', b: 'b', c: 'c'}, {
|
||||
keys: ['b', 'a'],
|
||||
sort: sortAsc
|
||||
});
|
||||
|
||||
Object.keys(o)[0].should.equal('b');
|
||||
Object.keys(o)[1].should.equal('a');
|
||||
o.should.not.have.property('c');
|
||||
});
|
||||
|
||||
|
||||
it('should use a `sortBy` function to return an array of keys to sort by.', function () {
|
||||
var old = {one: 'aa', two: 'bc', three: 'ab'};
|
||||
var o = sortObj(old, {
|
||||
sortBy: function (obj) {
|
||||
var arr = [];
|
||||
Object.keys(obj).filter(function(key) {
|
||||
if (/^a/.test(obj[key])) {
|
||||
arr.push(key);
|
||||
}
|
||||
});
|
||||
return arr.reverse();
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(o).length.should.equal(2);
|
||||
Object.keys(o)[0].should.equal('three');
|
||||
Object.keys(o)[1].should.equal('one');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user