Comparing version 0.0.0 to 0.0.1
26
index.js
@@ -15,2 +15,3 @@ var defaultUrl = | ||
return (loadScriptPromise = new Promise(function(resolve, reject) { | ||
// create and attach zxcvbn script | ||
var script = document.createElement("script"); | ||
@@ -29,8 +30,23 @@ script.type = "text/javascript"; | ||
document.getElementsByTagName("head")[0].appendChild(script); | ||
setTimeout(function() { | ||
reject({ message: "Timeout loading zxcvbn" }); | ||
}, loadTimeout); | ||
}).then(null, function(error) { | ||
// timeout and fallback for onload/onerror | ||
var c = 0; | ||
var hnd = setInterval(function(){ | ||
c++; | ||
if (typeof zxcvbn === 'function') { | ||
clearInterval(hnd); | ||
return resolve(zxcvbn); | ||
} | ||
if (c * 100 > loadTimeout) { | ||
clearInterval(hnd); | ||
return reject(new Error('Timeout loading zxcvbn')); | ||
} | ||
}, 100); | ||
}).then(function(zxcvbn) { | ||
// remove heavy promise wrapper | ||
return (loadScriptPromise = Promise.resolve(zxcvbn)); | ||
}, function(error) { | ||
// when an error happens, clear the saved promise | ||
loadScriptPromise = null; | ||
reject(error); | ||
throw error; | ||
})); | ||
@@ -37,0 +53,0 @@ } |
{ | ||
"name": "asdfgh", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Asynchronous wrapper around zxcvbn", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3608
59