windyrobin / HotCfg

json files auto load when the content changes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A auto-reload Json class

It supports file/diretory mode and you could use it like that :

var cfg = new Cfg("file.json");
var obj = cfg.get();

if you specify a directory and it has two files :

   dir/a.json
   dir/b.json

you could write code like that :

var cfg = new Cfg("dir");
var obja = cfg.get("a.json");
var objb = cfg.get("b.json");

####Note:

when you use directory mode ,it will auto-load when file add/detele/rename, but if you edit the exsting file, you should 'touch' the directory to trigger the change event to reload

About

json files auto load when the content changes


Languages

Language:JavaScript 100.0%