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

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i tiny-when

    Weekly Downloads

    2

    Version

    1.0.1

    License

    Apache-2.0

    Last publish

    Collaborators

    • chthomas
    • lanniemiao
    • mtrajano93
    • moskalen
    • elewis
    • mansinarain
    • attamusc
    • weikinhuang
    • mase
    • agaripian
    • nemtsov
    • bryanpackman
    • matt-oconnell
    • mlebrun
    • andyroo2000
    • ingluisjimenez
    • gtuckeradobe
    • tpaparne
    • danicasapit
    • dfoxinator
    • jelee11
    • jmedoy
    • bossjones
    • mtldo
    • jushean
    • bryanlatten
    • sadraei
    • tracyfogel
    • kangman
    • iooi
    • benake
    • davestein