From 3cf319114f3d3eaf056545da7e1be0b4e1f37b1a Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sun, 31 Oct 2021 14:41:39 +0100 Subject: [PATCH] chore: replace json-stable-stringify with safe-stable-stringify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a performance improvement as the latter is actually faster. json-stable-stringify x 13,870 ops/sec ±0.72% (94 runs sampled) safe-stable-stringify x 30,367 ops/sec ±0.39% (96 runs sampled) The only difference is that objects with circular reference are from now on also accepted instead of throwing an error. --- package.json | 2 +- tests/helpers/package-cache.js | 2 +- yarn.lock | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 466fd8c6589..a89c013520a 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,6 @@ "is-language-code": "^3.1.0", "isbinaryfile": "^4.0.8", "js-yaml": "^3.14.0", - "json-stable-stringify": "^1.0.1", "leek": "0.0.24", "lodash.template": "^4.5.0", "markdown-it": "^12.0.4", @@ -115,6 +114,7 @@ "remove-types": "^1.0.0", "resolve": "^1.20.0", "resolve-package-path": "^3.1.0", + "safe-stable-stringify": "^2.2.0", "sane": "^5.0.1", "semver": "^7.3.4", "silent-error": "^1.1.1", diff --git a/tests/helpers/package-cache.js b/tests/helpers/package-cache.js index 187762711bc..0d8234d9c60 100644 --- a/tests/helpers/package-cache.js +++ b/tests/helpers/package-cache.js @@ -5,7 +5,7 @@ const path = require('path'); const quickTemp = require('quick-temp'); const Configstore = require('configstore'); const CommandGenerator = require('./command-generator'); -const stableStringify = require('json-stable-stringify'); +const stableStringify = require('safe-stable-stringify'); const symlinkOrCopySync = require('symlink-or-copy').sync; let originalWorkingDirectory = process.cwd(); diff --git a/yarn.lock b/yarn.lock index cd6a963c82a..5c39bb7d3b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6989,6 +6989,11 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" +safe-stable-stringify@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.2.0.tgz#26a52f13a6988de16a0d88e20248f38e8a7d840c" + integrity sha512-C6AuMdYPuPV/P1leplHNu0lgc2LAElq/g3TdoksDCIVtBhr78o/CH03bt/9SKqugFbKU9CUjsNlCu0fjtQzQUw== + "safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"