From 93c271ec5d7ffc3f68b3ced3d15170387f9ab6c9 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Fri, 7 Jun 2024 17:57:13 -0700 Subject: [PATCH] feat(support): remove unleakString as no usage (#20221) BREAKING CHANGE: Remove unleakString since it is now in appium/logger --- packages/support/lib/util.js | 13 ------------- packages/support/test/unit/util.spec.js | 14 -------------- 2 files changed, 27 deletions(-) diff --git a/packages/support/lib/util.js b/packages/support/lib/util.js index 1c155e279..82f0f1d4a 100644 --- a/packages/support/lib/util.js +++ b/packages/support/lib/util.js @@ -358,18 +358,6 @@ function quote(args) { return shellQuote(_.castArray(args)); } -/** - * This function is necessary to workaround unexpected memory leaks - * caused by NodeJS string interning - * behavior described in https://bugs.chromium.org/p/v8/issues/detail?id=2869 - * - * @param {any} s - The string to unleak - * @return {string} Either the unleaked string or the original object converted to string - */ -function unleakString(s) { - return ` ${s}`.substring(1); -} - /** * @typedef PluralizeOptions * @property {boolean} [inclusive=false] - Whether to prefix with the number (e.g., 3 ducks) @@ -555,7 +543,6 @@ export { compareVersions, coerceVersion, quote, - unleakString, jsonStringify, pluralize, GiB, diff --git a/packages/support/test/unit/util.spec.js b/packages/support/test/unit/util.spec.js index 12f2fdae7..3eeb1f1c7 100644 --- a/packages/support/test/unit/util.spec.js +++ b/packages/support/test/unit/util.spec.js @@ -503,20 +503,6 @@ describe('util', function () { }); }); - describe('unleakString', function () { - it('should unleak a string', function () { - util.unleakString('yolo').should.eql('yolo'); - }); - it('should unleak a multiline string', function () { - util.unleakString(' yolo\nbolo ').should.eql(' yolo\nbolo '); - }); - it('should convert an object to a string', function () { - for (const obj of [{}, null, undefined, [], 0]) { - util.unleakString(obj).should.eql(`${obj}`); - } - }); - }); - describe('pluralize', function () { /* * The pluralize library (https://github.com/blakeembrey/pluralize)