# nodent-compiler

> NoDent - Asynchronous Javascript language extensions

Latest version **3.2.13** (published 2020-09-02) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install nodent-compiler
pnpm add nodent-compiler
yarn add nodent-compiler
bun add nodent-compiler
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.13 |
| Published | 2020-09-02 |
| First published | 2017-07-12 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 94.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Mat At Bread |
| Maintainers | matatbread |
| Keywords | Javascript, ES7, async, await, language, extensions, Node, callback, generator, Promise, asynchronous |

## Links

- npm: https://www.npmjs.com/package/nodent-compiler
- Repository: https://github.com/MatAtBread/nodent-compiler
- Homepage: https://github.com/MatAtBread/nodent-compiler#readme
- Issues: https://github.com/MatAtBread/nodent/issues
- npm.io page: https://npm.io/package/nodent-compiler

## Dependencies (4)

- [acorn](https://npm.io/package/acorn.md) >= 2.5.2 <= 5.7.5
- [source-map](https://npm.io/package/source-map.md) ^0.5.7
- [acorn-es7-plugin](https://npm.io/package/acorn-es7-plugin.md) ^1.1.7
- [nodent-transform](https://npm.io/package/nodent-transform.md) ^3.2.9

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 3.2.13 (latest) — 2020-09-02
- 3.2.11 — 2018-10-01
- 3.2.10 — 2018-09-18
- 3.2.9 — 2018-07-22
- 3.2.6 — 2018-05-02
- 3.2.5 — 2018-05-02
- 3.2.4 — 2018-04-30
- 3.2.2 — 2018-04-24
- 3.2.1 — 2018-04-20
- 3.2.0 — 2018-04-18
- 3.1.8 — 2018-04-10
- 3.1.7 — 2018-01-28
- 3.1.6 — 2018-01-25
- 3.1.5 — 2017-11-27
- 3.1.4 — 2017-11-22
- … 3 more at https://npm.io/package/nodent-compiler/versions

## README

[![NPM](https://nodei.co/npm/nodent-compiler.png?downloads=true&downloadRank=true)](https://nodei.co/npm/nodent-compiler/)

nodent-compiler
======

NoDent is a small module for Nodejs that implements the JavaScript ES7 keywords `async` and `await`. These make writing, reading and understanding asynchronous and callback methods more implicit and embedded in the language. It works by transforming the ES7 JavaScript keywords `await` and `async` to fully-ES5 compatible code.

This is the core compiler implementation. The main documentation and details for the CLI, require hook and package options, performance and testing can be found [here](https://github.com/MatAtBread/nodent/blob/master/README.md).

Usage
=====

```javascript
var NodentCompiler = require('nodent-compiler');
var compiler = new NodentCompiler() ;
var es5ReadySourceCode = compiler.compile(
  sourceCode,
  filename,
  { sourcemap:false, promises: true, noRuntime: true, es6target: true }
).code;
```

`new NodentCompiler(opts)` creates a new NodentCompiler. Note that instances of a NodentCompiler can (and should) be reused to improve compilation performance since internal structures are cached. `opts` is an optional set of options containing:

		log:<null|function>		// Called by the compiler to report a compilation warning.
		
`compiler.compile(sourceCode, filename, options)` compiles ES7 source code containing `async` and `await` to ES5 source code.

	sourceCode:<string>	// The source to compiler
	filename:<?string>	// Optional original filename for source maps
	options:<object>:
		es7:<boolean>,			// Compile in es7 mode
		promises:<boolean>,		// Compile in Promises mode
		generators:<boolean>,	// Compile in generator mode
		engine:<boolean>,		// Compile in engine mode
		sourcemap:<boolean>,	// Create a sourcemap for the browser's debugger
		wrapAwait:<boolean>,	// Allow 'await' on non-Promise expressions
		lazyThenables:<boolean>,// Evaluate async bodies lazily in 'es7' mode.
    	noRuntime:<boolean>,  	// Only compatible with promises & engine. Generate pure ES5 code for an environment that support Promises natively or as a global declaration.
    	es6target:<boolean>		// Compile code assuming an ES6 target (as of v3.1.0, this only requires support for arrow functions)

### Runtime requirements
[`nodent-runtime`](https://github.com/MatAtBread/nodent-runtime) must be available to generated code if `es7` or `generators` is set, or `noRuntime` is falsy.
`Promises` must be available to generated code if `promises`, `generators` or `engine` is set.

To generate code that requires no runtime support other than `Promises`, set `promises` and `noRuntime`.

---
_Source: https://npm.io/package/nodent-compiler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
