Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0bbbe0e

Browse files
committed
Remove dependency on jsonify
it's unlicensed which means that packages that depend on it (even transitively) can't be used in organizations that require explicit permission to use or copy a work.
1 parent e43ca2a commit 0bbbe0e

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

‎index.js‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var json = typeof JSON !== 'undefined' ? JSON : require('jsonify');
2-
31
module.exports = function (obj, opts) {
42
if (!opts) opts = {};
53
if (typeof opts === 'function') opts = { cmp: opts };
@@ -33,19 +31,19 @@ module.exports = function (obj, opts) {
3331
return;
3432
}
3533
if (typeof node !== 'object' || node === null) {
36-
return json.stringify(node);
34+
return JSON.stringify(node);
3735
}
3836
if (isArray(node)) {
3937
var out = [];
4038
for (var i = 0; i < node.length; i++) {
41-
var item = stringify(node, i, node[i], level+1) || json.stringify(null);
39+
var item = stringify(node, i, node[i], level+1) || JSON.stringify(null);
4240
out.push(indent + space + item);
4341
}
4442
return '[' + out.join(',') + indent + ']';
4543
}
4644
else {
4745
if (seen.indexOf(node) !== -1) {
48-
if (cycles) return json.stringify('__cycle__');
46+
if (cycles) return JSON.stringify('__cycle__');
4947
throw new TypeError('Converting circular structure to JSON');
5048
}
5149
else seen.push(node);
@@ -58,7 +56,7 @@ module.exports = function (obj, opts) {
5856

5957
if(!value) continue;
6058

61-
var keyValue = json.stringify(key)
59+
var keyValue = JSON.stringify(key)
6260
+ colonSeparator
6361
+ value;
6462
;

‎package.json‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
2-
"name": "json-stable-stringify",
2+
"name": "@samn/json-stable-stringify",
33
"version": "1.0.1",
4-
"description": "deterministic JSON.stringify() with custom sorting to get deterministic hashes from stringified results",
4+
"description": "deterministic JSON.stringify() with custom sorting to get deterministic hashes from stringified results, with no public domain dependencies",
55
"main": "index.js",
66
"dependencies": {
7-
"jsonify": "~0.0.0"
87
},
98
"devDependencies": {
109
"tape": "~1.0.4"
@@ -24,9 +23,9 @@
2423
},
2524
"repository": {
2625
"type": "git",
27-
"url": "git://github.com/substack/json-stable-stringify.git"
26+
"url": "git://github.com/samn/json-stable-stringify.git"
2827
},
29-
"homepage": "https://github.com/substack/json-stable-stringify",
28+
"homepage": "https://github.com/samn/json-stable-stringify",
3029
"keywords": [
3130
"json",
3231
"stringify",

‎readme.markdown‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# json-stable-stringify
22

3+
This is the same as https://github.com/substack/json-stable-stringify but it doesn't depend on libraries without licenses (jsonify).
4+
35
deterministic version of `JSON.stringify()` so you can get a consistent hash
46
from stringified results
57

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /