data-plugin

1.0.0 • Public • Published

data-plugin

data-plugin is a config data(.csv&.json) plugin for applications developed with nodejs. data-plugin can watch all config files in the given dir and reload the file automatically and asynchronous when it is modified.

Installation

npm install data-plugin

Usage

// ... ...
// ... ...
let plugin = require('data-plugin')({
    dir: './config/data',
    // must set for csv
    idx: 'id',
    // interval: 3000,
    // a file loaded callback
    // onLoaded: function(name){}
    // all files loaded down callback
    // onAllLoaded: function(){}
});
// ... ...
// ... ...
// check if the config exists 
if (!plugin.hasJson('card')) {
    return;
}
// get a json object by name
let card = plugin.getJson('card');
// ... ...
// ... ...
// check if the config exists 
if (!plugin.hasCSV('item')) {
    return;
}
// get a csv table by name
let item = plugin.getCSV('item');
// check if the value exists by id
if (item.has(0)) {
    return;
}
// get a value from csv table by id
let value = item.get(0);
// ... ...
// ... ...

Readme

Keywords

Package Sidebar

Install

npm i data-plugin

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

19 kB

Total Files

12

Last publish

Collaborators

  • yunmin