@originforest/common
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Common library in originforest

Setup

npm i @originforest/common

set config in tsconfig.json

"experimentalDecorators": true,
"emitDecoratorMetadata": true,

Distributed identity

use api

import {identity} from '@originforest/common'

// a unique id.
let id = identity.nextId();

// test id.
if (!identity.isValidId(id)) {
}

// id length.
identity.idLength == 32

use decorator

import {Identity} from '@originforest/common'

class Demo {
  @Identity
  id: string;
}

// a unique id.
new Demo().id

ErrorCode

import {errorCode, getErrorCodeMsg} from '@originforest/common';

// get the errCode
errorCode.OK                // 200
errorCode.NOT_FOUND         // 404
errorCode.OPERATOR_EXPIRED  // 408

getErrorCodeMsg(errorCode.OPERATOR_EXPIRED) // 'OPERATOR_EXPIRED'

Msg

Network message package.

import {Msg, errorCode} from '@originforest/common';

let msg:Msg = {
  err_code: errorCode.OK
}

Readme

Keywords

Package Sidebar

Install

npm i @originforest/common

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

43.4 kB

Total Files

23

Last publish

Collaborators

  • brainpoint