# wrappy

> Callback wrapping utility

Latest version **1.0.2** (published 2016-05-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install wrappy
pnpm add wrappy
yarn add wrappy
bun add wrappy
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score; declining downloads.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2016-05-17 |
| First published | 2014-09-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 55 |
| Author | Isaac Z. Schlueter |
| Maintainers | isaacs, zkat |

## Links

- npm: https://www.npmjs.com/package/wrappy
- Repository: https://github.com/npm/wrappy
- Issues: https://github.com/npm/wrappy/issues
- npm.io page: https://npm.io/package/wrappy

## Recent versions

- 1.0.2 (latest) — 2016-05-17
- 0.0.0 — 2021-04-22
- 1.0.1 — 2014-09-18
- 1.0.0 — 2014-09-18

## README

# wrappy

Callback wrapping utility

## USAGE

```javascript
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)
```

---
_Source: https://npm.io/package/wrappy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
