organic-watch-json-dir

1.4.0 • Public • Published

organic-watch-json-dir

Organelle for emitting changes in directory with .json files.

How to install

The minimal version of nodejs is: Nodejs version 4+

Open your terminal and run:

npm install organic-watch-json-dir --save

dna

{
  "location": "/full/path/with/json/files",
  "reactOn": ChemicalPattern,
  "emit": {
    "dataPropertyName": "data",
    "onChangeFile": ChemicalType || Function,
    "onNewFile": ChemicalType || Function,
    "onDeleteFile": ChemicalType || Function,
    "ready": ChemicalType,
    "errors": ChemicalType
  },
  "chokidar": {
    "awaitWriteFinish": {
      "stabilityThreshold": 100,
      "pollInterval": 10
    }
  }
}

reacts

reactOn chemical pattern is optional, if not present will execute during build(construction) phase.

emits

.json file related

  • onChangeFile emits when file has been touched
  • onNewFile emits when file has been created or it has been initially found
  • onDeleteFile emits when file has been removed (with a cached autoloaded data)

all chemicals have the following shape:

{
  type: dna.emit.*,
  <dna.emit.dataPropertyName>: JSON,
  path: String
}
  • note that invalid json files will not trigger emits
  • when dna.emit[key] is Function it will be invoked as dna.emit[key](c) where c is chemical having the above outlined shape.

ready

ready is optional, if present will emit in plasma dna specified plain chemical type.

errors

errors is optional, if present will emit any errors found during loading and parsing respective (new/changed) json files.

Contributing

We ♥️ contribution so send your PRs accordingly. Dont forget to update the README and tests along the way ;)

Readme

Keywords

none

Package Sidebar

Install

npm i organic-watch-json-dir

Weekly Downloads

0

Version

1.4.0

License

MIT

Unpacked Size

13.1 kB

Total Files

13

Last publish

Collaborators

  • outbounder