Skip to content

An instrument of unrelenting harm.

License

Notifications You must be signed in to change notification settings

Seldszar/lesion

Repository files navigation

Lesion

An instrument of unrelenting harm.

Lesion allows building custom file-based store clients by using resolvers.

Table of Contents

Installation

npm install lesion --save

Usage

const lesion = require('lesion');

const rootPath = '/path/to/store';
const resolvers = [
  {
    extensions: ['json', 'json5'],
    deserialize: contents => JSON.parse(contents.toString('utf8')),
  },
  {
    extensions: ['log', 'txt'],
    deserialize: contents => contents.toString('utf8'),
  },
  {
    extensions: ['gif', 'jpeg', 'jpg', 'png'],
    deserialize: contents => contents,
  },
];

lesion(rootPath, { resolvers })
  .then((store) => {
    // Fetch the store value
    console.log(store.value);

    // Attach a callback called after each store change
    const disposer = store.onChange(({ newFragment, oldFragment }) => {
      console.log({ newFragment, oldFragment });
    });
  });

Author

Alexandre Breteau - @0xSeldszar

License

MIT © Alexandre Breteau

About

An instrument of unrelenting harm.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published