_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q6300
provide
train
function provide(nucleus, key, provider) { provider(preventMultiCall(function
javascript
{ "resource": "" }
q6301
doNext
train
function doNext() { if (q) { q.pending = q.next = (!q.next && q.length) ? q.shift() : q.next; q.args = slice.call(arguments, 0); if (q.pending) {
javascript
{ "resource": "" }
q6302
train
function () { if (q) { for (var i = 0, len = arguments.length; i < len; i++) { q.push(arguments[i]); if (!q.pending) {
javascript
{ "resource": "" }
q6303
train
function () { delete nucleus.props; delete nucleus.needs; delete nucleus.providers; delete nucleus.listeners; while (q.length) { q.pop(); }
javascript
{ "resource": "" }
q6304
train
function (keyOrList, func) { var keys = toArray(keyOrList), i = -1, len = keys.length, key; while (++i < len) { key =
javascript
{ "resource": "" }
q6305
train
function (keyOrList, func) { var result = get(nucleus, keyOrList, func); return func ? result :
javascript
{ "resource": "" }
q6306
train
function () { var keys = []; for (var key in props) {
javascript
{ "resource": "" }
q6307
train
function (obj) { for (var p in obj) { if (hasOwn.call(obj, p)) { me[p]
javascript
{ "resource": "" }
q6308
train
function (keyOrList, func) { // alias: `bind` listeners.unshift({ keys: toArray(keyOrList), cb: func,
javascript
{ "resource": "" }
q6309
train
function (keyOrList, func) { var keys = toArray(keyOrList), results = get(nucleus, keys), values = results.values, missing = results.missing; if (!missing) { func.apply({}, values);
javascript
{ "resource": "" }
q6310
train
function (key, func) { if (needs[key]) { provide(nucleus, key,
javascript
{ "resource": "" }
q6311
train
function (keyOrMap, value) { if (typeof keyOrMap === typeObj) { for (var key in keyOrMap) { if (hasOwn.call(keyOrMap, key)) { set(nucleus, key, keyOrMap[key]);
javascript
{ "resource": "" }
q6312
join
train
function join(separator, itemList) { var result = ""; for (var i = 0; i < itemList.length; i++) {
javascript
{ "resource": "" }
q6313
similarity
train
function similarity(left, right, ignoreCase, trim) { if (left === right) { return 1; } if (TypeUtils.isNullOrUndefined(left) || TypeUtils.isNullOrUndefined(right)) { return 0; } if (arguments.length < 4) { if (arguments.length < 3) { ignoreCase =...
javascript
{ "resource": "" }
q6314
train
function (filename, callbackFn) { var self = this; request.post(this.options.hostAndPort + '/phantom/functions/injectJs', {form:{args:JSON.stringify(arguments)}}, function (error, response, body) { if (response.statusCode === 200) { ...
javascript
{ "resource": "" }
q6315
db_import
train
function db_import(config, src) { var cmd; // 1) Create cmd string from Lo-Dash template var tpl_mysql = grunt.template.process(tpls.mysql, { data: { host: config.host, user: config.user, pass: config.pass, database: c...
javascript
{ "resource": "" }
q6316
db_dump
train
function db_dump(config, output_paths) { var cmd; grunt.file.mkdir(output_paths.dir); // 2) Compile MYSQL cmd via Lo-Dash template string var tpl_mysqldump = grunt.template.process(tpls.mysqldump, { data: { user: config.user, pass: config.p...
javascript
{ "resource": "" }
q6317
train
function (callbackFn) { var self = this; request.post(this.options.hostAndPort + '/phantom/functions/exit', { form:{ } }, function (error, response, body) { if (response && response.statusCode === 200) {...
javascript
{ "resource": "" }
q6318
train
function (options, callbackFn) { var self = this; //compensate for optional options parm if (typeof options === 'function') { callbackFn = options; options = {}; } //assign default port options.port = options.port ...
javascript
{ "resource": "" }
q6319
train
function (cert, cb) { var infoObject = {}, subjectElements = [], err; var openssl = spawn('openssl', ['req', '-noout', '-subject', '-nameopt', 'RFC2253']); // Catch stderr openssl.stderr.on('data', function (out) { err = new Error(out); // Callback and return array retu...
javascript
{ "resource": "" }
q6320
toBunyan
train
function toBunyan (obj) { if (obj.msg && !obj.message) { obj.message = obj.msg delete obj.msg } if (typeof obj.level === 'number') { if (obj.level === 20) obj.level = 'debug' if
javascript
{ "resource": "" }
q6321
mock
train
function mock (_, mockArgs, fieldArgs, currentValue) { if (currentValue !== undefined) { return currentValue; } if (mockArgs && mockArgs.with) { if (fieldArgs) { try { return Mustache.render(mockArgs.with, fieldArgs); } catch (e) { logger.error(new AntError(
javascript
{ "resource": "" }
q6322
train
function(derives, xStart, yStart, h) { this.derives = derives this.x = xStart this.y = yStart || []
javascript
{ "resource": "" }
q6323
train
function() { var derives = this.derives, x = this.x, dimension = this.dimension, h = this.h var i, _y = [] // Alias: f() <=> this.derives() // Xn <=> this.x // Yn <=> this.y // H <=> ...
javascript
{ "resource": "" }
q6324
reducer
train
function reducer() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var action = arguments[1]; // add initial state if (action.type === (0, _.generateType)(_.types.add, (0, _get2.default)(action, 'payload.name'))) { return _extends({}, state, _defineProperty...
javascript
{ "resource": "" }
q6325
suite
train
function suite() { process.env.NODESASS_COV = 1; var coveralls = spawn(bin('coveralls')); var args = [bin('_mocha')].concat(['--reporter', 'mocha-lcov-reporter']); var mocha = spawn(process.sass.runtime.execPath, args, {
javascript
{ "resource": "" }
q6326
coverage
train
function coverage() { var jscoverage = spawn(bin('jscoverage'), ['lib', 'lib-cov']); jscoverage.on('error', function(err) { console.error(err); process.exit(1); });
javascript
{ "resource": "" }
q6327
destructureMessage
train
function destructureMessage (msg) { const keys = Object.keys(msg) var res = '' for (var i = 0; i < keys.length; i++) {
javascript
{ "resource": "" }
q6328
train
function(ast) { if (ast) { try { var doc = reader.parse(ast.lines); } catch(e) { console.error(e.stack); console.log('Source : \n* ' + ast.lines.join('\n* ')); return; } this.summary = doc.summary; this.tags = {}; this.a...
javascript
{ "resource": "" }
q6329
train
function(e) { delete self._pending[filename]; self.emit('error', {
javascript
{ "resource": "" }
q6330
_expectUsageInstructions
train
async function _expectUsageInstructions(args) { const { stdout, stderr } = await exec(getAntCommand(args)); expect(stdout).not.toBeNull(); expect(stdout.split('\n')[0]).toEqual( 'Usage: ant.js [--help] [--version] [--config <path>] [--verbose] <command>' ); expect(stdout).toContain( `Usage: ant.js [--...
javascript
{ "resource": "" }
q6331
_expectErrorMessage
train
async function _expectErrorMessage(args, ...errorMessages) { expect.hasAssertions(); try { await exec(getAntCommand(args)); throw new Error('It is expected to throw
javascript
{ "resource": "" }
q6332
_expectSuccessMessage
train
async function _expectSuccessMessage(args, ...successMessages) { const { stdout, stderr } = await exec(getAntCommand(args)); for (const successMessage of successMessages) {
javascript
{ "resource": "" }
q6333
_expectPackageVersion
train
async function _expectPackageVersion(args) { const packageVersion = require(
javascript
{ "resource": "" }
q6334
train
function(node) { if (node) { this.start = { line: node.start.line, column: node.start.column }; this.end = { line: node.end.line, column:
javascript
{ "resource": "" }
q6335
Amperize
train
function Amperize(options) { this.config = _.merge({}, DEFAULTS, options || {});
javascript
{ "resource": "" }
q6336
resolve
train
async function resolve (ant, resolveArgs, fieldArgs, currentValue, model) { let field = null; if (model) { field = model.field; } if (ant && resolveArgs && resolveArgs.to) { const antFunction = ant.functionController.getFunction(resolveArgs.to); if (!antFunction) { logger.error(new AntError( ...
javascript
{ "resource": "" }
q6337
dispatchToProps
train
function dispatchToProps(dispatch) { return { add: function add() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var name = arguments[1]; return dispatch({ type: generateType(types.add, name), payload...
javascript
{ "resource": "" }
q6338
train
function (type) { if (this.has(type)) { var messages = req.session[_session_key][type]; delete
javascript
{ "resource": "" }
q6339
train
function (host, port, cb) { var err, data = {}; var openssl = spawn('openssl', ['s_client', '-connect', host + ':' + port, '-servername', host]); // Clear timeout when execution was successful openssl.on('exit', function(){ clearTimeout(timeoutTimer); }); // Catch stderr and sea...
javascript
{ "resource": "" }
q6340
applyProxy
train
function applyProxy(options, cb) { npmconf.load({}, function (er, conf) { var proxyUrl; if (!er) { proxyUrl = conf.get('https-proxy') || conf.get('proxy') || conf.get('http-proxy'); } var env = process.env;
javascript
{ "resource": "" }
q6341
generateSourceMap
train
function generateSourceMap ( definition, options ) { if ( options === void 0 ) { options = {}; } if ( 'padding' in options ) { options.offset = options.padding; if ( !alreadyWarned ) { console.warn( 'rcu: options.padding is deprecated, use options.offset instead' ); // eslint-disable-line no-console alrea...
javascript
{ "resource": "" }
q6342
handleErrorMessage
train
function handleErrorMessage (msg, err, command, exitProcess) { setErrorHandled(); console.error(`Fatal => ${msg}`); if (err) { console.error(); if (isVerboseMode()) { console.error('Error stack:'); console.error(err.stack); } else { console.error('For getting the error stack, use --v...
javascript
{ "resource": "" }
q6343
attachFailHandler
train
function attachFailHandler (yargs, handler) { yargs.fail((msg, err, usage) => { // If failure was handled previously, does nothing. if (errorHandled) { return; } handler(msg, err, usage); if (errorHandled) { // Workaround to avoid yargs from running the command. // Since yargs ha...
javascript
{ "resource": "" }
q6344
executeCommand
train
async function executeCommand(command, asyncFn) { try { await asyncFn(); process.exit(0); }
javascript
{ "resource": "" }
q6345
subscribe
train
async function subscribe (ant, field, directiveArgs, fieldArgs) { if (ant && field && directiveArgs && directiveArgs.to) { const antFunction = ant.functionController.getFunction(directiveArgs.to); if (!antFunction) { logger.error(new AntError( `Could not find "${directiveArgs.to}" function` ...
javascript
{ "resource": "" }
q6346
train
function(inEvent) { var eventCopy = Object.create(null); var p; for (var i = 0; i < CLONE_PROPS.length; i++) { p = CLONE_PROPS[i]; eventCopy[p] = inEvent[p] || CLONE_DEFAULTS[i]; // Work around SVGInstanceElement shadow tree // Return the <use> element that is represen...
javascript
{ "resource": "" }
q6347
train
function(inEvent) { var lts = mouse.lastTouches; var t = inEvent.changedTouches[0]; // only the primary finger will synth mouse events if (this.isPrimaryTouch(t)) { // remember x/y of last touch var lt = { x: t.clientX, y: t.clientY }; lts.push(lt);
javascript
{ "resource": "" }
q6348
train
function(name, bool, node) { node = node || this; if (arguments.length == 1) { bool = !node.hasAttribute(name) || node.getAttribute(name) == 'false'; }
javascript
{ "resource": "" }
q6349
generateSchema
train
function generateSchema(ant, graphQL, _model) { let model = []; if (graphQL) { for (const directive of graphQL.directiveController.directives) { const directiveDefinition = graphQL.directiveController .getDirectiveDefinition(directive); if (directiveDefinition) { model.push(directiv...
javascript
{ "resource": "" }
q6350
train
function(url, callback) { url = getBaseUrl() + url; http.get(url, function(response) { var output = ""; response.on('data', function (chunk) { output += chunk; }); response.on('end', function() { output = JSON.parse(output...
javascript
{ "resource": "" }
q6351
facetAO
train
function facetAO(a00, a01, a02, a10, a12, a20, a21, a22) { var s00 = (a00&OPAQUE_BIT) ? 1 : 0 , s01 = (a01&OPAQUE_BIT) ? 1 : 0 , s02 = (a02&OPAQUE_BIT) ? 1 : 0 , s10 = (a10&OPAQUE_BIT) ? 1 : 0 , s12 = (a12&OPAQUE_BIT) ? 1 : 0 , s20 = (a20&OPAQUE_BIT) ? 1 : 0 ...
javascript
{ "resource": "" }
q6352
generateSurfaceVoxel
train
function generateSurfaceVoxel( v000, v001, v002, v010, v011, v012, v020, v021, v022, v100, v101, v102, v110, v111, v112, v120, v121, v122) { var t0 = !(v011 & OPAQUE_BIT) , t1 = !(v111 & OPAQUE_BIT) if(v111 && (!v011 || (t0 && !t1))) { return v111 | FLIP_BIT | facetAO(v000, v001, v002, ...
javascript
{ "resource": "" }
q6353
ForecastIoAPIError
train
function ForecastIoAPIError(url, statusCode, body) { this.response = { statusCode: statusCode, body: body }; this.message = this._formatErrorMessage(body); this.name = "ForecastIoAPIError";
javascript
{ "resource": "" }
q6354
getRuntimeInfo
train
function getRuntimeInfo() { var execPath = fs.realpathSync(process.execPath); // resolve symbolic link var runtime = execPath .split(/[\\/]+/).pop() .split('.').shift(); runtime
javascript
{ "resource": "" }
q6355
getBinaryUrl
train
function getBinaryUrl() { var site = flags['--sass-binary-site'] || process.env.SASS_BINARY_SITE
javascript
{ "resource": "" }
q6356
train
function (where) { if (where !== undefined) { if (where.gene !== undefined) { get_gene(where); return; } else { if (where.species === undefined) { where.species = genome_browser.species(); } else { ...
javascript
{ "resource": "" }
q6357
train
function (node, type, callback) { if (node.addEventListener) { node.addEventListener(type, function (e) { callback(e,
javascript
{ "resource": "" }
q6358
train
function (node, callback) { GOVUK.details.addEvent(node, 'keypress', function (e, target) { // When the key gets pressed - check if it is enter or space if (GOVUK.details.charCode(e) === GOVUK.details.KEY_ENTER || GOVUK.details.charCode(e) === GOVUK.details.KEY_SPACE) { if (target.nodeNa...
javascript
{ "resource": "" }
q6359
train
function (node, match) { do { if (!node || node.nodeName.toLowerCase() === match)
javascript
{ "resource": "" }
q6360
train
function (summary) { var expanded = summary.__details.__summary.getAttribute('aria-expanded') === 'true' var hidden = summary.__details.__content.getAttribute('aria-hidden') === 'true' summary.__details.__summary.setAttribute('aria-expanded', (expanded ? 'false' : 'true')) summary.__details.__c...
javascript
{ "resource": "" }
q6361
train
function ($container) { GOVUK.details.addEvent(document, 'DOMContentLoaded',
javascript
{ "resource": "" }
q6362
undef
train
function undef(w, i, depth, probs) { if (depth <= 1) return typeof probs[w[i]] ===
javascript
{ "resource": "" }
q6363
trainTuples
train
function trainTuples(words) { var probs = {}; var count = 0; words.forEach(function(w) { w = clean(w); for (var i = 0; i < w.length - 1; i++) { if (!probs[w[i]]) probs[w[i]] = {}; if (!probs[w[i]][w[i + 1]]) probs[w[i]][w[i + 1]] = 1; else probs[w[i]][w[i + 1]]++; count++; } ...
javascript
{ "resource": "" }
q6364
trainTriples
train
function trainTriples(words) { var probs = {}; var count = 0; words.forEach(function(w) { w = clean(w); for (var i = 0; i < w.length - 2; i++) { if (!probs[w[i]]) probs[w[i]] = {}; if (!probs[w[i]][w[i + 1]]) probs[w[i]][w[i + 1]] = {}; if (!probs[w[i]][w[i + 1]][w[i + 2]]) probs[w[i]]...
javascript
{ "resource": "" }
q6365
train
function(apiKey, contactId, creditCardId, payPlanId, productIds,
javascript
{ "resource": "" }
q6366
equals
train
function equals(first, second){ //If are the same instance, true if (first === second) return true; //If values are equals, return true if (first == second) return true; //If different type, false if (typeof first != typeof second) return false; //If are not objects, check value if...
javascript
{ "resource": "" }
q6367
train
function(a, b){ //Get value for "a" and "b" element var aValue = expression(a); var bValue = expression(b); //Check if one element is greater then the second one
javascript
{ "resource": "" }
q6368
subtract
train
function subtract(otherData, compareExpression) { //If other data is invalid, return empty array if (!otherData) return new jslinq([]); //Data for output var outData = []; //Check every element of "items" for (var n = 0; n < this.items.length; n++) { //...
javascript
{ "resource": "" }
q6369
transformer
train
function transformer(tree, file) { search(tree, phrases, searcher) function searcher(match, index, parent, phrase) { var type = weasel var message if (weasels.indexOf(phrase) === -1) { type = fillers.indexOf(phrase) === -1 ? hedge : filler } message = file.warn( ...
javascript
{ "resource": "" }
q6370
buildHTML
train
function buildHTML(navigation, first, sParentLink) { return '<ul class="nav' + (first ? ' sidenav' : '') + '">' + navigation.map(function(loc) { if (!loc || !loc.link) return ''; loc.link = (opts.parentLink
javascript
{ "resource": "" }
q6371
train
function(arrayOfSearchResultsArrays) { let ids = {}; let dedupedResults = []; _.each(arrayOfSearchResultsArrays, (searchResults) => { _.each(searchResults, (item) => { if (!
javascript
{ "resource": "" }
q6372
logOrThrow
train
function logOrThrow(error, result) { if (result) { self.log('connect-azuretables created table ' + self.table); } if (error) {
javascript
{ "resource": "" }
q6373
errorOrResult
train
function errorOrResult(error, result, fn) {
javascript
{ "resource": "" }
q6374
getExpiryDate
train
function getExpiryDate(store, data) { var offset; if (data.cookie.originalMaxAge) { offset = data.cookie.originalMaxAge; } else {
javascript
{ "resource": "" }
q6375
startListening
train
function startListening () { if (isBuilt === false) { app.listen( parseInt(port), host, () => { isBuilt = true
javascript
{ "resource": "" }
q6376
magnify
train
function magnify( rect, scale ) { var scrollOffset = getScrollOffset(); // Ensure a width/height is set rect.width = rect.width || 1; rect.height = rect.height || 1; // Center the rect within the zoomed viewport rect.x -= ( window.innerWidth - ( rect.width * scale ) ) / 2; rect.y -= ( window.innerHeigh...
javascript
{ "resource": "" }
q6377
train
function(T) { var ret = []; _(typedef.signature(T)).each(function(info, key) { if (info.decorations.FIELD)
javascript
{ "resource": "" }
q6378
train
function(o) { var q = this.clone();
javascript
{ "resource": "" }
q6379
train
function(f) { var q = this.clone(); if (arguments.length > 1) q._fields = _(arguments).toArray();
javascript
{ "resource": "" }
q6380
train
function() { if (this._executePromise) return this._executePromise; var q = this.clone(); var table = q._T.__name__; var page = q._page; var fields = q._fields; // Create the query from our stuff var query = {}; _(q._where.concat(q._l...
javascript
{ "resource": "" }
q6381
train
function(table, limit, page, query, fields) { if (this._doneLoading) return; var _this = this; // Execute -- add orderBy and ascending? var args = [table, limit, page, query, fields]; if (this._orderBy) { args.push(this._orderBy); args.pu...
javascript
{ "resource": "" }
q6382
train
function(apiKey, pieceTitle, categories, fromAddress, toAddress,
javascript
{ "resource": "" }
q6383
train
function(apiKey, contactId, fromName, fromAddress, toAddress, ccAddresses, bccAddresses, contentType,
javascript
{ "resource": "" }
q6384
train
function(apiKey, contactList, fromAddress, toAddress,
javascript
{ "resource": "" }
q6385
train
function(apiKey, templateId, pieceTitle, category, fromAddress, toAddress, ccAddress, bccAddresses, subject,
javascript
{ "resource": "" }
q6386
parentIsAllowedAtRule
train
function parentIsAllowedAtRule(rule) { return ( rule.parent && rule.parent.type === 'atrule' &&
javascript
{ "resource": "" }
q6387
hasParentRule
train
function hasParentRule(rule) { if (!rule.parent) { return false
javascript
{ "resource": "" }
q6388
regexpToGlobalRegexp
train
function regexpToGlobalRegexp(regexp) { let source = regexp instanceof RegExp ? regexp.source
javascript
{ "resource": "" }
q6389
init
train
function init ($container, elementSelector, eventSelectors, handler) { $container = $container || $(document.body) // Handle control clicks function deferred () { var $control = $(this) handler($control, getToggledContent($control)) } // Prepare ARIA attributes var ...
javascript
{ "resource": "" }
q6390
getEventSelectorsForRadioGroups
train
function getEventSelectorsForRadioGroups () { var radioGroups = [] // Build an array of radio group selectors return $(selectors.radio).map(function () { var groupName = $(this).attr('name') if ($.inArray(groupName, radioGroups) === -1) {
javascript
{ "resource": "" }
q6391
getIndex
train
function getIndex(objects, obj) { var i; for (i = 0; i < objects.length; i++) { if (objects[i] === obj) {
javascript
{ "resource": "" }
q6392
train
function() { var _this = this; _(api.services).each(function(service, key) {
javascript
{ "resource": "" }
q6393
train
function(T) { var tName = inflection.pluralize(T.__name__); this[tName]
javascript
{ "resource": "" }
q6394
train
function(iface) { var hash = {}; var collection = iface.__name__.substring(1); var dataContext = this; _(typedef.signature(iface)).each(function (info, key) { // create the function that calls method call and returns a promise hash[key] = function() ...
javascript
{ "resource": "" }
q6395
Dialog
train
function Dialog(options) { ui.Emitter.call(this); options = options || {}; this.template = html; this.el = $(this.template); this.render(options); if (active
javascript
{ "resource": "" }
q6396
ColorPicker
train
function ColorPicker() { ui.Emitter.call(this); this._colorPos = {}; this.el = $(html); this.main = this.el.find('.main').get(0); this.spectrum = this.el.find('.spectrum').get(0); $(this.main).bind('selectstart', function(e){ e.preventDefault() }); $(this.spectrum).bind('selectstart',
javascript
{ "resource": "" }
q6397
type
train
function type(type) { return function(title, msg){
javascript
{ "resource": "" }
q6398
Notification
train
function Notification(options) { ui.Emitter.call(this); options = options || {}; this.template = html; this.el = $(this.template);
javascript
{ "resource": "" }
q6399
SplitButton
train
function SplitButton(label) { ui.Emitter.call(this); this.el
javascript
{ "resource": "" }