# dunder

> hot-swap inheritance for every engine

Latest version **0.1.1** (published 2013-05-14) · 0 weekly downloads

## Install

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

## 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.1.1 |
| Published | 2013-05-14 |
| First published | 2013-04-22 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | __proto__, free, dunder, inheritance, ES5, ES6 |

## Links

- npm: https://www.npmjs.com/package/dunder
- Repository: https://github.com/WebReflection/dunder
- npm.io page: https://npm.io/package/dunder

## Dependencies (1)

- [wru](https://npm.io/package/wru.md) >= 0.0.0

## Recent versions

- 0.1.1 (latest) — 2013-05-14
- 0.1.0 — 2013-04-22

## README

dunder
======
hot-swap inheritance for every engine

[![build status](https://secure.travis-ci.org/WebReflection/dunder.png)](http://travis-ci.org/WebReflection/dunder)

### API

  * `dunder(object:Object):Object|null` returns the object prototype
  * `dunder(object:Object, proto:Object|null):object|Object` returns an object that inherits from the second argument

If the engine supports a descriptor to set the prototype chain, or the `__proto__`, the object is not recreated, otherwise it's inherited and replicated on top using ES5+ descriptors for a uniformed behavior in IE10 and IE9 too.

```javascript
// basics
var a = {}, b = {};
dunder(a) === Object.prototype; // true

// inline swap
a = dunder(a, b);
b.isPrototypeOf(a); // true
dunder(a) === b;    // true

// hot-swap Zepto.js like
var libObj = dunder(
  document.querySelectorAll(CSS),
  MyAwesomeLibrary.prototype
);
```

That is pretty much it, except you might decide to make the environment safe, if needed, invoking free.

```
'__proto__' in Object.prototype; // true
dunder.free();

// only in certain cases and if possible
'__proto__' in Object.prototype; // false
```

The list of engines able to get rid of __proto__ as getter/setter is not known yet.

### Free From __proto__ Problems

There is an extra method to try to get rid of `__proto__` called `dunder.free()`, it returns a boolean if `delete Object.prototype.__proto__` was successful, which should be the case with most recent JS engines.

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