/** * Create an assertion from `check`. * * @param {Check} [check] * Check. * @returns {Assert} * Assertion. */ export function convert(check?: Check): Assert /** * Check if `file` is a specific file. * * Converts `check` to an assertion and calls that assertion with `file`. * If you’re doing a lot of checks, use `convert`. * * @param {unknown} file * File to check (typically `VFile`). * @param {Check} [check] * Check. * @returns {boolean} * Whether `file` is a file and matches `check`. */ export function is(file: unknown, check?: Check): boolean export type VFile = import('vfile').VFile /** * Check that a file is a `vfile` and passes a test. */ export type Assert = (file?: unknown) => boolean /** * Check if a file passes a custom test. */ export type CheckFile = (file: VFile) => boolean | null | undefined | void /** * Object describing fields to values. * * Each key is a field in the file and each value is: * * * `boolean` — whether the field exists or not * * `string` — exact value of that field * * `object` — start (prefix) and/or end (suffix) of the field */ export type CheckFields = Record< string, FieldPartial | boolean | string | null | undefined > export type CheckItem = CheckFields | CheckFile | string | null | undefined /** * Different ways to check for a specific file. * * * if check is a glob string, checks if that glob matches `file.path` * * if check is a normal string, checks if that is `file.basename` or * `file.extname` * * if check is a function, checks whether that yields `true` when called * * if check is a normal object, checks if the given file matches the * `Spec` * * if check is an array, all tests in it must pass */ export type Check = Array | CheckItem /** * Check the prefix and/or suffix of a field. */ export type FieldPartial = { /** * Prefix. */ prefix?: string | null | undefined /** * Suffix. */ suffix?: string | null | undefined }