Evented Storage Agnostic Data API
Problem: You've got data and you want to do something whenever it changes.
Access and modify your data through the Tomes API and you'll get change events.
Play with a live demo here - https://bjornstar.github.io/tomes/
var filmData = {
cast: [
{ name: "Mr. Blonde", guns: 1, razors: 1 },
{ name: "Marvin Nash", ears: [ "left", "right" ], cop: true },
]
};
var reservoirDogs = Tome.conjure(filmData);
reservoirDogs.cast[1].on('readable', function (marvinNash) {
console.log(marvinNash.ears.length);
});
// >>> 2
reservoirDogs.cast[1].ears.pop();
// >>> 1
Returns a new Tome containing your data.
Returns data's type as a string. Tomes has types that exist in JSON which are:
- array
- boolean
- null
- number
- object
- string As well as:
- undefined
Returns a boolean indicating whether data is a Tome or not.
Returns a regular JavaScript version of your Tome.
- ArrayTome
- BooleanTome
- NullTome
- NumberTome
- ObjectTome
- StringTome
- UndefinedTome
Make a tome and all of it's sub-tomes emit destroy. This will not delete anything.
Assign data to a Tome.
Assign data to key on a Tome. Set will create a Tome on the key if it does not exist.
Delete a key from a Tome.
Swap key with tome.
Rename key to newkey.
Move key to tome. Optionally call it newkey on that tome.
Get a single change operation from the root Tome, removing it in the process. Returns null if there are no changes.
Get all change operations from the Tome
Applies a change operation or an array of change operations to a Tome.
Makes the tome and all of it's sub-tomes emit destroy. Does not delete anything.
Returns a regular javascript version of your Tome.
Returns a Tome's key.
Returns a Tome's parent Tome.
Returns a Tome's version.
Returns a boolean value indicating whether or not the Tome is observably indistinguishable from value (ref). If no value is given, returns whether or not the Tome's value is truthy.
Returns whether a Tome has been changed, but the change has not been read.
Emitted when a Tome receives a new key.
Emitted when a key is deleted from a Tome.
Emitted when a Tome is deleted. Removes all event listeners for this Tome.
Emitted every time a Tome or any of its child Tomes are altered. If the Tome was a primitive (ie. string, number, or boolean) the previous value will be emitted as well, but only if it did not change types.
Emitted by the root tome when a Tome changes type.