zlib: refactor to use primordial instead of <string>.startsWith

PR-URL: https://github.com/nodejs/node/pull/36718
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
This commit is contained in:
Rohan Chougule 2021-01-01 14:28:23 +05:30 committed by Yash Ladha
parent a3606f25dc
commit 7a6af022e6
No known key found for this signature in database
GPG Key ID: C2BEEFCCB74D6EF0

View File

@ -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
});