JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 765
  • Score
    100M100P100Q98140F
  • License

Read JSON or YAML files.

Package Exports

  • read-data

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (read-data) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

read-data NPM version Build Status

Read JSON or YAML files.

Install with npm

npm i read-data --save

API

.yaml

Asynchronously read a YAML file.

  • fp {String}: path of the file to read.
  • options {Object|String}: to pass to [js-yaml]
  • cb {Function}: callback function
  • returns {Object}: JSON
var yaml = require('read-data').yaml;

yaml('foo.yml', function(err, data) {
  if (err) throw err;
  console.log(data);
});

.yaml.sync

Synchronously read a YAML file.

  • fp {String}: path of the file to read.
  • options {Object|String}: to pass to [js-yaml]
  • returns {Object}: JSON
var yaml = require('read-data').yaml;
var data = yaml.sync('foo.yml');

.json

Asynchronously read a JSON file.

  • fp {String}: path of the file to read.
  • callback {Function}: callback function
  • returns {Object}: JSON
var json = require('read-data');

json('foo.json', function(err, data) {
  if (err) throw err;
  console.log(data);
});

.json.sync

Synchronously read a JSON file.

  • fp {String}: path of the file to read.
  • returns {Object}: JSON
var json = require('read-data').json;
var data = json.sync('foo.json');

.data

Asynchronously read a JSON or YAML file, automatically determining the reader based on extension.

  • fp {String}: path of the file to read.
  • options {Object|String}: to pass to [js-yaml]
  • cb {Function}: callback function
  • returns {Object}: JSON
var read = require('read-data');

read('foo.json', function(err, data) {
  if (err) throw err;
  console.log(data);
});

read('foo.yml', function(err, data) {
  if (err) throw err;
  console.log(data);
});

.data.sync

Synchronously read a data file, automatically determining the reader based on extension.

  • fp {String}: path of the file to read.
  • options {Object|String}: to pass to [js-yaml]
  • returns {Object}: JSON
var data = require('read-data').data;

var yaml = data.sync('foo.yml');
var json = data.sync('foo.json');
  • read-yaml: Very thin wrapper around js-yaml for directly reading in YAML files.
  • map-files: Return an object for a glob of files. Pass a rename function for the keys, or a parse function for the content, allowing it to be used for readable or require-able files.
  • data-store: Easily get, set and persist config data.
  • write-json: Write a JSON to file disk, also creates directories in the dest path if they don't already exist.
  • write-yaml: Write YAML. Converts JSON to YAML writes it to the specified file.
  • plasma: Load data from globs or files or directly from objects.

Running tests

Install dev dependencies:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 31, 2015.