Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
46M
increased by4.42%
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc