has-proto (1.2.0)
Published 2026-02-24 13:57:35 +00:00 by atheaadmin
Installation
registry=npm install has-proto@1.2.0"has-proto": "1.2.0"About this package
has-proto 
Does this environment have the ability to set the Prototype of an object on creation with __proto__?
Example
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);
}
Tests
Simply clone the repo, npm install, and run npm test
Dependencies
Dependencies
| ID | Version |
|---|---|
| dunder-proto | ^1.0.0 |
Development Dependencies
| ID | Version |
|---|---|
| @arethetypeswrong/cli | ^0.17.0 |
| @ljharb/eslint-config | ^21.1.1 |
| @ljharb/tsconfig | ^0.2.2 |
| @types/gopd | ^1.0.3 |
| @types/tape | ^5.6.5 |
| auto-changelog | ^2.5.0 |
| encoding | ^0.1.13 |
| eslint | =8.8.0 |
| evalmd | ^0.0.19 |
| gopd | ^1.2.0 |
| in-publish | ^2.0.1 |
| npmignore | ^0.3.1 |
| reflect.getprototypeof | ^1.0.7 |
| safe-publish-latest | ^2.0.0 |
| tape | ^5.9.0 |
| typescript | next |
Keywords
prototype
proto
set
get
__proto__
getPrototypeOf
setPrototypeOf
has
