Skip to content

Commit 2cc630a

Browse files
committed
fix for older Node version
1 parent 8ebcdb4 commit 2cc630a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,28 @@ function Tokens (options) {
5353
return new Tokens(options)
5454
}
5555

56-
var opts = Object.assign({}, DefaultOptions, options || {})
56+
var opts = options || {}
57+
58+
var saltLength = opts.saltLength !== undefined
59+
? opts.saltLength
60+
: DefaultOptions.saltLength
5761

58-
var saltLength = opts.saltLength
5962

6063
if (typeof saltLength !== 'number' || !isFinite(saltLength) || saltLength < 1) {
6164
throw new TypeError('option saltLength must be finite number > 1')
6265
}
6366

64-
var secretLength = opts.secretLength
67+
var secretLength = opts.secretLength !== undefined
68+
? opts.secretLength
69+
: DefaultOptions.secretLength
6570

6671
if (typeof secretLength !== 'number' || !isFinite(secretLength) || secretLength < 1) {
6772
throw new TypeError('option secretLength must be finite number > 1')
6873
}
6974

70-
var hashAlgorithm = opts.hashAlgorithm
75+
var hashAlgorithm = opts.hashAlgorithm !== undefined
76+
? opts.hashAlgorithm
77+
: DefaultOptions.hashAlgorithm
7178

7279
if (typeof hashAlgorithm !== 'string' || !hashAlgorithm) {
7380
throw new TypeError('option hashAlgorithm must be valid hash algorithn')

0 commit comments

Comments
 (0)