zxcvbn-ts
Guide
Demo
Changelog
GitHub
Guide
Demo
Changelog
GitHub
  • Guide

    • Introduction
    • Getting started
    • Examples
    • Best Practices
    • Comparison
    • Languages
    • Filtering custom words
    • Lazy loading
    • Matcher
    • Options
    • Framework examples
    • Migration
  • Demo

    • Demo

Examples

Debounce

import {
    zxcvbnAsync,
    debounce,
} from '@zxcvbn-ts/core'

let result
const someCallableFunction = () => {
// ...do your magic for example get the value from an input field or somewhere else
    const value = getInputValue()
    result = zxcvbnAsync(value)
}

const debouncedZxcvbn = debounce(someCallableFunction, 200)


// then you can call debouncedZxcvbn and if it is in the timeframe of 200ms the someCallableFunction will only be called once by the last call
debouncedZxcvbn()
debouncedZxcvbn()
debouncedZxcvbn()
debouncedZxcvbn()

If you want to execute the function on the first debounce and ignore the rest you can use the third parameter.

import {
    zxcvbnAsync,
    debounce,
} from '@zxcvbn-ts/core'

let result
const someCallableFunction = () => {
// ...do your magic for example get the value from an input field or somewhere else
    const value = getInputValue()
    result = zxcvbnAsync(value)
}

const debouncedZxcvbn = debounce(someCallableFunction, 200, true)


// then you can call debouncedZxcvbn and if it is in the timeframe of 200ms the someCallableFunction will only be called once by the first call
debouncedZxcvbn()
debouncedZxcvbn()
debouncedZxcvbn()
debouncedZxcvbn()
Edit this page
Last Updated: 6/26/25, 7:34 PM
Contributors: MrWook, espada-edalex
Prev
Getting started
Next
Best Practices