🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

has-proto

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

has-proto

Does this environment have the ability to get the [[Prototype]] of an object on creation with `__proto__`?

1.2.0
latest
Source
npm
Version published
Weekly downloads
46M
5.67%
Maintainers
1
Weekly downloads
 
Created
Source

has-proto Version Badge

github actions coverage License Downloads

npm badge

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

Keywords

prototype

FAQs

Package last updated on 06 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts