_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
|---|---|---|---|---|---|
q47200
|
mapDispatchToProps
|
train
|
function mapDispatchToProps(dispatch) {
return {
onChangeArr: (arr) => dispatch(changeArr(arr)),
onChangeFoo: (foo) => dispatch(changeFoo(foo)),
onChangeBar: (bar) => dispatch(changeBar(bar)),
onChangeBaz: (baz) => dispatch(changeBaz(baz)),
onChangeMany: (foo) => dispatch(changeMany({ foo })),
};
}
|
javascript
|
{
"resource": ""
}
|
q47201
|
mapUrlToProps
|
train
|
function mapUrlToProps(url, props) {
return {
foo: decode(UrlQueryParamTypes.number, url.fooInUrl),
bar: url.bar,
};
}
|
javascript
|
{
"resource": ""
}
|
q47202
|
mapUrlChangeHandlersToProps
|
train
|
function mapUrlChangeHandlersToProps(props) {
return {
onChangeFoo: (value) => replaceInUrlQuery('fooInUrl', encode(UrlQueryParamTypes.number, value)),
onChangeBar: (value) => replaceInUrlQuery('bar', value),
}
}
|
javascript
|
{
"resource": ""
}
|
q47203
|
multiUpdateInLocation
|
train
|
function multiUpdateInLocation(queryReplacements, location) {
location = getLocation(location);
// if a query is there, use it, otherwise parse the search string
const currQuery = location.query || parseQueryString(location.search);
const newQuery = {
...currQuery,
...queryReplacements,
};
// remove if it is nully or an empty string when encoded
Object.keys(queryReplacements).forEach(queryParam => {
const encodedValue = queryReplacements[queryParam];
if (encodedValue == null || encodedValue === '') {
delete newQuery[queryParam];
}
});
const newLocation = mergeLocationQueryOrSearch(location, newQuery);
// remove the key from the location
delete newLocation.key;
return newLocation;
}
|
javascript
|
{
"resource": ""
}
|
q47204
|
app
|
train
|
function app(state = {}, action) {
switch (action.type) {
case CHANGE_BAZ:
return {
...state,
baz: action.payload,
};
default:
return state;
}
}
|
javascript
|
{
"resource": ""
}
|
q47205
|
runTool
|
train
|
function runTool(platform, args_, done) {
var args = optimist.argv;
var allzones = args['allzones'];
var inputFile = args['_'][0];
if (!inputFile) {
console.log('usage: dump.js [--allzones] file.wtf-trace');
done(1);
return;
}
console.log('Dumping ' + inputFile + '...');
console.log('');
wtf.db.load(inputFile, function(db) {
if (db instanceof Error) {
console.log('ERROR: unable to open ' + inputFile, db, db.stack);
done(1);
} else {
done(dumpDatabase(db, allzones));
}
});
}
|
javascript
|
{
"resource": ""
}
|
q47206
|
dumpDatabase
|
train
|
function dumpDatabase(db, allzones) {
var sources = db.getSources();
for (var n = 0; n < sources.length; n++) {
util.logContextInfo(sources[n].getContextInfo());
}
var zones = db.getZones();
if (!zones.length) {
console.log('No zones');
return 0;
}
var count = allzones ? zones.length : 1;
for (var i = 0; i < count; ++i) {
var zone = zones[i];
var eventList = zone.getEventList();
var it = eventList.begin();
for (; !it.done(); it.next()) {
util.logEvent(it, zone);
}
}
return 0;
}
|
javascript
|
{
"resource": ""
}
|
q47207
|
finishLoad
|
train
|
function finishLoad() {
// Pick a title, unless one was specified.
var title = opt_title || this.generateTitleFromEntries_(entries);
this.mainDisplay_.setTitle(title);
// Show the document.
var documentView = this.mainDisplay_.openDocument(doc);
goog.asserts.assert(documentView);
// Zoom to fit.
// TODO(benvanik): remove setTimeout when zoomToFit is based on view.
wtf.timing.setTimeout(50, function() {
documentView.zoomToFit();
}, this);
}
|
javascript
|
{
"resource": ""
}
|
q47208
|
acquireMemoryObserver
|
train
|
function acquireMemoryObserver() {
// Only enable on first use.
++memoryObservationCount;
if (memoryObservationCount > 1) {
return;
}
// Enable memory notification.
setTemporaryPreference('javascript.options.mem.notify', true);
// Listen for events.
Services.obs.addObserver(
handleMemoryEvent, 'garbage-collection-statistics', false);
}
|
javascript
|
{
"resource": ""
}
|
q47209
|
releaseMemoryObserver
|
train
|
function releaseMemoryObserver() {
// Only disable on last use.
if (!memoryObservationCount) {
return;
}
--memoryObservationCount;
if (memoryObservationCount) {
return;
}
// Unlisten for events.
Services.obs.removeObserver(
handleMemoryEvent, 'garbage-collection-statistics', false);
// Reset memory notification to its original state.
resetTemporaryPreference('javascript.options.mem.notify');
}
|
javascript
|
{
"resource": ""
}
|
q47210
|
getCanonicalUrl
|
train
|
function getCanonicalUrl(url) {
// Trim the #fragment. We are unique to query string, though.
var hashIndex = url.indexOf('#');
if (hashIndex != -1) {
url = url.substring(0, hashIndex);
}
return url;
}
|
javascript
|
{
"resource": ""
}
|
q47211
|
train
|
function(url, worker) {
/**
* Page URL.
* @type {string}
*/
this.url = url;
/**
* Firefox tab handle.
* @type {!Tab}
*/
this.tab = worker.tab;
/**
* Page worker running the content script.
* @type {!Worker}
*/
this.worker = worker;
/**
* Pending debugger records.
* These are batched up so that we don't throw too many messages at the page.
* @type {!Array.<!Object>}
* @private
*/
this.debuggerRecords_ = [];
/**
* Periodic timer to transmit debugger data.
* @type {number}
* @private
*/
this.debuggerTransmitId_ = timers.setInterval((function() {
var records = this.debuggerRecords_;
if (records.length) {
this.debuggerRecords_ = [];
this.worker.port.emit('extension-event', JSON.stringify({
'command': 'debugger_data',
'records': records
}));
}
}).bind(this), 1000);
// Start watching GC events.
acquireMemoryObserver();
}
|
javascript
|
{
"resource": ""
}
|
|
q47212
|
enableInjectionForUrl
|
train
|
function enableInjectionForUrl(url) {
var url = getCanonicalUrl(url);
if (activePageMods[url]) {
return;
}
// Enable injection.
setPagePreference(url, 'enabled', true);
// Grab current options. Note that if they change we need to re-enable
// injection to update the pagemod.
var pagePrefs = getPagePreferences(url);
var storedOptions = {};
try {
storedOptions = JSON.parse(pagePrefs.options);
} catch (e) {
}
// Override defaults with specified values.
// Except for a few that we don't want to track across session.
var pageOptions = {
// The presence of this indicates that the options come from the injector.
'wtf.injector': true,
// Larger buffers mean less waste when doing recordings with a large amount
// of data (like WebGL captures).
'wtf.trace.session.bufferSize': 6 * 1024 * 1024,
// This is pretty excessive, but keeps us from truncating WebGL traces.
// After this limit the file likely won't load due to v8 memory limits
// anyway.
'wtf.trace.session.maximumMemoryUsage': 512 * 1024 * 1024,
// TODO(benvanik): endpoints
// 'wtf.hud.app.mode': '',
// 'wtf.hud.app.endpoint': '',
'wtf.trace.provider.firefoxDebug.present': true,
// Turn on embed remote images by default.
// When we have the UI in the extension and can fetch non-origin URLs this
// won't be required. Note that we allow the page to override this setting.
'wtf.trace.provider.webgl.embedRemoteImages': true
};
for (var key in storedOptions) {
switch (key) {
case 'wtf.injector':
case 'wtf.hud.app.mode':
case 'wtf.hud.app.endpoint':
case 'wtf.addons':
case 'wtf.trace.provider.firefoxDebug.present':
continue;
}
pageOptions[key] = storedOptions[key];
}
// Create a page mod for the given URLs.
var mod = pageMod.PageMod({
include: [
url,
url + '#*'
],
contentScriptFile: self.data.url('content-script.js'),
contentScriptWhen: 'start',
contentScriptOptions: {
// Accessible as self.options in the content script.
wtfScriptContents: wtfScriptContents,
wtfOptions: pageOptions
},
attachTo: 'top',
onAttach: function(worker) {
var injectedTab = new InjectedTab(url, worker);
injectedTabs.push(injectedTab);
console.log('added worker for ' + url);
worker.port.on('page-event', function(data) {
injectedTab.dispatchEvent(JSON.parse(data));
});
worker.on('detach', function() {
console.log('detached worker for ' + url);
injectedTab.dispose();
for (var n = 0; n < injectedTabs.length; n++) {
if (injectedTabs[n].worker == worker) {
injectedTabs.splice(n, 1);
break;
}
}
});
}
});
activePageMods[url] = mod;
// Find tabs with the URL and reload.
reloadTabsMatchingUrl(url);
}
|
javascript
|
{
"resource": ""
}
|
q47213
|
disableInjectionForUrl
|
train
|
function disableInjectionForUrl(url, opt_skipReload) {
var url = getCanonicalUrl(url);
// Disable injection.
setPagePreference(url, 'enabled', false);
// Find existing page mod and disable.
// This will detach workers in those tabs.
var mod = activePageMods[url];
if (!mod) {
return;
}
mod.destroy();
delete activePageMods[url];
if (!opt_skipReload) {
// Find tabs with the URL and reload.
reloadTabsMatchingUrl(url);
}
}
|
javascript
|
{
"resource": ""
}
|
q47214
|
toggleInjectionForActiveTab
|
train
|
function toggleInjectionForActiveTab() {
var url = tabs.activeTab.url;
if (!isInjectionEnabledForUrl(url)) {
enableInjectionForUrl(url);
} else {
disableInjectionForUrl(url);
}
}
|
javascript
|
{
"resource": ""
}
|
q47215
|
resetOptionsForActiveTab
|
train
|
function resetOptionsForActiveTab() {
var url = getCanonicalUrl(tabs.activeTab.url);
setPagePreference(url, 'options', '');
if (isInjectionEnabledForUrl(url)) {
disableInjectionForUrl(url, true);
enableInjectionForUrl(url);
}
}
|
javascript
|
{
"resource": ""
}
|
q47216
|
setupContextMenu
|
train
|
function setupContextMenu() {
var enableContextMenuItem = contextMenu.Item({
label: 'Enable For This URL',
data: 'toggle',
contentScript:
"self.on('context', function(node) {" +
" var hasWtf = !!document.querySelector('.wtf_a');" +
" return !hasWtf ? 'Enable For This URL' : 'Disable For This URL';" +
"});"
});
var resetSettingsContextMenuItem = contextMenu.Item({
label: 'Reset Settings For This URL',
data: 'reset'
});
var showUiContextMenuItem = contextMenu.Item({
label: 'Show UI',
data: 'show_ui'
});
var rootContextMenuItem = contextMenu.Menu({
label: 'Tracing Framework',
items: [
enableContextMenuItem,
resetSettingsContextMenuItem,
contextMenu.Separator(),
showUiContextMenuItem
],
contentScript:
"self.on('click', function(node, data) {" +
" self.postMessage(data);" +
"});",
onMessage: function(action) {
switch (action) {
case 'toggle':
toggleInjectionForActiveTab();
break;
case 'reset':
resetOptionsForActiveTab();
break;
case 'show_ui':
showUi();
break;
}
}
});
}
|
javascript
|
{
"resource": ""
}
|
q47217
|
setupAddonBarWidget
|
train
|
function setupAddonBarWidget() {
var panel = panels.Panel({
width: 200,
height: 128,
contentURL: self.data.url('widget-panel.html'),
contentScriptFile: self.data.url('widget-panel.js')
});
panel.on('show', function() {
var url = getCanonicalUrl(tabs.activeTab.url);
if (!url.length) {
panel.port.emit('show', null);
} else {
panel.port.emit('show', {
'enabled': isInjectionEnabledForUrl(url)
});
}
});
panel.port.on('perform', function(action) {
switch (action) {
case 'toggle':
toggleInjectionForActiveTab();
panel.hide();
break;
case 'reset':
resetOptionsForActiveTab();
panel.hide();
break;
case 'show_ui':
showUi();
panel.hide();
break;
}
});
var widget = widgets.Widget({
id: 'wtf-toggle',
label: 'Toggle Web Tracing Framework',
contentURL: self.data.url('widget.html'),
contentScriptFile: self.data.url('widget.js'),
panel: panel
});
// Update the widget icon when the URL changes.
function tabChanged() {
var url = getCanonicalUrl(tabs.activeTab.url);
widget.port.emit('update', {
'enabled': url.length ? isInjectionEnabledForUrl(url) : false
});
};
tabs.on('open', tabChanged);
tabs.on('close', tabChanged);
tabs.on('ready', tabChanged);
tabs.on('activate', tabChanged);
tabs.on('deactivate', tabChanged);
}
|
javascript
|
{
"resource": ""
}
|
q47218
|
tabChanged
|
train
|
function tabChanged() {
var url = getCanonicalUrl(tabs.activeTab.url);
widget.port.emit('update', {
'enabled': url.length ? isInjectionEnabledForUrl(url) : false
});
}
|
javascript
|
{
"resource": ""
}
|
q47219
|
prepareDebug
|
train
|
function prepareDebug() {
// Import Closure Library and deps.js.
require('../src/wtf/bootstrap/node').importClosureLibrary([
'wtf_js-deps.js'
]);
// Disable asserts unless debugging - asserts cause all code to deopt.
if (debugMode) {
goog.require('goog.asserts');
goog.asserts.assert = function(condition, opt_message) {
console.assert(condition, opt_message);
return condition;
};
} else {
goog.DEBUG = false;
goog.require('goog.asserts');
goog.asserts.assert = function(condition) {
return condition;
};
}
// Load WTF and configure options.
goog.require('wtf');
wtf.NODE = true;
goog.require('wtf.db.exports');
goog.require('wtf.db.node');
}
|
javascript
|
{
"resource": ""
}
|
q47220
|
prepareRelease
|
train
|
function prepareRelease() {
// Load WTF binary. Search a few paths.
// TODO(benvanik): look in ENV?
var searchPaths = [
'.',
'./build-out',
'../build-out'
];
var modulePath = path.dirname(module.filename);
var wtfPath = null;
for (var n = 0; n < searchPaths.length; n++) {
var searchPath = path.join(
searchPaths[n], 'wtf_node_js_compiled.js');
searchPath = path.join(modulePath, searchPath);
if (fs.existsSync(searchPath)) {
wtfPath = path.relative(modulePath, searchPath);
break;
}
}
if (!wtfPath) {
console.log('Unable to find wtf_node_js_compiled.js');
process.exit(-1);
return;
}
var wtf = require(wtfPath.replace('.js', ''));
global.wtf = wtf;
}
|
javascript
|
{
"resource": ""
}
|
q47221
|
createTabPanel
|
train
|
function createTabPanel(path, name, options, callback) {
tabbar.addPanel(new wtf.app.AddonTabPanel(
addon, documentView, path, name, options, callback));
}
|
javascript
|
{
"resource": ""
}
|
q47222
|
getFunctionName
|
train
|
function getFunctionName(node) {
function cleanupName(name) {
return name.replace(/[ \n]/g, '');
};
// Simple case of:
// function foo() {}
if (node.id) {
return cleanupName(node.id.name);
}
// get foo() {};
if (node.parent.kind == 'get' || node.parent.kind == 'set') {
return cleanupName(node.parent.key.name);
}
// var foo = function() {};
if (node.parent.type == 'VariableDeclarator') {
if (node.parent.id) {
return cleanupName(node.parent.id.name);
}
log('unknown var decl', node.parent);
return null;
}
// {foo: function() {}}
// {"foo": function() {}}
// {1: function() {}}
if (node.parent.type == 'Property') {
return cleanupName(node.parent.key.name || ''+node.parent.key.value);
}
// foo = function() {};
// Bar.foo = function() {};
if (node.parent.type == 'AssignmentExpression') {
// We are the RHS, LHS is something else.
var left = node.parent.left;
if (left.type == 'MemberExpression') {
// Bar.foo = function() {};
// left.object {type: 'Identifier', name: 'Bar'}
// left.property {type: 'Identifier', name: 'foo'}
// Object can be recursive MemberExpression's:
// Bar.prototype.foo = function() {};
// left.object {type: 'MemberExpression', ...}
// left.property {type: 'Identifier', name: 'foo'}
return cleanupName(left.source());
} else if (left.type == 'Identifier') {
return cleanupName(left.name);
}
log('unknown assignment LHS', left);
}
//log('unknown fn construct', node);
// TODO(benvanik): support jscompiler prototype alias:
// _.$JSCompiler_prototypeAlias$$ = _.$something;
// ...
// _.$JSCompiler_prototypeAlias$$.$unnamed = function() {};
// Recognize dart2js names.
var ret = null;
while (node.parent != null) {
node = node.parent;
if (node.type == 'Property') {
if (!ret) {
ret = node.key.name;
} else {
ret = node.key.name + '.' + ret;
}
}
}
return ret;
}
|
javascript
|
{
"resource": ""
}
|
q47223
|
setupAddBox
|
train
|
function setupAddBox() {
var addBox = document.querySelector('.addRow input');
addBox.oninput = function() {
if (addBox.value == '') {
clearError();
return;
}
fetchAddonManifest(addBox.value);
};
function fetchAddonManifest(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onerror = function() {
setError();
};
xhr.onload = function() {
var contentType = xhr.getResponseHeader('content-type') || '';
if (xhr.status != 200 ||
contentType.indexOf('/json') == -1) {
setError();
return;
}
var manifest;
try {
manifest = JSON.parse(xhr.responseText);
} catch (e) {
}
if (!manifest) {
setError();
return;
}
clearError();
addAddon(url, manifest);
};
try {
xhr.send(null);
} catch (e) {
setError();
}
};
function setError() {
addBox.classList.add('kTextFieldError');
};
function clearError() {
addBox.classList.remove('kTextFieldError');
};
function addAddon(url, manifest) {
_gaq.push(['_trackEvent', 'popup', 'addon_added']);
addBox.value = '';
port.postMessage({
command: 'add_addon',
url: url,
manifest: manifest
});
port.postMessage({
command: 'toggle_addon',
enabled: true,
url: url
});
};
}
|
javascript
|
{
"resource": ""
}
|
q47224
|
updateWithInfo
|
train
|
function updateWithInfo(info) {
var disableOverlay = document.querySelector('.disableOverlay');
var stopRecordingButton = document.querySelector('.buttonStopRecording');
var status = info.status;
switch (status) {
case 'instrumented':
// Instrumentation is enabled for the page.
disableOverlay.style.display = '';
stopRecordingButton.innerText = 'Stop Recording';
break;
case 'whitelisted':
// Tracing is enabled for the page.
disableOverlay.style.display = '';
stopRecordingButton.innerText = 'Stop Recording For This URL';
break;
default:
// Tracing is disabled for the page.
disableOverlay.style.display = 'none';
stopRecordingButton.innerText = '';
break;
}
buildAddonTable(info.all_addons, info.options['wtf.addons']);
}
|
javascript
|
{
"resource": ""
}
|
q47225
|
buildAddonTable
|
train
|
function buildAddonTable(addons, enabledAddons) {
var tbody = document.querySelector('.addonPicker tbody');
// Remove all old content.
while (tbody.firstChild) {
tbody.firstChild.remove();
}
// Add empty row.
if (!addons.length) {
var tr = document.createElement('tr');
tr.className = 'emptyRow';
var td = document.createElement('td');
td.innerText = 'No addons added.';
tr.appendChild(td);
tbody.appendChild(tr);
}
// Build the table.
for (var n = 0; n < addons.length; n++) {
var extension = addons[n];
addExtensionRow(extension);
}
function addExtensionRow(extension) {
var isEnabled = enabledAddons.indexOf(extension.url) >= 0;;
var td = document.createElement('td');
var input = document.createElement('input');
input.type = 'checkbox';
input.checked = isEnabled;
td.appendChild(input);
var span = document.createElement('span');
span.innerText = extension.manifest.name;
span.title = extension.url;
td.appendChild(span);
var remove = document.createElement('td');
remove.className = 'remove';
var removeImg = document.createElement('img');
removeImg.title = 'Remove extension';
remove.appendChild(removeImg);
var tr = document.createElement('tr');
tr.appendChild(td);
tr.appendChild(remove);
tbody.appendChild(tr);
function changed() {
_gaq.push(['_trackEvent', 'popup', 'addon_toggled']);
port.postMessage({
command: 'toggle_extension',
enabled: input.checked,
url: extension.url
});
};
input.onchange = function() {
changed();
};
span.onclick = function() {
input.checked = !input.checked;
changed();
};
remove.onclick = function() {
_gaq.push(['_trackEvent', 'popup', 'addon_removed']);
if (isEnabled) {
port.postMessage({
command: 'toggle_addon',
enabled: false,
url: extension.url
});
}
port.postMessage({
command: 'remove_addon',
url: extension.url
});
};
};
}
|
javascript
|
{
"resource": ""
}
|
q47226
|
openFileClicked
|
train
|
function openFileClicked() {
var inputElement = document.createElement('input');
inputElement['type'] = 'file';
inputElement['multiple'] = true;
inputElement['accept'] = [
'.wtf-trace,application/x-extension-wtf-trace',
'.wtf-json,application/x-extension-wtf-json',
'.wtf-calls,application/x-extension-wtf-calls',
'.cpuprofile,application/x-extension-cpuprofile',
'.part,application/x-extension-part'
].join(',');
inputElement.onchange = function(e) {
_gaq.push(['_trackEvent', 'popup', 'open_file']);
var fileEntries = [];
for (var n = 0; n < inputElement.files.length; n++) {
var file = inputElement.files[n];
var blob = new Blob([file], {
type: 'application/octet-stream'
});
var blobUrl = URL.createObjectURL(blob);
fileEntries.push({
name: file.name,
url: blobUrl,
size: blob.size
});
}
port.postMessage({
command: 'show_files',
files: fileEntries
});
window.close();
};
inputElement.click();
}
|
javascript
|
{
"resource": ""
}
|
q47227
|
instrumentMemoryClicked
|
train
|
function instrumentMemoryClicked() {
_gaq.push(['_trackEvent', 'popup', 'instrument_memory']);
try {
new Function('return %GetHeapUsage()');
} catch (e) {
// Pop open docs page.
port.postMessage({
command: 'instrument',
type: 'memory',
needsHelp: true
});
return;
}
port.postMessage({
command: 'instrument',
type: 'memory'
});
window.close();
}
|
javascript
|
{
"resource": ""
}
|
q47228
|
createInjectionShim
|
train
|
function createInjectionShim(scriptUrl, workerId) {
// Hacky handling for blob URLs.
// Unfortunately Chrome doesn't like importScript on blobs inside of the
// workers, so we need to embed it.
var resolvedScriptUrl = null;
var scriptContents = null;
if (goog.string.startsWith(scriptUrl, 'blob:')) {
var xhr = new (goog.global['XMLHttpRequest']['raw'] || XMLHttpRequest)();
xhr.open('GET', scriptUrl, false);
xhr.send();
scriptContents = xhr.response;
} else {
resolvedScriptUrl = goog.Uri.resolve(baseUri, scriptUrl).toString();
}
var shimScriptLines = [
'this.WTF_WORKER_ID = ' + workerId + ';',
'this.WTF_WORKER_BASE_URI = "' + goog.global.location.href + '";',
'importScripts("' + wtfUrl + '");',
'wtf.trace.prepare({',
'});',
'wtf.trace.start();'
];
// Add the script import or directly embed the contents.
if (resolvedScriptUrl) {
shimScriptLines.push('importScripts("' + resolvedScriptUrl + '");');
} else if (scriptContents) {
shimScriptLines.push('// Embedded: ' + scriptUrl);
shimScriptLines.push(scriptContents);
}
var shimBlob = new Blob([shimScriptLines.join('\n')], {
'type': 'text/javascript'
});
var shimScriptUrl = goog.fs.createObjectUrl(shimBlob);
return shimScriptUrl;
}
|
javascript
|
{
"resource": ""
}
|
q47229
|
train
|
function(scriptUrl) {
goog.base(this, descriptor);
/**
* Tracking ID.
* @type {number}
* @private
*/
this.workerId_ = nextWorkerId++;
// Create the child worker.
// If we are injecting generate a shim script and use that.
var newScriptUrl = scriptUrl;
if (injecting) {
newScriptUrl = createInjectionShim(scriptUrl, this.workerId_);
}
var scope = workerCtorEvent(scriptUrl, this.workerId_);
goog.global['Worker'] = originalWorker;
var previousGlobalWorker = goog.global['Worker'];
var handle;
try {
handle = new originalWorker(newScriptUrl);
} finally {
goog.global['Worker'] = previousGlobalWorker;
wtf.trace.leaveScope(scope);
}
/**
* Handle to the underlying worker instance.
* @type {!Worker}
* @private
*/
this.handle_ = handle;
/**
* Event type trackers, by name.
* @type {!Object.<Function>}
* @private
*/
this.trackers_ = {};
this.setEventHook('error', function(e) {
wtf.trace.appendScopeData('id', this.workerId_);
}, this);
this.setEventHook('message', function(e) {
wtf.trace.appendScopeData('id', this.workerId_);
}, this);
// Always hook onmessage.
// By doing it here we get first access to the event.
var self = this;
this.handle_.addEventListener('message', function(e) {
// Sniff provider messages.
if (!e.data['__wtf_worker_msg__']) {
return;
}
e['__wtf_ignore__'] = true;
var value = e.data['value'];
switch (e.data['command']) {
case 'snapshot':
var result = pendingSnapshots[value['id']];
delete pendingSnapshots[value['id']];
if (!result.getError()) {
result.setValue(value['data']);
}
break;
case 'close':
goog.array.remove(provider.childWorkers_, self);
break;
}
}, false);
provider.childWorkers_.push(this);
}
|
javascript
|
{
"resource": ""
}
|
|
q47230
|
sendMessage
|
train
|
function sendMessage(command, opt_value, opt_transfer) {
// TODO(benvanik): attempt to use webkitPostMessage
originalPostMessage.call(goog.global, {
'__wtf_worker_msg__': true,
'command': command,
'value': opt_value || null
}, []);
}
|
javascript
|
{
"resource": ""
}
|
q47231
|
runTool
|
train
|
function runTool(platform, args, done) {
var inputFile1 = args[0];
var inputFile2 = args[1];
var filterString = args[2];
if (!inputFile1 || !inputFile2) {
console.log('usage: diff.js file1.wtf-trace file2.wtf-trace [filter]');
done(1);
return;
}
console.log('Diffing ' + inputFile1 + ' and ' + inputFile2 + '...');
console.log('');
var filter = null;
if (filterString) {
filter = new wtf.db.Filter(filterString);
}
// Create databases for querying.
var db1 = null;
var db2 = null;
wtf.db.load(inputFile1, function(db) {
if (db instanceof Error) {
console.log('ERROR: unable to open ' + inputFile1, db);
done(1);
return;
}
db1 = db;
if (db1 && db2) {
diffDatabases(db1, db2, filter);
done(0);
}
});
wtf.db.load(inputFile2, function(db) {
if (db instanceof Error) {
console.log('ERROR: unable to open ' + inputFile2, db);
done(1);
return;
}
db2 = db;
if (db1 && db2) {
diffDatabases(db1, db2, filter);
done(0);
}
});
}
|
javascript
|
{
"resource": ""
}
|
q47232
|
computeNodeLinks
|
train
|
function computeNodeLinks() {
nodes.forEach(function(node) {
node.sourceLinks = [];
node.targetLinks = [];
});
links.forEach(function(link) {
var source = link.source,
target = link.target;
if (typeof source === "number") source = link.source = nodes[link.source];
if (typeof target === "number") target = link.target = nodes[link.target];
source.sourceLinks.push(link);
target.targetLinks.push(link);
});
}
|
javascript
|
{
"resource": ""
}
|
q47233
|
injectScriptFunction
|
train
|
function injectScriptFunction(fn, opt_args) {
// Format args as strings that can go in the source.
var args = opt_args || [];
for (var n = 0; n < args.length; n++) {
if (args[n] === undefined) {
args[n] = 'undefined';
} else if (args[n] === null) {
args[n] = 'null';
} else if (typeof args[n] == 'string') {
// TODO(benvanik): escape
args[n] = '"' + args[n] + '"';
} else if (typeof args[n] == 'object') {
args[n] = JSON.stringify(args[n]);
}
}
args = args.join(',');
// TODO(benvanik): escape fn source
var source = [
'(' + String(fn) + ')(' + args + ');',
'// Web Tracing Framework injected function: ' + fn.name,
'//# sourceURL=x://wtf-injector/' + fn.name
].join('\n');
// Create script tag.
var script = document.createElement('script');
script.text = source;
// Add to page.
injectScriptTag(script);
}
|
javascript
|
{
"resource": ""
}
|
q47234
|
injectScriptFile
|
train
|
function injectScriptFile(url, rawText) {
var filename = url;
var lastSlash = url.lastIndexOf('/');
if (lastSlash != -1) {
filename = url.substr(lastSlash + 1);
}
var source = [
'(function() {' + rawText + '})();',
'// Web Tracing Framework injected file: ' + url,
'//# sourceURL=x://wtf-injector/' + filename
].join('\n');
// Setup script tag with the raw source.
var script = document.createElement('script');
script.type = 'text/javascript';
script.text = source;
// Add to page.
injectScriptTag(script);
}
|
javascript
|
{
"resource": ""
}
|
q47235
|
startTracing
|
train
|
function startTracing(addons) {
// NOTE: this code is injected by string and cannot access any closure
// variables!
// Register addons.
for (var url in addons) {
var name = addons[url]['name'];
log('WTF Addon Installed: ' + name + ' (' + url + ')');
wtf.addon.registerAddon(url, addons[url]);
}
// Show HUD.
wtf.hud.prepare();
// Start recording.
wtf.trace.start();
}
|
javascript
|
{
"resource": ""
}
|
q47236
|
XMLHttpRequest
|
train
|
function XMLHttpRequest() {
var scope = ctorEvent();
goog.base(this, descriptor);
/**
* Real XHR.
* @type {!XMLHttpRequest}
* @private
*/
this.handle_ = new originalXhr();
/**
* Event type trackers, by name.
* @type {!Object.<Function>}
* @private
*/
this.trackers_ = {};
/**
* Properties, accumulated during setup before send().
* @type {!Object}
* @private
*/
this.props_ = {
'method': null,
'url': null,
'async': true,
'user': null,
'headers': {},
'timeout': 0,
'withCredentials': false,
'overrideMimeType': null,
'responseType': ''
};
/**
* Active flow, if any.
* @type {wtf.trace.Flow}
* @private
*/
this.flow_ = null;
// Always hook onreadystatechange.
// By doing it here we get first access to the event.
var self = this;
var handle = this.handle_;
var props = this.props_;
this.handle_.addEventListener('readystatechange', function(e) {
var flow = self.flow_;
if (!flow) {
return;
}
var value = undefined;
if (handle.readyState == 2) {
var headers = {};
var allHeaders = handle.getAllResponseHeaders().split('\r\n');
for (var n = 0; n < allHeaders.length; n++) {
if (allHeaders[n].length) {
var parts = allHeaders[n].split(':');
headers[parts[0]] = parts[1].substr(1);
}
}
value = {
'status': this.status,
'statusText': this.statusText,
'headers': headers
};
// TODO(benvanik): appendFlowData
}
// TODO(benvanik): response size/type/etc
// Extend flow, terminate if required.
if (handle.readyState < 4) {
wtf.trace.Flow.extend(flow, 'readyState: ' + handle.readyState, value);
} else {
wtf.trace.Flow.terminate(flow, 'readyState: ' + handle.readyState);
}
}, false);
// Add data to interesting events.
this.setEventHook('readystatechange', function(e) {
wtf.trace.appendScopeData('url', props['url']);
wtf.trace.appendScopeData('readyState', handle['readyState']);
});
this.setEventHook('load', function(e) {
wtf.trace.appendScopeData('url', props['url']);
});
wtf.trace.Scope.leave(scope);
}
|
javascript
|
{
"resource": ""
}
|
q47237
|
setupProxyProperty
|
train
|
function setupProxyProperty(name, opt_setPropsValue) {
Object.defineProperty(ProxyXMLHttpRequest.prototype, name, {
'configurable': true,
'enumerable': true,
'get': function() {
return this.handle_[name];
},
'set': opt_setPropsValue ? function(value) {
this.props_[name] = value;
this.handle_[name] = value;
} : function(value) {
this.handle_[name] = value;
}
});
}
|
javascript
|
{
"resource": ""
}
|
q47238
|
train
|
function(baseUrl, url) {
if (!resolveCache) {
var iframe = document.createElement('iframe');
document.documentElement.appendChild(iframe);
var doc = iframe.contentWindow.document;
var base = doc.createElement('base');
doc.documentElement.appendChild(base);
var a = doc.createElement('a');
doc.documentElement.appendChild(a);
iframe.parentNode.removeChild(iframe);
resolveCache = {
iframe: iframe,
base: base,
a: a
};
}
resolveCache.base.href = baseUrl;
resolveCache.a.href = url;
return resolveCache.a.href;
}
|
javascript
|
{
"resource": ""
}
|
|
q47239
|
WebSocket
|
train
|
function WebSocket(url, opt_protocols) {
var scope = ctorEvent();
goog.base(this, descriptor);
/**
* Underlying WS.
* @type {!WebSocket}
* @private
*/
this.handle_ = arguments.length == 1 ?
new originalWs(url) :
new originalWs(url, opt_protocols);
/**
* Event type trackers, by name.
* @type {!Object.<Function>}
* @private
*/
this.trackers_ = {};
/**
* Properties, accumulated during setup before send().
* @type {!Object}
* @private
*/
this.props_ = {
'url': url,
'protocol': opt_protocols
};
wtf.trace.Scope.leave(scope);
}
|
javascript
|
{
"resource": ""
}
|
q47240
|
train
|
function() {
/**
* Whether to show the page-action 'inject' icon.
* @type {boolean}
*/
this.showPageAction = true;
/**
* Whether to show the context menu items.
* @type {boolean}
*/
this.showContextMenu = false;
/**
* Whether to show the devtools panel.
* @type {boolean}
*/
this.showDevPanel = false;
/**
* A list of all added extensions, mapped by URL.
* @type {!Object.<!Object>}
* @private
*/
this.addons_ = {};
/**
* A map of instrumented tab IDs to their instrumentation options.
* If a tab has an entry in this map it is considered instrumented and
* that superceeds other whitelisting options.
* This is not saved (yet), as it's usually a one-off thing.
* @type {!Object.<number, Object>}
*/
this.instrumentedTabs_ = {};
/**
* A list of page match patterns that will have tracing on.
* @type {!Array.<string>}
* @private
*/
this.pageWhitelist_ = [];
/**
* A list of page match patterns that will have tracing off.
* @type {!Array.<string>}
* @private
*/
this.pageBlacklist_ = [];
/**
* A map of URLs to page options objects.
* @type {!Object.<!Object>}
* @private
*/
this.pageOptions_ = {};
/**
* Default endpoint to use for pages.
* @type {{mode: string, endpoint: string}}
* @private
*/
this.defaultEndpoint_ = {
mode: 'page',
endpoint: chrome.extension.getURL('app/maindisplay.html')
};
}
|
javascript
|
{
"resource": ""
}
|
|
q47241
|
runTool
|
train
|
function runTool(platform, args, done) {
if (args.length < 1) {
console.log('usage: query.js file.wtf-trace "[query string]"');
done(1);
return;
}
var inputFile = args[0];
var exprArgs = args.slice(1);
var expr = exprArgs.join(' ').trim();
console.log('Querying ' + inputFile + '...');
// Create database for querying.
var loadStart = wtf.now();
wtf.db.load(inputFile, function(db) {
if (db instanceof Error) {
console.log('ERROR: unable to open ' + inputFile, db);
done(1);
return;
}
var loadDuration = wtf.now() - loadStart;
console.log('Database loaded in ' + loadDuration.toFixed(3) + 'ms');
console.log('');
queryDatabase(db, expr);
done(0);
});
}
|
javascript
|
{
"resource": ""
}
|
q47242
|
queryDatabase
|
train
|
function queryDatabase(db, expr) {
// TODO(benvanik): allow the user to switch zone.
var zone = db.getZones()[0];
// If the user provided an expression on the command line, use that.
if (expr && expr.length) {
issue(expr);
return 0;
}
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on('line', function(line) {
line = line.trim();
if (line == 'q' || line == 'quit') {
rl.close();
return;
}
issue(line);
rl.prompt();
});
rl.on('close', function() {
console.log('');
db.dispose();
process.exit(0);
});
rl.setPrompt('> ');
rl.prompt();
function issue(expr) {
console.log('Expression: ' + expr);
var result;
try {
result = zone.query(expr);
} catch (e) {
console.log(e);
return;
}
var xexpr = result.getCompiledExpression();
console.log(xexpr.toString());
console.log('');
var resultValue = result.getValue();
if (resultValue instanceof wtf.db.EventIterator) {
var it = resultValue;
if (!it.getCount()) {
console.log('Nothing matched');
} else {
console.log('Results: (' + it.getCount() + ' total)');
for (; !it.done(); it.next()) {
util.logEvent(it, zone);
}
}
} else if (typeof resultValue == 'boolean' ||
typeof resultValue == 'number' ||
typeof resultValue == 'string') {
console.log('Result:');
logResult(resultValue);
} else if (!resultValue) {
// Note we test this after so that 0/strings/etc are handled.
console.log('Nothing matched');
} else if (resultValue.length) {
console.log('Results: (' + resultValue.length + ' total)');
for (var n = 0; n < resultValue.length; n++) {
logResult(resultValue[n]);
}
} else {
console.log('Result:');
logResult(resultValue);
}
console.log('');
console.log('Took ' + result.getDuration().toFixed(3) + 'ms');
}
}
|
javascript
|
{
"resource": ""
}
|
q47243
|
handlePost
|
train
|
function handlePost(req, res) {
var length = parseInt(req.headers['content-length'], 10);
if (length <= 0) {
res.end();
return;
}
var filename = req.headers['x-filename'] || 'save-trace.wtf-trace';
var writable = fs.createWriteStream(filename, {flags: 'w'});
req.on('data', function(chunk) {
writable.write(chunk);
});
req.on('end', function() {
console.log(filename);
writable.end();
res.end();
});
}
|
javascript
|
{
"resource": ""
}
|
q47244
|
handleOptions
|
train
|
function handleOptions(req, res) {
var acrh = req.headers['access-control-request-headers'];
var origin = req.headers['origin'];
if (acrh) res.setHeader('Access-Control-Allow-Headers', acrh);
if (origin) res.setHeader('Access-Control-Allow-Origin', origin);
res.end();
}
|
javascript
|
{
"resource": ""
}
|
q47245
|
match
|
train
|
function match(value) {
var token = lookahead();
return token.type === Token.Punctuator && token.value === value;
}
|
javascript
|
{
"resource": ""
}
|
q47246
|
matchKeyword
|
train
|
function matchKeyword(keyword) {
var token = lookahead();
return token.type === Token.Keyword && token.value === keyword;
}
|
javascript
|
{
"resource": ""
}
|
q47247
|
parseMultiplicativeExpression
|
train
|
function parseMultiplicativeExpression() {
var expr = parseUnaryExpression();
while (match('*') || match('/') || match('%')) {
expr = {
type: Syntax.BinaryExpression,
operator: lex().value,
left: expr,
right: parseUnaryExpression()
};
}
return expr;
}
|
javascript
|
{
"resource": ""
}
|
q47248
|
parseEqualityExpression
|
train
|
function parseEqualityExpression() {
var expr = parseRelationalExpression();
while (match('==') || match('!=') || match('===') || match('!==')) {
expr = {
type: Syntax.BinaryExpression,
operator: lex().value,
left: expr,
right: parseRelationalExpression()
};
}
return expr;
}
|
javascript
|
{
"resource": ""
}
|
q47249
|
parseLogicalANDExpression
|
train
|
function parseLogicalANDExpression() {
var expr = parseBitwiseORExpression();
while (match('&&')) {
lex();
expr = {
type: Syntax.LogicalExpression,
operator: '&&',
left: expr,
right: parseBitwiseORExpression()
};
}
return expr;
}
|
javascript
|
{
"resource": ""
}
|
q47250
|
fileExistsSync
|
train
|
function fileExistsSync(path) {
if (fs.existsSync) {
return fs.existsSync(path);
} else {
try {
fs.statSync(path);
return true;
} catch (e) {
return false;
}
}
}
|
javascript
|
{
"resource": ""
}
|
q47251
|
train
|
function(tabId, pageOptions) {
/**
* Target tab ID.
* @type {number}
* @private
*/
this.tabId_ = tabId;
/**
* Target debugee.
* @type {!Object}
* @private
*/
this.debugee_ = {
tabId: this.tabId_
};
/**
* Page options.
* @type {!Object}
* @private
*/
this.pageOptions_ = pageOptions;
/**
* A list of timeline records that have been recorded.
* @type {!Array.<!Array>}
* @private
*/
this.records_ = [];
/**
* Whether this debugger is attached.
* @type {boolean}
* @private
*/
this.attached_ = false;
/**
* Interval ID used for polling memory statistics.
* @type {number|null}
* @private
*/
this.memoryPollIntervalId_ = null;
/**
* The time of the first GC event inside of an event tree.
* Frequently the timeline will send 2-3 GC events with the same time.
* De-dupe those by tracking the first GC and ignoring the others.
* @type {number}
* @private
*/
this.lastGcStartTime_ = 0;
// Register us for dispatch.
Debugger.dispatchTable_.register(this.tabId_, this);
// Attach to the target tab.
try {
chrome.debugger.attach(this.debugee_, '1.0', (function() {
this.attached_ = true;
this.beginListening_();
}).bind(this));
} catch (e) {
// This is likely an exception saying the debugger is already attached,
// as Chrome has started throwing this in some versions. There's seriously
// like 10 different ways they report errors like this and it's different
// in every version. Sigh.
}
}
|
javascript
|
{
"resource": ""
}
|
|
q47252
|
copyFile
|
train
|
function copyFile(src, dest) {
var content = fs.readFileSync(src, 'binary');
fs.writeFileSync(dest, content, 'binary');
}
|
javascript
|
{
"resource": ""
}
|
q47253
|
computeInner
|
train
|
function computeInner(iterations) {
var dummy = 0;
for (var n = 0; n < iterations; n++) {
// We don't have to worry about this being entirely removed (yet), as
// JITs don't seem to consider now() as not having side-effects.
dummy += wtf.now();
}
return dummy;
}
|
javascript
|
{
"resource": ""
}
|
q47254
|
processFile
|
train
|
function processFile(argv, inputPath, opt_outputPath) {
// Setup output path.
var outputPath = opt_outputPath;
if (!opt_outputPath) {
var ext = path.extname(inputPath);
if (ext.length) {
outputPath = inputPath.substr(0, inputPath.length - ext.length) +
'.instrumented' + ext;
} else {
outputPath = inputPath + '.instrumented.js';
}
}
var sourceCode = fs.readFileSync(inputPath).toString();
// TODO(benvanik): support setting the module ID?
var targetCode = transformCode(0, inputPath, sourceCode, argv);
console.log('Writing ' + outputPath + '...');
fs.writeFileSync(outputPath, targetCode);
fs.chmodSync(outputPath, fs.statSync(inputPath).mode);
}
|
javascript
|
{
"resource": ""
}
|
q47255
|
handler
|
train
|
function handler(req, res) {
// Support both the ?url= mode and the X-WTF-URL header.
var targetUrl;
if (req.headers['x-wtf-url']) {
targetUrl = req.headers['x-wtf-url'];
} else {
var parsedUrl = url.parse(req.url, true);
var query = parsedUrl.query;
targetUrl = query.url;
}
if (!targetUrl || targetUrl.indexOf('http') != 0) {
res.writeHead(404, ['Content-Type', 'text/plain']);
res.end();
return;
}
res.on('error', function(e) {
console.log('ERROR (source): ' + e);
});
var targetModule = targetUrl.indexOf('https') == 0 ? https : http;
targetModule.get(targetUrl, function(originalRes) {
// Eat errors, otherwise the app will die.
originalRes.on('error', function(e) {
console.log('ERROR (target): ' + e);
});
// Pull out content type to see if we are interested in it.
var supportedContentType = false;
var contentType = originalRes.headers['content-type'];
if (contentType && contentType.indexOf(';') != 0) {
contentType = contentType.substr(0, contentType.indexOf(';'));
}
switch (contentType) {
case 'text/javascript':
case 'application/javascript':
supportedContentType = true;
break;
}
// Also parse the URL - some servers don't return content type for some
// reason.
var supportedPath = false;
var contentUrl = url.parse(targetUrl);
if (path.extname(contentUrl.pathname) == '.js') {
supportedPath = true;
}
if (supportedContentType || supportedPath) {
var headers = [];
for (var key in originalRes.headers) {
if (key == 'content-length') {
continue;
}
headers.push([key, originalRes.headers[key]]);
}
res.writeHead(originalRes.statusCode, headers);
injectStream(targetUrl, originalRes, res);
} else {
console.log('Pass-through: ' + targetUrl, contentType);
res.writeHead(originalRes.statusCode, originalRes.headers);
originalRes.pipe(res);
}
}).on('error', function(e) {
console.log(e);
res.writeHead(404, ['Content-Type', 'text/plain']);
res.end(e.message);
});
}
|
javascript
|
{
"resource": ""
}
|
q47256
|
fetchOptions
|
train
|
function fetchOptions() {
/**
* Name of the cookie that contains the options for the injection.
* The data is just a blob GUID that is used to construct a URL to the blob
* exposed by the extension.
* @const
* @type {string}
*/
var WTF_OPTIONS_COOKIE = 'wtf';
/**
* Cookie used for instrumentation options.
* @const
* @type {string}
*/
var WTF_INSTRUMENTATION_COOKIE = 'wtfi';
// Check for the injection cookie.
var optionsUuid = null;
var instrumentationOptions = null;
var cookies = document.cookie.split('; ');
for (var n = 0; n < cookies.length; n++) {
if (cookies[n].lastIndexOf(WTF_OPTIONS_COOKIE + '=') == 0) {
optionsUuid = cookies[n].substr(cookies[n].indexOf('=') + 1);
}
if (cookies[n].lastIndexOf(WTF_INSTRUMENTATION_COOKIE + '=') == 0) {
instrumentationOptions = cookies[n].substr(cookies[n].indexOf('=') + 1);
}
}
if (!optionsUuid && !instrumentationOptions) {
return null;
}
// If we have an instrumentation cookie we use that and go into
// instrumentation mode.
if (instrumentationOptions) {
instrumentationOptions = JSON.parse(instrumentationOptions);
instrumentationOptions['__instrumented__'] = true;
return instrumentationOptions;
}
// Fetch the options from the extension.
// This is complicated by a regression in Chrome that prevents the blob trick
// from working in certain versions. We try that first (as it's the best) and
// if it fails we fallback to a nasty HTTP header trick.
// https://code.google.com/p/chromium/issues/detail?id=295829
// blob:chrome-extension%3A//[extension id]/[options uuid]
var blobUrl = 'blob:' +
chrome.extension.getURL(optionsUuid).replace(':', '%3A');
var headerUrl =
'http://tracing-framework.appspot.com/tab-options/' + optionsUuid;
try {
var xhr = new XMLHttpRequest();
xhr.open('GET', blobUrl, false);
xhr.send(null);
if (xhr.status != 200) {
log('Failed to load WTF injection options:',
blobUrl,
xhr.status, xhr.statusText);
return null;
}
return JSON.parse(xhr.responseText);
} catch(e) {
log('Failed to parse WTF injection options (falling back to headers)... ' +
'See https://code.google.com/p/chromium/issues/detail?id=295829');
// Try the headers.
try {
var xhr = new XMLHttpRequest();
xhr.open('GET', headerUrl, false);
xhr.send(null);
var optionsData = xhr.getResponseHeader('X-WTF-Options');
if (!optionsData) {
log('Failed to load WTF injection options from header:' + headerUrl);
log('Using defaults for settings :(');
return {
'wtf.injector': true,
'wtf.injector.failed': true,
'wtf.trace.session.bufferSize': 6 * 1024 * 1024,
'wtf.trace.session.maximumMemoryUsage': 512 * 1024 * 1024,
'wtf.trace.provider.chromeDebug.present': true,
'wtf.trace.provider.chromeDebug.tracing': false
};
}
return JSON.parse(optionsData);
} catch(e) {
log('Really failed to fetch WTF injection options, aborting', e);
// Try again!
window.setTimeout(function() {
window.location.reload();
}, 100);
return null;
}
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
q47257
|
injectAddons
|
train
|
function injectAddons(manifestUrls) {
var addons = {};
for (var n = 0; n < manifestUrls.length; n++) {
// Fetch Manifest JSON.
var url = manifestUrls[n];
var json = getUrl(url);
if (!json) {
log('Unable to fetch manifest JSON: ' + url);
continue;
}
json = JSON.parse(json);
addons[url] = json;
// If it has a tracing node, inject scripts.
var tracingInfo = json['tracing'];
if (tracingInfo && tracingInfo['scripts']) {
var tracingScripts = tracingInfo['scripts'];
for (var m = 0; m < tracingScripts.length; m++) {
var scriptUrl = resolveUrl(url, tracingScripts[m]);
if (!injectScriptFile(scriptUrl)) {
log('Error loading addon ' + url + ':');
log('Tracing script file not found: ' + scriptUrl);
}
}
}
}
return addons;
}
|
javascript
|
{
"resource": ""
}
|
q47258
|
convertUint8ArraysToArrays
|
train
|
function convertUint8ArraysToArrays(sources) {
var targets = [];
for (var n = 0; n < sources.length; n++) {
var source = sources[n];
var target = new Array(source.length);
for (var i = 0; i < source.length; i++) {
target[i] = source[i];
}
targets.push(target);
}
return targets;
}
|
javascript
|
{
"resource": ""
}
|
q47259
|
resolveUrl
|
train
|
function resolveUrl(base, url) {
var value = '';
if (url.indexOf('://') != -1) {
// Likely absolute...
value = url;
} else {
// Combine by smashing together and letting the browser figure it out.
if (url.length && url[0] == '/') {
// URL is absolute, so strip base to just host.
var i = url.indexOf('://') + 3;
i = url.indexOf('/', i);
if (i != -1) {
value = base + url;
} else {
value = base.substr(0, i) + url;
}
} else {
// URL is relative, so combine with base.
if (base[base.length] == '/') {
value = base + '/' + url;
} else {
value = base + '/../' + url;
}
}
}
return value;
}
|
javascript
|
{
"resource": ""
}
|
q47260
|
wrapMethod
|
train
|
function wrapMethod(target, targetType, signature, opt_generator) {
// Parse signature.
var parsedSignature = wtf.data.Variable.parseSignature(signature);
var methodName = parsedSignature.name;
// Define a custom event type at runtime.
var customEvent = wtf.trace.events.createScope(
targetType + '#' + signature);
goog.asserts.assert(customEvent);
// Grab the original method from the target.
var rawFn = target[methodName];
if (!rawFn) {
goog.global.console.log(targetType + ' is missing ' + methodName);
return;
}
// Generate a bound function.
var instrumentedFn;
if (opt_generator) {
// Custom enter function generator.
instrumentedFn = opt_generator(rawFn, customEvent);
} else {
// Default case of simple event.
instrumentedFn = function() {
// Always call setCurrentContext first to ensure proper event order.
setCurrentContext(this);
// Enter scope with the arguments of the call.
var scope = customEvent.apply(null, arguments);
// Call the original method.
var result = rawFn.apply(this, arguments);
// Return the result and leave the scope.
return leaveScope(scope, result);
};
}
// Swap the method and save a restore function so that we can swap it back.
instrumentedFn['raw'] = rawFn;
target[methodName] = instrumentedFn;
contextRestoreFns.push(function() {
target[methodName] = rawFn;
});
}
|
javascript
|
{
"resource": ""
}
|
q47261
|
wrapInstancedArraysExtension
|
train
|
function wrapInstancedArraysExtension(ctx, proto) {
/**
* @param {string} signature Event signature.
* @param {Function=} opt_generator Generator function.
*/
function wrapInstancedArraysMethod(signature, opt_generator) {
wrapMethod(
proto, 'ANGLEInstancedArrays',
signature, opt_generator);
};
wrapInstancedArraysMethod(
'drawArraysInstancedANGLE(uint32 mode, uint32 first, int32 count, ' +
'int32 primcount)',
function(fn, eventType) {
return function drawArraysInstancedANGLE() {
setCurrentContext(ctx);
var scope = eventType.apply(this, arguments);
return leaveScope(scope, fn.apply(this, arguments));
};
});
wrapInstancedArraysMethod(
'drawElementsInstancedANGLE(uint32 mode, int32 count, uint32 type, ' +
'uint32 offset, int32 primcount)',
function(fn, eventType) {
return function drawElementsInstancedANGLE() {
setCurrentContext(ctx);
var scope = eventType.apply(this, arguments);
return leaveScope(scope, fn.apply(this, arguments));
};
});
wrapInstancedArraysMethod(
'vertexAttribDivisorANGLE(uint32 index, uint32 divisor)',
function(fn, eventType) {
return function vertexAttribDivisorANGLE() {
setCurrentContext(ctx);
var scope = eventType.apply(this, arguments);
return leaveScope(scope, fn.apply(this, arguments));
};
});
}
|
javascript
|
{
"resource": ""
}
|
q47262
|
wrapVertexArrayObjectExtension
|
train
|
function wrapVertexArrayObjectExtension(ctx, proto) {
/**
* @param {string} signature Event signature.
* @param {Function=} opt_generator Generator function.
*/
function wrapVertexArrayObjectMethod(signature, opt_generator) {
wrapMethod(
proto, 'OESVertexArrayObject',
signature, opt_generator);
};
// http://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/
wrapVertexArrayObjectMethod(
'createVertexArrayOES(uint32 arrayObject)',
function(fn, eventType) {
return function createVertexArrayOES() {
setCurrentContext(ctx);
var id = provider.nextObjectId_++;
leaveScope(eventType(id));
var obj = fn.apply(this, arguments);
if (obj) {
setHandle(obj, id);
}
return obj;
};
});
wrapVertexArrayObjectMethod(
'deleteVertexArrayOES(uint32 arrayObject)',
function(fn, eventType) {
return function deleteVertexArrayOES(arrayObject) {
setCurrentContext(ctx);
var scope = eventType(getHandle(arrayObject));
return leaveScope(scope, fn.apply(this, arguments));
};
});
wrapVertexArrayObjectMethod(
'isVertexArrayOES(uint32 arrayObject)',
function(fn, eventType) {
return function isVertexArrayOES(arrayObject) {
setCurrentContext(ctx);
var scope = eventType(getHandle(arrayObject));
return leaveScope(scope, fn.apply(this, arguments));
};
});
wrapVertexArrayObjectMethod(
'bindVertexArrayOES(uint32 arrayObject)',
function(fn, eventType) {
return function bindVertexArrayOES(arrayObject) {
setCurrentContext(ctx);
var scope = eventType(getHandle(arrayObject));
return leaveScope(scope, fn.apply(this, arguments));
};
});
}
|
javascript
|
{
"resource": ""
}
|
q47263
|
wrapLoseContextExtension
|
train
|
function wrapLoseContextExtension(ctx, proto) {
/**
* @param {string} signature Event signature.
* @param {Function=} opt_generator Generator function.
*/
function wrapLoseContextMethod(signature, opt_generator) {
wrapMethod(
proto, 'WebGLLoseContext',
signature, opt_generator);
};
// http://www.khronos.org/registry/webgl/extensions/WEBGL_lose_context/
wrapLoseContextMethod(
'loseContext()',
function(fn, eventType) {
return function loseContext() {
setCurrentContext(ctx);
var scope = eventType.apply(this, arguments);
return leaveScope(scope, fn.apply(this, arguments));
};
});
wrapLoseContextMethod(
'restoreContext()',
function(fn, eventType) {
return function restoreContext() {
setCurrentContext(ctx);
var scope = eventType.apply(this, arguments);
return leaveScope(scope, fn.apply(this, arguments));
};
});
}
|
javascript
|
{
"resource": ""
}
|
q47264
|
instrumentExtensionObject
|
train
|
function instrumentExtensionObject(ctx, name, object) {
var proto = object.constructor.prototype;
// We do this check only for known extensions, as Firefox will return a
// generic 'Object' for others and that will break everything.
function checkInstrumented() {
if (proto['__gl_wrapped__']) {
return false;
}
Object.defineProperty(proto, '__gl_wrapped__', {
'configurable': true,
'enumerable': false,
'value': true
});
contextRestoreFns.push(function() {
delete proto['__gl_wrapped__'];
});
return true;
};
switch (name) {
case 'ANGLE_instanced_arrays':
if (checkInstrumented()) {
wrapInstancedArraysExtension(ctx, proto);
}
return true;
case 'OES_vertex_array_object':
if (checkInstrumented()) {
wrapVertexArrayObjectExtension(ctx, proto);
}
return true;
case 'WEBGL_lose_context':
if (checkInstrumented()) {
wrapLoseContextExtension(ctx, proto);
}
return true;
case 'WEBGL_draw_buffers':
// http://www.khronos.org/registry/webgl/extensions/WEBGL_draw_buffers/
case 'WEBGL_security_sensitive_resources':
// http://www.khronos.org/registry/webgl/extensions/WEBGL_security_sensitive_resources/
case 'WEBGL_shared_resources':
// http://www.khronos.org/registry/webgl/extensions/WEBGL_shared_resources/
// Don't support these yet, so report them as not present.
return false;
default:
return true;
}
}
|
javascript
|
{
"resource": ""
}
|
q47265
|
checkInstrumented
|
train
|
function checkInstrumented() {
if (proto['__gl_wrapped__']) {
return false;
}
Object.defineProperty(proto, '__gl_wrapped__', {
'configurable': true,
'enumerable': false,
'value': true
});
contextRestoreFns.push(function() {
delete proto['__gl_wrapped__'];
});
return true;
}
|
javascript
|
{
"resource": ""
}
|
q47266
|
pidusage
|
train
|
function pidusage (pids, options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
if (options === undefined) {
options = {}
}
if (typeof callback === 'function') {
stats(pids, options, callback)
return
}
return new Promise(function (resolve, reject) {
stats(pids, options, function (err, data) {
if (err) return reject(err)
resolve(data)
})
})
}
|
javascript
|
{
"resource": ""
}
|
q47267
|
ps
|
train
|
function ps (pids, options, done) {
var pArg = pids.join(',')
var args = ['-o', 'etime,pid,ppid,pcpu,rss,time', '-p', pArg]
if (PLATFORM === 'aix') {
args = ['-o', 'etime,pid,ppid,pcpu,rssize,time', '-p', pArg]
}
bin('ps', args, function (err, stdout, code) {
if (err) return done(err)
if (code === 1) {
return done(new Error('No maching pid found'))
}
if (code !== 0) {
return done(new Error('pidusage ps command exited with code ' + code))
}
var date = Date.now()
// Example of stdout on *nix.
// ELAPSED: format is [[dd-]hh:]mm:ss
// RSS: is counted as blocks of 1024 bytes
// TIME: format is [[dd-]hh:]mm:ss
// %CPU: goes from 0 to vcore * 100
//
// Refs: http://www.manpages.info/linux/ps.1.html
// NB: The columns are returned in the order given inside the -o option
//
// ELAPSED PID PPID %CPU RSS TIME
// 2-40:50:53 430 1 3.0 5145 1-02:03:04
// 40:50:53 432 430 0.0 2364 1-01:02:03
// 01:50:50 727 1 10.0 348932 14:27
// 00:20 7166 1 0.1 3756 0:00
// Example of stdout on Darwin
// ELAPSED: format is [[dd-]hh:]mm:ss
// RSS: is counted as blocks of 1024 bytes
// TIME: format is [[dd-]hh:]mm:ss.cc (cc are centiseconds)
// %CPU: goes from 0 to vcore * 100
//
// Refs: https://ss64.com/osx/ps.html
// NB: The columns are returned in the order given inside the -o option
//
// ELAPSED PID PPID %CPU RSS TIME
// 2-40:50:53 430 1 3.0 5145 1-02:03:04.07
// 40:50:53 432 430 0.0 2364 1-01:02:03.10
// 01:50:50 727 1 10.0 348932 14:27.26
// 00:20 7166 1 0.1 3756 0:00.02
stdout = stdout.split(os.EOL)
var statistics = {}
for (var i = 1; i < stdout.length; i++) {
var line = stdout[i].trim().split(/\s+/)
if (!line || line.length !== 6) {
continue
}
var pid = parseInt(line[1], 10)
var hst = history.get(pid, options.maxage)
if (hst === undefined) hst = {}
var ppid = parseInt(line[2], 10)
var memory = parseInt(line[4], 10) * 1024
var etime = parseTime(line[0])
var ctime = parseTime(line[5], true)
var total = (ctime - (hst.ctime || 0))
// time elapsed between calls in seconds
var seconds = Math.abs(hst.elapsed !== undefined ? etime - hst.elapsed : etime)
var cpu = seconds > 0 ? (total / seconds) * 100 : 0
statistics[pid] = {
cpu: cpu,
memory: memory,
ppid: ppid,
pid: pid,
ctime: ctime,
elapsed: etime,
timestamp: date
}
history.set(pid, statistics[pid], options.maxage)
}
done(null, statistics)
})
}
|
javascript
|
{
"resource": ""
}
|
q47268
|
getDecoder
|
train
|
function getDecoder (encoding) {
if (!encoding) return null
try {
return iconv.getDecoder(encoding)
} catch (e) {
// error getting decoder
if (!ICONV_ENCODING_MESSAGE_REGEXP.test(e.message)) throw e
// the encoding was not found
throw createError(415, 'specified encoding unsupported', {
encoding: encoding,
type: 'encoding.unsupported'
})
}
}
|
javascript
|
{
"resource": ""
}
|
q47269
|
train
|
function(query, dialect) {
var sql = query.sql || (query.table && query.table.sql);
var Dialect;
if (dialect) {
// dialect is specified
Dialect = getDialect(dialect);
} else if (sql && sql.dialect) {
// dialect is not specified, use the dialect from the sql instance
Dialect = sql.dialect;
} else {
// dialect is not specified, use the default dialect
Dialect = require('../').dialect;
}
return Dialect;
}
|
javascript
|
{
"resource": ""
}
|
|
q47270
|
getModifierValue
|
train
|
function getModifierValue(dialect,node){
return node.count.type ? dialect.visit(node.count) : node.count;
}
|
javascript
|
{
"resource": ""
}
|
q47271
|
attach
|
train
|
function attach(listener) {
if (!listener) return;
if (!listener[CONTEXTS_SYMBOL]) listener[CONTEXTS_SYMBOL] = Object.create(null);
listener[CONTEXTS_SYMBOL][thisSymbol] = {
namespace : namespace,
context : namespace.active
};
}
|
javascript
|
{
"resource": ""
}
|
q47272
|
bind
|
train
|
function bind(unwrapped) {
if (!(unwrapped && unwrapped[CONTEXTS_SYMBOL])) return unwrapped;
var wrapped = unwrapped;
var contexts = unwrapped[CONTEXTS_SYMBOL];
Object.keys(contexts).forEach(function (name) {
var thunk = contexts[name];
wrapped = thunk.namespace.bind(wrapped, thunk.context);
});
return wrapped;
}
|
javascript
|
{
"resource": ""
}
|
q47273
|
train
|
function (name, path, options) {
options = options || {}
options.attachment = true
return handleField(name, path, options)
}
|
javascript
|
{
"resource": ""
}
|
|
q47274
|
train
|
function (name, value, options) {
$this._multipart.push({
name: name,
value: value,
options: options,
attachment: options.attachment || false
})
}
|
javascript
|
{
"resource": ""
}
|
|
q47275
|
train
|
function (user, password, sendImmediately) {
$this.options.auth = (is(user).a(Object)) ? user : {
user: user,
password: password,
sendImmediately: sendImmediately
}
return $this
}
|
javascript
|
{
"resource": ""
}
|
|
q47276
|
train
|
function (field, value) {
if (is(field).a(Object)) {
for (var key in field) {
if (Object.prototype.hasOwnProperty.call(field, key)) {
$this.header(key, field[key])
}
}
return $this
}
var existingHeaderName = $this.hasHeader(field)
$this.options.headers[existingHeaderName || field] = value
return $this
}
|
javascript
|
{
"resource": ""
}
|
|
q47277
|
train
|
function (value) {
if (is(value).a(Object)) value = Unirest.serializers.form(value)
if (!value.length) return $this
$this.options.url += (does($this.options.url).contain('?') ? '&' : '?') + value
return $this
}
|
javascript
|
{
"resource": ""
}
|
|
q47278
|
train
|
function (data) {
var type = $this.options.headers[$this.hasHeader('content-type')]
if ((is(data).a(Object) || is(data).a(Array)) && !Buffer.isBuffer(data)) {
if (!type) {
$this.type('form')
type = $this.options.headers[$this.hasHeader('content-type')]
$this.options.body = Unirest.serializers.form(data)
} else if (~type.indexOf('json')) {
$this.options.json = true
if ($this.options.body && is($this.options.body).a(Object)) {
for (var key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
$this.options.body[key] = data[key]
}
}
} else {
$this.options.body = data
}
} else {
$this.options.body = Unirest.Request.serialize(data, type)
}
} else if (is(data).a(String)) {
if (!type) {
$this.type('form')
type = $this.options.headers[$this.hasHeader('content-type')]
}
if (type === 'application/x-www-form-urlencoded') {
$this.options.body = $this.options.body
? $this.options.body + '&' + data
: data
} else {
$this.options.body = ($this.options.body || '') + data
}
} else {
$this.options.body = data
}
return $this
}
|
javascript
|
{
"resource": ""
}
|
|
q47279
|
train
|
function (options) {
if (!$this._multipart) {
$this.options.multipart = []
}
if (is(options).a(Object)) {
if (options['content-type']) {
var type = Unirest.type(options['content-type'], true)
if (type) options.body = Unirest.Response.parse(options.body)
} else {
if (is(options.body).a(Object)) {
options.body = Unirest.serializers.json(options.body)
}
}
$this.options.multipart.push(options)
} else {
$this.options.multipart.push({
body: options
})
}
return $this
}
|
javascript
|
{
"resource": ""
}
|
|
q47280
|
handleField
|
train
|
function handleField (name, value, options) {
var serialized
var length
var key
var i
options = options || { attachment: false }
if (is(name).a(Object)) {
for (key in name) {
if (Object.prototype.hasOwnProperty.call(name, key)) {
handleField(key, name[key], options)
}
}
} else {
if (is(value).a(Array)) {
for (i = 0, length = value.length; i < length; i++) {
serialized = handleFieldValue(value[i])
if (serialized) {
$this.rawField(name, serialized, options)
}
}
} else if (value != null) {
$this.rawField(name, handleFieldValue(value), options)
}
}
return $this
}
|
javascript
|
{
"resource": ""
}
|
q47281
|
handleFieldValue
|
train
|
function handleFieldValue (value) {
if (!(value instanceof Buffer || typeof value === 'string')) {
if (is(value).a(Object)) {
if (value instanceof fs.FileReadStream) {
return value
} else {
return Unirest.serializers.json(value)
}
} else {
return value.toString()
}
} else return value
}
|
javascript
|
{
"resource": ""
}
|
q47282
|
dq
|
train
|
function dq(selector, context) {
var nodes = []
context = context || document
if (typeof selector === 'function') {
if (context.attachEvent ? context.readyState === 'complete' : context.readyState !== 'loading') {
selector()
} else {
context.addEventListener('DOMContentLoaded', selector)
}
} else if (selector instanceof Element) {
nodes = [ selector ]
} else if (typeof selector === 'string') {
if (selector[0] === '<') {
nodes = Array.prototype.slice.call(fragment(selector))
} else {
nodes = Array.prototype.slice.call(context.querySelectorAll(selector))
}
} else {
nodes = selector
}
return new DOMQuery(nodes, context)
}
|
javascript
|
{
"resource": ""
}
|
q47283
|
DOMQuery
|
train
|
function DOMQuery(elements, context) {
this.length = elements.length
this.context = context
var self = this
each(elements, function(i) { self[i] = this })
}
|
javascript
|
{
"resource": ""
}
|
q47284
|
train
|
function (parent, nodes) {
for (var i = nodes.length - 1; i >= 0; i--) {
parent.insertBefore(nodes[nodes.length - 1], parent.firstChild)
}
}
|
javascript
|
{
"resource": ""
}
|
|
q47285
|
train
|
function (selector, event, handler, scope) {
(scope || document).addEventListener(event, function(event) {
var listeningTarget = closest(event.target, selector)
if (listeningTarget) {
handler.call(listeningTarget, event)
}
})
}
|
javascript
|
{
"resource": ""
}
|
|
q47286
|
train
|
function (value) {
/* jshint maxcomplexity:7 */
// boolean
if (value === 'true') { return true }
if (value === 'false') { return false }
// null
if (value === 'null') { return null }
// number
if (+value + '' === value) { return +value }
// json
if (/^[[{]/.test(value)) {
try {
return JSON.parse(value)
} catch (e) {
return value
}
}
// everything else
return value
}
|
javascript
|
{
"resource": ""
}
|
|
q47287
|
draftToMarkdown
|
train
|
function draftToMarkdown(rawDraftObject, options) {
options = options || {};
var markdownString = '';
rawDraftObject.blocks.forEach(function (block, index) {
markdownString += renderBlock(block, index, rawDraftObject, options);
});
orderedListNumber = {}; // See variable definitions at the top of the page to see why we have to do this sad hack.
return markdownString;
}
|
javascript
|
{
"resource": ""
}
|
q47288
|
Gradient
|
train
|
function Gradient(size, start) {
this.size = size;
this.canvas = new Canvas(1, 1);
this.setStartPosition(start);
this.ctx = this.canvas.getContext('2d');
this.grad = this.ctx.createLinearGradient(
this.from[0], this.from[1],
this.to[0], this.to[1]);
}
|
javascript
|
{
"resource": ""
}
|
q47289
|
normalize
|
train
|
function normalize(property, value, prefix){
var result = value.toString(),
args;
/* Fixing the gradients */
if (~result.indexOf('gradient(')) {
/* Normalize color stops */
result = result.replace(RE_GRADIENT_STOPS,'$1$4$3$2');
/* Normalize legacy gradients */
result = result.replace(RE_GRADIENT_VAL, function(){
args = [].slice.call(arguments, 1);
return normalizeGradient(args, prefix);
});
/* Adding prefixes to the legacy gradients */
if (prefix) result = result.replace(RE_GRADIENT_TYPE, '-' + prefix + '-$1');
}
/* Adding prefixes to the `transform` values of legacy `transition` property */
if (prefix && (property == "'transition'" || property == "'transition-property'")) {
result = result.replace(RE_TRANSFORM, '-' + prefix + '-$1');
}
/* Removing `fill` keyword from the legacy `border-image` property */
if (prefix && (property == "'border-image'" || property == "'border-image-slice'")) {
result = result.replace(RE_FILL_KEYWORD, ' ');
}
return result;
}
|
javascript
|
{
"resource": ""
}
|
q47290
|
ColorImage
|
train
|
function ColorImage(color) {
this.color = color;
this.canvas = new Canvas(1, 1);
this.ctx = this.canvas.getContext('2d');
this.ctx.fillStyle = color.toString();
this.ctx.fillRect(0, 0, 1, 1);
}
|
javascript
|
{
"resource": ""
}
|
q47291
|
clearRequireCacheInDir
|
train
|
function clearRequireCacheInDir(dir, extension) {
var options = {
cwd: dir
};
// find all files with the `extension` in the express view directory
// and clean them out of require's cache.
var files = glob.sync('**/*.' + extension, options);
files.map(function(file) {
clearRequireCache(dir + path.sep + (file.split(/\\|\//g).join(path.sep)));
});
}
|
javascript
|
{
"resource": ""
}
|
q47292
|
train
|
function(component) {
if (options.reduxStoreInitiator && isFunction(options.reduxStoreInitiator)) {
var initStore = options.reduxStoreInitiator;
if (initStore.default) {
initStore = initStore.default;
}
var store = initStore(props);
var Provider = require('react-redux').Provider;
return React.createElement(Provider, { store: store }, component);
} else {
return component;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q47293
|
mixin
|
train
|
function mixin (target, source, options) {
options = options || {};
options.skip = options.skip || [];
for (let key in source) {
if (typeof source[key] === 'function' && key.indexOf('_') !== 0 && options.skip.indexOf(key) === -1) {
target[key] = source[key].bind(source);
}
}
}
|
javascript
|
{
"resource": ""
}
|
q47294
|
InterfaceNotFoundError
|
train
|
function InterfaceNotFoundError(message, iface) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.message = message;
this.code = 'INTERFACE_NOT_FOUND';
this.interface = iface;
}
|
javascript
|
{
"resource": ""
}
|
q47295
|
InjectedContainer
|
train
|
function InjectedContainer(c, parent) {
var pasm = parent ? parent._assembly : undefined;
this._c = c;
this._parent = parent;
this._ns = (pasm && pasm.namespace) || '';
}
|
javascript
|
{
"resource": ""
}
|
q47296
|
LiteralComponent
|
train
|
function LiteralComponent(id, obj, asm) {
Component.call(this, id, obj, asm);
this._instance = obj;
}
|
javascript
|
{
"resource": ""
}
|
q47297
|
FactoryComponent
|
train
|
function FactoryComponent(id, fn, asm) {
Component.call(this, id, fn, asm);
this._fn = fn;
}
|
javascript
|
{
"resource": ""
}
|
q47298
|
ComponentNotFoundError
|
train
|
function ComponentNotFoundError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.message = message;
this.code = 'COMPONENT_NOT_FOUND';
}
|
javascript
|
{
"resource": ""
}
|
q47299
|
ComponentCreateError
|
train
|
function ComponentCreateError(message) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.message = message;
this.code = 'COMPONENT_CREATE_ERROR';
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.