_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,
};
// rem... | 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('');
w... | 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;
... | 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 t... | 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(
handleMemoryEven... | 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);
//... | 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.
* Thes... | 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 = getPag... | 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.destro... | 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' : 'Disa... | 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) {
... | 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(co... | 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 = ... | 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') {
... | 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', u... | 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.s... | 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... | 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-extensio... | 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... | 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:'... | 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) {
... | 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 ' + in... | 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 ... | 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[... | 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-injec... | 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]);
... | 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
*/
thi... | 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]... | 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');
d... | 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);
/**
* Eve... | 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... | 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 + '...');
// Cr... | 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,
... | 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) {
wr... | 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: parseUnaryExpressi... | 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:... | javascript | {
"resource": ""
} |
q47249 | parseLogicalANDExpression | train | function parseLogicalANDExpression() {
var expr = parseBitwiseORExpression();
while (match('&&')) {
lex();
expr = {
type: Syntax.LogicalExpression,
operator: '&&',
left: expr,
right: parseBitwiseORExpression()
... | 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.pageOptio... | 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 {
... | 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;
}
... | 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 instrument... | 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);
ad... | 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 =... | 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(
targetT... | 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',
signat... | 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',
si... | 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_gen... | 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__']) {
... | 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... | 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... | 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 =... | 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', {
... | 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;
} e... | 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... | 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(fi... | 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')]
$thi... | 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.bod... | 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[... | 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 {
... | 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)
}... | 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... | 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 pag... | 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_G... | 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... | 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').Provide... | 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(sourc... | 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.