🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

serializable-model

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serializable-model

A serializable and deserializable model written in TypeScript.

1.0.5
latest
Source
npm
Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Source

SerializableModel.ts

Usage

A serializable and deserializable base model written in Typescript. Use it as follows:


import { SerializableModel } from 'serializable-model';

export default class ChildModel extends SerializableModel {
  private name;

  getName():string {
    return this.name;
  }

  setName(value:string) {
    this.name = value;
  }
}

Instantiation

You then can instantiate via one of the following methods:

let model = new ChildModel();

model.setName('karl');

// prints 'karl'
console.log(model.getName());

Deserialization

let model = ChildModel.fromObject({ name: 'karl' });

// prints 'karl'
console.log(model.getName());

which is basically the same as:

let model = new ChildModel();

model.deserialize{ name: 'karl' });

// prints 'karl'
console.log(model.getName());

Serialization

let obj = model.serialize();

// prints 'karl'
console.log(obj.name);

Keywords

BaseModel

FAQs

Package last updated on 28 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts