0.1.2 • Published 5 years ago

@delucis/reading-data-yaml-loader v0.1.2

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
5 years ago

@delucis/reading-data-yaml-loader

Build Status Coverage Status npm (scoped)

A plugin for @delucis/reading-data that loads YAML files over the network or from the local file system.

Installation

npm install --save @delucis/reading-data-yaml-loader

Usage

const RD = require('@delucis/reading-data')
const YAML_LOADER = require('@delucis/reading-data-yaml-loader')

RD.use(YAML_LOADER, {
  scope: 'myYAMLFile',
  path: 'https://unpkg.com/@delucis/reading-data/.travis.yml'
})

RD.run().then((res) => {
  console.log(res.data.myYAMLFile)
})

Using reading-data-yaml-loader to load multiple files:

RD.use(YAML_LOADER, {
  scope: [local, github, unpkg]
  path: {
    local: 'config.yml',
    github: 'https://raw.githubusercontent.com/delucis/reading-data/master/.travis.yml',
    unpkg: 'https://unpkg.com/@delucis/reading-data/.travis.yml'
  }
})

RD.run().then((res) => {
  for (var key in res.data) {
    console.log(key) // 'local', 'github', 'unpkg'
  }
})

Options

nametypedefaultrequired?description
hooksString, ObjectThe reading-data hook that should load the YAML file. Can be scoped by passing an object with scopes as keys, hooks as values.
pathString, Object✔︎The path or URL of the YAML file to load. Can be an object, where the keys match the scope(s) set in the scope option.
scopeString, Array'yaml-loader'The scope under which reading-data will store this plugin’s data. Can be an array to return multiple filepaths/URLs, to multiple scopes.