Giter VIP home page Giter VIP logo

js-yaml's Introduction

Forums / Blogs / Groups / ...

Build Status

Live demo: https://rcopen.com

Nodeca itself is not expected for wide use. It's intended to replace old RC Design forum software and make programmer's life more comfortable.

But during development we create a lot of useful and popular packages for node.js. See organizations of @puzrin profile. Everything we do is published on github. Enjoy!

js-yaml's People

Contributors

aengl avatar aepsilon avatar dervus avatar djchie avatar dod38fr avatar dplepage avatar dubzzz avatar dustyrockpyle avatar eseliger avatar isaacs avatar ixti avatar kcivey avatar kirill89 avatar lwassermann avatar martijncuppens avatar mikeralphson avatar monken avatar murtazajafferji avatar mxl avatar paolochiodi avatar realityking avatar rjmunro avatar rlidwka avatar rockitbaby avatar roryokane avatar scrooloose avatar shinnn avatar shockey avatar tcr avatar zentner-kyle 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  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  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  avatar  avatar

js-yaml's Issues

Parse failed when no document start present

Parser fais when document have no --- start node:

TypeError: Cannot read property '!!' of undefined
    at [object Object].parseNode (/home/ixti/projects/js-yaml/lib/js-yaml/parser.js:375:44)
    at [object Object].parseBlockNodeOrIndentlessSequence (/home/ixti/projects/js-yaml/lib/js-yaml/parser.js:324:17)
    at [object Object].parseBlockMappingValue (/home/ixti/projects/js-yaml/lib/js-yaml/parser.js:561:23)
    at [object Object].state (/home/ixti/projects/js-yaml/node_modules/jsclass/src/core.js:56:19)
    at [object Object].checkEvent (/home/ixti/projects/js-yaml/lib/js-yaml/parser.js:110:32)
    at [object Object].composeNode (/home/ixti/projects/js-yaml/lib/js-yaml/composer.js:89:14)
    at [object Object].composeMappingNode (/home/ixti/projects/js-yaml/lib/js-yaml/composer.js:190:24)
    at [object Object].composeNode (/home/ixti/projects/js-yaml/lib/js-yaml/composer.js:115:19)
    at [object Object].composeMappingNode (/home/ixti/projects/js-yaml/lib/js-yaml/composer.js:190:24)
    at [object Object].composeNode (/home/ixti/projects/js-yaml/lib/js-yaml/composer.js:115:19)

Can not install 1.0.0 on MacOS

js-yaml used to install nicely for me (npm install) until version 0.3.7.
I just tried today to run a simple npm install js-yaml and noticed that the latest version was 1.0.0, and I'm getting the following error in the console:


npm http GET https://registry.npmjs.org/js-yaml
npm http 304 https://registry.npmjs.org/js-yaml
npm http GET https://registry.npmjs.org/argparse
npm http 304 https://registry.npmjs.org/argparse
npm http GET https://registry.npmjs.org/underscore.string
npm http GET https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/underscore.string
npm http 304 https://registry.npmjs.org/underscore
npm ERR! error installing [email protected]
npm ERR! Error: ENOENT, no such file or directory '/Users/patrickbrosset/ariatemplates-captainbrosset/node_modules/js-yaml/bin/js-yaml.js'
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR! 
npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "js-yaml"
npm ERR! cwd /Users/patrickbrosset/ariatemplates-captainbrosset
npm ERR! node -v v0.6.7
npm ERR! npm -v 1.1.0-beta-10
npm ERR! path /Users/patrickbrosset/ariatemplates-captainbrosset/node_modules/js-yaml/bin/js-yaml.js
npm ERR! code ENOENT
npm ERR! message ENOENT, no such file or directory '/Users/patrickbrosset/ariatemplates-captainbrosset/node_modules/js-yaml/bin/js-yaml.js'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/patrickbrosset/ariatemplates-captainbrosset/npm-debug.log
npm not ok

Setup is MacOS 10.7.4

Running npm install [email protected] runs fine though.

RequireJS Working Example?

I'm struggling to get this working with requireJS. I've tried the examples in the README with no luck.

Here is my control case:

define([
  'require',
  'jquery',
  'mustache',
  'js-yaml.min',
], function(require, $){

  var JB = { 
    init : function(boot){
      var doc = jsyaml.load('greeting: hello\nname: world');
      console.log(doc); // this works fine.

      //require('js-yaml.min'); // this works both uncommented and commented.

      var singleDoc = require('http://127.0.0.1/~jade/javascripts/require-js/tags.yaml').shift();
      console.log(singleDoc); 
      // This does not work
      // Uncaught Error: Module name 'http://127.0.0.1/~jade/javascripts/require-js/tags.yaml' has not been loaded yet for context: _
      // http://requirejs.org/docs/errors.html#notloaded

      if(typeof boot === "function") boot();
    } 
  };

  return JB;
});

As per the error documentation (http://requirejs.org/docs/errors.html#notloaded) I have tried to load the tags.yaml first in the define statement. The tags.yaml loads fine but since its not javascript, It returns a syntax error.

Any help would be appreciated, thanks.

Literal and Folded Style on documents throws ParserError

This valid YAML should be parseable into 3 documents:

---
a:
  When parsed,
  these three lines
  SHOULD NOT retain linebreaks.
b: |
  When parsed,
  these three lines
  SHOULD retain linebreaks.

---
When parsed,
these three lines
SHOULD NOT retain linebreaks.
--- |
When parsed,
these three lines
SHOULD retain linebreaks.

But yaml.loadAll throws a ParserError exception when the third document (beginning with --- |) is reached.

According to the YAML 1.2 spec, Literal and Folded Style on documents is valid YAML, but most parsers fail to support either.

Can you add support for this?

NPM package broken on Windows

On Windows, for some reason after installing the module, some required files aren't present, in particular js-yaml.js and lib/js-yaml.js, which cause the library to not work at all.

Replace all shims with underscore

Instead of using shims, we must use Underscore (right in the library), so the browserified version will become in two options: with underscore bundled (for hardcore standalone version) and without (when user is using underscore already).

That will probably solve any problems with different browsers.

Browser support

It could be useful to run JS-YAML in browser. For example, to do nice looking debug dumps for complex data.

Key 'y' becomes 'true'

If we have an object with 'y' property, like

point: 
    x: 19
    y: 5

it becomes

point: { x: 19, true: 5 }

Looks really strange, but maybe it's not a bug ( later I found a discussion)

Cannost install js-yaml

Just tried on a clean install. Randomly-tested other modules are OK:

almad@namtar /tmp $ node --version
v0.6.10
almad@namtar /tmp $ npm --version
1.1.0-3
almad@namtar /tmp $ npm install js-yaml
npm http GET https://registry.npmjs.org/js-yaml
npm http 200 https://registry.npmjs.org/js-yaml
npm http GET https://registry.npmjs.org/js-yaml/-/js-yaml-1.0.3.tgz
npm http 200 https://registry.npmjs.org/js-yaml/-/js-yaml-1.0.3.tgz
npm http GET https://registry.npmjs.org/argparse
npm http 200 https://registry.npmjs.org/argparse
npm http GET https://registry.npmjs.org/argparse/-/argparse-0.1.7.tgz
npm http 200 https://registry.npmjs.org/argparse/-/argparse-0.1.7.tgz
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/underscore.string
npm http 200 https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/underscore/-/underscore-1.3.3.tgz
npm http 200 https://registry.npmjs.org/underscore.string
npm http GET https://registry.npmjs.org/underscore.string/-/underscore.string-2.1.1.tgz
npm http 200 https://registry.npmjs.org/underscore/-/underscore-1.3.3.tgz
npm http 200 https://registry.npmjs.org/underscore.string/-/underscore.string-2.1.1.tgz
npm ERR! error installing [email protected]

npm ERR! Error: ENOENT, no such file or directory '/tmp/node_modules/js-yaml/bin/js-yaml.js'
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR! 
npm ERR! System Linux 3.2.1-gentoo-r2
npm ERR! command "node" "/home/almad/.nvm/v0.6.10/bin/npm" "install" "js-yaml"
npm ERR! cwd /tmp
npm ERR! node -v v0.6.10
npm ERR! npm -v 1.1.0-3
npm ERR! path /tmp/node_modules/js-yaml/bin/js-yaml.js
npm ERR! code ENOENT
npm ERR! message ENOENT, no such file or directory '/tmp/node_modules/js-yaml/bin/js-yaml.js'
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /tmp/npm-debug.log
npm not ok
almad@namtar /tmp $ 

Error: Cannot find module './lib/js-yaml.js'

I just installed "js-yaml" with "npm install js-yaml". It doesn't work because the file "./lib/js-yaml.js" isn't there. I had to take it from the git repo and paste it into my dir "node_modules/js-yaml/lib" to make it work. Great job for the native port though!

Support for ?

This doesn't seem to be supported in js-yaml:

? - Detroit Tigers
  - Chicago cubs
:
  - 2001-07-23

? [ New York Yankees,
    Atlanta Braves ]
: [ 2001-07-02, 2001-08-12,
    2001-08-14 ]

Wrong parse bug

I found a bug

Keys or values y evaluate as true (yes), the same bug with n:

bugs:
  x: 1 # ok
  y: 2 # buggy, expect key 'y'
  n: 3 # buggy, expect key 'n'
  yesValue: y # buggy, expect string 'y'
  noValue: n # buggy, expect string 'n'
   

->

{ bugs: 
   { x: 1,
     true: 2,
     false: 3,
     yesValue: true,
     noValue: false } }

require() returns single-element array

When I do something like var c = require('config.yaml'); I get a single-element array with the YAML-derived data structure as the element. I guess that's more or less as documented, but it seems strange. I would have expected that I'd get just the data structure, with no extra array around it. Having to use a [0] to get to the actual data is an annoyance. Is there some point I'm missing?

That is, I'd hoped to get

{"property1":"value1","property2":"value2"}

but instead I get

[{"property1":"value1","property2":"value2"}]

"double" is reserved keyword

Hi!

Yahoo compressor noticed me that "double" is reserved keyword, js still works, but it's not cool.

An example:

Scanner.prototype.scanFlowScalar = function scanFlowScalar(style) {
  var double, chunks, length, code, startMark, quote, endMark;
  ...

and in other parts of the code.

Function.bind not guaranteed

The browser version dies in safari (probably also IE!) as Function.prototype.bind does not exist. I've fixed it for my use case using underscore's bind function as I had underscore knocking around anyway, but this isn't a long term solution.

Problems redirecting stdout to file

Works

ϟ js-yaml ./client/locales/en.yaml          

{ credits: 
   { roles: 
      { art_director: 'Art director',
        associate_producer: 'Associate producer',
        producers: 'Producers',
        colourist: 'Colourist',
        costume_designer: 'Costume designer',
        director: 'Director',
        director_of_photography: 'Director of photography',
        editor: 'Editor',
        music: 'Music',
        producer: 'Producer',
        titles_and_poster: 'Titles and poster',
        screenwriter: 'Screenwriter',
        sound_designer: 'Sound designer',
        writer: 'Writer',
        sound_recorder_and_design_and_mix: 'Sound recorder, design, and mix',
        sound_design_and_mix: 'Sound design and mix"',
        original_music_composer_and_orchestrator_and_conductor: 'Original music composer, orchestrator, and conductor',
        original_score_composer_and_performer: 'Original score, composer, and performer' } },
  production_companies: 'Production companies',
  production_company: 'Production company',
  shooting_format: 'Shooting format',
  release_date: 'Release date',
  funding_agencies: 'Funding agencies',
  distribution_and_sales: 'Distribution and sales',
  genre: 'Genre',
  languages: 'languages',
  language: 'Language',
  runtime: 'Runtime' }

Fails

ϟ js-yaml ./client/locales/en.yaml > test.js

.... open ./test.js...

{ credits: 
   { roles: 
      { art_director: �[32m'Art director'�[39m,
        associate_producer: �[32m'Associate producer'�[39m,
        producers: �[32m'Producers'�[39m,
        colourist: �[32m'Colourist'�[39m,
        costume_designer: �[32m'Costume designer'�[39m,
        director: �[32m'Director'�[39m,
        director_of_photography: �[32m'Director of photography'�[39m,
        editor: �[32m'Editor'�[39m,
        music: �[32m'Music'�[39m,
        producer: �[32m'Producer'�[39m,
        titles_and_poster: �[32m'Titles and poster'�[39m,
        screenwriter: �[32m'Screenwriter'�[39m,
        sound_designer: �[32m'Sound designer'�[39m,
        writer: �[32m'Writer'�[39m,
        sound_recorder_and_design_and_mix: �[32m'Sound recorder, design, and mix'�[39m,
        sound_design_and_mix: �[32m'Sound design and mix"'�[39m,
        original_music_composer_and_orchestrator_and_conductor: �[32m'Original music composer, orchestrator, and conductor'�[39m,
        original_score_composer_and_performer: �[32m'Original score, composer, and performer'�[39m } },
  production_companies: �[32m'Production companies'�[39m,
  production_company: �[32m'Production company'�[39m,
  shooting_format: �[32m'Shooting format'�[39m,
  release_date: �[32m'Release date'�[39m,
  funding_agencies: �[32m'Funding agencies'�[39m,
  distribution_and_sales: �[32m'Distribution and sales'�[39m,
  genre: �[32m'Genre'�[39m,
  languages: �[32m'languages'�[39m,
  language: �[32m'Language'�[39m,
  runtime: �[32m'Runtime'�[39m }

Incorrect utf-8 handling on require('file.yaml')

When js-yaml loads long files with multibyte utf-8 symbols sometimes it brokes characters (replaces valid unicode char by two error marks)

yaml = require('js-yaml')
data_broken = require('mydata.yaml')
data_correct = yaml.load( fs.readFileSync('mydata.yaml') )

Probably it happens when utf-8 symbol lays exactly on read buffer boundary and byte reader splits it on two incorrect parts.

Non-specific "!" tags should resolve to !!str

! 12

resolves to !!int when scalar nodes with a non-specific "!" tags should always resolve to !!str according to recommendation in spec (paragraph 3.3.2)

It is recommended that nodes having the “!” non-specific tag should be resolved as “tag:yaml.org,2002:seq”, “tag:yaml.org,2002:map” or “tag:yaml.org,2002:str” depending on the node’s kind.

Wrong mark of error on multiple documents

expected a single document in the stream
 in "<unicode string>", line 2, column 1:
    pid: '/home/www/pids/thin.pid'
wait: 12.34
listen: {host: localhost, port: 3000}
modules: ['users', 'i18n']
users: &crew
  puzrin:
    role: manager
  ixti:
    role: developer
authors: *crew
require:
  - logger
  - debugger
dbg-mode: true
# some comments
non-ascii-ключ: значение # more comments
folded: >
  Multi
  line
  text
literal: |
  More
  samples
...

---
multiple: docs

    ^
but found another document
 in "<unicode string>", line 27, column 1:
    ---
multiple: docs

    ^

[browserified] Fails on IE7 (and IE6)

While support of IE6 is close to necrophilia, IE7 is still one of the things that make our days not so shiny. By some reason js-yaml ignores new-line breaks on IE7.

This works:

{ foo: bar, baz: 123 }

And this one doesn't:

foo: bar
baz: 123

To demonstrate problem closer:

- foo
- bar

Becomes:

[ 'foo - baz' ]

Also, integers are becomes integers ONLY with strict type casting:

{ foo: !!int 123, bar: 123 }

The above will become:

{ foo: 123, bar: '123' }

JSON to YAML converter

First of all thanks for a good lib! YAML is so much better than JSON.

A question: would it be easy to include a JSON to YAML converter?

So you can do conversion in both directions kinda like: http://js2coffee.org/

jsyaml.addConstructor fails (at least in browserified versions)

I’m trying to add a constructor for custom tags using

jsyaml.addConstructor(
  '!sometag',
  function(node) { return "test"} );

This fails with "(Loader || _loader.Loader).addConstructor is not a function". I checked _loader.Loader using Firebug, and it indeed does not have that function. If it’s not a bug, do you have any hints on what I am doing wrong?

js-yaml.js not found

I'm running latest Ubuntu version.

I installed the proposed fix from master tree, (related to issue #34, #35 and #36) I still receive the error Error: ENOENT, no such file or directory '..//node_modules/js-yaml/bin/js-yaml.js'

error output from standard package:

npm ERR! error installing [email protected]

npm ERR! Error: ENOENT, no such file or directory '../../node_modules/js-yaml/bin/js-yaml.js'
npm ERR! You may report this log at:
npm ERR! http://bugs.debian.org/npm
npm ERR! or use
npm ERR! reportbug --attach ../../npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.2.0-29-generic
npm ERR! command "node" "/usr/bin/npm" "install" "js-yaml"
npm ERR! cwd
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! path ../../node_modules/js-yaml/bin/js-yaml.js
npm ERR! code ENOENT
npm ERR! message ENOENT, no such file or directory '../../node_modules/js-yaml/bin/js-yaml.js'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! ../../npm-debug.log

error output from tarball master:

npm ERR! error installing [email protected]

npm ERR! Error: ENOENT, no such file or directory '../../node_modules/js-yaml/bin/js-yaml.js'
npm ERR! You may report this log at:
npm ERR! http://bugs.debian.org/npm
npm ERR! or use
npm ERR! reportbug --attach ../../npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.2.0-29-generic
npm ERR! command "node" "/usr/bin/npm" "install" "https://github.com/nodeca/js-yaml/tarball/master"
npm ERR! cwd ../..
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! path ../../node_modules/js-yaml/bin/js-yaml.js
npm ERR! code ENOENT
npm ERR! message ENOENT, no such file or directory '../../node_modules/js-yaml/bin/js-yaml.js'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! ../../npm-debug.log
npm not ok

Add UTF-16 support.

Encoding should be automatically guessed when reading from the file. Right now it's hardcoded to read as UTF-8 only. Need to "guess" which UTF to use by first byte of the buffer: http://pyyaml.org/browser/pyyaml/trunk/lib3/yaml/reader.py#L122

It needs to raise an exception on invalid UTF bytes:

yaml.reader.ReaderError: 'utf8' codec can't decode byte #xff: invalid start byte
  in "invalid-utf8-byte.loader-error", position 4119

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.