has-proto
Version:
Does this environment have the ability to get the [[Prototype]] of an object on creation with `__proto__`?
58 lines (46 loc) • 2.05 kB
Markdown
this environment have the ability to set the [[Prototype]] of an object on creation with `__proto__`?
```js
var hasProto = require('has-proto');
var assert = require('assert');
assert.equal(typeof hasProto(), 'boolean');
var hasProtoAccessor = require('has-proto/accessor')();
if (hasProtoAccessor) {
assert.equal([].__proto__, Array.prototype);
} else {
assert(!('__proto__' in Object.prototype));
}
var hasProtoMutator = require('has-proto/mutator');
var obj = {};
assert('toString' in obj);
obj.__proto__ = null;
if (hasProtoMutator) {
assert(!('toString' in obj));
} else {
assert('toString' in obj);
assert.equal(obj.__proto__, null);
}
```
Simply clone the repo, `npm install`, and run `npm test`
[ ]: https://npmjs.org/package/has-proto
[ ]: https://versionbadg.es/inspect-js/has-proto.svg
[ ]: https://david-dm.org/inspect-js/has-proto.svg
[ ]: https://david-dm.org/inspect-js/has-proto
[ ]: https://david-dm.org/inspect-js/has-proto/dev-status.svg
[ ]: https://david-dm.org/inspect-js/has-proto#info=devDependencies
[ ]: https://nodei.co/npm/has-proto.png?downloads=true&stars=true
[ ]: https://img.shields.io/npm/l/has-proto.svg
[ ]: LICENSE
[ ]: https://img.shields.io/npm/dm/has-proto.svg
[ ]: https://npm-stat.com/charts.html?package=has-proto
[ ]: https://codecov.io/gh/inspect-js/has-proto/branch/main/graphs/badge.svg
[ ]: https://app.codecov.io/gh/inspect-js/has-proto/
[ ]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/has-proto
[ ]: https://github.com/inspect-js/has-proto/actions
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
Does