+13
| module.exports = visit; | ||
| function visit(old) { | ||
| if (typeof(old) !== 'object' && old !== null) { | ||
| return old; | ||
| } | ||
| var copy = Array.isArray(old) ? [] : {}; | ||
| var keys = Object.keys(old).sort(); | ||
| keys.forEach(function(key) { | ||
| copy[key] = visit(old[key]); | ||
| }); | ||
| return copy; | ||
| } |
+1
-11
@@ -10,13 +10,3 @@ #!/usr/bin/env node | ||
| function visit(old) { | ||
| if (Array.isArray(old) || typeof(old) !== 'object') { | ||
| return old; | ||
| } | ||
| var sorted = {}; | ||
| var keys = Object.keys(old).sort(); | ||
| keys.forEach(function(key) { | ||
| sorted[key] = visit(old[key]); | ||
| }); | ||
| return sorted; | ||
| } | ||
| var visit = require('./'); | ||
@@ -23,0 +13,0 @@ var result = visit(json); |
+10
-4
| { | ||
| "name": "sort-json", | ||
| "version": "0.0.1", | ||
| "version": "1.0.0", | ||
| "description": "Takes a json-file and return a copy of the same file, but sorted", | ||
| "main": "cmd.js", | ||
| "main": "index.js", | ||
| "dependencies": {}, | ||
@@ -14,6 +14,12 @@ "bin": { | ||
| }, | ||
| "repository": "", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/kesla/sort-json.git" | ||
| }, | ||
| "author": "David Björklund <david.bjorklund@gmail.com>", | ||
| "license": "MIT", | ||
| "preferGlobal": true | ||
| "bugs": { | ||
| "url": "https://github.com/kesla/sort-json/issues" | ||
| }, | ||
| "homepage": "https://github.com/kesla/sort-json" | ||
| } |
+11
-1
| sort-json | ||
| ========= | ||
| Takes a json-file and return a copy of the same file, but sorted | ||
| Takes a json-file and return a copy of the same file, but with the keys sorted | ||
@@ -11,6 +11,16 @@ installation | ||
| usage | ||
| ----- | ||
| ```js | ||
| var sortJson = require('sort-json'); | ||
| var copy = sortJson(object); | ||
| ``` | ||
| CLI usage | ||
| --------- | ||
| `sort-json file.json` | ||
| For now sort-json takes no other arguments, so the origin file will be overritten by a sorted json file with 2-space indentation. |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance 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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1706
26.28%5
25%18
5.88%0
-100%1
-66.67%25
66.67%2
-33.33%