@bargain/core
TypeScript icon, indicating that this package has built-in type declarations

1.0.1-alpha.0 • Public • Published

@bargain/core

A simple TypeScript decorator-based library for serializing and deserializing data.

Usage

Before you get started, make sure that you update your tsconfig.json to include the following to enable TypeScript decorators:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

After, that you can import any of the package members into your code.

import { Property, Bargain } from "@bargain/core";

class Person {
  @Property()
  name: string = "Carter";

  formatFullName(lastName: string) {
    return `${this.name} ${lastName}`;
  }
}

const bargain = new Bargain(); // initializes bargain

const person = new Person(); // Person { name: "Carter" }
const personFullName = person.formatFullName("Foo"); // "Carter Foo"

const serializedPerson = bargain.serialize(person); // { name: "Carter" }

console.log(serializedPerson.formatFullName); // undefined

License

MIT

Package Sidebar

Install

npm i @bargain/core

Weekly Downloads

0

Version

1.0.1-alpha.0

License

MIT

Unpacked Size

29.7 kB

Total Files

13

Last publish

Collaborators

  • sno2