UNPKG

is-audio-buffer

Version:

Check whether an object is instance of AudioBuffer

16 lines (14 loc) 448 B
/** * @module is-audio-buffer */ 'use strict'; module.exports = function isAudioBuffer (buffer) { //the guess is duck-typing return buffer != null && typeof buffer.length === 'number' && typeof buffer.sampleRate === 'number' //swims like AudioBuffer && typeof buffer.getChannelData === 'function' //quacks like AudioBuffer // && buffer.copyToChannel // && buffer.copyFromChannel && typeof buffer.duration === 'number' };