onaml
v0.0.4
Published
Oh No, Another Markup Language. Based on YAML, but stores considerably more object metadata.
Downloads
1
Maintainers
Readme
ONAML
Oh No! Another Markup Language - The Javacript version.
ONAML is a markup language / serialization format similar to JSON and, more closely, YAML. Key features of ONAML are:
- ONAML (re)stores type information, a serialized
RegExp
will be restored as aRegExp
. - The full property descriptor information is stored and restored. A read-only property will be restored as read-only.
- Every non-trivial object or array is provided with a permanent unique id, user
accessible in the (non-enumerable, read-only and hidden)
__puid
property. - Objects are deduplicated and referenced. Every non-trivial item is serialized exactly once.
- Pluggable input and output handlers.
Usage
Obtaining & initialization:
npm install --save onaml
var ONAML = require('onaml')([configuration]);
The examples directory has two example files. Run write.js
first, to populate
the local disk store.
Configuration options
So far the only configuration option is:
storageDirectory
: Directory containing serialized ONAML objects. Used forsave
andload
functions. Default:./onaml.store
Methods
serialize( object )
Serialize the given object or array. Returns a string.restore( puid, string )
: Return object or array with givenpuid
, from string or string arraysource
.exists( puid )
: Returns true ifpuid
is either loaded in memory or available in the store.load( puid )
: Return object or array with givenpuid
fromstorageDirectory/puid.onaml
save( puid )
: Serialize object or array withpuid
and all children to disk.
Format
An ONAML file is only only one level deep, because of the (non-optional) referencing:
7cpfOepkqPe(!!js/Object, @@7cpfOepkqPe):
count(!!js/number, writable=true, enumerable=true, configurable=true): 5739573
nope(!!js/null, writable=true, enumerable=true, configurable=true): null
myBoolean(!!js/boolean, writable=true, enumerable=true, configurable=true): true
myBuffer(!!js/Buffer, writable=true, enumerable=true, configurable=true): AAAAAAAAAADQzOsAAAAAAA==
myDate(!!js/Date, writable=true, enumerable=true, configurable=true): 2015-08-28T15:42:14.002Z
childArray(!!ONAML/reference, writable=true, enumerable=true, configurable=true): 7cpfOeoLez6
childObject(!!ONAML/reference, writable=true, enumerable=true, configurable=true): 7cpfOepkqPf
The first and non-indented line (object definition):
- The puid for this object
- Optional property attributes, between brackets:
!!...
: Type / prototype name@@...
: puid:
followed by a newline
The subsequent, indented lines:
- Property name
- Optional property attributes, between brackets:
!!...
: Type / prototype name@@...
: puid...
: property descriptor settings:
followed by the value
A linked object will have ONAML/reference
as type and the referenced id as value.
License
This project is licensed as LGPLv3, the license file is included in the project directory.
The ONAML repository on GitHub
Copyright 2015 Stefan Hamminga - prjct.net