Get unlimited public & private packages + team-based management with npm Teams.Learn more »

tiny-when

1.0.1 • Public • Published

Behance Tiny-When Build Status NPM version

This Browser / Node.js library that periodically checks when a condition is satisfied.

Features

  • Pass a condition to check the interval
  • Set the options for interval of checks and the max number of checks
  • Returns a promise that is resolved or rejected based on the options

Usage

const when = require('tiny-when');
 
function condition() {
  return window.adobeAnalytics && window.liveFyre;
}
 
const options = {
  maxChecks: 30,
  intervalInMs: 100
}
 
when(codition, options)
.then(function() {
  console.log('Adobe Analaytics and LiveFyre loaded and are ready!');
});

When Arguments:

  • condition - a function that checks to see if a condition is met (e.g., function() { return window._satellite && window.s_adbadobenonacdc }).
  • options.intervalInMs - defaults to 300 - Number of MS before checking the condition
  • options.maxChecks - defaults to 30 - Number of Max checks

License

Apache-2.0

Install

npm i tiny-when

DownloadsWeekly Downloads

2

Version

1.0.1

License

Apache-2.0

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar