From b6f74b0b09d103178dbea69451e4ce3be54ed21a 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 cb7e0cff40e48e..1d1426635ca99b 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -37,6 +37,7 @@ const { ObjectKeys, ObjectSetPrototypeOf, ReflectApply, + StringPrototypeStartsWith, Symbol, TypedArrayPrototypeFill, Uint32Array, @@ -786,7 +787,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); @@ -927,7 +930,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 });