go back

Getting Started with the Documentation

bun add one-firework
import firework from 'one-firework';

function veryExpensiveFunction() {
    // did some expensive work
    return result;
}

const oneFireworkExecution = firework(veryExpensiveFunction);

console.log(oneFireworkExecution()); // will call the function and return the result
console.log(oneFireworkExecution()); // will return the cached result

console.log(firework.fired(oneFireworkExecution)) // will return true if the function was called at least once

API

firework(fn: Function): Function

firework.fired(fn: Function): number