Sign In

no-mo-fun

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

no-mo-fun

Run a function no-mo' than n times

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

NoMoFun

PRs Welcome Maintenance

Calls function no-mo' than n many times. Doesn't mean you can't have no-mo' fun!

Installation/ Usage

npm i noMoFun

import { nTimes, once, twice, thrice } from "../noMoFun";

const sayHello = function() {
  console.log("Hello, you good looking person");
};
// say you want the function to execute no more than four times
const sayHelloFourTimes = nTimes(sayHello, 4);

sayHelloFourTimes();
sayHelloFourTimes();
sayHelloFourTimes();
sayHelloFourTimes();
sayHelloFourTimes(); // => upon the fifth time, it will not run

// Other methods for `once`, `twice`, and `thrice` are also available!
const sayHelloOnce = once(sayHello);
const sayHelloTwice = twice(sayHello);
const sayHelloThrice = thrice(sayHello);

Example

Check out the demo folder for an example.

cd demo
npm i
npm run start-demo // will run on localhost:1234

Questions and suggestions are welcome. Have fun!

Keywords

n-times

FAQs

Package last updated on 22 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts