@poppinss/manager
Advanced tools
Comparing version 2.1.6 to 2.1.7
@@ -0,1 +1,8 @@ | ||
/** | ||
* Shape of the extend callback | ||
*/ | ||
export declare type ExtendCallback<Driver extends any> = (container: any, mappingName: string, config: any) => Driver; | ||
/** | ||
* Manager class shape | ||
*/ | ||
export interface ManagerContract<DriverContract extends any, ReturnValueContract extends any = DriverContract, MappingsList extends { | ||
@@ -9,3 +16,3 @@ [key: string]: ReturnValueContract; | ||
use(): DefaultItem; | ||
extend(name: string, callback: (container: any) => DriverContract): void; | ||
extend(name: string, callback: ExtendCallback<DriverContract>): void; | ||
release<K extends keyof MappingsList>(name: K): void; | ||
@@ -12,0 +19,0 @@ release(name: string): void; |
@@ -1,2 +0,2 @@ | ||
import { ManagerContract } from './Contracts'; | ||
import { ManagerContract, ExtendCallback } from './Contracts'; | ||
/** | ||
@@ -14,3 +14,3 @@ * Manager class implements the Builder pattern to make instance of similar | ||
}, DefaultItem extends ReturnValueContract = ReturnValueContract> implements ManagerContract<DriverContract, ReturnValueContract, MappingsList, DefaultItem> { | ||
protected $container: any; | ||
protected container: any; | ||
/** | ||
@@ -42,3 +42,3 @@ * Mappings cache (if caching is enabled) | ||
protected abstract getMappingDriver(mappingName: string): string | undefined; | ||
constructor($container: any); | ||
constructor(container: any); | ||
/** | ||
@@ -74,3 +74,3 @@ * Returns the value saved inside cache, this method will check for | ||
*/ | ||
use<K extends keyof MappingsList>(name: K): MappingsList[K]; | ||
use<K extends keyof MappingsList & string>(name: K): MappingsList[K]; | ||
use(name: string): ReturnValueContract; | ||
@@ -81,3 +81,3 @@ use(): DefaultItem; | ||
*/ | ||
release<K extends keyof MappingsList>(name: K): void; | ||
release<K extends keyof MappingsList & string>(name: K): void; | ||
release(name: string): void; | ||
@@ -88,3 +88,3 @@ /** | ||
*/ | ||
extend(name: string, callback: (container: any, mappingName: string, config: any) => DriverContract): void; | ||
extend(name: string, callback: ExtendCallback<DriverContract>): void; | ||
} |
@@ -19,4 +19,4 @@ "use strict"; | ||
class Manager { | ||
constructor($container) { | ||
this.$container = $container; | ||
constructor(container) { | ||
this.container = container; | ||
/** | ||
@@ -51,3 +51,3 @@ * Mappings cache (if caching is enabled) | ||
makeExtendedDriver(mappingName, driver, config) { | ||
const value = this.wrapDriverResponse(mappingName, this.extendedDrivers[driver](this.$container, mappingName, config)); | ||
const value = this.wrapDriverResponse(mappingName, this.extendedDrivers[driver](this.container, mappingName, config)); | ||
this.saveToCache(mappingName, value); | ||
@@ -54,0 +54,0 @@ return value; |
{ | ||
"name": "@poppinss/manager", | ||
"version": "2.1.6", | ||
"version": "2.1.7", | ||
"description": "The builder (Manager) pattern implementation", | ||
@@ -31,5 +31,5 @@ "main": "build/index.js", | ||
"@adonisjs/mrm-preset": "^2.3.0", | ||
"@types/node": "^13.11.1", | ||
"commitizen": "^4.0.4", | ||
"cz-conventional-changelog": "^3.1.0", | ||
"@types/node": "^13.13.5", | ||
"commitizen": "^4.1.2", | ||
"cz-conventional-changelog": "^3.2.0", | ||
"del-cli": "^3.0.0", | ||
@@ -41,5 +41,5 @@ "doctoc": "^1.4.0", | ||
"japa": "^3.0.1", | ||
"mrm": "^2.2.1", | ||
"mrm": "^2.3.0", | ||
"np": "^5.2.1", | ||
"ts-node": "^8.8.2", | ||
"ts-node": "^8.10.1", | ||
"typescript": "^3.8.3" | ||
@@ -46,0 +46,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20099
254