object-prototype
A replacement prototype for Object.prototype
with all the same
functions.
Installation
npm install object-prototype --save
Usage
const create ObjectPrototype = const obj1 = const obj2 = {} console // falseconsole // true console // trueconsole // false Objectprototypefoo = 42 console // undefinedconsole // 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()
ObjectPrototype.isPrototypeOf()
ObjectPrototype.propertyIsEnumerable()
ObjectPrototype.toLocaleString()
ObjectPrototype.toString()
ObjectPrototype.valueOf()
And the following functions which are considered deprecated according to the ECMAScript specification:
ObjectPrototype.__defineGetter__()
ObjectPrototype.__defineSetter__()
ObjectPrototype.__lookupGetter__()
ObjectPrototype.__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
.