@edwardmx/noopdeprecated

No operation module

Usage no npm install needed!

<script type="module">
  import edwardmxNoop from 'https://cdn.skypack.dev/@edwardmx/noop';
</script>

README

noop

No operation module.

You can use this empty function when you wish to pass around a function that will do nothing.

This is useful for components developers who offer optional callbacks

Installation

# Using npm
npm install --save @edwardmx/noop

Example

const noop = require("@edwardmx/noop");

//-------- Case 1
noop();
// Hey, nothing happened!


//-------- Case 2
let person = (name, age, cb) => {
    cb = cb || noop;
    cb(name, age);
};

// Eg. 1
person('Edward', 30, (name, age) => {
    // My name is Edward. I'm 30 years old
    console.log(`My name is ${name}. I'm ${age} years old`);
});


// Eg. 2
person('Edward', 30);
// No error, even we don't send the callback function