# js-wrap

> Universal Wrapper Object System for ECMAScript 5 and beyond

Latest version **0.0.4** (published 2013-03-27) · BSD license · 0 weekly downloads

## Install

```sh
npm install js-wrap
pnpm add js-wrap
yarn add js-wrap
bun add js-wrap
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2013-03-27 |
| First published | 2013-03-24 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Dan Kogai |
| Maintainers | dankogai |
| Keywords | ES5, ESMAScript5, wrap, wrapper |

## Links

- npm: https://www.npmjs.com/package/js-wrap
- Repository: https://github.com/dankogai/js-wrap
- npm.io page: https://npm.io/package/js-wrap

## Recent versions

- 0.0.4 (latest) — 2013-03-27
- 0.0.3 — 2013-03-26
- 0.0.2 — 2013-03-26
- 0.0.1 — 2013-03-24

## README

[![build status](https://secure.travis-ci.org/dankogai/js-wrap.png)](http://travis-ci.org/dankogai/js-wrap)

wrap.js
=======

Universal Wrapper Object System for ECMAScript 5 and beyond

Usage
-----

### From HTML:

````html
<script src="wrap.js"></script>
````

### On node.js:

````javascript
require('wrap');
````

Synopsis
--------

````javascript
// for convenience
var _ = Object.Wrap;

// singleton method!
_(42)
  .learn('square', function() { return this*this })
  .square() * 1;  // 1764;
(42).square();    // TypeError: Object 42 has no method 'square'

// class method without changing Number
_.Number.prototype.learn({
    times: function(f) { for (var i = 0; i < this; i++) f(i) },
    toThe: function(n) { return Math.pow(this, n) }
});
 // see your log!
_(42).times(function(n){ console.log( _(2).toThe(n) ) });
 // TypeError: Object 42 has no method 'times'
(42).times(function(n){ console.log(   (2).toThe(n) ) });
````

Description
-----------

As seen above, `Object.Wrap()` wraps objects as transparently and painlessly as possible:

+ transparently
  + wrapped objects have same methods as its original
  + wrapped objects automatical unwraps on demand
+ painlessly
  + you can extend wrapped objects as easy as unwrapped version

So you can extend built-in methods without tainting built-in prototypes.

See [wrap.md](wrap.md#description) for details!

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