feint

1.0.3 • Public • Published

feint

npm version Build Status codecov

Make a given Function do nothing at its first call

import feint from 'feint';
 
const fn = feint(() => 1);
fn(); //=> undefined
fn(); //=> 1
fn(); //=> 1

Installation

Use [npm]https://docs.npmjs.com/about-npm/).

npm install feint

API

import feint from 'feint';

feint(fn)

fn: Function
Return: Function

It returns a new Function that does nothing when it's called for the first time. From the second time on, the function performs normally.

import {existsSync, mkdirSync} from 'fs';
import feint from 'feint';
 
const feintMkdir = feint(mkdirSync);
 
feintMkdir('foo');
existsSync('foo'); //=> false
 
feintMkdir('foo');
existsSync('foo'); //=> true

License

ISC License © 2018 - 2019 Watanabe Shinnosuke

Package Sidebar

Install

npm i feint

Weekly Downloads

67

Version

1.0.3

License

ISC

Unpacked Size

3.53 kB

Total Files

5

Last publish

Collaborators

  • shinnn