setprototypeof
Advanced tools
Comparing version 1.1.0 to 1.1.1
24
index.js
@@ -1,15 +0,17 @@ | ||
module.exports = Object.setPrototypeOf || ({__proto__:[]} instanceof Array ? setProtoOf : mixinProperties); | ||
'use strict' | ||
/* eslint no-proto: 0 */ | ||
module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties) | ||
function setProtoOf(obj, proto) { | ||
obj.__proto__ = proto; | ||
return obj; | ||
function setProtoOf (obj, proto) { | ||
obj.__proto__ = proto | ||
return obj | ||
} | ||
function mixinProperties(obj, proto) { | ||
for (var prop in proto) { | ||
if (!obj.hasOwnProperty(prop)) { | ||
obj[prop] = proto[prop]; | ||
} | ||
} | ||
return obj; | ||
function mixinProperties (obj, proto) { | ||
for (var prop in proto) { | ||
if (!obj.hasOwnProperty(prop)) { | ||
obj[prop] = proto[prop] | ||
} | ||
} | ||
return obj | ||
} |
{ | ||
"name": "setprototypeof", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A small polyfill for Object.setprototypeof", | ||
@@ -8,3 +8,10 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "standard && mocha", | ||
"testallversions": "npm run node010 && npm run node4 && npm run node6 && npm run node9 && npm run node11", | ||
"testversion": "docker run -it --rm -v $(PWD):/usr/src/app -w /usr/src/app node:${NODE_VER} npm install mocha@${MOCHA_VER:-latest} && npm t", | ||
"node010": "NODE_VER=0.10 MOCHA_VER=3 npm run testversion", | ||
"node4": "NODE_VER=4 npm run testversion", | ||
"node6": "NODE_VER=6 npm run testversion", | ||
"node9": "NODE_VER=9 npm run testversion", | ||
"node11": "NODE_VER=11 npm run testversion" | ||
}, | ||
@@ -25,3 +32,7 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/wesleytodd/setprototypeof" | ||
"homepage": "https://github.com/wesleytodd/setprototypeof", | ||
"devDependencies": { | ||
"mocha": "^5.2.0", | ||
"standard": "^12.0.1" | ||
} | ||
} |
# Polyfill for `Object.setPrototypeOf` | ||
[![NPM Version](https://img.shields.io/npm/v/setprototypeof.svg)](https://npmjs.org/package/setprototypeof) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/setprototypeof.svg)](https://npmjs.org/package/setprototypeof) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard) | ||
A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8. | ||
@@ -12,16 +16,17 @@ | ||
```javascript | ||
var setPrototypeOf = require('setprototypeof'); | ||
var setPrototypeOf = require('setprototypeof') | ||
var obj = {}; | ||
var obj = {} | ||
setPrototypeOf(obj, { | ||
foo: function() { | ||
return 'bar'; | ||
} | ||
}); | ||
obj.foo(); // bar | ||
foo: function () { | ||
return 'bar' | ||
} | ||
}) | ||
obj.foo() // bar | ||
``` | ||
TypeScript is also supported: | ||
```typescript | ||
import setPrototypeOf = require('setprototypeof'); | ||
``` | ||
import setPrototypeOf = require('setprototypeof') | ||
``` |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
3913
6
39
0
32
2