Skip to content

Dead simple noop function compatible with TypeScript

Notifications You must be signed in to change notification settings

therealemjy/noop-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

noop-ts

A very simple "do nothing" JavaScript function, compatible with TypeScript. Since the noop accepts any arguments (and does nothing in return), it can be used as a replacement of any function passed as a parameter to another function or a property of a web/React/Angular/(...) component.

That can be particularly useful for unit tests, for example to test a React component:

import noop from 'noop-ts';

describe('MyComponent', () => {
  it('does what I want it to do', () => {
    const component = shallow(<MyComponent onChange={noop} />);
    expect(component).toMatchSnapshot();
  });
});

Installation

npm

npm install noop-ts --save-dev

yarn

yarn add noop-ts --dev

About

Dead simple noop function compatible with TypeScript

Resources

Stars

Watchers

Forks

Packages

No packages published