Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
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

FAQs

Package last updated on 27 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc