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
  • Loading branch information
rchougule committed Jan 1, 2021
1 parent 51b4367 commit 0665753
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 0665753

Please sign in to comment.