npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zxcvbn-async

v0.0.6

Published

A Webpack/Browserify/... asynchronous loader for zxcvbn

Downloads

497

Readme

zxcvbn-async

npm GitHub issues GitHub license Codacy grade

Donate

A Webpack/Browserify/... asynchronous loader for zxcvbn

Motivation

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.

Installation

$ npm install zxcvbn

Usage

zxcvbn-async provides two modes of operation : async and mimic sync.

Async mode (recommended)

This mode is the typical one when working with async code in JS. It's the recommended one for a new project or if you don't have to rewrite a lot of code.

With Old-school callbacks

var zxcvbnAsync = require('zxcvbn-async');

zxcvbnAsync.load({}, function(err, zxcvbn) {
    var results = zxcvbn(password, user_inputs);
});

With Promises

var zxcvbnAsync = require('zxcvbn-async');

zxcvbnAsync.load({})
.then((zxcvbn) => {
    var results = zxcvbn(password, user_inputs);
});

Mimic sync

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.

var zxcvbnAsync = require('zxcvbn-async');
var zxcvbn = zxcvbnAsync.load({ sync: true });

If the library hasn't loaded yet, the result will be :

result = {
	guesses: -1,
	guesses_log10: -1,
	crack_times_seconds: -1,
	crack_times_display: -1,
	score: -1,
	feedback: null,
	sequence: [],
	calc_time: 0
}

API

zxcvbnAsync.load(options, cb)

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 Integrity

cb : function(err, zxcvbn)

  • err : error object, if any
  • zxcvbn : the zxcvbn function (See the zxcvbn docs for details)

Contributors

TODO

  • Write tests