repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
realmq/realmq-web-sdk
lib/rtm-client.js
function() { var me = this; var connectionOptions = me._connectionOptions; return promised(function(cb) { if (me.isConnected || me.status === 'connecting') { return cb(new Error('Broker client already connected or connecting.')); } if (!me.mqttClient) { var mqttClient = n...
javascript
function() { var me = this; var connectionOptions = me._connectionOptions; return promised(function(cb) { if (me.isConnected || me.status === 'connecting') { return cb(new Error('Broker client already connected or connecting.')); } if (!me.mqttClient) { var mqttClient = n...
[ "function", "(", ")", "{", "var", "me", "=", "this", ";", "var", "connectionOptions", "=", "me", ".", "_connectionOptions", ";", "return", "promised", "(", "function", "(", "cb", ")", "{", "if", "(", "me", ".", "isConnected", "||", "me", ".", "status",...
Opens a connection to the @return {Promise}
[ "Opens", "a", "connection", "to", "the" ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/rtm-client.js#L58-L97
train
realmq/realmq-web-sdk
lib/rtm-client.js
function(args) { var mqttClient = this.mqttClient; return promised(function(cb) { mqttClient.subscribe(args.channel, _getPahoCallbacks(cb)); }); }
javascript
function(args) { var mqttClient = this.mqttClient; return promised(function(cb) { mqttClient.subscribe(args.channel, _getPahoCallbacks(cb)); }); }
[ "function", "(", "args", ")", "{", "var", "mqttClient", "=", "this", ".", "mqttClient", ";", "return", "promised", "(", "function", "(", "cb", ")", "{", "mqttClient", ".", "subscribe", "(", "args", ".", "channel", ",", "_getPahoCallbacks", "(", "cb", ")"...
Subscribe to rtm channel. @param {Object} args @param {String} args.channel @return {Promise}
[ "Subscribe", "to", "rtm", "channel", "." ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/rtm-client.js#L137-L142
train
realmq/realmq-web-sdk
lib/rtm-client.js
function(args) { var mqttClient = this.mqttClient; return promised(function(cb) { mqttClient.unsubscribe(args.channel, _getPahoCallbacks(cb)); }); }
javascript
function(args) { var mqttClient = this.mqttClient; return promised(function(cb) { mqttClient.unsubscribe(args.channel, _getPahoCallbacks(cb)); }); }
[ "function", "(", "args", ")", "{", "var", "mqttClient", "=", "this", ".", "mqttClient", ";", "return", "promised", "(", "function", "(", "cb", ")", "{", "mqttClient", ".", "unsubscribe", "(", "args", ".", "channel", ",", "_getPahoCallbacks", "(", "cb", "...
Unsubscribe from rtm channel. @param {Object} args @param {String} args.channel
[ "Unsubscribe", "from", "rtm", "channel", "." ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/rtm-client.js#L150-L155
train
realmq/realmq-web-sdk
lib/rtm-client.js
function(event, handler) { return events.on({ listeners: this._listeners, event: event, handler: handler }); }
javascript
function(event, handler) { return events.on({ listeners: this._listeners, event: event, handler: handler }); }
[ "function", "(", "event", ",", "handler", ")", "{", "return", "events", ".", "on", "(", "{", "listeners", ":", "this", ".", "_listeners", ",", "event", ":", "event", ",", "handler", ":", "handler", "}", ")", ";", "}" ]
Register an event handler. @param {String} event @param {Function} handler
[ "Register", "an", "event", "handler", "." ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/rtm-client.js#L163-L169
train
realmq/realmq-web-sdk
lib/rtm-client.js
function(event, handler) { return events.off({ listeners: this._listeners, event: event, handler: handler }); }
javascript
function(event, handler) { return events.off({ listeners: this._listeners, event: event, handler: handler }); }
[ "function", "(", "event", ",", "handler", ")", "{", "return", "events", ".", "off", "(", "{", "listeners", ":", "this", ".", "_listeners", ",", "event", ":", "event", ",", "handler", ":", "handler", "}", ")", ";", "}" ]
Unregister an event handler @param {String} event @param {Function} handler
[ "Unregister", "an", "event", "handler" ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/rtm-client.js#L177-L183
train
realmq/realmq-web-sdk
lib/rtm-client.js
function(event, data) { return events.emit({ listeners: this._listeners, event: event, data: data }); }
javascript
function(event, data) { return events.emit({ listeners: this._listeners, event: event, data: data }); }
[ "function", "(", "event", ",", "data", ")", "{", "return", "events", ".", "emit", "(", "{", "listeners", ":", "this", ".", "_listeners", ",", "event", ":", "event", ",", "data", ":", "data", "}", ")", ";", "}" ]
Emit an event. @param event @param data
[ "Emit", "an", "event", "." ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/rtm-client.js#L191-L197
train
realmq/realmq-web-sdk
lib/features/auto-subscribe.js
autoSubscribe
function autoSubscribe(args) { var rtm = args.rtm; var listSubscriptions = args.listSubscriptions; var filterFn = args.filterFn || _autoSubscribeDefaultFilterFn; var subscriptionLoadLimit = 50; _observeSubscriptionSyncEvents({ rtm: rtm, filterFn: filterFn }); return listSubscriptions({limit: sub...
javascript
function autoSubscribe(args) { var rtm = args.rtm; var listSubscriptions = args.listSubscriptions; var filterFn = args.filterFn || _autoSubscribeDefaultFilterFn; var subscriptionLoadLimit = 50; _observeSubscriptionSyncEvents({ rtm: rtm, filterFn: filterFn }); return listSubscriptions({limit: sub...
[ "function", "autoSubscribe", "(", "args", ")", "{", "var", "rtm", "=", "args", ".", "rtm", ";", "var", "listSubscriptions", "=", "args", ".", "listSubscriptions", ";", "var", "filterFn", "=", "args", ".", "filterFn", "||", "_autoSubscribeDefaultFilterFn", ";",...
Subscribe to all read allowed subscriptions. @param {Object} args @param {RtmClient} args.rtm @param {Function} args.listSubscriptions @param {Function} [args.filterFn] @return {Promise}
[ "Subscribe", "to", "all", "read", "allowed", "subscriptions", "." ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/features/auto-subscribe.js#L14-L53
train
realmq/realmq-web-sdk
lib/features/auto-subscribe.js
_observeSubscriptionSyncEvents
function _observeSubscriptionSyncEvents(args) { var rtm = args.rtm; var filterFn = args.filterFn; rtm.on('subscription-created', function(subscription) { if (subscription.allowRead !== true) return; filterFn(subscription).then(function(ok) { if (ok) { rtm.subscribe({channel: subscription.c...
javascript
function _observeSubscriptionSyncEvents(args) { var rtm = args.rtm; var filterFn = args.filterFn; rtm.on('subscription-created', function(subscription) { if (subscription.allowRead !== true) return; filterFn(subscription).then(function(ok) { if (ok) { rtm.subscribe({channel: subscription.c...
[ "function", "_observeSubscriptionSyncEvents", "(", "args", ")", "{", "var", "rtm", "=", "args", ".", "rtm", ";", "var", "filterFn", "=", "args", ".", "filterFn", ";", "rtm", ".", "on", "(", "'subscription-created'", ",", "function", "(", "subscription", ")",...
Register event listeners for keeping subscriptions in sync. @param {Object} args @param {RtmClient} args.rtm @param {Function} args.filterFn @private
[ "Register", "event", "listeners", "for", "keeping", "subscriptions", "in", "sync", "." ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/features/auto-subscribe.js#L102-L130
train
realmq/realmq-web-sdk
lib/errors/api-error.js
createApiError
function createApiError(options) { return { name: options.name || 'ApiError', message: options.message, status: options.status || 500, details: options.details, code: options.code || options.status || 500, toString: function() { return this.name + ' [' + this.status + '] - ' + this.mess...
javascript
function createApiError(options) { return { name: options.name || 'ApiError', message: options.message, status: options.status || 500, details: options.details, code: options.code || options.status || 500, toString: function() { return this.name + ' [' + this.status + '] - ' + this.mess...
[ "function", "createApiError", "(", "options", ")", "{", "return", "{", "name", ":", "options", ".", "name", "||", "'ApiError'", ",", "message", ":", "options", ".", "message", ",", "status", ":", "options", ".", "status", "||", "500", ",", "details", ":"...
Constructs a generalized api error object. @param options.message @param options.code @param options.details @param options.status @param options.name @return {{name: string, status: number, code: *|number, details, toString(): string}}
[ "Constructs", "a", "generalized", "api", "error", "object", "." ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/errors/api-error.js#L13-L25
train
realmq/realmq-web-sdk
lib/api-client.js
function(args) { var baseUrl = this.baseUrl + this.basePath; var authToken = this.authToken; var qs = this._buildQueryString(args.params); return new Promise(function(resolve, reject) { var req = new XMLHttpRequest(); req.onreadystatechange = function() { if (req.readyState === 4) ...
javascript
function(args) { var baseUrl = this.baseUrl + this.basePath; var authToken = this.authToken; var qs = this._buildQueryString(args.params); return new Promise(function(resolve, reject) { var req = new XMLHttpRequest(); req.onreadystatechange = function() { if (req.readyState === 4) ...
[ "function", "(", "args", ")", "{", "var", "baseUrl", "=", "this", ".", "baseUrl", "+", "this", ".", "basePath", ";", "var", "authToken", "=", "this", ".", "authToken", ";", "var", "qs", "=", "this", ".", "_buildQueryString", "(", "args", ".", "params",...
Generic request method. @param args.method @param args.path @returns {Promise} @private
[ "Generic", "request", "method", "." ]
d9ef1b85bf4798beed1988f2e78ed04d862c19ef
https://github.com/realmq/realmq-web-sdk/blob/d9ef1b85bf4798beed1988f2e78ed04d862c19ef/lib/api-client.js#L51-L95
train
CHENXCHEN/hexo-renderer-markdown-it-plus
lib/renderer.js
checkValue
function checkValue(config, res, key, trueVal, falseVal) { res[key] = (config[key] == true || config[key] == undefined || config[key] == null) ? trueVal: falseVal; }
javascript
function checkValue(config, res, key, trueVal, falseVal) { res[key] = (config[key] == true || config[key] == undefined || config[key] == null) ? trueVal: falseVal; }
[ "function", "checkValue", "(", "config", ",", "res", ",", "key", ",", "trueVal", ",", "falseVal", ")", "{", "res", "[", "key", "]", "=", "(", "config", "[", "key", "]", "==", "true", "||", "config", "[", "key", "]", "==", "undefined", "||", "config...
General Default markdown-it config. @param {Object} config configuration @param {Object} res configuration @param {String} key the key of config @param {String} trueVal the val of config[key] == true @param {String} falseVal the val of config[key] == false @return {null}
[ "General", "Default", "markdown", "-", "it", "config", "." ]
f2dd1b25738992efc391ba9da398a9c6a7efb105
https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus/blob/f2dd1b25738992efc391ba9da398a9c6a7efb105/lib/renderer.js#L41-L43
train
CHENXCHEN/hexo-renderer-markdown-it-plus
lib/renderer.js
checkPlugins
function checkPlugins(pugs) { var def_pugs_obj = {}; for(var i = 0;i < def_pugs_lst.length;i++) def_pugs_obj[def_pugs_lst[i]] = {'name': def_pugs_lst[i], 'enable': true}; var _t = []; for(var i = 0;i < pugs.length;i++) { if(!(pugs[i] instanceof Object) || !(pugs[i].plugin instanceof Obje...
javascript
function checkPlugins(pugs) { var def_pugs_obj = {}; for(var i = 0;i < def_pugs_lst.length;i++) def_pugs_obj[def_pugs_lst[i]] = {'name': def_pugs_lst[i], 'enable': true}; var _t = []; for(var i = 0;i < pugs.length;i++) { if(!(pugs[i] instanceof Object) || !(pugs[i].plugin instanceof Obje...
[ "function", "checkPlugins", "(", "pugs", ")", "{", "var", "def_pugs_obj", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "def_pugs_lst", ".", "length", ";", "i", "++", ")", "def_pugs_obj", "[", "def_pugs_lst", "[", "i", "]", "...
General default plugin config @param {List} pugs plugin List. @return {List} plugin List.
[ "General", "default", "plugin", "config" ]
f2dd1b25738992efc391ba9da398a9c6a7efb105
https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus/blob/f2dd1b25738992efc391ba9da398a9c6a7efb105/lib/renderer.js#L80-L101
train
canjs/can-validate-legacy
map/validate/validate.js
function (behavior, attr, define) { var prop; var defaultProp; if (define) { prop = define[attr]; defaultProp = define["*"]; if (prop && prop[behavior] !== undefined) { return prop[behavior]; } else { if (defaultProp && defaultProp[behavior] !== undefined) { return defaultProp[behavior]; } }...
javascript
function (behavior, attr, define) { var prop; var defaultProp; if (define) { prop = define[attr]; defaultProp = define["*"]; if (prop && prop[behavior] !== undefined) { return prop[behavior]; } else { if (defaultProp && defaultProp[behavior] !== undefined) { return defaultProp[behavior]; } }...
[ "function", "(", "behavior", ",", "attr", ",", "define", ")", "{", "var", "prop", ";", "var", "defaultProp", ";", "if", "(", "define", ")", "{", "prop", "=", "define", "[", "attr", "]", ";", "defaultProp", "=", "define", "[", "\"*\"", "]", ";", "if...
Gets properties from the map"s define property.
[ "Gets", "properties", "from", "the", "map", "s", "define", "property", "." ]
a4a9919e7b1a9e7060331a3e2633a786ae53c65f
https://github.com/canjs/can-validate-legacy/blob/a4a9919e7b1a9e7060331a3e2633a786ae53c65f/map/validate/validate.js#L50-L66
train
IjzerenHein/node-web-bluetooth
src/utils.js
fromNobleUuid
function fromNobleUuid(uuid) { if (uuid.length !== 32) return uuid; return ( uuid.substring(0, 8) + '-' + uuid.substring(8, 12) + '-' + uuid.substring(12, 16) + '-' + uuid.substring(16, 20) + '-' + uuid.substring(20) ); }
javascript
function fromNobleUuid(uuid) { if (uuid.length !== 32) return uuid; return ( uuid.substring(0, 8) + '-' + uuid.substring(8, 12) + '-' + uuid.substring(12, 16) + '-' + uuid.substring(16, 20) + '-' + uuid.substring(20) ); }
[ "function", "fromNobleUuid", "(", "uuid", ")", "{", "if", "(", "uuid", ".", "length", "!==", "32", ")", "return", "uuid", ";", "return", "(", "uuid", ".", "substring", "(", "0", ",", "8", ")", "+", "'-'", "+", "uuid", ".", "substring", "(", "8", ...
00000001-1212-efde-1523-785feabcd124
[ "00000001", "-", "1212", "-", "efde", "-", "1523", "-", "785feabcd124" ]
6f9f40132473395b6fadb3c6365544e9f2251117
https://github.com/IjzerenHein/node-web-bluetooth/blob/6f9f40132473395b6fadb3c6365544e9f2251117/src/utils.js#L61-L74
train
thlorenz/v8-flags
scripts/preinstall.js
removeComplete
function removeComplete(regex, lines, start) { var matches = lines[start].match(regex); var i = 0; var s = lines[start]; matches = s.match(regex); while (!matches) { i++; if ((start + i) > lines.length) return; s += lines[start + i]; matches = s.match(regex); } lines.splice(start, i + 1);...
javascript
function removeComplete(regex, lines, start) { var matches = lines[start].match(regex); var i = 0; var s = lines[start]; matches = s.match(regex); while (!matches) { i++; if ((start + i) > lines.length) return; s += lines[start + i]; matches = s.match(regex); } lines.splice(start, i + 1);...
[ "function", "removeComplete", "(", "regex", ",", "lines", ",", "start", ")", "{", "var", "matches", "=", "lines", "[", "start", "]", ".", "match", "(", "regex", ")", ";", "var", "i", "=", "0", ";", "var", "s", "=", "lines", "[", "start", "]", ";"...
some calls stretch across multiple lines, so we need to ensure to remove them completely
[ "some", "calls", "stretch", "across", "multiple", "lines", "so", "we", "need", "to", "ensure", "to", "remove", "them", "completely" ]
ac622e813cdb3716e3f3d767d9e7da5220556a6f
https://github.com/thlorenz/v8-flags/blob/ac622e813cdb3716e3f3d767d9e7da5220556a6f/scripts/preinstall.js#L27-L40
train
que-etc/intersection-observer-polyfill
src/_IntersectionObserver.js
parseThresholds
function parseThresholds(thresholds = 0) { let result = thresholds; if (!Array.isArray(thresholds)) { result = [thresholds]; } else if (!thresholds.length) { result = [0]; } return result.map(threshold => { // We use Number function instead of parseFloat // to conve...
javascript
function parseThresholds(thresholds = 0) { let result = thresholds; if (!Array.isArray(thresholds)) { result = [thresholds]; } else if (!thresholds.length) { result = [0]; } return result.map(threshold => { // We use Number function instead of parseFloat // to conve...
[ "function", "parseThresholds", "(", "thresholds", "=", "0", ")", "{", "let", "result", "=", "thresholds", ";", "if", "(", "!", "Array", ".", "isArray", "(", "thresholds", ")", ")", "{", "result", "=", "[", "thresholds", "]", ";", "}", "else", "if", "...
Validates and parses threshold values. Throws an error if one of the thresholds is non-finite or not in range of 0 and 1. @param {(Array<Number>|Number)} [thresholds = 0] @returns {Array<Number>} An array of thresholds in ascending order.
[ "Validates", "and", "parses", "threshold", "values", ".", "Throws", "an", "error", "if", "one", "of", "the", "thresholds", "is", "non", "-", "finite", "or", "not", "in", "range", "of", "0", "and", "1", "." ]
39eae5569fe09ba840d2a4d92de5c0670bc11a71
https://github.com/que-etc/intersection-observer-polyfill/blob/39eae5569fe09ba840d2a4d92de5c0670bc11a71/src/_IntersectionObserver.js#L13-L37
train
koenkivits/nesnes
system/apu/index.js
function() { return ( ( (!!this.pulse1.lengthCounter) << 0 ) | ( (!!this.pulse2.lengthCounter) << 1 ) | ( (!!this.triangle.lengthCounter) << 2 ) | ( (!!this.noise.lengthCounter) << 3 ) | ( (!!this.dmc.sampleBytesLeft) << 4 ) ); }
javascript
function() { return ( ( (!!this.pulse1.lengthCounter) << 0 ) | ( (!!this.pulse2.lengthCounter) << 1 ) | ( (!!this.triangle.lengthCounter) << 2 ) | ( (!!this.noise.lengthCounter) << 3 ) | ( (!!this.dmc.sampleBytesLeft) << 4 ) ); }
[ "function", "(", ")", "{", "return", "(", "(", "(", "!", "!", "this", ".", "pulse1", ".", "lengthCounter", ")", "<<", "0", ")", "|", "(", "(", "!", "!", "this", ".", "pulse2", ".", "lengthCounter", ")", "<<", "1", ")", "|", "(", "(", "!", "!"...
Read channel status.
[ "Read", "channel", "status", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/apu/index.js#L53-L61
train
koenkivits/nesnes
system/apu/index.js
function( address, value ) { if ( address < 0x4 ) { // pulse 1 registers this.pulse1.writeRegister( address, value ); } else if ( address < 0x8 ) { // pulse 2 registers this.pulse2.writeRegister( address - 0x4, value ); } else if ( address < 0xc ) { // triangle registers this.triangle.writeRegis...
javascript
function( address, value ) { if ( address < 0x4 ) { // pulse 1 registers this.pulse1.writeRegister( address, value ); } else if ( address < 0x8 ) { // pulse 2 registers this.pulse2.writeRegister( address - 0x4, value ); } else if ( address < 0xc ) { // triangle registers this.triangle.writeRegis...
[ "function", "(", "address", ",", "value", ")", "{", "if", "(", "address", "<", "0x4", ")", "{", "// pulse 1 registers", "this", ".", "pulse1", ".", "writeRegister", "(", "address", ",", "value", ")", ";", "}", "else", "if", "(", "address", "<", "0x8", ...
Write to APU registers.
[ "Write", "to", "APU", "registers", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/apu/index.js#L66-L107
train
koenkivits/nesnes
system/apu/index.js
function() { switch( this.cycles ) { case 3728: case 7457: case 11186: case 14915: this.doQuarterFrame(); break; } switch( this.cycles ) { case 7457: case 14915: this.doHalfFrame(); break; } if ( this.cycles >= 14915 ) { this.cycles = 0; if( this.frameCounterInterrupt ) { ...
javascript
function() { switch( this.cycles ) { case 3728: case 7457: case 11186: case 14915: this.doQuarterFrame(); break; } switch( this.cycles ) { case 7457: case 14915: this.doHalfFrame(); break; } if ( this.cycles >= 14915 ) { this.cycles = 0; if( this.frameCounterInterrupt ) { ...
[ "function", "(", ")", "{", "switch", "(", "this", ".", "cycles", ")", "{", "case", "3728", ":", "case", "7457", ":", "case", "11186", ":", "case", "14915", ":", "this", ".", "doQuarterFrame", "(", ")", ";", "break", ";", "}", "switch", "(", "this",...
Tick for framecounter mode 0.
[ "Tick", "for", "framecounter", "mode", "0", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/apu/index.js#L141-L165
train
koenkivits/nesnes
system/apu/index.js
function() { var tndOut = 0, // triangle, noise, dmc pulseOut = 0; this.pulse1.doTimer(); this.pulse2.doTimer(); this.triangle.doTimer(); this.noise.doTimer(); this.dmc.doTimer(); if ( this.output.enabled ) { // no need to do calculations if output is disabled if ( this.sampleCounter >= this.sa...
javascript
function() { var tndOut = 0, // triangle, noise, dmc pulseOut = 0; this.pulse1.doTimer(); this.pulse2.doTimer(); this.triangle.doTimer(); this.noise.doTimer(); this.dmc.doTimer(); if ( this.output.enabled ) { // no need to do calculations if output is disabled if ( this.sampleCounter >= this.sa...
[ "function", "(", ")", "{", "var", "tndOut", "=", "0", ",", "// triangle, noise, dmc", "pulseOut", "=", "0", ";", "this", ".", "pulse1", ".", "doTimer", "(", ")", ";", "this", ".", "pulse2", ".", "doTimer", "(", ")", ";", "this", ".", "triangle", ".",...
Update output sample.
[ "Update", "output", "sample", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/apu/index.js#L221-L244
train
koenkivits/nesnes
index.js
function( filename, autorun ) { var self = this; utils.readFile( filename, function( data ) { self.initCartridge( data ); if ( typeof autorun === "function" ) { autorun(); } else if ( autorun === true ) { self.run(); } }); }
javascript
function( filename, autorun ) { var self = this; utils.readFile( filename, function( data ) { self.initCartridge( data ); if ( typeof autorun === "function" ) { autorun(); } else if ( autorun === true ) { self.run(); } }); }
[ "function", "(", "filename", ",", "autorun", ")", "{", "var", "self", "=", "this", ";", "utils", ".", "readFile", "(", "filename", ",", "function", "(", "data", ")", "{", "self", ".", "initCartridge", "(", "data", ")", ";", "if", "(", "typeof", "auto...
Load a ROM and optionally run it. @param {string} filename - Path of ROM to run. @param autorun - If true, run ROM when loaded. If a function, call that function.
[ "Load", "a", "ROM", "and", "optionally", "run", "it", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/index.js#L51-L63
train
koenkivits/nesnes
index.js
function() { if ( this.interval ) { // once is enough return; } var self = this; this.interval = setInterval( function() { if ( !self.paused) { self.runFrame(); } }, 1000 / 60 ); this.output.video.run(); this.running = true; this.paused = false; }
javascript
function() { if ( this.interval ) { // once is enough return; } var self = this; this.interval = setInterval( function() { if ( !self.paused) { self.runFrame(); } }, 1000 / 60 ); this.output.video.run(); this.running = true; this.paused = false; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "interval", ")", "{", "// once is enough", "return", ";", "}", "var", "self", "=", "this", ";", "this", ".", "interval", "=", "setInterval", "(", "function", "(", ")", "{", "if", "(", "!", "self", ...
Turn on and run emulator.
[ "Turn", "on", "and", "run", "emulator", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/index.js#L68-L85
train
koenkivits/nesnes
system/cpu.js
doADC
function doADC( value ) { var t = A + value + flagC; flagV = !!((A ^ t) & (value ^ t) & 0x80) && 1; flagN = !!( t & 0x80 ); flagC = ( t > 255 ); flagZ = !( t & 0xff ); writeA( t & 0xff ); }
javascript
function doADC( value ) { var t = A + value + flagC; flagV = !!((A ^ t) & (value ^ t) & 0x80) && 1; flagN = !!( t & 0x80 ); flagC = ( t > 255 ); flagZ = !( t & 0xff ); writeA( t & 0xff ); }
[ "function", "doADC", "(", "value", ")", "{", "var", "t", "=", "A", "+", "value", "+", "flagC", ";", "flagV", "=", "!", "!", "(", "(", "A", "^", "t", ")", "&", "(", "value", "^", "t", ")", "&", "0x80", ")", "&&", "1", ";", "flagN", "=", "!...
Actually performe add with carry. Useful, as SBC is also a modified add-with-carry.
[ "Actually", "performe", "add", "with", "carry", ".", "Useful", "as", "SBC", "is", "also", "a", "modified", "add", "-", "with", "-", "carry", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cpu.js#L1069-L1078
train
koenkivits/nesnes
system/cpu.js
branch
function branch( flag ) { var offset = read(), prevHigh = PC & HIGH, curHigh = 0; if ( flag ) { // branching burns a cycle burn(1); if ( offset & 0x80 ) { offset = -complement( offset ); } PC += offset; curHigh = PC & HIGH; if ( prevHigh !== curHigh ) { // crossing page bounda...
javascript
function branch( flag ) { var offset = read(), prevHigh = PC & HIGH, curHigh = 0; if ( flag ) { // branching burns a cycle burn(1); if ( offset & 0x80 ) { offset = -complement( offset ); } PC += offset; curHigh = PC & HIGH; if ( prevHigh !== curHigh ) { // crossing page bounda...
[ "function", "branch", "(", "flag", ")", "{", "var", "offset", "=", "read", "(", ")", ",", "prevHigh", "=", "PC", "&", "HIGH", ",", "curHigh", "=", "0", ";", "if", "(", "flag", ")", "{", "// branching burns a cycle", "burn", "(", "1", ")", ";", "if"...
Helper function for all branching operations. @param {boolean} flag - If true, do branch. Otherwise do nothing.
[ "Helper", "function", "for", "all", "branching", "operations", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cpu.js#L1175-L1196
train
koenkivits/nesnes
system/cpu.js
xCMP
function xCMP( value ) { var readValue = read(), t = ( value - readValue ) & 0xff; flagN = ( t & 0x80 ) && 1; flagC = +( value >= readValue ); flagZ = +( t === 0 ); }
javascript
function xCMP( value ) { var readValue = read(), t = ( value - readValue ) & 0xff; flagN = ( t & 0x80 ) && 1; flagC = +( value >= readValue ); flagZ = +( t === 0 ); }
[ "function", "xCMP", "(", "value", ")", "{", "var", "readValue", "=", "read", "(", ")", ",", "t", "=", "(", "value", "-", "readValue", ")", "&", "0xff", ";", "flagN", "=", "(", "t", "&", "0x80", ")", "&&", "1", ";", "flagC", "=", "+", "(", "va...
Compare value with memory as if subtraction was carried out. @param {number} value - The value to compare with memory.
[ "Compare", "value", "with", "memory", "as", "if", "subtraction", "was", "carried", "out", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cpu.js#L1296-L1302
train
koenkivits/nesnes
system/cpu.js
peekWord
function peekWord( index ) { var low = peek( index ), high = peek( (index + 1) & 0xffff ) << 8; return ( low | high ); }
javascript
function peekWord( index ) { var low = peek( index ), high = peek( (index + 1) & 0xffff ) << 8; return ( low | high ); }
[ "function", "peekWord", "(", "index", ")", "{", "var", "low", "=", "peek", "(", "index", ")", ",", "high", "=", "peek", "(", "(", "index", "+", "1", ")", "&", "0xffff", ")", "<<", "8", ";", "return", "(", "low", "|", "high", ")", ";", "}" ]
Peek a 16-bit word from memory.
[ "Peek", "a", "16", "-", "bit", "word", "from", "memory", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cpu.js#L1677-L1682
train
koenkivits/nesnes
system/cpu.js
setFlags
function setFlags() { flagN = !!( P & 0x80 ); flagV = !!( P & 0x40 ); flagB = !!( P & 0x10 ); flagD = !!( P & 0x08 ); flagI = !!( P & 0x04 ); flagZ = !!( P & 0x02 ); flagC = !!( P & 0x01 ); }
javascript
function setFlags() { flagN = !!( P & 0x80 ); flagV = !!( P & 0x40 ); flagB = !!( P & 0x10 ); flagD = !!( P & 0x08 ); flagI = !!( P & 0x04 ); flagZ = !!( P & 0x02 ); flagC = !!( P & 0x01 ); }
[ "function", "setFlags", "(", ")", "{", "flagN", "=", "!", "!", "(", "P", "&", "0x80", ")", ";", "flagV", "=", "!", "!", "(", "P", "&", "0x40", ")", ";", "flagB", "=", "!", "!", "(", "P", "&", "0x10", ")", ";", "flagD", "=", "!", "!", "(",...
Set flags from value in P.
[ "Set", "flags", "from", "value", "in", "P", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cpu.js#L1709-L1717
train
koenkivits/nesnes
system/ppu/index.js
function( value ) { this.output.setGrayscale( value & 0x1 ); this.output.setIntensity( value & 0x20, value & 0x40, value & 0x80 ); this.sprites.toggle( value & 0x10 ); this.sprites.toggleLeft( value & 0x4 ); this.background.toggle( value & 0x8 ); this.background.toggleLeft( value & 0x2 ); this.enabled ...
javascript
function( value ) { this.output.setGrayscale( value & 0x1 ); this.output.setIntensity( value & 0x20, value & 0x40, value & 0x80 ); this.sprites.toggle( value & 0x10 ); this.sprites.toggleLeft( value & 0x4 ); this.background.toggle( value & 0x8 ); this.background.toggleLeft( value & 0x2 ); this.enabled ...
[ "function", "(", "value", ")", "{", "this", ".", "output", ".", "setGrayscale", "(", "value", "&", "0x1", ")", ";", "this", ".", "output", ".", "setIntensity", "(", "value", "&", "0x20", ",", "value", "&", "0x40", ",", "value", "&", "0x80", ")", ";...
Set various flags to control video output behavior.
[ "Set", "various", "flags", "to", "control", "video", "output", "behavior", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/ppu/index.js#L64-L75
train
koenkivits/nesnes
system/ppu/index.js
function( value ) { var nametableFlag = value & 0x3, incrementFlag = value & 0x4, spriteFlag = value & 0x8, backgroundFlag = value & 0x10, sizeFlag = value & 0x20, nmiFlag = value & 0x80; this.background.setNameTable( nametableFlag ); this.increment = incrementFlag ? 32 : 1; this.sprites.baseTa...
javascript
function( value ) { var nametableFlag = value & 0x3, incrementFlag = value & 0x4, spriteFlag = value & 0x8, backgroundFlag = value & 0x10, sizeFlag = value & 0x20, nmiFlag = value & 0x80; this.background.setNameTable( nametableFlag ); this.increment = incrementFlag ? 32 : 1; this.sprites.baseTa...
[ "function", "(", "value", ")", "{", "var", "nametableFlag", "=", "value", "&", "0x3", ",", "incrementFlag", "=", "value", "&", "0x4", ",", "spriteFlag", "=", "value", "&", "0x8", ",", "backgroundFlag", "=", "value", "&", "0x10", ",", "sizeFlag", "=", "...
Set various flags to control rendering behavior.
[ "Set", "various", "flags", "to", "control", "rendering", "behavior", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/ppu/index.js#L80-L98
train
koenkivits/nesnes
system/ppu/index.js
function() { var sprites = this.sprites, background = this.background; if ( this.inRenderScanline ) { if ( this.enabled ) { background.evaluate(); sprites.evaluate(); } if ( this.pixelInRange ) { if ( this.pixelInRange && sprites.sprite0InRange && sprites.scanlineSprite0...
javascript
function() { var sprites = this.sprites, background = this.background; if ( this.inRenderScanline ) { if ( this.enabled ) { background.evaluate(); sprites.evaluate(); } if ( this.pixelInRange ) { if ( this.pixelInRange && sprites.sprite0InRange && sprites.scanlineSprite0...
[ "function", "(", ")", "{", "var", "sprites", "=", "this", ".", "sprites", ",", "background", "=", "this", ".", "background", ";", "if", "(", "this", ".", "inRenderScanline", ")", "{", "if", "(", "this", ".", "enabled", ")", "{", "background", ".", "e...
A single PPU tick.
[ "A", "single", "PPU", "tick", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/ppu/index.js#L167-L192
train
que-etc/intersection-observer-polyfill
src/IntersectionObserverController.js
debounce
function debounce(callback, delay = 0) { let timeoutID = false; return function (...args) { if (timeoutID !== false) { clearTimeout(timeoutID); } timeoutID = setTimeout(() => { timeoutID = false; callback.apply(this, args); }, delay); };...
javascript
function debounce(callback, delay = 0) { let timeoutID = false; return function (...args) { if (timeoutID !== false) { clearTimeout(timeoutID); } timeoutID = setTimeout(() => { timeoutID = false; callback.apply(this, args); }, delay); };...
[ "function", "debounce", "(", "callback", ",", "delay", "=", "0", ")", "{", "let", "timeoutID", "=", "false", ";", "return", "function", "(", "...", "args", ")", "{", "if", "(", "timeoutID", "!==", "false", ")", "{", "clearTimeout", "(", "timeoutID", ")...
Creates a wrapper function that ensures that provided callback will be invoked only after the specified delay. @param {Function} callback @param {Number} [delay = 0] @returns {Function}
[ "Creates", "a", "wrapper", "function", "that", "ensures", "that", "provided", "callback", "will", "be", "invoked", "only", "after", "the", "specified", "delay", "." ]
39eae5569fe09ba840d2a4d92de5c0670bc11a71
https://github.com/que-etc/intersection-observer-polyfill/blob/39eae5569fe09ba840d2a4d92de5c0670bc11a71/src/IntersectionObserverController.js#L30-L44
train
koenkivits/nesnes
system/input/index.js
function() { var i, j, item, controls, config = this.config = this.system.config.input; for ( i = 0; i < config.length; i++ ) { item = config[ i ]; this.setController( i, item.type ); controls = item.controls; if ( !Array.isArray(controls) ) { controls = [ controls ]; } for ( j = ...
javascript
function() { var i, j, item, controls, config = this.config = this.system.config.input; for ( i = 0; i < config.length; i++ ) { item = config[ i ]; this.setController( i, item.type ); controls = item.controls; if ( !Array.isArray(controls) ) { controls = [ controls ]; } for ( j = ...
[ "function", "(", ")", "{", "var", "i", ",", "j", ",", "item", ",", "controls", ",", "config", "=", "this", ".", "config", "=", "this", ".", "system", ".", "config", ".", "input", ";", "for", "(", "i", "=", "0", ";", "i", "<", "config", ".", "...
Initialize total input config.
[ "Initialize", "total", "input", "config", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/input/index.js#L56-L74
train
koenkivits/nesnes
system/input/index.js
function( index, type, config ) { var currentHandler, InputHandler = inputHandlerMap[ type ], controller = this.controllers.get( index ); this.initInputHandlers( index ); currentHandler = this.inputHandlers[ index ][ type ]; if ( currentHandler ) { currentHandler.disable(); } this.inputHandlers[ ...
javascript
function( index, type, config ) { var currentHandler, InputHandler = inputHandlerMap[ type ], controller = this.controllers.get( index ); this.initInputHandlers( index ); currentHandler = this.inputHandlers[ index ][ type ]; if ( currentHandler ) { currentHandler.disable(); } this.inputHandlers[ ...
[ "function", "(", "index", ",", "type", ",", "config", ")", "{", "var", "currentHandler", ",", "InputHandler", "=", "inputHandlerMap", "[", "type", "]", ",", "controller", "=", "this", ".", "controllers", ".", "get", "(", "index", ")", ";", "this", ".", ...
Configure the input for a controller @param {number} index - Either 0 or 1 @param {string} type - Type of input handler (either 'keyboard' or 'gamepad') @param {object} config - Configuration for input handler (see config.json for examples)
[ "Configure", "the", "input", "for", "a", "controller" ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/input/index.js#L92-L108
train
koenkivits/nesnes
system/ppu/background.js
function() { var cartridge = this.memory.cartridge, attrAddress = attrAddresses[ this.loopyV ], attribute = cartridge.readNameTable( attrAddress & 0x1fff ), nametableAddress = 0x2000 | ( this.loopyV & 0x0fff ), tileIndex = cartridge.readNameTable( nametableAddress & 0x1fff ), ...
javascript
function() { var cartridge = this.memory.cartridge, attrAddress = attrAddresses[ this.loopyV ], attribute = cartridge.readNameTable( attrAddress & 0x1fff ), nametableAddress = 0x2000 | ( this.loopyV & 0x0fff ), tileIndex = cartridge.readNameTable( nametableAddress & 0x1fff ), ...
[ "function", "(", ")", "{", "var", "cartridge", "=", "this", ".", "memory", ".", "cartridge", ",", "attrAddress", "=", "attrAddresses", "[", "this", ".", "loopyV", "]", ",", "attribute", "=", "cartridge", ".", "readNameTable", "(", "attrAddress", "&", "0x1f...
Fetch background tile data.
[ "Fetch", "background", "tile", "data", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/ppu/background.js#L168-L186
train
koenkivits/nesnes
system/ppu/background.js
initAttrAddresses
function initAttrAddresses() { var i, result = new Uint16Array( 0x8000 ); for ( i = 0; i < 0x8000; i++ ) { result[ i ] = 0x23c0 | (i & 0x0c00) | ((i >> 4) & 0x38) | ((i >> 2) & 0x07); } return result; }
javascript
function initAttrAddresses() { var i, result = new Uint16Array( 0x8000 ); for ( i = 0; i < 0x8000; i++ ) { result[ i ] = 0x23c0 | (i & 0x0c00) | ((i >> 4) & 0x38) | ((i >> 2) & 0x07); } return result; }
[ "function", "initAttrAddresses", "(", ")", "{", "var", "i", ",", "result", "=", "new", "Uint16Array", "(", "0x8000", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x8000", ";", "i", "++", ")", "{", "result", "[", "i", "]", "=", "0x23c0", ...
Initialize attribute address lookup table. Maps loopy_v values to attribute addresses.
[ "Initialize", "attribute", "address", "lookup", "table", ".", "Maps", "loopy_v", "values", "to", "attribute", "addresses", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/ppu/background.js#L213-L222
train
koenkivits/nesnes
system/ppu/background.js
initMasks
function initMasks() { var i, mask, result = new Uint8Array( 0x10000 ); for ( i = 0; i < 0x10000; i++ ) { mask = 3; if ( i & 0x2 ) { // right mask <<= 2; } if ( i & 0x40 ) { // bottom mask <<= 4; } result[ i ] = mask; } return result; }
javascript
function initMasks() { var i, mask, result = new Uint8Array( 0x10000 ); for ( i = 0; i < 0x10000; i++ ) { mask = 3; if ( i & 0x2 ) { // right mask <<= 2; } if ( i & 0x40 ) { // bottom mask <<= 4; } result[ i ] = mask; } return result; }
[ "function", "initMasks", "(", ")", "{", "var", "i", ",", "mask", ",", "result", "=", "new", "Uint8Array", "(", "0x10000", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "0x10000", ";", "i", "++", ")", "{", "mask", "=", "3", ";", "if", "(...
Inititialze mask lookup table. Maps loopy_v values to bitmasks for attribute bytes to get the correct palette value.
[ "Inititialze", "mask", "lookup", "table", ".", "Maps", "loopy_v", "values", "to", "bitmasks", "for", "attribute", "bytes", "to", "get", "the", "correct", "palette", "value", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/ppu/background.js#L228-L247
train
koenkivits/nesnes
system/ppu/background.js
initTileCycles
function initTileCycles() { var i, result = new Uint8Array( 400 ); for ( i = 7; i < 256; i += 8 ) { result[ i ] = 1; } for ( i = 327; i < 336; i += 8 ) { result[ i ] = 1; } return result; }
javascript
function initTileCycles() { var i, result = new Uint8Array( 400 ); for ( i = 7; i < 256; i += 8 ) { result[ i ] = 1; } for ( i = 327; i < 336; i += 8 ) { result[ i ] = 1; } return result; }
[ "function", "initTileCycles", "(", ")", "{", "var", "i", ",", "result", "=", "new", "Uint8Array", "(", "400", ")", ";", "for", "(", "i", "=", "7", ";", "i", "<", "256", ";", "i", "+=", "8", ")", "{", "result", "[", "i", "]", "=", "1", ";", ...
Initialize tile fetch cycles. Returns a typed array containing a 1 at every cycle a background tile should be fetched.
[ "Initialize", "tile", "fetch", "cycles", ".", "Returns", "a", "typed", "array", "containing", "a", "1", "at", "every", "cycle", "a", "background", "tile", "should", "be", "fetched", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/ppu/background.js#L270-L282
train
koenkivits/nesnes
system/ppu/sprites.js
function() { var spriteIndex = this.currentSprite << 2, y = this.oam2[ spriteIndex ], tileIndex = this.oam2[ spriteIndex + 1 ], attributes = this.oam2[ spriteIndex + 2 ], x = this.oam2[ spriteIndex + 3 ], baseTable = this.baseTable, tile = 0, flipX = attributes & 0x40, flipY = 0, fineY = 0;...
javascript
function() { var spriteIndex = this.currentSprite << 2, y = this.oam2[ spriteIndex ], tileIndex = this.oam2[ spriteIndex + 1 ], attributes = this.oam2[ spriteIndex + 2 ], x = this.oam2[ spriteIndex + 3 ], baseTable = this.baseTable, tile = 0, flipX = attributes & 0x40, flipY = 0, fineY = 0;...
[ "function", "(", ")", "{", "var", "spriteIndex", "=", "this", ".", "currentSprite", "<<", "2", ",", "y", "=", "this", ".", "oam2", "[", "spriteIndex", "]", ",", "tileIndex", "=", "this", ".", "oam2", "[", "spriteIndex", "+", "1", "]", ",", "attribute...
Fetch sprite data and feed appropriate shifters, counters and latches.
[ "Fetch", "sprite", "data", "and", "feed", "appropriate", "shifters", "counters", "and", "latches", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/ppu/sprites.js#L185-L232
train
koenkivits/nesnes
system/output/audiooutput.js
function( sample ) { this.bufferData[ this.bufferIndex++ ] = sample; if ( this.bufferIndex === this.bufferLength ) { this.bufferIndex = 0; if ( this.playing ) { this.playing.stop(); } this.bufferSource.buffer = this.buffer; this.playing = this.bufferSource; this.playing.start( 0 ); t...
javascript
function( sample ) { this.bufferData[ this.bufferIndex++ ] = sample; if ( this.bufferIndex === this.bufferLength ) { this.bufferIndex = 0; if ( this.playing ) { this.playing.stop(); } this.bufferSource.buffer = this.buffer; this.playing = this.bufferSource; this.playing.start( 0 ); t...
[ "function", "(", "sample", ")", "{", "this", ".", "bufferData", "[", "this", ".", "bufferIndex", "++", "]", "=", "sample", ";", "if", "(", "this", ".", "bufferIndex", "===", "this", ".", "bufferLength", ")", "{", "this", ".", "bufferIndex", "=", "0", ...
Write sample to buffer.
[ "Write", "sample", "to", "buffer", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/audiooutput.js#L16-L32
train
koenkivits/nesnes
system/output/audiooutput.js
function() { this.context = new AudioContext(); this.sampleRate = this.context.sampleRate; this.gainNode = this.context.createGain(); this.gainNode.connect( this.context.destination ); }
javascript
function() { this.context = new AudioContext(); this.sampleRate = this.context.sampleRate; this.gainNode = this.context.createGain(); this.gainNode.connect( this.context.destination ); }
[ "function", "(", ")", "{", "this", ".", "context", "=", "new", "AudioContext", "(", ")", ";", "this", ".", "sampleRate", "=", "this", ".", "context", ".", "sampleRate", ";", "this", ".", "gainNode", "=", "this", ".", "context", ".", "createGain", "(", ...
Initialize audio context.
[ "Initialize", "audio", "context", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/audiooutput.js#L74-L79
train
koenkivits/nesnes
system/output/audiooutput.js
function() { this.buffer = this.context.createBuffer(1, this.bufferLength, this.context.sampleRate); this.bufferData = this.buffer.getChannelData( 0 ); this.bufferSource = this.context.createBufferSource(); this.bufferSource.connect( this.gainNode ); }
javascript
function() { this.buffer = this.context.createBuffer(1, this.bufferLength, this.context.sampleRate); this.bufferData = this.buffer.getChannelData( 0 ); this.bufferSource = this.context.createBufferSource(); this.bufferSource.connect( this.gainNode ); }
[ "function", "(", ")", "{", "this", ".", "buffer", "=", "this", ".", "context", ".", "createBuffer", "(", "1", ",", "this", ".", "bufferLength", ",", "this", ".", "context", ".", "sampleRate", ")", ";", "this", ".", "bufferData", "=", "this", ".", "bu...
Initialize audio buffer.
[ "Initialize", "audio", "buffer", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/audiooutput.js#L84-L90
train
que-etc/intersection-observer-polyfill
src/IntersectionObservation.js
isDetached
function isDetached(container, target) { const docElement = document.documentElement; return ( container !== docElement && !docElement.contains(container) || !container.contains(target) ); }
javascript
function isDetached(container, target) { const docElement = document.documentElement; return ( container !== docElement && !docElement.contains(container) || !container.contains(target) ); }
[ "function", "isDetached", "(", "container", ",", "target", ")", "{", "const", "docElement", "=", "document", ".", "documentElement", ";", "return", "(", "container", "!==", "docElement", "&&", "!", "docElement", ".", "contains", "(", "container", ")", "||", ...
Tells whether target is a descendant of container element and that both of them are present in DOM. @param {Element} container - Container element. @param {Element} target - Target element. @returns {Boolean}
[ "Tells", "whether", "target", "is", "a", "descendant", "of", "container", "element", "and", "that", "both", "of", "them", "are", "present", "in", "DOM", "." ]
39eae5569fe09ba840d2a4d92de5c0670bc11a71
https://github.com/que-etc/intersection-observer-polyfill/blob/39eae5569fe09ba840d2a4d92de5c0670bc11a71/src/IntersectionObservation.js#L15-L22
train
que-etc/intersection-observer-polyfill
src/IntersectionObservation.js
computeIntersection
function computeIntersection(rootRect, targetRect) { const left = Math.max(targetRect.left, rootRect.left); const right = Math.min(targetRect.right, rootRect.right); const top = Math.max(targetRect.top, rootRect.top); const bottom = Math.min(targetRect.bottom, rootRect.bottom); co...
javascript
function computeIntersection(rootRect, targetRect) { const left = Math.max(targetRect.left, rootRect.left); const right = Math.min(targetRect.right, rootRect.right); const top = Math.max(targetRect.top, rootRect.top); const bottom = Math.min(targetRect.bottom, rootRect.bottom); co...
[ "function", "computeIntersection", "(", "rootRect", ",", "targetRect", ")", "{", "const", "left", "=", "Math", ".", "max", "(", "targetRect", ".", "left", ",", "rootRect", ".", "left", ")", ";", "const", "right", "=", "Math", ".", "min", "(", "targetRect...
Computes intersection rectangle between two rectangles. @param {ClientRect} rootRect - Rectangle of container element. @param {ClientRect} targetRect - Rectangle of target element. @returns {ClientRect} Intersection rectangle.
[ "Computes", "intersection", "rectangle", "between", "two", "rectangles", "." ]
39eae5569fe09ba840d2a4d92de5c0670bc11a71
https://github.com/que-etc/intersection-observer-polyfill/blob/39eae5569fe09ba840d2a4d92de5c0670bc11a71/src/IntersectionObservation.js#L31-L41
train
que-etc/intersection-observer-polyfill
src/IntersectionObservation.js
getIntersection
function getIntersection(container, target, containterRect, targetRect) { let intersecRect = targetRect, parent = target.parentNode, rootReached = false; while (!rootReached) { let parentRect = null; if (parent === container || parent.nodeType !== 1) { ...
javascript
function getIntersection(container, target, containterRect, targetRect) { let intersecRect = targetRect, parent = target.parentNode, rootReached = false; while (!rootReached) { let parentRect = null; if (parent === container || parent.nodeType !== 1) { ...
[ "function", "getIntersection", "(", "container", ",", "target", ",", "containterRect", ",", "targetRect", ")", "{", "let", "intersecRect", "=", "targetRect", ",", "parent", "=", "target", ".", "parentNode", ",", "rootReached", "=", "false", ";", "while", "(", ...
Finds intersection rectangle of provided elements. @param {Element} container - Container element. @param {Element} target - Target element. @param {ClientRect} targetRect - Rectangle of target element. @param {ClientRect} containterRect - Rectangle of container element.
[ "Finds", "intersection", "rectangle", "of", "provided", "elements", "." ]
39eae5569fe09ba840d2a4d92de5c0670bc11a71
https://github.com/que-etc/intersection-observer-polyfill/blob/39eae5569fe09ba840d2a4d92de5c0670bc11a71/src/IntersectionObservation.js#L51-L74
train
koenkivits/nesnes
system/cartridge.js
function() { if ( !( this.header[0] === 0x4e && // 'N' this.header[1] === 0x45 && // 'E' this.header[2] === 0x53 && // 'S' this.header[3] === 0x1a // ending character )) { throw new Error("Invalid ROM!"); } if ( this.header[7] & 0xe ) { throw new Error("Bit 1-3 of byte 7 i...
javascript
function() { if ( !( this.header[0] === 0x4e && // 'N' this.header[1] === 0x45 && // 'E' this.header[2] === 0x53 && // 'S' this.header[3] === 0x1a // ending character )) { throw new Error("Invalid ROM!"); } if ( this.header[7] & 0xe ) { throw new Error("Bit 1-3 of byte 7 i...
[ "function", "(", ")", "{", "if", "(", "!", "(", "this", ".", "header", "[", "0", "]", "===", "0x4e", "&&", "// 'N'", "this", ".", "header", "[", "1", "]", "===", "0x45", "&&", "// 'E'", "this", ".", "header", "[", "2", "]", "===", "0x53", "&&",...
Validate INES header. Throws an exception if invalid.
[ "Validate", "INES", "header", ".", "Throws", "an", "exception", "if", "invalid", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cartridge.js#L31-L59
train
koenkivits/nesnes
system/cartridge.js
function() { var flags6 = this.header[6]; this.mirroring = ( flags6 & 0x1 ) ? VERTICAL : HORIZONTAL; this.battery = ( flags6 & 0x2 ); this.trainer = ( flags6 & 0x4 ); this.mirroring = ( flags6 & 0x8 ) ? FOUR_SCREEN : this.mirroring; var flags7 = this.header[7]; this.vs = (flags7 & 0x1); this.mapper ...
javascript
function() { var flags6 = this.header[6]; this.mirroring = ( flags6 & 0x1 ) ? VERTICAL : HORIZONTAL; this.battery = ( flags6 & 0x2 ); this.trainer = ( flags6 & 0x4 ); this.mirroring = ( flags6 & 0x8 ) ? FOUR_SCREEN : this.mirroring; var flags7 = this.header[7]; this.vs = (flags7 & 0x1); this.mapper ...
[ "function", "(", ")", "{", "var", "flags6", "=", "this", ".", "header", "[", "6", "]", ";", "this", ".", "mirroring", "=", "(", "flags6", "&", "0x1", ")", "?", "VERTICAL", ":", "HORIZONTAL", ";", "this", ".", "battery", "=", "(", "flags6", "&", "...
Init header flags.
[ "Init", "header", "flags", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cartridge.js#L64-L80
train
koenkivits/nesnes
system/cartridge.js
function() { this.prgRead = new Uint8Array( 0x8000 ); this.prgRead.set( this.prgData.subarray( 0, 0x2000 ) ); this.chrRead = new Uint8Array( 0x2000 ); this.chrRead.set( this.chrData.subarray( 0, 0x2000 ) ); mappers.init( this ); }
javascript
function() { this.prgRead = new Uint8Array( 0x8000 ); this.prgRead.set( this.prgData.subarray( 0, 0x2000 ) ); this.chrRead = new Uint8Array( 0x2000 ); this.chrRead.set( this.chrData.subarray( 0, 0x2000 ) ); mappers.init( this ); }
[ "function", "(", ")", "{", "this", ".", "prgRead", "=", "new", "Uint8Array", "(", "0x8000", ")", ";", "this", ".", "prgRead", ".", "set", "(", "this", ".", "prgData", ".", "subarray", "(", "0", ",", "0x2000", ")", ")", ";", "this", ".", "chrRead", ...
Init mapper data and logic. NESNES copies data around to a dedicated typed array to emulate mapper behavior. See also loadChrBank and loadPrgBank.
[ "Init", "mapper", "data", "and", "logic", ".", "NESNES", "copies", "data", "around", "to", "a", "dedicated", "typed", "array", "to", "emulate", "mapper", "behavior", ".", "See", "also", "loadChrBank", "and", "loadPrgBank", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cartridge.js#L113-L121
train
koenkivits/nesnes
system/cartridge.js
function( address, value ) { if ( address & 0x8000 ) { this.writeRegister( address, value ); } else if ( address >= 0x6000 ) { // writing RAM this.ramData[ address - 0x6000 ] = value; } return; }
javascript
function( address, value ) { if ( address & 0x8000 ) { this.writeRegister( address, value ); } else if ( address >= 0x6000 ) { // writing RAM this.ramData[ address - 0x6000 ] = value; } return; }
[ "function", "(", "address", ",", "value", ")", "{", "if", "(", "address", "&", "0x8000", ")", "{", "this", ".", "writeRegister", "(", "address", ",", "value", ")", ";", "}", "else", "if", "(", "address", ">=", "0x6000", ")", "{", "// writing RAM", "t...
Write program data. This is usually used to write to cartridge RAM or mapper registers. Cartridges don't have mappers by default, but mapperless cartridges can also not be written to. This method implements the most common mapper register locations.
[ "Write", "program", "data", ".", "This", "is", "usually", "used", "to", "write", "to", "cartridge", "RAM", "or", "mapper", "registers", ".", "Cartridges", "don", "t", "have", "mappers", "by", "default", "but", "mapperless", "cartridges", "can", "also", "not"...
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cartridge.js#L152-L161
train
koenkivits/nesnes
system/cartridge.js
function( address, bank, size ) { var offset = bank * size, bankData = this.prgData.subarray( offset, offset + size ); this.prgRead.set( bankData, address - 0x8000 ); }
javascript
function( address, bank, size ) { var offset = bank * size, bankData = this.prgData.subarray( offset, offset + size ); this.prgRead.set( bankData, address - 0x8000 ); }
[ "function", "(", "address", ",", "bank", ",", "size", ")", "{", "var", "offset", "=", "bank", "*", "size", ",", "bankData", "=", "this", ".", "prgData", ".", "subarray", "(", "offset", ",", "offset", "+", "size", ")", ";", "this", ".", "prgRead", "...
Load a PRG Bank at a specific addres. @param {number} address - The absolute address to load bank at (eg. 0x8000). @param {bank} bank - Index of bank to load at given address. @param {size} size - Size of all banks.
[ "Load", "a", "PRG", "Bank", "at", "a", "specific", "addres", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cartridge.js#L169-L174
train
koenkivits/nesnes
system/cartridge.js
function( address, bank, size ) { var offset = bank * size, bankData = this.chrData.subarray( offset, offset + size ); this.chrRead.set( bankData, address ); }
javascript
function( address, bank, size ) { var offset = bank * size, bankData = this.chrData.subarray( offset, offset + size ); this.chrRead.set( bankData, address ); }
[ "function", "(", "address", ",", "bank", ",", "size", ")", "{", "var", "offset", "=", "bank", "*", "size", ",", "bankData", "=", "this", ".", "chrData", ".", "subarray", "(", "offset", ",", "offset", "+", "size", ")", ";", "this", ".", "chrRead", "...
Load a CHR Bank at a specific addres. @param {number} address - The absolute address to load bank at (eg. 0x8000). @param {bank} bank - Index of bank to load at given address. @param {size} size - Size of all banks.
[ "Load", "a", "CHR", "Bank", "at", "a", "specific", "addres", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cartridge.js#L211-L216
train
koenkivits/nesnes
system/cartridge.js
function( address ) { switch( this.mirroring ) { case HORIZONTAL: if ( address >= 0x400 ) { address -= 0x400; } if ( address >= 0x800 ) { address -= 0x400; } break; case VERTICAL: address &= 0x07ff; break; case FOUR_SCREEN: // we still don't implement any mappers that support fou...
javascript
function( address ) { switch( this.mirroring ) { case HORIZONTAL: if ( address >= 0x400 ) { address -= 0x400; } if ( address >= 0x800 ) { address -= 0x400; } break; case VERTICAL: address &= 0x07ff; break; case FOUR_SCREEN: // we still don't implement any mappers that support fou...
[ "function", "(", "address", ")", "{", "switch", "(", "this", ".", "mirroring", ")", "{", "case", "HORIZONTAL", ":", "if", "(", "address", ">=", "0x400", ")", "{", "address", "-=", "0x400", ";", "}", "if", "(", "address", ">=", "0x800", ")", "{", "a...
Map a nametable address to our internal memory, taking mirroring into account.
[ "Map", "a", "nametable", "address", "to", "our", "internal", "memory", "taking", "mirroring", "into", "account", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/cartridge.js#L221-L248
train
koenkivits/nesnes
system/output/renderer/canvas2d.js
function() { this.width = 256; this.height = 224; this.data = new Uint8Array( this.width * this.height * 4 ); for ( var i = 0; i < this.data.length; i++ ) { this.data[ i ] = 0xff; } this.context = getContext( this.el ); this.image = this.context.getImageData( 0, 0, this.width, this.height ); this...
javascript
function() { this.width = 256; this.height = 224; this.data = new Uint8Array( this.width * this.height * 4 ); for ( var i = 0; i < this.data.length; i++ ) { this.data[ i ] = 0xff; } this.context = getContext( this.el ); this.image = this.context.getImageData( 0, 0, this.width, this.height ); this...
[ "function", "(", ")", "{", "this", ".", "width", "=", "256", ";", "this", ".", "height", "=", "224", ";", "this", ".", "data", "=", "new", "Uint8Array", "(", "this", ".", "width", "*", "this", ".", "height", "*", "4", ")", ";", "for", "(", "var...
Initialize the video output.
[ "Initialize", "the", "video", "output", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/renderer/canvas2d.js#L52-L65
train
koenkivits/nesnes
system/output/renderer/canvas2d.js
function() { var color = 0, i = 0, address = 0, view = palette, buffer = new ArrayBuffer( 0xc0 ), splitPalette = new Uint8Array( buffer ); // first, re-arrange RGB values in a single array (first reds, then blues, then greens) for ( color = 0; color < 3; color +=1 ) { for ( i = 0...
javascript
function() { var color = 0, i = 0, address = 0, view = palette, buffer = new ArrayBuffer( 0xc0 ), splitPalette = new Uint8Array( buffer ); // first, re-arrange RGB values in a single array (first reds, then blues, then greens) for ( color = 0; color < 3; color +=1 ) { for ( i = 0...
[ "function", "(", ")", "{", "var", "color", "=", "0", ",", "i", "=", "0", ",", "address", "=", "0", ",", "view", "=", "palette", ",", "buffer", "=", "new", "ArrayBuffer", "(", "0xc0", ")", ",", "splitPalette", "=", "new", "Uint8Array", "(", "buffer"...
Initialize palette for video output.
[ "Initialize", "palette", "for", "video", "output", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/renderer/canvas2d.js#L70-L91
train
koenkivits/nesnes
system/output/videooutput.js
function( background, sprites, priorities ) { this.bgBuffer.set( background, this.index ); this.spriteBuffer.set( sprites, this.index ); this.prioBuffer.set( priorities, this.index ); this.index += 256; }
javascript
function( background, sprites, priorities ) { this.bgBuffer.set( background, this.index ); this.spriteBuffer.set( sprites, this.index ); this.prioBuffer.set( priorities, this.index ); this.index += 256; }
[ "function", "(", "background", ",", "sprites", ",", "priorities", ")", "{", "this", ".", "bgBuffer", ".", "set", "(", "background", ",", "this", ".", "index", ")", ";", "this", ".", "spriteBuffer", ".", "set", "(", "sprites", ",", "this", ".", "index",...
Output a scanline. @param {Uint8Array} background - Scanline background buffer @param {Uint8Array} sprites - Scanline sprite buffer @param {Uint8Array} priorities - Scanline sprite priority buffer
[ "Output", "a", "scanline", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/videooutput.js#L66-L71
train
koenkivits/nesnes
system/output/videooutput.js
function() { if ( !this.force2D && WebGLRenderer.isSupported( this.el ) ) { this.renderer = new WebGLRenderer( this.el ); } else if ( Canvas2DRenderer.isSupported( this.el ) ) { this.renderer = new Canvas2DRenderer( this.el ); } else { throw new Error( "No supported renderer!" ); } }
javascript
function() { if ( !this.force2D && WebGLRenderer.isSupported( this.el ) ) { this.renderer = new WebGLRenderer( this.el ); } else if ( Canvas2DRenderer.isSupported( this.el ) ) { this.renderer = new Canvas2DRenderer( this.el ); } else { throw new Error( "No supported renderer!" ); } }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "force2D", "&&", "WebGLRenderer", ".", "isSupported", "(", "this", ".", "el", ")", ")", "{", "this", ".", "renderer", "=", "new", "WebGLRenderer", "(", "this", ".", "el", ")", ";", "}", "else"...
Initialize renderer.
[ "Initialize", "renderer", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/videooutput.js#L85-L93
train
koenkivits/nesnes
system/output/renderer/webgl.js
function() { var gl = this.gl; var buffer = this.buffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData( gl.ARRAY_BUFFER, new Float32Array([ -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0 ]), gl.STATIC_DRAW ); }
javascript
function() { var gl = this.gl; var buffer = this.buffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, buffer); gl.bufferData( gl.ARRAY_BUFFER, new Float32Array([ -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0 ]), gl.STATIC_DRAW ); }
[ "function", "(", ")", "{", "var", "gl", "=", "this", ".", "gl", ";", "var", "buffer", "=", "this", ".", "buffer", "=", "gl", ".", "createBuffer", "(", ")", ";", "gl", ".", "bindBuffer", "(", "gl", ".", "ARRAY_BUFFER", ",", "buffer", ")", ";", "gl...
Initialize the quad to draw to.
[ "Initialize", "the", "quad", "to", "draw", "to", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/renderer/webgl.js#L69-L86
train
koenkivits/nesnes
system/output/renderer/webgl.js
function() { var gl = this.gl, program = this.program; // initialize pixel textures this.bgTexture = createTexture( 0, "bgTexture" ); this.spriteTexture = createTexture( 1, "spriteTexture" ); this.prioTexture = createTexture( 2, "prioTexture" ); // initialize palette texture this.paletteTexture...
javascript
function() { var gl = this.gl, program = this.program; // initialize pixel textures this.bgTexture = createTexture( 0, "bgTexture" ); this.spriteTexture = createTexture( 1, "spriteTexture" ); this.prioTexture = createTexture( 2, "prioTexture" ); // initialize palette texture this.paletteTexture...
[ "function", "(", ")", "{", "var", "gl", "=", "this", ".", "gl", ",", "program", "=", "this", ".", "program", ";", "// initialize pixel textures", "this", ".", "bgTexture", "=", "createTexture", "(", "0", ",", "\"bgTexture\"", ")", ";", "this", ".", "spri...
Initialize textures. One 'dynamic' texture that contains the screen pixel data, and one fixed texture containing the system palette.
[ "Initialize", "textures", ".", "One", "dynamic", "texture", "that", "contains", "the", "screen", "pixel", "data", "and", "one", "fixed", "texture", "containing", "the", "system", "palette", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/renderer/webgl.js#L93-L120
train
koenkivits/nesnes
system/output/renderer/webgl.js
function() { var gl = this.gl; var fragmentShaderSource = [ "precision mediump float;", "uniform sampler2D bgTexture;", "uniform sampler2D spriteTexture;", "uniform sampler2D prioTexture;", "uniform sampler2D paletteTexture;", "uniform vec4 bgColor;", "varying vec2 texCoord;", "void main(v...
javascript
function() { var gl = this.gl; var fragmentShaderSource = [ "precision mediump float;", "uniform sampler2D bgTexture;", "uniform sampler2D spriteTexture;", "uniform sampler2D prioTexture;", "uniform sampler2D paletteTexture;", "uniform vec4 bgColor;", "varying vec2 texCoord;", "void main(v...
[ "function", "(", ")", "{", "var", "gl", "=", "this", ".", "gl", ";", "var", "fragmentShaderSource", "=", "[", "\"precision mediump float;\"", ",", "\"uniform sampler2D bgTexture;\"", ",", "\"uniform sampler2D spriteTexture;\"", ",", "\"uniform sampler2D prioTexture;\"", "...
Initialize WebGL shaders.
[ "Initialize", "WebGL", "shaders", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/renderer/webgl.js#L125-L176
train
koenkivits/nesnes
system/output/renderer/webgl.js
function() { var gl = this.gl; var program = gl.createProgram(); gl.attachShader( program, this.vertexShader ); gl.attachShader( program, this.fragmentShader ); gl.linkProgram( program ); gl.useProgram( program ); this.program = program; }
javascript
function() { var gl = this.gl; var program = gl.createProgram(); gl.attachShader( program, this.vertexShader ); gl.attachShader( program, this.fragmentShader ); gl.linkProgram( program ); gl.useProgram( program ); this.program = program; }
[ "function", "(", ")", "{", "var", "gl", "=", "this", ".", "gl", ";", "var", "program", "=", "gl", ".", "createProgram", "(", ")", ";", "gl", ".", "attachShader", "(", "program", ",", "this", ".", "vertexShader", ")", ";", "gl", ".", "attachShader", ...
Initialize WebGL program.
[ "Initialize", "WebGL", "program", "." ]
bc11a7c34f3ccf45179bf16c0241b698b36df980
https://github.com/koenkivits/nesnes/blob/bc11a7c34f3ccf45179bf16c0241b698b36df980/system/output/renderer/webgl.js#L181-L191
train
gmrutilus/rutilus-logger-node
utils/trackedUsersCache.js
update
function update(sessionId, info) { sessionIdCache[sessionId] = info; db.collection('trackedUsersCache').update({ _id: sessionId, }, { $set: { info: info, }}, { upsert: true }, (err) => { if (errorHandler.dbErrorCatcher(err)) { retu...
javascript
function update(sessionId, info) { sessionIdCache[sessionId] = info; db.collection('trackedUsersCache').update({ _id: sessionId, }, { $set: { info: info, }}, { upsert: true }, (err) => { if (errorHandler.dbErrorCatcher(err)) { retu...
[ "function", "update", "(", "sessionId", ",", "info", ")", "{", "sessionIdCache", "[", "sessionId", "]", "=", "info", ";", "db", ".", "collection", "(", "'trackedUsersCache'", ")", ".", "update", "(", "{", "_id", ":", "sessionId", ",", "}", ",", "{", "$...
Adding the id and the information in the cache. If we already have it, we update it
[ "Adding", "the", "id", "and", "the", "information", "in", "the", "cache", ".", "If", "we", "already", "have", "it", "we", "update", "it" ]
797c6283f5c26d9677c60afa80ac99f8cfd00edc
https://github.com/gmrutilus/rutilus-logger-node/blob/797c6283f5c26d9677c60afa80ac99f8cfd00edc/utils/trackedUsersCache.js#L13-L27
train
gmrutilus/rutilus-logger-node
utils/trackedUsersCache.js
has
function has(id, cb) { // Do we have it in the local cache? if (sessionIdCache[id]) { cb(true); } // Looking in the database else { db.collection('trackedUsersCache').find({ _id: id }) .toArray((err, doc...
javascript
function has(id, cb) { // Do we have it in the local cache? if (sessionIdCache[id]) { cb(true); } // Looking in the database else { db.collection('trackedUsersCache').find({ _id: id }) .toArray((err, doc...
[ "function", "has", "(", "id", ",", "cb", ")", "{", "// Do we have it in the local cache?", "if", "(", "sessionIdCache", "[", "id", "]", ")", "{", "cb", "(", "true", ")", ";", "}", "// Looking in the database", "else", "{", "db", ".", "collection", "(", "'t...
Do we have this user's information recorded? If yes, we already tracked it at least once
[ "Do", "we", "have", "this", "user", "s", "information", "recorded?", "If", "yes", "we", "already", "tracked", "it", "at", "least", "once" ]
797c6283f5c26d9677c60afa80ac99f8cfd00edc
https://github.com/gmrutilus/rutilus-logger-node/blob/797c6283f5c26d9677c60afa80ac99f8cfd00edc/utils/trackedUsersCache.js#L32-L58
train
gmrutilus/rutilus-logger-node
utils/trackedUsersCache.js
get
function get(sessionId, cb) { has(sessionId, (hasId) => { if (hasId) { cb(sessionIdCache[sessionId]); } else { cb(); } }); }
javascript
function get(sessionId, cb) { has(sessionId, (hasId) => { if (hasId) { cb(sessionIdCache[sessionId]); } else { cb(); } }); }
[ "function", "get", "(", "sessionId", ",", "cb", ")", "{", "has", "(", "sessionId", ",", "(", "hasId", ")", "=>", "{", "if", "(", "hasId", ")", "{", "cb", "(", "sessionIdCache", "[", "sessionId", "]", ")", ";", "}", "else", "{", "cb", "(", ")", ...
What is the latest tracked information for the user? We get it from the local cache, if we have it, otherwise we fetch it from the database and record in the local cache
[ "What", "is", "the", "latest", "tracked", "information", "for", "the", "user?", "We", "get", "it", "from", "the", "local", "cache", "if", "we", "have", "it", "otherwise", "we", "fetch", "it", "from", "the", "database", "and", "record", "in", "the", "loca...
797c6283f5c26d9677c60afa80ac99f8cfd00edc
https://github.com/gmrutilus/rutilus-logger-node/blob/797c6283f5c26d9677c60afa80ac99f8cfd00edc/utils/trackedUsersCache.js#L64-L73
train
gmrutilus/rutilus-logger-node
utils/parsing.js
toObjectOrUndefined
function toObjectOrUndefined(input) { let object = input; if (typeof input === 'string') { try { object = JSON.parse(input); } catch (e) {} } if (typeof object === 'object') { return object; } return undefined; }
javascript
function toObjectOrUndefined(input) { let object = input; if (typeof input === 'string') { try { object = JSON.parse(input); } catch (e) {} } if (typeof object === 'object') { return object; } return undefined; }
[ "function", "toObjectOrUndefined", "(", "input", ")", "{", "let", "object", "=", "input", ";", "if", "(", "typeof", "input", "===", "'string'", ")", "{", "try", "{", "object", "=", "JSON", ".", "parse", "(", "input", ")", ";", "}", "catch", "(", "e",...
Accepts anything and tries to parse into a JSON object. If it fails, returns undefined. @param {*} input @returns {{}|[]|undefined}
[ "Accepts", "anything", "and", "tries", "to", "parse", "into", "a", "JSON", "object", ".", "If", "it", "fails", "returns", "undefined", "." ]
797c6283f5c26d9677c60afa80ac99f8cfd00edc
https://github.com/gmrutilus/rutilus-logger-node/blob/797c6283f5c26d9677c60afa80ac99f8cfd00edc/utils/parsing.js#L98-L108
train
gmrutilus/rutilus-logger-node
utils/parsing.js
toArrayOrUndefined
function toArrayOrUndefined(str) { if (validation.isArray(str) && str.length < 1) { return undefined; } try { let parsedArray = str; if (typeof str !== 'object') { parsedArray = JSON.parse(str); } if (validation.isArray(parsedArray) && parsedArray.lengt...
javascript
function toArrayOrUndefined(str) { if (validation.isArray(str) && str.length < 1) { return undefined; } try { let parsedArray = str; if (typeof str !== 'object') { parsedArray = JSON.parse(str); } if (validation.isArray(parsedArray) && parsedArray.lengt...
[ "function", "toArrayOrUndefined", "(", "str", ")", "{", "if", "(", "validation", ".", "isArray", "(", "str", ")", "&&", "str", ".", "length", "<", "1", ")", "{", "return", "undefined", ";", "}", "try", "{", "let", "parsedArray", "=", "str", ";", "if"...
Receives anything and parses it into an array. If it is a stringified array, it gets parsed, stringified and returned; if it is not either of these, it returns undefined @param {*} str @returns {[]|undefined}
[ "Receives", "anything", "and", "parses", "it", "into", "an", "array", ".", "If", "it", "is", "a", "stringified", "array", "it", "gets", "parsed", "stringified", "and", "returned", ";", "if", "it", "is", "not", "either", "of", "these", "it", "returns", "u...
797c6283f5c26d9677c60afa80ac99f8cfd00edc
https://github.com/gmrutilus/rutilus-logger-node/blob/797c6283f5c26d9677c60afa80ac99f8cfd00edc/utils/parsing.js#L251-L273
train
gmrutilus/rutilus-logger-node
utils/parsing.js
fromExtra
function fromExtra(value, type) { const t = (type + '').toLowerCase(); switch (t) { case 'number': return toNumberOrUndefined(value); break; case 'boolean': return toTrueOrUndefined(value); break; case 'objectarray': return t...
javascript
function fromExtra(value, type) { const t = (type + '').toLowerCase(); switch (t) { case 'number': return toNumberOrUndefined(value); break; case 'boolean': return toTrueOrUndefined(value); break; case 'objectarray': return t...
[ "function", "fromExtra", "(", "value", ",", "type", ")", "{", "const", "t", "=", "(", "type", "+", "''", ")", ".", "toLowerCase", "(", ")", ";", "switch", "(", "t", ")", "{", "case", "'number'", ":", "return", "toNumberOrUndefined", "(", "value", ")"...
Parses an ExtraInformation piece @param {*} value @param {String} type @returns {*}
[ "Parses", "an", "ExtraInformation", "piece" ]
797c6283f5c26d9677c60afa80ac99f8cfd00edc
https://github.com/gmrutilus/rutilus-logger-node/blob/797c6283f5c26d9677c60afa80ac99f8cfd00edc/utils/parsing.js#L368-L401
train
Mostafa-Samir/zip-local
main.js
augment
function augment(_opts) { var opts = _opts || {}; opts.createFolders = opts.createFolders || true; return opts; }
javascript
function augment(_opts) { var opts = _opts || {}; opts.createFolders = opts.createFolders || true; return opts; }
[ "function", "augment", "(", "_opts", ")", "{", "var", "opts", "=", "_opts", "||", "{", "}", ";", "opts", ".", "createFolders", "=", "opts", ".", "createFolders", "||", "true", ";", "return", "opts", ";", "}" ]
augments the options object with a 'createFolders' option
[ "augments", "the", "options", "object", "with", "a", "createFolders", "option" ]
938853444377beccee57865c96b2a7cead3a437b
https://github.com/Mostafa-Samir/zip-local/blob/938853444377beccee57865c96b2a7cead3a437b/main.js#L16-L20
train
cmap/morpheus.js
src/algorithm/kmeans.js
cluster
function cluster(points) { // number of clusters has to be smaller or equal the number of data points if (points.length < k) { throw 'Too many clusters'; } // create the initial clusters var clusters = chooseInitialCenters(points); // create an array containing the latest assignment of a...
javascript
function cluster(points) { // number of clusters has to be smaller or equal the number of data points if (points.length < k) { throw 'Too many clusters'; } // create the initial clusters var clusters = chooseInitialCenters(points); // create an array containing the latest assignment of a...
[ "function", "cluster", "(", "points", ")", "{", "// number of clusters has to be smaller or equal the number of data points", "if", "(", "points", ".", "length", "<", "k", ")", "{", "throw", "'Too many clusters'", ";", "}", "// create the initial clusters", "var", "cluste...
Runs the K-means++ clustering algorithm. @param points the points to cluster @return a list of clusters containing the points
[ "Runs", "the", "K", "-", "means", "++", "clustering", "algorithm", "." ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/src/algorithm/kmeans.js#L54-L93
train
cmap/morpheus.js
src/algorithm/kmeans.js
chooseInitialCenters
function chooseInitialCenters(points) { // Convert to list for indexed access. Make it unmodifiable, since removal of items // would screw up the logic of this method. var pointList = points; // The number of points in the list. var numPoints = pointList.length; // Set the corresponding elemen...
javascript
function chooseInitialCenters(points) { // Convert to list for indexed access. Make it unmodifiable, since removal of items // would screw up the logic of this method. var pointList = points; // The number of points in the list. var numPoints = pointList.length; // Set the corresponding elemen...
[ "function", "chooseInitialCenters", "(", "points", ")", "{", "// Convert to list for indexed access. Make it unmodifiable, since removal of items", "// would screw up the logic of this method.", "var", "pointList", "=", "points", ";", "// The number of points in the list.", "var", "num...
Use K-means++ to choose the initial centers. @param points the points to choose the initial centers from @return the initial centers
[ "Use", "K", "-", "means", "++", "to", "choose", "the", "initial", "centers", "." ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/src/algorithm/kmeans.js#L127-L242
train
cmap/morpheus.js
src/algorithm/kmeans.js
centroidOf
function centroidOf(points, dimension) { var centroid = new Float32Array(dimension); for (var i = 0; i < centroid.length; i++) { var sum = 0; var count = 0; for (var pointIndex = 0; pointIndex < points.length; pointIndex++) { var p = points[pointIndex]; var point = p.getPoint()...
javascript
function centroidOf(points, dimension) { var centroid = new Float32Array(dimension); for (var i = 0; i < centroid.length; i++) { var sum = 0; var count = 0; for (var pointIndex = 0; pointIndex < points.length; pointIndex++) { var p = points[pointIndex]; var point = p.getPoint()...
[ "function", "centroidOf", "(", "points", ",", "dimension", ")", "{", "var", "centroid", "=", "new", "Float32Array", "(", "dimension", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "centroid", ".", "length", ";", "i", "++", ")", "{", "v...
Computes the centroid for a set of points. @param points the set of points @param dimension the point dimension @return the computed centroid for the set of points
[ "Computes", "the", "centroid", "for", "a", "set", "of", "points", "." ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/src/algorithm/kmeans.js#L354-L371
train
cmap/morpheus.js
src/ui/file_picker.js
createPicker
function createPicker() { if (pickerApiLoaded && oauthToken) { var picker = new google.picker.PickerBuilder().addView(google.picker.ViewId.DOCS) .setOAuthToken(oauthToken) .setDeveloperKey(developerKey) .setCallback(pickerCallback) .build(); picker.setVisibl...
javascript
function createPicker() { if (pickerApiLoaded && oauthToken) { var picker = new google.picker.PickerBuilder().addView(google.picker.ViewId.DOCS) .setOAuthToken(oauthToken) .setDeveloperKey(developerKey) .setCallback(pickerCallback) .build(); picker.setVisibl...
[ "function", "createPicker", "(", ")", "{", "if", "(", "pickerApiLoaded", "&&", "oauthToken", ")", "{", "var", "picker", "=", "new", "google", ".", "picker", ".", "PickerBuilder", "(", ")", ".", "addView", "(", "google", ".", "picker", ".", "ViewId", ".",...
Create and render a Picker object for picking user Photos.
[ "Create", "and", "render", "a", "Picker", "object", "for", "picking", "user", "Photos", "." ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/src/ui/file_picker.js#L179-L190
train
cmap/morpheus.js
src/util/events.js
function (evtStr, handler) { if (!handler) { throw Error('Handler not specified'); } if (!this.eventListeners) { this.eventListeners = {}; } var events = evtStr.split(' '), len = events.length, n, event, parts, baseEvent, name; /* * loop through types and attach event listeners ...
javascript
function (evtStr, handler) { if (!handler) { throw Error('Handler not specified'); } if (!this.eventListeners) { this.eventListeners = {}; } var events = evtStr.split(' '), len = events.length, n, event, parts, baseEvent, name; /* * loop through types and attach event listeners ...
[ "function", "(", "evtStr", ",", "handler", ")", "{", "if", "(", "!", "handler", ")", "{", "throw", "Error", "(", "'Handler not specified'", ")", ";", "}", "if", "(", "!", "this", ".", "eventListeners", ")", "{", "this", ".", "eventListeners", "=", "{",...
Pass in a string of events delimmited by a space to bind multiple events at once such as 'mousedown mouseup mousemove'. Include a namespace to bind an event by name such as 'click.foobar'. @param {String} evtStr e.g. 'click', 'mousedown touchstart', 'mousedown.foo touchstart.foo' @param {Function} handler The handler ...
[ "Pass", "in", "a", "string", "of", "events", "delimmited", "by", "a", "space", "to", "bind", "multiple", "events", "at", "once", "such", "as", "mousedown", "mouseup", "mousemove", ".", "Include", "a", "namespace", "to", "bind", "an", "event", "by", "name",...
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/src/util/events.js#L16-L43
train
cmap/morpheus.js
src/util/events.js
function (evtStr, handler) { if (!this.eventListeners) { this.eventListeners = {}; } var events = (evtStr || '').split(' '), len = events.length, n, t, event, parts, baseEvent, name; if (!evtStr) { // remove all events for (t in this.eventListeners) { this._off(t, null, handler...
javascript
function (evtStr, handler) { if (!this.eventListeners) { this.eventListeners = {}; } var events = (evtStr || '').split(' '), len = events.length, n, t, event, parts, baseEvent, name; if (!evtStr) { // remove all events for (t in this.eventListeners) { this._off(t, null, handler...
[ "function", "(", "evtStr", ",", "handler", ")", "{", "if", "(", "!", "this", ".", "eventListeners", ")", "{", "this", ".", "eventListeners", "=", "{", "}", ";", "}", "var", "events", "=", "(", "evtStr", "||", "''", ")", ".", "split", "(", "' '", ...
Remove event bindings. Pass in a string of event types delimmited by a space to remove multiple event bindings at once such as 'mousedown mouseup mousemove'. include a namespace to remove an event binding by name such as 'click.foobar'. If you only give a name like '.foobar', all events in that namespace will be remove...
[ "Remove", "event", "bindings", ".", "Pass", "in", "a", "string", "of", "event", "types", "delimmited", "by", "a", "space", "to", "remove", "multiple", "event", "bindings", "at", "once", "such", "as", "mousedown", "mouseup", "mousemove", ".", "include", "a", ...
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/src/util/events.js#L89-L116
train
cmap/morpheus.js
src/tools/open_file_tool.js
function (dataset, heatMap, isColumns, sets, setSourceFileName) { var promptTool = {}; var _this = this; promptTool.execute = function (options) { var metadataName = options.input.dataset_field_name; var vector = _this.annotateSets(dataset, isColumns, sets, metadataName, setSourceFileNam...
javascript
function (dataset, heatMap, isColumns, sets, setSourceFileName) { var promptTool = {}; var _this = this; promptTool.execute = function (options) { var metadataName = options.input.dataset_field_name; var vector = _this.annotateSets(dataset, isColumns, sets, metadataName, setSourceFileNam...
[ "function", "(", "dataset", ",", "heatMap", ",", "isColumns", ",", "sets", ",", "setSourceFileName", ")", "{", "var", "promptTool", "=", "{", "}", ";", "var", "_this", "=", "this", ";", "promptTool", ".", "execute", "=", "function", "(", "options", ")", ...
prompt for metadata field name in dataset
[ "prompt", "for", "metadata", "field", "name", "in", "dataset" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/src/tools/open_file_tool.js#L437-L468
train
cmap/morpheus.js
src/ui/heat_map.js
function (mode) { this._togglingInfoWindow = true; this.options.tooltipMode = mode; this.$tipInfoWindow.html(''); this.toolbar.$tip.html(''); this.$tipFollow.html('').css({ display: 'none' }); this.toolbar.$tip.css('display', mode === 0 ? '' : 'none'); this.setToolTip(-1, -1); ...
javascript
function (mode) { this._togglingInfoWindow = true; this.options.tooltipMode = mode; this.$tipInfoWindow.html(''); this.toolbar.$tip.html(''); this.$tipFollow.html('').css({ display: 'none' }); this.toolbar.$tip.css('display', mode === 0 ? '' : 'none'); this.setToolTip(-1, -1); ...
[ "function", "(", "mode", ")", "{", "this", ".", "_togglingInfoWindow", "=", "true", ";", "this", ".", "options", ".", "tooltipMode", "=", "mode", ";", "this", ".", "$tipInfoWindow", ".", "html", "(", "''", ")", ";", "this", ".", "toolbar", ".", "$tip",...
Set where the tooltip is shown @param mode 0 is formula bar, 1 is dialog, -1 is no tooltip
[ "Set", "where", "the", "tooltip", "is", "shown" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/src/ui/heat_map.js#L2526-L2542
train
cmap/morpheus.js
js/morpheus.js
function (e) { clipboardData.forEach(function (elem) { e.clipboardData.setData(elem.format, elem.data); }); e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); fakeElem.removeEventListener('copy', f); }
javascript
function (e) { clipboardData.forEach(function (elem) { e.clipboardData.setData(elem.format, elem.data); }); e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); fakeElem.removeEventListener('copy', f); }
[ "function", "(", "e", ")", "{", "clipboardData", ".", "forEach", "(", "function", "(", "elem", ")", "{", "e", ".", "clipboardData", ".", "setData", "(", "elem", ".", "format", ",", "elem", ".", "data", ")", ";", "}", ")", ";", "e", ".", "preventDef...
fakeElem.innerHTML = html;
[ "fakeElem", ".", "innerHTML", "=", "html", ";" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/morpheus.js#L562-L571
train
cmap/morpheus.js
js/morpheus.js
function (lines) { var regex = /[ ,]+/; // header= <num_data> <num_classes> 1 var header = lines[0].split(regex); if (header.length < 3) { throw new Error('Header line needs three numbers'); } var headerNumbers = []; try { for (var i = 0; i < 3; i++) { headerNumbers[i] = ...
javascript
function (lines) { var regex = /[ ,]+/; // header= <num_data> <num_classes> 1 var header = lines[0].split(regex); if (header.length < 3) { throw new Error('Header line needs three numbers'); } var headerNumbers = []; try { for (var i = 0; i < 3; i++) { headerNumbers[i] = ...
[ "function", "(", "lines", ")", "{", "var", "regex", "=", "/", "[ ,]+", "/", ";", "// header= <num_data> <num_classes> 1", "var", "header", "=", "lines", "[", "0", "]", ".", "split", "(", "regex", ")", ";", "if", "(", "header", ".", "length", "<", "3", ...
Parses the cls file. @param lines The lines to read. @throw Error If there is a problem with the data
[ "Parses", "the", "cls", "file", "." ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/morpheus.js#L2607-L2653
train
cmap/morpheus.js
js/morpheus.js
function () { var rowCounts = new Uint32Array(nrows); var columnCounts = new Uint32Array(ncols); for (var i = 0; i < nrows; i++) { var obj = matrix[i]; if (obj.values != null) { // trim to size var values = new Uint16Array(obj.length); var indices = new Ui...
javascript
function () { var rowCounts = new Uint32Array(nrows); var columnCounts = new Uint32Array(ncols); for (var i = 0; i < nrows; i++) { var obj = matrix[i]; if (obj.values != null) { // trim to size var values = new Uint16Array(obj.length); var indices = new Ui...
[ "function", "(", ")", "{", "var", "rowCounts", "=", "new", "Uint32Array", "(", "nrows", ")", ";", "var", "columnCounts", "=", "new", "Uint32Array", "(", "ncols", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "nrows", ";", "i", "++", ...
for each row we store values and indices
[ "for", "each", "row", "we", "store", "values", "and", "indices" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/morpheus.js#L4143-L4168
train
cmap/morpheus.js
js/morpheus.js
function (seriesIndex) { this.seriesArrays.splice(seriesIndex, 1); this.seriesNames.splice(seriesIndex, 1); this.seriesDataTypes.splice(seriesIndex, 1); }
javascript
function (seriesIndex) { this.seriesArrays.splice(seriesIndex, 1); this.seriesNames.splice(seriesIndex, 1); this.seriesDataTypes.splice(seriesIndex, 1); }
[ "function", "(", "seriesIndex", ")", "{", "this", ".", "seriesArrays", ".", "splice", "(", "seriesIndex", ",", "1", ")", ";", "this", ".", "seriesNames", ".", "splice", "(", "seriesIndex", ",", "1", ")", ";", "this", ".", "seriesDataTypes", ".", "splice"...
Removes the specified series. @param seriesIndex The series index.
[ "Removes", "the", "specified", "series", "." ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/morpheus.js#L5264-L5268
train
cmap/morpheus.js
js/morpheus.js
function (newDatasetMetadataNames, currentDatasetMetadataNames, heatMap, callback) { var tool = {}; tool.execute = function (options) { return options.input; }; tool.toString = function () { return 'Select Fields'; }; tool.gui = function () { var items...
javascript
function (newDatasetMetadataNames, currentDatasetMetadataNames, heatMap, callback) { var tool = {}; tool.execute = function (options) { return options.input; }; tool.toString = function () { return 'Select Fields'; }; tool.gui = function () { var items...
[ "function", "(", "newDatasetMetadataNames", ",", "currentDatasetMetadataNames", ",", "heatMap", ",", "callback", ")", "{", "var", "tool", "=", "{", "}", ";", "tool", ".", "execute", "=", "function", "(", "options", ")", "{", "return", "options", ".", "input"...
prompt for metadata field name in dataset and in file
[ "prompt", "for", "metadata", "field", "name", "in", "dataset", "and", "in", "file" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/morpheus.js#L16340-L16368
train
cmap/morpheus.js
js/morpheus.js
function () { var items = []; for (var i = 0, length = this.getFilteredItemCount(); i < length; i++) { items.push(this.items[this.convertViewIndexToModel(i)]); } return items; }
javascript
function () { var items = []; for (var i = 0, length = this.getFilteredItemCount(); i < length; i++) { items.push(this.items[this.convertViewIndexToModel(i)]); } return items; }
[ "function", "(", ")", "{", "var", "items", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ",", "length", "=", "this", ".", "getFilteredItemCount", "(", ")", ";", "i", "<", "length", ";", "i", "++", ")", "{", "items", ".", "push", "(", ...
Gets the sorted, visible items
[ "Gets", "the", "sorted", "visible", "items" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/morpheus.js#L23791-L23797
train
cmap/morpheus.js
js/jquery.event.drag-2.3.0.js
function( obj ){ // read the interaction data var data = $.data( this, drag.datakey ), // read any passed options opts = obj.data || {}; // count another realted event data.related += 1; // extend dat...
javascript
function( obj ){ // read the interaction data var data = $.data( this, drag.datakey ), // read any passed options opts = obj.data || {}; // count another realted event data.related += 1; // extend dat...
[ "function", "(", "obj", ")", "{", "// read the interaction data", "var", "data", "=", "$", ".", "data", "(", "this", ",", "drag", ".", "datakey", ")", ",", "// read any passed options", "opts", "=", "obj", ".", "data", "||", "{", "}", ";", "// count anothe...
count bound related events
[ "count", "bound", "related", "events" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/jquery.event.drag-2.3.0.js#L52-L65
train
cmap/morpheus.js
js/jquery.event.drag-2.3.0.js
function(){ // check for related events if ( $.data( this, drag.datakey ) ) return; // initialize the drag data with copied defaults var data = $.extend({ related:0 }, drag.defaults ); // store the interaction data ...
javascript
function(){ // check for related events if ( $.data( this, drag.datakey ) ) return; // initialize the drag data with copied defaults var data = $.extend({ related:0 }, drag.defaults ); // store the interaction data ...
[ "function", "(", ")", "{", "// check for related events", "if", "(", "$", ".", "data", "(", "this", ",", "drag", ".", "datakey", ")", ")", "return", ";", "// initialize the drag data with copied defaults", "var", "data", "=", "$", ".", "extend", "(", "{", "r...
configure interaction, capture settings
[ "configure", "interaction", "capture", "settings" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/jquery.event.drag-2.3.0.js#L73-L86
train
cmap/morpheus.js
js/jquery.event.drag-2.3.0.js
function(){ var data = $.data( this, drag.datakey ) || {}; // check for related events if ( data.related ) return; // remove the stored data $.removeData( this, drag.datakey ); // remove the mousedown eve...
javascript
function(){ var data = $.data( this, drag.datakey ) || {}; // check for related events if ( data.related ) return; // remove the stored data $.removeData( this, drag.datakey ); // remove the mousedown eve...
[ "function", "(", ")", "{", "var", "data", "=", "$", ".", "data", "(", "this", ",", "drag", ".", "datakey", ")", "||", "{", "}", ";", "// check for related events", "if", "(", "data", ".", "related", ")", "return", ";", "// remove the stored data", "$", ...
destroy configured interaction
[ "destroy", "configured", "interaction" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/jquery.event.drag-2.3.0.js#L89-L103
train
cmap/morpheus.js
js/jquery.event.drag-2.3.0.js
function( event ){ // sorry, only one touch at a time if ( drag.touched ) return; // the drag/drop interaction data var dd = event.data, results; // check the which directive if ( event.which != 0 && dd.w...
javascript
function( event ){ // sorry, only one touch at a time if ( drag.touched ) return; // the drag/drop interaction data var dd = event.data, results; // check the which directive if ( event.which != 0 && dd.w...
[ "function", "(", "event", ")", "{", "// sorry, only one touch at a time", "if", "(", "drag", ".", "touched", ")", "return", ";", "// the drag/drop interaction data", "var", "dd", "=", "event", ".", "data", ",", "results", ";", "// check the which directive", "if", ...
initialize the interaction
[ "initialize", "the", "interaction" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/jquery.event.drag-2.3.0.js#L106-L159
train
cmap/morpheus.js
js/jquery.event.drag-2.3.0.js
function( elem, dd ){ var offset = (elem && elem.ownerDocument) ? $( elem )[ dd.relative ? "position" : "offset" ]() || { top:0, left:0 } : { top: 0, left: 0 }; return { drag: elem, callback: new drag.callba...
javascript
function( elem, dd ){ var offset = (elem && elem.ownerDocument) ? $( elem )[ dd.relative ? "position" : "offset" ]() || { top:0, left:0 } : { top: 0, left: 0 }; return { drag: elem, callback: new drag.callba...
[ "function", "(", "elem", ",", "dd", ")", "{", "var", "offset", "=", "(", "elem", "&&", "elem", ".", "ownerDocument", ")", "?", "$", "(", "elem", ")", "[", "dd", ".", "relative", "?", "\"position\"", ":", "\"offset\"", "]", "(", ")", "||", "{", "t...
returns an interaction object
[ "returns", "an", "interaction", "object" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/jquery.event.drag-2.3.0.js#L162-L172
train
cmap/morpheus.js
js/jquery.event.drag-2.3.0.js
function( event, type, dd, x, elem ){ // not configured if ( !dd ) return; // remember the original event and type var orig = { event:event.originalEvent, type:event.type }, // is the event drag related or drog relat...
javascript
function( event, type, dd, x, elem ){ // not configured if ( !dd ) return; // remember the original event and type var orig = { event:event.originalEvent, type:event.type }, // is the event drag related or drog relat...
[ "function", "(", "event", ",", "type", ",", "dd", ",", "x", ",", "elem", ")", "{", "// not configured", "if", "(", "!", "dd", ")", "return", ";", "// remember the original event and type", "var", "orig", "=", "{", "event", ":", "event", ".", "originalEvent...
re-use event object for custom events
[ "re", "-", "use", "event", "object", "for", "custom", "events" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/jquery.event.drag-2.3.0.js#L229-L307
train
cmap/morpheus.js
js/jquery.event.drag-2.3.0.js
function( arr ){ return $.map( arr, function( member ){ return member && member.jquery ? $.makeArray( member ) : member && member.length ? drag.flatten( member ) : member; }); }
javascript
function( arr ){ return $.map( arr, function( member ){ return member && member.jquery ? $.makeArray( member ) : member && member.length ? drag.flatten( member ) : member; }); }
[ "function", "(", "arr", ")", "{", "return", "$", ".", "map", "(", "arr", ",", "function", "(", "member", ")", "{", "return", "member", "&&", "member", ".", "jquery", "?", "$", ".", "makeArray", "(", "member", ")", ":", "member", "&&", "member", "."...
flatten nested jquery objects and arrays into a single dimension array
[ "flatten", "nested", "jquery", "objects", "and", "arrays", "into", "a", "single", "dimension", "array" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/jquery.event.drag-2.3.0.js#L340-L345
train
cmap/morpheus.js
js/tsne.js
function (n) { if (typeof(n) === 'undefined' || isNaN(n)) { return []; } if (typeof ArrayBuffer === 'undefined') { // lacking browser support var arr = new Array(n); for (var i = 0; i < n; i++) { arr[i] = 0; } return arr; } else { return new Float64Array(n); // typed arrays are faster ...
javascript
function (n) { if (typeof(n) === 'undefined' || isNaN(n)) { return []; } if (typeof ArrayBuffer === 'undefined') { // lacking browser support var arr = new Array(n); for (var i = 0; i < n; i++) { arr[i] = 0; } return arr; } else { return new Float64Array(n); // typed arrays are faster ...
[ "function", "(", "n", ")", "{", "if", "(", "typeof", "(", "n", ")", "===", "'undefined'", "||", "isNaN", "(", "n", ")", ")", "{", "return", "[", "]", ";", "}", "if", "(", "typeof", "ArrayBuffer", "===", "'undefined'", ")", "{", "// lacking browser su...
utilitity that creates contiguous vector of zeros of size n
[ "utilitity", "that", "creates", "contiguous", "vector", "of", "zeros", "of", "size", "n" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/tsne.js#L45-L59
train
cmap/morpheus.js
js/tsne.js
function (n, d, s) { var uses = typeof s !== 'undefined'; var x = []; for (var i = 0; i < n; i++) { var xhere = []; for (var j = 0; j < d; j++) { if (uses) { xhere.push(s); } else { xhere.push(randn(0.0, 1e-4)); } } x.push(xhere); } return x; }
javascript
function (n, d, s) { var uses = typeof s !== 'undefined'; var x = []; for (var i = 0; i < n; i++) { var xhere = []; for (var j = 0; j < d; j++) { if (uses) { xhere.push(s); } else { xhere.push(randn(0.0, 1e-4)); } } x.push(xhere); } return x; }
[ "function", "(", "n", ",", "d", ",", "s", ")", "{", "var", "uses", "=", "typeof", "s", "!==", "'undefined'", ";", "var", "x", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "var", "xher...
utility that returns 2d array filled with random numbers or with value s, if provided
[ "utility", "that", "returns", "2d", "array", "filled", "with", "random", "numbers", "or", "with", "value", "s", "if", "provided" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/tsne.js#L63-L78
train
cmap/morpheus.js
js/tsne.js
function (x1, x2) { var D = x1.length; var d = 0; for (var i = 0; i < D; i++) { var x1i = x1[i]; var x2i = x2[i]; d += (x1i - x2i) * (x1i - x2i); } return d; }
javascript
function (x1, x2) { var D = x1.length; var d = 0; for (var i = 0; i < D; i++) { var x1i = x1[i]; var x2i = x2[i]; d += (x1i - x2i) * (x1i - x2i); } return d; }
[ "function", "(", "x1", ",", "x2", ")", "{", "var", "D", "=", "x1", ".", "length", ";", "var", "d", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "D", ";", "i", "++", ")", "{", "var", "x1i", "=", "x1", "[", "i", "]", ...
compute L2 distance between two vectors
[ "compute", "L2", "distance", "between", "two", "vectors" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/tsne.js#L81-L90
train
cmap/morpheus.js
js/tsne.js
function (X) { var N = X.length; var dist = zeros(N * N); // allocate contiguous array for (var i = 0; i < N; i++) { for (var j = i + 1; j < N; j++) { var d = L2(X[i], X[j]); dist[i * N + j] = d; dist[j * N + i] = d; } } return dist; }
javascript
function (X) { var N = X.length; var dist = zeros(N * N); // allocate contiguous array for (var i = 0; i < N; i++) { for (var j = i + 1; j < N; j++) { var d = L2(X[i], X[j]); dist[i * N + j] = d; dist[j * N + i] = d; } } return dist; }
[ "function", "(", "X", ")", "{", "var", "N", "=", "X", ".", "length", ";", "var", "dist", "=", "zeros", "(", "N", "*", "N", ")", ";", "// allocate contiguous array", "for", "(", "var", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{...
compute pairwise distance in all vectors in X
[ "compute", "pairwise", "distance", "in", "all", "vectors", "in", "X" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/tsne.js#L93-L104
train
cmap/morpheus.js
js/tsne.js
function (X) { var N = X.length; var D = X[0].length; assert(N > 0, " X is empty? You must have some data!"); assert(D > 0, " X[0] is empty? Where is the data?"); var dists = xtod(X); // convert X to distances using gaussian kernel this.P = d2p(dists, this.perplexity, 1e-4); // attach to object thi...
javascript
function (X) { var N = X.length; var D = X[0].length; assert(N > 0, " X is empty? You must have some data!"); assert(D > 0, " X[0] is empty? Where is the data?"); var dists = xtod(X); // convert X to distances using gaussian kernel this.P = d2p(dists, this.perplexity, 1e-4); // attach to object thi...
[ "function", "(", "X", ")", "{", "var", "N", "=", "X", ".", "length", ";", "var", "D", "=", "X", "[", "0", "]", ".", "length", ";", "assert", "(", "N", ">", "0", ",", "\" X is empty? You must have some data!\"", ")", ";", "assert", "(", "D", ">", ...
this function takes a set of high-dimensional points and creates matrix P from them using gaussian kernel
[ "this", "function", "takes", "a", "set", "of", "high", "-", "dimensional", "points", "and", "creates", "matrix", "P", "from", "them", "using", "gaussian", "kernel" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/tsne.js#L217-L226
train
cmap/morpheus.js
js/tsne.js
function (D) { var N = D.length; assert(N > 0, " X is empty? You must have some data!"); // convert D to a (fast) typed array version var dists = zeros(N * N); // allocate contiguous array for (var i = 0; i < N; i++) { for (var j = i + 1; j < N; j++) { var d = D[i][j]; dists[i * N + j] = d;...
javascript
function (D) { var N = D.length; assert(N > 0, " X is empty? You must have some data!"); // convert D to a (fast) typed array version var dists = zeros(N * N); // allocate contiguous array for (var i = 0; i < N; i++) { for (var j = i + 1; j < N; j++) { var d = D[i][j]; dists[i * N + j] = d;...
[ "function", "(", "D", ")", "{", "var", "N", "=", "D", ".", "length", ";", "assert", "(", "N", ">", "0", ",", "\" X is empty? You must have some data!\"", ")", ";", "// convert D to a (fast) typed array version", "var", "dists", "=", "zeros", "(", "N", "*", "...
this function takes a given distance matrix and creates matrix P from them. D is assumed to be provided as a list of lists, and should be symmetric
[ "this", "function", "takes", "a", "given", "distance", "matrix", "and", "creates", "matrix", "P", "from", "them", ".", "D", "is", "assumed", "to", "be", "provided", "as", "a", "list", "of", "lists", "and", "should", "be", "symmetric" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/tsne.js#L231-L246
train
cmap/morpheus.js
js/tsne.js
function () { this.iter += 1; var N = this.N; var cg = this.costGrad(this.Y); // evaluate gradient var cost = cg.cost; var grad = cg.grad; // perform gradient step var ymean = zeros(this.dim); for (var i = 0; i < N; i++) { for (var d = 0; d < this.dim; d++) { var gid = grad[i][d]; ...
javascript
function () { this.iter += 1; var N = this.N; var cg = this.costGrad(this.Y); // evaluate gradient var cost = cg.cost; var grad = cg.grad; // perform gradient step var ymean = zeros(this.dim); for (var i = 0; i < N; i++) { for (var d = 0; d < this.dim; d++) { var gid = grad[i][d]; ...
[ "function", "(", ")", "{", "this", ".", "iter", "+=", "1", ";", "var", "N", "=", "this", ".", "N", ";", "var", "cg", "=", "this", ".", "costGrad", "(", "this", ".", "Y", ")", ";", "// evaluate gradient", "var", "cost", "=", "cg", ".", "cost", "...
perform a single step of optimization to improve the embedding
[ "perform", "a", "single", "step", "of", "optimization", "to", "improve", "the", "embedding" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/tsne.js#L263-L305
train
cmap/morpheus.js
js/tsne.js
function (Y) { var N = this.N; var dim = this.dim; // dim of output space var P = this.P; var pmul = this.iter < 100 ? 4 : 1; // trick that helps with local optima // compute current Q distribution, unnormalized first var Qu = zeros(N * N); var qsum = 0.0; for (var i = 0; i < N; i++) { for...
javascript
function (Y) { var N = this.N; var dim = this.dim; // dim of output space var P = this.P; var pmul = this.iter < 100 ? 4 : 1; // trick that helps with local optima // compute current Q distribution, unnormalized first var Qu = zeros(N * N); var qsum = 0.0; for (var i = 0; i < N; i++) { for...
[ "function", "(", "Y", ")", "{", "var", "N", "=", "this", ".", "N", ";", "var", "dim", "=", "this", ".", "dim", ";", "// dim of output space", "var", "P", "=", "this", ".", "P", ";", "var", "pmul", "=", "this", ".", "iter", "<", "100", "?", "4",...
return cost and gradient, given an arrangement
[ "return", "cost", "and", "gradient", "given", "an", "arrangement" ]
566784e9d77dea811c43b39dd6ed6a156d28c751
https://github.com/cmap/morpheus.js/blob/566784e9d77dea811c43b39dd6ed6a156d28c751/js/tsne.js#L336-L387
train
forbesmyester/SyncIt
makeAsync.js
function() { var args = Array.prototype.slice.call(arguments); args.unshift(null); var Factory = classFunc.bind.apply( classFunc, args ); this._inst = new Factory(); }
javascript
function() { var args = Array.prototype.slice.call(arguments); args.unshift(null); var Factory = classFunc.bind.apply( classFunc, args ); this._inst = new Factory(); }
[ "function", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "args", ".", "unshift", "(", "null", ")", ";", "var", "Factory", "=", "classFunc", ".", "bind", ".", "apply", "(", "cla...
This will create the constructor
[ "This", "will", "create", "the", "constructor" ]
f1e8e7eda7552b11f083a779e01c4fab5f073167
https://github.com/forbesmyester/SyncIt/blob/f1e8e7eda7552b11f083a779e01c4fab5f073167/makeAsync.js#L40-L48
train
rtc-io/rtc-screenshare
electron.js
simpleSelector
function simpleSelector(sources, callback) { var options = crel('select', { style: 'margin: 0.5rem' }, sources.map(function(source) { return crel('option', {id: source.id, value: source.id}, source.name); })); var selector = crel('div', { style: 'position: absolute; padding: 1rem; z-index: 9...
javascript
function simpleSelector(sources, callback) { var options = crel('select', { style: 'margin: 0.5rem' }, sources.map(function(source) { return crel('option', {id: source.id, value: source.id}, source.name); })); var selector = crel('div', { style: 'position: absolute; padding: 1rem; z-index: 9...
[ "function", "simpleSelector", "(", "sources", ",", "callback", ")", "{", "var", "options", "=", "crel", "(", "'select'", ",", "{", "style", ":", "'margin: 0.5rem'", "}", ",", "sources", ".", "map", "(", "function", "(", "source", ")", "{", "return", "cre...
This is just a simple default screen selector implementation
[ "This", "is", "just", "a", "simple", "default", "screen", "selector", "implementation" ]
0a160e73031a8b0f43111c22f48db6dbde3be305
https://github.com/rtc-io/rtc-screenshare/blob/0a160e73031a8b0f43111c22f48db6dbde3be305/electron.js#L84-L123
train
InvokIT/js-untar
src/untar.js
untar
function untar(arrayBuffer) { if (!(arrayBuffer instanceof ArrayBuffer)) { throw new TypeError("arrayBuffer is not an instance of ArrayBuffer."); } if (!global.Worker) { throw new Error("Worker implementation is not available in this environment."); } return new ProgressivePromise(function(resolve, reject, p...
javascript
function untar(arrayBuffer) { if (!(arrayBuffer instanceof ArrayBuffer)) { throw new TypeError("arrayBuffer is not an instance of ArrayBuffer."); } if (!global.Worker) { throw new Error("Worker implementation is not available in this environment."); } return new ProgressivePromise(function(resolve, reject, p...
[ "function", "untar", "(", "arrayBuffer", ")", "{", "if", "(", "!", "(", "arrayBuffer", "instanceof", "ArrayBuffer", ")", ")", "{", "throw", "new", "TypeError", "(", "\"arrayBuffer is not an instance of ArrayBuffer.\"", ")", ";", "}", "if", "(", "!", "global", ...
Returns a ProgressivePromise.
[ "Returns", "a", "ProgressivePromise", "." ]
49e639cf82e8d58dccb3458cbd08768afee8b41c
https://github.com/InvokIT/js-untar/blob/49e639cf82e8d58dccb3458cbd08768afee8b41c/src/untar.js#L12-L61
train
sidorares/hot-module-replacement
index.js
collectDependencies
function collectDependencies(module) { let paths = []; function pathsToAcceptingModules(path, root) { const requiredMe = parents[root.filename]; if (module.hot._selfAccepted) { paths.push(path.concat(root.filename)); return; } if (module.hot._selfDeclined) { retur...
javascript
function collectDependencies(module) { let paths = []; function pathsToAcceptingModules(path, root) { const requiredMe = parents[root.filename]; if (module.hot._selfAccepted) { paths.push(path.concat(root.filename)); return; } if (module.hot._selfDeclined) { retur...
[ "function", "collectDependencies", "(", "module", ")", "{", "let", "paths", "=", "[", "]", ";", "function", "pathsToAcceptingModules", "(", "path", ",", "root", ")", "{", "const", "requiredMe", "=", "parents", "[", "root", ".", "filename", "]", ";", "if", ...
module is changed, which dependency needs to be reloaded?
[ "module", "is", "changed", "which", "dependency", "needs", "to", "be", "reloaded?" ]
2af226b9e8fd1ce75b40b96c0920f053e92db450
https://github.com/sidorares/hot-module-replacement/blob/2af226b9e8fd1ce75b40b96c0920f053e92db450/index.js#L22-L47
train
dstreet/dependsOn
src/dependency.js
getFieldState
function getFieldState($ele) { var val = $ele.val() // If dependency is a radio group, then filter by `:checked` if ($ele.attr('type') === 'radio') { val = $ele.filter(':checked').val() } return { value: val, checked: $ele.is(':checked'), disabled: $ele.is(':disabled'), selected: $ele.is(':selected') ...
javascript
function getFieldState($ele) { var val = $ele.val() // If dependency is a radio group, then filter by `:checked` if ($ele.attr('type') === 'radio') { val = $ele.filter(':checked').val() } return { value: val, checked: $ele.is(':checked'), disabled: $ele.is(':disabled'), selected: $ele.is(':selected') ...
[ "function", "getFieldState", "(", "$ele", ")", "{", "var", "val", "=", "$ele", ".", "val", "(", ")", "// If dependency is a radio group, then filter by `:checked`", "if", "(", "$ele", ".", "attr", "(", "'type'", ")", "===", "'radio'", ")", "{", "val", "=", "...
Get the current state of a field @param {jQuery} $ele The element @return {Object} @private
[ "Get", "the", "current", "state", "of", "a", "field" ]
a40100652aa6a6f7748bf3cd761578b34b82d547
https://github.com/dstreet/dependsOn/blob/a40100652aa6a6f7748bf3cd761578b34b82d547/src/dependency.js#L311-L325
train