Comparing version 1.11.1 to 1.12.0
@@ -0,1 +1,6 @@ | ||
## 1.12.0 (Jun 26, 2015) | ||
- Adds [`Oolong.setPrototypeOf`][setPrototypeOf]. | ||
[setPrototypeOf]: https://github.com/moll/js-oolong/blob/master/doc/API.md#Oolong.setPrototypeOf | ||
## 1.11.1 (Jun 24, 2015) | ||
@@ -2,0 +7,0 @@ - Fixes [`Oolong.isPlainObject`][isPlainObject] to return `false` for |
@@ -32,2 +32,3 @@ Oolong.js API Documentation | ||
- [reject](#Oolong.reject)(object, callback, [thisArg]) | ||
- [setPrototypeOf](#Oolong.setPrototypeOf)(object, prototype) | ||
- [values](#Oolong.values)(object) | ||
@@ -426,2 +427,18 @@ - [wrap](#Oolong.wrap)(value, key) | ||
<a name="Oolong.setPrototypeOf" /> | ||
### Oolong.setPrototypeOf(object, prototype) | ||
Set the prototype of the given object to the given prototype. | ||
Pass `null` or another object for the prototype. | ||
Returns `object`. | ||
Uses `Object.setPrototypeOf` if it exists. Otherwise uses a polyfill. | ||
**Examples**: | ||
```javascript | ||
var person = {name: "Unnamed", age: 42} | ||
var mike = Oolong.setPrototypeOf({name: "Mike"}, person) | ||
mike.name // => "Mike | ||
mike.age // => 42 | ||
``` | ||
<a name="Oolong.values" /> | ||
@@ -428,0 +445,0 @@ ### Oolong.values(object) |
26
index.js
@@ -6,2 +6,3 @@ var hasOwn = Function.call.bind(Object.hasOwnProperty) | ||
var lookupSetter = Object.prototype.__lookupSetter__ | ||
var SET_PROTO_OF_NULL = "Oolong.setPrototypeOf called on null or undefined" | ||
@@ -620,2 +621,27 @@ /** | ||
/** | ||
* Set the prototype of the given object to the given prototype. | ||
* Pass `null` or another object for the prototype. | ||
* Returns `object`. | ||
* | ||
* Uses `Object.setPrototypeOf` if it exists. Otherwise uses a polyfill. | ||
* | ||
* @example | ||
* var person = {name: "Unnamed", age: 42} | ||
* var mike = Oolong.setPrototypeOf({name: "Mike"}, person) | ||
* mike.name // => "Mike | ||
* mike.age // => 42 | ||
* | ||
* @static | ||
* @method setPrototypeOf | ||
* @param object | ||
* @param prototype | ||
*/ | ||
exports.setPrototypeOf = Object.setPrototypeOf || function(obj, prototype) { | ||
/* eslint no-proto: 0 */ | ||
if (obj == null) throw new TypeError(SET_PROTO_OF_NULL) | ||
if (typeof obj == "object") obj.__proto__ = prototype | ||
return obj | ||
} | ||
/** | ||
* Returns all enumerable property values as an array. | ||
@@ -622,0 +648,0 @@ * |
{ | ||
"name": "oolong", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"description": "Utilities for objects. Simple, tasteful and plentiful. Supports inherited properties.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -69,2 +69,3 @@ Oolong.js | ||
- [reject](https://github.com/moll/js-oolong/blob/master/doc/API.md#Oolong.reject)(object, callback, [thisArg]) | ||
- [setPrototypeOf](https://github.com/moll/js-oolong/blob/master/doc/API.md#Oolong.setPrototypeOf)(object, prototype) | ||
- [values](https://github.com/moll/js-oolong/blob/master/doc/API.md#Oolong.values)(object) | ||
@@ -71,0 +72,0 @@ - [wrap](https://github.com/moll/js-oolong/blob/master/doc/API.md#Oolong.wrap)(value, key) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78106
41
1572
100