Socket
Book a DemoInstallSign in
Socket

object-prototype

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-prototype

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

latest
Source
npmnpm
Version
3.0.4
Version published
Maintainers
1
Created
Source

object-prototype

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

npm build status js-standard-style

Installation

npm install object-prototype --save

Usage

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:

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

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

Keywords

object

FAQs

Package last updated on 28 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts