This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>minimum-webrtc-demo</title> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compose(middlewares) { | |
return function () { | |
return dispatch(0) | |
function dispatch(i) { | |
let fn = middlewares[i] | |
if (!fn) { | |
return Promise.resolve() | |
} | |
return Promise.resolve( | |
fn(function next() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createHash } from 'crypto'; | |
/** | |
* @type {Object} HASH_POOL segment_hash -> str | |
* @type {Object} HASH_CACHE str -> full_hash | |
*/ | |
const HASH_POOL = {}; | |
const HASH_CACHE = {}; | |
const DEFAULT_LENGTH = 6; | |
const MAX_LENGTH = 32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1. deepClone | |
*/ | |
function deepClone(obj) { | |
var copy; | |
// Handle the 3 simple types, and null or undefined | |
if (null == obj || 'object' != typeof obj) return obj; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1. bytesToSize | |
* 2. getAllFiles | |
* 3. createWorker | |
*/ | |
function bytesToSize(bytes, prec = 2) { | |
if (Number.isNaN(parseInt(bytes, 10))) return bytes; | |
if (bytes < 1024) return `${parseInt(bytes, 10)} B`; |