Skip to content

Commit 7fef846

Browse files
committed
fix: optimize adding this.algorithm to algorithms list
1 parent d90f674 commit 7fef846

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ class IntegrityStream extends MiniPass {
3030

3131
// options used for calculating stream. can't be changed.
3232
if (opts?.algorithms) {
33-
this.algorithms = Array.from(
34-
new Set(opts.algorithms.concat(this.algorithm ? [this.algorithm] : []))
35-
)
33+
this.algorithms = [...opts.algorithms]
3634
} else {
3735
this.algorithms = [...DEFAULT_ALGORITHMS]
38-
39-
if (this.algorithm !== null && this.algorithm !== DEFAULT_ALGORITHMS[0]) {
40-
this.algorithms.push(this.algorithm)
41-
}
36+
}
37+
if (this.algorithm !== null && !this.algorithms.includes(this.algorithm)) {
38+
this.algorithms.push(this.algorithm)
4239
}
4340

4441
this.hashes = this.algorithms.map(crypto.createHash)

0 commit comments

Comments
 (0)