Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

debounceif

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debounceif

DebounceIf a condition is met.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

debounceif

DebounceIf a condition is met.

Sample Usage

TypeScript

debounce(() => {
	console.log('Debounced after 1s!')
}, 1000)

let isLoading = true
setTimeout(() => (isLoading = false), 5000)

// Example using function
let dots = ''
debounceIf(
	() => {
		console.log('Debounced after condition is met!')
	},
	500,
	() => {
		dots += '.'
		if (dots.length > 3) {
			dots = '.'
		}
		console.log('Loading' + dots)
		return !isLoading
	},
)

// Example with class instantiation
const debounceInst = new DebounceIf(() => {
	console.log('Debounced from DebouncedIf() instance after 2s!')
}, 2000)

debounceInst.debounce()

HTML

<input type="text" id="debounce" />
<div id="suggestions"></div>

<script>
	var exports = {}
</script>
<script src="debounceIf.js"></script>
<script>
	const words = ['world', 'wide', 'web']
	document.getElementById('debounce').onkeypress = event => {
		exports.debounce(() => {
			const search = event.target.value
			const suggestions = words
				.filter(word => word.startsWith(search.toLowerCase()))
				.sort()
				.join('<br />')
			document.getElementById('suggestions').innerHTML = suggestions
		}, 500)
	}
</script>

See tests/debounceIf.html to learn more about how to incorporate this into your project via HTML and JS or tests/usage.ts for an example on how to debounceIf with NodeJS and Typescript.

Available Scripts

In the project directory, you can run:

npm run build

Builds debounceIf.ts and tests/usage.ts into JS files for usage. usage.ts is a demo of the script being used in Typescript while tests/debounceIf.html provides a demonstration of usage within the browser.

npm run test-usage

Runs the sample usage.js file which should output a log in your console.

Learn More

You can learn more about the developer here.

Keywords

FAQs

Package last updated on 11 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc