A Webpack/Browserify/... asynchronous loader for zxcvbn
npm install zxcvbn-async




A Webpack/Browserify/... asynchronous loader for zxcvbn
As the zxcvbn docs states,
the zxcvbn package should not be included in your bundle.
This modules loads the library from CDNJS (by default) when it is required by your application.
``bash`
$ npm install zxcvbn
zxcvbn-async provides two modes of operation : async and mimic sync.
javascript
var zxcvbnAsync = require('zxcvbn-async');zxcvbnAsync.load({}, function(err, zxcvbn) {
var results = zxcvbn(password, user_inputs);
});
`#### With Promises
`javascript
var zxcvbnAsync = require('zxcvbn-async');zxcvbnAsync.load({})
.then((zxcvbn) => {
var results = zxcvbn(password, user_inputs);
});
`$3
This mode mimics the synchronous loading of zxcvbn. If you try to use it before the library has loaded,
the result object will be filled with -1 values.
`javascript
var zxcvbnAsync = require('zxcvbn-async');
var zxcvbn = zxcvbnAsync.load({ sync: true });
`If the library hasn't loaded yet, the result will be :
`javascript
result = {
guesses: -1,
guesses_log10: -1,
crack_times_seconds: -1,
crack_times_display: -1,
score: -1,
feedback: null,
sequence: [],
calc_time: 0
}
`API
$3
Loads the library if not done yet.options :
- sync : If true, uses the mimic sync mode. (default: false)
- libUrl : If set, the path of the library (default: the latest version from CDNJS, currently 4.4.2)
- libIntegrity : If set, the integrity checksum for libUrl. Subresource Integritycb : function(err, zxcvbn)
- err : error object, if any
- zxcvbn : the zxcvbn` function (See the zxcvbn docs for details) - xurei: Author, Maintainer
- mlogan: Contributor