sort-object
Advanced tools
Comparing version
{ | ||
"name": "sort-object", | ||
"description": "Sort the keys in an object", | ||
"version": "0.0.6", | ||
"description": "Sort the keys in an object.", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/helpers/sort-object", | ||
@@ -12,3 +12,3 @@ "author": { | ||
"type": "git", | ||
"url": "https://github.com/helpers/sort-object.git" | ||
"url": "git://github.com/helpers/sort-object.git" | ||
}, | ||
@@ -18,2 +18,8 @@ "bugs": { | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "Jon Schlinkert", | ||
"url": "https://github.com/helpers" | ||
} | ||
], | ||
"licenses": [ | ||
@@ -25,23 +31,27 @@ { | ||
], | ||
"main": "sort-object.js", | ||
"scripts": { | ||
"test": "mocha --reporter list" | ||
}, | ||
"keywords": [ | ||
"array", | ||
"arr", | ||
"function", | ||
"keys", | ||
"key", | ||
"order", | ||
"obj", | ||
"object", | ||
"sort" | ||
], | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
"node": ">=0.10.0" | ||
}, | ||
"dependencies": { | ||
"lodash": "~2.2.1" | ||
"scripts": { | ||
"test": "mocha -R spec" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.13.0", | ||
"benchmark": "~1.0.0" | ||
"mocha": "*", | ||
"verb": "^0.2.15" | ||
}, | ||
"keywords": [ | ||
"sort", | ||
"sort object", | ||
"sort object keys", | ||
"sort object by keys", | ||
"javascript sort" | ||
] | ||
} | ||
"dependencies": { | ||
"lodash": "^2.4.1" | ||
} | ||
} |
@@ -1,8 +0,8 @@ | ||
# sort-object [](http://badge.fury.io/js/sort-object) | ||
# sort-object [](http://badge.fury.io/js/sort-object) | ||
> Sort the keys in an object | ||
> Sort the keys in an object. | ||
## Install | ||
#### Install with [npm](npmjs.org) | ||
## Quickstart | ||
```bash | ||
@@ -12,43 +12,48 @@ npm i sort-object --save | ||
## Usage | ||
```js | ||
var sort = require('sort-object'); | ||
var outOfOrder = { | ||
'foo': 1, | ||
'baz': 2, | ||
'bar': 3 | ||
}; | ||
console.log('before: ', outOfOrder); | ||
var sortObj = require('sort-object'); | ||
``` | ||
Sort the keys on an object | ||
var inOrder = sort(outOfOrder); | ||
console.log('inOrder: ', inOrder); | ||
console.log('after: ', outOfOrder); | ||
```js | ||
console.log(sortObj({a: 1, c: 2, b: 3})); | ||
//=> {a: 1, b: 3, c: 2} | ||
``` | ||
## Run the tests | ||
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']})); | ||
```bash | ||
npm i mocha -g | ||
//=> {a: 1, b: 3} | ||
``` | ||
then run: | ||
Sort the keys using a custom function. | ||
```bash | ||
mocha | ||
```js | ||
var o = {a: 1, c: 2, e: 5, d: 4, b: 3}; | ||
var obj = sortObj(o, {fn: function (a, b) { | ||
return a < b ? -1 : 1; | ||
}}); | ||
console.log(obj); | ||
//=> {a: 1, b: 3, c: 2, d: 4, e: 5} | ||
``` | ||
## Author | ||
+ [github/doowb](https://github/doowb) | ||
**Brian Woodward** | ||
+ [github/doowb](https://github.com/doowb) | ||
+ [twitter/doowb](http://twitter.com/doowb) | ||
## License | ||
Copyright (c) 2013 Brian Woodward | ||
Licensed under the [MIT license](LICENSE-MIT). | ||
Copyright (c) 2014 Brian Woodward, contributors. | ||
Released under the MIT license | ||
*** | ||
Project created by [Assemble](https://github.com/assemble). | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 15, 2014._ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
10
25%58
7.41%11120
-4.25%206
-34.19%+ Added
- Removed
Updated