├── .npmrc ├── .gitattributes ├── .gitignore ├── factory.js ├── logo.png ├── index.js ├── .travis.yml ├── .editorconfig ├── package.json ├── test.js ├── license └── readme.md /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | .nyc_output 4 | -------------------------------------------------------------------------------- /factory.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = () => () => {}; 3 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sindresorhus/noop3/HEAD/logo.png -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const noopFactory = require('./factory'); 3 | 4 | module.exports = noopFactory(); 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '10' 4 | - '8' 5 | - '6' 6 | after_success: 7 | - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls' 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "noop3", 3 | "version": "1000.0.0", 4 | "description": "◻️ Supreme nothingness", 5 | "license": "MIT", 6 | "repository": "sindresorhus/noop3", 7 | "author": { 8 | "name": "Sindre Sorhus", 9 | "email": "sindresorhus@gmail.com", 10 | "url": "sindresorhus.com" 11 | }, 12 | "engines": { 13 | "node": ">=6" 14 | }, 15 | "scripts": { 16 | "test": "xo && ava" 17 | }, 18 | "files": [ 19 | "index.js", 20 | "factory.js" 21 | ], 22 | "keywords": [ 23 | "noop", 24 | "no-op", 25 | "empty", 26 | "nothing", 27 | "function", 28 | "func", 29 | "fn" 30 | ], 31 | "devDependencies": { 32 | "ava": "*", 33 | "coveralls": "^2.11.5", 34 | "nyc": "^11.0.3", 35 | "xo": "*" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import noopFactory from './factory'; 3 | import noop from '.'; 4 | 5 | const EXAMPLE_NOOP_FUNCTION_3 = '() => {}'; 6 | 7 | test('noop does nothing', t => { 8 | t.is(typeof noop, 'function'); 9 | t.is(noop(), undefined); 10 | 11 | /** 12 | * Check that function actually does nothing, for everyone. 13 | * https://github.com/sindresorhus/noop3/issues/10 14 | */ 15 | // Check that noop function is a function that functions like a function. 16 | t.is(noop.toString, Function.prototype.toString); 17 | // Ensure the preciseness of the no operation. 18 | t.is(noop.toString(), EXAMPLE_NOOP_FUNCTION_3); 19 | }); 20 | 21 | test('noop factory produces noop functions', t => { 22 | t.is(typeof noopFactory(), 'function'); 23 | t.is(noopFactory()(), undefined); 24 | t.not(noopFactory(), noopFactory()); 25 | }); 26 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | noop3 4 |
5 |
6 |
7 |

8 | 9 | > ◻️ Supreme nothingness 10 | 11 | [![Build Status](https://travis-ci.org/sindresorhus/noop3.svg?branch=master)](https://travis-ci.org/sindresorhus/noop3) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/noop3/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/noop3?branch=master) 12 | 13 | ![](https://cloud.githubusercontent.com/assets/170270/11731042/eba6ffc6-9f98-11e5-8d7d-7890dbc394c5.gif) 14 | 15 | 16 | ## Install 17 | 18 | ``` 19 | $ npm install noop3 20 | ``` 21 | 22 | 23 | ## Usage 24 | 25 | ```js 26 | const noop = require('noop3'); 27 | 28 | function unicorn(fn) { 29 | fn = fn || noop; 30 | return fn('unicorn'); 31 | } 32 | unicorn(); 33 | 34 | // Also compatible with non-mythical single horned creatures 35 | function narwhal(fn) { 36 | fn = fn || noop; 37 | return fn('narwhal'); 38 | } 39 | narwhal(); 40 | 41 | // Using the noop factory 42 | const fn = require('noop3/factory'); 43 | const rainbow = fn(); 44 | const flowers = fn(); 45 | console.log(rainbow === flowers); 46 | //=> false 47 | 48 | rainbow(); 49 | //=> undefined 50 | ``` 51 | 52 | 53 | ## Related 54 | 55 | - [noop-cli](https://github.com/sindresorhus/noop-cli) - CLI for this module 56 | - [noop2](https://github.com/yoshuawuyts/noop2) - Prior art 57 | 58 | 59 | ## License 60 | 61 | MIT © [Sindre Sorhus](https://sindresorhus.com) 62 | --------------------------------------------------------------------------------