UNPKG

ghoststools

Version:

A collection of functions (tools) I commonly use

45 lines (40 loc) 1.47 kB
/** * Removes all the keys from a given object and returns it (doesn't mutate the given object) */ declare const removeKeys: (object: object, keys: string | string[]) => object; /** * Cast a item to a array of that item */ declare const castToArray: <T>(item: T | T[]) => T[]; interface ReadDirOptions { /** * @param {string} file the file/directory name * @param {string} path the absolute path of the file/directory */ filter?: (file: string, path: string) => boolean; } /** * Get all files within a directory recursively (includes sub directories) */ declare const readdirRecursive: (cwd: string, options?: ReadDirOptions) => string[]; /** * Takes in path(s) and flattens down to a single array of files (turning directories into paths) */ declare const flattenPaths: (input: string | string[], options?: ReadDirOptions) => string[]; /** * Normalises all paths to posix style */ declare const posixify: (path: string) => string; /** * Removes the trailing slash on a path - removes both \ and / */ declare const stripTrailingSlash: (path: string) => string; /** * This combines path.normalize and stripTrailingSlash to fully normalize a path */ declare const fullNormalize: (path: string) => string; /** * This removes the file extension from the path */ declare const stripExt: (path: string) => string; export { castToArray, flattenPaths, fullNormalize, posixify, readdirRecursive, removeKeys, stripExt, stripTrailingSlash };