Skip to content

Commit

Permalink
fix: add typings file
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 17, 2019
1 parent e01b03d commit a6f40c5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
30 changes: 30 additions & 0 deletions index.d.ts
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 {};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "pirates",
"description": "Properly hijack require",
"main": "lib/index.js",
"types": "index.d.ts",
"scripts": {
"clean": "rimraf lib",
"build": "babel src -d lib",
Expand All @@ -10,7 +11,8 @@
"prepublish": "yarn run clean && yarn run build"
},
"files": [
"lib"
"lib",
"index.d.ts"
],
"repository": {
"type": "git",
Expand Down

0 comments on commit a6f40c5

Please sign in to comment.