Skip to content

Commit 740638d

Browse files
rchouguletargos
authored andcommitted
zlib: refactor to use primordial instead of <string>.startsWith
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>
1 parent 716076e commit 740638d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/zlib.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const {
3737
ObjectKeys,
3838
ObjectSetPrototypeOf,
3939
ReflectApply,
40+
StringPrototypeStartsWith,
4041
Symbol,
4142
TypedArrayPrototypeFill,
4243
Uint32Array,
@@ -781,7 +782,9 @@ function createConvenienceMethod(ctor, sync) {
781782

782783
const kMaxBrotliParam = MathMax(...ArrayPrototypeMap(
783784
ObjectKeys(constants),
784-
(key) => (key.startsWith('BROTLI_PARAM_') ? constants[key] : 0)
785+
(key) => (StringPrototypeStartsWith(key, 'BROTLI_PARAM_') ?
786+
constants[key] :
787+
0)
785788
));
786789

787790
const brotliInitParamsArray = new Uint32Array(kMaxBrotliParam + 1);
@@ -922,7 +925,7 @@ ObjectDefineProperties(module.exports, {
922925
// These should be considered deprecated
923926
// expose all the zlib constants
924927
for (const bkey of ObjectKeys(constants)) {
925-
if (bkey.startsWith('BROTLI')) continue;
928+
if (StringPrototypeStartsWith(bkey, 'BROTLI')) continue;
926929
ObjectDefineProperty(module.exports, bkey, {
927930
enumerable: false, value: constants[bkey], writable: false
928931
});

0 commit comments

Comments
 (0)