From 8f0b1c17fb540e121843c7085140c9246850ddd2 Mon Sep 17 00:00:00 2001 From: Pooja D P Date: Fri, 18 Dec 2020 02:55:43 -0800 Subject: [PATCH] lib: refactor the code to use primordials --- lib/internal/v8_prof_polyfill.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/internal/v8_prof_polyfill.js b/lib/internal/v8_prof_polyfill.js index 5f5922c5386543..9c93ef86801e67 100644 --- a/lib/internal/v8_prof_polyfill.js +++ b/lib/internal/v8_prof_polyfill.js @@ -28,6 +28,10 @@ /* eslint-disable no-restricted-globals */ module.exports = { versionCheck }; +const { + StringPrototypeSplit, + StringPrototypeReplace, +} = primordials; // Don't execute when required directly instead of being eval'd from // lib/internal/v8_prof_processor.js. This way we can test functions @@ -154,8 +158,8 @@ function macCppfiltNm(out) { } let i = 0; - filtered = filtered.split('\n'); - return out.replace(FUNC_RE, (all, prefix, postfix) => { + filtered = StringPrototypeSplit(filtered, '\n'); + return StringPrototypeReplace(out, FUNC_RE, (all, prefix, postfix) => { return prefix + (filtered[i++] || postfix); }); }