Socket
Book a DemoInstallSign in
Socket

data-directory

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-directory

Load data from a directory like Jekyll

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

data-directory

This is a Node module for loading structured data from a directory in the style of Jekyll's _data. Install it with:

npm install data-directory

Directory Structure

Your directory should contain one or more files with the following extensions:

  • .csv for comma-separated values
  • .json for JSON
  • .yaml or .yml for YAML

You can read them all into a single data structure like this:

var loadData = require('data-directory');
loadData('_data', function(error, data) {
  if (error) return console.error('error:', error);
  console.log('data:', JSON.stringify(data, null, '  '));
});

Nested Directories

Nested directories will introduce new levels in the data structure. For instance, if you data directory looks like this:

├─ bar.json
└─ baz
   └─ qux.csv

Then it should parse into a JSON structure that looks like:

{
  "bar": {
    // contents of bar.json
  },
  "baz": {
    "qux": [
      // rows in baz/qux.csv
    ]
  }
}

Keywords

jekyll

FAQs

Package last updated on 05 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts