UNPKG

@opra/common

Version:
38 lines (37 loc) 1.17 kB
export function isStream(x) { return x !== null && typeof x === 'object' && typeof x.pipe === 'function'; } export function isReadable(x) { return (isStream(x) && typeof x._read === 'function' && typeof x._readableState === 'object'); } export function isWritable(x) { return isStream(x) && typeof x._write === 'function'; } export function isReadableStream(x) { return (isStream(x) && typeof x.getReader === 'function' && typeof x.pipeThrough === 'function' && typeof x.pipeTo === 'function'); } export function isBlob(x) { return (x !== null && typeof x === 'object' && typeof x.size === 'number' && typeof x.arrayBuffer === 'function' && typeof x.stream === 'function'); } export function isFormData(x) { return (x !== null && typeof x.constructor === 'function' && x.constructor.name === 'FormData' && typeof x.append === 'function' && typeof x.getAll === 'function'); } export function isURL(x) { return (x !== null && typeof x == 'object' && typeof x.host === 'string' && typeof x.href === 'string'); }