@andrewcaires/decorator 1.0.3 → 1.1.0
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.cjs.js +2 -2
- package/dist/index.d.ts +9 -12
- package/dist/index.esm.js +2 -2
- package/package.json +5 -5
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @andrewcaires/decorator v1.0
|
|
2
|
+
* @andrewcaires/decorator v1.1.0
|
|
3
3
|
* Typescript decorator library for nodejs development
|
|
4
4
|
* (c) 2026 Andrew Caires
|
|
5
5
|
* @license: MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var e=require("@andrewcaires/utils.js");const t=
|
|
7
|
+
"use strict";var e=require("@andrewcaires/utils.js");const t=e.cache(),r=(r,s,o)=>{e.isObject(s)&&!e.isSymbol(s)&&(s=s.constructor);const n=t(s);return n[r]||(n[r]=o),n[r]},s=Symbol("INJECTION"),o=e=>{var t;const n=r(s,e,{});return(null!==(t=n.args)&&void 0!==t?t:[]).sort(({index:e},{index:t})=>e-t).map(({key:e})=>(n.instance||(n.instance=new e(o(e))),n.instance))},n=Symbol("SINGLETON");exports.Inject=e=>(t,o,n)=>{const c=r(s,t,{});c.args||(c.args=[]),c.args.push({index:n,key:e})},exports.Injectable=()=>e=>class t extends e{constructor(...n){super(...o(e)),r(s,t,{}).constructor=e}},exports.InjectionKey=s,exports.Singleton=()=>e=>class t extends e{constructor(...e){if(t[n])return t[n];super(...e),t[n]=this}},exports.SingletonKey=n,exports.Trait=(...e)=>t=>{e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{var s;Object.defineProperty(t.prototype,r,null!==(s=Object.getOwnPropertyDescriptor(e.prototype,r))&&void 0!==s?s:Object.create(null))})})},exports.getInjectionArgs=o,exports.metadata=r;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @andrewcaires/decorator v1.0
|
|
2
|
+
* @andrewcaires/decorator v1.1.0
|
|
3
3
|
* Typescript decorator library for nodejs development
|
|
4
4
|
* (c) 2026 Andrew Caires
|
|
5
5
|
* @license: MIT
|
|
6
6
|
*/
|
|
7
|
-
import { TypeAnyConstructor, TypeAnyObject } from '@andrewcaires/utils.js';
|
|
7
|
+
import { TypeAnyConstructor, TypeAnyFunction, TypeAnyObject } from '@andrewcaires/utils.js';
|
|
8
|
+
|
|
9
|
+
declare const getInjectionArgs: (target: TypeAnyConstructor) => Array<any>;
|
|
8
10
|
|
|
9
11
|
declare const Inject: (key: TypeAnyConstructor) => ParameterDecorator;
|
|
10
12
|
|
|
11
|
-
declare const Injectable: <T extends TypeAnyConstructor>(
|
|
13
|
+
declare const Injectable: <T extends TypeAnyConstructor>() => TypeAnyFunction<T>;
|
|
12
14
|
|
|
13
15
|
interface Injection {
|
|
14
16
|
args: Array<any>;
|
|
@@ -18,18 +20,13 @@ interface Injection {
|
|
|
18
20
|
|
|
19
21
|
declare const InjectionKey: unique symbol;
|
|
20
22
|
|
|
21
|
-
declare
|
|
22
|
-
private static registry;
|
|
23
|
-
static register(key: TypeAnyConstructor, instance: TypeAnyObject): void;
|
|
24
|
-
static get(key: TypeAnyConstructor): TypeAnyObject | null;
|
|
25
|
-
static has(key: TypeAnyConstructor): boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
declare const Singleton: <T extends TypeAnyConstructor>(constructor: T) => T;
|
|
23
|
+
declare const Singleton: <T extends TypeAnyConstructor>() => TypeAnyFunction<T>;
|
|
29
24
|
|
|
30
25
|
declare const SingletonKey: unique symbol;
|
|
31
26
|
|
|
27
|
+
declare const Trait: (...constructors: Array<TypeAnyConstructor>) => ClassDecorator;
|
|
28
|
+
|
|
32
29
|
declare const metadata: <T = any>(key: symbol, target: any, value: T) => T;
|
|
33
30
|
|
|
34
|
-
export { Inject, Injectable, InjectionKey,
|
|
31
|
+
export { Inject, Injectable, InjectionKey, Singleton, SingletonKey, Trait, getInjectionArgs, metadata };
|
|
35
32
|
export type { Injection };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @andrewcaires/decorator v1.0
|
|
2
|
+
* @andrewcaires/decorator v1.1.0
|
|
3
3
|
* Typescript decorator library for nodejs development
|
|
4
4
|
* (c) 2026 Andrew Caires
|
|
5
5
|
* @license: MIT
|
|
6
6
|
*/
|
|
7
|
-
import{
|
|
7
|
+
import{cache as r,isObject as t,isSymbol as e}from"@andrewcaires/utils.js";const o=r(),s=(r,s,n)=>{t(s)&&!e(s)&&(s=s.constructor);const c=o(s);return c[r]||(c[r]=n),c[r]},n=Symbol("INJECTION"),c=r=>{var t;const e=s(n,r,{});return(null!==(t=e.args)&&void 0!==t?t:[]).sort(({index:r},{index:t})=>r-t).map(({key:r})=>(e.instance||(e.instance=new r(c(r))),e.instance))},a=r=>(t,e,o)=>{const c=s(n,t,{});c.args||(c.args=[]),c.args.push({index:o,key:r})},p=()=>r=>class t extends r{constructor(...e){super(...c(r)),s(n,t,{}).constructor=r}},i=Symbol("SINGLETON"),u=()=>r=>class t extends r{constructor(...r){if(t[i])return t[i];super(...r),t[i]=this}},l=(...r)=>t=>{r.forEach(r=>{Object.getOwnPropertyNames(r.prototype).forEach(e=>{var o;Object.defineProperty(t.prototype,e,null!==(o=Object.getOwnPropertyDescriptor(r.prototype,e))&&void 0!==o?o:Object.create(null))})})};export{a as Inject,p as Injectable,n as InjectionKey,u as Singleton,i as SingletonKey,l as Trait,c as getInjectionArgs,s as metadata};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrewcaires/decorator",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Typescript decorator library for nodejs development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs.js",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/andrewcaires/npm/tree/main/decorator#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@andrewcaires/utils.js": "^0.4.
|
|
40
|
+
"@andrewcaires/utils.js": "^0.4.25"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
44
44
|
"@rollup/plugin-terser": "^0.4.4",
|
|
45
45
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
46
|
-
"@types/node": "^25.0.
|
|
46
|
+
"@types/node": "^25.0.9",
|
|
47
47
|
"eslint": "^9.39.2",
|
|
48
|
-
"rollup": "^4.55.
|
|
48
|
+
"rollup": "^4.55.2",
|
|
49
49
|
"rollup-plugin-dts": "^6.3.0",
|
|
50
50
|
"tslib": "^2.8.1",
|
|
51
51
|
"tsx": "^4.21.0",
|
|
52
|
-
"typescript-eslint": "^8.53.
|
|
52
|
+
"typescript-eslint": "^8.53.1"
|
|
53
53
|
}
|
|
54
54
|
}
|