$ npm install --save babel-cli babel-preset-es2015
$ npm install --save-dev jasmine
.babelrc:
{
"presets": ["es2015"]
$ npm install --save babel-cli babel-preset-es2015
$ npm install --save-dev jasmine
.babelrc:
{
"presets": ["es2015"]
A lot of people mentioned other immutable JS libraries after reading my post. I thought it would be good to make a list of available ones.
There are two types of immutable libraries: simple helpers for copying JavaScript objects, and actual persistent data structure implementations. My post generally analyzed the tradeoffs between both kinds of libraries and everything applies to the below libraries in either category.
Libraries are sorted by github popularity.
var uniqueArray = function(arrArg) { | |
return arrArg.filter(function(elem, pos,arr) { | |
return arr.indexOf(elem) == pos; | |
}); | |
}; | |
var uniqEs6 = (arrArg) => { | |
return arrArg.filter((elem, pos, arr) => { | |
return arr.indexOf(elem) == pos; | |
}); |
// Groovy's Elvis operator | |
// | |
// lhs ?: rhs | |
// | |
// is equivalent to: | |
// | |
// lhs == null ? rhs : lhs | |
// | |
// or: | |
// |
In React's terminology, there are five core types that are important to distinguish:
React Elements
This Gist presents a new design of class-based object construction in ES6 that does not require use of the two-phase @@create protocol.
One of the characteristics of this proposal is that subclass constructors must explicitly super invoke their superclass's constructor if they wish to use the base class' object allocation and initialization logic.
An alternative version of this design automatically invokes the base constructor in most situations.
if ( typeof document.currentScript == "undefined" && document.__defineGetter__ ) { | |
document.__defineGetter__("currentScript", function (){ | |
try { | |
throw new Error() | |
} | |
catch ( e ) { | |
var qualifiedUrl = location.protocol + "//" + location.host | |
, srcs = e.stack.match(new RegExp(qualifiedUrl + ".*?\\.js", 'g')) | |
, src = srcs[srcs.length - 1] | |
, absoluteUrl = src.replace(qualifiedUrl, "") |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
A design rationale.
See first: In-Application Sandboxing with Web Workers.
Web Workers interact with their Host Pages using a messaging channel (the postMessage
API). Crucially for their programming model, the messages are asyncronous. This introduces a significant challenge for implementing Page APIs within a Worker – for instance, how do you port a GUI widget from the Page (where it can access the DOM) to a Worker, where it can only send async messages?
In my experience, two categories of solutions are suggested: use code-transformations to recreate Page-native APIs in the Worker, or introduce a new interface around messaging. In this gist, I'll explain why code transformations don't address the problem fully, and present a complete messaging solution based on HTTP.
A design rationale.
For the past fews years, the Web has been shifting control to the client. Given the limitations of remote services, developers are now looking for ways to "unhost" static applications – that is, break the dependency on remote servers while still using the Web platform.
One untapped technology for client-side control is the Web Worker Sandbox. This API lets the Page load, execute, and destroy separate Worker threads which use their own Virtual Machines. By using Worker Sandboxes to drive behavior, the Web can give users the choice of which software they run together, shifting development from a centralized SaaS model into a distributed and free (as in freedom) script-sharing model.
Worker Sandboxes can Execute Arbitrary Code