Skip to content

Commit

Permalink
increase sync.js internal coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Apr 16, 2018
1 parent cbba249 commit 1f47f98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,13 @@ function resolvePromise (promise, callback) {
})
}
module.exports = function (password, salt, iterations, keylen, digest, callback) {
checkParameters(password, salt, iterations, keylen)

if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)

if (typeof digest === 'function') {
callback = digest
digest = undefined
}
if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')

digest = digest || 'sha1'
var algo = toBrowser[digest.toLowerCase()]

if (!algo || typeof global.Promise !== 'function') {
return process.nextTick(function () {
var out
Expand All @@ -89,6 +83,12 @@ module.exports = function (password, salt, iterations, keylen, digest, callback)
callback(null, out)
})
}

checkParameters(password, salt, iterations, keylen)
if (typeof callback !== 'function') throw new Error('No callback provided to pbkdf2')
if (!Buffer.isBuffer(password)) password = Buffer.from(password, defaultEncoding)
if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, defaultEncoding)

resolvePromise(checkNative(algo).then(function (resp) {
if (resp) {
return browserPbkdf2(password, salt, iterations, keylen, algo)
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
},
"scripts": {
"prepublish": "npm run test",
"coverage-report": "nyc report --reporter=lcov",
"coverage-html": "nyc report --reporter=html",
"coverage": "nyc --check-coverage --branches 90 --functions 100 tape test/*.js",
"lint": "standard",
"test": "npm run lint && npm run unit",
Expand Down

0 comments on commit 1f47f98

Please sign in to comment.