1.0.3 • Published 4 years ago

magmarath v1.0.3

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

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