exec-once

Creates a function that executes once

Usage no npm install needed!

<script type="module">
  import execOnce from 'https://cdn.skypack.dev/exec-once';
</script>

README

Exec Once

Create a function that executes once

Examples

This code should prints 10 lines of the same number

const once = require('exec-once')
const randomOnce = once(Math.random())
for (let count = 10; count; --count) {
  console.log(randomOnce())
}

License

MIT © Hoàng Văn Khải