_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q41200 | train | function(href)
{
var _this = this;
return Q.nfcall(request, href).then(function(data) {
var $ = cheerio.load(data);
var serviceName =
$('.collection')
.first()
.text()
.trim()
.replace(/\./g, '');
... | javascript | {
"resource": ""
} | |
q41201 | generateLockName | train | function generateLockName() {
let subMark = Math.floor(Math.random() * 1000).toString(36)
return `Lock:${Date.now().toString(36)}:${subMark}`
} | javascript | {
"resource": ""
} |
q41202 | parseResponse | train | function parseResponse(mystemResponse) {
var mystemResponseFacts = mystemResponse.slice(mystemResponse.indexOf("{") + 1, -1),
factRegexp = /([^,]+\([^)]+\)|[^,]+)/g,
facts = [],
fact;
while (fact = factRegexp.exec(mystemResponseFacts)) {
facts.push(fact[0]);
}
var resul... | javascript | {
"resource": ""
} |
q41203 | applyEvents | train | function applyEvents(context, child, data) {
var events = context.events[child.name];
if (events !== undefined && child.el !== undefined && child.data.type !== 'cp') {
events.forEach((event)=> {
context._events.push(child.on(event.name, event.action, context, data));
... | javascript | {
"resource": ""
} |
q41204 | train | function (file) {
var match = pattern.exec(basename(file));
return { date: match[1], url: match[2] };
} | javascript | {
"resource": ""
} | |
q41205 | train | function (userOptions) {
var defaultOptions = { ignore: [], collection: null, jekyllStyleLayout: true };
for (var opt in userOptions) defaultOptions[opt] = userOptions[opt];
return defaultOptions;
} | javascript | {
"resource": ""
} | |
q41206 | getClosestFormName | train | function getClosestFormName(element) {
var parent = element.parent();
if(parent[0].tagName.toLowerCase() === 'form') {
return parent.attr('name') || null;
} else {
return getClosestFormName(parent);
... | javascript | {
"resource": ""
} |
q41207 | Subscriber | train | function Subscriber(opts) {
opts = opts || {};
this._channel = opts.channel || 'default';
this._subscribers = [];
/* for mocking */
var addEventListener = opts.addEventListener || window.addEventListener;
var attachEvent = opts.attachEvent || window.attachEvent;
var _this = this;
function onMessage(e... | javascript | {
"resource": ""
} |
q41208 | train | function(keys){
console.log('\nInitializing keys in Redis...\n')
keys.forEach(function(el,i){
client.get(el.key, function(e,d){
if(e) {
console.log("Error trying to get %s ", el.key)
return console.error(e)
}
// checking for falsey values only is a bad idea
if(typeof... | javascript | {
"resource": ""
} | |
q41209 | train | function(userObj, setname, hashPrefix, cb){
console.log("\nCreating new user account %s", userObj.network.username)
/*
userObj = {
network: {
type : 'facebook',
first_name: 'Joe',
last_name: 'McCann',
username: 'joemccann',
full_n... | javascript | {
"resource": ""
} | |
q41210 | train | function(userObj, setname, hashPrefix, cb){
// client.srem('users',userObj.uuid, redis.print)
var _uuid = sha1('photopipe', userObj.email_address)
client.srem(setname, _uuid, function(e,d){
if(cb){
return cb(e,d)
}
userSetRemoveHandler(e,d)... | javascript | {
"resource": ""
} | |
q41211 | train | function(e,d){
if(e){
console.log("User set add data response: %s", d)
e && console.error(e)
return
}
console.log("User set add data response with no error: %s", d)
} | javascript | {
"resource": ""
} | |
q41212 | decorate | train | function decorate (fn) {
return async function (...args) {
try {
return fn.call(this, ...args);
} catch (err) {
this.logger && this.logger.error(err.message);
throw err;
}
};
} | javascript | {
"resource": ""
} |
q41213 | start | train | function start() {
proc = spawn(procCommand, procArgs, procOptions);
var onClose = function (code) {
if (!restarting) {
process.exit(code);
}
start();
restarting = false;
};
proc.on('error', function () {
debug('restarting due error');
restarting = true;
... | javascript | {
"resource": ""
} |
q41214 | commonSequence | train | function commonSequence(a, b){
var result = [];
for (var i = 0; i < Math.min(a.length, b.length); i++){
if (a[i] === b[i]){
result.push(a[i]);
} else {
break;
}
}
return result;
} | javascript | {
"resource": ""
} |
q41215 | generator | train | function generator(url) {
var randomnesss = Crypto.randomBytes(24);
randomnesss.writeDoubleBE(Date.now(), 0);
randomnesss.writeUInt32BE(process.pid, 8);
var output = randomnesss.toString('base64');
// URL safe
if (url) {
output = output.replace(/\//g, '_');
output = output.replace(/\+/g, '-');
}
return o... | javascript | {
"resource": ""
} |
q41216 | Confirm | train | function Confirm(client, channel){
EE.call(this);
this.client = client;
this.channel = channel;
this.id = channel.$getId();
return this;
} | javascript | {
"resource": ""
} |
q41217 | mixin | train | function mixin(rework, declarations, mixins) {
for (var i = 0; i < declarations.length; ++i) {
var decl = declarations[i];
if ('comment' == decl.type) continue;
var key = decl.property;
var val = decl.value;
var fn = mixins[key];
if (!fn) continue;
// invoke mixin
var ret = fn.call(r... | javascript | {
"resource": ""
} |
q41218 | generateKey | train | function generateKey (args, strictArgMatch = true) {
args = Array.from(args)
if (strictArgMatch) return args
return args.map(arg => maybeStringify(arg))
} | javascript | {
"resource": ""
} |
q41219 | train | function(model) {
var fields = _.keys(model);
var updated = {};
_.each(fields, function(field) {
var updatedField = {};
var modelField = {};
if (!(field === Object(field))) {
updatedField.field = field;
if (!(model[field] === Object(model[field]))) {... | javascript | {
"resource": ""
} | |
q41220 | rgbToHex | train | function rgbToHex(r, g, b) {
var integer = ((Math.round(r) & 0xFF) << 16)
+ ((Math.round(g) & 0xFF) << 8)
+ (Math.round(b) & 0xFF);
var string = integer.toString(16).toUpperCase();
return '#' + ('000000'.substring(string.length) + string);
} | javascript | {
"resource": ""
} |
q41221 | nthWeekDay | train | function nthWeekDay(countDays, weekDay, year, month, day) {
let countedDays = 0
if (countDays >= 0) {
month = month || 1
let monthStr = String(month)
if (monthStr.length === 1) { monthStr = "0" + monthStr }
day = day || 1
let dayStr = String(day)
if (dayStr.length === 1) { dayStr = "0" + day... | javascript | {
"resource": ""
} |
q41222 | lastDayOfMonth | train | function lastDayOfMonth(time) {
let year = time.getUTCFullYear()
let nextMonth = time.getUTCMonth() + 2
if (nextMonth > 12) {
year++
nextMonth = 1
}
let nextMonthStr = String(nextMonth)
if (nextMonthStr.length === 1) { nextMonthStr = '0' + nextMonthStr }
let date = new Date(`${year}-${nextMonthStr... | javascript | {
"resource": ""
} |
q41223 | processKeyProperty | train | function processKeyProperty(propDesc, keyPropContainer) {
// get the key property descriptor
const keyPropName = propDesc._keyPropertyName;
if (!keyPropContainer.hasProperty(keyPropName))
throw invalidPropDef(
propDesc, 'key property ' + keyPropName +
' not found among the target object properties.');
con... | javascript | {
"resource": ""
} |
q41224 | train | function(opts) {
opts = opts || {};
this.userHandshake = opts.handshake;
if(opts.heartbeat) {
this.heartbeatSec = opts.heartbeat;
this.heartbeat = opts.heartbeat * 1000;
}
this.checkClient = opts.checkClient;
this.useDict = opts.useDict;
this.useProtobuf = opts.useProtobuf;
this.useCrypto = o... | javascript | {
"resource": ""
} | |
q41225 | formatError | train | function formatError(err, input) {
var msg = err.message.replace(/\s*\(\d*\:\d*\)\s*$/i, ''); // remove line number / col number
var bm = ('' + input.slice(0, err.pos)).match(/.*$/i);
var am = ('' + input.slice(err.pos)).match(/.*/i);
var before = bm ? bm[0] : '';
var after = am ? am[0] : '';
... | javascript | {
"resource": ""
} |
q41226 | sn_ui_pixelWidth | train | function sn_ui_pixelWidth(selector) {
if ( selector === undefined ) {
return undefined;
}
var styleWidth = d3.select(selector).style('width');
if ( !styleWidth ) {
return null;
}
var pixels = styleWidth.match(/([0-9.]+)px/);
if ( pixels === null ) {
return null;
}
var result = Math.floor(pixels[1]);
if ... | javascript | {
"resource": ""
} |
q41227 | create | train | function create(loader, shouldReload = defaultShouldReload, mapper = defaultMapper, initialCtx = defaultInitialCtx) {
// Initialise context, which is passed around and holds the lastData.
const ctx = initialCtx; // TODO: instead of providing a full initial context, the redata() function below should receive
... | javascript | {
"resource": ""
} |
q41228 | onConnection | train | function onConnection() {
var endpoint = new http2.Endpoint(log, 'CLIENT', {});
endpoint.pipe(socket).pipe(endpoint);
// Sending request
var stream = endpoint.createStream();
stream.headers({
':method': 'GET',
':scheme': url.protocol.slice(0, url.protocol.length - 1),
':authority': url.hostname,
... | javascript | {
"resource": ""
} |
q41229 | iterateElements | train | function iterateElements(array) {
return {
__iterator__: function() {
var index = 0;
var current;
return {
get current() {
return current;
},
moveNext: function() {
if (index < array.length) {
current = array[index++];
return tr... | javascript | {
"resource": ""
} |
q41230 | validate | train | function validate(method) {
var decorated = function validateDecorator() {
var params = method.params;
var schema = method.schema;
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var value = _combineObject(param... | javascript | {
"resource": ""
} |
q41231 | decorate | train | function decorate(service, serviceName) {
var logger = _config.loggerFactory(serviceName, _config);
_lodash2.default.map(service, function (method, name) {
method.methodName = name;
if (!method.params) {
method.params = (0, _getParameterNames2.default)(method);
}
service[name] = log(validate(m... | javascript | {
"resource": ""
} |
q41232 | Interval | train | function Interval(func, options) {
this.func = func;
this.delay = options.delay || 16;
this.lifetime = options.lifetime;
this.useRequestAnimationFrame = options.useRequestAnimationFrame && window.requestAnimationFrame && window.cancelAnimationFrame;
this.interval = null;
this.gcTimeout = null;
} | javascript | {
"resource": ""
} |
q41233 | Device | train | function Device (device, sp) {
if (!(device && sp))
throw new Error('a Device and a SerialPort must be passed');
for (var i in device)
this[i] = device[i];
this._open = false;
this._sp = sp;
EventEmitter.call(this);
} | javascript | {
"resource": ""
} |
q41234 | Exchange | train | function Exchange(client, channel){
EE.call(this);
this.client = client;
this.channel = channel;
this.id = channel.$getId();
return this;
} | javascript | {
"resource": ""
} |
q41235 | sortByAttributeNameComparitor | train | function sortByAttributeNameComparitor(a,b) {
if (a.attributes.name < b.attributes.name)
return -1;
if (a.attributes.name > b.attributes.name)
return 1;
return 0;
} | javascript | {
"resource": ""
} |
q41236 | turnOn | train | function turnOn(device) {
return api.request('/device/turnOn?' + querystring.stringify({id: device.id || device}));
} | javascript | {
"resource": ""
} |
q41237 | turnOff | train | function turnOff(device) {
return api.request('/device/turnOff?' + querystring.stringify({id: device.id || device}));
} | javascript | {
"resource": ""
} |
q41238 | history | train | function history(device, from, to) {
return api.request('/device/history?' + querystring.stringify({id: device.id || device, from: from, to: to}));
} | javascript | {
"resource": ""
} |
q41239 | multipart | train | function multipart(options) {
options = options || {};
DEBUG && debug('configure http multipart middleware', options);
return function (req, res, next) {
if (req._body || !req.is('multipart/form-data') || 'POST' !== req.method) {
return next();
}
DEBUG && debug('got mult... | javascript | {
"resource": ""
} |
q41240 | add | train | function add(appName, domain, callback) {
commons.post(format('/%s/apps/%s/domains/', deis.version, appName), {
domain: domain.toString()
}, callback);
} | javascript | {
"resource": ""
} |
q41241 | remove | train | function remove(appName, domain, callback) {
var url = format('/%s/apps/%s/domains/%s', deis.version, appName, domain);
commons.del(url, callback);
} | javascript | {
"resource": ""
} |
q41242 | getAll | train | function getAll(appName, callback) {
var url = format('/%s/apps/%s/domains/', deis.version, appName);
commons.get(endpoint, callback);
} | javascript | {
"resource": ""
} |
q41243 | getDomain | train | function getDomain(domain, callback) {
getAll(function onGetAll(err, domains) {
if (err) {
return callback(err);
}
callback(null, domains.results.filter(function onGetDomain(domain_obj) {
return domain_obj.domain == domain;
})[0]);
});
} | javascript | {
"resource": ""
} |
q41244 | train | function (target) {
var inst = this._getInst(target);
if (!inst) {
return FALSE;
}
$("#sbHolder_" + inst.uid).remove();
$.data(target, PROP_NAME, null);
$(target).show();
} | javascript | {
"resource": ""
} | |
q41245 | train | function (target, value, text) {
var inst = this._getInst(target),
onChange = this._get(inst, 'onChange');
$("#sbSelector_" + inst.uid).text(text);
$(target).find("option[value='" + value + "']").attr("selected", TRUE);
if (onChange) {
onChange.apply((inst.input ? inst.input[0] : null), [value... | javascript | {
"resource": ""
} | |
q41246 | train | function (target) {
var inst = this._getInst(target);
if (!inst || !inst.isDisabled) {
return FALSE;
}
$("#sbHolder_" + inst.uid).removeClass(inst.settings.classHolderDisabled);
inst.isDisabled = FALSE;
$.data(target, PROP_NAME, inst);
} | javascript | {
"resource": ""
} | |
q41247 | train | function (target) {
var inst = this._getInst(target);
if (!inst || inst.isDisabled) {
return FALSE;
}
$("#sbHolder_" + inst.uid).addClass(inst.settings.classHolderDisabled);
inst.isDisabled = TRUE;
$.data(target, PROP_NAME, inst);
} | javascript | {
"resource": ""
} | |
q41248 | train | function (target, name, value) {
var inst = this._getInst(target);
if (!inst) {
return FALSE;
}
//TODO check name
inst[name] = value;
$.data(target, PROP_NAME, inst);
} | javascript | {
"resource": ""
} | |
q41249 | train | function (target) {
var inst = this._getInst(target);
//if (!inst || this._state[inst.uid] || inst.isDisabled) {
if (!inst || inst.isOpen || inst.isDisabled) {
return;
}
var el = $("#sbHolder_" + inst.uid),
viewportHeight = parseInt($(window).height(), 10),
offset = $("#sbHolder_" + i... | javascript | {
"resource": ""
} | |
q41250 | train | function (target) {
var inst = this._getInst(target);
//if (!inst || !this._state[inst.uid]) {
if (!inst || !inst.isOpen) {
return;
}
var onClose = this._get(inst, 'onClose');
inst.settings.effect === "fade" ? $("#sbOptions_" + inst.uid).fadeOut(inst.settings.speed) : $("#sbOptions_" + inst... | javascript | {
"resource": ""
} | |
q41251 | train | function(target) {
var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1');
return {
id: id,
input: target,
uid: Math.floor(Math.random() * 99999999),
isOpen: FALSE,
isDisabled: FALSE,
settings: {}
};
} | javascript | {
"resource": ""
} | |
q41252 | checkHttpCode | train | function checkHttpCode(expected, res, body, callback) {
if (res.statusCode !== expected) {
if (!body) {
return callback(new Error(format('Unexpected deis response (expected %s but %s was returned)', expected, res.statusCode)));
}
var error = body.hasOwnProperty('detail') ?
body.detail : JSO... | javascript | {
"resource": ""
} |
q41253 | compareVersions | train | function compareVersions(versions) {
// 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));
var chunks = map(versions, function (version) {
var delta = precision - getVers... | javascript | {
"resource": ""
} |
q41254 | isUnsupportedBrowser | train | function isUnsupportedBrowser(minVersions, strictMode, ua) {
var _bowser = bowser;
// make strictMode param optional with ua param usage
if (typeof strictMode === 'string') {
ua = strictMode;
strictMode = void(0);
}
if (strictMode === void(0)) {
strictMode = false;
}
if (... | javascript | {
"resource": ""
} |
q41255 | sendCommand | train | function sendCommand(method, url, payload, skipQueue) {
if (!self.connected) {
debug('Queueing %s %s', method, url);
return new P(function(resolve, reject) {
var p = P.method(function() {
debug('Dequeueing %s %s', method, url);
return _sendCommand(method, url, payload)
... | javascript | {
"resource": ""
} |
q41256 | sequencer | train | function sequencer (ctx, callback) {
var timer, iterable, iterator, nextTick, tempo, tickInterval, lookahead
function emit (event, data, time, duration) {
setTimeout(function () { callback(event, data, time, duration) }, 0)
}
function sequence (data) {
if (!data) iterator = rangeIterator(0, Infinity)
... | javascript | {
"resource": ""
} |
q41257 | _checkExitCode | train | function _checkExitCode(result, test) {
var actual = result.exitcode;
var expect = test.exitcode;
var error;
if (typeof expect === 'string') {
expect = parseInt(expect, 10);
}
if (expect !== undefined && expect !== actual) {
error = util.format('Exit code %d does not match expected %d', actual, e... | javascript | {
"resource": ""
} |
q41258 | check | train | function check(result, test) {
const CHECKERS = [ _checkExitCode, _checkOutput, _checkStdout, _checkStderr ];
var errors = [];
CHECKERS.forEach(function (checker) {
var error = checker(result, test);
if (error) {
errors.push(error);
}
});
return errors;
} | javascript | {
"resource": ""
} |
q41259 | train | function (obj)
{
if (typeof obj === 'undefined')
{
obj = this.getConfig();
delete obj.class;
}
if (typeof obj == 'object')
{
delete obj.autoInit;
delete obj.id;
delete obj.serverID;
delete obj.modulePath;
for (o in obj)
{
this.exportConfig(obj[o]);
}
}
... | javascript | {
"resource": ""
} | |
q41260 | train | function (filePath)
{
if (typeof arguments[1]=='function')
var cb = arguments[1];
if (typeof arguments[2]=='function')
var cb = arguments[2];
var binary = typeof arguments[1]=='boolean' ? arguments[1] : false,
realPath = this.instanceOf('wnModule')?this.modulePath+filePath:filePath,
cmd = !... | javascript | {
"resource": ""
} | |
q41261 | train | function (filePath,cb)
{
var realPath = this.instanceOf('wnModule')?this.modulePath+filePath:filePath,
cmd = !cb ? 'statSync' : 'stat';
if (!fs.existsSync(realPath))
return (cb&&cb(false) == true);
var _cb = cb ? function (err,stat) {
cb&&cb(!err ? stat : false);
} : null,
stat = fs[cmd]... | javascript | {
"resource": ""
} | |
q41262 | train | function ()
{
this.e.log&&this.e.log('Preloading events...','system');
var preload = {};
_.merge(preload,this.defaultEvents);
_.merge(preload,this.getConfig().events);
if (preload != undefined)
this.setEvents(preload);
for (e in preload)
{
this.getEvent(e);
}
this.attachEventsHandle... | javascript | {
"resource": ""
} | |
q41263 | train | function (className,config,path,npmPath)
{
var source = this.c || process.wns;
var instance;
var builder = this.getComponent&&this.getComponent('classBuilder');
if (!source || !source[className])
{ return false; }
if (config.id)
source[className].build.id = config.id;
if (source[className... | javascript | {
"resource": ""
} | |
q41264 | train | function () {
this.e.log&&this.e.log("Attaching default event's handlers...",'system');
var events = this.getEvents();
for (e in events)
{
var eventName = e.split('-').pop(),
event = this.getEvent(eventName),
evtConfig = event.getConfig();
if (evtConfig.handler != null && this[evtConfig.h... | javascript | {
"resource": ""
} | |
q41265 | train | function (events)
{
var event = {};
for (e in events)
{
var ref=events[e],
e = 'event-'+e.replace('-','.');
event[e]=ref;
event[e].class=ref.class || 'wnEvent';
event[e].eventName = e.split('-').pop();
if (this.hasEvent(e))
{
_.merge(event[e],this.getEvent(e));
}
_ev... | javascript | {
"resource": ""
} | |
q41266 | train | function (name,hidden)
{
var eventName = 'event-'+name;
if (_events[eventName] != undefined)
return _events[eventName];
else
{
if (!_eventsConfig[eventName] || !this.c)
return false;
var config = _eventsConfig[eventName] || {},
_class = config.class;
config.id = eventName;
c... | javascript | {
"resource": ""
} | |
q41267 | train | function (eventName,handler) {
var event;
if (event = this.getEvent(eventName))
{
if (!event.addListener(handler))
this.e.log('Invalid handler sent to event `'+eventName+'` on `'+this.getConfig('id')+'`','warning');
} else
this.e.log('Not existent event `'+eventName+'` on `'+this.getConfig('id'... | javascript | {
"resource": ""
} | |
q41268 | train | function (eventName,handler) {
var event;
if (event = this.getEvent(eventName))
{
if (!event.prependListener(handler))
this.e.log('Invalid handler sent to event `'+eventName+'` on `'+this.getConfig('id')+'`','warning');
} else
this.e.log('Not existent event `'+eventName+'` on `'+this.getConfig(... | javascript | {
"resource": ""
} | |
q41269 | train | function (eventName,handler) {
var event;
if (event = this.getEvent(eventName))
{
if (!event.once(handler,true))
this.e.log('Invalid handler sent to event `'+eventName+'` on `'+this.getConfig('id')+'`','warning');
} else
this.e.log('Not existent event `'+eventName+'` on `'+this.getConfig('id')+... | javascript | {
"resource": ""
} | |
q41270 | train | function ()
{
var _export = {},
merge = {};
_.merge(merge,this.getConfig());
_.merge(merge,this);
var proto = this._proto.public;
for (p in proto)
if (!((typeof proto[p] == 'object' || typeof proto[p] == 'function') && proto[p] != null && proto[p].instanceOf!=undefined))
_export[p] = proto... | javascript | {
"resource": ""
} | |
q41271 | train | function (msg,verbosity)
{
if (!_debug || verbosity>_verbosity)
return false;
this.e.log.apply(this,[msg||'','debug',verbosity||0]);
return self;
} | javascript | {
"resource": ""
} | |
q41272 | train | function ()
{
arguments[arguments.length+'']='info';
arguments.length++;
this.e.log.apply(this,arguments);
return self;
} | javascript | {
"resource": ""
} | |
q41273 | train | function (cmd,context,silent)
{
var ctx = (context!=undefined?context:this);
try
{
return (function () {
var result = eval(cmd);
if (!silent)
self.e.log&&self.e.log(util.inspect(result),'result');
return result;
}.bind(ctx))();
} catch (e)
{
this.e.exception&&this.e.exc... | javascript | {
"resource": ""
} | |
q41274 | rehydrateAggregate | train | function rehydrateAggregate(ARObject){
return when.try(eventSink.rehydrate.bind(eventSink), ARObject, ARID, ARObject.getNextSequenceNumber());
} | javascript | {
"resource": ""
} |
q41275 | train | function()
{
this.anchor = this.view.env.document.createTextNode('');
var el = this.view.element;
if(el.parentNode)
{
el.parentNode.insertBefore(this.anchor, el.nextSibling);
el.parentNode.removeChild(el);
}
this.boundViews = [];
// Boundview options:
this.boundViewName = this.view.element.get... | javascript | {
"resource": ""
} | |
q41276 | train | function()
{
var boundView, i, l;
// Destroy boundviews
if(this.boundViews !== null)
{
for(i = 0, l = this.boundViews.length; i < l; i++)
{
boundView = this.boundViews[i];
boundView.destroyAll();
if(boundView.element && boundView.element.parentNode) boundView.element.parentNode.removeChild(b... | javascript | {
"resource": ""
} | |
q41277 | train | function(from, to)
{
if(!from) from = 0;
if(!to || to > this.boundViews.length) to = this.boundViews.length;
// Reindex subsequent boundviews:
for(var i = from; i < to; i++)
{
this.boundViews[i].setBindingIndex(i);
this.boundViews[i].refreshBinders(true);
}
} | javascript | {
"resource": ""
} | |
q41278 | train | function(item)
{
var boundView, element, i;
if(!this.viewTemplate)
{
element = this.view.element.cloneNode(true);
this.boundViewOptions.element = element;
boundView = new this.view.constructor(this.boundViewOptions);
boundView._collectionBinder = null;
boundView._modelBindersMap = this.view._m... | javascript | {
"resource": ""
} | |
q41279 | normalize | train | function normalize(acc, val) {
if (typeof val === 'string') {
var value = val.trim().replace(acc.refIgnoreRegExp, REF_MAGIC);
if (value.indexOf(acc.refLabel) === 0 && value.indexOf(acc.refLabel + acc.macroBegin) === -1) {
value = value.substring(acc.refLabel.length);
this.update(acc.get(value));
} else if ... | javascript | {
"resource": ""
} |
q41280 | HyperConfig | train | function HyperConfig(options) {
this.name = 'HyperConfig';
if (!(this instanceof HyperConfig)) {
return new HyperConfig(options);
}
options = options || {};
this._refLabel = options.refLabel || '~';
this._annotationLabel = options.annotationLabel || '@';
this._macroBegin = options.macroBegin || '{';
this._mac... | javascript | {
"resource": ""
} |
q41281 | isEmpty | train | function isEmpty(ptr, propDesc, value) {
if ((value === undefined) || (value === null))
return true;
if (propDesc.isArray() && !ptr.collectionElement && Array.isArray(value)) {
if (value.length === 0)
return true;
} else if (propDesc.isMap() && !ptr.collectionElement &&
((typeof value) === 'object')) {
... | javascript | {
"resource": ""
} |
q41282 | hasMatchingSibling | train | function hasMatchingSibling(ctx, propName, testValue, whenErrors) {
const containerDesc = ctx.currentPropDesc.container;
const propDesc = containerDesc.getPropertyDesc(propName);
let propPtr;
if (containerDesc.parentContainer &&
containerDesc.parentContainer.isPolymorphObject()) {
const pathParts = containerD... | javascript | {
"resource": ""
} |
q41283 | addDepsError | train | function addDepsError(ctx, type, propName, testValue) {
let depsErrors = ctx[DEPS_ERRORS];
if (!depsErrors)
depsErrors = ctx[DEPS_ERRORS] = {};
const curPtrStr = ctx.currentPointer.toString();
if (depsErrors[curPtrStr])
return;
depsErrors[curPtrStr] = true;
const hasTestValue = (testValue !== undefined);
... | javascript | {
"resource": ""
} |
q41284 | Credentials | train | function Credentials (options) {
EventEmitter.call(this)
options.keys.apiVersion = 'latest'
options.keys.sslEnabled = true
if (options.hasOwnProperty('upgrade')) {
// Update with the MFA token passed in with the credentials
this.upgrade(options)
return
}
let awsConfig = Object.assign({}, opti... | javascript | {
"resource": ""
} |
q41285 | train | function (controlPoint, uuid, location, desc, localAddress) {
EventEmitter.call(this);
if (TRACE) {
logger.info({
method: "UpnpDevice",
uuid: uuid,
}, "new device object");
}
this.controlPoint = controlPoint;
this.uuid = uuid;
this.udn = desc.UDN[0];
... | javascript | {
"resource": ""
} | |
q41286 | extendHttpRequest | train | function extendHttpRequest(req) {
req = req || express.request;
/**
* get param value from path-variable or query or body or headers.
* @param {string} paramName
* @param {*} [fallback]
* @returns {*}
*/
req.anyParam = function (paramName, fallback) {
return (this.params &&... | javascript | {
"resource": ""
} |
q41287 | extendHttpResponse | train | function extendHttpResponse(res) {
res = res || express.response;
function callbackFnFn(verbFunc) {
return function (next, status) {
var res = this;
return function (err, result) {
if (err) {
return next(err);
}
... | javascript | {
"resource": ""
} |
q41288 | matches | train | function matches(el, target, selector)
{
var elements = el.querySelectorAll(selector);
return arrayIndexOf(elements, target) !== -1;
} | javascript | {
"resource": ""
} |
q41289 | tumblr | train | function tumblr(hostname, key, secret, access_key, access_secret) {
if (!(this instanceof tumblr)) return new tumblr(hostname, key, secret, access_key, access_secret);
var obj = (typeof hostname !== 'object') ? {
hostname : hostname,
secret : secret,
key : key,
access_secret : access_secret,
ac... | javascript | {
"resource": ""
} |
q41290 | create | train | function create(requestObj, callback) {
var storage = this;
callback = callback || function defaultPostCallback() {
//setup Error Notification here
};
if ((typeof requestObj) === 'undefined' || requestObj === null) {
... | javascript | {
"resource": ""
} |
q41291 | find | train | function find(requestObj, callback) {
var found, storedData, property;
var storage = this;
callback = callback || function defaultGetCallback() {
//nothing here maybe put error notification
};
for (i = 0; i < storage.preproces... | javascript | {
"resource": ""
} |
q41292 | update | train | function update(requestObj, callback) {
var storage = this;
callback = callback || function defaultPutCallBack() {
//setup Error notification
};
if ((typeof requestObj) === 'undefined' || requestObj === null) {
callb... | javascript | {
"resource": ""
} |
q41293 | remove | train | function remove(requestObj, callback) {
var storageInstance = this;
var storage = this;
callback = callback || function defaultRemoveCallBack() {
//setup Error Notification
};
if ((typeof requestObj) === 'undefined' ||... | javascript | {
"resource": ""
} |
q41294 | log | train | function log ( object, symbol ) {
var message = (object.plugin ? ("(" + (object.plugin) + " plugin) " + (object.message)) : object.message) || object;
stderr( ("" + symbol + (index$3.bold( message ))) );
if ( object.url ) {
stderr( index$3.cyan( object.url ) );
}
if ( object.loc ) {
stderr( ((relativeId( ob... | javascript | {
"resource": ""
} |
q41295 | train | function(into, from) {
for (var key in from) {
if (into[key] instanceof Object &&
!(into[key] instanceof Array) &&
!(into[key] instanceof Function)) {
merge_(into[key], from[key]);
} else {
into[key] = from[key];
}
}
return into;
} | javascript | {
"resource": ""
} | |
q41296 | split | train | function split( command ) {
if ( typeof command !== 'string' ) {
throw new Error( 'Command must be a string' );
}
var r = command.match( /[^"\s]+|"(?:\\"|[^"])*"/g );
if ( ! r ) {
return [];
}
return r.map( function ( expr ) {
var isQuoted = expr.charAt( 0 ) === '"' && ... | javascript | {
"resource": ""
} |
q41297 | splitToObject | train | function splitToObject( command ) {
var cmds = split( command );
switch( cmds.length ) {
case 0: return {};
case 1: return { command: cmds[ 0 ] };
default: {
var first = cmds[ 0 ];
cmds.shift();
return { command: first, args: cmds };
}
}
} | javascript | {
"resource": ""
} |
q41298 | train | function(params, callback) {
if (!params.url) return (callback || function() {})(new Error(utils.i18n.webhooks.url));
if (!params.events || !params.events.length) return (callback || function() {})(new Error(utils.i18n.webhooks.events));
if (!params.secret) return (callback || function() {})(new Err... | javascript | {
"resource": ""
} | |
q41299 | train | function(webhookId, callback) {
utils.debug('Webhooks disable: ' + webhookId);
request.post({
path: '/webhooks/' + utils.toUUID(webhookId) + '/deactivate',
}, callback || utils.nop);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.