• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    JavaScript
  • Created over 7 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use `await` at your Node.js code's top level!

top-level-await (PoC)

Allow using await at your code's top level. Requires Node.js v7.6.0 or higher.

Not this:

// 💩
(async function() {
  console.log(await Promise.resolve('hello world'));
})();

But this:

// 🎉
console.log(await Promise.resolve('hello world'));

Installation

npm i top-level-await

Usage

It's a two-step process: first require() this module, then require() the rest of your code:

// bootstrap.js
require('top-level-await');
require('./app');

Inside app.js, you can use await whenever you like.

You can also tell Node to require the module for you, instead of using a separate bootstrap script:

$ node -r top-level-await app

Which works for CLI tools too:

#!/usr/bin/env node -r top-level-await

console.log( await Promise.resolve('hello world') );

How?

By hacking Module.wrap().

This is done without prejudice, so all modules that get loaded after loading this module will be "fixed".

Is it production-ready?

¯\_(ツ)_/¯

More Repositories

1

dsm7-usb-serial-drivers

Synology DSM 7 USB serial drivers
C
372
star
2

quotefixformac

QuoteFix for Apple Mail —
Python
192
star
3

node-mbox

mbox file parser for Node.js
JavaScript
68
star
4

ToggleProxy

Mac OS X menu item for quickly enabling/disabling proxies.
Python
42
star
5

bosch-xmpp

Protocol implementation for Bosch XMPP protocols
JavaScript
38
star
6

nefit-easy-http-server

HTTP server to access Nefit/Bosch XMPP backend over HTTP
JavaScript
38
star
7

node-instapaper

Instapaper API client for Node.js
JavaScript
34
star
8

node-benchr

Node.js benchmark runner
JavaScript
27
star
9

node-metrohash

Node.js bindings for MetroHash
C++
25
star
10

node-monkeypatch

Slightly easier monkeypatching
JavaScript
22
star
11

node-trakt-api

Trakt API v2 client for Node.js
JavaScript
21
star
12

nefit-easy-core

Core functionality to implementation communications with Nefit/Bosch backend.
JavaScript
20
star
13

nefit-easy-client

Nefit Easyâ„¢ client for Node.js
JavaScript
15
star
14

nefit-easy-commands

High-level command implementation for Nefit Easyâ„¢ clients.
JavaScript
14
star
15

homebridge-klikaanklikuit

Homebridge plugin for KlikAanKlikUit outlets
JavaScript
14
star
16

homebridge-nefit-easy

Homebridge plugin for Nefit Easyâ„¢
JavaScript
14
star
17

nefit-easy-cli

Command line interface for communications with Nefit/Bosch backend.
JavaScript
14
star
18

buffered-ext-list-sencha-touch-2

Buffered Ext.List for Sencha Touch 2
JavaScript
13
star
19

name.klep.homekitty

HomeyKit 3.0
JavaScript
13
star
20

node-port-mux

TCP port multiplexer: run multiple services through the same port
JavaScript
13
star
21

node-sabnzbd

Node interface for SABnzbd
JavaScript
11
star
22

qbittorrent

Node.js qBittorrent API client
TypeScript
11
star
23

name.klep.homekit-controller

HomeKit Controller — Allow Homey to control HomeKit-enabled devices
JavaScript
9
star
24

react-boilerplate

React.js (+ Express + Browserify) boilerplate
JavaScript
9
star
25

name.klep.sonoff

Homey driver for Sonoff devices
HTML
7
star
26

homey-mocks

Mock objects for Homey pairing/setting pages
JavaScript
7
star
27

node-kaku-rpi

Node.js KlikAanKlikUit (KaKu) driver for Raspberry Pi
JavaScript
7
star
28

homey-app-upload

Homey App Upload
JavaScript
4
star
29

name.klep.transitions

Homey app — Flexible Time Transitions
JavaScript
4
star
30

node-dsmr-parser

Dutch Smart Meter Requirements protocol parser
JavaScript
4
star
31

supergenpass-cli

CLI wrapper around supergenpass-lib
JavaScript
4
star
32

socks-proxy

SOCKS5 proxy with whitelisting and built-in admin
JavaScript
3
star
33

node-rewriting-proxy

A Node.js-based request/response rewriting HTTP proxy
JavaScript
3
star
34

node-filtering-proxy

Standalone Node.js based HTTP/HTTPS proxy with request/response modification
JavaScript
2
star
35

ancs2mqtt

Use an ESP32 to relay iOS notifications to MQTT
C++
2
star
36

name.klep.flow-event-bus

Homey app to implement a flow event bus
JavaScript
2
star
37

css-tabs

Dirt-simple CSS tabs
2
star
38

NPMJSSearch

Makes searching search.npmjs.org from Chrome easier.
JavaScript
2
star
39

homey-log-to-file

Capture stdout/stderr of Homey app to a logfile
JavaScript
2
star
40

node-nzb-name-parser

NZB filename parser for Node
CoffeeScript
1
star
41

name.klep.homekit.presence

HomeKit occupancy accessory to provide presence status for Homey users
JavaScript
1
star
42

node-nzb-cleanup

Clean up NZB file names
JavaScript
1
star
43

blurizr

Make a Hip Blurry Backgroundâ„¢ from any photo, directly in your browser!
1
star
44

package-bundler

Bundle a Node.js package into a single file.
JavaScript
1
star
45

FeedbackSlider

Sencha Touch 2 implementations of Ext.slider.Slider and Ext.field.Slider with textual feedback.
JavaScript
1
star
46

bas64r

Client side data-URL generator using HTML5 API's
1
star