templates-mo
Version:
Templates is a scaffolding framework that makes code generation simple, dynamic, and reusable. Generate files, parts of your app, or whole project structures—without the repetitive copy-pasting
53 lines (52 loc) • 1.79 kB
TypeScript
export declare function hasProp(obj: Record<string, any>, prop: string): boolean;
/**
* Loop through a object property. Will break out of loop if `cb` returns false
* @param obj - object to loop through
* @param cb - Function to call on every property
*/
export declare function eachObj(obj: Record<string, any>, cb: (val: any, key: string) => void | boolean): void;
/**
* Check to see if `obj` matches `matcher`
* @param matcher
* @param obj - object to match against `matcher`
*/
export declare function couldMatchObj(matcher: Record<string, any>, obj: Record<string, any>): boolean;
/**
* Makes `options` inherit all properties it doesnt have from `default`
* @param options
* @param defaultObj - default properties that you want `options` to have
* @returns - options with all default properties
*/
export declare function defaults<T extends object>(options: Partial<T>, defaultObj: T): T;
export declare function cliLog(str: string): void;
/**
* Get all npm paths
*/
export declare const getNpmPaths: (cwd?: string) => string[];
/**
* Get a list of all parent directories from a directory
*
* @example
* getAllDirectoriesAndUp("/User/marcellinoornelas/Desktop/random")
* // returns
* [
* "/User/marcellinoornelas/Desktop/random",
* "/User/marcellinoornelas/Desktop",
* "/User/marcellinoornelas",
* "/User",
* "/",
* ]
*/
export declare const getAllDirectoriesAndUp: (dir: any) => string[];
/**
* Unflatten an array
*/
export declare const flatten: <T>(arr: T[][]) => T[];
export declare const unique: <T extends string | number>(array: T[]) => T[];
/**
* strip the prefix from the provided string
*
* @example
* stripPrefix("tps-app", "tps-"); // "app"
*/
export declare const stripPrefix: (str: string, prefix: string) => string;