Skip to content

Commit cf459a7

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

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

index.js

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

56-
var opts = Object.assign({}, DefaultOptions, options || {})
56+
var opts = options || {}
5757

58-
var saltLength = opts.saltLength
58+
var saltLength = opts.saltLength !== undefined
59+
? opts.saltLength
60+
: DefaultOptions.saltLength
5961

6062
if (typeof saltLength !== 'number' || !isFinite(saltLength) || saltLength < 1) {
6163
throw new TypeError('option saltLength must be finite number > 1')
6264
}
6365

64-
var secretLength = opts.secretLength
66+
var secretLength = opts.secretLength !== undefined
67+
? opts.secretLength
68+
: DefaultOptions.secretLength
6569

6670
if (typeof secretLength !== 'number' || !isFinite(secretLength) || secretLength < 1) {
6771
throw new TypeError('option secretLength must be finite number > 1')
6872
}
6973

70-
var hashAlgorithm = opts.hashAlgorithm
74+
var hashAlgorithm = opts.hashAlgorithm !== undefined
75+
? opts.hashAlgorithm
76+
: DefaultOptions.hashAlgorithm
7177

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

0 commit comments

Comments
 (0)