Socket
Socket
Sign inDemoInstall

serializable-model

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    serializable-model

A serializable and deserializable model written in TypeScript.


Version published
Weekly downloads
7
increased by600%
Maintainers
1
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 28 Apr 2016

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc