props
extract json/yaml from the beginning of text files
Last updated 14 years ago .
Repository · Bugs · Original npm · Tarball · package.json
$ npm install props 
SYNC missed versions from official npm registry.

props

a module for node that is able to extract either JSON or YAML from the beginning of a string

Installation

npm install props or npm install -g props

Usage

var props = require("props");

// Use JSON

var json =
'{\n\
  "title": "How to use node.js",\n\
  "date": "2011-08-09T17:56:00",\n\
  "tags": [ "example", "node.js" ]\n\
}\n\
\n\
\n\
Node.js is a new technology...';

console.log(props(json));

// or YAML

var yaml =
'title: How to use node.js\n\
date: 2011-08-09T17:56:00\n\
tags:\n\
  - example\n\
  - node.js\n\
\n\
\n\
Node.js is a new technology...';

console.log(props(yaml));

This will print nearly the same object twice, since json and yaml define the same object:

JSON:

{ title: 'How to use node.js',
  date: '2011-08-09T17:56:00',
  tags: [ 'example', 'node.js' ],
  __content: 'Node.js is a new technology...' }

YAML:

{ title: 'How to use node.js',
  date: Tue, 09 Aug 2011 15:56:00 GMT,
  tags: [ 'example', 'node.js' ],
  __content: 'Node.js is a new technology...' }

The difference is that, due to it's JS implementation, the Date is parsed in the YAML version.

The JSON/YAML part has to be always seperated from the content by three newline characters (\n\n\n or \r\n\r\n\r\n).

Bugs and Issues

If you encounter any bugs or issues, feel free to open an issue at github.

License

The MIT license.

Current Tags

  • 0.3.0                                ...           latest (14 years ago)

11 Versions

  • 0.3.0                                ...           14 years ago
  • 0.2.4                                ...           14 years ago
  • 0.2.3                                ...           15 years ago
  • 0.2.2                                ...           15 years ago
  • 0.2.1                                ...           15 years ago
  • 0.2.0                                ...           15 years ago
  • 0.1.1                                ...           15 years ago
  • 0.1.0                                ...           15 years ago
  • 0.0.3                                ...           15 years ago
  • 0.0.2                                ...           15 years ago
  • 0.0.1                                ...           15 years ago
Maintainers (1)
Downloads
Total 52
Today 0
This Week 8
This Month 21
Last Day 0
Last Week 0
Last Month 11
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE