_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q31000 | makePoint | train | function makePoint() {
// Pull start time from req and log responseTime
var responseTime = Date.now() - req.start;
// Add the new point to the batch of points
batch.points.push({
measurement: "requests",
"tags": {
"path": req.path,
"host": req.hostname,... | javascript | {
"resource": ""
} |
q31001 | isGonnaBeLegen | train | function isGonnaBeLegen() {
current = shift.call(queue);
if (current) {
if (typeof current == "function") {
current = {name: current[NAME] || "anonymous", test: current};
}
(node = putItThereAndGimmeBack(
putItThereAndGimmeBack(wru.node... | javascript | {
"resource": ""
} |
q31002 | patch | train | function patch(obj, properties) {
var old = {};
for (var name in properties) {
old[name] = obj[name];
obj[name] = properties[name];
}
return old;
} | javascript | {
"resource": ""
} |
q31003 | giveItATry | train | function giveItATry(name) {
if (iHasIt(current, name)) {
try {
current[name](tmp);
} catch(doooodeThisIsBAD) {
push.call(fatal, EMPTY + doooodeThisIsBAD);
}
}
} | javascript | {
"resource": ""
} |
q31004 | isGonnaBeLegen | train | function isGonnaBeLegen() {
current = shift.call(queue);
if (current) {
if (typeof current == "function") {
current = {name: current[NAME] || "anonymous", test: current};
}
log(OUTPUT_SEPARATOR);
log(
(iHasIt(current, NAME) ... | javascript | {
"resource": ""
} |
q31005 | checkVertStretch | train | function checkVertStretch (up, dn, g, doP) /* non-MathML */ {
if (g.nodeName.toLowerCase() == 'mo' && g.childNodes.length == 1) {
var c = g.firstChild, s = c.data;
if (c.nodeType == 3 /* Text */ && (up > 0.9 || dn > 0.9)
&& (M.prefix_[s] < 25 || M.postfix_[s] < 25
|| '|\u2016\u221A' /* ‖ √... | javascript | {
"resource": ""
} |
q31006 | parse_table_tokP | train | function parse_table_tokP (dtableQ) {
if (dtableQ === undefined) dtableQ = M.dtableQ;
var mtrs = [];
while (true) {
var mtrP_tokP = parse_mtr_tokP(mtrs.length == 0), mtrP = mtrP_tokP[0],
tokP = mtrP_tokP[1] || scanTokP();
if (mtrP) mtrs.push(mtrP);
if (!(tokP && tokP[1] == ';'))
return [n... | javascript | {
"resource": ""
} |
q31007 | listCacheSet$1 | train | function listCacheSet$1(key, value) {
var data = this.__data__,
index = assocIndexOf$4(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
} | javascript | {
"resource": ""
} |
q31008 | hashDelete$1 | train | function hashDelete$1(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
} | javascript | {
"resource": ""
} |
q31009 | getMapData$1 | train | function getMapData$1(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
} | javascript | {
"resource": ""
} |
q31010 | arrayEach$1 | train | function arrayEach$1(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
} | javascript | {
"resource": ""
} |
q31011 | copyArray$1 | train | function copyArray$1(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
} | javascript | {
"resource": ""
} |
q31012 | arrayPush$1 | train | function arrayPush$1(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
} | javascript | {
"resource": ""
} |
q31013 | setToArray$1 | train | function setToArray$1(set) {
var index = -1,
result = Array(set.size);
set.forEach(function (value) {
result[++index] = value;
});
return result;
} | javascript | {
"resource": ""
} |
q31014 | arrayMap$1 | train | function arrayMap$1(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
} | javascript | {
"resource": ""
} |
q31015 | baseSet$1 | train | function baseSet$1(object, path, value, customizer) {
if (!isObject$6(object)) {
return object;
}
path = castPath$2(path, object);
var index = -1,
length = path.length,
lastIndex = length - 1,
nested = object;
while (nested != null && ++index < length) {
var key = toKey$2(path[inde... | javascript | {
"resource": ""
} |
q31016 | baseSlice$1 | train | function baseSlice$1(array, start, end) {
var index = -1,
length = array.length;
if (start < 0) {
start = -start > length ? 0 : length + start;
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : end - start >>> 0;
start >>>= 0;
var result = ... | javascript | {
"resource": ""
} |
q31017 | baseUnset$1 | train | function baseUnset$1(object, path) {
path = castPath$3(path, object);
object = parent(object, path);
return object == null || delete object[toKey$3(last(path))];
} | javascript | {
"resource": ""
} |
q31018 | baseFindIndex$1 | train | function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
var length = array.length,
index = fromIndex + (fromRight ? 1 : -1);
while (fromRight ? index-- : ++index < length) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
} | javascript | {
"resource": ""
} |
q31019 | baseIndexOf$1 | train | function baseIndexOf$1(array, value, fromIndex) {
return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
} | javascript | {
"resource": ""
} |
q31020 | shortOut$1 | train | function shortOut$1(func) {
var count = 0,
lastCalled = 0;
return function () {
var stamp = nativeNow(),
remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) {
return arguments[0];
}
} else {
count =... | javascript | {
"resource": ""
} |
q31021 | baseDifference$1 | train | function baseDifference$1(array, values, iteratee, comparator) {
var index = -1,
includes = arrayIncludes$2,
isCommon = true,
length = array.length,
result = [],
valuesLength = values.length;
if (!length) {
return result;
}
if (iteratee) {
values = arrayMap$4(values, baseU... | javascript | {
"resource": ""
} |
q31022 | baseFlatten$1 | train | function baseFlatten$1(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth > 1) {
/... | javascript | {
"resource": ""
} |
q31023 | train | function() {
if (node.debug) {
node.log('STARTING event listener');
}
var net = require('net');
var dgram = require('dgram');
node.inputSocket = dgram.createSocket({type:'udp4', reuseAddr: true});
node.inputSocket.on('notify', function (event) {
if (node.debug) {
... | javascript | {
"resource": ""
} | |
q31024 | transform | train | function transform(str) {
str = str.split(/^lazy\(/gm).join('require(');
var lines = str.split(/\r\n|\n/);
var len = lines.length;
var re = regex();
var idx = 0;
var start = false;
var isExported = false;
var namespace;
var res = '';
while (idx < len) {
var line = lines[idx++];
res += '\n'... | javascript | {
"resource": ""
} |
q31025 | camelcase | train | function camelcase(str) {
if (!/[\s\W]/.test(str)) return str;
if (str.length === 1) {
return str.toLowerCase();
}
str = str.replace(/^[\W_]+|[\W_]+$/g, '').toLowerCase();
return str.replace(/[\W_]+(\w|$)/g, function(_, ch) {
return ch.toUpperCase();
});
} | javascript | {
"resource": ""
} |
q31026 | createWasmModule | train | function createWasmModule(source, wasm) {
var length = wasm.length;
var buffer = [];
for (var i = 0; i < length; i += 1) {
buffer.push(wasm[i]);
}
var module = "var buffer = new ArrayBuffer(" + wasm.length + ");\n var uint8 = new Uint8Array(buffer);\n uint8.set([" + buffer.join... | javascript | {
"resource": ""
} |
q31027 | createJsModule | train | function createJsModule(source) {
var compilerOptions = {
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
alwaysStrict: false
}
};
var transpiled = ts.transpileModule(source, compilerOptions);
return transpiled.outputTex... | javascript | {
"resource": ""
} |
q31028 | AssemblyScriptLiveLoader | train | function AssemblyScriptLiveLoader(source) {
var jsModule;
var wasmModule;
if (this.cacheable) {
this.cacheable();
}
this.addDependency(wasmFooterPath);
jsModule = createJsModule(source);
wasmModule = createWasmModule(source, compile(source));
return createCompatibleModule(jsModul... | javascript | {
"resource": ""
} |
q31029 | createTimeout | train | function createTimeout(timer, i, callback) {
return setTimeout(function() {
callback(timer, i);
}, timer.seconds * 1000);
} | javascript | {
"resource": ""
} |
q31030 | init | train | function init(_config) {
if (initialized)
return;
// Validate the config
config = helpers.validateConfig(_config);
// Create a user for the bot
users[config.name] = helpers.createUser(true);
// Create a user for the channel owner
var name = config.channel.replace('#', '');
users[name] = helpers.c... | javascript | {
"resource": ""
} |
q31031 | exit | train | function exit() {
if (!initialized || exited)
return;
log('Exiting...', true);
// Leave the twitch channel
if (ircClient)
ircClient.part(config.channel);
// Leave discord
if (discordClient)
discordClient.disconnect();
// Clear the stream check interval
if (streamInterval)
clearInterv... | javascript | {
"resource": ""
} |
q31032 | isSpam | train | function isSpam(from, message) {
if (!config.filterSpam)
return false;
// Skip if this is a mod
if (users[from] && users[from].mod)
return false;
// Check for capital letter spam
var uppercaseCount = message.replace(/[^A-Z]/g, '').length;
if (uppercaseCount >= 10 && uppercaseCount >= message.lengt... | javascript | {
"resource": ""
} |
q31033 | timeoutUser | train | function timeoutUser(name, seconds, reason) {
// Create a user if it doesn't exist
users[name] = users[name] || helpers.createUser();
users[name].offenses++;
var offenses = users[name].offenses;
if (offenses > config.maxOffenses)
banUser(name);
else {
seconds = seconds || (offenses === 1 ? 10 : 60... | javascript | {
"resource": ""
} |
q31034 | say | train | function say(message, channelId) {
channelId = channelId || false;
if (channelId) {
sendDiscordMessage(channelId, message);
return;
}
if (!ircClient || typeof message !== 'string')
return;
ircClient.say(config.channel, message);
} | javascript | {
"resource": ""
} |
q31035 | sendDiscordMessage | train | function sendDiscordMessage(id, message) {
if (!discordClient || typeof id !== 'string' || typeof message !== 'string')
return;
discordClient.sendMessage({
to: id,
message: message,
});
} | javascript | {
"resource": ""
} |
q31036 | logChat | train | function logChat(from, message) {
if (typeof config.log !== 'string' || !from || typeof message !== 'string')
return;
// Get the current moment
var now = moment();
// Create the file name
var file = path.join(config.log, now.format('YYYY-MM-DD') + '-' + 'chat.log');
// Create the text to log based on... | javascript | {
"resource": ""
} |
q31037 | train | function(region) {
if (this._isShown) {
throw new Error('This component is already shown in a region.');
}
if (!region) {
throw new Error('Please supply a region to show inside.');
}
this.region = region;
this.triggerMethod('before:show');
this._showView();
this._isShown ... | javascript | {
"resource": ""
} | |
q31038 | train | function() {
var view = this.view = this._getView();
this._initializeViewEvents();
// Trigger show:view after the view is shown in the region
this.listenTo(view, 'show', _.partial(this.triggerMethod, 'show:view'));
// Trigger before:show before the region shows the view
this.triggerMethod('be... | javascript | {
"resource": ""
} | |
q31039 | any | train | function any(target, fn) {
var keys = Object.keys(target);
for(var i = 0, len = keys.length; i < len; i++) {
var key = keys[i];
var value = target[key];
if(fn(value, key)) return true;
}
return false;
} | javascript | {
"resource": ""
} |
q31040 | extend | train | function extend(target, source) {
var keys = Object.keys(source);
for(var i = 0, len = keys.length; i < len; i++) {
var key = keys[i];
target[key] = source[key];
}
return target;
} | javascript | {
"resource": ""
} |
q31041 | train | function() {
$.each(watched_props, function(index, value) {
if (index != '_interval' && index != '_interval_func' && index != '_element' && index != '_speed' && index != '_status' && index != '_load') {
var new_value = value.orig_value;
// Are we returning a jQuery function value... | javascript | {
"resource": ""
} | |
q31042 | train | function (query, update, fship) {
var options = { new: false };
return function (done) {
this.findOneAndUpdate(query, update, options, function (err, res) {
done(err, fship);
});
}
} | javascript | {
"resource": ""
} | |
q31043 | train | function (m1, m2, fship) {
var query = {_id: m1};
query[pathName] = {$elemMatch: {_id: m2}};
var updater = {$set: {}};
updater.$set[pathName+".$.status"] = fship.status;
return _update(query, updater, fship);
} | javascript | {
"resource": ""
} | |
q31044 | train | function (m1, m2, fship) {
var query = {_id: m1};
fship.added = new Date();
var updater = {$push: {}};
updater.$push[pathName] = fship;
return _update(query, updater, fship);
} | javascript | {
"resource": ""
} | |
q31045 | train | function (done) {
var select = {};
select[pathName] = 1;
Model.findOne({_id: model}, select, function (err, doc) {
if (err) return done(err);
if (!doc) return done(null, []);
done(null, doc[pathName].reduce(function (o, friend) {
... | javascript | {
"resource": ""
} | |
q31046 | defaults | train | function defaults(options, defaultOptions) {
options || (options = {});
for (var opt in defaultOptions) {
if (defaultOptions.hasOwnProperty(opt) && !options.hasOwnProperty(opt)) {
options[opt] = defaultOptions[opt];
}
}
return options;
} | javascript | {
"resource": ""
} |
q31047 | resetSeat | train | function resetSeat(s) {
const street = this.street
const stage = this.stage
const preflop = street === 'preflop'
const chipsName = 'chips' + street[0].toUpperCase() + street.slice(1)
const p = script.players[s.playerIdx]
const chips = p[chipsName]
return Object.assign({}, seats[p.seatno], ... | javascript | {
"resource": ""
} |
q31048 | train | function() {
var min = typeof this.options.start_value !== 'undefined' && this.min >= 0 ? this.options.start_value : this.min,
start_value = this.round(min, 1);
/* This is a boundary condition */
if (this.min > 0 && start_value > this.min) {
return 0;
}
if (this.min === this.max) {
... | javascript | {
"resource": ""
} | |
q31049 | train | function(value) {
return Math.pow(10, Math.round((Math.log(value) / Math.LN10)) - 1);
} | javascript | {
"resource": ""
} | |
q31050 | train | function(data, options) {
if (typeof data.length !== 'undefined') {
if (typeof data[0].length !== 'undefined') {
this.grouped = true;
// TODO: Find longest?
this.group_size = data[0].length;
var o = {}, k, i = 0;
for (k in options.labels) {
k = options.labels... | javascript | {
"resource": ""
} | |
q31051 | train | function() {
// Make sure the true largest value is used for max
return this.options.line ? { start_value: 0, max: Helpers.max([Helpers.max(this.options.line), Helpers.max(this.flat_data)]) } : { start_value: 0 };
} | javascript | {
"resource": ""
} | |
q31052 | train | function() {
this.bar_padding = this.options.bar_padding || 5;
this.bar_width = this.options.bar_size || this.calculateBarWidth();
if (this.options.bar_size && !this.options.bar_padding) {
this.bar_padding = this.graph_width / this.data_size;
}
this.options.plot_padding = (this.bar_width / 2... | javascript | {
"resource": ""
} | |
q31053 | train | function() {
var width = (this.graph_width / this.data_size) - this.bar_padding;
if (this.grouped) {
//width = width / this.group_size - (this.bar_padding * this.group_size);
}
if (this.options.max_bar_size && width > this.options.max_bar_size) {
width = this.options.max_bar_size;
th... | javascript | {
"resource": ""
} | |
q31054 | train | function(index, pathString, x, y, colour) {
if (this.options.highlight_colours && this.options.highlight_colours.hasOwnProperty(index)) {
colour = this.options.highlight_colours[index];
}
x = x + this.bar_padding;
pathString += 'M' + x + ',' + this.start_y;
pathString += 'L' + x + ',' + y;
... | javascript | {
"resource": ""
} | |
q31055 | attribToHtml | train | function attribToHtml(str) {
return str.replace(pr_amp, '&')
.replace(pr_lt, '<')
.replace(pr_gt, '>')
.replace(pr_quot, '"');
} | javascript | {
"resource": ""
} |
q31056 | htmlToText | train | function htmlToText(html) {
var pos = html.indexOf('&');
if (pos < 0) { return html; }
// Handle numeric entities specially. We can't use functional substitution
// since that doesn't work in older versions of Safari.
// These should be rare since most browsers convert them to normal chars.
for... | javascript | {
"resource": ""
} |
q31057 | isPreformatted | train | function isPreformatted(node, content) {
// PRE means preformatted, and is a very common case, so don't create
// unnecessary computed style objects.
if ('PRE' === node.tagName) { return true; }
if (!newlineRe.test(content)) { return true; } // Don't care
var whitespace = '';
// For disconnecte... | javascript | {
"resource": ""
} |
q31058 | makeTabExpander | train | function makeTabExpander(tabWidth) {
var SPACES = ' ';
var charInLine = 0;
return function (plainText) {
// walk over each character looking for tabs and newlines.
// On tabs, expand them. On newlines, reset charInLine.
// Otherwise increment charInLine
var out = nul... | javascript | {
"resource": ""
} |
q31059 | train | function (job) {
var sourceCode = job.source, basePos = job.basePos;
/** Even entries are positions in source in ascending order. Odd enties
* are style markers (e.g., PR_COMMENT) that run from that position until
* the end.
* @type {Array.<number|string>}
*/
var decor... | javascript | {
"resource": ""
} | |
q31060 | sourceDecorator | train | function sourceDecorator(options) {
var shortcutStylePatterns = [], fallthroughStylePatterns = [];
if (options['tripleQuotedStrings']) {
// '''multi-line-string''', 'single-line-string', and double-quoted
shortcutStylePatterns.push(
[PR_STRING, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\... | javascript | {
"resource": ""
} |
q31061 | emitTextUpTo | train | function emitTextUpTo(sourceIdx) {
if (sourceIdx > outputIdx) {
if (openDecoration && openDecoration !== currentDecoration) {
// Close the current decoration
html.push('</span>');
openDecoration = null;
}
if (!openDecoration && currentDecoration) {
o... | javascript | {
"resource": ""
} |
q31062 | referenceProtection | train | function referenceProtection(session) {
function checkScope(funcName) {
return (msg) => {
if (typeof session[funcName] === 'function') {
session[funcName](msg);
}
}
}
return {
actor: session.actor,
debug: checkScope('debug'),
sendToClient: checkScope('sendToClient')
}
} | javascript | {
"resource": ""
} |
q31063 | train | function(raw) {
var result = {}
var md = raw.split(protocol.FDFS_RECORD_SEPERATOR)
md.forEach(function(item) {
var arr = item.split(protocol.FDFS_FIELD_SEPERATOR)
var key = helpers.trim(arr[0])
var value = helpers.trim(arr[1])
result[key] = value
... | javascript | {
"resource": ""
} | |
q31064 | getStyle | train | function getStyle(el, styleProp) {
if (typeof window === 'undefined') {
return;
}
var style;
if (el.currentStyle) {
style = el.currentStyle[styleProp];
} else if (window.getComputedStyle) {
style = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
}
if (style && sty... | javascript | {
"resource": ""
} |
q31065 | parseGraph | train | function parseGraph (rdf, baseUrl, rdfSource, contentType) {
let parsedGraph = rdf.graph()
rdf.parse(rdfSource, parsedGraph, baseUrl, contentType)
return parsedGraph
} | javascript | {
"resource": ""
} |
q31066 | train | function(num, dec) {
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
return result;
} | javascript | {
"resource": ""
} | |
q31067 | train | function(data) {
var values = [],
i = 0;
for (i = 0; i < data.length; i++) {
values.push(this.normalise(data[i]));
}
return values;
} | javascript | {
"resource": ""
} | |
q31068 | train | function(data) {
var flat_data = [];
if (typeof data.length === 'undefined') {
if (typeof data === 'object') {
for (var key in data) {
if (data.hasOwnProperty(key))
flat_data = flat_data.concat(this.flatten(data[key]));
}
} else {
return [];
}
... | javascript | {
"resource": ""
} | |
q31069 | train | function(start, end, options) {
var values = [], i;
for (i = start; i < end; i++) {
if (options && options.skip) {
if (i % options.skip === 0) {
values.push(i);
} else {
values.push(undefined);
}
} else {
values.push(i);
}
}
return va... | javascript | {
"resource": ""
} | |
q31070 | summary | train | function summary(hand) {
const res = {}
if (hand.players == null || hand.players.length === 0) return res
const bb = hand.info.bb
res.header = getHeader(hand)
const seatsInfo = getSeats(hand)
res.seats = seatsInfo.seats
res.chipStackRatio = seatsInfo.hero != null
? getChipStackRatio(res.header.gamet... | javascript | {
"resource": ""
} |
q31071 | sheetToTable | train | function sheetToTable(sheet) {
if (sheet.data.length === 0 || sheet.data[0].rowData === undefined) {
return {
title: sheet.properties.title,
headers: [],
formats: [],
rows: []
};
}
const gridData = sheet.data[0]; // first (unique) range
const headers = gridData.rowData[0].values ... | javascript | {
"resource": ""
} |
q31072 | getRanges | train | async function getRanges(
auth,
spreadsheetId,
ranges,
fields = 'properties.title,sheets.properties,sheets.data(rowData.values.effectiveValue,rowData.values.formattedValue,rowData.values.effectiveFormat.numberFormat)'
) {
var sheets = google.sheets('v4');
const response = await Q.ninvoke(sheets.spreadsheets... | javascript | {
"resource": ""
} |
q31073 | train | function (options) {
if (!(this instanceof Store)) {
return new Store(options)
}
this._opts = options || {}
this.db = new Datastore({ filename: this._opts.filename, autoload: true })
} | javascript | {
"resource": ""
} | |
q31074 | gain | train | function gain(options) {
// gain()
if (options == null) options = {volume: 1};
// gain(Function)
// gain(Number)
else if (typeof options === 'function' || typeof options === 'number') options = {volume: options};
var volume;
if (options.mode === 'tan') {
volume = Math.tan(options.volume);
} else {
volume... | javascript | {
"resource": ""
} |
q31075 | train | function(fileId) {
var pos = fileId.indexOf('/')
return {
group: fileId.substring(0, pos),
filename: fileId.substring(pos + 1)
}
} | javascript | {
"resource": ""
} | |
q31076 | train | function(){
var clone = element.clone()
.removeAttr('vertilize')
.css({
height: '',
width: element.outerWidth(),
position: 'fixed',
top: 0,
left: 0,
visibility: 'hidden'
... | javascript | {
"resource": ""
} | |
q31077 | neighbourhoodSorter | train | function neighbourhoodSorter (a, b) {
a = a.join(',');
b = b.join(',');
return a > b ? 1 : a < b ? -1 : 0;
} | javascript | {
"resource": ""
} |
q31078 | getRules | train | function getRules (resource, role, create) {
resource = typeof resource === 'undefined' ? null : resource;
role = typeof role === 'undefined' ? null : role;
create = typeof create === 'undefined' ? false : create;
var visitor;
// follow $resource
do {
if (re... | javascript | {
"resource": ""
} |
q31079 | getRuleType | train | function getRuleType(resource, role, privilege) {
resource = typeof resource === 'undefined' ? null : resource;
role = typeof role === 'undefined' ? null : role;
privilege = typeof privilege === 'undefined' ? null : privilege;
// get the rules for the $resource and $role
var ru... | javascript | {
"resource": ""
} |
q31080 | getChildResources | train | function getChildResources(resource){
var result = [], children = _resources[resource].children;
children.forEach(function (child) {
var childReturn = getChildResources(child);
childReturn.push(child);
result = result.concat(childReturn);
});
return r... | javascript | {
"resource": ""
} |
q31081 | train | function(evname, callback, context) {
this._events = this._events || {};
var a = this._events[evname] = this._events[evname] || [];
a.push({
cb: callback,
ctxt: context || this
});
return this;
} | javascript | {
"resource": ""
} | |
q31082 | train | function(evname, callback, context) {
var self = this, args = arguments;
this.on(evname, function() {
callback.apply(context, arguments);
self.off.apply(self, args);
});
return this;
} | javascript | {
"resource": ""
} | |
q31083 | train | function(evname) {
var fns = this._events && this._events[evname] || [],
args = __slice.call(arguments, 1);
for (var i = 0, ii = fns.length; i < ii; i++) {
fns[i].cb.apply(fns[i].ctxt, args);
}
} | javascript | {
"resource": ""
} | |
q31084 | train | function(other, evname, callback) {
other.on(evname, callback, this);
var a = this._listeningTo = this._listeningTo || {},
b = a[other._cid] = other;
} | javascript | {
"resource": ""
} | |
q31085 | train | function(other, evname, callback) {
if (!this._listeningTo) return;
if (!other) {
for (var cid in this._listeningTo) {
this.stopListening(this._listeningTo[cid], evname, callback);
}
} else {
other.off(evname, callback, this);
// TODO: remove local listener tracker
}
} | javascript | {
"resource": ""
} | |
q31086 | Surface | train | function Surface(app, options) {
if (!(this instanceof Surface)) {
return new Surface(app, options);
}
this.conf = setting(options);
this.middleware(app);
context(app, this);
} | javascript | {
"resource": ""
} |
q31087 | athost | train | function athost() {
var pos = position();
var m = match(/^@host */);
if (!m) return;
if (!open()) return error("@host missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@host missing '}'");
return pos({
type: 'host',
rules: style
});
} | javascript | {
"resource": ""
} |
q31088 | atcustommedia | train | function atcustommedia() {
var pos = position();
var m = match(/^@custom-media (--[^\s]+) *([^{;]+);/);
if (!m) return;
return pos({
type: 'custom-media',
name: trim(m[1]),
media: trim(m[2])
});
} | javascript | {
"resource": ""
} |
q31089 | atfontface | train | function atfontface() {
var pos = position();
var m = match(/^@font-face */);
if (!m) return;
if (!open()) return error("@font-face missing '{'");
var decls = comments();
// declarations
var decl;
while (decl = declaration()) {
decls.push(decl);
decls = decls.concat(comment... | javascript | {
"resource": ""
} |
q31090 | generateContent | train | function generateContent(globOrGlobArray, options) {
// Detect base.
const globs = toArray(globOrGlobArray)
assert(globs.length > 0, "globs should exist")
const base = commonPart(globs)
assert(base != null, "the common parent directory of globs is not found.")
// Create streams.
const glob... | javascript | {
"resource": ""
} |
q31091 | generate | train | function generate(globs, options, callback) {
if (generationQueue.size > 0) {
// There is a process not started.
return
}
if (typeof options.delay === "number") {
generationQueue.push(next => setTimeout(next, options.delay))
}
generationQueue.push(next => {
//eslint-d... | javascript | {
"resource": ""
} |
q31092 | watch | train | function watch(globs, options) {
options.delay = 1000
chokidar
.watch(globs, { persistent: true, ignoreInitial: true })
.on("add", () => generate(globs, options))
.on("unlink", () => generate(globs, options))
.on("change", () => generate(globs, options))
.on("error", (er... | javascript | {
"resource": ""
} |
q31093 | Server | train | function Server(host, port, options) {
var self = this;
// Needed to convert this constructor into EventEmitter
EventEmitter.call(this);
options = options || {};
this.host = host || '127.0.0.1';
this.port = port || 59895;
this.debug = options.debug || false;
this.json = options.json || true;
var pa... | javascript | {
"resource": ""
} |
q31094 | _send | train | function _send(cmd, callback) {
cmd_callback = callback;
if(connected) {
client.write(cmd + '\n');
} else {
connect();
}
} | javascript | {
"resource": ""
} |
q31095 | globParentToArray | train | function globParentToArray(glob) {
return path.resolve(globParent(glob))
.replace(BACK_SLASH, "/")
.split("/")
.filter(Boolean)
} | javascript | {
"resource": ""
} |
q31096 | findLastCommonIndex | train | function findLastCommonIndex(xs, ys) {
for (let i = Math.min(xs.length, ys.length) - 1; i >= 0; --i) {
if (xs[i] === ys[i]) {
return i
}
}
return -1
} | javascript | {
"resource": ""
} |
q31097 | train | function(val) {
return val === null ? 'Null' :
val === undefined ? 'Undefined' :
Object.prototype.toString.call(val).slice(8, -1);
} | javascript | {
"resource": ""
} | |
q31098 | train | function(expectedType, value) {
var actualType = getType(value);
if (expectedType!== actualType) {
throw new TypeError('Expected type to be ' +
expectedType + ', but got ' + actualType);
}
return value;
} | javascript | {
"resource": ""
} | |
q31099 | leftPad | train | function leftPad(n, prefix) {
var s = n.toString(),
nchars = intChars(n),
nspaces = nchars - s.length - 1;
prefix || (prefix = ' ');
for (var i = 0; i < nspaces; i++) {
prefix += ' ';
}
return prefix + s;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.