1.0.1 • Published 5 years ago
once.ts v1.0.1
once.ts
About
Once.ts is a micro-library that enables you to enforce a function can only be executed once. Once.ts completely dependency-free and written in Typescript for AMD, Node.js and the Web. This is a typescript version of the once.js library.
Import
Node.js
const {once} = require("once.ts");
Browser
import {once} from "once";
Usage
let foo = once(()=> console.log("Hello World!"));
foo(); // 'Hello World!'
foo(); // nothing
// with arguments
const callback = (a,b) => console.log(a+b);
const callOnce = once(callback);
callOnce(1,2)// 3
callOnce(2,4) // 3
Install Choices
npm install once.ts
- download the zip
- clone the repo
License
(The MIT License)