Nibble Plum Meringue

    abitbol-serializable

    2.0.0 • Public • Published

    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

    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

    Install

    npm i abitbol-serializable

    DownloadsWeekly Downloads

    152

    Version

    2.0.0

    License

    BSD-3-Clause

    Unpacked Size

    75 kB

    Total Files

    8

    Last publish

    Collaborators

    • flozz
    • wanadmin