UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

55 lines (54 loc) 2.96 kB
import type { CustomFile, FileUpload, OriginFileObj } from './types'; /** * * Checks if a given value is a valid `FormData` & it's not empty. * - **N.B.** Be cautious when using this in SSR (Server-Side Rendering) environments (such as `Next.js` Server Components), as it may not work as expected. * @param value - The value to check. * @returns `true` if the value is a valid `FormData` and not empty, otherwise `false`. */ export declare function isValidFormData(value: unknown): value is FormData; /** * * Checks if a given value is an `OriginFileObj`. * - **N.B.** Be cautious when using this in SSR (Server-Side Rendering) environments (such as `Next.js` Server Components), as it may not work as expected. * @param value - The value to check. * @returns `true` if the value is a valid `OriginFileObj`, otherwise `false`. */ export declare function isOriginFileObj(value: unknown): value is OriginFileObj; /** * * Checks if a given value is a `CustomFile`. * - **N.B.** Be cautious when using this in SSR (Server-Side Rendering) environments (such as `Next.js` Server Components), as it may not work as expected. * @param value - The value to check. * @returns `true` if the value is a valid `CustomFile`, otherwise `false`. */ export declare function isCustomFile(value: unknown): value is CustomFile; /** * * Checks if a given value is an array of `CustomFile` objects. * - **N.B.** Be cautious when using this in SSR (Server-Side Rendering) environments (such as `Next.js` Server Components), as it may not work as expected. * @param value - The value to check. * @returns `true` if the value is a valid `CustomFile[]`, otherwise `false`. */ export declare function isCustomFileArray(value: unknown): value is CustomFile[]; /** * * Checks if a given value is an array of `File/Blob` objects. * - **N.B.** Be cautious when using this in SSR (Server-Side Rendering) environments (such as `Next.js` Server Components), as it may not work as expected. * @param value - The value to check. * @returns `true` if the value is a valid `File[]` or `Blob[]`, otherwise `false`. */ export declare function isFileArray(value: unknown): value is File[] | Blob[]; /** * * Checks if a given value is an instance of `FileList`. * @param value - The value to check. * @returns `true` if the value is a valid `FileList`, otherwise `false`. */ export declare function isFileList(value: unknown): value is FileList; /** * * Checks if a given value is an instance of `File` or `Blob`. * @param value - The value to check. * @returns `true` if the value is an instance of `File` or `Blob`, otherwise `false`. */ export declare function isFileOrBlob(value: unknown): value is File | Blob; /** * * Checks if a given value is a `FileUpload` object. * @param value - The value to check. * @returns `true` if the value is a valid `FileUpload`, otherwise `false`. */ export declare function isFileUpload(value: unknown): value is FileUpload;