_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q42300 | processElement | train | function processElement( that, element, toBeRemoved, opts ) {
var status,
retVal = 0,
callbacksRetVal;
// Unprotect elements names previously protected by htmlDataProcessor
// (see protectElementNames and protectSelfClosingElements functions).
// Note: body, title, etc. are not protected by htmlDataP (or... | javascript | {
"resource": ""
} |
q42301 | regexifyPropertiesWithWildcards | train | function regexifyPropertiesWithWildcards( validators ) {
var patterns = [],
i;
for ( i in validators ) {
if ( i.indexOf( '*' ) > -1 )
patterns.push( i.replace( /\*/g, '.*' ) );
}
if ( patterns.length )
return new RegExp( '^(?:' + patterns.join( '|' ) + ')$' );
else
return null;
} | javascript | {
"resource": ""
} |
q42302 | standardizeRule | train | function standardizeRule( rule ) {
rule.elements = convertValidatorToHash( rule.elements, /\s+/ ) || null;
rule.propertiesOnly = rule.propertiesOnly || ( rule.elements === true );
var delim = /\s*,\s*/,
i;
for ( i in validators ) {
rule[ i ] = convertValidatorToHash( rule[ i ], delim ) || null;
rule[... | javascript | {
"resource": ""
} |
q42303 | transformElement | train | function transformElement( that, element ) {
var transformations = that._.transformations[ element.name ],
i;
if ( !transformations )
return;
populateProperties( element );
for ( i = 0; i < transformations.length; ++i )
applyTransformationsGroup( that, element, transformations[ i ] );
// Do not c... | javascript | {
"resource": ""
} |
q42304 | updateAttributes | train | function updateAttributes( element ) {
var attrs = element.attributes,
styles;
// Will be recreated later if any of styles/classes exists.
delete attrs.style;
delete attrs[ 'class' ];
if ( ( styles = CKEDITOR.tools.writeCssText( element.styles, true ) ) )
attrs.style = styles;
if ( element.classes.... | javascript | {
"resource": ""
} |
q42305 | updateElement | train | function updateElement( element, status ) {
var validAttrs = status.validAttributes,
validStyles = status.validStyles,
validClasses = status.validClasses,
attrs = element.attributes,
styles = element.styles,
classes = element.classes,
origClasses = element.classBackup,
origStyles = element.styleB... | javascript | {
"resource": ""
} |
q42306 | inlineNode | train | function inlineNode( node ) {
return node.type == CKEDITOR.NODE_TEXT ||
node.type == CKEDITOR.NODE_ELEMENT && DTD.$inline[ node.name ];
} | javascript | {
"resource": ""
} |
q42307 | removeElement | train | function removeElement( element, enterTag, toBeChecked ) {
var name = element.name;
if ( DTD.$empty[ name ] || !element.children.length ) {
// Special case - hr in br mode should be replaced with br, not removed.
if ( name == 'hr' && enterTag == 'br' )
element.replaceWith( createBr() );
else {
// ... | javascript | {
"resource": ""
} |
q42308 | stripBlock | train | function stripBlock( element, enterTag, toBeChecked ) {
var children = element.children;
// First, check if element's children may be wrapped with <p/div>.
// Ignore that <p/div> may not be allowed in element.parent.
// This will be fixed when removing parent or by toBeChecked rule.
if ( checkChildren( child... | javascript | {
"resource": ""
} |
q42309 | getContentFormTransformationGroup | train | function getContentFormTransformationGroup( form, preferredForm ) {
var element, left;
if ( typeof form == 'string' )
element = form;
else if ( form instanceof CKEDITOR.style )
left = form;
else {
element = form[ 0 ];
left = form[ 1 ];
}
return [ {
element: element,
left: left,
right:... | javascript | {
"resource": ""
} |
q42310 | train | function( element ) {
if ( !( 'float' in element.styles ) ) {
var value = element.attributes.align;
if ( value == 'left' || value == 'right' )
element.styles[ 'float' ] = value; // Uh... GCC doesn't like the 'float' prop name.
}
delete element.attributes.align;
} | javascript | {
"resource": ""
} | |
q42311 | train | function( el, form ) {
if ( typeof form == 'string' )
el.name = form;
// Form is an instance of CKEDITOR.style.
else {
var def = form.getDefinition(),
defStyles = def.styles,
defAttrs = def.attributes,
attrName, styleName,
existingClassesPattern, defClasses, cl;
el.name = def.e... | javascript | {
"resource": ""
} | |
q42312 | RouteManager | train | function RouteManager(opts) {
var defaultActions = {
// Encapsulation of the next callback in express routes
next: function(req, res, next) {
next();
},
// Render view
render: function (req, res, next, data) {
res.render(data.render.viewPath, data.re... | javascript | {
"resource": ""
} |
q42313 | train | function(message) {
var identifier = _makeIdentifier(message);
if (typeof _filter[identifier] !== 'undefined' && _filter[identifier] < ((+new Date()) + 10 * 60000)) {
console.error('duplicated error', identifier, message);
return _filter[identifier];
}
_filter[identifier] = +new Date();
return false;
... | javascript | {
"resource": ""
} | |
q42314 | findWriteStream | train | function findWriteStream(arg, copy) {
if (copy.proto !== 'ReadableState') return null
if (copy.pipes != null && copy.pipes.proto !== 'WriteStream') return null
return arg.pipes
} | javascript | {
"resource": ""
} |
q42315 | parse | train | function parse(str, arr) {
return str.replace(/\.\w+|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g, function(expr) {
if(forbidden.indexOf(expr[0]) > -1) return expr;
if(!~arr.indexOf(expr)) arr.push(expr);
return 'model.' + expr;
});
} | javascript | {
"resource": ""
} |
q42316 | handleYield | train | function handleYield(forms) {
var yieldType = sl.valueOf(forms[0]); // "yield" or "yield*"
if (forms.length != 2) {
forms.error(yieldType + " expects a single expression");
}
this.indent += this.indentSize;
this.transpileSubExpressions(forms);
var generated = sl.generated();
generated... | javascript | {
"resource": ""
} |
q42317 | train | function(forms) {
if (forms.length < 2) {
forms.error("missing argument for operator");
}
if(forms.length > 2) {
// it's a normal binary (or more) minus
return handleArithOperator.call(this, forms);
}
// it's a unary minus
this.transpileSubExpressions(forms)
var generated... | javascript | {
"resource": ""
} | |
q42318 | startService | train | function startService() {
let me = this;
return server.start(me, function(err) {
if (err) {
return out.error("service failed to start: %j", err);
}
return server.ping(me, function() {
out.success("service started");
});
});
} | javascript | {
"resource": ""
} |
q42319 | stopService | train | function stopService() {
return server.stop(this, function(err) {
if (err) {
return out.error("service did not respond well: %j", err);
}
return out.success("service stopped");
});
} | javascript | {
"resource": ""
} |
q42320 | checkStatus | train | function checkStatus() {
return server.ping(this, function(err, res) {
if (err) {
return out.error("error occurred: %j", err);
}
if (res.running) {
return out.success("service running");
}
return out.error("service not running");
});
} | javascript | {
"resource": ""
} |
q42321 | commonDir | train | function commonDir (files) {
return files
.map(path.dirname)
.map(function (dir) {
return dir.split(path.sep)
})
.reduce(commonSequence)
.concat([''])
.join(path.sep)
} | javascript | {
"resource": ""
} |
q42322 | train | function (fn, context) {
var obj = this,
keys = Object.keys(obj),
l = keys.length,
i = -1,
key;
while (++i < l) {
key = keys[i];
fn.call(context || obj, obj[key], key, obj);
}
return obj;
} | javascript | {
"resource": ""
} | |
q42323 | train | function (descriptors) {
var instance = this,
m = Object.create(Object.getPrototypeOf(instance)),
keys = Object.getOwnPropertyNames(instance),
l = keys.length,
i = -1,
key, propDescriptor;
while (++i < l) {
key = keys[i];
... | javascript | {
"resource": ""
} | |
q42324 | train | function(refObj) {
var instance = this,
keys = Object.getOwnPropertyNames(instance),
l = keys.length,
i = -1,
same, key;
same = (l===refObj.itsa_size(true));
// loop through the members:
while (same && (++i < l)) {
key = keys[i]... | javascript | {
"resource": ""
} | |
q42325 | train | function (obj, options) {
var instance = this,
i = -1,
deepForce, keys, l, key, force, replace, descriptors, propDescriptor;
if (!Object.itsa_isObject(obj)) {
return instance;
}
options || (options={});
keys = options.full ? Object.getOwnProper... | javascript | {
"resource": ""
} | |
q42326 | train | function(obj, clone) {
var thisObj = this;
thisObj.itsa_emptyObject();
if (clone) {
deepCloneObj(obj, thisObj, true);
}
else {
thisObj.itsa_merge(obj);
}
return thisObj;
} | javascript | {
"resource": ""
} | |
q42327 | train | function (method, model, options) {
options = options ? _.clone(options) : {};
var jsonPayload;
var promise;
// Ensure that we have a hoodie object type.
if (!model.HOODIE_TYPE) {
throw new Error('A HOODIE_TYPE property must be specified');
}
// Ensu... | javascript | {
"resource": ""
} | |
q42328 | processLine | train | function processLine (line, callback) {
var trigger = line[0];
// Required to drop the args to callback so async doesn't think we're throwing an error.
function cb () {
callback();
}
if (trigger === 'alias') {
bot.db.schemas.factTrigger.saveAlias(line[1], line[2]).then(cb);
} else {
bot.db.schemas.factTri... | javascript | {
"resource": ""
} |
q42329 | randomString | train | function randomString(options) {
var set = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
if (options.symbols === true) {
set += '!@#$%^&*()<>?/[]{},.:;';
}
var key = '';
for (var i = 0; i < options.length; i++) {
key += set.charAt(Math.floor(Math.random() * set.length));
}
re... | javascript | {
"resource": ""
} |
q42330 | otpauth | train | function otpauth(key, name) {
var code = 'otpauth://totp/' + encodeURIComponent(name);
code += '?secret=' + encodeURIComponent(key);
code += '&issuer=' + encodeURIComponent('One Sony');
return code;
} | javascript | {
"resource": ""
} |
q42331 | link | train | function link(key, options) {
if (options.google && options.name) {
return 'https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=' + otpauth(key, options.name);
} else {
return 'https://chart.googleapis.com/chart?chs=166x166&chld=L|0&cht=qr&chl=' + encodeURIComponent(key);
}
} | javascript | {
"resource": ""
} |
q42332 | qrcode | train | function qrcode(key, name, options) {
// Options
options = _.extend({
type: 'svg',
sync: false
}, options || {});
var link = otpauth(key, name);
if (options.sync) {
return qr.imageSync(link, {
type: options.type,
margin: 0
});
} else {
return qr.image(link, {
type: op... | javascript | {
"resource": ""
} |
q42333 | generateKey | train | function generateKey(options) {
// Options
options = _.extend({
length: 32,
name: '',
symbols: false,
google: false,
qrCode: false,
type: 'base32'
}, options || {});
// Generate the random string
var key = randomString(options);
if (options.type === 'ascii') {
return key;
} e... | javascript | {
"resource": ""
} |
q42334 | Model | train | function Model(io, name, itemDef, modelDef, filter) {
EventEmitter.call(this);
//name = name.toLowerCase();
this.io = io;
this.name = name;
this.url = utils.resolveName(name);
this.itemDef = itemDef || {};
this.modelDef = modelDef || {};
this.filter = filter || {};
this.children = ... | javascript | {
"resource": ""
} |
q42335 | train | function(callback) {
if (Object.keys(templateDependencies).indexOf(args['<template>']) === -1) {
return callback(new Error(format('Unknown template "%s". Run '
+ '`mj help create` for list of valid templates.', args['<template>'])));
}
return callback(null);
} | javascript | {
"resource": ""
} | |
q42336 | train | function(callback) {
fs.readdir(args['<directory>'], function(err, files) {
// error here means it does not exist, which is good.
if (err || args['--force']) {
return callback(null, args['<directory>']);
}
if (files.length > 0) {
return callback(new Error(format... | javascript | {
"resource": ""
} | |
q42337 | train | function(template, parent) {
var templateLocation;
if (templateNameToRepo[template].startsWith('file://')) {
templateLocation = templateNameToRepo[template].slice(7);
} else {
templateLocation = path.join(path.homedir(), '.khaos', 'templates', template);
}
return function(callback, resul... | javascript | {
"resource": ""
} | |
q42338 | insert | train | function insert(arr, index, values) {
[].splice.apply(arr, [index, 0].concat(values));
} | javascript | {
"resource": ""
} |
q42339 | train | function(objectId, options) {
var self = this;
self.equalTo('objectId', objectId);
var firstOptions = {};
if (options && _.has(options, 'useMasterKey')) {
firstOptions = { useMasterKey: options.useMasterKey };
}
return self.first(firstOptions).then(function(response) {
... | javascript | {
"resource": ""
} | |
q42340 | train | function(options) {
var self = this;
options = options || {};
var request = Parse._request({
route: "classes",
className: this.className,
method: "GET",
useMasterKey: options.useMasterKey,
data: this.toJSON()
});
return request.then(function(respon... | javascript | {
"resource": ""
} | |
q42341 | train | function(options) {
var self = this;
options = options || {};
var params = this.toJSON();
params.limit = 0;
params.count = 1;
var request = Parse._request({
route: "classes",
className: self.className,
method: "GET",
useMasterKey: options.useMasterKe... | javascript | {
"resource": ""
} | |
q42342 | train | function(items, options) {
options = options || {};
return new Parse.Collection(items, _.extend(options, {
model: this.objectClass,
query: this
}));
} | javascript | {
"resource": ""
} | |
q42343 | train | function(key) {
var self = this;
if (!this._order) {
this._order = [];
}
Parse._arrayEach(arguments, function(key) {
if (Array.isArray(key)) {
key = key.join();
}
self._order = self._order.concat(key.replace(/\s/g, "").split(","));
});
retur... | javascript | {
"resource": ""
} | |
q42344 | train | function() {
var self = this;
Parse._arrayEach(arguments, function(key) {
if (_.isArray(key)) {
self._include = self._include.concat(key);
} else {
self._include.push(key);
}
});
return this;
} | javascript | {
"resource": ""
} | |
q42345 | train | function() {
var self = this;
this._select = this._select || [];
Parse._arrayEach(arguments, function(key) {
if (_.isArray(key)) {
self._select = self._select.concat(key);
} else {
self._select.push(key);
}
});
return this;
} | javascript | {
"resource": ""
} | |
q42346 | LogstashStream | train | function LogstashStream(options) {
EventEmitter.call(this);
options = options || {};
this.name = 'bunyan';
this.level = options.level || 'info';
this.server = options.server || os.hostname();
this.host = options.host || '127.0.0.1';
this.port = options.port || 9999;
this.application = options.... | javascript | {
"resource": ""
} |
q42347 | npmInstall | train | function npmInstall(packages, callback) {
callback = utils.defineCallback(callback);
if (_.isString(packages)) {
packages = [ packages ];
}
return npm.load({
loglevel: "silent",
prefix: tmpDir,
}, function(loadErr) {
if (loadErr) {
return callback(new errors.NpmLoadError(loadErr));
}... | javascript | {
"resource": ""
} |
q42348 | dirInstall | train | function dirInstall(dirpath, callback) {
callback = utils.defineCallback(callback);
return fs.exists(dirpath, function(exists) {
if (!exists) {
return callback(new errors.DirectoryNotExistingError());
}
var pluginName = path.basename(dirpath);
var destPath = path.join(pluginsDir, pluginName);
... | javascript | {
"resource": ""
} |
q42349 | listPlugins | train | function listPlugins(callback) {
callback = utils.defineCallback(callback);
return fs.readdir(pluginsDir, function(readdirErr, files) {
if (readdirErr) {
return callback(new errors.PluginsListingError(readdirErr));
}
var fullpath, pkg;
var descriptors = [ ];
files.forEach(function (file) {... | javascript | {
"resource": ""
} |
q42350 | inheirtInlineStyles | train | function inheirtInlineStyles( parent, el ) {
var style = parent.getAttribute( 'style' );
// Put parent styles before child styles.
style && el.setAttribute( 'style', style.replace( /([^;])$/, '$1;' ) + ( el.getAttribute( 'style' ) || '' ) );
} | javascript | {
"resource": ""
} |
q42351 | mergeListSiblings | train | function mergeListSiblings( listNode )
{
var mergeSibling;
( mergeSibling = function( rtl )
{
var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty );
if ( sibling &&
sibling.type == CKEDITOR.NODE_ELEMENT &&
sibling.is( listNode.getName() ) )
{
// Move childre... | javascript | {
"resource": ""
} |
q42352 | isTextBlock | train | function isTextBlock( node ) {
return node.type == CKEDITOR.NODE_ELEMENT && ( node.getName() in CKEDITOR.dtd.$block || node.getName() in CKEDITOR.dtd.$listItem ) && CKEDITOR.dtd[ node.getName() ][ '#' ];
} | javascript | {
"resource": ""
} |
q42353 | train | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'SAVE';
options.res = res;
if (req.params.model) {
options.model = req.params.model;
}
if (req.body) {
options.item = req.body;
}
if (req.params.data) {
options.data = req.param... | javascript | {
"resource": ""
} | |
q42354 | train | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'REMOVE';
options.res = res;
if (!options) {
options = {};
}
if (req.params.model) {
options.model = req.params.model;
}
if (req.params.query) {
options.query = req.params.query... | javascript | {
"resource": ""
} | |
q42355 | train | function (req, res) {
var options = {
operation: 'LIST',
res: res,
};
exports.list.before(req, res, options);
vulpejs.models.list({
model: req.params.model,
query: req.params.query || {},
populate: req.params.populate || '',
sort: req.params.sort || {},
userId: ... | javascript | {
"resource": ""
} | |
q42356 | train | function (req, res) {
var options = {
operation: 'PAGINATE',
res: res,
};
exports.paginate.before(req, res, options);
vulpejs.models.paginate({
model: req.params.model,
query: req.params.query || {},
populate: req.params.populate || '',
sort: req.params.sort || {},
... | javascript | {
"resource": ""
} | |
q42357 | train | function (req, res) {
var options = {
operation: 'DISTINCT',
res: res,
};
exports.distinct.before(req, res, options);
vulpejs.models.distinct({
model: req.params.model,
query: req.params.query || {},
sort: req.params.sort || false,
array: req.params.array || false,
... | javascript | {
"resource": ""
} | |
q42358 | train | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'FIND';
options.res = res;
exports.find.before(req, res, options);
vulpejs.models.find({
model: req.params.model,
populate: req.params.populate,
history: true,
id: req.params.id || fa... | javascript | {
"resource": ""
} | |
q42359 | train | function (req, res, options) {
if (!options) {
options = {};
}
options.operation = 'STATUS';
options.res = res;
exports.status.before(req, res, options);
vulpejs.models.status({
model: req.params.model,
data: req.body,
callback: {
success: function (item) {
... | javascript | {
"resource": ""
} | |
q42360 | train | function (configObject) {
if (typeof configObject !== 'undefined') {
configuration.directory = configObject.directory || configuration.directory;
configuration.extension = configObject.extension || configuration.extension;
configuration.objectNotation = configObject.objectNotation || configuration... | javascript | {
"resource": ""
} | |
q42361 | train | function (request, response, next) {
response.locals.i18n = {
getLocale: function () {
return request.cookies.appLanguage || vulpejs.i18n.getLocale.apply(request, arguments);
},
};
// For backwards compatibility, also define 'acceptedLanguage'.
response.locals.acceptedLanguage = res... | javascript | {
"resource": ""
} | |
q42362 | train | function (request, response) {
var locale = request.params.locale;
var sendFile = response.sendFile || response.sendfile;
sendFile.apply(response, [path.join(configuration.directory, locale + configuration.extension)]);
} | javascript | {
"resource": ""
} | |
q42363 | train | function (request, response) {
var locale = request.params.locale;
var phrase = request.params.phrase;
var result;
if (request.query.plural) {
var singular = phrase;
var plural = request.query.plural;
// Make sure the information is added to the catalog if it doesn't exi... | javascript | {
"resource": ""
} | |
q42364 | subscribe | train | function subscribe(topicArn) {
// validate the topic arn
if (!rxTopicArn.test(topicArn)) throw Error('Cannot subscribe to an invalid AWS Topic Arn: ' + topicArn);
// if already subscribed then return now
if (subscriptions[topicArn]) return subscriptions[topicArn].promise;
// c... | javascript | {
"resource": ""
} |
q42365 | unsubscribe | train | function unsubscribe(topicArn) {
// if not subscribed then return now
if (!subscriptions[topicArn]) {
debug('Not subscribed to ' + topicArn);
return Promise.resolve();
}
return new Promise(function(resolve, reject) {
const params = { SubscriptionArn:... | javascript | {
"resource": ""
} |
q42366 | parseBody | train | function parseBody(req) {
return extractBody(req)
.then(() => {
if (req.body && typeof req.body === 'object') return req.body;
try {
return JSON.parse(req.body);
} catch (err) {
throw Error('Unexpected body format received. Expected applica... | javascript | {
"resource": ""
} |
q42367 | train | function (version, semverIndex)
{
const splittedVersion = version.split('.');
splittedVersion[ semverIndex ] = parseInt(splittedVersion[ semverIndex ], 10) + 1;
while (semverIndex < 2)
{
splittedVersion[ ++semverIndex ] = '0';
}
return splittedVersion.join('.');
} | javascript | {
"resource": ""
} | |
q42368 | train | function (packagePath, semverIndex)
{
// Check if package file exists
if ( !fs.existsSync(packagePath) )
{
throw new Error(`Package file ${packagePath} is not found.`, 1);
}
// Read package file content
const packageData = JSON.parse( fs.readFileSync( packagePath ) );
// Increment version according ... | javascript | {
"resource": ""
} | |
q42369 | multiproject | train | function multiproject (pointer, target, path) {
var pointerType = getTypeStr (pointer);
var mainTarget;
if (target)
mainTarget = target;
else
if (pointerType == 'object')
target = {};
else if (pointerType... | javascript | {
"resource": ""
} |
q42370 | origin | train | function origin(fn) {
'use strict';
exec('git config --local --get remote.origin.url', function (errors, stdout, stderr) {
var url = "";
if (errors) return fn(errors.stack, url);
if (stderr) return fn(stderr, url);
url = trim.call(stdout);
if (!url) return fn('Unable to find remote origin U... | javascript | {
"resource": ""
} |
q42371 | srcStream | train | function srcStream(stream) {
var pass = through.obj();
pass.setMaxListeners(0);
var outputstream = duplexify.obj(pass, ms(stream, pass));
outputstream.setMaxListeners(0);
var isReading = false;
outputstream.on('pipe', function (src) {
isReading = true;
src.on('end', function () {
isReading =... | javascript | {
"resource": ""
} |
q42372 | createIHDRChunk | train | function createIHDRChunk(width, height) {
const data = buffer.Buffer.alloc(13);
// Width
data.writeUInt32BE(width);
// Height
data.writeUInt32BE(height, 4);
// Bit depth
data.writeUInt8(8, 8);
// RGBA mode
data.writeUInt8(6, 9);
// No compression
data.writeUInt8(0, 10);
// No filter
data.writeUInt8(0, 11)... | javascript | {
"resource": ""
} |
q42373 | createPng | train | function createPng(pixelData) {
const length = pixelData.length + 4 - (pixelData.length % 4);
const pixels = Math.ceil(length / 4);
const width = Math.min(pixels, MAX_WIDTH);
const height = Math.ceil(pixels / MAX_WIDTH);
const bytesPerRow = width * 4;
const buffer$$1 = buffer.Buffer.alloc((bytesPerRow + 1) * heig... | javascript | {
"resource": ""
} |
q42374 | prependLength | train | function prependLength(data) {
const lengthAsBytes = buffer.Buffer.alloc(4);
lengthAsBytes.writeUInt32BE(data.length);
return buffer.Buffer.concat([lengthAsBytes, data]);
} | javascript | {
"resource": ""
} |
q42375 | encode | train | function encode(data) {
const bytes = buffer.Buffer.from(data, 'utf8');
const pixelData = prependLength(bytes);
return createPng(pixelData);
} | javascript | {
"resource": ""
} |
q42376 | train | function (increment) {
increment = increment || Semver.PATCH; // default is patch
switch (increment) {
/* jshint indent: false */
case Semver.MAJOR:
this.major++;
this.minor = this.patch = 0;
break;
case Semver.MINOR:
... | javascript | {
"resource": ""
} | |
q42377 | isMyTurn | train | function isMyTurn(game, from) {
if (game.score.ended)
return false;
from = Board.getPositionFromBoard(game.board, from);
return isWhiteTurn(game) ? Position.hasWhitePiece(from) : Position.hasBlackPiece(from);
} | javascript | {
"resource": ""
} |
q42378 | getTurnPieces | train | function getTurnPieces(game) {
const isBlack = isBlackTurn(game);
return game.board.reduce((piecesRow, row) => {
return piecesRow.concat(row.reduce((pieces, position) => (isBlack !== position.isBlack)
? pieces
: pieces.concat({ x: position.x, y: position.y, isBlack }), []));
... | javascript | {
"resource": ""
} |
q42379 | prefix | train | function prefix(pattern) {
if (!pattern) {
pattern = 'grunt-available-tasks';
}
pattern = pattern.replace(/^node_modules\//, '');
var ret;
if (grunt.file.expand('node_modules/' + pattern).length) {
ret = 'node_modules/';
} else if (grunt.file.expan... | javascript | {
"resource": ""
} |
q42380 | getConfig | train | function getConfig(name, def) {
var i, j;
// Load initital config.
if (!config) {
var external;
config = grunt.config.get('cog') || {options: {}};
// Expand general external definitions to category specific definitions.
if (config.options.exte... | javascript | {
"resource": ""
} |
q42381 | configuredFramework | train | function configuredFramework() {
var lib = getConfig('external.lib');
if (!lib) {
return null;
}
if (typeof(lib) === 'string') {
lib = [lib];
}
if (lib.indexOf('ember') >= 0) {
return 'ember';
}
if (lib.indexOf('angular'... | javascript | {
"resource": ""
} |
q42382 | getOption | train | function getOption(name) {
var ret = getConfig('options.' + name);
if (ret === undefined) {
var framework = configuredFramework();
if (db.frameworks.options[framework] && (name in db.frameworks.options[framework])) {
ret = db.frameworks.options[framework][name];
... | javascript | {
"resource": ""
} |
q42383 | train | function (inst) {
if (inst.isDirty()) {
inst.save();
ngModel.$setViewValue(elm.val());
if (!scope.$$phase)
scope.$apply();
}
} | javascript | {
"resource": ""
} | |
q42384 | train | function(event, jsEvent, view) {
if (view.name !== 'agendaDay') {
$(jsEvent.target).attr('title', event.title);
}
} | javascript | {
"resource": ""
} | |
q42385 | CFG | train | function CFG(rules) {
let arr = [];
arr.__proto__ = CFG.prototype;
if (Array.isArray(rules)) {
rules.forEach(arr.rule.bind(arr));
}
return arr;
} | javascript | {
"resource": ""
} |
q42386 | reapply | train | function reapply (parameters) {
return (arguments.length > 1)
? reapplyer(parameters, arguments[1])
: reapplyer.bind(null, parameters)
} | javascript | {
"resource": ""
} |
q42387 | handlePush | train | function handlePush(key, req, log, fn) {
var body = req.body;
var repo = body.repository;
if (!body || !repo) return fn(new Error('missing body'));
var url = repo.url;
var name = repo.name;
var ref = body.ref;
var branch = ref.replace('refs/heads/', '');
var sha = body.after;
var info = {
repo: ... | javascript | {
"resource": ""
} |
q42388 | clone | train | function clone(url, target, ref, key, log, fn) {
var urlObj = parseurl(url);
urlObj.auth = key + ':x-oauth-basic';
var authurl = formaturl(urlObj) + '.git';
var dir = target + '/.git';
log('creating dir ' + dir);
mkdirp(dir, function(err) {
if (err) return fn(err);
var remote = git.remote(authurl... | javascript | {
"resource": ""
} |
q42389 | basePackageJson | train | function basePackageJson (opts) {
opts = opts || {}
const _name = opts.name || '<name>'
const _version = opts.version || '1.0.0'
const _private = opts.private || false
var called = false
return from({ objectMode: true }, function (size, next) {
if (called) return next(null, null)
const res = { na... | javascript | {
"resource": ""
} |
q42390 | padLeft | train | function padLeft(width, string, padding) {
return (width <= string.length) ? string : padLeft(width, string + padding, padding);
} | javascript | {
"resource": ""
} |
q42391 | writeLogFile | train | function writeLogFile(file, line) {
if (file === undefined || file === null) {
return;
}
fs.appendFile(file, line + os.EOL, {}, function() {
//
});
} | javascript | {
"resource": ""
} |
q42392 | Stash | train | function Stash(nlz) {
if (!(this instanceof Stash)) return new Stash(nlz);
nlz = nlz || function(val) {return val};
assert.equal(typeof nlz, 'function', 'linkstash: nlz should be a function');
this._prev = null;
this._next = null;
this._nlz = nlz;
return this;
} | javascript | {
"resource": ""
} |
q42393 | checkMocksCalled | train | function checkMocksCalled(createResult) {
expect(createResult).to.deep.equal(createResult);
sinon.assert.calledOnce(mockDatasetManager.create);
sinon.assert.calledWith(mockDatasetManager.create, sinon.match(mockDataToCreate));
} | javascript | {
"resource": ""
} |
q42394 | nav | train | function nav(path, query, hash, forceReload) {
var reload = forceReload || !path;
path = path || location.pathname;
query = query || (reload && location.search) || '';
hash = hash || (reload && location.hash) || '';
var newpage = generator.findPage(path);
if (!newpage) return generator.... | javascript | {
"resource": ""
} |
q42395 | layoutChanged | train | function layoutChanged(oldpage, newpage) {
if (oldpage && oldpage.fixlayout) return true;
if (lang(oldpage) !== lang(newpage)) return true;
var currentlayout = $layout.attr('data-render-layout') || 'main-layout';
var newlayout = generator.layoutTemplate(newpage);
return (newlayout !== curr... | javascript | {
"resource": ""
} |
q42396 | updateHtml | train | function updateHtml(href) {
var fragment = generator.fragment$[href];
if (!fragment) return generator.emit('notify', 'Oops, jqueryview cannot find fragment: ' + href);
var $html = $('[data-render-html="' + href + '"]');
if (!$html.length) return generator.emit('notify', 'Oops, jqueryview cannot update ... | javascript | {
"resource": ""
} |
q42397 | appendModel | train | function appendModel(url, model, done){
var list = utils.flatten_tree(JSON.parse(JSON.stringify(model)))
var errormodel = null
list = list.filter(function(model){
if(!model._digger.path || !model._digger.inode){
errormodel = model;
return false;
}
return true
})
if(errormodel){
return d... | javascript | {
"resource": ""
} |
q42398 | prepend | train | function prepend(pre) {
function prepender(string) { return pre + string; }
return arguments.length > 1
? prepender(arguments[1])
: prepender;
} | javascript | {
"resource": ""
} |
q42399 | train | function(value, compareFunction) {
var low = 0;
var high = this.length;
var mid;
if (compareFunction) {
while (low < high) {
mid = low + high >>> 1;
var direction = compareFunction(this[mid], value);
if (!direction) {
return mid;
}
if (direction <... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.