packages/ove-lib-utils/src/persistence.js
function Persistable (key, value) {
        const __self = this;
        __self.key = key;

        // Set value and type of object.
        if (value === undefined || value === null) {
            __self.value = undefined;
            __self.type = typeof undefined;
        } else if (value instanceof Array) {
            __self.value = [];
            value.forEach(function (e, i) {
                __self.value.push(new Persistable(key + '[' + i + ']', e));
            });
            __self.type = Type.ARRAY;
        } else {
            switch (typeof value) {
                case Type.STRING:
                case Type.NUMBER:
                case Type.BOOLEAN:
                    __self.value = value;
                    __self.type = typeof value;
                    break;
                case Type.OBJECT:
                    __self.value = [];
                    Object.keys(value).forEach(function (e) {
                        __self.value.push(new Persistable(key + '[' + e + ']', value[e]));
                    });
                    __self.type = typeof value;
                    break;
                default:
                    _logUnknownType(typeof value);
            }
        }

        __self.timestamp = Date.now();

        __self.toOriginal = function () {
            return _fromPersistable(__self);
        };
    }
function Persistable (key, value) {
        const __self = this;
        __self.key = key;

        // Set value and type of object.
        if (value === undefined || value === null) {
            __self.value = undefined;
            __self.type = typeof undefined;
        } else if (value instanceof Array) {
            __self.value = [];
            value.forEach(function (e, i) {
                __self.value.push(new Persistable(key + '[' + i + ']', e));
            });
            __self.type = Type.ARRAY;
        } else {
            switch (typeof value) {
                case Type.STRING:
                case Type.NUMBER:
                case Type.BOOLEAN:
                    __self.value = value;
                    __self.type = typeof value;
                    break;
                case Type.OBJECT:
                    __self.value = [];
                    Object.keys(value).forEach(function (e) {
                        __self.value.push(new Persistable(key + '[' + e + ']', value[e]));
                    });
                    __self.type = typeof value;
                    break;
                default:
                    _logUnknownType(typeof value);
            }
        }

        __self.timestamp = Date.now();

        __self.toOriginal = function () {
            return _fromPersistable(__self);
        };
    }
function Persistable ( key , value ) { const __self = this ; __self . key = key ; // Set value and type of object. if ( value === undefined || value === null ) { __self . value = undefined ; __self . type = typeof undefined ; } else if ( value instanceof Array ) { __self . value = [ ] ; value . forEach ( function ( e , i ) { __self . value . push ( new Persistable ( key + '[' + i + ']' , e ) ) ; } ) ; __self . type = Type . ARRAY ; } else { switch ( typeof value ) { case Type . STRING : case Type . NUMBER : case Type . BOOLEAN : __self . value = value ; __self . type = typeof value ; break ; case Type . OBJECT : __self . value = [ ] ; Object . keys ( value ) . forEach ( function ( e ) { __self . value . push ( new Persistable ( key + '[' + e + ']' , value [ e ] ) ) ; } ) ; __self . type = typeof value ; break ; default : _logUnknownType ( typeof value ) ; } } __self . timestamp = Date . now ( ) ; __self . toOriginal = function ( ) { return _fromPersistable ( __self ) ; } ; }
The persistable object.
The persistable object .