JSPM

no-mo-fun

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q30306F
  • License MIT

Run a function no-mo' than n times

Package Exports

  • no-mo-fun

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (no-mo-fun) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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!