Comparing version 5.0.3 to 5.1.0
@@ -1,11 +0,25 @@ | ||
declare type MacroableFn<T> = (this: T, ...args: any[]) => any; | ||
declare type MacroableMap = { | ||
[key: string]: MacroableFn<any>; | ||
}; | ||
/** | ||
* Shape of the Macro function | ||
*/ | ||
declare type MacroFn<T, Args extends any[], ReturnValue extends any> = (this: T, ...args: Args) => ReturnValue; | ||
/** | ||
* Shape of the Getter function | ||
*/ | ||
declare type GetterFn<T, ReturnValue extends any> = (this: T) => ReturnValue; | ||
/** | ||
* Returns the typed variation of the macro by inspecting the | ||
* interface declaration | ||
*/ | ||
declare type GetMacroFn<T, K> = K extends keyof T ? T[K] extends (...args: infer A) => infer B ? MacroFn<T, A, B> : MacroFn<T, any[], any> : MacroFn<T, any[], any>; | ||
/** | ||
* Returns the typed variation of the getter by inspecting the | ||
* interface declaration | ||
*/ | ||
declare type GetGetterFn<T, K> = K extends keyof T ? GetterFn<T, T[K]> : GetterFn<T, any>; | ||
/** | ||
* Shape of the macroable constructor | ||
*/ | ||
export interface MacroableConstructorContract<T extends any> { | ||
macro(name: string, callback: MacroableFn<T>): void; | ||
getter(name: string, callback: MacroableFn<T>, singleton?: boolean): void; | ||
macro<K extends string>(name: K, callback: GetMacroFn<T, K>): void; | ||
getter<K extends string>(name: K, callback: GetGetterFn<T, K>, singleton?: boolean): void; | ||
hydrate(): void; | ||
@@ -23,4 +37,8 @@ } | ||
export declare abstract class Macroable { | ||
protected static macros: MacroableMap; | ||
protected static getters: MacroableMap; | ||
protected static macros: { | ||
[key: string]: MacroFn<any, any[], any>; | ||
}; | ||
protected static getters: { | ||
[key: string]: GetterFn<any, any>; | ||
}; | ||
constructor(); | ||
@@ -40,7 +58,7 @@ /** | ||
*/ | ||
static macro<T extends any = any>(name: string, callback: MacroableFn<T>): void; | ||
static macro<T extends any>(name: string, callback: MacroFn<T, any[], any>): void; | ||
/** | ||
* Return the existing macro or null if it doesn't exists | ||
*/ | ||
static getMacro(name: string): MacroableFn<any> | undefined; | ||
static getMacro(name: string): MacroFn<any, any[], any> | undefined; | ||
/** | ||
@@ -70,7 +88,7 @@ * Returns a boolean telling if a macro exists | ||
*/ | ||
static getter<T extends any = any>(name: string, callback: MacroableFn<T>, singleton?: boolean): void; | ||
static getter<T extends any = any>(name: string, callback: GetterFn<T, any>, singleton?: boolean): void; | ||
/** | ||
* Return the existing getter or null if it doesn't exists | ||
*/ | ||
static getGetter(name: string): MacroableFn<any> | undefined; | ||
static getGetter(name: string): GetterFn<any, any> | undefined; | ||
/** | ||
@@ -77,0 +95,0 @@ * Returns a boolean telling if a getter exists |
{ | ||
"name": "macroable", | ||
"version": "5.0.3", | ||
"version": "5.1.0", | ||
"description": "A simple ES6 class that can be extended to provide macros and getters functionality", | ||
@@ -31,21 +31,20 @@ "main": "build/index.js", | ||
"devDependencies": { | ||
"@adonisjs/mrm-preset": "^2.4.0", | ||
"@adonisjs/require-ts": "^1.0.0", | ||
"@types/node": "^14.11.1", | ||
"commitizen": "^4.2.1", | ||
"@adonisjs/mrm-preset": "^3.0.0", | ||
"@adonisjs/require-ts": "^2.0.0", | ||
"@types/node": "^14.14.25", | ||
"commitizen": "^4.2.3", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"del-cli": "^3.0.1", | ||
"doctoc": "^1.4.0", | ||
"eslint": "^7.9.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-adonis": "^1.0.15", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"doctoc": "^2.0.0", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-adonis": "^1.2.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"github-label-sync": "^2.0.0", | ||
"husky": "^4.3.0", | ||
"husky": "^4.3.8", | ||
"japa": "^3.1.1", | ||
"mrm": "^2.5.0", | ||
"np": "^6.5.0", | ||
"npm-audit-html": "^1.4.3", | ||
"prettier": "^2.1.2", | ||
"typescript": "^4.0.3" | ||
"mrm": "^2.5.15", | ||
"np": "^7.3.0", | ||
"prettier": "^2.2.1", | ||
"typescript": "^4.1.3" | ||
}, | ||
@@ -77,3 +76,3 @@ "dependencies": {}, | ||
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js", | ||
"pre-commit": "npm audit --production --json | ./node_modules/.bin/npm-audit-html && git add npm-audit.html && doctoc README.md --title='## Table of contents' && git add README.md" | ||
"pre-commit": "doctoc README.md --title='## Table of contents' && git add README.md" | ||
} | ||
@@ -80,0 +79,0 @@ }, |
@@ -7,3 +7,3 @@ <div align="center"><img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px"></div> | ||
[![circleci-image]][circleci-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url] [![audit-report-image]][audit-report-url] | ||
[![circleci-image]][circleci-url] [![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url] [![synk-image]][synk-url] | ||
@@ -103,9 +103,13 @@ Base class for exposing external API to extend the class prototype in a more declarative way. | ||
[circleci-url]: https://circleci.com/gh/poppinss/macroable 'circleci' | ||
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript | ||
[typescript-url]: "typescript" | ||
[npm-image]: https://img.shields.io/npm/v/macroable.svg?style=for-the-badge&logo=npm | ||
[npm-url]: https://npmjs.org/package/macroable 'npm' | ||
[license-image]: https://img.shields.io/npm/l/macroable?color=blueviolet&style=for-the-badge | ||
[license-url]: LICENSE.md 'license' | ||
[audit-report-image]: https://img.shields.io/badge/-Audit%20Report-blueviolet?style=for-the-badge | ||
[audit-report-url]: https://htmlpreview.github.io/?https://github.com/poppinss/macroable/blob/develop/npm-audit.html 'audit-report' | ||
[synk-image]: https://img.shields.io/snyk/vulnerabilities/github/poppinss/manager?label=Synk%20Vulnerabilities&style=for-the-badge | ||
[synk-url]: https://snyk.io/test/github/poppinss/manager?targetFile=package.json "synk" |
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
13519
18
213
114