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 danielleadams committed Jan 12, 2021
1 parent d70824f commit b6f74b0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const {
ObjectKeys,
ObjectSetPrototypeOf,
ReflectApply,
StringPrototypeStartsWith,
Symbol,
TypedArrayPrototypeFill,
Uint32Array,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
});
Expand Down

0 comments on commit b6f74b0

Please sign in to comment.