New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-use-async

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-use-async - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json

@@ -13,3 +13,3 @@ {

"repository": "warncke/babel-plugin-use-async",
"version": "0.0.1"
"version": "0.0.2"
}

@@ -10,3 +10,3 @@ # babel-plugin-use-async

`async` and `await` are great but in practice the vast majority of `async`
function calls get `await`'d and they are subject to the
function use `await` and they are subject to the
[What Color is Your Function](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/)

@@ -17,5 +17,5 @@ critique.

and specifications. While that is an entirely reasonable design goal it creates
the problem of not knowing whether a call to an `async function` without an
the problem of not knowing whether a call to an async function without an
`await` is intentional or accidental and the annoyance of having to litter your
code with `await`s.
code with `await` statements.

@@ -25,12 +25,12 @@ `"use async"` is an option, modeled on `"use strict"`, that makes the following

* in `async function`s:
* calls to `async function`s are `await`'d by default
* the `async` keyword can be used before an `async function` call
to indicate that it should not be `await`'d
* in async functions:
* calls to async functions are await'd by default
* the `async` keyword can be used before an async function call
to indicate that it should not be await'd
* `await` works as before
* in plain `function`s:
* calls to `async function`s *without* the `async` keyword before them
* in plain functions:
* calls to async functions *without* the `async` keyword before them
will throw an error
* calls to regular `function`s *with* the `async` keyword will throw an
* calls to regular functions *with* the `async` keyword will throw an
error

@@ -41,15 +41,8 @@ * `await` is invalid as before

sequential control flow and the ambiguity about whether or not a function call
should be `await`d is eliminated.
should be await'd is eliminated.
Requiring `async` to be used when calling `async` from non-`async` functions
Requiring `async` to be used when calling async functions from plain functions
prevents a similar ambiguity from arising with regards to whether or not a
function was intended to be `async`.
`await` is only ever needed when calling to code that does not use
`async function`s. `await` could be eliminated entirely by implementing
`await <Promise>` as `(async () => <Promise>)()` but this seems unnecessary.
In practice `await` will disappear from the vast majority of code once
`"use async"` is in place.
This proposal aims to resolve the issues raised by

@@ -97,3 +90,3 @@ [Proposal to add keyword "nowait"](https://esdiscuss.org/topic/proposal-to-add-keyword-nowait)

`await` by requiring the `async` keyword to be used when calling
`async function`s from regular functions.
async functions from regular functions.

@@ -157,3 +150,3 @@ ## Missing async on function declaration

const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor

@@ -164,7 +157,7 @@ async function foo() {

This does not work for code that does not use real `async function`s and it is
This does not work for code that does not use real async functions and it is
not intended to.
The goal here is to remove ambiguity about how code will behave at runtime so
regular functions that return Promises should not be implicitly `await`'d.
The goal here is to reduce ambiguity about how code will behave at runtime so
regular functions that return Promises should not be implicitly await'd.

@@ -191,3 +184,3 @@ ### Benchmarks

const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor
class AsyncError extends Error {

@@ -194,0 +187,0 @@ constructor(message) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc