Did you know about ES6/ES7 and babel? It allows you to write code like this:
const readFile = promisify(require('fs').readFile);
async function f(filename) {
const content = await readFile(filename);
return content.trim().length;
}
I'm not sure another async syntax on top of JavaScript will have a chance
of gaining traction at this point, unless there are very compelling reasons.
* The async/await ECMAScript
proposal: https://github.com/tc39/ecmascript-asyncawait/
* babel: https://babeljs.io/
Your project can still be a lot of fun, just mentioning this as a potential
alternative. :)
Cheers,
Jan
On Monday, May 4, 2015 at 8:12:13 AM UTC-7, ami wrote:
>
> Hello everyone.
>
> I thought about a solution how to solve the callback hell.
>
> var a=asyncFunction1(parameters,function(err,param1){
> var b=asyncFunction2(parameters,function(err,param2){
> if (err) console.log(err)
> console.log('here')
> }
>
> I want to create new syntax for calling to async functions.
> The new syntax will be as extension to JavaScript (like TypeScript, or
> CoffeScript but minimalist change to the JS code).
> It will be compiled just before Node.jS running the JavaScript.
>
> I have created new GitHub repository. And I want to start developing it. (
> https://github.com/AminaG/HeavenScript)
> I am searching for other developers, who want to join me in this project.
> I need help in 2 things:
> 1. IDE's intellisense. Because I am changing little bit the JavaScript,
> all IDE's will create warnings. So I need to create new definition files
> for them (IntelliJ, SublimeText, VS, etc;) Who here know how to do it?
> 2. Help me with English. My development skills, are much better than
> English. So for explanations, and create README file, I need help.
>
> //******************************
> the new syntax:
>
> a=@asyncFunction1(param1)
> err,b=@asyncFunction2(param2)
> console.log('now we can access to a,b')
>
> it will be converted to
>
> asyncFunction1(param1,function(err,a){
> if(err) throw err;
> asyncFunction2(param2,function(err,b){
> console.log('now we can access to param1, param2')
> })
> })
>
>
> //******************************
> One More Example:
>
> See how much it is easier and readable to write it in HeavenScript
>
> function theBlock(){
> a=@asyncFunction1(param1)
> err,b=@asyncFunction2(param2)
> console.log('Now we can access a,b,err')
> if (err) {console.log('error in function2'),
> err,c=@asyncFunction3(param3) {
> console.log('Now we can access a,b,c')
> }
> d=@asyncFunction4(param4)
> console.log('Now we can access only to a,b. c is in another scope')
> }
>
> (304 characters)
>
> It will be converted to:
>
> asyncFunction1(param1,function(err,a){
> if(err) throw err
> asyncFunction2(param2,function(err,b){
> console.log('Now we can access a,b,err')
> if (err) console.log('error in function2')
> asyncFunction3(param3,function(err,c){
> console.log('Now we can access a,b,c')
> })
> d=asyncFunction4(param4,function(err,d){
> if(err) throw err
> console.log('Now we can access only to a,b. c is in another
> scope')
> })
> })
> })
>
>
> (391 characters)
>
> What do you think?
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/0cbbf27b-fe45-47f6-9651-dc5a801e25ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.