code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
evaluate(expression, scope) { return new Promise((resolve, reject) => { if (!expression) return reject(new Error('Expression - eval() - expression is required')); let astTokens = esprima.tokenize(expression); let startTime = process.hrtime(); _eval(expression, scope) .then(result ...
evaluate a JS expression @param {String} expression @param {Object} [scope] - a customized scope that the expression will be evaluated in @returns Promise
evaluate
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
getMongoCollectionName(expression) { if (!expression) return null; let errors = this.validate(expression); if (errors && errors.length) return null; let astTokens = esprima.tokenize(expression); return _getMongoCollectionName(expression, astTokens); }
evaluate a JS expression @param {String} expression @param {Object} [scope] - a customized scope that the expression will be evaluated in @returns Promise
getMongoCollectionName
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
getMongoMethodName(expression) { if (!expression) return null; let errors = this.validate(expression); if (errors && errors.length) return null; let astTokens = esprima.tokenize(expression); return _getMongoMethodName(astTokens); }
evaluate a JS expression @param {String} expression @param {Object} [scope] - a customized scope that the expression will be evaluated in @returns Promise
getMongoMethodName
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
validate(expression) { let syntax; try { syntax = esprima.parse(expression, { tolerant: true, loc: true }); } catch (e) { return null; } return syntax.errors; }
evaluate a JS expression @param {String} expression @param {Object} [scope] - a customized scope that the expression will be evaluated in @returns Promise
validate
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
function _getMongoCollectionName(expression, astTokens) { if (!astTokens || astTokens.length < 3) return null; if (astTokens[0].value !== 'db') return null; let bracketNotation = mongoUtils.isBracketNotation(expression); let value = astTokens[2].value; if (bracketNotation) value = _getStringValue(value); ...
evaluate a JS expression @param {String} expression @param {Object} [scope] - a customized scope that the expression will be evaluated in @returns Promise
_getMongoCollectionName
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
function _getMongoMethodName(astTokens) { if (!astTokens || astTokens.length < 4) return null; if (astTokens[0].value !== 'db') return null; let bracketNotation = astTokens[3].value === '['; let value = astTokens[4].value; if (bracketNotation) value = _getStringValue(value); return value; }
evaluate a JS expression @param {String} expression @param {Object} [scope] - a customized scope that the expression will be evaluated in @returns Promise
_getMongoMethodName
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
function _getTime(startTime) { let endTime = process.hrtime(startTime); return endTime[0], endTime[1] / 1000000; }
evaluate a JS expression @param {String} expression @param {Object} [scope] - a customized scope that the expression will be evaluated in @returns Promise
_getTime
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
function _eval(expression, scope) { return new Promise((resolve, reject) => { if (!expression) return reject(new Error('evaluator - eval() - must pass an expression')); if (!_.isString(expression)) return reject(new Error('evaluator - eval() - expression must be a string')); var evalScope = { Objec...
@private @param {String} expression @param {Object} scope
_eval
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
function _getConsole() { let customConsole = { log: function() { return arguments; }, debug: function() { return arguments; }, info: function() { return arguments; }, warn: function() { return arguments; }, error: function() { return arguments; } ...
@private @param {String} expression @param {Object} scope
_getConsole
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
function _getStringValue(str) { let matches = str.match(/(?:\\?\"|\\?\')(.*?)(?:\\?\"|\\?\')/); return matches && matches.length >= 2 ? matches[1] : null; }
@private @param {String} expression @param {Object} scope
_getStringValue
javascript
officert/mongotron
src/lib/modules/expression/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/expression/index.js
MIT
function parseKeybindingsFileData(data) { return new Promise((resolve, reject) => { if (!data || !_.isArray(data)) return reject(new Error('keybindings - list() - error parsing keybindings file data')); //TODO: should we group these by context name to avoid duplicates?? var commands = []; _.each(da...
@function parseKeybindingsFileData @private @param {Object} data - raw contexts from keybindings file
parseKeybindingsFileData
javascript
officert/mongotron
src/lib/modules/keybindings/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/keybindings/index.js
MIT
changeActive(themeName) { var _this = this; var newActiveTheme; if (!themeName) return Promise.reject(new Error('theme - changeActive() - themeName is required')); return _this.list() .then((themes) => { return new Promise((resolve, reject) => { newActiveTheme = _.findWhere(the...
Change active theme @param {string} themeName - Name of the theme to change to
changeActive
javascript
officert/mongotron
src/lib/modules/themes/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/themes/index.js
MIT
function readThemesFile() { return fileUtils.readJsonFile(appConfig.themesPath); }
Change active theme @param {string} themeName - Name of the theme to change to
readThemesFile
javascript
officert/mongotron
src/lib/modules/themes/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/themes/index.js
MIT
function writeThemesFile(fileData) { return fileUtils.writeJsonFile(appConfig.themesPath, fileData); }
Change active theme @param {string} themeName - Name of the theme to change to
writeThemesFile
javascript
officert/mongotron
src/lib/modules/themes/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/themes/index.js
MIT
function parseThemesFileData(data) { return new Promise((resolve, reject) => { if (!data || !_.isArray(data)) return reject(new Error('themes - list() - error parsing themes file data')); return resolve(data); }); }
@function parseThemesFileData @private @param {Object} data - raw contexts from themes file
parseThemesFileData
javascript
officert/mongotron
src/lib/modules/themes/index.js
https://github.com/officert/mongotron/blob/master/src/lib/modules/themes/index.js
MIT
get(key) { if (!key) throw new Error('localStorageService - get() - key is required'); let json; try { var val = $window.localStorage.getItem(key); if (val) json = JSON.parse(val); } catch (e) {} if (!json) json = CACHE[key]; return json; }
@desc get a value by key @param {String} key @return {String}
get
javascript
officert/mongotron
src/ui/services/localStorageService.js
https://github.com/officert/mongotron/blob/master/src/ui/services/localStorageService.js
MIT
set(key, value) { if (!key) throw new Error('localStorageService - set() - key is required'); if (!value) throw new Error('localStorageService - set() - value is required'); if (value) { try { var val = JSON.stringify(value); $window.localStorage.setItem(key, v...
@desc set a value by key @param {String} key @param {Object} obj @return null
set
javascript
officert/mongotron
src/ui/services/localStorageService.js
https://github.com/officert/mongotron/blob/master/src/ui/services/localStorageService.js
MIT
remove(key) { if (!key) throw new Error('localStorageService - remove() - key is required'); try { $window.localStorage.removeItem(key); } catch (e) { delete CACHE[key]; } return null; }
@desc remove a value by key @param {String} key @return null
remove
javascript
officert/mongotron
src/ui/services/localStorageService.js
https://github.com/officert/mongotron/blob/master/src/ui/services/localStorageService.js
MIT
exists(key) { if (!key) throw new Error('localStorageService - exists() - key is required'); var exists = null; try { exists = this.get(key) !== null && this.get(key) !== undefined; } catch (e) { exists = CACHE[key] ? true : false; } return exists; ...
@desc check if a value exists by key @param {String} key @return {Boolean}
exists
javascript
officert/mongotron
src/ui/services/localStorageService.js
https://github.com/officert/mongotron/blob/master/src/ui/services/localStorageService.js
MIT
compareMongoObjectIds(expected, result) { var expectedString = expected.toString(); var resultString = result.toString(); if (result instanceof mongodb.ObjectId !== true) return false; if (expectedString !== resultString) return false; return true; }
Tests that the resulting objectId is an instance of mongodb.ObjectId and tests that it matches the toString value of the expected ObjectId @param {ObjectId} expected The ObjectId that's expected @param {ObjectId} result The ObjectId that's returned @return {[type]} [description]
compareMongoObjectIds
javascript
officert/mongotron
tests/utils/testUtils.js
https://github.com/officert/mongotron/blob/master/tests/utils/testUtils.js
MIT
function extractVersion(uastring, expr, pos) { var match = uastring.match(expr); return match && match.length >= pos && parseInt(match[pos], 10); }
Extract browser version out of the provided user agent string. @param {!string} uastring userAgent string. @param {!string} expr Regular expression used as match criteria. @param {!number} pos position in the version string to be returned. @return {!number} browser version.
extractVersion
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/desktopCapture-p2p/background/helpers/adapter.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/desktopCapture-p2p/background/helpers/adapter.js
MIT
function wrapPeerConnectionEvent(window, eventNameToWrap, wrapper) { if (!window.RTCPeerConnection) { return; } var proto = window.RTCPeerConnection.prototype; var nativeAddEventListener = proto.addEventListener; proto.a...
Extract browser version out of the provided user agent string. @param {!string} uastring userAgent string. @param {!string} expr Regular expression used as match criteria. @param {!number} pos position in the version string to be returned. @return {!number} browser version.
wrapPeerConnectionEvent
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/desktopCapture-p2p/background/helpers/adapter.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/desktopCapture-p2p/background/helpers/adapter.js
MIT
function lookup(uri, opts) { if ((typeof uri === 'undefined' ? 'undefined' : _typeof(uri)) === 'object') { opts = uri; uri = undefined; } opts = opts || {}; var parsed = url(uri); var source = parsed.source; var id = parsed.id; var path = parsed.path; var sameNamespace = cache[id] &&...
Looks up an existing `Manager` for multiplexing. If the user summons: `io('http://localhost/a');` `io('http://localhost/b');` We reuse the existing instance based on same scheme/port/host, and we initialize sockets for each namespace. @api public
lookup
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeQueryString(obj) { var str = []; for (var p in obj) { if (obj.hasOwnProperty(p)) { str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p])); } } return str.join('&'); }
Helper method to parse query objects to string. @param {object} query @returns {string}
encodeQueryString
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function url(uri, loc) { var obj = uri; // default to window.location loc = loc || global.location; if (null == uri) uri = loc.protocol + '//' + loc.host; // relative path support if ('string' === typeof uri) { if ('/' === uri.charAt(0)) { if ('/' === uri.charAt(1)) { uri = loc....
URL parser. @param {String} url @param {Object} An object meant to mimic window.location. Defaults to window.location. @api public
url
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function useColors() { // is webkit? http://stackoverflow.com/a/16459606/376773 return ('WebkitAppearance' in document.documentElement.style) || // is firebug? http://stackoverflow.com/a/398120/376773 (window.console && (console.firebug || (console.exception && console.table))) || // is firefox >= ...
Currently only WebKit-based Web Inspectors, Firefox >= v31, and the Firebug extension (any Firefox version) are known to support "%c" CSS customizations. TODO: add a `localStorage` variable to explicitly enable/disable colors
useColors
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function formatArgs() { var args = arguments; var useColors = this.useColors; args[0] = (useColors ? '%c' : '') + this.namespace + (useColors ? ' %c' : ' ') + args[0] + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff); if (!useColors) return args; var c = 'color: ...
Colorize log arguments if enabled. @api public
formatArgs
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function log() { // this hackery is required for IE8/9, where // the `console.log` function doesn't have 'apply' return 'object' === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments); }
Invokes `console.log()` when available. No-op when `console.log` is not a "function". @api public
log
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function save(namespaces) { try { if (null == namespaces) { exports.storage.removeItem('debug'); } else { exports.storage.debug = namespaces; } } catch(e) {} }
Save `namespaces`. @param {String} namespaces @api private
save
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function load() { var r; try { r = exports.storage.debug; } catch(e) {} return r; }
Load `namespaces`. @return {String} returns the previously persisted debug modes @api private
load
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function localstorage(){ try { return window.localStorage; } catch (e) {} }
Localstorage attempts to return the localstorage. This is necessary because safari throws when a user disables cookies/localstorage and you attempt to access it. @return {LocalStorage} @api private
localstorage
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function selectColor() { return exports.colors[prevColor++ % exports.colors.length]; }
Select a color. @return {Number} @api private
selectColor
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function debug(namespace) { // define the `disabled` version function disabled() { } disabled.enabled = false; // define the `enabled` version function enabled() { var self = enabled; // set `diff` timestamp var curr = +new Date(); var ms = curr - (prevTime || curr); self....
Create a debugger with the given `namespace`. @param {String} namespace @return {Function} @api public
debug
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function enabled() { var self = enabled; // set `diff` timestamp var curr = +new Date(); var ms = curr - (prevTime || curr); self.diff = ms; self.prev = prevTime; self.curr = curr; prevTime = curr; // add the `color` if not set if (null == self.useColors) self.useCol...
Create a debugger with the given `namespace`. @param {String} namespace @return {Function} @api public
enabled
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function enable(namespaces) { exports.save(namespaces); var split = (namespaces || '').split(/[\s,]+/); var len = split.length; for (var i = 0; i < len; i++) { if (!split[i]) continue; // ignore empty strings namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { e...
Enables a debug mode by namespaces. This can include modes separated by a colon and wildcards. @param {String} namespaces @api public
enable
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function enabled(name) { var i, len; for (i = 0, len = exports.skips.length; i < len; i++) { if (exports.skips[i].test(name)) { return false; } } for (i = 0, len = exports.names.length; i < len; i++) { if (exports.names[i].test(name)) { return true; } } return false; ...
Returns true if the given mode name is enabled, false otherwise. @param {String} name @return {Boolean} @api public
enabled
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function coerce(val) { if (val instanceof Error) return val.stack || val.message; return val; }
Coerce `val`. @param {Mixed} val @return {Mixed} @api private
coerce
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function parse(str) { str = '' + str; if (str.length > 10000) return; var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); if (!match) return; var n = parseFloat(match[1]); var type = (match[2] || 'ms').toLowerCa...
Parse the given `str` and return milliseconds. @param {String} str @return {Number} @api private
parse
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function short(ms) { if (ms >= d) return Math.round(ms / d) + 'd'; if (ms >= h) return Math.round(ms / h) + 'h'; if (ms >= m) return Math.round(ms / m) + 'm'; if (ms >= s) return Math.round(ms / s) + 's'; return ms + 'ms'; }
Short format for `ms`. @param {Number} ms @return {String} @api private
short
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function long(ms) { return plural(ms, d, 'day') || plural(ms, h, 'hour') || plural(ms, m, 'minute') || plural(ms, s, 'second') || ms + ' ms'; }
Long format for `ms`. @param {Number} ms @return {String} @api private
long
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeAsString(obj) { var str = ''; var nsp = false; // first is type str += obj.type; // attachments if we have them if (exports.BINARY_EVENT == obj.type || exports.BINARY_ACK == obj.type) { str += obj.attachments; str += '-'; } // if we have a namespace other than `/` ...
Encode packet as string. @param {Object} packet @return {String} encoded @api private
encodeAsString
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeAsBinary(obj, callback) { function writeEncoding(bloblessData) { var deconstruction = binary.deconstructPacket(bloblessData); var pack = encodeAsString(deconstruction.packet); var buffers = deconstruction.buffers; buffers.unshift(pack); // add packet info to beginning of data lis...
Encode packet as 'buffer sequence' by removing blobs, and deconstructing packet into object with placeholders and a list of buffers. @param {Object} packet @return {Buffer} encoded @api private
encodeAsBinary
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function writeEncoding(bloblessData) { var deconstruction = binary.deconstructPacket(bloblessData); var pack = encodeAsString(deconstruction.packet); var buffers = deconstruction.buffers; buffers.unshift(pack); // add packet info to beginning of data list callback(buffers); // write all the bu...
Encode packet as 'buffer sequence' by removing blobs, and deconstructing packet into object with placeholders and a list of buffers. @param {Object} packet @return {Buffer} encoded @api private
writeEncoding
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function Decoder() { this.reconstructor = null; }
A socket.io Decoder instance @return {Object} decoder @api public
Decoder
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function decodeString(str) { var p = {}; var i = 0; // look up type p.type = Number(str.charAt(0)); if (null == exports.types[p.type]) return error(); // look up attachments if type binary if (exports.BINARY_EVENT == p.type || exports.BINARY_ACK == p.type) { var buf = ''; while (str.cha...
Decode a packet String (JSON data) @param {String} str @return {Object} packet @api private
decodeString
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function BinaryReconstructor(packet) { this.reconPack = packet; this.buffers = []; }
A manager of a binary event's 'buffer sequence'. Should be constructed whenever a packet of type BINARY_EVENT is decoded. @param {Object} packet @return {BinaryReconstructor} initialized reconstructor @api private
BinaryReconstructor
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function error(data){ return { type: exports.ERROR, data: 'parser error' }; }
Cleans up binary packet reconstruction variables. @api private
error
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function _deconstructPacket(data) { if (!data) return data; if (isBuf(data)) { var placeholder = { _placeholder: true, num: buffers.length }; buffers.push(data); return placeholder; } else if (isArray(data)) { var newData = new Array(data.length); for (var i = 0; i < d...
Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder. Anything with blobs or files should be fed through removeBlobs before coming here. @param {Object} packet - socket.io event packet @return {Object} with deconstructed packet and list of buffers @api public
_deconstructPacket
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function _reconstructPacket(data) { if (data && data._placeholder) { var buf = buffers[data.num]; // appropriate buffer (should be natural order anyway) return buf; } else if (isArray(data)) { for (var i = 0; i < data.length; i++) { data[i] = _reconstructPacket(data[i]); }...
Reconstructs a binary packet from its placeholder packet and buffers @param {Object} packet - event packet with placeholders @param {Array} buffers - binary buffers to put in placeholder positions @return {Object} reconstructed packet @api public
_reconstructPacket
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function _removeBlobs(obj, curKey, containingObject) { if (!obj) return obj; // convert any blob if ((global.Blob && obj instanceof Blob) || (global.File && obj instanceof File)) { pendingBlobs++; // async filereader var fileReader = new FileReader(); fileReader.onl...
Asynchronously removes Blobs or Files from data via FileReader's readAsArrayBuffer method. Used before encoding data as msgpack. Calls callback with the blobless data. @param {Object} data @param {Function} callback @api private
_removeBlobs
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function isBuf(obj) { return (global.Buffer && global.Buffer.isBuffer(obj)) || (global.ArrayBuffer && obj instanceof ArrayBuffer); }
Returns true if obj is a buffer or an arraybuffer. @api private
isBuf
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function Manager(uri, opts) { if (!(this instanceof Manager)) return new Manager(uri, opts); if (uri && 'object' === (typeof uri === 'undefined' ? 'undefined' : _typeof(uri))) { opts = uri; uri = undefined; } opts = opts || {}; opts.path = opts.path || '/socket.io'; this.nsps = {}; this....
`Manager` constructor. @param {String} engine instance or engine uri/opts @param {Object} options @api public
Manager
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function onConnecting() { if (!~indexOf(self.connecting, socket)) { self.connecting.push(socket); } }
Creates a new socket for the given `nsp`. @return {Socket} @api public
onConnecting
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function Socket (uri, opts) { if (!(this instanceof Socket)) return new Socket(uri, opts); opts = opts || {}; if (uri && 'object' === typeof uri) { opts = uri; uri = null; } if (uri) { uri = parseuri(uri); opts.hostname = uri.host; opts.secure = uri.protocol === 'https' || uri...
Socket constructor. @param {String|Object} uri or options @param {Object} options @api public
Socket
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function clone (obj) { var o = {}; for (var i in obj) { if (obj.hasOwnProperty(i)) { o[i] = obj[i]; } } return o; }
Creates transport of the given type. @param {String} transport name @return {Transport} @api private
clone
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function onTransportOpen () { if (self.onlyBinaryUpgrades) { var upgradeLosesBinary = !this.supportsBinary && self.transport.supportsBinary; failed = failed || upgradeLosesBinary; } if (failed) return; debug('probe transport "%s" opened', name); transport.send([{ type: 'ping', da...
Probes a transport. @param {String} transport name @api private
onTransportOpen
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function freezeTransport () { if (failed) return; // Any callback called by transport should be ignored since now failed = true; cleanup(); transport.close(); transport = null; }
Probes a transport. @param {String} transport name @api private
freezeTransport
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function onerror (err) { var error = new Error('probe error: ' + err); error.transport = transport.name; freezeTransport(); debug('probe transport "%s" failed because of error: %s', name, err); self.emit('upgradeError', error); }
Probes a transport. @param {String} transport name @api private
onerror
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function onTransportClose () { onerror('transport closed'); }
Probes a transport. @param {String} transport name @api private
onTransportClose
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function onclose () { onerror('socket closed'); }
Probes a transport. @param {String} transport name @api private
onclose
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function onupgrade (to) { if (transport && to.name !== transport.name) { debug('"%s" works - aborting "%s"', to.name, transport.name); freezeTransport(); } }
Probes a transport. @param {String} transport name @api private
onupgrade
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function cleanup () { transport.removeListener('open', onTransportOpen); transport.removeListener('error', onerror); transport.removeListener('close', onTransportClose); self.removeListener('close', onclose); self.removeListener('upgrading', onupgrade); }
Probes a transport. @param {String} transport name @api private
cleanup
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function polling (opts) { var xhr; var xd = false; var xs = false; var jsonp = false !== opts.jsonp; if (global.location) { var isSSL = 'https:' === location.protocol; var port = location.port; // some user agents have empty `location.port` if (!port) { port = isSSL ? 443 : 8...
Polling transport polymorphic constructor. Decides on xhr vs jsonp based on feature detection. @api private
polling
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function XHR (opts) { Polling.call(this, opts); if (global.location) { var isSSL = 'https:' === location.protocol; var port = location.port; // some user agents have empty `location.port` if (!port) { port = isSSL ? 443 : 80; } this.xd = opts.hostname !== global.location.ho...
XHR Polling constructor. @param {Object} opts @api public
XHR
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function Request (opts) { this.method = opts.method || 'GET'; this.uri = opts.uri; this.xd = !!opts.xd; this.xs = !!opts.xs; this.async = false !== opts.async; this.data = undefined !== opts.data ? opts.data : null; this.agent = opts.agent; this.isBinary = opts.isBinary; this.supportsBinary =...
Request constructor @param {Object} options @api public
Request
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function Polling (opts) { var forceBase64 = (opts && opts.forceBase64); if (!hasXHR2 || forceBase64) { this.supportsBinary = false; } Transport.call(this, opts); }
Polling interface. @param {Object} opts @api private
Polling
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function pause () { debug('paused'); self.readyState = 'paused'; onPause(); }
Pauses polling. @param {Function} callback upon buffers are flushed and transport is paused @api private
pause
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
callback = function (packet, index, total) { // if its the first message we consider the transport open if ('opening' === self.readyState) { self.onOpen(); } // if its a close packet, we close the ongoing requests if ('close' === packet.type) { self.onClose(); return false...
Overloads onData to detect payloads. @api private
callback
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function close () { debug('writing close packet'); self.write([{ type: 'close' }]); }
For polling, send a close packet. @api private
close
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
callbackfn = function () { self.writable = true; self.emit('drain'); }
Writes a packets payload. @param {Array} data packets @param {Function} drain callback @api private
callbackfn
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function Transport (opts) { this.path = opts.path; this.hostname = opts.hostname; this.port = opts.port; this.secure = opts.secure; this.query = opts.query; this.timestampParam = opts.timestampParam; this.timestampRequests = opts.timestampRequests; this.readyState = ''; this.agent = opts.agen...
Transport abstract constructor. @param {Object} options. @api private
Transport
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeBase64Object(packet, callback) { // packet data is an object { base64: true, data: dataAsBase64String } var message = 'b' + exports.packets[packet.type] + packet.data.data; return callback(message); }
Encodes a packet. <packet type id> [ <data> ] Example: 5hello world 3 4 Binary is encoded in an identical principle @api private
encodeBase64Object
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeArrayBuffer(packet, supportsBinary, callback) { if (!supportsBinary) { return exports.encodeBase64Packet(packet, callback); } var data = packet.data; var contentArray = new Uint8Array(data); var resultBuffer = new Uint8Array(1 + data.byteLength); resultBuffer[0] = packets[packet....
Encode packet helpers for binary types
encodeArrayBuffer
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeBlobAsArrayBuffer(packet, supportsBinary, callback) { if (!supportsBinary) { return exports.encodeBase64Packet(packet, callback); } var fr = new FileReader(); fr.onload = function() { packet.data = fr.result; exports.encodePacket(packet, supportsBinary, true, callback); }; ...
Encode packet helpers for binary types
encodeBlobAsArrayBuffer
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeBlob(packet, supportsBinary, callback) { if (!supportsBinary) { return exports.encodeBase64Packet(packet, callback); } if (dontSendBlobs) { return encodeBlobAsArrayBuffer(packet, supportsBinary, callback); } var length = new Uint8Array(1); length[0] = packets[packet.type]; ...
Encode packet helpers for binary types
encodeBlob
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function tryDecode(data) { try { data = utf8.decode(data); } catch (e) { return false; } return data; }
Decodes a packet. Changes format to Blob if requested. @return {Object} with `type` and `data` (if any) @api private
tryDecode
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function setLengthHeader(message) { return message.length + ':' + message; }
Encodes multiple messages (payload). <length>:data Example: 11:hello world2:hi If any contents are binary, they will be encoded as base64 strings. Base64 encoded strings are marked with a b before the length specifier @param {Array} packets @api private
setLengthHeader
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeOne(packet, doneCallback) { exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) { doneCallback(null, setLengthHeader(message)); }); }
Encodes multiple messages (payload). <length>:data Example: 11:hello world2:hi If any contents are binary, they will be encoded as base64 strings. Base64 encoded strings are marked with a b before the length specifier @param {Array} packets @api private
encodeOne
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encodeOne(packet, doneCallback) { exports.encodePacket(packet, true, true, function(data) { return doneCallback(null, data); }); }
Encodes multiple messages (payload) as binary. <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number 255><data> Example: 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers @param {Array} packets @return {ArrayBuffer} encoded payload @api private
encodeOne
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function hasBinary(data) { function _hasBinary(obj) { if (!obj) return false; if ( (global.Buffer && global.Buffer.isBuffer(obj)) || (global.ArrayBuffer && obj instanceof ArrayBuffer) || (global.Blob && obj instanceof Blob) || (global.File && obj instanceof File) ) ...
Checks for binary data. Right now only Buffer and ArrayBuffer are supported.. @param {Object} anything @api public
hasBinary
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function _hasBinary(obj) { if (!obj) return false; if ( (global.Buffer && global.Buffer.isBuffer(obj)) || (global.ArrayBuffer && obj instanceof ArrayBuffer) || (global.Blob && obj instanceof Blob) || (global.File && obj instanceof File) ) { return true; } ...
Checks for binary data. Right now only Buffer and ArrayBuffer are supported.. @param {Object} anything @api public
_hasBinary
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function mapArrayBufferViews(ary) { for (var i = 0; i < ary.length; i++) { var chunk = ary[i]; if (chunk.buffer instanceof ArrayBuffer) { var buf = chunk.buffer; // if this is a subarray, make a copy so we only // include the subarray region from the underlying buffer if (chunk...
Helper function that maps ArrayBufferViews to ArrayBuffers Used by BlobBuilder constructor and old browsers that didn't support it in the Blob constructor.
mapArrayBufferViews
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function BlobBuilderConstructor(ary, options) { options = options || {}; var bb = new BlobBuilder(); mapArrayBufferViews(ary); for (var i = 0; i < ary.length; i++) { bb.append(ary[i]); } return (options.type) ? bb.getBlob(options.type) : bb.getBlob(); }
Helper function that maps ArrayBufferViews to ArrayBuffers Used by BlobBuilder constructor and old browsers that didn't support it in the Blob constructor.
BlobBuilderConstructor
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function BlobConstructor(ary, options) { mapArrayBufferViews(ary); return new Blob(ary, options || {}); }
Helper function that maps ArrayBufferViews to ArrayBuffers Used by BlobBuilder constructor and old browsers that didn't support it in the Blob constructor.
BlobConstructor
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function encode(num) { var encoded = ''; do { encoded = alphabet[num % length] + encoded; num = Math.floor(num / length); } while (num > 0); return encoded; }
Return a string representing the specified number. @param {Number} num The number to convert. @returns {String} The string representation of the number. @api public
encode
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function decode(str) { var decoded = 0; for (i = 0; i < str.length; i++) { decoded = decoded * length + map[str.charAt(i)]; } return decoded; }
Return the integer value specified by the given string. @param {String} str The string to convert. @returns {Number} The integer value represented by the string. @api public
decode
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function yeast() { var now = encode(+new Date()); if (now !== prev) return seed = 0, prev = now; return now +'.'+ encode(seed++); }
Yeast: A tiny growing id generator. @returns {String} A unique id. @api public
yeast
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function JSONPPolling (opts) { Polling.call(this, opts); this.query = this.query || {}; // define global callbacks array if not present // we do this here (lazily) to avoid unneeded global pollution if (!callbacks) { // we need to consider multiple engines in the same page if (!global.___eio)...
JSONP Polling constructor. @param {Object} opts. @api public
JSONPPolling
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function complete () { initIframe(); fn(); }
Writes with a hidden iframe. @param {String} data to send @param {Function} called upon flush. @api private
complete
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function initIframe () { if (self.iframe) { try { self.form.removeChild(self.iframe); } catch (e) { self.onError('jsonp polling iframe removal error', e); } } try { // ie6 dynamic iframes with target="" support (thanks Chris Lambacher) var html = '<if...
Writes with a hidden iframe. @param {String} data to send @param {Function} called upon flush. @api private
initIframe
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function WS (opts) { var forceBase64 = (opts && opts.forceBase64); if (forceBase64) { this.supportsBinary = false; } this.perMessageDeflate = opts.perMessageDeflate; Transport.call(this, opts); }
WebSocket transport constructor. @api {Object} connection options @api public
WS
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function done () { self.emit('flush'); // fake drain // defer to next tick to allow Socket to clear writeBuffer setTimeout(function () { self.writable = true; self.emit('drain'); }, 0); }
Writes data to socket. @param {Array} array of packets. @api private
done
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function hasBinary(data) { function _hasBinary(obj) { if (!obj) return false; if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) || (global.ArrayBuffer && obj instanceof ArrayBuffer) || (global.Blob && obj instanceof Blob) || (global.File && obj in...
Checks for binary data. Right now only Buffer and ArrayBuffer are supported.. @param {Object} anything @api public
hasBinary
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function _hasBinary(obj) { if (!obj) return false; if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) || (global.ArrayBuffer && obj instanceof ArrayBuffer) || (global.Blob && obj instanceof Blob) || (global.File && obj instanceof File) ) { ...
Checks for binary data. Right now only Buffer and ArrayBuffer are supported.. @param {Object} anything @api public
_hasBinary
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function Backoff(opts) { opts = opts || {}; this.ms = opts.min || 100; this.max = opts.max || 10000; this.factor = opts.factor || 2; this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0; this.attempts = 0; }
Initialize backoff timer with `opts`. - `min` initial timeout in milliseconds [100] - `max` max timeout [10000] - `jitter` [0] - `factor` [2] @param {Object} opts @api public
Backoff
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/file-sharing/rmc-files-handler.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/file-sharing/rmc-files-handler.js
MIT
function makeMetadataSeekable(originalMetadata, duration, cuesInfo) { // extract the header, we can reuse this as-is var header = extractElement("EBML", originalMetadata); var headerSize = encodedSizeOfEbml(header); //console.error("Header size: " + headerSize); //printElementIds(header); // Aft...
convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues @param originalMetadata - orginal metadata (everything before the clusters start) from media recorder @param duration - Duration (TimecodeScale) @param cues - cue points for clusters
makeMetadataSeekable
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/screen-recording/RecordRTC/EBML.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/screen-recording/RecordRTC/EBML.js
MIT
_loop_1 = function (i) { // SeekHead starts at 0 var infoStart = seekHeadSize; // Info comes directly after SeekHead var tracksStart = infoStart + infoSize; // Tracks comes directly after Info var cuesStart = tracksStart + tracksSize; // Cues starts directly after var newMetadat...
convert the metadata from a streaming webm bytestream to a seekable file by inserting Duration, Seekhead and Cues @param originalMetadata - orginal metadata (everything before the clusters start) from media recorder @param duration - Duration (TimecodeScale) @param cues - cue points for clusters
_loop_1
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/screen-recording/RecordRTC/EBML.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/screen-recording/RecordRTC/EBML.js
MIT
function removeElement(idName, metadata) { var result = []; var start = -1; for (var i = 0; i < metadata.length; i++) { var element = metadata[i]; if (element.name === idName) { // if it's a Master element, extract the start and end element, and everything in between ...
remove all occurances of an EBML element from an array of elements If it's a MasterElement you will also remove the content. (everything between start and end) @param idName - name of the EBML Element to remove. @param metadata - array of EBML elements to search
removeElement
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/screen-recording/RecordRTC/EBML.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/screen-recording/RecordRTC/EBML.js
MIT
function extractElement(idName, metadata) { var result = []; var start = -1; for (var i = 0; i < metadata.length; i++) { var element = metadata[i]; if (element.name === idName) { // if it's a Master element, extract the start and end element, and everything in between ...
extract the first occurance of an EBML tag from a flattened array of EBML data. If it's a MasterElement you will also get the content. (everything between start and end) @param idName - name of the EBML Element to extract. @param metadata - array of EBML elements to search
extractElement
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/screen-recording/RecordRTC/EBML.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/screen-recording/RecordRTC/EBML.js
MIT
function kMaxLength () { return Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff }
The Buffer constructor returns instances of `Uint8Array` that have their prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`, so the returned instances will have all the node `Buffer` methods and the `Uint8Array` methods. Square bracket notation works as expected -- it returns a...
kMaxLength
javascript
muaz-khan/WebRTC-Experiment
Chrome-Extensions/screen-recording/RecordRTC/EBML.js
https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Chrome-Extensions/screen-recording/RecordRTC/EBML.js
MIT