Node v8.1.2
nodejs.org
nodejs.org
Debugging async functions (server-side) is a lot better now that there is no transpiler mangling my code beyond recognition.
{
"files": [],
"compilerOptions": {
"baseUrl": ".",
"moduleResolution": "node",
"target": "es2017",
"jsx": "react",
"experimentalDecorators": true,
"sourceMap": true,
"skipDefaultLibCheck": true,
"lib": [ "es2017", "dom" ],
"allowJs": false,
"paths": {
"*": [ "./ClientApp/types/*", "*" ]
}
},
"exclude": [
"bin",
"obj",
"node_modules"
]
}
edit: remove unneeded entriesAlso:
"*": [ "./ClientApp/types/*", "*" ]
I like that. I may have to add it to my app and get rid of our typings.d.ts (currently included through "files") once and for all.But you are right: typescript or those dependencies have improved and they are no longer necessary. I removed them and everything still works.
What tools do you folks use to monitor your node dependencies and make sure you are keeping everything up to date?
`npm update --save` or `npm update --save-dev` say explicitly "save updates to `dependencies` resp. `devDependencies`", which causes duplication between dependencies and devDependencies. (Say you have a dep foo and a devDep bar and both are outdated: `npm update --save` will bork package.json with an additional incorrect dep bar, and `npm update --save-dev` will bork it with an additional incorrect devDep foo :-/ )
Am I missing something? I understand there are 3rd-party packages providing such functionality, but is there any reason to not cover this feature in npm?
I was thinking of making dependency-updates part of the CI-pipeline, using a 'allow_failure'-flag. However, if you decide not to upgrade a dep for some reason, this will cause each and every build to throw a warning.
Mostly I just really like the compact output, and the short "ncu" command which I run every day to check what's available :)
Notably, it brings async/await syntax to vanilla JS. This new feature complements callbacks and largely replaces how Promises are currently consumed (opting for sequential-like execution with try/catch blocks instead of Promise chains).
The closest analogue would be Tasks in C#.
EDIT: removing reference to node-v8 to prevent confusion.
https://github.com/utilise/emitterify/issues/1#issuecomment-...
The way it is now, I defensively await things all over the place. What's worse, it propagates. If any of your function's dependencies are async, your function will also have to be async (or be ok with continuing operation after it's returned) and it turtles all the way down.
It is nicer than having to deal with promises directly though, there is that.
But it still beats promises or callback hell.....
JS async produces Promises like C# produces Task, so you can call an async function and use the result as a Promise.
And then() hell ...
Also notable is that async/await isn't new for node, 7.10 supported it (and previous versions with a flag). It's new for a LTS release. What is new, however, is the in-built util.promisify that can convert callbacks into native promises.
Yeah, a lot of companies won't touch non-LTS Node though, so a lot of users won't use async/await until later this year when the next LTS is released (Oct 2017).
Except in their official release blog posts, it seems :-D
Another fine example of JavaScript trying to be hip and ignoring the lessons learned from countless other languages over the years.
I see this constantly with JS like with the 3+ ways to check for NaN and the object "freeze" system that doesn't actually make objects immutable. They take a solid concept from other languages then put a snazzy spin on it that makes it fucking useless. Then try again in the next version. JS library and syntax is littered with corpses of failed experiments.
At least they finally have a usable ForEach loop after three attempts.
Please typescript save us from this hubris.
Otherwise the argument collapses to: we don't need any of these features, we just need NAND.
Pending the implementation of new language syntax, raw Promises were a practical solution for what they set out to accomplish. If you don't think they improved callback hell at all, I expect that you probably weren't using them correctly (an easy mistake to make without looking at the documentation and/or reading the wrong tutorials / blog posts).
cf.
getAsyncValue1(a =>
getAsyncValue2(a, b =>
getAsyncValue3(b, c =>
doSomething(c)
)
)
);
and getAsyncValue1().then(a =>
getAsyncValue2(a)
).then(b =>
getAsyncValue3(b)
).then(c =>
doSomething(c)
);
Sure, async/await flattens that to zero nested callbacks, which is great, but with that off the table I'd rather deal with code flattened to one level deep (or a few, in some edge cases) than arbitrarily many. And that's just the "callback hell" improvement; don't forget what a nightmare error handling with callbacks can be — you have to handle both synchronous exceptions and error value callback parameters, you have to deal with the possibility of the asynchronous function unexpectedly calling your callback more than once, etc.