Skip to content

Commit

Permalink
zlib: refactor to use primordial instead of <string>.startsWith
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
rchougule authored and targos committed Jun 11, 2021
1 parent 716076e commit 740638d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/zlib.js
Expand Up @@ -37,6 +37,7 @@ const {
ObjectKeys,
ObjectSetPrototypeOf,
ReflectApply,
StringPrototypeStartsWith,
Symbol,
TypedArrayPrototypeFill,
Uint32Array,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
});
Expand Down

0 comments on commit 740638d

Please sign in to comment.