-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from SimenB/typescript-types
Typescript types
- Loading branch information
Showing
3 changed files
with
36 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* (c) 2015 Ari Porad (@ariporad) <http://ariporad.com>. License: ariporad.mit-license.org */ | ||
|
||
declare type Hook = (code: string, filename: string) => string; | ||
declare type Matcher = (code: string) => boolean; | ||
declare type RevertFunction = () => void; | ||
interface Options { | ||
/** A matcher function, will be called with path to a file. Should return truthy if the file should be hooked, falsy otherwise. */ | ||
matcher?: Matcher; | ||
/** | ||
* The extensions to hook. Should start with '.' (ex. ['.js']). | ||
* | ||
* @default ['.js'] | ||
*/ | ||
exts?: Array<string>; | ||
/** | ||
* Auto-ignore node_modules. Independent of any matcher. | ||
* | ||
* @default true | ||
*/ | ||
ignoreNodeModules?: boolean; | ||
} | ||
/** | ||
* Add a require hook. | ||
* | ||
* @param {Hook} hook - The hook. Accepts the code of the module and the filename. Required. | ||
* @param {Options} [opts] - Options | ||
* @returns {RevertFunction} revert - Reverts the hooks. | ||
*/ | ||
export declare function addHook(hook: Hook, opts?: Options): RevertFunction; | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters