mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2024-12-23 14:32:35 -05:00
36 lines
858 B
JavaScript
36 lines
858 B
JavaScript
class AudioNodeMock {
|
|
constructor (params) {
|
|
Object.assign(this, params);
|
|
|
|
this.connected = null;
|
|
this.connectedFrom = [];
|
|
this._testResult = [];
|
|
}
|
|
|
|
connect (node) {
|
|
this.connected = node;
|
|
node.connectedFrom.push(this);
|
|
}
|
|
|
|
disconnect () {
|
|
if (this.connected !== null) {
|
|
this.connectedFrom = this.connectedFrom.filter(connection => connection !== this);
|
|
}
|
|
this.connected = null;
|
|
}
|
|
|
|
_test (test, message, depth = 0) {
|
|
if (this.connected === null) {
|
|
this._testResult.push({test, message, depth});
|
|
} else {
|
|
this.connected._test(test, message, depth + 1);
|
|
this._testResult.push(null);
|
|
}
|
|
}
|
|
|
|
_result () {
|
|
return this._testResult.pop();
|
|
}
|
|
}
|
|
|
|
module.exports = AudioNodeMock;
|