From 740638de0ff6a9a34a142293dbb3bbd9c75d4952 Mon Sep 17 00:00:00 2001 From: Rohan Chougule Date: Fri, 1 Jan 2021 14:28:23 +0530 Subject: [PATCH] zlib: refactor to use primordial instead of .startsWith PR-URL: https://github.com/nodejs/node/pull/36718 Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Pooja D P --- lib/zlib.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/zlib.js b/lib/zlib.js index d5228e28e9a89a..4cc45a7c26d8b2 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -37,6 +37,7 @@ const { ObjectKeys, ObjectSetPrototypeOf, ReflectApply, + StringPrototypeStartsWith, Symbol, TypedArrayPrototypeFill, Uint32Array, @@ -781,7 +782,9 @@ function createConvenienceMethod(ctor, sync) { const kMaxBrotliParam = MathMax(...ArrayPrototypeMap( ObjectKeys(constants), - (key) => (key.startsWith('BROTLI_PARAM_') ? constants[key] : 0) + (key) => (StringPrototypeStartsWith(key, 'BROTLI_PARAM_') ? + constants[key] : + 0) )); const brotliInitParamsArray = new Uint32Array(kMaxBrotliParam + 1); @@ -922,7 +925,7 @@ ObjectDefineProperties(module.exports, { // These should be considered deprecated // expose all the zlib constants for (const bkey of ObjectKeys(constants)) { - if (bkey.startsWith('BROTLI')) continue; + if (StringPrototypeStartsWith(bkey, 'BROTLI')) continue; ObjectDefineProperty(module.exports, bkey, { enumerable: false, value: constants[bkey], writable: false });