zd-once

1.0.1 • Public • Published

Build Status Known Vulnerabilities Coverage Status

zd-once

Ensure a function is only called once. Zero deps and simple codebase.

Install

$ npm install zd-once

Usage

const {
    once
} = require('zd-once');

function sum(a, b) {
    return a + b;
}
let sumOnce = once(sum);
console.log(sumOnce(1, 2)); // prints 3
console.log(sumOnce(1, 2)); // prints nothing

API

  • once(fn) ensures a function is called only once.
  • onceStrict(fn) similar to once(fn). It will throw an error if called more than once.

Readme

Keywords

none

Package Sidebar

Install

npm i zd-once

Weekly Downloads

30

Version

1.0.1

License

MIT

Unpacked Size

6.68 kB

Total Files

8

Last publish

Collaborators

  • p.revington