Skip to content

Commit

Permalink
fix for older Node version
Browse files Browse the repository at this point in the history
  • Loading branch information
buzcarter committed Sep 11, 2019
1 parent 8ebcdb4 commit 2cc630a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions index.js
Expand Up @@ -53,21 +53,28 @@ function Tokens (options) {
return new Tokens(options)
}

var opts = Object.assign({}, DefaultOptions, options || {})
var opts = options || {}

var saltLength = opts.saltLength !== undefined
? opts.saltLength
: DefaultOptions.saltLength

var saltLength = opts.saltLength

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

var secretLength = opts.secretLength
var secretLength = opts.secretLength !== undefined
? opts.secretLength
: DefaultOptions.secretLength

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

var hashAlgorithm = opts.hashAlgorithm
var hashAlgorithm = opts.hashAlgorithm !== undefined
? opts.hashAlgorithm
: DefaultOptions.hashAlgorithm

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

0 comments on commit 2cc630a

Please sign in to comment.