conode 0.2.29 → 0.2.31

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/build/index.cjs CHANGED
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  function _export(target, all) {
6
6
  for(var name in all)Object.defineProperty(target, name, {
7
7
  enumerable: true,
8
- get: all[name]
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- Contextable: function() {
12
+ get Contextable () {
13
13
  return Contextable;
14
14
  },
15
- contextualize: function() {
15
+ get contextualize () {
16
16
  return contextualize;
17
17
  },
18
- createContext: function() {
18
+ get createContext () {
19
19
  return createContext;
20
20
  }
21
21
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nexport type Fn<T extends unknown[], R> = (...args: T) => R;\n\nexport const createContext = <T>() => {\n const storage = new AsyncLocalStorage<{ context: T }>();\n return {\n contextualize<R>(context: T, callback: Fn<[], R>): R {\n return storage.run({ context }, callback);\n },\n getContext() {\n const store = storage.getStore();\n if (!store) {\n throw new Error('Context not initialized');\n }\n return store.context;\n }\n };\n};\n\ntype Constructor = new (...args: any) => any;\n\nexport interface Contextualized {\n contextualize<R>(callback: Fn<[], R>): Promise<R>;\n}\n\nexport function Contextable(BaseClass: Constructor = class { }) {\n const context = createContext();\n return class Contextual extends BaseClass {\n static getContext<C extends Constructor>(this: C) {\n return context.getContext() as InstanceType<C>;\n }\n constructor(...args: unknown[]) {\n super(...args);\n }\n\n contextualize<R>(callback: Fn<[], R>): R {\n return context.contextualize(this, callback);\n }\n };\n}\n\nexport function contextualize<T extends Contextualized, K extends keyof T>(...args: unknown[]) {\n const [, , descriptor] = args as [T, K, TypedPropertyDescriptor<T[K]>];\n const property = descriptor?.value;\n if (typeof property === 'function') {\n descriptor.value = function(this: Contextualized, ...args: unknown[]) {\n return this.contextualize(() => property.apply(this, args));\n } as T[K];\n }\n}\n\n"],"names":["Contextable","contextualize","createContext","storage","AsyncLocalStorage","context","callback","run","getContext","store","getStore","Error","BaseClass","Contextual","constructor","args","descriptor","property","value","apply"],"mappings":";;;;;;;;;;;IA0BgBA,WAAW;eAAXA;;IAgBAC,aAAa;eAAbA;;IAtCHC,aAAa;eAAbA;;;iCAJqB;AAI3B,MAAMA,gBAAgB;IAC3B,MAAMC,UAAU,IAAIC,kCAAiB;IACrC,OAAO;QACLH,eAAiBI,OAAU,EAAEC,QAAmB;YAC9C,OAAOH,QAAQI,GAAG,CAAC;gBAAEF;YAAQ,GAAGC;QAClC;QACAE;YACE,MAAMC,QAAQN,QAAQO,QAAQ;YAC9B,IAAI,CAACD,OAAO;gBACV,MAAM,IAAIE,MAAM;YAClB;YACA,OAAOF,MAAMJ,OAAO;QACtB;IACF;AACF;AAQO,SAASL,YAAYY,YAAyB;AAAQ,CAAC;IAC5D,MAAMP,UAAUH;IAChB,OAAO,MAAMW,mBAAmBD;QAC9B,OAAOJ,aAA2C;YAChD,OAAOH,QAAQG,UAAU;QAC3B;QACAM,YAAY,GAAGC,IAAe,CAAE;YAC9B,KAAK,IAAIA;QACX;QAEAd,cAAiBK,QAAmB,EAAK;YACvC,OAAOD,QAAQJ,aAAa,CAAC,IAAI,EAAEK;QACrC;IACF;AACF;AAEO,SAASL,cAA2D,GAAGc,IAAe;IAC3F,MAAM,KAAKC,WAAW,GAAGD;IACzB,MAAME,WAAWD,YAAYE;IAC7B,IAAI,OAAOD,aAAa,YAAY;QAClCD,WAAWE,KAAK,GAAG,SAA+B,GAAGH,IAAe;YAClE,OAAO,IAAI,CAACd,aAAa,CAAC,IAAMgB,SAASE,KAAK,CAAC,IAAI,EAAEJ;QACvD;IACF;AACF"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nexport type Fn<T extends unknown[], R> = (...args: T) => R;\n\nexport const createContext = <T>() => {\n const storage = new AsyncLocalStorage<{ context: T }>();\n return {\n contextualize<R>(context: T, callback: Fn<[], R>): R {\n return storage.run({ context }, callback);\n },\n getContext() {\n const store = storage.getStore();\n if (!store) {\n throw new Error('Context not initialized');\n }\n return store.context;\n }\n };\n};\n\ntype Constructor = new (...args: any) => any;\n\nexport interface Contextualized {\n contextualize<R>(callback: Fn<[], R>): Promise<R>;\n}\n\nexport function Contextable(BaseClass: Constructor = class { }) {\n const context = createContext();\n return class Contextual extends BaseClass {\n static getContext<C extends Constructor>(this: C) {\n return context.getContext() as InstanceType<C>;\n }\n constructor(...args: unknown[]) {\n super(...args);\n }\n\n contextualize<R>(callback: Fn<[], R>): R {\n return context.contextualize(this, callback);\n }\n };\n}\n\nexport function contextualize<T extends Contextualized, K extends keyof T>(...args: unknown[]) {\n const [, , descriptor] = args as [T, K, TypedPropertyDescriptor<T[K]>];\n const property = descriptor?.value;\n if (typeof property === 'function') {\n descriptor.value = function(this: Contextualized, ...args: unknown[]) {\n return this.contextualize(() => property.apply(this, args));\n } as T[K];\n }\n}\n\n"],"names":["Contextable","contextualize","createContext","storage","AsyncLocalStorage","context","callback","run","getContext","store","getStore","Error","BaseClass","Contextual","args","descriptor","property","value","apply"],"mappings":";;;;;;;;;;;QA0BgBA;eAAAA;;QAgBAC;eAAAA;;QAtCHC;eAAAA;;;iCAJqB;AAI3B,MAAMA,gBAAgB;IAC3B,MAAMC,UAAU,IAAIC,kCAAiB;IACrC,OAAO;QACLH,eAAiBI,OAAU,EAAEC,QAAmB;YAC9C,OAAOH,QAAQI,GAAG,CAAC;gBAAEF;YAAQ,GAAGC;QAClC;QACAE;YACE,MAAMC,QAAQN,QAAQO,QAAQ;YAC9B,IAAI,CAACD,OAAO;gBACV,MAAM,IAAIE,MAAM;YAClB;YACA,OAAOF,MAAMJ,OAAO;QACtB;IACF;AACF;AAQO,SAASL,YAAYY,YAAyB;AAAQ,CAAC;IAC5D,MAAMP,UAAUH;IAChB,OAAO,MAAMW,mBAAmBD;QAC9B,OAAOJ,aAA2C;YAChD,OAAOH,QAAQG,UAAU;QAC3B;QACA,YAAY,GAAGM,IAAe,CAAE;YAC9B,KAAK,IAAIA;QACX;QAEAb,cAAiBK,QAAmB,EAAK;YACvC,OAAOD,QAAQJ,aAAa,CAAC,IAAI,EAAEK;QACrC;IACF;AACF;AAEO,SAASL,cAA2D,GAAGa,IAAe;IAC3F,MAAM,KAAKC,WAAW,GAAGD;IACzB,MAAME,WAAWD,YAAYE;IAC7B,IAAI,OAAOD,aAAa,YAAY;QAClCD,WAAWE,KAAK,GAAG,SAA+B,GAAGH,IAAe;YAClE,OAAO,IAAI,CAACb,aAAa,CAAC,IAAMe,SAASE,KAAK,CAAC,IAAI,EAAEJ;QACvD;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nexport type Fn<T extends unknown[], R> = (...args: T) => R;\n\nexport const createContext = <T>() => {\n const storage = new AsyncLocalStorage<{ context: T }>();\n return {\n contextualize<R>(context: T, callback: Fn<[], R>): R {\n return storage.run({ context }, callback);\n },\n getContext() {\n const store = storage.getStore();\n if (!store) {\n throw new Error('Context not initialized');\n }\n return store.context;\n }\n };\n};\n\ntype Constructor = new (...args: any) => any;\n\nexport interface Contextualized {\n contextualize<R>(callback: Fn<[], R>): Promise<R>;\n}\n\nexport function Contextable(BaseClass: Constructor = class { }) {\n const context = createContext();\n return class Contextual extends BaseClass {\n static getContext<C extends Constructor>(this: C) {\n return context.getContext() as InstanceType<C>;\n }\n constructor(...args: unknown[]) {\n super(...args);\n }\n\n contextualize<R>(callback: Fn<[], R>): R {\n return context.contextualize(this, callback);\n }\n };\n}\n\nexport function contextualize<T extends Contextualized, K extends keyof T>(...args: unknown[]) {\n const [, , descriptor] = args as [T, K, TypedPropertyDescriptor<T[K]>];\n const property = descriptor?.value;\n if (typeof property === 'function') {\n descriptor.value = function(this: Contextualized, ...args: unknown[]) {\n return this.contextualize(() => property.apply(this, args));\n } as T[K];\n }\n}\n\n"],"names":["AsyncLocalStorage","createContext","storage","contextualize","context","callback","run","getContext","store","getStore","Error","Contextable","BaseClass","Contextual","constructor","args","descriptor","property","value","apply"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,mBAAmB;AAIrD,OAAO,MAAMC,gBAAgB;IAC3B,MAAMC,UAAU,IAAIF;IACpB,OAAO;QACLG,eAAiBC,OAAU,EAAEC,QAAmB;YAC9C,OAAOH,QAAQI,GAAG,CAAC;gBAAEF;YAAQ,GAAGC;QAClC;QACAE;YACE,MAAMC,QAAQN,QAAQO,QAAQ;YAC9B,IAAI,CAACD,OAAO;gBACV,MAAM,IAAIE,MAAM;YAClB;YACA,OAAOF,MAAMJ,OAAO;QACtB;IACF;AACF,EAAE;AAQF,OAAO,SAASO,YAAYC,YAAyB;AAAQ,CAAC;IAC5D,MAAMR,UAAUH;IAChB,OAAO,MAAMY,mBAAmBD;QAC9B,OAAOL,aAA2C;YAChD,OAAOH,QAAQG,UAAU;QAC3B;QACAO,YAAY,GAAGC,IAAe,CAAE;YAC9B,KAAK,IAAIA;QACX;QAEAZ,cAAiBE,QAAmB,EAAK;YACvC,OAAOD,QAAQD,aAAa,CAAC,IAAI,EAAEE;QACrC;IACF;AACF;AAEA,OAAO,SAASF,cAA2D,GAAGY,IAAe;IAC3F,MAAM,KAAKC,WAAW,GAAGD;IACzB,MAAME,WAAWD,YAAYE;IAC7B,IAAI,OAAOD,aAAa,YAAY;QAClCD,WAAWE,KAAK,GAAG,SAA+B,GAAGH,IAAe;YAClE,OAAO,IAAI,CAACZ,aAAa,CAAC,IAAMc,SAASE,KAAK,CAAC,IAAI,EAAEJ;QACvD;IACF;AACF"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nexport type Fn<T extends unknown[], R> = (...args: T) => R;\n\nexport const createContext = <T>() => {\n const storage = new AsyncLocalStorage<{ context: T }>();\n return {\n contextualize<R>(context: T, callback: Fn<[], R>): R {\n return storage.run({ context }, callback);\n },\n getContext() {\n const store = storage.getStore();\n if (!store) {\n throw new Error('Context not initialized');\n }\n return store.context;\n }\n };\n};\n\ntype Constructor = new (...args: any) => any;\n\nexport interface Contextualized {\n contextualize<R>(callback: Fn<[], R>): Promise<R>;\n}\n\nexport function Contextable(BaseClass: Constructor = class { }) {\n const context = createContext();\n return class Contextual extends BaseClass {\n static getContext<C extends Constructor>(this: C) {\n return context.getContext() as InstanceType<C>;\n }\n constructor(...args: unknown[]) {\n super(...args);\n }\n\n contextualize<R>(callback: Fn<[], R>): R {\n return context.contextualize(this, callback);\n }\n };\n}\n\nexport function contextualize<T extends Contextualized, K extends keyof T>(...args: unknown[]) {\n const [, , descriptor] = args as [T, K, TypedPropertyDescriptor<T[K]>];\n const property = descriptor?.value;\n if (typeof property === 'function') {\n descriptor.value = function(this: Contextualized, ...args: unknown[]) {\n return this.contextualize(() => property.apply(this, args));\n } as T[K];\n }\n}\n\n"],"names":["AsyncLocalStorage","createContext","storage","contextualize","context","callback","run","getContext","store","getStore","Error","Contextable","BaseClass","Contextual","args","descriptor","property","value","apply"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,mBAAmB;AAIrD,OAAO,MAAMC,gBAAgB;IAC3B,MAAMC,UAAU,IAAIF;IACpB,OAAO;QACLG,eAAiBC,OAAU,EAAEC,QAAmB;YAC9C,OAAOH,QAAQI,GAAG,CAAC;gBAAEF;YAAQ,GAAGC;QAClC;QACAE;YACE,MAAMC,QAAQN,QAAQO,QAAQ;YAC9B,IAAI,CAACD,OAAO;gBACV,MAAM,IAAIE,MAAM;YAClB;YACA,OAAOF,MAAMJ,OAAO;QACtB;IACF;AACF,EAAE;AAQF,OAAO,SAASO,YAAYC,YAAyB;AAAQ,CAAC;IAC5D,MAAMR,UAAUH;IAChB,OAAO,MAAMY,mBAAmBD;QAC9B,OAAOL,aAA2C;YAChD,OAAOH,QAAQG,UAAU;QAC3B;QACA,YAAY,GAAGO,IAAe,CAAE;YAC9B,KAAK,IAAIA;QACX;QAEAX,cAAiBE,QAAmB,EAAK;YACvC,OAAOD,QAAQD,aAAa,CAAC,IAAI,EAAEE;QACrC;IACF;AACF;AAEA,OAAO,SAASF,cAA2D,GAAGW,IAAe;IAC3F,MAAM,KAAKC,WAAW,GAAGD;IACzB,MAAME,WAAWD,YAAYE;IAC7B,IAAI,OAAOD,aAAa,YAAY;QAClCD,WAAWE,KAAK,GAAG,SAA+B,GAAGH,IAAe;YAClE,OAAO,IAAI,CAACX,aAAa,CAAC,IAAMa,SAASE,KAAK,CAAC,IAAI,EAAEJ;QACvD;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conode",
3
- "version": "0.2.29",
3
+ "version": "0.2.31",
4
4
  "description": "0-Deps, simple and fast context library for NodeJS",
5
5
  "type": "module",
6
6
  "main": "build/index.cjs",
@@ -35,7 +35,7 @@
35
35
  "@swc/jest": "^0.2.39",
36
36
  "@types/jest": "^29.5.14",
37
37
  "@types/node": "^22.18.0",
38
- "inop": "^0.7.9",
38
+ "inop": "^0.7.10",
39
39
  "jest": "^29.7.0",
40
40
  "typescript": "^5.9.2"
41
41
  },