# object-prototype

> A replacement prototype for `Object.prototype` with all the same functions

Latest version **3.0.4** (published 2020-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install object-prototype
pnpm add object-prototype
yarn add object-prototype
bun add object-prototype
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.4 |
| Published | 2020-02-28 |
| First published | 2019-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Thomas Watson |
| Maintainers | watson |
| Keywords | object, prototype, pollution, polyfill, security |

## Links

- npm: https://www.npmjs.com/package/object-prototype
- Repository: https://github.com/watson/object-prototype
- Homepage: https://github.com/watson/object-prototype#readme
- Issues: https://github.com/watson/object-prototype/issues
- npm.io page: https://npm.io/package/object-prototype

## Dependencies (1)

- [object-prototype-functions](https://npm.io/package/object-prototype-functions.md) ^1.2.0

## Recent versions

- 3.0.4 (latest) — 2020-02-28
- 3.0.3 — 2020-02-28
- 3.0.2 — 2020-02-24
- 3.0.1 — 2020-02-10
- 3.0.0 — 2020-01-31
- 2.1.0 — 2020-01-29
- 2.0.0 — 2019-11-20
- 1.0.0 — 2019-10-25

## README

# object-prototype

A replacement prototype for `Object.prototype` with all the same
functions.

[![npm](https://img.shields.io/npm/v/object-prototype.svg)](https://www.npmjs.com/package/object-prototype)
[![build status](https://travis-ci.org/watson/object-prototype.svg?branch=master)](https://travis-ci.org/watson/object-prototype)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

## Installation

```
npm install object-prototype --save
```

## Usage

```js
const { create, ObjectPrototype } = require('object-prototype')

const obj1 = create()
const obj2 = {}

console.log(Object.prototype.isPrototypeOf(obj1)) // false
console.log(ObjectPrototype.isPrototypeOf(obj1)) // true

console.log(Object.prototype.isPrototypeOf(obj2)) // true
console.log(ObjectPrototype.isPrototypeOf(obj2)) // false

Object.prototype.foo = 42

console.log(obj1.foo) // undefined
console.log(obj2.foo) // 42
```

## API

### `ObjectPrototype`

The `ObjectPrototype` property exposed by this module is ment as a
replacement to `Object.prototype` and has the following ECMAScript
spec'd functions:

- [`ObjectPrototype.hasOwnProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)
- [`ObjectPrototype.isPrototypeOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)
- [`ObjectPrototype.propertyIsEnumerable()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)
- [`ObjectPrototype.toLocaleString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)
- [`ObjectPrototype.toString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
- [`ObjectPrototype.valueOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)

And the following functions which are considered deprecated according to
the ECMAScript specification:

- [`ObjectPrototype.__defineGetter__()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__)
- [`ObjectPrototype.__defineSetter__()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__)
- [`ObjectPrototype.__lookupGetter__()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__)
- [`ObjectPrototype.__lookupSetter__()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__lookupSetter__)

### `object = create()`

The `create` function is a convenience function that returns a new
object with `ObjectPrototype` as its prototype.

This is equivalent to writing `Object.create(ObjectPrototype)`.

### `object = assign([...objects])`

The `assign` function is a convenience function that returns a new
object with all the same properties as the provided objects, but with
`ObjectPrototype` as its prototype.

This is equivalent to writing
`Object.assign(Object.create(ObjectPrototype), ...objects)`.

### `FunctionPrototype`

The `FunctionPrototype` property exposed by this module is ment as a
replacement to `Function.prototype` and exposes the same properties.

### `function = safePrototypeFunction(function)`

Given a function as the first argument, `safePrototypeFunction` will
return another function which wraps the given function in a way so that
it doesn't leak `Object.prototype`.

## License

[MIT](LICENSE)

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