1.0.0 • Published 2 years ago

data-plugin v1.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
2 years ago

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);
// ... ...
// ... ...
1.0.0

2 years ago

0.0.7

2 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago