magmarath

1.0.3 • Public • Published

Magmarath

Magmarath is a simple storage system for Javascript. It helps ensure that values put into the store is formatted correctly and is a valid value. Helpful for simple maintaining an external storage (through local storage, JSON file, query string etc).

Examples

const { Store, Item } = require('magmarath');

const store = new Store();
const item = new Item('country', {
  defaultValue: 'US',
  options: ['US', 'UK', 'CA'],
  displayFormatter: (v) => v.toLowerCase(),
  typeFormatter: (v) => v.toUpperCase(),
});

store.addItem(item);

store.fromJson({ country: 'UK' });

item.value === 'UK' // true

item.update('AU');
item.value === 'AU'; // false

store.toJson() // { country: 'us' }

Installation

Readme

Keywords

none

Package Sidebar

Install

npm i magmarath

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

6.33 kB

Total Files

8

Last publish

Collaborators

  • dinubs