Socket
Book a DemoInstallSign in
Socket

@littledan/plugin-transform-operator-overloading

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@littledan/plugin-transform-operator-overloading

Babel plugin for a transform for an operator overloading proposal

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

This package implements an operator overloading proposal for JavaScript as a Babel plugin.

To use the plugin, run the following commands for installation

npm install --save-dev @littledan/plugin-transform-operator-overloading
npm install --save-prod @littledan/operator-overloading-shim

and add the following to your .babelrc:

{
  "plugins": ["@littledan/plugin-transform-operator-overloading"]
}

If you encounter any issues, including unexpected behavior, poor performance, weird ergonomics, etc, please file an issue.

  • Use with operators from declarations just in code that needs it, rather than at the top level of the module. This makes the transformation only apply to that code, reducing the predictability and performance impact.
  • When creating a library that exposes operator overloading, expose a method-based interface as well, to support usage without this transform.
  • Note that overloading [] or []= results in the creation of a Proxy; carefully consider whether this is appropriate for performance-sensitive code.

Deviations from proto-specification behavior

  • Rather than using the syntax with operators from ABC, use the syntax withOperatorsFrom(ABC)
  • When outside of any block which has a with operators from declaration, this transform treats objects with overloaded operators as if they didn't have overloading (and therefore undergo coercion like objects), whereas the spec behavior would be to throw a TypeError.
  • The underlying operator-overloading-shim does not protect against introspection of symbols or monkey-patching in the environment. Error checking behavior may be somewhat weaker.

Keywords

operator-overloading

FAQs

Package last updated on 26 Dec 2018

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