Open jonahsnider opened 3 years ago
hi , if you targeting js you need compare to asyncjs module, it has subset interfaces of asyncfuture, and doesn't support chained promise.that's the major differiences I've found.
It's a wiki, feel free to modify it :)
@bung87 @pizzafox interested in making those changes in the wiki? Or maybe @juancarlospaco?
I'm not really comfortable enough with Nim confidently write that kind of documentation. I am however very knowledgeable in TypeScript and would be happy to give more advice on that side of things.
Summary
This is a documentation only issue.
The Nim for TypeScript Programmers is great but is currently missing information about the similarities between Nim's
Future
s and TypeScript/JavaScript'sPromise
s, as well as how asynchronous functions behave.Description
Here is a table I've compiled of Nim
asyncfutures
features and their respective JavaScript counterparts:Future[T]
Promise<T>
newFuture[T]
new Promise<T>()
complete
Promise.resolve()
fail
Promise.reject()
addCallback
Promise.prototype.then()
`and`
Promise.all()
`or`
Promise.race()
all
Promise.all()
Additional Information
The above information only mentions
Promise
s, not any of the behavior with asynchronous functions, which do not behave identically to functions that return aPromise
. I don't know enough about Nim'sasync
pragma to write about that.