Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-proto-to-assign

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-proto-to-assign

Babel plugin for turning __proto__ into a shallow property clone

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
75K
decreased by-47.69%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-proto-to-assign

The proto-to-assignplugin will transform all __proto__ assignments to a method that will do a shallow copy of all properties.

This means that the following will work:

var foo = { a: 1 };
var bar = { b: 2 };
bar.__proto__ = foo;
bar.a; // 1
bar.b; // 2

however the following will not:

var foo = { a: 1 };
var bar = { b: 2 };
bar.__proto__ = foo;
bar.a; // 1
foo.a = 2;
bar.a; // 1 - should be 2 but remember that nothing is bound and it's a straight copy

This is a case that you have to be aware of if you intend to use this plugin.

Example

In

bar.__proto__ = foo;

Out

var _defaults = ...;

_defaults(bar, foo);

Installation

$ npm install babel-plugin-proto-to-assign

Usage

.babelrc

{
  "plugins": ["proto-to-assign"]
}

Via CLI

$ babel --plugins proto-to-assign script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["proto-to-assign"]
});

Keywords

FAQs

Package last updated on 15 Jun 2015

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