UNPKG

@opra/common

Version:
47 lines (46 loc) 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isStream = isStream; exports.isReadable = isReadable; exports.isWritable = isWritable; exports.isReadableStream = isReadableStream; exports.isBlob = isBlob; exports.isFormData = isFormData; exports.isURL = isURL; function isStream(x) { return x !== null && typeof x === 'object' && typeof x.pipe === 'function'; } function isReadable(x) { return (isStream(x) && typeof x._read === 'function' && typeof x._readableState === 'object'); } function isWritable(x) { return isStream(x) && typeof x._write === 'function'; } function isReadableStream(x) { return (isStream(x) && typeof x.getReader === 'function' && typeof x.pipeThrough === 'function' && typeof x.pipeTo === 'function'); } function isBlob(x) { return (x !== null && typeof x === 'object' && typeof x.size === 'number' && typeof x.arrayBuffer === 'function' && typeof x.stream === 'function'); } function isFormData(x) { return (x !== null && typeof x.constructor === 'function' && x.constructor.name === 'FormData' && typeof x.append === 'function' && typeof x.getAll === 'function'); } function isURL(x) { return (x !== null && typeof x == 'object' && typeof x.host === 'string' && typeof x.href === 'string'); }