Giter Site home page Giter Site logo

let-er's People

Contributors

getify 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  avatar

let-er's Issues

investigate a flag (or feature-test) to use the actual `let` keyword instead of try/catch

ES6 is adding the let keyword, which will allow block-scoped variable declarations like so:

if (something) {
   let isTrue = something;
   console.log(isTrue);
}
isTrue; // ReferenceError

Unfortunately, the better let (foo) { .. } style of code (which btw works in FF since forever), is not supported, which is why BlockScoper will be useful not only today but into the future.

This code transpiler currently makes the try/catch rewrite for let blocks, but it would probably be nice to have it be able to use the new let keyword in the future once it arrives via ES6.

For instance, we can use naked blocks, and use the style I suggested here: https://gist.github.com/getify/5285514

So, the code transpilation for let (foo) { .. } could just be in ES6:

/*let*/{ let foo;
  // ..
}

Need to investigate whether this would just be a flag you used to switch between try/catch and let declarations, or if there's anyway feasible to have a runtime feature-test for let to automatically switch. Probably not, but worth exploring briefly.

A smaller syntactically valid error throwing expression

To significantly reduce the download size of the library, the expression ''() which is used to throw an error could be replaced with 0().

This would need thorough investigation to ensure it is syntactically valid in all environments.

grunt

make a grunt contrib task for let-er, dummy. :)

consider swapping to purely --es6 mode only

Consider simplifying this tool to purely transpile to the ES6 equiv syntax (like the --es6 tag does), and avoiding any of the try..catch ES3 stuff, deferring that to some other tool. That would make it clearer that the point of this tool is to put it into the build process before something like traceur.

some comments not kept

In the following snippet, the comments are not kept. Investigate how, if any, to keep them.

let /*not-kept*/
     // neither is this one
  (a,b,c) /* and neither this one */ // or this one
{
   a = b * c;
}

support multiple let declarations at once, and support assignments

Currently, only this style is supported:

let (foo) { .. }

Need to support usage like this:

let (foo = 42, bar) { .. }

The way to handle multiple declarations is to have nested try/catch's, and the way to handle assignments appears to be to change the value being thrown from void 0 to the assigned value in question. For example:

try{throw 42}catch
/*let*/(foo) {
   try{throw void 0}catch
   /*let*/(bar) {
      // ...
   }
}

explore if `let` declarations should ALSO be transpiled

Should BlockScoper insert let blocks anywhere that it finds declarations like let foo = 42;?

The problem that will make that hard to do would be that let declarations are hoisted to the nearest containing block, so to insert a let block in the right place (not just where the letdeclaration is found), I'll have to actually do full JS parsing and not just regex style pattern matching. That takes this whole thing to a much more complicated level. But it's worth exploring I suppose.

typo in readme, re: let(...)

ES6 is going to give us the let operator, which will let us do things like let (foo) { .. }

let-statements and let-expressions won't be in ES6

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.