aonce

Run an async function once and remember its results

Usage no npm install needed!

<script type="module">
  import aonce from 'https://cdn.skypack.dev/aonce';
</script>

README

aonce

Run an async function once, no matter how many times it's called.

Example

var init = aonce(function(cb) {
    // Do some initialization
    results = {};
    cb(results);
});

// Later:

init(function(results) {
    // do something with results
});

// Elsewhere:

init(function(results) {
    // do something else with results
});