_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q45000 | _runInDataframes | train | function _runInDataframes (viewportExpressions, renderLayer, dataframes) {
const processedFeaturesIDs = new Set(); // same feature can belong to multiple dataframes
const viz = renderLayer.viz;
const inViewportFeaturesIDs = new Set();
dataframes.forEach(dataframe => {
_runInDataframe(viz, viewp... | javascript | {
"resource": ""
} |
q45001 | _runForPartialViewportFeatures | train | function _runForPartialViewportFeatures (viewportFeaturesExpressions, renderLayer, featuresIDs) {
// Reset previous expressions with (possibly 1 partial) features
viewportFeaturesExpressions.forEach(expr => expr._resetViewportAgg(null, renderLayer));
// Gather all pieces per feature
const piecesPerFeat... | javascript | {
"resource": ""
} |
q45002 | checkAuth | train | function checkAuth (auth) {
if (util.isUndefined(auth)) {
throw new CartoValidationError('\'auth\'', CartoValidationErrorTypes.MISSING_REQUIRED);
}
if (!util.isObject(auth)) {
throw new CartoValidationError('\'auth\' property must be an object.', CartoValidationErrorTypes.INCORRECT_TYPE);
... | javascript | {
"resource": ""
} |
q45003 | resolveConfigPath | train | function resolveConfigPath(configPath) {
// Specify a default
configPath = configPath || '.pa11yci';
if (configPath[0] !== '/') {
configPath = path.join(process.cwd(), configPath);
}
if (/\.js(on)?$/.test(configPath)) {
configPath = configPath.replace(/\.js(on)?$/, '');
}
return configPath;
} | javascript | {
"resource": ""
} |
q45004 | loadLocalConfigUnmodified | train | function loadLocalConfigUnmodified(configPath) {
try {
return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
} catch (error) {
if (error.code !== 'ENOENT') {
throw error;
}
}
} | javascript | {
"resource": ""
} |
q45005 | defaultConfig | train | function defaultConfig(config) {
config.urls = config.urls || [];
config.defaults = config.defaults || {};
config.defaults.log = config.defaults.log || console;
// Setting to undefined rather than 0 allows for a fallback to the default
config.defaults.wrapWidth = process.stdout.columns || undefined;
if (program.... | javascript | {
"resource": ""
} |
q45006 | loadSitemapIntoConfig | train | function loadSitemapIntoConfig(program, config) {
const sitemapUrl = program.sitemap;
const sitemapFind = (
program.sitemapFind ?
new RegExp(program.sitemapFind, 'gi') :
null
);
const sitemapReplace = program.sitemapReplace || '';
const sitemapExclude = (
program.sitemapExclude ?
new RegExp(program.sitem... | javascript | {
"resource": ""
} |
q45007 | WaveformDataSegment | train | function WaveformDataSegment(context, start, end) {
this.context = context;
/**
* Start index.
*
* ```javascript
* var waveform = new WaveformData({ ... }, WaveformData.adapters.object);
* waveform.set_segment(10, 50, "example");
*
* console.log(waveform.segments.example.start); // -> 10
*... | javascript | {
"resource": ""
} |
q45008 | WaveformData | train | function WaveformData(response_data, adapter) {
/**
* Backend adapter used to manage access to the data.
*
* @type {Object}
*/
this.adapter = adapter.fromResponseData(response_data);
/**
* Defined segments.
*
* ```javascript
* var waveform = new WaveformData({ ... }, WaveformData.adapter... | javascript | {
"resource": ""
} |
q45009 | setSegment | train | function setSegment(start, end, identifier) {
if (identifier === undefined || identifier === null || identifier.length === 0) {
identifier = "default";
}
this.segments[identifier] = new WaveformDataSegment(this, start, end);
return this.segments[identifier];
} | javascript | {
"resource": ""
} |
q45010 | setPoint | train | function setPoint(timeStamp, identifier) {
if (identifier === undefined || identifier === null || identifier.length === 0) {
identifier = "default";
}
this.points[identifier] = new WaveformDataPoint(this, timeStamp);
return this.points[identifier];
} | javascript | {
"resource": ""
} |
q45011 | getOffsetValues | train | function getOffsetValues(start, length, correction) {
var adapter = this.adapter;
var values = [];
correction += (start * 2); // offset the positioning query
for (var i = 0; i < length; i++) {
values.push(adapter.at((i * 2) + correction));
}
return values;
} | javascript | {
"resource": ""
} |
q45012 | fromAudioObjectBuilder | train | function fromAudioObjectBuilder(audio_context, raw_response, options, callback) {
var audioContext = window.AudioContext || window.webkitAudioContext;
if (!(audio_context instanceof audioContext)) {
throw new TypeError("First argument should be an AudioContext instance");
}
var opts = getOptions(options, ... | javascript | {
"resource": ""
} |
q45013 | ADD_LOCALE | train | function ADD_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations);
if (state.translations.hasOwnProperty(payload.locale)) {
// get the existing translations
var existingTranslations = state.transl... | javascript | {
"resource": ""
} |
q45014 | REPLACE_LOCALE | train | function REPLACE_LOCALE(state, payload) {
// reduce the given translations to a single-depth tree
var translations = flattenTranslations(payload.translations); // replace the translations entirely
state.translations[payload.locale] = translations; // make sure to notify vue of changes (this might bre... | javascript | {
"resource": ""
} |
q45015 | REMOVE_LOCALE | train | function REMOVE_LOCALE(state, payload) {
// check if the given locale is present in the state
if (state.translations.hasOwnProperty(payload.locale)) {
// check if the current locale is the given locale to remvoe
if (state.locale === payload.locale) {
// reset the current locale
... | javascript | {
"resource": ""
} |
q45016 | addLocale | train | function addLocale(context, payload) {
context.commit({
type: 'ADD_LOCALE',
locale: payload.locale,
translations: payload.translations
});
} | javascript | {
"resource": ""
} |
q45017 | replaceLocale | train | function replaceLocale(context, payload) {
context.commit({
type: 'REPLACE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
} | javascript | {
"resource": ""
} |
q45018 | removeLocale | train | function removeLocale(context, payload) {
context.commit({
type: 'REMOVE_LOCALE',
locale: payload.locale,
translations: payload.translations
});
} | javascript | {
"resource": ""
} |
q45019 | flattenTranslations | train | function flattenTranslations(translations) {
var toReturn = {};
for (var i in translations) {
// check if the property is present
if (!translations.hasOwnProperty(i)) {
continue;
} // get the type of the property
var objType = _typeof(translations[i]); // allow unflattened array of strings
... | javascript | {
"resource": ""
} |
q45020 | $t | train | function $t() {
// get the current language from the store
var locale = store.state[moduleName].locale;
return translateInLanguage.apply(void 0, [locale].concat(Array.prototype.slice.call(arguments)));
} | javascript | {
"resource": ""
} |
q45021 | checkKeyExists | train | function checkKeyExists(key) {
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'fallback';
// get the current language from the store
var locale = store.state[moduleName].locale;
var fallback = store.state[moduleName].fallback;
var translations = store.state[moduleNam... | javascript | {
"resource": ""
} |
q45022 | replaceLocale | train | function replaceLocale(locale, translations) {
return store.dispatch({
type: "".concat(moduleName, "/replaceLocale"),
locale: locale,
translations: translations
});
} | javascript | {
"resource": ""
} |
q45023 | removeLocale | train | function removeLocale(locale) {
if (store.state[moduleName].translations.hasOwnProperty(locale)) {
store.dispatch({
type: "".concat(moduleName, "/removeLocale"),
locale: locale
});
}
} | javascript | {
"resource": ""
} |
q45024 | replace | train | function replace(translation, replacements) {
// check if the object has a replace property
if (!translation.replace) {
return translation;
}
return translation.replace(matcher, function (placeholder) {
// remove the identifiers (can be set on the module level)
var key = placeholder.r... | javascript | {
"resource": ""
} |
q45025 | render | train | function render(locale, translation) {
var replacements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var pluralization = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
// get the type of the property
var objType = _typeof(translation);
var pl... | javascript | {
"resource": ""
} |
q45026 | findInheritedProperties | train | function findInheritedProperties(ci, properties) {
while (ci && ci.extends) {
ci = findTypeMetaInfo(ci.extends);
if (!ci) {
console.warn('no meta info for: ' + ci.extends);
continue;
}
mergeProperties(ci).forEach(p => {
if (properties.find(... | javascript | {
"resource": ""
} |
q45027 | findInheritedMethods | train | function findInheritedMethods(ci, methods) {
while (ci && ci.extends) {
ci = findTypeMetaInfo(ci.extends);
if (!ci) {
console.warn('no meta info for: ' + ci.extends);
continue;
}
(ci.methodsClass || ci.methods).forEach(m => {
if (methods.fi... | javascript | {
"resource": ""
} |
q45028 | multipleFilterFn | train | function multipleFilterFn () {
return this.choices.choices
.filter((choice) => choice.checked)
.map((choice) => choice.key)
} | javascript | {
"resource": ""
} |
q45029 | train | function(msg, levelMsg) {
if (console.isTimestamped()) {
return "[" + levelMsg + " - " + new Date().toJSON() + "] " + msg;
} else {
return "[" + levelMsg + "] " + msg;
}
} | javascript | {
"resource": ""
} | |
q45030 | train | function(d, val) {
val = val > 86399 ? 0 : val;
var next = later.date.next(
later.Y.val(d),
later.M.val(d),
later.D.val(d) + (val <= later.t.val(d) ? 1 : 0),
0,
0,
val);
// correct for passing over a daylight savings boundry
if(!later.date.isUTC && next.getTime() < ... | javascript | {
"resource": ""
} | |
q45031 | train | function(d) {
if (d.wy) return d.wy;
// move to the Thursday in the target week and find Thurs of target year
var wThur = later.dw.next(later.wy.start(d), 5),
YThur = later.dw.next(later.Y.prev(wThur, later.Y.val(wThur)-1), 5);
// caculate the difference between the two dates in weeks
retu... | javascript | {
"resource": ""
} | |
q45032 | train | function(d) {
if (d.wyExtent) return d.wyExtent;
// go to start of ISO week to get to the right year
var year = later.dw.next(later.wy.start(d), 5),
dwFirst = later.dw.val(later.Y.start(year)),
dwLast = later.dw.val(later.Y.end(year));
return (d.wyExtent = [1, dwFirst === 5 || dwLast =... | javascript | {
"resource": ""
} | |
q45033 | train | function(d, val) {
var wyThur = later.dw.next(later.wy.start(d), 5),
year = later.date.prevRollover(wyThur, val, later.wy, later.Y);
// handle case where 1st of year is last week of previous month
if(later.wy.val(year) !== 1) {
year = later.dw.next(year, 2);
}
var wyMax = later.wy.ex... | javascript | {
"resource": ""
} | |
q45034 | train | function(d) {
return d.dc || (d.dc = Math.floor((later.D.val(d)-1)/7)+1);
} | javascript | {
"resource": ""
} | |
q45035 | train | function(d) {
return d.dcExtent || (d.dcExtent = [1, Math.ceil(later.D.extent(d)[1] /7)]);
} | javascript | {
"resource": ""
} | |
q45036 | train | function(d) {
return d.dcStart || (d.dcStart =
later.date.next(
later.Y.val(d),
later.M.val(d),
Math.max(1, ((later.dc.val(d) - 1) * 7) + 1 || 1)));
} | javascript | {
"resource": ""
} | |
q45037 | train | function(d) {
return d.dcEnd || (d.dcEnd =
later.date.prev(
later.Y.val(d),
later.M.val(d),
Math.min(later.dc.val(d) * 7, later.D.extent(d)[1])));
} | javascript | {
"resource": ""
} | |
q45038 | train | function(d, val) {
val = val > later.dc.extent(d)[1] ? 1 : val;
var month = later.date.nextRollover(d, val, later.dc, later.M),
dcMax = later.dc.extent(month)[1];
val = val > dcMax ? 1 : val;
var next = later.date.next(
later.Y.val(month),
later.M.val(month),
val === 0 ? late... | javascript | {
"resource": ""
} | |
q45039 | train | function(d, val) {
var month = later.date.prevRollover(d, val, later.dc, later.M),
dcMax = later.dc.extent(month)[1];
val = val > dcMax ? dcMax : val || dcMax;
return later.dc.end(later.date.prev(
later.Y.val(month),
later.M.val(month),
1 + (7 * (val - 1))
));
} | javascript | {
"resource": ""
} | |
q45040 | train | function(d) {
return d.wm || (d.wm =
(later.D.val(d) +
(later.dw.val(later.M.start(d)) - 1) + (7 - later.dw.val(d))) / 7);
} | javascript | {
"resource": ""
} | |
q45041 | train | function(d) {
return d.wmExtent || (d.wmExtent = [1,
(later.D.extent(d)[1] + (later.dw.val(later.M.start(d)) - 1) +
(7 - later.dw.val(later.M.end(d)))) / 7]);
} | javascript | {
"resource": ""
} | |
q45042 | train | function(d) {
return d.wmStart || (d.wmStart = later.date.next(
later.Y.val(d),
later.M.val(d),
Math.max(later.D.val(d) - later.dw.val(d) + 1, 1)));
} | javascript | {
"resource": ""
} | |
q45043 | train | function(d) {
return d.wmEnd || (d.wmEnd = later.date.prev(
later.Y.val(d),
later.M.val(d),
Math.min(later.D.val(d) + (7 - later.dw.val(d)), later.D.extent(d)[1])));
} | javascript | {
"resource": ""
} | |
q45044 | train | function(d, val) {
val = val > later.wm.extent(d)[1] ? 1 : val;
var month = later.date.nextRollover(d, val, later.wm, later.M),
wmMax = later.wm.extent(month)[1];
val = val > wmMax ? 1 : val || wmMax;
// jump to the Sunday of the desired week, set to 1st of month for week 1
return later.d... | javascript | {
"resource": ""
} | |
q45045 | train | function (id, vals) {
var custom = later.modifier[id];
if(!custom) throw new Error('Custom modifier ' + id + ' not recognized!');
modifier = id;
values = arguments[1] instanceof Array ? arguments[1] : [arguments[1]];
return this;
} | javascript | {
"resource": ""
} | |
q45046 | train | function (id) {
var custom = later[id];
if(!custom) throw new Error('Custom time period ' + id + ' not recognized!');
add(id, custom.extent(new Date())[0], custom.extent(new Date())[1]);
return this;
} | javascript | {
"resource": ""
} | |
q45047 | train | function(d) {
return d.s || (d.s = later.date.getSec.call(d));
} | javascript | {
"resource": ""
} | |
q45048 | train | function(d) {
var year = later.Y.val(d);
// shortcut on finding leap years since this function gets called a lot
// works between 1901 and 2099
return d.dyExtent || (d.dyExtent = [1, year % 4 ? 365 : 366]);
} | javascript | {
"resource": ""
} | |
q45049 | train | function(d, val) {
var m = later.m.val(d),
s = later.s.val(d),
inc = val > 59 ? 60-m : (val <= m ? (60-m) + val : val-m),
next = new Date(d.getTime() + (inc * later.MIN) - (s * later.SEC));
// correct for passing over a daylight savings boundry
if(!later.date.isUTC && next.getTime()... | javascript | {
"resource": ""
} | |
q45050 | calcEnd | train | function calcEnd(dir, schedArr, startsArr, startDate, maxEndDate) {
var compare = compareFn(dir), result;
for(var i = 0, len = schedArr.length; i < len; i++) {
var start = startsArr[i];
if(start && start.getTime() === startDate.getTime()) {
var end = schedArr[i].end(dir, start);
/... | javascript | {
"resource": ""
} |
q45051 | cloneSchedule | train | function cloneSchedule(sched) {
var clone = {}, field;
for(field in sched) {
if (field !== 'dc' && field !== 'd') {
clone[field] = sched[field].slice(0);
}
}
return clone;
} | javascript | {
"resource": ""
} |
q45052 | parse | train | function parse(item, s, name, min, max, offset) {
var value,
split,
schedules = s.schedules,
curSched = schedules[schedules.length-1];
// L just means min - 1 (this also makes it work for any field)
if (item === 'L') {
item = min - 1;
}
// parse x
if ((value = get... | javascript | {
"resource": ""
} |
q45053 | extend | train | function extend(src, props) {
props = props || {};
var p;
for (p in src) {
if (src.hasOwnProperty(p)) {
if (!props.hasOwnProperty(p)) {
props[p] = src[p];
}
}
}
return props;
} | javascript | {
"resource": ""
} |
q45054 | createElement | train | function createElement(name, props) {
var c = document,
d = c.createElement(name);
if (props && "[object Object]" === Object.prototype.toString.call(props)) {
var e;
for (e in props)
if ("html" === e) d.innerHTML = props[e];
else if ("text" === e) {
var f = c.createTextNode(props[e]);
d.app... | javascript | {
"resource": ""
} |
q45055 | style | train | function style(el, obj) {
if ( !obj ) {
return window.getComputedStyle(el);
}
if ("[object Object]" === Object.prototype.toString.call(obj)) {
var s = "";
each(obj, function(prop, val) {
if ( typeof val !== "string" && prop !== "opacity" ) {
val += "px";
}
s += prop + ": " + val + ";";... | javascript | {
"resource": ""
} |
q45056 | rect | train | function rect(t, e) {
var o = window,
r = t.getBoundingClientRect(),
x = o.pageXOffset,
y = o.pageYOffset,
m = {},
f = "none";
if (e) {
var s = style(t);
m = {
top: parseInt(s["margin-top"], 10),
left: parseInt(s["margin-left"], 10),
right: parseInt(s["margin-right"], 10),
bott... | javascript | {
"resource": ""
} |
q45057 | getScrollBarWidth | train | function getScrollBarWidth() {
var width = 0, div = createElement("div", { class: "scrollbar-measure" });
style(div, {
width: 100,
height: 100,
overflow: "scroll",
position: "absolute",
top: -9999
});
document.body.appendChild(div);
width = div.offsetWidth - div.clientWidth;
document.body... | javascript | {
"resource": ""
} |
q45058 | createExchangeErrorHandlerFor | train | function createExchangeErrorHandlerFor (exchange) {
return function (err) {
if (!exchange.options.confirm) return;
// should requeue instead?
// https://www.rabbitmq.com/reliability.html#producer
debug && debug('Exchange error handler triggered, erroring and wiping all unacked publishes');
for (v... | javascript | {
"resource": ""
} |
q45059 | parseInt | train | function parseInt (buffer, size) {
switch (size) {
case 1:
return buffer[buffer.read++];
case 2:
return (buffer[buffer.read++] << 8) + buffer[buffer.read++];
case 4:
return (buffer[buffer.read++] << 24) + (buffer[buffer.read++] << 16) +
(buffer[buffer.read++] << 8) + buff... | javascript | {
"resource": ""
} |
q45060 | registerable | train | function registerable (cfgObj) {
_.forIn(cfgObj, function (value, key) {
if (registerableCfg.indexOf(key) !== -1) {
register(key, cfgObj)
}
})
} | javascript | {
"resource": ""
} |
q45061 | parse | train | function parse(str, options) {
if (typeof str !== 'string') {
throw new TypeError('argument str must be a string');
}
var obj = {}
var opt = options || {};
var pairs = str.split(pairSplitRegExp);
var dec = opt.decode || decode;
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i];
va... | javascript | {
"resource": ""
} |
q45062 | findByNodeName | train | function findByNodeName(el, nodeName) {
if (!el.prop) { // not a jQuery or jqLite object -> wrap it
el = angular.element(el)
}
if (el.prop('nodeName') === nodeName.toUpperCase()) {
return el
}
const c = el.children()
for (let i = 0; c && i < c.length; i++) {
const node = findByNodeName(c[i], n... | javascript | {
"resource": ""
} |
q45063 | write | train | function write(rows, geometry_type, geometries, callback) {
var TYPE = types.geometries[geometry_type],
writer = writers[TYPE],
parts = writer.parts(geometries, TYPE),
shpLength = 100 + (parts - geometries.length) * 4 + writer.shpLength(geometries),
shxLength = 100 + writer.shxLengt... | javascript | {
"resource": ""
} |
q45064 | train | function(otherUserId, callback){
// if there is only one other user or the other user is the same user
if (otherUserIdsWhoRated.length === 1 || userId === otherUserId){
// then call the callback and exciting the similarity check
callback();
}
// if the use... | javascript | {
"resource": ""
} | |
q45065 | train | function(err){
client.del(recommendedZSet, function(err){
async.each(scoreMap,
function(scorePair, callback){
client.zadd(recommendedZSet, scorePair[0], scorePair[1], function(err){
callback();
});
... | javascript | {
"resource": ""
} | |
q45066 | findReplace | train | function findReplace (array, testFn) {
const found = [];
const replaceWiths = arrayify$1(arguments);
replaceWiths.splice(0, 2);
arrayify$1(array).forEach((value, index) => {
let expanded = [];
replaceWiths.forEach(replaceWith => {
if (typeof replaceWith === 'function') {
expanded = expand... | javascript | {
"resource": ""
} |
q45067 | isClass | train | function isClass (input) {
if (isFunction(input)) {
return /^class /.test(Function.prototype.toString.call(input))
} else {
return false
}
} | javascript | {
"resource": ""
} |
q45068 | isPromise | train | function isPromise (input) {
if (input) {
const isPromise = isDefined(Promise) && input instanceof Promise;
const isThenable = input.then && typeof input.then === 'function';
return !!(isPromise || isThenable)
} else {
return false
}
} | javascript | {
"resource": ""
} |
q45069 | warnIfNotLocal | train | function warnIfNotLocal() {
if (config.esclient.hosts.some((env) => { return env.host !== 'localhost'; } )) {
console.log(colors.red(`WARNING: DROPPING SCHEMA NOT ON LOCALHOST: ${config.esclient.hosts[0].host}`));
}
} | javascript | {
"resource": ""
} |
q45070 | makeAction | train | function makeAction (controller, method, opts) {
let action = {action: controller + '@' + method};
return extend (action, opts);
} | javascript | {
"resource": ""
} |
q45071 | registerParticipant | train | function registerParticipant (name, participant) {
let barrier = barriers[name];
if (!barrier) {
debug (`creating barrier ${name}`);
barrier = barriers[name] = new Barrier ({name});
}
debug (`registering participant with barrier ${name}`);
return barrier.registerParticipant (participant);
} | javascript | {
"resource": ""
} |
q45072 | getResponseHeaders | train | function getResponseHeaders(xhr) {
let raw = xhr.getAllResponseHeaders();
let parts = raw.replace(/\s+$/, '').split(/\n/);
for (let i = 0; i < parts.length; i++) {
parts[i] = parts[i].replace(/\r/g, '').replace(/^\s+/, '').replace(/\s+$/, '');
}
return parts;
} | javascript | {
"resource": ""
} |
q45073 | queryUserInfo | train | function queryUserInfo(parentSpan, username, callback) {
// Aggregated user information across multiple API calls
var user = {
login : null,
type : null,
repoNames : [],
recentEvents : 0,
eventCounts : {},
};
// Call the callback only when all ... | javascript | {
"resource": ""
} |
q45074 | httpGet | train | function httpGet(parentSpan, urlString, callback) {
var span = opentracing.globalTracer().startSpan('http.get', { childOf : parentSpan });
var callbackWrapper = function (err, data) {
span.finish();
callback(err, data);
};
try {
var carrier = {};
opentracing.globalTracer... | javascript | {
"resource": ""
} |
q45075 | filterInPlace | train | function filterInPlace (arr, pred) {
var idx = 0;
for (var ii = 0; ii < arr.length; ++ii) {
if (pred(arr[ii])) {
arr[idx] = arr[ii];
++idx;
}
}
arr.length = idx;
} | javascript | {
"resource": ""
} |
q45076 | normalizeList | train | function normalizeList(dom) {
for (let child = dom.firstChild, prevItem = null; child; child = child.nextSibling) {
let name = child.nodeType == 1 ? child.nodeName.toLowerCase() : null
if (name && listTags.hasOwnProperty(name) && prevItem) {
prevItem.appendChild(child)
child = prevItem
} else ... | javascript | {
"resource": ""
} |
q45077 | matches | train | function matches(dom, selector) {
return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector)
} | javascript | {
"resource": ""
} |
q45078 | nullFrom | train | function nullFrom(nfa, node) {
let result = []
scan(node)
return result.sort(cmp)
function scan(node) {
let edges = nfa[node]
if (edges.length == 1 && !edges[0].term) return scan(edges[0].to)
result.push(node)
for (let i = 0; i < edges.length; i++) {
let {term, to} = edges[i]
if (!t... | javascript | {
"resource": ""
} |
q45079 | connect | train | function connect(orbs, callback) {
var total = Object.keys(orbs).length,
finished = 0;
function done() {
finished++;
if (finished >= total) { callback(); }
}
for (var name in orbs) {
orbs[name].connect(done);
}
} | javascript | {
"resource": ""
} |
q45080 | start | train | function start(name) {
var orb = spheros[name],
contacts = 0,
age = 0,
alive = false;
orb.detectCollisions();
born();
orb.on("collision", function() { contacts += 1; });
setInterval(function() { if (alive) { move(); } }, 3000);
setInterval(birthday, 10000);
// roll Sphero in a rando... | javascript | {
"resource": ""
} |
q45081 | calculateLuminance | train | function calculateLuminance(hex, lum) {
return Math.round(Math.min(Math.max(0, hex + (hex * lum)), 255));
} | javascript | {
"resource": ""
} |
q45082 | adjustLuminance | train | function adjustLuminance(rgb, lum) {
var newRgb = {};
newRgb.red = calculateLuminance(rgb.red, lum);
newRgb.green = calculateLuminance(rgb.green, lum);
newRgb.blue = calculateLuminance(rgb.blue, lum);
return newRgb;
} | javascript | {
"resource": ""
} |
q45083 | warn | train | function warn( message )
{
if ( message in warn.cache ) {
return;
}
const prefix = chalk.hex('#CC4A8B')('WARNING:');
console.warn(chalk`${prefix} ${message}`);
} | javascript | {
"resource": ""
} |
q45084 | filterHashes | train | function filterHashes( hashes )
{
const validHashes = crypto.getHashes();
return hashes.filter( hash => {
if ( validHashes.includes(hash) ) {
return true;
}
warn(chalk`{blueBright ${hash}} is not a supported hash algorithm`);
return false;
});
} | javascript | {
"resource": ""
} |
q45085 | varType | train | function varType( v )
{
const [ , type ] = Object.prototype.toString.call( v ).match(/\[object\s(\w+)\]/);
return type;
} | javascript | {
"resource": ""
} |
q45086 | getSortedObject | train | function getSortedObject(object, compareFunction)
{
const keys = Object.keys(object);
keys.sort( compareFunction );
return keys.reduce(
(sorted, key) => (sorted[ key ] = object[ key ], sorted),
Object.create(null)
);
} | javascript | {
"resource": ""
} |
q45087 | createTag | train | function createTag(tagName, attrMap, publicPath) {
publicPath = publicPath || '';
// add trailing slash if we have a publicPath and it doesn't have one.
if (publicPath && !RE_ENDS_WITH_BS.test(publicPath)) {
publicPath += '/';
}
const attributes = Object.getOwnPropertyNames(attrMap)
.filter(function... | javascript | {
"resource": ""
} |
q45088 | getHtmlElementString | train | function getHtmlElementString(dataSource, publicPath) {
return Object.getOwnPropertyNames(dataSource)
.map(function(name) {
if (Array.isArray(dataSource[name])) {
return dataSource[name].map(function(attrs) { return createTag(name, attrs, publicPath); } );
} else {
return [ createTag(n... | javascript | {
"resource": ""
} |
q45089 | copyToDemo | train | function copyToDemo(srcArr) {
return gulp.src(srcArr)
.pipe(gulp.dest(function (file) {
return demoDist + file.base.slice(__dirname.length); // save directly to demo
}));
} | javascript | {
"resource": ""
} |
q45090 | copyToDist | train | function copyToDist(srcArr) {
return gulp.src(srcArr.concat(globalExcludes))
.pipe(gulp.dest(function (file) {
return libraryDist + file.base.slice(__dirname.length); // save directly to dist
}));
} | javascript | {
"resource": ""
} |
q45091 | transpileMinifyLESS | train | function transpileMinifyLESS(src) {
return gulp.src(src)
.pipe(sourcemaps.init())
.pipe(lessCompiler({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(cssmin().on('error', function(err) {
console.log(err);
}))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write... | javascript | {
"resource": ""
} |
q45092 | inlineTemplate | train | function inlineTemplate() {
return gulp.src(['./src/app/**/*.ts'].concat(globalExcludes), {base: './'})
.pipe(replace(/templateUrl.*\'/g, function (matched) {
var fileName = matched.match(/\/.*html/g).toString();
var dirName = this.file.relative.substring(0, this.file.relative.lastIndexOf('/'));
... | javascript | {
"resource": ""
} |
q45093 | transpileAot | train | function transpileAot() {
// https://stackoverflow.com/questions/36897877/gulp-error-the-following-tasks-did-not-complete-did-you-forget-to-signal-async
return new Promise(function(resolve, reject) {
// Need to capture the exit code
exec('node_modules/.bin/ngc -p tsconfig-aot.json', function (err, stdout, s... | javascript | {
"resource": ""
} |
q45094 | updateWatchDist | train | function updateWatchDist() {
return gulp
.src([libraryDist + '/**'].concat(globalExcludes))
.pipe(changed(watchDist))
.pipe(gulp.dest(watchDist));
} | javascript | {
"resource": ""
} |
q45095 | checkBinaryReady | train | function checkBinaryReady(uuid) {
if (!(uuid in api._blobs && uuid in api._binaryMessages)) {
return;
}
log('receive full binary message', uuid);
var blob = api._blobs[uuid];
var msg = api._binaryMessages[uuid];
delete api._blobs[uuid];
delete api._binaryMessages[uuid]... | javascript | {
"resource": ""
} |
q45096 | train | function(){
if (controller.connection.opts.requestProtocolVersion < 5 && controller.streamingCount == 0){
controller.streamingCount = 1;
var info = {
attached: true,
streaming: true,
type: 'unknown',
id: "Lx00000000000"
};
controller.devices[info.id] = info;
... | javascript | {
"resource": ""
} | |
q45097 | train | function(data) {
/**
* The center point of the circle within the Leap frame of reference.
*
* @member center
* @memberof Leap.CircleGesture.prototype
* @type {number[]}
*/
this.center = data.center;
/**
* The normal vector for the circle being traced.
*
* If you draw the circle clockwise, the norm... | javascript | {
"resource": ""
} | |
q45098 | train | function(data) {
/**
* The starting position within the Leap frame of
* reference, in mm.
*
* @member startPosition
* @memberof Leap.SwipeGesture.prototype
* @type {number[]}
*/
this.startPosition = data.startPosition;
/**
* The current swipe position within the Leap frame of
* reference, in mm.
... | javascript | {
"resource": ""
} | |
q45099 | train | function(data) {
/**
* The position where the key tap is registered.
*
* @member position
* @memberof Leap.KeyTapGesture.prototype
* @type {number[]}
*/
this.position = data.position;
/**
* The direction of finger tip motion.
*
* @member direction
* @membero... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.