common-types.ts ×4

Frontier kind: Code frontier

unlabeled · c_243e86c7861b

789 tests · 134 LOC · 2 files · introduces 0 tests · 134 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges134 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5 ranges134 lines · 2 files · Browse complete extent
All tests (intent)
789 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 134 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

lib/typings/common-types.ts 131 introduced LOC · 4 ranges

Open complete file

1 > import {Parser} from './yargs-parser-types.js'; common-types.ts
2 >
3 > /**
4 > * A type that represents undefined or null
5 > */
6 > export type nil = undefined | null;
7 >
8 > /**
9 > * An object whose all properties have the same type.
10 > */
11 > export type Dictionary<T = any> = {[key: string]: T};
12 >
13 > /**
14 > * Returns the keys of T that match Dictionary<U> and are not arrays.
15 > */
16 > export type DictionaryKeyof<T, U = any> = Exclude<
17 > KeyOf<T, Dictionary<U>>,
18 > KeyOf<T, any[]>
19 > >;
20 >
21 > /**
22 > * Returns the keys of T that match U.
23 > */
24 > export type KeyOf<T, U> = Exclude<
25 > {[K in keyof T]: T[K] extends U ? K : never}[keyof T],
26 > undefined
27 > >;
28 >
29 > /**
30 > * An array whose first element is not undefined.
31 > */
32 > export type NotEmptyArray<T = any> = [T, ...T[]];
33 >
34 > /**
35 > * Returns the type of a Dictionary or array values.
36 > */
37 > export type ValueOf<T> = T extends (infer U)[] ? U : T[keyof T];
38 >
39 > /**
40 > * Typing wrapper around assert.notStrictEqual()
41 > */
42 > export function assertNotStrictEqual<N, T>(
43 actual: T | N,
44 expected: N,
48 shim.assert.notStrictEqual(actual, expected, message);
49 }
51 > /**
52 > * Asserts actual is a single key, not a key array or a key map.
53 > */
54 > export function assertSingleKey(
55 actual: string | string[] | Dictionary,
56 shim: PlatformShim
58 shim.assert.strictEqual(typeof actual, 'string');
59 }
61 > /**
62 > * Typing wrapper around Object.keys()
63 > */
64 > export function objectKeys<T extends {}>(object: T) {
65 return Object.keys(object) as (keyof T)[];
66 }
68 > export interface RequireDirectoryOptions {
69 > extensions?: ReadonlyArray<string>;
70 > visit?: (commandObject: any, pathToFile: string, filename?: string) => any;
71 > recurse?: boolean;
72 > include?: RegExp | ((fileName: string) => boolean);
73 > exclude?: RegExp | ((fileName: string) => boolean);
74 > }
75 >
76 > // Dependencies that might vary between CJS, ESM, and Deno are isolated:
77 > export interface PlatformShim {
78 > assert: {
79 > notStrictEqual: (
80 > expected: any,
81 > observed: any,
82 > message?: string | Error
83 > ) => void;
84 > strictEqual: (
85 > expected: any,
86 > observed: any,
87 > message?: string | Error
88 > ) => void;
89 > };
90 > findUp: (
91 > startDir: string,
92 > fn: (dir: string[], names: string[]) => string | undefined
93 > ) => string;
94 > getCallerFile: () => string;
95 > getEnv: (key: string) => string | undefined;
96 > getProcessArgvBin: () => string;
97 > inspect: (obj: object) => string;
98 > mainFilename: string;
99 > requireDirectory: Function;
100 > stringWidth: (str: string) => number;
101 > cliui: Function;
102 > Parser: Parser;
103 > path: {
104 > basename: (p1: string, p2?: string) => string;
105 > extname: (path: string) => string;
106 > dirname: (path: string) => string;
107 > relative: (p1: string, p2: string) => string;
108 > resolve: (p1: string, p2: string) => string;
109 > join: (p1: string, p2: string) => string;
110 > };
111 > process: {
112 > argv: () => string[];
113 > cwd: () => string;
114 > emitWarning: (warning: string | Error, type?: string) => void;
115 > execPath: () => string;
116 > exit: (code: number) => void;
117 > nextTick: (cb: Function) => void;
118 > stdColumns: number | null;
119 > };
120 > readFileSync: (path: string, encoding: string) => string;
121 > readdirSync: (
122 > path: string,
123 > opts: object
124 > ) => Array<string | Buffer<ArrayBufferLike>>[];
125 > require: RequireType;
126 > y18n: Y18N;
127 > }
128 >
129 > export interface RequireType {
130 > (path: string): Function;
131 > main: MainType;
132 > }
133 >
134 > export interface MainType {
135 > filename: string;
136 > children: MainType[];
137 > }
138 >
139 > export interface Y18N {
140 > __(str: string, ...args: string[]): string;
141 > __n(str: string, ...args: (string | number)[]): string;
142 > getLocale(): string;
143 > setLocale(locale: string): void;
144 > updateLocale(obj: {[key: string]: string}): void;
145 > }
lib/utils/obj-filter.ts 3 introduced LOC · 1 range

Open complete file

1 > import {objectKeys} from '../typings/common-types.js'; obj-filter.ts
2 >
3 > export function objFilter<T extends object>(
4 original = {} as T,
5 filter: (k: keyof T, v: T[keyof T]) => boolean = () => true