Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

emptyfunction

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emptyfunction

Simply an empty closure.

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
110
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

emptyFunction (NodeJS)

Nothing but an empty function closure.

Primarily Intended for optional closures. This allows you to use one empty closure object in your entire project, and whenever you need it, you can just pass it by reference instead of creating a new closure.

install

npm install emptyfunction

usage

Get the closure from the module

var emptyFunction = require('emptyfunction');

Whenever there's an optional closure, just add the empty function if no closure is provided

function MyClass(closureArgument) {
    if (typeof closureArgument === "function") {
        this.someFunction = closureArgument
    } else {
        this.someFunction = emptyFunction;
    }
}

Write your class as if the function exists

MyClass.prototype.doSomething = function() {
    this.someFunction();
}

identifying

Sometimes you might need to verify if the closure is an empty function.

If you're inside the same package you can use:

this.someFunction === emptyFunction

If not, a more hacky solution is to use:

this.someFunction.name === 'emptyFunction'

Keywords

FAQs

Package last updated on 01 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc