Function.timebomb >= 0.1.4

Purpose

Create a timebomb that needs to be defused or it'll throw an error

Syntax

Function.timebomb ( NumbertimerFunctioncallback );

Parameters

timer

Time in ms to wait before exploding

callback

The callback to use when exploding

Return values

Object

Returns a timebomb object

Examples

Create a bomb with no callback, and let it go off

In this example we create a bomb that'll go off after 50ms.

Because there is no callback, it'll just throw an error.

We also create a timeout, which will execute 50ms after the bomb went off

var bomb = Function.timebomb(50);

setTimeout(function() {
    console.log(bomb);
    >>> {defused: false, exploded: true}
}, 100);

Create a bomb and defuse it in time

var bomb = Function.timebomb(50);

setTimeout(function() {
    bomb.defuse();
}, 10);

setTimeout(function() {
    console.log(bomb);
    >>> {defused: true, exploded: false}
}, 100);

Comments

Eusebia

Could you inform me what style are you making use of on your internet site? It looks wonderful.

Jude

I found your web site from Google as well as I have to say it was a wonderful locate. Thanks!