# mkast

> Abstract syntax tree transformer

Latest version **1.2.12** (published 2016-12-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install mkast
pnpm add mkast
yarn add mkast
bun add mkast
```

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.12 |
| Published | 2016-12-05 |
| First published | 2016-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | muji |
| Maintainers | muji |
| Keywords | markdown, commonmark, parser, stream, ast |

## Links

- npm: https://www.npmjs.com/package/mkast
- Repository: https://github.com/mkdoc/mkast
- Homepage: https://github.com/mkdoc/mkast#readme
- Issues: https://github.com/mkdoc/mkast/issues
- npm.io page: https://npm.io/package/mkast

## Dependencies (3)

- [through3](https://npm.io/package/through3.md) ~1.1.5
- [commonmark](https://npm.io/package/commonmark.md) github:tmpfs/commonmark.js#develop
- [stream-lines](https://npm.io/package/stream-lines.md) ~1.2.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.2.12 (latest) — 2016-12-05
- 1.2.11 — 2016-04-23
- 1.2.10 — 2016-04-18
- 1.2.8 — 2016-04-03
- 1.2.7 — 2016-04-02
- 1.2.6 — 2016-04-01
- 1.2.5 — 2016-03-30
- 1.2.3 — 2016-03-23
- 1.2.2 — 2016-03-22
- 1.2.1 — 2016-03-22
- 1.2.0 — 2016-03-22
- 1.1.22 — 2016-03-22
- 1.1.21 — 2016-03-22
- 1.1.20 — 2016-03-21
- 1.1.19 — 2016-03-21
- … 22 more at https://npm.io/package/mkast/versions

## README

# Tree

[![Build Status](https://travis-ci.org/mkdoc/mkast.svg?v=3)](https://travis-ci.org/mkdoc/mkast)
[![npm version](http://img.shields.io/npm/v/mkast.svg?v=3)](https://npmjs.org/package/mkast)
[![Coverage Status](https://coveralls.io/repos/mkdoc/mkast/badge.svg?branch=master&service=github&v=3)](https://coveralls.io/github/mkdoc/mkast?branch=master)

> Converts nodes to and from JSON

Transforms [commonmark][] nodes to and from JSON for piping between processes.

## Install

```
npm i mkast
```

---

- [Install](#install)
- [Usage](#usage)
- [API](#api)
  - [parser](#parser)
  - [deserialize](#deserialize)
  - [serialize](#serialize)
- [License](#license)

---

## Usage

Serialize [commonmark][] nodes to line-delimited JSON:

```javascript
var mkast = require('mkast')
  , ast = mkast.parse('# Title\n<? @include file.md ?>');
mkast.serialize(ast).pipe(process.stdout);
```

For more information see the [api docs](#api).

## API

### parser

```javascript
parser(stream[, cb])
```

Parse line-delimited JSON to vanilla objects.

When a callback function is given it is added as a listener for
the `error` and `finish` events on the parser stream.

Returns the parser stream.

* `stream` Object input stream.
* `cb` Function callback function.

### deserialize

```javascript
deserialize([stream][, cb])
```

Deserialize line-delimited JSON to commonmark nodes.

When a callback function is given it is added as a listener for
the `error` and `eof` events on the deserializer stream.

The `eof` event can fire multiple times so the callback may be called
multiple times.

Returns the deserializer stream.

* `stream` Object input stream.
* `cb` Function callback function.

### serialize

```javascript
serialize(node[, opts][, cb])
```

Serialize a commonmark AST node to line-delimited JSON.

When the node is of the `document` type it's direct descendants are
detached from the document and streamed as independent lines. So that
consumers of the stream will know when the document ends a node
with an `eof` type is sent to indicate the end of file (EOF).

When injecting documents into a stream it may be desirable to disable
this behaviour, to do so use:

```javascript
{eof: false}
```

When a callback function is given it is added as a listener for
the `error` and `finish` events on the serializer stream.

Returns the serializer stream.

* `node` Object input AST node.
* `opts` Object processing options.
* `cb` Function callback function.

## License

MIT

---

Created by [mkdoc](https://github.com/mkdoc/mkdoc) on April 2, 2016

[mkdoc]: https://github.com/mkdoc/mkdoc
[commonmark]: http://commonmark.org
[jshint]: http://jshint.com
[jscs]: http://jscs.info

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