// Current ES spec grammar
1 + yield // error
1 + yield 2 // error
yield + 1 // yield (+1)
yield 1 + yield 2 // error
yield(1) + yield(2) // error
yield 1 + 2 // yield (1+2)
yield * yield // (yield *) yield
yield + yield // error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
// The default system module loader exposed by ES6 on the | |
// global object. | |
Object.system = { | |
load: function(name, callback, errback) { | |
// ... | |
}, | |
loaded: {} | |
} | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global) { | |
// TODO: Delegate to parent loader in various places | |
// TODO: Canonicalization | |
// TODO: Can we do better for 'eval'? | |
/// Module loader constructor | |
function Loader(parent, options) { | |
// Initialization of loader state from options |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#1 | |
// Current spec would suggest that this is an early error during compilation of the main code. | |
// However, dynamically, the "x=20" will write to the "var x" declared inside g. | |
// This is a case where the early error for assignments to const variables appears to overreach, flagging an error which will not actually occur if the code were allowed to run. | |
function f() { | |
const x = 5; | |
function g() { | |
eval(“var x = 10”); | |
x = 20; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Things I want to be able to do: | |
a) Bind a name to a remote module | |
b) Alias a name for a module | |
c) Alias a name for a member of a remote module | |
d) Put all names from inside a module in lexical scope | |
e) Put all names from inside a remote module in lexical scope | |
f) Put a few names from inside a module in lexical scope | |
g) Define a local module | |
h) Export names from lexical scope | |
i) Re-export names from other modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you are starting with a file from a picker, something like this should work: | |
var picker = new Windows.Storage.Pickers.FileOpenPicker(); | |
picker.fileTypeFilter.replaceAll(['.jpg', '.jpeg']); | |
picker.pickSingleFileAsync().then(function (file) { | |
return file.openAsync(Windows.Storage.FileAccessMode.read); | |
}).done(function (ras) { | |
var blob = MSApp.createBlobFromRandomAccessStream('image/jpeg', ras); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Spawn function inspired by Q.async at http://wiki.ecmascript.org/doku.php?id=strawman:async_functions#reference_implementation | |
// Takes an ES6 generator function and produces a WinJS.Promise | |
function spawn(generatorFunc) { | |
return new WinJS.Promise(function (c, e) { | |
var generator = generatorFunc(); | |
var callback = continuer.bind(void 0, 'send'); | |
var errback = continuer.bind(void 0, 'throw'); | |
function continuer(verb, valueOrErr) { | |
var promisedValue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using bin/typescript.js from TypeScript 0.9.7 | |
function compile(source) { | |
var parseErrors = []; | |
var logger = new TypeScript.NullLogger(); | |
var compilationSettings = TypeScript.ImmutableCompilationSettings.defaultSettings(); | |
var compiler = new TypeScript.TypeScriptCompiler(logger, compilationSettings); | |
var snapshot = TypeScript.ScriptSnapshot.fromString(source); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
- jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
- Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
- AngularJS - Conventions based MVC framework for HTML5 apps.
- Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
- lawnchair - Key/value store adapter for indexdb, localStorage
OlderNewer