# yaml-js

> Pure Javascript YAML loader and dumper, ported from PyYAML

Latest version **0.3.1** (published 2021-09-19) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install yaml-js
pnpm add yaml-js
yarn add yaml-js
bun add yaml-js
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2021-09-19 |
| First published | 2012-01-04 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 712 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 68 |
| Maintainers | connec |

## Links

- npm: https://www.npmjs.com/package/yaml-js
- Repository: https://github.com/connec/yaml-js
- Homepage: https://github.com/connec/yaml-js#readme
- Issues: https://github.com/connec/yaml-js/issues
- npm.io page: https://npm.io/package/yaml-js

## Recent versions

- 0.3.1 (latest) — 2021-09-19
- 0.3.1-0 — 2021-09-19
- 0.2.3 — 2018-01-09
- 0.3.0 — 2017-12-18
- 0.2.2 — 2017-12-18
- 0.2.1 — 2017-12-18
- 0.2.0 — 2017-06-22
- 0.1.5 — 2017-04-25
- 0.1.4 — 2016-09-07
- 0.1.3 — 2015-09-20
- 0.1.2 — 2015-09-20
- 0.1.1 — 2015-05-08
- 0.1.0 — 2014-08-24
- 0.0.8 — 2013-08-15
- 0.0.7 — 2013-04-14
- … 6 more at https://npm.io/package/yaml-js/versions

## README

⚠️Abandoned
---

This project is now abandoned and the repository archived.
The license should allow you to fork and do whatever you want, in case you cannot migrate to a different YAML library.

Fun history fact: when I made the port there wasn't another pure JS YAML parser - the [initial commit](https://github.com/connec/yaml-js/commit/5b493a680e20d15ef2139ac7b8f1096c185cca51) for this repo was just a couple of days before the [initial release of js-yaml](https://www.npmjs.com/package/js-yaml/v/0.2.0)!

yaml-js
===

yaml-js is a YAML loader and dumper, ported pretty much line-for-line from
[PyYAML](http://pyyaml.org/).  The goal for the project is to maintain a reliable and
specification-complete YAML processor in pure Javascript, with CoffeeScript source code.  You can
try it out [here](http://connec.github.io/yaml-js/).

Loading is stable and well-used, and passes the [yaml-spec](https://github.com/connec/yaml-spec)
test suite, which fairly thoroughly covers the YAML 'core' schema.

Dumping is present but very lightly tested (auto-tests only, no significant usage).  The output
should therefore be correct YAML, however formatting is currently entirely untested.

How Do I Get It?
---

    npm install yaml-js

How Do I Use It?
---

```javascript
// Server (e.g. node.js)
var yaml = require('yaml-js');

// Browser
// <script src='yaml.min.js'></script>

// Loading
console.log(yaml.load(
  '---\n' +
  'phrase1:\n' +
  '  - hello\n' +
  '  - &world world\n' +
  'phrase2:\n' +
  '  - goodbye\n' +
  '  - *world\n' +
  'phrase3: >\n' +
  '  What is up\n' +
  '  in this place.'
));
// { phrase1: [ 'hello', 'world' ],
//   phrase2: [ 'goodbye', 'world' ],
//   phrase3: 'What is up in this place.' }

// Dumping
console.log(yaml.dump({
  phrase1: [ 'hello',   'world' ],
  phrase2: [ 'goodbye', 'world' ],
  phrase3: 'What is up in this place.'
}));
// phrase1: [hello, world]
// phrase2: [goodbye, world]
// phrase3: What is up in this place.
```

### API summary

| Method          | Description                                                                                     |
|-----------------|-------------------------------------------------------------------------------------------------|
| **`load`**      | Parse the first YAML document in a stream and produce the corresponding Javascript object.      |
| **`dump`**      | Serialize a Javascript object into a YAML stream.                                               |
| `load_all`      | Parse all YAML documents in a stream and produce the corresponing Javascript objects.           |
| `dump_all`      | Serialize a sequence of Javascript objects into a YAML stream.                                  |
| `scan`          | Scan a YAML stream and produce tokens.                                                          |
| `parse`         | Parse a YAML stream and produce events.                                                         |
| `compose`       | Parse the first YAML document in a stream and produce the corresponding representation tree.    |
| `compose_all`   | Parse all YAML documents in a stream and produce corresponding representation trees.            |
| `emit`          | Emit YAML parsing events into a stream.                                                         |
| `serialize`     | Serialize a representation tree into a YAML stream.                                             |
| `serialize_all` | Serialize a sequence of representation trees into a YAML stream.                                |

License
---

[WTFPL](http://sam.zoy.org/wtfpl/)

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