npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yaml-js

v0.3.1

Published

Pure Javascript YAML loader and dumper, ported from PyYAML

Downloads

651,074

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

| 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