Group the sources into aliased modules and lint with the published plugins
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
// A missing file or a missing process: Node reports them as ENOENT and ESRCH.
|
||||
export function isNotFound(error: unknown): boolean {
|
||||
if (!(error instanceof Error) || !("code" in error)) {
|
||||
return false;
|
||||
}
|
||||
return error.code === "ENOENT" || error.code === "ESRCH";
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Helpers every phase shares: error and JSON value checks.
|
||||
export { isNotFound } from "./errors.ts";
|
||||
export { isMapping, isObject } from "./json.ts";
|
||||
export type { JsonObject } from "./json.ts";
|
||||
@@ -0,0 +1,12 @@
|
||||
// Type guards for values read from JSON, which arrive as `unknown`.
|
||||
export type JsonObject = NodeJS.Dict<unknown>;
|
||||
|
||||
// Any non-null object, arrays included: reading a missing key yields undefined.
|
||||
export function isObject(value: unknown): value is JsonObject {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
// A plain mapping, which an array is not.
|
||||
export function isMapping(value: unknown): value is JsonObject {
|
||||
return isObject(value) && !Array.isArray(value);
|
||||
}
|
||||
Reference in New Issue
Block a user