Skip to content

Instantly share code, notes, and snippets.

@grishgrigoryan
grishgrigoryan / StreamMixer.ts
Created July 4, 2018 13:56
StreamMixer helps to play with MediaStream: Merge multiple streams into single one ( can be used with WebRtc to send multiple streams over a single WebRTC MediaConnection, or to switch streams without worrying about renegotiation)
export class StreamMixer {
streams: Array<{
id: string,
audioSource: any,
gainNode: any,
mediaStream: MediaStream
}>;
destination: any;
audioCtx: any;
@grishgrigoryan
grishgrigoryan / IterableFile.ts
Created May 4, 2018 12:55
Helper to iterate over file in browser using for-await-of loop
interface IConfig{
chunkSize:number
}
class IterableFile implements AsyncIterable<string>{
private reader : FileReader;
private file:File
private config : IConfig = {chunkSize : 64 * 1024}
constructor( file:File,config :Partial<IConfig> = {}){
this.file = file
@grishgrigoryan
grishgrigoryan / browserify
Last active June 11, 2017 20:04
Typescript compile and browserify ( tsc -w & watchify )
var spawn = require('child_process').spawn;
var compile = spawn('./node_modules/.bin/tsc',['-w']);
compile.stdout.on('data', function (data) {
console.log('stdout: ' + data.toString());
});
compile.stderr.on('data', function (data) {
console.log('stderr: ' + data.toString());
});
compile.on('exit', function (code) {
console.log('child process exited with code ' + code.toString());