Giter Site home page Giter Site logo

coolaj86 / noop.js Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 0.0 11 KB

Provides a few global functions such as `noop`, `throwop`, and `doop`

Home Page: https://twitter.com/JasonONeillCTG/status/1431479346980536330

License: Other

JavaScript 95.30% Vim Script 4.70%
zerodependencies

noop.js's Introduction

node-noop

Provides a few global functions such as noop, throwop, and doop

npm install noop@v1
require("noop");

Features

  • Works with Promises and Thunks
  • Faster than Object (always true-y)
  • More predictable than Boolean (sometimes false-y)
  • Linted with TypeScript, JSHint, and Prettier

API

global.noop

Does nothing

function noop() {}

global.throwop(err)

Throws if err is true-y

function throwop(err) {
  if (err) {
    throw err;
  }
}

global.doop(callback)

Calls callback or noop

function doop(callback, args, context) {
  if ("function" === typeof callback) {
    callback.apply(context, args);
  }
}

Similar function signature to setTimeout.

LICENSE

MIT OR CC0-1.0 (Public Domain)

Written in 2011 by AJ ONeal [email protected]
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.

You should have received a copy of the CC0 Public Domain Dedication along with
this software. If not, see https://creativecommons.org/publicdomain/zero/1.0/.

noop.js's People

Stargazers

tit avatar 坏了 avatar Luis Eduardo Brito avatar Angus H. avatar Rahul Doshi avatar Peter avatar Max Sysoev avatar Nick Kampe avatar Adrian avatar stagas avatar vlapan avatar Ilya Nazarov avatar AJ ONeal avatar Scott  Koon avatar Pau Ramon Revilla avatar TJ Holowaychuk avatar Guillermo Rauch avatar Caolan McMahon avatar

Watchers

AJ ONeal avatar James Cloos avatar  avatar

noop.js's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.