Socket
Socket
Sign inDemoInstall

yaml-js

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    yaml-js

Pure Javascript YAML loader and dumper, ported from PyYAML


Version published
Weekly downloads
139K
decreased by-10.28%
Maintainers
1
Install size
713 kB
Created
Weekly downloads
 

Readme

Source

⚠️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 for this repo was just a couple of days before the initial release of js-yaml!

yaml-js

yaml-js is a YAML loader and dumper, ported pretty much line-for-line from PyYAML. 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.

Loading is stable and well-used, and passes the 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?

// 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

MethodDescription
loadParse the first YAML document in a stream and produce the corresponding Javascript object.
dumpSerialize a Javascript object into a YAML stream.
load_allParse all YAML documents in a stream and produce the corresponing Javascript objects.
dump_allSerialize a sequence of Javascript objects into a YAML stream.
scanScan a YAML stream and produce tokens.
parseParse a YAML stream and produce events.
composeParse the first YAML document in a stream and produce the corresponding representation tree.
compose_allParse all YAML documents in a stream and produce corresponding representation trees.
emitEmit YAML parsing events into a stream.
serializeSerialize a representation tree into a YAML stream.
serialize_allSerialize a sequence of representation trees into a YAML stream.

License

WTFPL

FAQs

Last updated on 19 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc