nucleus-mold 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export declare function Nucleus(options?: {
1
+ export declare function Serializable(options?: {
2
2
  as?: string;
3
3
  }): <T extends Function>(target: T, context: ClassDecoratorContext<any>) => void;
4
- export declare const JsonMold: {
5
- conceal: (obj: any, space?: number) => string;
6
- reveal: <T = any>(json: string) => T;
4
+ export declare const Json: {
5
+ marshall: (obj: any, space?: number) => string;
6
+ unmarshall: <T = any>(json: string) => T;
7
7
  };
8
8
  export declare function isSerializable(obj: any): boolean;
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,OAAO,CAAC,OAAO,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,IAC7B,CAAC,SAAS,QAAQ,EAC9B,QAAQ,CAAC,EACT,SAAS,qBAAqB,CAAC,GAAG,CAAC,KACpC,IAAI,CAsBV;AAGD,eAAO,MAAM,QAAQ;mBACF,GAAG,UAAU,MAAM;aAIzB,CAAC,cAAc,MAAM,KAAG,CAAC;CAqBrC,CAAA;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAEhD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,IAClC,CAAC,SAAS,QAAQ,EAC9B,QAAQ,CAAC,EACT,SAAS,qBAAqB,CAAC,GAAG,CAAC,KACpC,IAAI,CAsBV;AAGD,eAAO,MAAM,IAAI;oBACG,GAAG,UAAU,MAAM;iBAItB,CAAC,cAAc,MAAM,KAAG,CAAC;CAqBzC,CAAA;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAEhD"}
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsonMold = void 0;
4
- exports.Nucleus = Nucleus;
3
+ exports.Json = void 0;
4
+ exports.Serializable = Serializable;
5
5
  exports.isSerializable = isSerializable;
6
6
  const SERIALIZABLE_MARKER = Symbol('serializable');
7
7
  const TYPE_KEY = '__type';
8
8
  const registry = new Map();
9
- function Nucleus(options) {
9
+ function Serializable(options) {
10
10
  return function (target, context) {
11
11
  const className = options?.as || context?.name || target.name;
12
12
  registry.set(className, target);
@@ -25,11 +25,11 @@ function Nucleus(options) {
25
25
  };
26
26
  };
27
27
  }
28
- exports.JsonMold = {
29
- conceal: (obj, space) => {
28
+ exports.Json = {
29
+ marshall: (obj, space) => {
30
30
  return JSON.stringify(obj, null, space);
31
31
  },
32
- reveal: (json) => {
32
+ unmarshall: (json) => {
33
33
  return JSON.parse(json, (key, value) => {
34
34
  if (value && typeof value === 'object' && value[TYPE_KEY]) {
35
35
  const TargetClass = registry.get(value[TYPE_KEY]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-mold",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "files": [
5
5
  "dist",
6
6
  "README.md"