@prostojs/mate 0.0.1 → 0.0.2

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.
@@ -88,3 +88,5 @@ class Mate {
88
88
  }
89
89
 
90
90
  exports.Mate = Mate;
91
+ exports.getConstructor = getConstructor;
92
+ exports.isConstructor = isConstructor;
package/dist/mate.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export declare function getConstructor<T = TObject>(instance: T): TFunction;
2
+
3
+ export declare function isConstructor<T = TAny>(v: T): v is T & TClassConstructor;
4
+
1
5
  export declare class Mate<T extends TProstoMetadata = TProstoMetadata> {
2
6
  protected workspace: string;
3
7
  constructor(workspace: string);
@@ -13,6 +17,8 @@ export declare class Mate<T extends TProstoMetadata = TProstoMetadata> {
13
17
 
14
18
  declare type TAny = any;
15
19
 
20
+ declare type TClassConstructor<T = unknown> = new (...args: TAny[]) => T;
21
+
16
22
  declare type TFunction = Function;
17
23
 
18
24
  export declare interface TMergedDecoratorArgs {
@@ -1 +1 @@
1
- function e(e){console.error(`[prostojs/mate][${(new Date).toISOString().replace("T"," ").replace(/\.\d{3}z$/i,"")}] `+e+"")}function t(e){return"function"==typeof e&&Object.getOwnPropertyNames(e).includes("prototype")&&!Object.getOwnPropertyNames(e).includes("caller")&&!!e.name}require("reflect-metadata");class r{constructor(e){this.workspace=e}set(t,r,a,o){var p;let s=Reflect.getMetadata(this.workspace,t.target,t.propKey)||{};const{index:n}=t,c="function"==typeof r?r:void 0;let i=s;if(i.params||(i.params=null===(p=Reflect.getMetadata("design:paramtypes",t.target,t.propKey))||void 0===p?void 0:p.map((e=>({type:e})))),"number"==typeof n&&(i.params=i.params||[],i.params[n]=i.params[n]||{type:void 0},c?i.params[n]=c(i.params[n]):i=i.params[n]),"function"!=typeof r)if(o){const t=i[r]||[];Array.isArray(t)||(e(f="Mate.add (isArray=true) called for non-array metadata"),new Error(f)),t.unshift(a),i[r]=t}else i[r]=a;else c&&"number"!=typeof n&&(s=c(i));var f;Reflect.defineMetadata(this.workspace,s,t.target,t.propKey)}read(e,r){return Reflect.getMetadata(this.workspace,"string"==typeof r?t(e)?e.prototype:e:t(e)?e:Object.getPrototypeOf(e).constructor,r)}apply(...e){return(t,r,a)=>{for(const o of e)o(t,r,a)}}decorate(e,t,r){return(a,o,p)=>{this.set({target:a,propKey:o,descriptor:"number"==typeof p?void 0:p,index:"number"==typeof p?p:void 0},e,t,r)}}}export{r as Mate};
1
+ function e(e){console.error(`[prostojs/mate][${(new Date).toISOString().replace("T"," ").replace(/\.\d{3}z$/i,"")}] `+e+"")}function t(e){return Object.getPrototypeOf(e).constructor}function r(e){return"function"==typeof e&&Object.getOwnPropertyNames(e).includes("prototype")&&!Object.getOwnPropertyNames(e).includes("caller")&&!!e.name}require("reflect-metadata");class a{constructor(e){this.workspace=e}set(t,r,a,o){var p;let n=Reflect.getMetadata(this.workspace,t.target,t.propKey)||{};const{index:s}=t,c="function"==typeof r?r:void 0;let i=n;if(i.params||(i.params=null===(p=Reflect.getMetadata("design:paramtypes",t.target,t.propKey))||void 0===p?void 0:p.map((e=>({type:e})))),"number"==typeof s&&(i.params=i.params||[],i.params[s]=i.params[s]||{type:void 0},c?i.params[s]=c(i.params[s]):i=i.params[s]),"function"!=typeof r)if(o){const t=i[r]||[];Array.isArray(t)||(e(f="Mate.add (isArray=true) called for non-array metadata"),new Error(f)),t.unshift(a),i[r]=t}else i[r]=a;else c&&"number"!=typeof s&&(n=c(i));var f;Reflect.defineMetadata(this.workspace,n,t.target,t.propKey)}read(e,a){return Reflect.getMetadata(this.workspace,"string"==typeof a?r(e)?e.prototype:e:r(e)?e:t(e),a)}apply(...e){return(t,r,a)=>{for(const o of e)o(t,r,a)}}decorate(e,t,r){return(a,o,p)=>{this.set({target:a,propKey:o,descriptor:"number"==typeof p?void 0:p,index:"number"==typeof p?p:void 0},e,t,r)}}}export{a as Mate,t as getConstructor,r as isConstructor};
@@ -83,4 +83,4 @@ class Mate {
83
83
  }
84
84
  }
85
85
 
86
- export { Mate };
86
+ export { Mate, getConstructor, isConstructor };
@@ -1 +1 @@
1
- var ProstoMate=function(e){"use strict";function t(e){console.error(`[prostojs/mate][${(new Date).toISOString().replace("T"," ").replace(/\.\d{3}z$/i,"")}] `+e+"")}function r(e){return"function"==typeof e&&Object.getOwnPropertyNames(e).includes("prototype")&&!Object.getOwnPropertyNames(e).includes("caller")&&!!e.name}require("reflect-metadata");return e.Mate=class{constructor(e){this.workspace=e}set(e,r,a,o){var p;let s=Reflect.getMetadata(this.workspace,e.target,e.propKey)||{};const{index:n}=e,c="function"==typeof r?r:void 0;let i=s;if(i.params||(i.params=null===(p=Reflect.getMetadata("design:paramtypes",e.target,e.propKey))||void 0===p?void 0:p.map((e=>({type:e})))),"number"==typeof n&&(i.params=i.params||[],i.params[n]=i.params[n]||{type:void 0},c?i.params[n]=c(i.params[n]):i=i.params[n]),"function"!=typeof r)if(o){const e=i[r]||[];Array.isArray(e)||(t(f="Mate.add (isArray=true) called for non-array metadata"),new Error(f)),e.unshift(a),i[r]=e}else i[r]=a;else c&&"number"!=typeof n&&(s=c(i));var f;Reflect.defineMetadata(this.workspace,s,e.target,e.propKey)}read(e,t){return Reflect.getMetadata(this.workspace,"string"==typeof t?r(e)?e.prototype:e:r(e)?e:Object.getPrototypeOf(e).constructor,t)}apply(...e){return(t,r,a)=>{for(const o of e)o(t,r,a)}}decorate(e,t,r){return(a,o,p)=>{this.set({target:a,propKey:o,descriptor:"number"==typeof p?void 0:p,index:"number"==typeof p?p:void 0},e,t,r)}}},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ var ProstoMate=function(e){"use strict";function t(e){console.error(`[prostojs/mate][${(new Date).toISOString().replace("T"," ").replace(/\.\d{3}z$/i,"")}] `+e+"")}function r(e){return Object.getPrototypeOf(e).constructor}function a(e){return"function"==typeof e&&Object.getOwnPropertyNames(e).includes("prototype")&&!Object.getOwnPropertyNames(e).includes("caller")&&!!e.name}require("reflect-metadata");return e.Mate=class{constructor(e){this.workspace=e}set(e,r,a,o){var n;let s=Reflect.getMetadata(this.workspace,e.target,e.propKey)||{};const{index:p}=e,c="function"==typeof r?r:void 0;let i=s;if(i.params||(i.params=null===(n=Reflect.getMetadata("design:paramtypes",e.target,e.propKey))||void 0===n?void 0:n.map((e=>({type:e})))),"number"==typeof p&&(i.params=i.params||[],i.params[p]=i.params[p]||{type:void 0},c?i.params[p]=c(i.params[p]):i=i.params[p]),"function"!=typeof r)if(o){const e=i[r]||[];Array.isArray(e)||(t(u="Mate.add (isArray=true) called for non-array metadata"),new Error(u)),e.unshift(a),i[r]=e}else i[r]=a;else c&&"number"!=typeof p&&(s=c(i));var u;Reflect.defineMetadata(this.workspace,s,e.target,e.propKey)}read(e,t){return Reflect.getMetadata(this.workspace,"string"==typeof t?a(e)?e.prototype:e:a(e)?e:r(e),t)}apply(...e){return(t,r,a)=>{for(const o of e)o(t,r,a)}}decorate(e,t,r){return(a,o,n)=>{this.set({target:a,propKey:o,descriptor:"number"==typeof n?void 0:n,index:"number"==typeof n?n:void 0},e,t,r)}}},e.getConstructor=r,e.isConstructor=a,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
@@ -1,2 +1,3 @@
1
1
  export * from './mate';
2
+ export * from './utils/helpers';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prostojs/mate",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "MATE is TS Metadata Organizer",
5
5
  "main": "index.js",
6
6
  "module": "dist/mate.esm-bundler.js",