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

harmony-reflect

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

harmony-reflect

ES5 shim for ES6 (ECMAScript 6) Reflect and Proxy objects

  • 1.6.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.4M
increased by6.91%
Maintainers
1
Weekly downloads
 
Created

What is harmony-reflect?

The harmony-reflect package is a library for ECMAScript 2015 (also known as ES6) that provides a full implementation of the ES6 Reflect API and Proxy handlers. It allows developers to intercept and define custom behavior for fundamental language operations (e.g., property lookup, assignment, enumeration, function invocation, etc.) using the Proxy API. It also provides utility functions that mirror the standard Reflect API, which provides methods for interceptable JavaScript operations.

What are harmony-reflect's main functionalities?

Proxying an object

This code demonstrates how to create a proxy for an object that returns the property value if it exists, or 42 if it does not.

{"handler": {"get": function(target, name) { return name in target ? target[name] : 42; }}, "proxy": new Proxy({}, handler)}

Reflecting property access

This code uses the Reflect API to access the property 'foo' on the target object.

{"target": {"foo": 1}, "status": Reflect.get(target, 'foo')}

Defining a property on an object

This code snippet uses Reflect.defineProperty to define a new property 'foo' on the target object with the value 123.

{"target": {}, "status": Reflect.defineProperty(target, 'foo', {value: 123})}

Observing function invocations

This code shows how to create a proxy for a function that intercepts the call and returns the result multiplied by 2.

{"handler": {"apply": function(target, thisArg, argumentsList) { return target.apply(thisArg, argumentsList) * 2; }}, "proxy": new Proxy(function(x) { return x; }, handler)}

Other packages similar to harmony-reflect

Keywords

FAQs

Package last updated on 15 Apr 2021

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