sort-keys-recursive
Advanced tools
Comparing version 1.1.1 to 1.2.0
52
index.js
@@ -1,10 +0,44 @@ | ||
'use strict'; | ||
require('coffee-script/register'); | ||
var typeOf = require('fn-typeof'); | ||
var sort = require('./lib/SortRecursive'); | ||
'use strict' | ||
module.exports = function(something, compareFn) { | ||
var type = typeOf(something); | ||
if (sort[type]) return sort[type](something, compareFn); | ||
return something; | ||
}; | ||
var sortKeys = require('sort-keys') | ||
var kindOf = require('kind-of') | ||
function sortObjectKeys (obj, compare) { | ||
return sortKeys(obj, compare) | ||
} | ||
function sortArray (arr, compare) { | ||
return arr.slice().sort(compare) | ||
} | ||
function sortObject (obj, compare) { | ||
var result = sortObjectKeys(obj, compare) | ||
Object.keys(obj).forEach(function (key) { | ||
var current = result[key] | ||
var type = kindOf(current) | ||
if (type === 'object') { | ||
result[key] = sortObject(current, compare) | ||
return | ||
} | ||
if (type === 'array') { | ||
result[key] = sortArray(current) | ||
return | ||
} | ||
}) | ||
return result | ||
} | ||
function sort (something, compareFn) { | ||
var type = kindOf(something) | ||
if (sort[type]) return sort[type](something, compareFn) | ||
return something | ||
} | ||
sort.array = sortArray | ||
sort.object = sortObject | ||
module.exports = sort |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/Kikobeats/sort-keys-recursive", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"main": "./index.js", | ||
@@ -13,3 +13,6 @@ "author": { | ||
}, | ||
"repository": "Kikobeats/sort-keys-recursive", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/kikobeats/sort-keys-recursive.git" | ||
}, | ||
"bugs": { | ||
@@ -19,2 +22,5 @@ "url": "https://github.com/Kikobeats/sort-keys-recursive/issues" | ||
"keywords": [ | ||
"array", | ||
"deep", | ||
"deterministic", | ||
"key", | ||
@@ -25,28 +31,27 @@ "keys", | ||
"recursive", | ||
"sort" | ||
"recursively", | ||
"sort", | ||
"stable" | ||
], | ||
"dependencies": { | ||
"fn-typeof": "*", | ||
"sort-keys": "*" | ||
"kind-of": "~3.1.0", | ||
"sort-keys": "~1.1.2" | ||
}, | ||
"devDependencies": { | ||
"browserify": "*", | ||
"coffee-script": "*", | ||
"coffeeify": "*", | ||
"gulp": "*", | ||
"gulp-header": "*", | ||
"gulp-uglify": "*", | ||
"gulp-util": "*", | ||
"mocha": "*", | ||
"should": "*", | ||
"vinyl-buffer": "*", | ||
"vinyl-source-stream": "*" | ||
"ava": "latest", | ||
"coveralls": "latest", | ||
"nyc": "latest", | ||
"standard": "latest", | ||
"standard-markdown": "latest" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "sh test/test.sh" | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
"lint": "standard-markdown && standard", | ||
"pretest": "npm run lint", | ||
"test": "nyc ava" | ||
}, | ||
"license": "MIT" | ||
} |
# sort-keys-recursive | ||
[![Build Status](http://img.shields.io/travis/Kikobeats/sort-keys-recursive/master.svg?style=flat)](https://travis-ci.org/Kikobeats/sort-keys-recursive) | ||
[![Dependency status](http://img.shields.io/david/Kikobeats/sort-keys-recursive.svg?style=flat)](https://david-dm.org/Kikobeats/sort-keys-recursive) | ||
[![Dev Dependencies Status](http://img.shields.io/david/dev/Kikobeats/sort-keys-recursive.svg?style=flat)](https://david-dm.org/Kikobeats/sort-keys-recursive#info=devDependencies) | ||
[![NPM Status](http://img.shields.io/npm/dm/sort-keys-recursive.svg?style=flat)](https://www.npmjs.org/package/sort-keys-recursive) | ||
[![Gittip](http://img.shields.io/gittip/Kikobeats.svg?style=flat)](https://www.gittip.com/Kikobeats/) | ||
![Last version](https://img.shields.io/github/tag/Kikobeats/sort-keys-recursive.svg?style=flat-square) | ||
[![Build Status](https://img.shields.io/travis/Kikobeats/sort-keys-recursive/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/sort-keys-recursive) | ||
[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/sort-keys-recursive.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/sort-keys-recursive) | ||
[![Dependency status](https://img.shields.io/david/Kikobeats/sort-keys-recursive.svg?style=flat-square)](https://david-dm.org/Kikobeats/sort-keys-recursive) | ||
[![Dev Dependencies Status](https://img.shields.io/david/dev/Kikobeats/sort-keys-recursive.svg?style=flat-square)](https://david-dm.org/Kikobeats/sort-keys-recursive#info=devDependencies) | ||
[![NPM Status](https://img.shields.io/npm/dm/str-match.svg?style=flat-square)](https://www.npmjs.org/package/str-match) | ||
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/Kikobeats) | ||
@@ -22,13 +24,6 @@ > Sort the keys of an object recursively | ||
``` | ||
and later link in your HTML: | ||
```html | ||
<script src="bower_components/sort-keys-recursive/dist/sort-keys-recursive.js"></script> | ||
``` | ||
## Usage | ||
```js | ||
recursive = require('sort-keys-recursive'); | ||
var sort = require('sort-keys-recursive') | ||
@@ -43,6 +38,8 @@ var object = { | ||
b: 0 | ||
}; | ||
} | ||
console.log(recursive(object)); | ||
var output = sort(object) | ||
console.log(output) | ||
// { | ||
@@ -63,3 +60,1 @@ // a: { | ||
MIT © [Kiko Beats](http://www.kikobeats.com) | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
5
95
0
0
0
0
13053
13
58
+ Addedkind-of@~3.1.0
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-plain-obj@1.1.0(transitive)
+ Addedkind-of@3.1.0(transitive)
+ Addedsort-keys@1.1.2(transitive)
- Removedfn-typeof@*
- Removedfn-typeof@1.1.0(transitive)
- Removedis-plain-obj@4.1.0(transitive)
- Removedsort-keys@5.1.0(transitive)
Updatedsort-keys@~1.1.2