abitbol-serializable

Serializable classes based on Abitbol classes

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
abitbol-serializable
022.0.05 years ago7 years agoMinified + gzip package size for abitbol-serializable in KB

Readme

abitbol-serializable
Build Status NPM Version License Greenkeeper badge
Abitbol Serializable is an abitbol class that can serialize its properties.
Features:
  • Serialize / Unserialize all computed properties that have a getter and
a setter,
  • Skip properties annotated with "@serializable false".
  • Use custom serialization function for specific properties.

Example Class:
var SerializableClass = require("abitbol-serializable");

var Person = SerializableClass.$extend({

    __name__: "Person",  // The class name

    __init__: function(params) {
        this.$data.firstName = "John";
        this.$data.lastName = "DOE";
        this.$data.age = 0;
        this.$super(params);
    },

    getFirstName: function() {
        return this.$data.firstName;
    },

    setFirstName: function(firstName) {
        this.$data.firstName = firstName;
    },

    getLastName: function() {
        return this.$data.lastName;
    },

    setLastName: function(lastName) {
        this.$data.lastName = lastName;
    },

    getAge: function() {
        "@serializable false";
        return this.$data.age;
    },

    setAge: function(age) {
        this.$data.age = age;
    }

});

Example Serialization:
var john = new Person({
    lastName: "Wayne",
    age: 72
});

john.serialize();

// -> {
//        __name__: "Person",
//        id: "<an autogenerated uuid>",
//        firstName: "John",
//        lastName: "Wayne"
//    }

Documentation

  • https://wanadev.github.io/abitbol-serializable/

Changelog

  • 2.0.0: Updates abitbol dependency to 2.0.0
  • 1.0.2: Documentation site
  • 1.0.1: Updates uuid dependency to 3.0.0
  • 1.0.0: Initial release