All Projects → krzkaczor → Babel Plugin Proxy

krzkaczor / Babel Plugin Proxy

Licence: mit
Use ES6 proxies today!

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Labels

Projects that are alternatives of or similar to Babel Plugin Proxy

Xwasm
[Work In Progress] WebAssembly Packager and WASM tooling for modern frontend
Stars: ✭ 45 (-26.23%)
Mutual labels:  babel
Marvelheroes
Marvel Heroes
Stars: ✭ 54 (-11.48%)
Mutual labels:  babel
.dot Org Files
Dotfiles, Emacs + Org-mode with babel and Literate programming.
Stars: ✭ 57 (-6.56%)
Mutual labels:  babel
Todoist Js
!! OBSOLETE !! The (un)official Todoist javascript API library
Stars: ✭ 46 (-24.59%)
Mutual labels:  babel
React Boilerplate
Production-ready boilerplate for building universal web apps with React and Redux
Stars: ✭ 53 (-13.11%)
Mutual labels:  babel
Vue Dropload
vue下拉加载,简单路由,模态框组件等开发
Stars: ✭ 55 (-9.84%)
Mutual labels:  babel
Generator Expressjs Rest
Project template for an ExpressJS application
Stars: ✭ 41 (-32.79%)
Mutual labels:  babel
Babel Plugin Partial Application
[DEPRECATED] Please use https://github.com/citycide/param.macro
Stars: ✭ 60 (-1.64%)
Mutual labels:  babel
Parse Comments
Parse JavaScript code comments. Works with block and line comments, and should work with CSS, LESS, SASS, or any language with the same comment formats.
Stars: ✭ 53 (-13.11%)
Mutual labels:  babel
Tinker.macro
Evaluate Laravel code at build-time, via Laravel Tinker
Stars: ✭ 56 (-8.2%)
Mutual labels:  babel
Modularjs
△ Dead simple modular JavaScript framework for ES modules.
Stars: ✭ 52 (-14.75%)
Mutual labels:  babel
Babel Plugin Transform Scala Lambda
Enable Scala lambda style
Stars: ✭ 53 (-13.11%)
Mutual labels:  babel
Babel Plugin Root Import
Add the opportunity to import modules by the root path
Stars: ✭ 1,084 (+1677.05%)
Mutual labels:  babel
React Es6 Padawan To Jedi Book
Uma introdução simples e completa para React usando ES6 e Babel.
Stars: ✭ 46 (-24.59%)
Mutual labels:  babel
Envs
Component development environments for the Bit community
Stars: ✭ 58 (-4.92%)
Mutual labels:  babel
Tris Webpack Boilerplate
A Webpack boilerplate for static websites that has all the necessary modern tools and optimizations built-in. Score a perfect 10/10 on performance.
Stars: ✭ 1,016 (+1565.57%)
Mutual labels:  babel
Vue2 Web
酷我音乐—vue2、vue-router2、webpack2框架
Stars: ✭ 54 (-11.48%)
Mutual labels:  babel
React Starter Kit
React Starter Kit - Fiercely quick front-end boilerplate and workflows, React.js, Babel, PostCSS, Webpack
Stars: ✭ 61 (+0%)
Mutual labels:  babel
Simple Universal React Redux
The simplest possible Async Universal React & Redux Boilerplate app, that works on both Mac and Windows
Stars: ✭ 58 (-4.92%)
Mutual labels:  babel
Babel Plugin Css Prop
Babel plugin to transpile `css` prop to a styled component. (Experimental)
Stars: ✭ 56 (-8.2%)
Mutual labels:  babel

babel-plugin-proxy

JavaScript Style Guide

Use ES6 proxies today!

Installation

npm install babel-plugin-proxy --save-dev

Motivation

Proxies are awesome feature of ES2015 that enables redefining some language operations. For example we can intercept every object property access with our own function.

The problem is that proper proxy implementation requires native browser support (currently it works in Firefox and Edge). This plugin is proof of concept that proxies can be implemented with ES5 features. It is not suitable for production environments because performance impact is huge.

How does it work?

We are intercepting every property access (except these connected with function invocation) and property assignment with custom interceptor functions that performs runtime check if object is proxied.

proxy.foo = 5;
proxy.foo;

becomes:

globalSetInterceptor(proxy, "foo", 5);
globalGetInterceptor(proxy, 'foo');

These interceptors performs runtime check if object should be proxied. You can check out whole runtime here

Example

Proxies for example allow us to create objects that will warn us when undefined key is being accessed.

var proxy = new Proxy({}, {
    get: function(target, propKey) {
        if (!(propKey in target)) {
            console.log("Accessing undefined key!");
        }

        return target[propKey];
    }
});

proxy.a = 5;
console.log(proxy.a);
console.log(proxy.b);

output:

5
Accessing undefined key!
undefined
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].