Code Monkey home page Code Monkey logo

awesome-es2015-proxy's Introduction

proxy-fun

🐐 For learning how to use JavaScript Proxy, or just to see what is possible through metaprogramming in modern JavaScript. Tries to collect resources such as presentations, articles, modules and examples using Proxy, Reflect and other intercession type metaprogramming.

The Proxy object was included in the ES2015 iteration of the standard and is available in all evergreen browsers and Node.js v6. Unfortunately as it is a big language semantic change, it cannot be polyfilled through transpilers such as Babel.

Know of any brilliant resources? Let us know and we'll create a vast collection of awesomeness.

JavaScript ES2015 Proxy

Proxies are a common pattern in both programming and networking. It often entails something interfacing with something else. Usually a proxy takes the role of the original contstruct and intercepts calls made to that construct and in some cases altering it's original behaviour. This allows you to enrich functions with more actions or operations in a transitive manner, or even intercept and cancel an action.

A proxy can be looked at as a decorator function, but with you can intercept default language semantics also, in a meta-level of programming instead of at the base-level.

TL;DR? See an overview of examples using JavaScript Proxy in the summary.

Proxy Resources

Presentations

Videos

Articles

Modules

  • slice: Slice implements Python's extended slice syntax and negative indexing in JavaScript using proxies.
  • zer: Zer helps you serialize any JavaScript chains to String representations of any languages by leveraging ES2015 Proxy objects
  • negative-array: Negative array index support array[-1] using ES2015 Proxy
  • tpyo: A small script that enables you to make typos in JavaScript property names. Powered by ES6 proxies + Levenshtein string distance.
  • stevia: Experimental module providing natural sweetening for javascript objects
  • known: Allow only access to known object properties using ES2015 Proxy
  • iSeries: A set of modules that use Proxy to extend and enhance your existing JavaScript classes.
  • proxy-observe: A Proxy based implementation of Object.observe
  • Experimental Safe JavaScript Navigation : The purpose of this function is to provide a way to avoid deep nested conditionals when traversing a hierarchy of objects
  • allora: Promisify everything in less tha ~50 lines It can be used to use promises on any javascript object.
  • stroxy: A simple streaming wrapper for native event functions (e.g. addEventListener) using ES2015 proxies.
  • Declaraoids: Declarative programming on steroids.
  • python-range: A JavaScript implementation of the Python's range() function.
  • rebridge: Transparent Javascript-Redis bridge.
  • box-js: A tool for studying JavaScript malware.
  • v: Secure, Synchronized, Realtime, Cloud, Native JavaScript Variables & Events.
  • Promiser: Promise combination resolver by get accessor pattern.
  • React Easy State: A transparent state management library for React.
  • The Observer Utility: A general purpose transparent reactivity library (React Easy State is just a thin wrapper of it). It uses ES6 Proxies to achieve a 100% language coverage for reactivity.
  • The Compiler Utility: A 'sandboxed' code evaluation library. It uses ES6 Proxies (has traps) in conjuction with the with keyword to 'sandbox' code.
  • Did I do that?: A debug tool based on JavaScript Proxy to track surprising/unwanted mutation of objects.
  • mewt: Array and object immutability implemented in under one kilobyte using Proxies.
  • objecthistory: Object undo, redo & change history using Proxies.
  • hoopy: Circular array type
  • emmis: Chaining API where you reduce over payload and operators, like redux
  • rus_roulette: Bringing runtime errors back to fashion
  • Echo: Write a line of code that starts with Echo, and Echo will print it back to the console.
  • Comlink: Uses proxies to hide the fact that you're using Web Workers.
  • enum-xyz: JavaScript enums using proxies.

Meta-programming in general

Resources not using JavaScript Proxy, but shows different usages of creative and awesome meta-programming to be used as inspiration.

Articles

Modules

  • jsPipe: Implementing pipes in Javascript using pseudo operator overloading.
  • JSDecorators: Python like decorators in Javascript with pseudo operator overloading.

Examples in this repo

Run all examples in this repo by using node@6:

$ node ./examples/<example-file>.js

Examples using tracing and tests can be run using npm:

$ npm test

Remember to install all example dependencies by doing npm i

awesome-es2015-proxy's People

Contributors

arfatsalman avatar capacitorset avatar chasefleming avatar christianalfoni avatar diegorbaquero avatar hemanth avatar mikaelbr avatar mischah avatar mrjacobbloom avatar nilssolanki avatar philbooth avatar sangaline avatar sdgluck avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

awesome-es2015-proxy's Issues

Add Echo and ComLink to the list

I've been working on a silly little proxy toy called Echo that could be a fun addition to this list: https://github.com/mrjacobbloom/echo -- it prints whatever line of code you write, as long as it starts with Echo.

Also, ComLink is a very cool library that uses proxies to simplify communication between Web Workers. I definitely think it should be on here

Suggestion: Perhaps you could add this gist

I made this gist recently as a proof of concept of what Proxies could do after watching one of your talks (I believe it was you, the guy giving the talk certainly directed everyone to this github[ really enjoyed it by the way]).

Anyhow, its a proxy constructor that allows you to place promises on the object's body, then accessed them from a chained set of properties. (sorry, i may not be explaining it very well. showing is best);

var obj = Promiser({
    a: new Promise((res,rej)=>setTimeout(()=>res(1), 1000)),
    b: new Promise((res,rej)=>setTimeout(()=>res(2), 1000)),
    c: new Promise((res,rej)=>setTimeout(()=>res(3), 1000)),
    d:1,
    e:2,
    f:3,
});


console.log( await obj.a.b.c.f.e ); //prints { a:1, b:2, c:3, f:3, e:2 }  in approx 3s
console.log( await obj.a.b.c ); //prints { a:1, b:2, c:3 } almost immediately

just thought that your repo was a great resource for people looking for things regarding proxies, since there aren't many out there.

https://gist.github.com/jasuperior/5d339f9c2572b3bb52d487de4086a3b2

Consider adding react-easy-state, the observer utility (and the compiler utility)

  • React Easy State is a transparent state management library for React.

  • The Observer Utility is a general purpose transparent reactivity library (React Easy State is just a thin wrapper of it). It uses ES6 Proxies to achieve a 100% language coverage for reactivity.

  • The Compiler Utility is a 'sandboxed' code evaluation library. It uses ES6 Proxies (has traps) in conjuction with the with keyword to 'sandbox' code. This library gets less dev time from me than the former two nowadays.

Please add the ones you like from these. Thanks! πŸ™‚

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.