UNPKG

2 kBTypeScriptView Raw
1/**
2 * Pick the value for each `key` property from `obj` and return each one in a new object.
3 * If `names` are given, use them in the new object, instead of `keys`.
4 *
5 * If any `key` was not found or its value was `undefined`, nothing will be picked for that key.
6 *
7 * @param obj Object to pick from
8 * @param keys Keys to pick
9 * @param names Optional names to use in the output object
10 * @returns A new object containing a each `name` property and the picked value, or `undefined` if no keys were picked.
11 */
12export declare function pickValues<T>(obj: T, keys: (keyof T)[], names?: string[]): Record<string, unknown> | undefined;
13/**
14 * Components of a package reference.
15 */
16export type PackageRef = {
17 scope?: string;
18 name: string;
19};
20/**
21 * Options which control how package dependecies are located.
22 */
23export type FindPackageDependencyOptions = {
24 /**
25 * Optional starting directory for the search. Defaults to `process.cwd()`.
26 */
27 startDir?: string;
28 /**
29 * Optional flag controlling whether symlinks can be found. Defaults to `true`.
30 * When `false`, and the package dependency directory is a symlink, it will not
31 * be found.
32 */
33 allowSymlinks?: boolean;
34 /**
35 * Optional flag controlling whether to resolve symlinks. Defaults to `false`.
36 * Note that this flag has no effect if `allowSymlinks` is `false`.
37 */
38 resolveSymlinks?: boolean;
39};
40/**
41 * Find the package dependency's directory, starting from the given directory
42 * and moving outward, through all parent directories.
43 *
44 * Package dependencies exist under 'node_modules/[`scope`]/[`name`]'.
45 *
46 * @param ref Package dependency reference
47 * @param options Options which control the search
48 * @returns Path to the package dependency's directory, or `undefined` if not found.
49 */
50export declare function findPackageDependencyDir(ref: string | PackageRef, options?: FindPackageDependencyOptions): string | undefined;
51//# sourceMappingURL=findPackageDependencyDir.d.ts.map
\No newline at end of file