UNPKG

filestack-js

Version:

Official JavaScript library for Filestack

77 lines (76 loc) 2.07 kB
import { Session } from '../client'; import { Hosts } from './../../config'; /** * Resolve cdn url based on handle type * * @private * @param session session object * @param handle file handle (hash, src://alias, url) */ export declare const resolveCdnUrl: (session: Session, handle: string) => string; /** * Resolve all urls with provided cnames * * @private * @param urls * @param cname */ export declare const resolveHost: (urls: Hosts, cname: string) => Hosts; /** * Removes empty options from object * * @private * @param obj */ export declare const removeEmpty: (obj: any) => any; export declare const uniqueTime: () => any; /** * Generates random string with provided length * * @param len */ export declare const uniqueId: (len?: number) => string; /** * Check if input is a svg * * @param {Uint8Array | Buffer} file * @returns {string} - mimetype */ export declare const getMimetype: (file: Uint8Array | Buffer, name?: string) => Promise<string>; /** * Change extension to according mimetype using ext=>mimetype map * * @param ext - string * @return string|boolean */ export declare const extensionToMime: (ext: string) => string; /** * Sanitizer Options */ export type SanitizeOptions = boolean | { exclude?: string[]; replacement?: string; }; /** * Sanitize file name * * @param name * @param {bool} options - enable,disable sanitizer, default enabled * @param {string} options.replacement - replacement for sanitized chars defaults to "-" * @param {string[]} options.exclude - array with excluded chars default - `['\', '{', '}','|', '%', '`', '"', "'", '~', '[', ']', '#', '|', '^', '<', '>']` */ export declare const sanitizeName: (name: string, options?: SanitizeOptions) => string; /** * Filter object to given fields * * @param toFilter * @param requiredFields */ export declare const filterObject: (toFilter: any, requiredFields: string[]) => any; /** * Deep cleanup object from functions * * @param obj */ export declare const cleanUpCallbacks: (obj: any) => any; export * from './index.node';