Coder Social home page Coder Social logo

yaml-js's Introduction

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

yaml-js's People

Contributors

connec avatar evgenus avatar hirse avatar tgriesser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

yaml-js's Issues

Yaml dump including JSON object

Yaml dump of an object can include JSON syntax rather than the yaml syntax.

This can be replicated with deserialization and serialization of the following:

description: "initializes the simulation"
properties:

  • fileName:
    type: string

This will return:

description: initializes the simulation
properties:

  • fileName: {type: string}

fix require usage

getting error "require function is used in a way in which dependencies cannot be statically extracted" then trying to use with webpack.

Document with misindented/unescaped string causes "logic failure" error

I didn't get a chance to fully dig into the underlying cause, just filing all the information to one place.

Given the following YAML document:

openapi: 3.0.0
key:
  key:
      key: 'x
key: 'string'

The following error is emitted when using yaml.compose():

Error: logic failure
    at Loader.Scanner.Scanner.save_possible_simple_key (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/scanner.js:302:15)
    at Loader.Scanner.Scanner.fetch_plain (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/scanner.js:566:12)
    at Loader.Scanner.Scanner.fetch_more_tokens (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/scanner.js:238:21)
    at Loader.Scanner.Scanner.check_token (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/scanner.js:115:14)
    at Loader.Parser.Parser.parse_block_mapping_key (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/parser.js:421:16)
    at Loader.Parser.Parser.check_event (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/parser.js:61:48)
    at Loader.Composer.Composer.compose_mapping_node (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/composer.js:248:20)
    at Loader.Composer.Composer.compose_node (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/composer.js:160:21)
    at Loader.Composer.Composer.compose_mapping_node (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/composer.js:250:27)
    at Loader.Composer.Composer.compose_node (/Users/kyle/Projects/apiaryio/api-elements.js/node_modules/yaml-js/lib/composer.js:160:21)

From https://github.com/connec/yaml-js/blob/fdfaa28/src/lib/scanner.coffee#L261

Expected:

An error with a message aimed at users explaining what they did wrong including a "context_mark" or "problem_mark".

Actual:

An internal error without source map information (marks)

Formatting tests for `dump`

Currently, tests for dump only check that the emitted YAML generates the same result as the original YAML. There should be tests for the different formatting options.

It's not clear whether or not these tests should be specified in connec/yaml-spec.

Fix `null` tests

Currently, 3 Serializer tests are failing due to the asymmetric way documents/null-tagged scalars are interpreted by the Emitter. Either:

  • the Emitter should special-case these scenarios and emit an appropriate ScalarEvent
  • the Serializer should special-case these scenarios and detect the relevant event sequences and generate ScalarNodes

Syntax Error, dunno.

When I load my yaml file, it throws malformed
screenshot_7
screenshot_9

but when I log the object, it seems to be correct.
screenshot_8

I don't know if this a fault in my code, just letting you know.

Also, I would like to thank you a lot you saved me hours of work.

Can't call add_constructor on Loader object

In PyYAML it is possible to add constructor to loader.

>>> import yaml
>>> yaml.Loader
<class 'yaml.loader.Loader'>
>>> yaml.Loader.add_constructor
<bound method BaseConstructor.add_constructor of <class 'yaml.loader.Loader'>>

I know there is no multiple inheritance in JS. It looks like the only way to add new tags in standalone (non-global) context is to extend Constructor and use it in make_loader. But extending coffee-script classes in pure JS is not obvious task. I think it needs make_constructor function. The same also stands for Resolver and Presenter.

Error to Install

npm install js-yaml --save
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]

¿= ?

error while using .dump(data)

I got the following error while trying to dump.

Having:

C:\ws\nodejs\sandbox>node -v
v6.3.1

C:\ws\nodejs\sandbox>node
> require('yaml-js/package').version
'0.1.4'

Scenario:

> require('yaml-js').dump({foo: 'bar'})

Expected:

> require('yaml-js').dump({foo: 'bar'})
'foo: bar'
>

Found:

> require('yaml-js').dump({foo: 'bar'})
tag is not specified
    at EmitterError.YAMLError [as constructor] (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\errors.js:70:46)
    at new EmitterError (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\emitter.js:17:49)
    at Resolver.__dirname.Emitter.Emitter.error (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\emitter.js:1298:13)
    at Resolver.__dirname.Emitter.Emitter.process_tag (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\emitter.js:619:14)
    at Resolver.__dirname.Emitter.Emitter.expect_node (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\emitter.js:282:14)
    at Resolver.__dirname.Emitter.Emitter.expect_document_root (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\emitter.js:265:19)
    at Resolver.__dirname.Emitter.Emitter.emit (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\emitter.js:116:14)
    at Resolver.__dirname.Serializer.Serializer.serialize_node (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\serializer.js:115:16)
    at Resolver.__dirname.Serializer.Serializer.serialize (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\serializer.js:64:14)
    at Resolver.__dirname.BaseRepresenter.BaseRepresenter.represent (C:\ws\nodejs\sandbox\node_modules\yaml-js\lib\representer.js:63:12)
>

..WTF?

help?

YAML with emoji fails

Throws this.character.charCodeAt is not a function(…)

I'm not sure emoji is even ever valid in YAML, but in case it is, the loader chokes with it. If it isn't, feel free to close this 😅

How can I access Loader object to add custom resolvers?

Hi: Im trying to port a PyYaml project of my own, and I cannot find the way to access to the internal objects of the yaml-js library

The code Iḿ trying to do is:

Loader.add_implicit_resolver(mycustomtag,myregexp)

Thanks in advance and excuse for my n00biness.

Documentation!

The library is currently mostly undocumented. The PyYAML documentation is useful for reference on the general structure of the API, however some library-specific documentation is urgently required.

Conflict with js-yaml?

Hi,

does 'yaml-js' modify any global object, which could cause a conflict with 'js-yaml'?

We use js-yaml, but one of the plugins did use yaml-js (via rc-yaml) and then we got the problem that regular expression in our config could not be parsed (a feature of js-yaml).

I was able to solve the conflict, by changing rc-yaml to use js-yaml (publihed as rc-yaml-2 on npm) - but I have no idea how the two node modules could make trouble in another one.

Here is the error message we found initially:

{ could not determine a constructor for the tag tag:yaml.org,2002:js/regexp
  on line 22, column 20
    at ConstructorError.YAMLError [as constructor] (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/errors.js:70:46)
    at ConstructorError.MarkedYAMLError [as constructor] (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/errors.js:90:45)
    at new ConstructorError (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/constructor.js:22:53)
    at Loader.__dirname.Constructor.Constructor.construct_undefined (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/constructor.js:629:13)
    at Loader.__dirname.BaseConstructor.BaseConstructor.construct_object (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/constructor.js:208:28)
    at Loader.__dirname.BaseConstructor.BaseConstructor.construct_mapping (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/constructor.js:248:22)
    at Loader.__dirname.Constructor.Constructor.construct_mapping (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/constructor.js:368:54)
    at /usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/constructor.js:598:23
    at Loader.__dirname.BaseConstructor.BaseConstructor.construct_document (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/constructor.js:163:41)
    at Loader.__dirname.BaseConstructor.BaseConstructor.get_single_data (/usr/lib/node_modules/@sematext/logagent-nodejs-monitor/node_modules/yaml-js/lib/constructor.js:147:21)
  context: null,
  context_mark: null,
  problem: 'could not determine a constructor for the tag tag:yaml.org,2002:js/regexp',
  problem_mark: 
   Mark {
     line: 21,
     column: 19,

The workaround was to replace in the sub-modules the dependency to yaml-js with js-yaml and our program did work again.

dump produces malformed yaml?

yaml.dump({
  attributes: {
    image-url: "http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg",
    position: 6
  }
})

Expected output:

---
attributes:
  image-url: "http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg"
  position: 6

Actual output:

attributes: {image-url: 'http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg',
  position: 6}

When I try to run actual output in http://codebeautify.org/yaml-validator , it reports:

Error : Malformed inline YAML string "{image-url: 'http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg'," at line 1 (near "attributes: {image-url: 'http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg',")
Line : 1  attributes: {image-url: 'http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg',

How to add a field with variables in yaml using yaml-js ?

I am quite new to using yaml-js.

I have a field :

var:
  file: dist/main.js

that I would like to merge/add to another yaml file that may look like this :

var:
  file: &file
    dist/main.js
foo:
  - vitamin D
bar: *file

or just :

foo:
  - vitamin D
bar: much text

Essentially, how to "edit" yaml file before parsing.

It looks like the date parsing is off by one

When parsing dates they are one month ahead:

> yaml.load('date: 2012-01-01')
{ date: Wed Feb 01 2012 00:00:00 GMT-0800 (PST) }

I dug through your code and it looks like the month is being passed directly to the Date constructor which wants: "Integer value representing the month, beginning with 0 for January to 11 for December."

Pull request inbound...

Improve default dump style

Dumping, as implemented in PyYAML, does not produce very desirable output. Ideally the output should look like somebody wrote it.

Bad examples:

  • Using flow style for (visually) large objects (#21)

    attributes: {
      'image-url': 'http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg',
      position:    6
    }

    Actual

    attributes: {image-url: 'http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg',
      position: 6}

    Expected

    attributes:
      image-url: http://www.2do2go.ru/uploads/full/a99dca2d765bb9c034ea8fbf315a48b2_w960_h2048.jpg
      position:  6
  • Adding unecessary document end tokens to simple documents (#23)

    'foobar'

    Actual

    foobar
    ...

    Expected

    foobar

Examples hard to read

Thank you for your hard work. It's most unfortunate that you obfuscate the usability of it by putting your examples in your README in a language that less than 1% of people on Node have any familiarity with.

Please use JavaScript in your README examples.

Accept %YAML directive?

Hi,

I've just been trying out your module via http://connec.github.io/yaml-js/ (thank you for providing that!) and I have a YAML file that parses only if I remove the %YAML 1.1 directive which is the first line.

I did check out https://github.com/connec/yaml-spec and it appears this directive is not listed, so I assume this would be a feature request. (The PyYAML documentation seems to indicate it's handled there, though - see the Tokens section: http://pyyaml.org/wiki/PyYAMLDocumentation.)

Thank you!

Supported Node/ECMAScript versions

Hi, I noticed that the patch release 0.2.1 removes support for Node version 4. I can't find any note in readme regarding the supported Node/ECMAScript versions. Would you be able to clarify the supported versions for me please @connec?

internal modules hidden in bundle

There is no way to create custom loader when using in bundled mode because there is no access to loader module. So I can't make_loader and can't add_constructor to it.

Memory leak when runing compose in worker

Here is what I've done to reproduce this bug:

1. Make an HTML file with following content:

<html>
  <head></head>
  <body>
    <script>
    var worker = new Worker('worker.js');

    worker.onmessage = function (message) {
      console.log(message.data);
    };

    fetch('file.yaml').then(function (resp) {
      resp.text().then(function(y) {
        worker.postMessage(y);
      });
    });
    </script>
  </body>
</html>

2. Next to index.html make a file an name it worker.js, it's exactly `yaml.js file with these lines added at the end:

onmessage = function (message) {
    postMessage(yaml.compose(message.data));
}

Which is basically adding a very simple Web Worker API to yaml-js. It also fixes the bug I reported in #16 by using this as global: var global = this;

3. Make another file and name it file.yaml. Content of this file can be found here: http://pastebin.com/c8AYYEGF

4. Run a static web server like http-server from this folder and open the browser. What I see is Chrome's "Aw! Snap!" message. When I profiled this, memory usage goes up and up until tab crashes

screen shot 2015-09-18 at 11 25 30 am

Firefox crashes also. Safari doesn't have the Fetch API so I can't test it but I'm pretty sure that would crash also.

Note that the same file and the same method is not having this issue when run in the main thread. So if you change the content of HTML file to following code, the error won't happen:

<html>
  <head></head>
  <body>
    <script src="https://rawgit.com/connec/yaml-js/master/yaml.js"></script>
    <script>
      fetch('file.yaml').then(function (resp) {
        resp.text().then(function(y) {
          console.log(yaml.compose(y));
        });
      });
    </script>
  </body>
</html>

You can also download all the files in one zip file from here: https://github.com/mohsen1/mohsen1.github.io/blob/b8d76793a1e81a6c35fe83de3fea322edac910db/assets/yaml.zip

This issue was originally raised in Swagger Editor:
swagger-api/swagger-editor#641
swagger-api/swagger-editor#658
swagger-api/swagger-editor#651

require.extensions is not supported by webpack. Use a loader instead.

Using from create-react-app and swagger-editor
version 0.2.3

Compiled with warnings.

./node_modules/yaml-js/lib/yaml.js
256:40-47 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

./node_modules/yaml-js/lib/yaml.js
require.extensions is not supported by webpack. Use a loader instead.

./node_modules/yaml-js/lib/yaml.js
require.extensions is not supported by webpack. Use a loader instead.

./node_modules/yaml-js/lib/yaml.js
require.extensions is not supported by webpack. Use a loader instead.

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File name is "undefined" in token ScannerError

File name in a token ScannerError is printed as "undefined".

For example:

yaml-js/lib/scanner.js:243
      throw new exports.ScannerError('while scanning for the next token', null
            ^
while scanning for the next token
found character      that cannot start any token
  in "undefined", line 7, column 1

This is the line where I think the main issue is where null is passed as context_mark to YAMLError.

Escaped forward-slashes cause yaml-js to crash

I am using js-yaml to load Swagger files in my app. Today, my app crashed and I discovered it was because a string had an escaped forward-slash (\/). My stack trace:

{ while scanning a double-quoted scalar
  on line 487, column 1
found unknown escape character /
  on line 487, column 28
    at ScannerError.YAMLError [as constructor] (myProject/node_modules/yaml-js/lib/errors.js:70:46)
    at ScannerError.MarkedYAMLError [as constructor] (myProject/node_modules/yaml-js/lib/errors.js:90:45)
    at new ScannerError (myProject/node_modules/yaml-js/lib/scanner.js:23:49)
    at Loader.__dirname.Scanner.Scanner.scan_flow_scalar_non_spaces (myProject/node_modules/yaml-js/lib/scanner.js:1203:19)
    at Loader.__dirname.Scanner.Scanner.scan_flow_scalar (myProject/node_modules/yaml-js/lib/scanner.js:1152:37)
    at Loader.__dirname.Scanner.Scanner.fetch_flow_scalar (myProject/node_modules/yaml-js/lib/scanner.js:562:36)
    at Loader.__dirname.Scanner.Scanner.fetch_double (myProject/node_modules/yaml-js/lib/scanner.js:556:19)
    at Loader.__dirname.Scanner.Scanner.fetch_more_tokens (myProject/node_modules/yaml-js/lib/scanner.js:235:21)
    at Loader.__dirname.Scanner.Scanner.check_token (myProject/node_modules/yaml-js/lib/scanner.js:115:14)
    at Loader.__dirname.Parser.Parser.parse_flow_sequence_entry (myProject/node_modules/yaml-js/lib/parser.js:481:18)
  context: 'while scanning a double-quoted scalar',

While forward slashes don't really need to be escaped, it is allowed by the JSON spec, so I don't think that yaml-js should crash when this occurs.

compose wrong end_mark on objects in seq

Example https://codepen.io/alexholly/pen/qBBjYJq

This shows in line 50 the end line 2 but it should be 1

key:
  - 1
test: 2

This case shows it right, in line 50 the end line is 1

key:
  - 1

In cases with Block Style Indicator '>' or '|' end_line has also a +1 bug

Is this a solution or why is this happening?

Add this to line

if(event.style=='>' || event.style=='|') {
  event.end_mark.line -= 1;
}

Test case:

key: >- 
 jhgjhgjhgkjhkjh
test: 1

Accepting @-symbols

I'm trying to use Schema.org conform data in a markdown front matter.


---
  @context: "http://schema.org"
  @type: "Social event"
  location: 
    @type: "Place"
    address: 
      @type: "PostalAddress"
      addressLocality: "Barcelona, Spain"
      postalCode: "08001"
      streetAddress: "C/ Fontanella 2"
    name: "Mobile World Centre"

the @-signs are breaking with found character @ that cannot start any token. There's nothing in YML 1.2 spec that doesn't allow @ characters. Any chance to get this working?

A Web Worker API?

On top of node and browser support it would be nice if we had a web-worker API too.

parse yaml error while text is a valid json string

I have a text, it is a valid json string but error is occured while parsing the string to json using yaml-js.

var yaml = require('yaml-js');
var str = `
{
	"Tags": {
		"ManageCgroup": true,
		"domain_type": "test-development",
		"physical_storage_type": 2,
		"storage_network_type": "net2",
		"storage_type": "io8",
		"virt_type": "kvm"
	}
}
`;

var obj = JSON.parse(str)  // it is a valid json
console.log(obj);

console.log('start parse yaml');
// Loading err
//console.log(yaml.load(str)); // parse yaml error
try {
	console.log(yaml.load(str)); // parse yaml error
} catch (e) {
	console.log('parse yaml error: ', e);	
}

Documentation and Error Handling

Hi, Thanks for writing the lib. I realize there's already an issue #12 related to docs, but I wanted to echo it and chime in by asking if there is any way to easily detect parse errors. I'm using the lib to serialize file based yaml specs for swagger documentation, but sometimes things silently fail. I noticed the dump function seems to provide no direct error indication, but if you inspect the results, errors seemed to be buried in the object that encountered the error.

For example, a swagger definitions object in my results contained this:

ReceiptHistory: 
      { [Error]
        context: 'while scanning for the next token',
        context_mark: null,
        problem: 'found character ` that cannot start any token',
        problem_mark: [Object],
        note: undefined,
        message: undefined,
        stack: 'while scanning for the next token\nfound character ` that cannot start any token\n  on line 2, column 14\n    at ScannerError.YAMLError (/doc/api/node_modules/yaml-js/lib/errors.js:70:46)\n    at ScannerError.MarkedYAMLError (/doc/api/node_modules/yaml-js/lib/errors.js:90:45)\n    at new ScannerError (/doc/api/node_modules/yaml-js/lib/scanner.js:23:49)\n    at Constructor.Scanner.Scanner.fetch_more_tokens (/doc/api/node_modules/yaml-js/lib/scanner.js:240:13)\n    at Constructor.Scanner.Scanner.check_token (/doc/api/node_modules/yaml-js/lib/scanner.js:115:14)\n    at Constructor.Parser.Parser.parse_block_mapping_value (/doc/api/node_modules/yaml-js/lib/parser.js:446:19)\n    at Constructor.Parser.Parser.check_event (/doc/api/node_modules/yaml-js/lib/parser.js:61:48)\n    at Constructor.Composer.Composer.compose_node (/doc/api/node_modules/yaml-js/lib/composer.js:72:16)\n    at Constructor.Composer.Composer.compose_mapping_node (/doc/api/node_modules/yaml-js/lib/composer.js:145:27)\n    at Constructor.Composer.Composer.compose_node (/doc/api/node_modules/yaml-js/lib/composer.js:91:21)' },

There seems to be no reasonable path to detect an error like this other than dumping the contents to the console and looking for the error, or else navigating programmatically through the whole object tree and looking for an Error.

It would be nice to have the dump function take a function callback(err) { } or return an array of errors that it encountered.

I was going to take a stab at improving the docs or even error-handling, but...I don't have the time / luxury / desire to spend the time with coffeescript (sorry!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.