UNPKG

@thumbmarkjs/thumbmarkjs

Version:

![GitHub package.json dynamic](https://img.shields.io/github/package-json/version/ilkkapeltola/thumbmarkjs) ![NPM Version](https://img.shields.io/npm/v/@thumbmarkjs/thumbmarkjs) ![NPM Downloads](https://img.shields.io/npm/dm/%40thumbmarkjs%2Fthumbmarkjs

28 lines (25 loc) 1.08 kB
export interface optionsInterface { exclude: string[], include: string[], webgl_runs?: number, canvas_runs?: number, permissions_to_check?: PermissionName[], // new option retries?: number, // new option timeout: number, // new option logging: boolean } export let options: optionsInterface = { exclude: [], include: [], logging: true, timeout: 1000 } export function setOption<K extends keyof optionsInterface>(key: K, value: optionsInterface[K]) { if (!['include', 'exclude', 'permissions_to_check', 'retries', 'timeout', 'logging'].includes(key)) throw new Error('Unknown option ' + key) if (['include', 'exclude', 'permissions_to_check'].includes(key) && !(Array.isArray(value) && value.every(item => typeof item === 'string')) ) throw new Error('The value of the include, exclude and permissions_to_check must be an array of strings'); if ([ 'retries', 'timeout'].includes(key) && typeof value !== 'number') throw new Error('The value of retries must be a number'); options[key] = value; }