async-injection 2.0.2 → 2.0.4

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/Changelog.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 2.0.4 / 2026-01-17
2
+ * Improve recoverability of identifier used for creating injection token.
3
+ * Add .nvmrc file which is set to lts/hydrogen (affects build, not runtime).
4
+ * Updated devDependencies.
5
+
6
+ ## 2.0.3 / 2025-11-18
7
+ * Updated devDependencies (dependabot alerts about build toolchain).
8
+
1
9
  ## 2.0.2 / 2025-03-13
2
10
  * Fix failure to use `@Optional` when async object construction fails [#19](https://github.com/pcafstockf/async-injection/issues/19).
3
11
  Thanks to [@dmtaub](https://github.com/pcafstockf/async-injection/issues/19) for finding this and providing a reproducible unit test.
@@ -11,6 +11,10 @@ class InjectionToken {
11
11
  this.id = id;
12
12
  }
13
13
  toString() {
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
15
+ if (typeof this.id === 'symbol' && typeof this.id.description !== 'undefined')
16
+ // eslint-disable-next-line
17
+ return this.id.description.toString();
14
18
  return this.id.toString();
15
19
  }
16
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"injector.js","sourceRoot":"","sources":["../../src/injector.ts"],"names":[],"mappings":";;;AASA;;;GAGG;AACF,6DAA6D;AAC9D,MAAa,cAAc;IAC1B,YAAoB,EAAmB;QAAnB,OAAE,GAAF,EAAE,CAAiB;IACvC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACD;AAPD,wCAOC","sourcesContent":["/**\n * This is about as close as we can get in Typescript\n */\nexport type AbstractConstructor<T> = Function & { prototype: T }; // eslint-disable-line @typescript-eslint/ban-types\n/**\n * Standard definition of a constructor.\n */\nexport type ClassConstructor<T> = new (...args: any[]) => T;\n\n/**\n * Allow for implicit typing of constants and interfaces.\n * Inspired by Angular and some colleges at work.\n */\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport class InjectionToken<T> {\n\tconstructor(private id: string | symbol) {\n\t}\n\n\ttoString(): string {\n\t\treturn this.id.toString();\n\t}\n}\n\n/**\n * Universal id that can be bound to a constant, class, or factories.\n */\nexport type InjectableId<T> = string | symbol | AbstractConstructor<T> | ClassConstructor<T> | InjectionToken<T>;\n\n/**\n * Retrieve instances previously bound to the specified InjectableId.\n */\nexport interface Injector {\n\t/**\n\t * Check to see if the existing InjectableId is known (aka has been bound).\n\t * Error callbacks may wish to know if a particular InjectableId is available.\n\t * Also the Binder's bindXXX calls always overwrite any previous bindings, so you may want to use this as a gate.\n\t *\n\t * @param id The id to check for.\n\t * @param ascending If true, this will search up the chain of parent containers (if they exist). Default is false (only checks if the id is bound within this container).\n\t */\n\tisIdKnown<T>(id: InjectableId<T> | AbstractConstructor<T>, ascending?: boolean): boolean;\n\n\t/**\n\t * Return an instance of <T> previously bound to 'id'.\n\t *\n\t * @throws Error if the InjectableId was never registered, OR if there are unresolved asynchronous dependencies in the dependency tree for 'id'.\n\t */\n\tget<T>(id: InjectableId<T> | AbstractConstructor<T>): T;\n\n\t/**\n\t * awaits the asynchronous resolution of all dependencies in the tree for 'id'.\n\t */\n\tresolve<T>(id?: InjectableId<T> | AbstractConstructor<T>): Promise<T>;\n}\n"]}
1
+ {"version":3,"file":"injector.js","sourceRoot":"","sources":["../../src/injector.ts"],"names":[],"mappings":";;;AASA;;;GAGG;AACF,6DAA6D;AAC9D,MAAa,cAAc;IAC1B,YAAoB,EAAmB;QAAnB,OAAE,GAAF,EAAE,CAAiB;IACvC,CAAC;IAED,QAAQ;QACP,sEAAsE;QACtE,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAQ,IAAI,CAAC,EAAU,CAAC,WAAW,KAAK,WAAW;YACrF,2BAA2B;YAC3B,OAAQ,IAAI,CAAC,EAAU,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACD;AAXD,wCAWC","sourcesContent":["/**\n * This is about as close as we can get in Typescript\n */\nexport type AbstractConstructor<T> = Function & { prototype: T }; // eslint-disable-line @typescript-eslint/ban-types\n/**\n * Standard definition of a constructor.\n */\nexport type ClassConstructor<T> = new (...args: any[]) => T;\n\n/**\n * Allow for implicit typing of constants and interfaces.\n * Inspired by Angular and some colleges at work.\n */\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport class InjectionToken<T> {\n\tconstructor(private id: string | symbol) {\n\t}\n\n\ttoString(): string {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\tif (typeof this.id === 'symbol' && typeof (this.id as any).description !== 'undefined')\n\t\t\t// eslint-disable-next-line\n\t\t\treturn (this.id as any).description.toString();\n\t\treturn this.id.toString();\n\t}\n}\n\n/**\n * Universal id that can be bound to a constant, class, or factories.\n */\nexport type InjectableId<T> = string | symbol | AbstractConstructor<T> | ClassConstructor<T> | InjectionToken<T>;\n\n/**\n * Retrieve instances previously bound to the specified InjectableId.\n */\nexport interface Injector {\n\t/**\n\t * Check to see if the existing InjectableId is known (aka has been bound).\n\t * Error callbacks may wish to know if a particular InjectableId is available.\n\t * Also the Binder's bindXXX calls always overwrite any previous bindings, so you may want to use this as a gate.\n\t *\n\t * @param id The id to check for.\n\t * @param ascending If true, this will search up the chain of parent containers (if they exist). Default is false (only checks if the id is bound within this container).\n\t */\n\tisIdKnown<T>(id: InjectableId<T> | AbstractConstructor<T>, ascending?: boolean): boolean;\n\n\t/**\n\t * Return an instance of <T> previously bound to 'id'.\n\t *\n\t * @throws Error if the InjectableId was never registered, OR if there are unresolved asynchronous dependencies in the dependency tree for 'id'.\n\t */\n\tget<T>(id: InjectableId<T> | AbstractConstructor<T>): T;\n\n\t/**\n\t * awaits the asynchronous resolution of all dependencies in the tree for 'id'.\n\t */\n\tresolve<T>(id?: InjectableId<T> | AbstractConstructor<T>): Promise<T>;\n}\n"]}
@@ -8,6 +8,10 @@ export class InjectionToken {
8
8
  this.id = id;
9
9
  }
10
10
  toString() {
11
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
12
+ if (typeof this.id === 'symbol' && typeof this.id.description !== 'undefined')
13
+ // eslint-disable-next-line
14
+ return this.id.description.toString();
11
15
  return this.id.toString();
12
16
  }
13
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"injector.js","sourceRoot":"","sources":["../../src/injector.ts"],"names":[],"mappings":"AASA;;;GAGG;AACF,6DAA6D;AAC9D,MAAM,OAAO,cAAc;IAC1B,YAAoB,EAAmB;QAAnB,OAAE,GAAF,EAAE,CAAiB;IACvC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/**\n * This is about as close as we can get in Typescript\n */\nexport type AbstractConstructor<T> = Function & { prototype: T }; // eslint-disable-line @typescript-eslint/ban-types\n/**\n * Standard definition of a constructor.\n */\nexport type ClassConstructor<T> = new (...args: any[]) => T;\n\n/**\n * Allow for implicit typing of constants and interfaces.\n * Inspired by Angular and some colleges at work.\n */\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport class InjectionToken<T> {\n\tconstructor(private id: string | symbol) {\n\t}\n\n\ttoString(): string {\n\t\treturn this.id.toString();\n\t}\n}\n\n/**\n * Universal id that can be bound to a constant, class, or factories.\n */\nexport type InjectableId<T> = string | symbol | AbstractConstructor<T> | ClassConstructor<T> | InjectionToken<T>;\n\n/**\n * Retrieve instances previously bound to the specified InjectableId.\n */\nexport interface Injector {\n\t/**\n\t * Check to see if the existing InjectableId is known (aka has been bound).\n\t * Error callbacks may wish to know if a particular InjectableId is available.\n\t * Also the Binder's bindXXX calls always overwrite any previous bindings, so you may want to use this as a gate.\n\t *\n\t * @param id The id to check for.\n\t * @param ascending If true, this will search up the chain of parent containers (if they exist). Default is false (only checks if the id is bound within this container).\n\t */\n\tisIdKnown<T>(id: InjectableId<T> | AbstractConstructor<T>, ascending?: boolean): boolean;\n\n\t/**\n\t * Return an instance of <T> previously bound to 'id'.\n\t *\n\t * @throws Error if the InjectableId was never registered, OR if there are unresolved asynchronous dependencies in the dependency tree for 'id'.\n\t */\n\tget<T>(id: InjectableId<T> | AbstractConstructor<T>): T;\n\n\t/**\n\t * awaits the asynchronous resolution of all dependencies in the tree for 'id'.\n\t */\n\tresolve<T>(id?: InjectableId<T> | AbstractConstructor<T>): Promise<T>;\n}\n"]}
1
+ {"version":3,"file":"injector.js","sourceRoot":"","sources":["../../src/injector.ts"],"names":[],"mappings":"AASA;;;GAGG;AACF,6DAA6D;AAC9D,MAAM,OAAO,cAAc;IAC1B,YAAoB,EAAmB;QAAnB,OAAE,GAAF,EAAE,CAAiB;IACvC,CAAC;IAED,QAAQ;QACP,sEAAsE;QACtE,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAQ,IAAI,CAAC,EAAU,CAAC,WAAW,KAAK,WAAW;YACrF,2BAA2B;YAC3B,OAAQ,IAAI,CAAC,EAAU,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;CACD","sourcesContent":["/**\n * This is about as close as we can get in Typescript\n */\nexport type AbstractConstructor<T> = Function & { prototype: T }; // eslint-disable-line @typescript-eslint/ban-types\n/**\n * Standard definition of a constructor.\n */\nexport type ClassConstructor<T> = new (...args: any[]) => T;\n\n/**\n * Allow for implicit typing of constants and interfaces.\n * Inspired by Angular and some colleges at work.\n */\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport class InjectionToken<T> {\n\tconstructor(private id: string | symbol) {\n\t}\n\n\ttoString(): string {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\tif (typeof this.id === 'symbol' && typeof (this.id as any).description !== 'undefined')\n\t\t\t// eslint-disable-next-line\n\t\t\treturn (this.id as any).description.toString();\n\t\treturn this.id.toString();\n\t}\n}\n\n/**\n * Universal id that can be bound to a constant, class, or factories.\n */\nexport type InjectableId<T> = string | symbol | AbstractConstructor<T> | ClassConstructor<T> | InjectionToken<T>;\n\n/**\n * Retrieve instances previously bound to the specified InjectableId.\n */\nexport interface Injector {\n\t/**\n\t * Check to see if the existing InjectableId is known (aka has been bound).\n\t * Error callbacks may wish to know if a particular InjectableId is available.\n\t * Also the Binder's bindXXX calls always overwrite any previous bindings, so you may want to use this as a gate.\n\t *\n\t * @param id The id to check for.\n\t * @param ascending If true, this will search up the chain of parent containers (if they exist). Default is false (only checks if the id is bound within this container).\n\t */\n\tisIdKnown<T>(id: InjectableId<T> | AbstractConstructor<T>, ascending?: boolean): boolean;\n\n\t/**\n\t * Return an instance of <T> previously bound to 'id'.\n\t *\n\t * @throws Error if the InjectableId was never registered, OR if there are unresolved asynchronous dependencies in the dependency tree for 'id'.\n\t */\n\tget<T>(id: InjectableId<T> | AbstractConstructor<T>): T;\n\n\t/**\n\t * awaits the asynchronous resolution of all dependencies in the tree for 'id'.\n\t */\n\tresolve<T>(id?: InjectableId<T> | AbstractConstructor<T>): Promise<T>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "async-injection",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "A robust lightweight dependency injection library for TypeScript.",
5
5
  "author": "Frank Stock",
6
6
  "license": "MIT",
@@ -40,7 +40,8 @@
40
40
  ],
41
41
  "scripts": {
42
42
  "clean": "rimraf ./lib",
43
- "fullclean": "npm run clean && rimraf ./.nyc_output && rimraf ./coverage && rimraf ./package-lock.json && rimraf ./node_modules",
43
+ "reinstall": "npm run clean && rimraf ./.nyc_output && rimraf ./coverage && rimraf ./node_modules",
44
+ "fullclean": "npm run reinstall && rimraf ./package-lock.json",
44
45
  "pretest": "npm run lint",
45
46
  "test": "TS_NODE_PROJECT=./tsconfig-test.json node --require ts-node/register --require tsconfig-paths/register node_modules/jasmine/bin/jasmine.js --config=jasmine.json",
46
47
  "coverage": "rimraf coverage && rimraf ./nyc_output && nyc -e .ts -x \"**/*.spec.ts\" -x \"tst/*\" --reporter=text-summary --reporter=lcov npm run test",
@@ -57,14 +58,15 @@
57
58
  },
58
59
  "devDependencies": {
59
60
  "@istanbuljs/nyc-config-typescript": "~1.0.2",
60
- "@types/jasmine": "~5.1.7",
61
+ "@types/jasmine": "~5.1.15",
62
+ "@types/node": "^18.19.130",
61
63
  "@typescript-eslint/eslint-plugin": "~5.62.0",
62
64
  "@typescript-eslint/parser": "~5.62.0",
63
- "eslint": "~8.57.0",
64
- "eslint-plugin-import": "~2.29.1",
65
+ "eslint": "~8.57.1",
66
+ "eslint-plugin-import": "~2.32.0",
65
67
  "eslint-plugin-jsdoc": "~39.9.1",
66
68
  "eslint-plugin-prefer-arrow": "~1.2.3",
67
- "jasmine": "~5.2.0",
69
+ "jasmine": "~5.13.0",
68
70
  "jasmine-console-reporter": "~3.1.0",
69
71
  "nyc": "~15.1.0",
70
72
  "reflect-metadata": "~0.2.2",
@@ -72,9 +74,12 @@
72
74
  "source-map-support": "~0.5.21",
73
75
  "ts-node": "~10.9.2",
74
76
  "tsconfig-paths": "~4.2.0",
75
- "tslib": "~2.6.3",
77
+ "tslib": "~2.8.1",
76
78
  "typescript": "~4.9.5"
77
79
  },
80
+ "overrides": {
81
+ "diff": "^8.0.3"
82
+ },
78
83
  "nyc": {
79
84
  "extends": "@istanbuljs/nyc-config-typescript",
80
85
  "all": true,