wrappy

WebJar for wrappy

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

wrappy
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

wrappy
WebJar for wrappy
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/npm/wrappy

Download wrappy

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/wrappy/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>wrappy</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/wrappy/
implementation 'org.webjars.npm:wrappy:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/wrappy/
implementation ("org.webjars.npm:wrappy:1.0.2")
'org.webjars.npm:wrappy:jar:1.0.2'
<dependency org="org.webjars.npm" name="wrappy" rev="1.0.2">
  <artifact name="wrappy" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='wrappy', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "wrappy" % "1.0.2"
[org.webjars.npm/wrappy "1.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

wrappy

Callback wrapping utility

USAGE

var wrappy = require("wrappy")

// var wrapper = wrappy(wrapperFunction)

// make sure a cb is called only once
// See also: http://npm.im/once for this specific use case
var once = wrappy(function (cb) {
  var called = false
  return function () {
    if (called) return
    called = true
    return cb.apply(this, arguments)
  }
})

function printBoo () {
  console.log('boo')
}
// has some rando property
printBoo.iAmBooPrinter = true

var onlyPrintOnce = once(printBoo)

onlyPrintOnce() // prints 'boo'
onlyPrintOnce() // does nothing

// random property is retained!
assert.equal(onlyPrintOnce.iAmBooPrinter, true)
org.webjars.npm

npm

node package manager

Versions

Version
1.0.2
1.0.1