generated from JS-DevTools/template-node-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated internal and public-facing types
- Loading branch information
1 parent
b2725ba
commit aec1d0c
Showing
5 changed files
with
39 additions
and
30 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FilterCriterion, FilterFunction, Filters } from "./types"; | ||
|
||
/** | ||
* Symbol used to store the underlying filters of a `pathFilter()` function. | ||
*/ | ||
export const _filters = Symbol("_filters"); | ||
|
||
/** | ||
* A `pathFilter()` function that was created by `filePathFilter()`. | ||
*/ | ||
export interface PathFilter extends FilterFunction { | ||
[_filters]: Filters<FilterFunction[]>; | ||
} | ||
|
||
/** | ||
* Determines whether the given value is a `FilterCriterion`. | ||
*/ | ||
export function isFilterCriterion(value: unknown): value is FilterCriterion { | ||
let type = typeof value; | ||
return type === "string" || | ||
type === "boolean" || | ||
type === "function" || | ||
value instanceof RegExp; | ||
} | ||
|
||
/** | ||
* Determines whether the given value is one of our internal `pathFilter()` functions. | ||
*/ | ||
export function isPathFilter(value: unknown): value is PathFilter { | ||
let fn = value as PathFilter; | ||
return fn && | ||
typeof fn === "function" && | ||
typeof fn[_filters] === "object"; | ||
} |