xprezzo-setprototypeof
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -0,1 +1,7 @@ | ||
1.1.2 / 2022-05-11 | ||
================== | ||
* depds xprezzo-mixin update to v1.1.2 | ||
* devDepds mocha update to 10.0.0 | ||
1.1.1 / 2020-10-17 | ||
@@ -2,0 +8,0 @@ ================== |
'use strict' | ||
var mixin = require('xprezzo-mixin'); | ||
const mixin = require('xprezzo-mixin'); | ||
@@ -9,5 +9,5 @@ /* eslint no-proto: 0 */ | ||
function setProtoOf (obj, proto) { | ||
obj.__proto__ = proto; | ||
return obj; | ||
let setProtoOf = (obj, proto) => { | ||
obj.__proto__ = proto | ||
return obj | ||
} |
{ | ||
"name": "xprezzo-setprototypeof", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A small polyfill for Object.setprototypeof", | ||
"author": "Ben Ajenoui <info@seohero.io>", | ||
"author": "Cloudgen Wong <cloudgen.wong@gmail.com>", | ||
"license": "MIT", | ||
@@ -17,3 +17,3 @@ "repository": "xprezzo/xprezzo-setprototypeof", | ||
"dependencies": { | ||
"xprezzo-mixin": "1.1.1" | ||
"xprezzo-mixin": "1.1.2" | ||
}, | ||
@@ -24,4 +24,4 @@ "scripts": { | ||
"devDependencies": { | ||
"mocha": "^8.2.0" | ||
"mocha": "^10.0.0" | ||
} | ||
} |
# xprezzo-setprototypeof | ||
Polyfill for `Object.setPrototypeOf` | ||
Object.setPrototypeOf() is in the ECMAScript 2015 specification. NodeJS starts implement `Object.setPrototypeOf` since version 0.12.0. NodeJS starts from 0.10.0 before 0.12.0 was using `Object.prototype.__proto__`. | ||
`xprezzo-setprototypeof` is a polyfill for `Object.setPrototypeOf`. | ||
The setprototypeof is extending directly on the [xprezzo-mixin](https://github.com/xprezzo/xprezzo-mixin) | ||
## Usage: | ||
For more ussages, please visit [xprezzo-mixin](https://github.com/xprezzo/xprezzo-mixin). | ||
``` | ||
@@ -12,5 +18,5 @@ $ npm install --save xprezzo-setprototypeof | ||
```javascript | ||
var setPrototypeOf = require('setprototypeof') | ||
const setPrototypeOf = require('setprototypeof') | ||
var obj = {} | ||
let obj = {} | ||
setPrototypeOf(obj, { | ||
@@ -32,3 +38,3 @@ foo: function () { | ||
Xprezzo and related projects are maintained by [Ben Ajenoui](mailto:info@seohero.io) and sponsored by [SEO Hero](https://www.seohero.io). | ||
Xprezzo and related projects are maintained by [Cloudgen Wong](mailto:cloudgen.wong@gmail.com). | ||
@@ -35,0 +41,0 @@ # License |
'use strict' | ||
/* eslint-env mocha */ | ||
/* eslint no-proto: 0 */ | ||
var assert = require('assert') | ||
var setPrototypeOf = require('..') | ||
const assert = require('assert') | ||
const setPrototypeOf = require('..') | ||
describe('setProtoOf(obj, proto)', function () { | ||
it('should merge objects', function () { | ||
var obj = { a: 1, b: 2 } | ||
var proto = { b: 3, c: 4 } | ||
var mergeObj = setPrototypeOf(obj, proto) | ||
it('should merge objects', function () { | ||
let obj = { a: 1, b: 2 } | ||
let proto = { b: 3, c: 4 } | ||
let mergeObj = setPrototypeOf(obj, proto) | ||
if (Object.getPrototypeOf) { | ||
assert.strictEqual(Object.getPrototypeOf(obj), proto) | ||
} else if ({ __proto__: [] } instanceof Array) { | ||
assert.strictEqual(obj.__proto__, proto) | ||
} else { | ||
assert.strictEqual(obj.a, 1) | ||
assert.strictEqual(obj.b, 2) | ||
assert.strictEqual(obj.c, 4) | ||
} | ||
assert.strictEqual(mergeObj, obj) | ||
}) | ||
if (Object.getPrototypeOf) { | ||
assert.strictEqual(Object.getPrototypeOf(obj), proto) | ||
} else if ({ __proto__: [] } instanceof Array) { | ||
assert.strictEqual(obj.__proto__, proto) | ||
} else { | ||
assert.strictEqual(obj.a, 1) | ||
assert.strictEqual(obj.b, 2) | ||
assert.strictEqual(obj.c, 4) | ||
} | ||
assert.strictEqual(mergeObj, obj) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
3677
42
+ Addedxprezzo-mixin@1.1.2(transitive)
- Removedxprezzo-mixin@1.1.1(transitive)
Updatedxprezzo-mixin@1.1.2