Skip to content

yunmin97/data-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A config data plugin for applications developed with nodejs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published