_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q33500 | train | function (options, fileExtension) {
var getOptionsKey = function (options, fileExtension) {
for (var prop in options) {
var _prop = prop.toLowerCase();
if ((options[_prop].hasOwnProperty('allowed_file_extensions') && options[_prop].allowed_file_extensions.indexOf(fileExtension) > -1) || (!options[_pr... | javascript | {
"resource": ""
} | |
q33501 | train | function (source, fileExtension, globalOptions, beautify) {
var path = rcFile.for(this.resourcePath)
, options = globalOptions || {};
if (globalOptions === null && typeof path === "string") {
this.addDependency(path);
options = JSON.parse(stripJsonComments(fs.readFileSync(path, "utf8")));
}
return... | javascript | {
"resource": ""
} | |
q33502 | train | function (source, fileExtension, globalOptions, beautify, callback) {
var _this = this;
if (globalOptions === null) {
rcFile.for(this.resourcePath, function (err, path) {
if (!err) {
if (typeof path === "string") {
_this.addDependency(path);
fs.readFile(path, "utf8", function... | javascript | {
"resource": ""
} | |
q33503 | _extract | train | function _extract(keyStr, dataObj) {
var altkey,
_subKey,
_splitPoint,
_found = false,
dataValue = null,
_queryParts = [];
if (dataObj && typeof dataObj === 'object') {
dataValue = Object.create(dataObj);
_queryParts = keyStr.split(/[\-\_\.]/);
//console.warn("INIT:", keyStr, _queryParts);
// tes... | javascript | {
"resource": ""
} |
q33504 | renderData | train | function renderData(textString, options, data, doSpecials) {
var replacer = function replacer(match, $1, $2) {
var extracted,
dataValue,
key = String($1 || '').trim(),
defaultValue = String($2 || '').trim();
// literal bracket excaping via \[ text ]
if(match.substr(0, 1) === "\\") {
return match.su... | javascript | {
"resource": ""
} |
q33505 | getOptions | train | function getOptions(opts) {
var obj = Object.create(_options);
obj = util._extend(obj, opts);
return obj;
} | javascript | {
"resource": ""
} |
q33506 | getCurrentState | train | function getCurrentState(systemID, authOpts) {
return authenticatedGet(SYSTEM_URL + systemID, authOpts).then(res => {
const rels = res.data.relationships
const partTasks = rels.partitions.data.map(p =>
getPartition(p.id, authOpts)
)
const sensorIDs = rels.sensors.data.map(s => s.id)
return ... | javascript | {
"resource": ""
} |
q33507 | getSensors | train | function getSensors(sensorIDs, authOpts) {
if (!Array.isArray(sensorIDs)) sensorIDs = [sensorIDs]
const query = sensorIDs.map(id => `ids%5B%5D=${id}`).join('&')
const url = `${SENSORS_URL}?${query}`
return authenticatedGet(url, authOpts)
} | javascript | {
"resource": ""
} |
q33508 | train | function(key, defaultValue) {
var value = window.localStorage.getItem(key);
return value ? JSON.parse(value) : defaultValue;
} | javascript | {
"resource": ""
} | |
q33509 | writeConfig | train | function writeConfig(filePath, data, fileFormat) {
if (!filePath || !data) {
throw new Error('No file/data to save!');
}
const ext = rgxExt.exec(filePath) || [];
const format = fileFormat || ext[1];
if (format === 'yaml' || format === 'yml') {
return writeFileSync(filePath, yaml.safeDump(data), { en... | javascript | {
"resource": ""
} |
q33510 | readConfig | train | function readConfig(globPattern, fileFormat) {
const filepath = findConfigFile(globPattern);
if (!filepath) {
this.settings = {};
return;
}
const ext = rgxExt.exec(filepath) || [];
const format = fileFormat || ext[1];
const settings = (format === 'yaml' || format === 'yml')
? yaml.safeLoad(re... | javascript | {
"resource": ""
} |
q33511 | createXMLHTTPObject | train | function createXMLHTTPObject () {
var xmlhttp = false
for (var i = 0; i < XMLHttpFactories.length; i++) {
try {
xmlhttp = XMLHttpFactories[i]()
} catch (e) {
continue
}
break
}
return xmlhttp
} | javascript | {
"resource": ""
} |
q33512 | optionString | train | function optionString(options) {
return Object.keys(options).map(function (key) {
var value = options[key];
if (value === null) {
return '-' + key;
} else if (typeof value === 'number') {
value += '';
} else if (typeof value === 'string') {
value =... | javascript | {
"resource": ""
} |
q33513 | randomString | train | function randomString() {
var str = '', length = 32;
while (length--) {
str += String.fromCharCode(Math.random() * 26 | 97);
}
return str;
} | javascript | {
"resource": ""
} |
q33514 | train | function() {
var element = this.element,
template = this.template,
offset = element.offset(),
width = element.outerWidth(),
height = element.outerHeight(),
position = this.options.position,
alignment = this.optio... | javascript | {
"resource": ""
} | |
q33515 | train | function(view, delay) {
var self = this;
var raiseAfterShowHours = false;
var raiseAfterShowMinutes = false;
if (view === 'hours') {
raiseCallback(this.options.beforeShowHours);
raiseAfterShowHours = true;
}
if (vie... | javascript | {
"resource": ""
} | |
q33516 | train | function(delay) {
var view = this.currentView,
value = this[view],
isHours = view === 'hours',
unit = Math.PI / (isHours ? 6 : 30),
radian = value * unit,
radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius,
... | javascript | {
"resource": ""
} | |
q33517 | train | function(timeObject) {
this.hours = timeObject.hours;
this.minutes = timeObject.minutes;
this.amOrPm = timeObject.amOrPm;
this._checkTimeLimits();
this._updateLabels();
this.resetClock();
} | javascript | {
"resource": ""
} | |
q33518 | train | function(str, methodDec, methodName, method, methodsMap, options){
var methodValue = getMethodValue(methodDec, methodName, method, methodsMap, options);
if(str === methodDec) return methodValue;
return str.replace(methodDec, function(){ return methodValue; });
} | javascript | {
"resource": ""
} | |
q33519 | renderNode | train | function renderNode(node, children = []) {
[...children].forEach(child => {
if (child && child.tag) {
node.ele(child.tag, child.props);
renderNode(node, child.children);
node.end();
} else {
node.text(child);
}
});
} | javascript | {
"resource": ""
} |
q33520 | initialize | train | function initialize(server, callback) {
source = new Backend(server, options);
source.initialize(callback);
} | javascript | {
"resource": ""
} |
q33521 | replacementForNode | train | function replacementForNode (node) {
var rule = this.rules.forNode(node)
var content = process.call(this, node)
var whitespace = node.flankingWhitespace
if (whitespace.leading || whitespace.trailing) content = content.trim()
return (
whitespace.leading +
rule.replacement(content, node, this.options) +... | javascript | {
"resource": ""
} |
q33522 | separatingNewlines | train | function separatingNewlines (output, replacement) {
var newlines = [
output.match(trailingNewLinesRegExp)[0],
replacement.match(leadingNewLinesRegExp)[0]
].sort()
var maxNewlines = newlines[newlines.length - 1]
return maxNewlines.length < 2 ? maxNewlines : '\n\n'
} | javascript | {
"resource": ""
} |
q33523 | quadratic_distance | train | function quadratic_distance(a, b, c, dpa, dpb, orientation) {
var ab = new Array(3);
var ac = new Array(3);
var dab2 = 0.0;
for(var i=0; i<3; ++i) {
ab[i] = b[i] - a[i];
dab2 += ab[i] * ab[i];
ac[i] = c[i] - a[i];
}
if(dab2 < EPSILON) {
return 1e30;
}
//Transform c into triangle co... | javascript | {
"resource": ""
} |
q33524 | geodesic_distance | train | function geodesic_distance(cells, positions, p, max_distance, tolerance, stars) {
if(typeof(max_distance) === "undefined") {
max_distance = Number.POSITIVE_INFINITY
}
if(typeof(tolerance) === "undefined") {
tolerance = 1e-4
}
if(typeof(dual) === "undefined") {
stars = top.dual(cells, positions.le... | javascript | {
"resource": ""
} |
q33525 | walk | train | function walk(node, output, previousNode) {
// tag name
validator.checkTagName(node, output)
// attrs: id/class/style/if/repeat/append/event/attr
var attrs = node.attrs || []
attrs.forEach(function switchAttr(attr) {
var name = attr.name
var value = attr.value
var locationInfo = {line: 1, colum... | javascript | {
"resource": ""
} |
q33526 | Cobertura | train | function Cobertura(runner) {
var jade = require('jade')
jade.doctypes.cobertura = '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd">'
var file = __dirname + '/templates/cobertura.jade',
str = fs.readFileSync(file, 'utf8'),
fn = jade.compile(str, { filename: file }),
self = this
... | javascript | {
"resource": ""
} |
q33527 | deepReduce | train | function deepReduce(obj, reducer, reduced, path, thisArg) {
if (reduced === void 0) { reduced = {}; }
if (path === void 0) { path = ''; }
if (thisArg === void 0) { thisArg = {}; }
var pathArr = path === '' ? [] : path.split('.');
var root = obj; // keep value of root object, for recursion
if (pa... | javascript | {
"resource": ""
} |
q33528 | evaluateID | train | function evaluateID(sub, element) {
var id = element.id;
return id && id.indexOf(sub) === 0;
} | javascript | {
"resource": ""
} |
q33529 | removeA | train | function removeA(arr) {
var what,
a = arguments,
L = a.length,
ax;
while (L > 1 && arr.length) {
what = a[--L];
while ((ax = arr.indexOf(what)) !== -1) {
arr.splice(ax, 1);
}
}
return arr;
} | javascript | {
"resource": ""
} |
q33530 | countWords | train | function countWords(s) {
s = s.replace(/(^\s*)|(\s*$)/gi, ""); //exclude start and end white-space
s = s.replace(/[ ]{2,}/gi, " "); //2 or more space to 1
s = s.replace(/\n /, "\n"); // exclude newline with a start spacing
return s.split(" ").length;
} | javascript | {
"resource": ""
} |
q33531 | train | function(needle) {
// Per spec, the way to identify NaN is that it is not equal to itself
var findNaN = needle !== needle;
var indexOf;
if (!findNaN && typeof Array.prototype.indexOf === "function") {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function(needle) {
var i = -1,
i... | javascript | {
"resource": ""
} | |
q33532 | BreakpointController | train | function BreakpointController(options) {
if (!(this instanceof BreakpointController)) {
return new BreakpointController(options);
}
Emitter.mixin(this);
var breakpointStream = BreakpointStream.create(options.breakpoints, {
throttleMs: options.throttleMs,
debounceMs: options.debounceMs
});
var... | javascript | {
"resource": ""
} |
q33533 | train | function(x, y) {
var array = this.getAllData(x, y);
return array && array.length ? array[0] : undefined;
} | javascript | {
"resource": ""
} | |
q33534 | train | function(x, y) {
var maskX = this._getMaskX(x);
var maskY = this._getMaskY(y);
var key = this._getIndexKey(maskX, maskY);
return this._dataIndex[key];
} | javascript | {
"resource": ""
} | |
q33535 | train | function(x, y, options) {
var maskX = this._getMaskX(x);
var maskY = this._getMaskY(y);
var key = this._getIndexKey(maskX, maskY);
return this._addDataToIndex(key, options);
} | javascript | {
"resource": ""
} | |
q33536 | evaluateReactID | train | function evaluateReactID(sub, element) {
var id = element.getAttribute && element.getAttribute('data-reactid');
return id && id.indexOf(sub) > -1;
} | javascript | {
"resource": ""
} |
q33537 | checkTagName | train | function checkTagName(node, output) {
var result = output.result
var deps = output.deps
var log = output.log
var tagName = node.tagName
var childNodes = node.childNodes || []
var location = node.__location || {}
// alias
if (TAG_NAME_ALIAS_MAP[tagName]) {
if (tagName !== 'img') { // FIXME: `parse5... | javascript | {
"resource": ""
} |
q33538 | _parse | train | function _parse(content, options, callback) {
if(typeof options == 'function') {
callback = options;
options.test = false;
}
var on = outcome.error(callback),
warnings,
window;
step(
/**
* load it.
*/
function() {
jsdom.env({
html: content,
scripts: [
__dirname + "/jqu... | javascript | {
"resource": ""
} |
q33539 | attachListener_ | train | function attachListener_() {
if (isListening) { return; }
isListening = true;
unsubFunc = Events.eventListener(target, eventName, function() {
if (outputStream.closed) {
detachListener_();
} else {
Util.apply(boundEmit, arguments);
}
});
onClose(outputStream, deta... | javascript | {
"resource": ""
} |
q33540 | attach_ | train | function attach_() {
var i = 0;
var intervalId = setInterval(function() {
if (outputStream.closed) {
clearInterval(intervalId);
} else {
boundEmit(i++);
}
}, ms);
} | javascript | {
"resource": ""
} |
q33541 | ScrollController | train | function ScrollController(options) {
if (!(this instanceof ScrollController)) {
return new ScrollController(options);
}
Emitter.mixin(this);
options = options || {};
var scrollStream = ScrollStream.create({
scrollTarget: options.scrollTarget
});
Stream.onValue(scrollStream, Util.partial(this.t... | javascript | {
"resource": ""
} |
q33542 | arrayToWeb | train | function arrayToWeb(arr) {
return new ReadableStream({
start(controller) {
for (var i = 0; i < arr.length; i++) {
controller.enqueue(arr[i]);
}
controller.close();
}
});
} | javascript | {
"resource": ""
} |
q33543 | copyone | train | function copyone (name) {
if (metadata !== undefined) { //3/11/18 by DW
var val = metadata [name];
if ((val !== undefined) && (val != null)) {
theOutline [name] = val;
}
}
} | javascript | {
"resource": ""
} |
q33544 | train | function(image, position, options) {
this._drawOnCanvasContext(options, function(g) {
this._setImageStyles(g, options);
g.drawImage(image, position[0], position[1]);
return true;
});
} | javascript | {
"resource": ""
} | |
q33545 | train | function(polygon, options) {
// Create new canvas where the polygon should be drawn
this._drawOnCanvasContext(options, function(g) {
options = options || {};
g.beginPath();
for (var i = 0; i < polygon.length; i++) {
var ring = this._simplify(polygon[i]... | javascript | {
"resource": ""
} | |
q33546 | train | function(coords) {
var tolerance = this.options.tolerance || 0.8;
var enableHighQuality = !!this.options.highQuality;
var points = GeometryUtils.simplify(coords, tolerance,
enableHighQuality);
return points;
} | javascript | {
"resource": ""
} | |
q33547 | train | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
g.fillStyle = options.fillColor || options.color;
if (options.fillImage) {
g.fillStyle = g.c... | javascript | {
"resource": ""
} | |
q33548 | train | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
g.globalAlpha = options.stokeOpacity || options.lineOpacity
|| options.opacity || 0;
g.s... | javascript | {
"resource": ""
} | |
q33549 | train | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
} | javascript | {
"resource": ""
} | |
q33550 | ElementVisibleController | train | function ElementVisibleController(elem, options) {
if (!(this instanceof ElementVisibleController)) {
return new ElementVisibleController(elem, options);
}
Emitter.mixin(this);
options = options || {};
this.elem = elem;
this.buffer = Util.getOption(options.buffer, 0);
this.isVisible = false;
this... | javascript | {
"resource": ""
} |
q33551 | deserialize | train | function deserialize(phcstr) {
if (typeof phcstr !== 'string' || phcstr === '') {
throw new TypeError('pchstr must be a non-empty string');
}
if (phcstr[0] !== '$') {
throw new TypeError('pchstr must contain a $ as first char');
}
const fields = phcstr.split('$');
// Remove first empty $
fields.sh... | javascript | {
"resource": ""
} |
q33552 | train | function(options){
var _this = this;
this.handlers = {};
if(!options){
options = {};
}
if(!options.redis){
options.redis = {};
}
this.options = {
id: options.id || shortId.generate(),
autoConfig: options.autoConfig || false,
dataExpiry: options.dataExpiry || 30,
redis: {
... | javascript | {
"resource": ""
} | |
q33553 | rewrite | train | function rewrite (raw) {
var c = raw.charAt(0)
var path = raw.slice(1)
if (allowedKeywordsRE.test(path)) {
return raw
} else {
path = path.indexOf('"') > -1
? path.replace(restoreRE, restore)
: path
return c + 'this.' + path
}
} | javascript | {
"resource": ""
} |
q33554 | parseExpression | train | function parseExpression (exp) {
exp = exp.trim()
var res = isSimplePath(exp) && exp.indexOf('[') < 0
// optimized super simple getter
? 'this.' + exp
// dynamic getter
: compileGetter(exp)
return res
} | javascript | {
"resource": ""
} |
q33555 | isSimplePath | train | function isSimplePath (exp) {
return pathTestRE.test(exp) &&
// don't treat true/false as paths
!booleanLiteralRE.test(exp) &&
// Math constants e.g. Math.PI, Math.E etc.
exp.slice(0, 5) !== 'Math.'
} | javascript | {
"resource": ""
} |
q33556 | PromisePool | train | function PromisePool(opts) {
this._opts = {
// Configuration options
name: opts.name || 'pool',
idleTimeoutMillis: opts.idleTimeoutMillis || 30000,
reapInterval: opts.reapIntervalMillis || 1000,
drainCheckInterval: opts.drainCheckIntervalMillis || 100,
... | javascript | {
"resource": ""
} |
q33557 | _ensureMinimum | train | function _ensureMinimum() {
// Nothing to do if draining.
if (this._draining) {
return Promise.resolve();
}
var diff = this._opts.min - this._count + this.availableLength;
var promises = [];
for (var i = 0; i < diff; ++i) {
promises.push(this.acquire(function(client){ return Pro... | javascript | {
"resource": ""
} |
q33558 | _createResource | train | function _createResource() {
this._log(
util.format(
'PromisePool._createResource() - creating client - count=%d min=%d max=%d',
this._count, this._opts.min, this._opts.max
),
'verbose'
);
return Promise.resolve(this._opts.create());
} | javascript | {
"resource": ""
} |
q33559 | _scheduleRemoveIdle | train | function _scheduleRemoveIdle(){
if (!this._removeIdleScheduled) {
this._removeIdleScheduled = true;
this._removeIdleTimer = setTimeout(_removeIdle.bind(this), this._opts.reapInterval);
}
} | javascript | {
"resource": ""
} |
q33560 | _objFilter | train | function _objFilter(obj, eql) {
return function(objWithTimeout){
return (eql ? (obj === objWithTimeout.obj) : (obj !== objWithTimeout.obj));
};
} | javascript | {
"resource": ""
} |
q33561 | _requireDirAll | train | function _requireDirAll(originalModule, absDir, options) {
var modules = {};
var files = [];
try {
files = fs.readdirSync(absDir);
} catch (e) {
if (options.throwNoDir) {
throw e;
}
}
for (var length=files.length, i=0; i<length; ++i) {
var reqModule = {};
reqModule.filename = fi... | javascript | {
"resource": ""
} |
q33562 | create | train | function create(options) {
options = options || {};
var scrollParent = (options.scrollTarget && options.scrollTarget.parentNode) || window;
var oldScrollY;
var scrollDirty = true;
var scrollEventsStream = Stream.createFromEvents(scrollParent, 'scroll');
Stream.onValue(scrollEventsStream, function onScrol... | javascript | {
"resource": ""
} |
q33563 | train | function(image, x, y, options) {
var result = false;
var data = options.data;
if (!data)
return result;
var mask = this._getImageMask(image, options);
var imageMaskWidth = this._getMaskX(image.width);
var maskShiftX = this._getMaskX(x);
var maskShiftY ... | javascript | {
"resource": ""
} | |
q33564 | train | function(image, options) {
var index = options.imageMaskIndex || this.options.imageMaskIndex;
if (!index)
return;
if (typeof index === 'function') {
index = index(image, options);
}
return index;
} | javascript | {
"resource": ""
} | |
q33565 | train | function(image) {
var maskWidth = this._getMaskX(image.width);
var maskHeight = this._getMaskY(image.height);
var buf = this._getResizedImageBuffer(image, maskWidth, maskHeight);
var mask = new Array(maskWidth * maskHeight);
for (var y = 0; y < maskHeight; y++) {
for ... | javascript | {
"resource": ""
} | |
q33566 | train | function(image, width, height) {
var g;
if (image.tagName === 'CANVAS' && image.width === width
&& image.height === height) {
g = image.getContext('2d');
} else {
var canvas = this._newCanvas(width, height);
canvas.width = width;
ca... | javascript | {
"resource": ""
} | |
q33567 | applyAspectRatioPadding | train | function applyAspectRatioPadding(image) {
var ratioPadding = (image.knownDimensions[1] / image.knownDimensions[0]) * 100.0;
DOM.setStyle(image.element, 'paddingBottom', ratioPadding + '%');
} | javascript | {
"resource": ""
} |
q33568 | getBreakpointSizes | train | function getBreakpointSizes(element) {
var breakpointString = element.getAttribute('data-breakpoints');
var knownSizes = Util.map(function(s) {
return Util.parseInteger(s);
}, breakpointString ? breakpointString.split(',') : []);
if (knownSizes.length <= 0) {
return [0];
} else {
return Util.sor... | javascript | {
"resource": ""
} |
q33569 | update | train | function update(image) {
if (image.lazyLoad) {
return;
}
var rect = DOM.getRect(image.element);
var foundBreakpoint;
for (var i = 0; i < image.knownSizes.length; i++) {
var s = image.knownSizes[i];
if (rect.width <= s) {
foundBreakpoint = s;
} else {
break;
}
}
if (!fou... | javascript | {
"resource": ""
} |
q33570 | loadImageForBreakpoint | train | function loadImageForBreakpoint(image, s) {
var alreadyLoaded = image.loadedSizes[s];
if ('undefined' !== typeof alreadyLoaded) {
setImage(image, alreadyLoaded);
} else {
var img = new Image();
img.onload = function() {
image.loadedSizes[s] = img;
setImage(image, img);
update(image... | javascript | {
"resource": ""
} |
q33571 | setImage | train | function setImage(image, img) {
if (!image.hasLoaded) {
image.hasLoaded = true;
setTimeout(function() {
image.element.className += ' loaded';
}, 100);
}
image.trigger('load', img);
if (image.element.tagName.toLowerCase() === 'img') {
return setImageTag(image, img);
} else {
return... | javascript | {
"resource": ""
} |
q33572 | setDivTag | train | function setDivTag(image, img) {
var setElemStyle = DOM.setStyle(image.element);
setElemStyle('backgroundImage', 'url(' + img.src + ')');
if (image.preserveAspectRatio) {
var w, h;
if (image.knownDimensions) {
w = image.knownDimensions[0];
h = image.knownDimensions[1];
} else {
w =... | javascript | {
"resource": ""
} |
q33573 | getPath | train | function getPath(image, s, wantsRetina) {
if (s === 0) { return image.src; }
var parts = image.src.split('.');
var ext = parts.pop();
return parts.join('.') + '-' + s + (wantsRetina ? '@2x' : '') + '.' + ext;
} | javascript | {
"resource": ""
} |
q33574 | train | function(tableName, columnName, callback) {
var cqlString = util.format('ALTER TABLE %s DROP %s', tableName, columnName);
return this.runSql(cqlString, callback).nodeify(callback);
} | javascript | {
"resource": ""
} | |
q33575 | train | function(callback) {
var cqlString = 'SELECT * from migrations';
return this.runSql(cqlString)
.then(function(data) {
var sortedData = data.rows.map(function(item) {
item.moment_time = moment(item.ran_on).valueOf();
return item
});
// Order migration records in ... | javascript | {
"resource": ""
} | |
q33576 | train | function (name, callback) {
var formattedDate = name.split('-')[0].replace('/', '');
formattedDate = moment(formattedDate, 'YYYY-MM-DD HH:mm:ss');
formattedDate = moment(formattedDate).format('YYYY-MM-DD HH:mm:ss');
var command = util.format('INSERT INTO %s (name, ran_on) VALUES (\'%s\', \'%s\')', inte... | javascript | {
"resource": ""
} | |
q33577 | train | function(migrationName, callback) {
var command = util.format('DELETE FROM %s where name = \'/%s\'', internals.migrationTable, migrationName);
return this.runSql(command).nodeify(callback);
} | javascript | {
"resource": ""
} | |
q33578 | train | function(callback) {
var tableOptions = {
'name': 'varchar',
'ran_on': 'timestamp'
};
var constraints = {
'primary_key': 'name'
};
return this.createTable(internals.migrationTable, tableOptions, constraints).nodeify(callback);
} | javascript | {
"resource": ""
} | |
q33579 | train | function(command, callback) {
var self = this;
return new Promise(function(resolve, reject) {
var prCB = function(err, data) {
if (err) {
log.error(err.message);
log.debug(command);
}
return (err ? reject('err') : resolve(data));
};
s... | javascript | {
"resource": ""
} | |
q33580 | _Markdown_formatOptions | train | function _Markdown_formatOptions(options) {
function toHighlight(code, lang) {
if (!lang && elm$core$Maybe$isJust(options.defaultHighlighting)) {
lang = options.defaultHighlighting.a;
}
if (
typeof hljs !== "undefined" &&
lang &&
hljs.listLanguages().indexOf(lang) ... | javascript | {
"resource": ""
} |
q33581 | train | function(g, x, y, width, height, radius) {
g.beginPath();
// a
g.moveTo(x + width / 2, y);
// b
g.bezierCurveTo(//
x + width / 2 + radius / 2, y, //
x + width / 2 + radius, y + radius / 2, //
x + width / 2 + radius, y + radius);
// c
g.bezi... | javascript | {
"resource": ""
} | |
q33582 | simplifyDouglasPeucker | train | function simplifyDouglasPeucker(points, sqTolerance) {
var len = points.length;
var MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array
: Array;
var markers = new MarkerArray(len);
var first = 0;
var last = len - 1;
va... | javascript | {
"resource": ""
} |
q33583 | simplify | train | function simplify(points, tolerance, highestQuality) {
if (points.length <= 1)
return points;
var sqTolerance = tolerance !== undefined ? tolerance * tolerance
: 1;
points = highestQuality ? points : simplifyRadialDist(points,
... | javascript | {
"resource": ""
} |
q33584 | train | function(polygons, clipPolygon) {
var result = [];
for (var i = 0; i < polygons.length; i++) {
var r = this.clipPolygon(polygons[i], clipPolygon);
if (r && r.length) {
result.push(r);
}
}
return result;
} | javascript | {
"resource": ""
} | |
q33585 | format | train | function format(node) {
var ret = node.children.map(function (child) {
var val = stringify(child)
val = val.replace(/\"function\s*\(\)\s*{\s*return\s*(.*?)}\"/g, function ($0, $1) {
return $1
}).replace(/\"([^,]*?)\":/g, function ($0, $1) {
return $1 + ': '
}).replace(/(,)(\S)/g, function ... | javascript | {
"resource": ""
} |
q33586 | walkAndFormat | train | function walkAndFormat(node) {
if (node) {
if (node.append !== 'once') {
if (node.children && node.children.length) {
for (var i = 0, len = node.children.length; i < len; i++) {
walkAndFormat(node.children[i])
}
}
}
else {
format(node)
}
}
} | javascript | {
"resource": ""
} |
q33587 | assetHashPath | train | function assetHashPath(url) {
const parsedUrl = path.parse(url.getValue());
const asset = manifest.getAssetValue(parsedUrl.base);
return compiler.types.String('url("' + asset + '")');
} | javascript | {
"resource": ""
} |
q33588 | assetPath | train | function assetPath(url) {
const parsedUrl = path.parse(url.getValue());
return compiler.types.String('url("' + parsedUrl.base + '")');
} | javascript | {
"resource": ""
} |
q33589 | evaluateClassName | train | function evaluateClassName(sub, element) {
var className = BLANK_STRING + element.className + BLANK_STRING;
sub = BLANK_STRING + sub + BLANK_STRING;
return className && className.indexOf(sub) > -1;
} | javascript | {
"resource": ""
} |
q33590 | train | function () {
OptionsProcessor.apply(this, arguments)
this._single = false
this._cached = false
this._resolved = true
this._query = undefined
this._fields = undefined
this._options = {
limit: 500
}
} | javascript | {
"resource": ""
} | |
q33591 | indexOf | train | function indexOf(list, item) {
if (NATIVE_ARRAY_INDEXOF) {
return NATIVE_ARRAY_INDEXOF.call(list, item);
}
for (var i = 0; i < list.length; i++) {
if (list[i] === item) {
return i;
}
}
return -1;
} | javascript | {
"resource": ""
} |
q33592 | throttle | train | function throttle(f, delay) {
var timeoutId;
var previous = 0;
return function throttleExecute_() {
var args = arguments;
var now = +(new Date());
var remaining = delay - (now - previous);
if (remaining <= 0) {
clearTimeout(timeoutId);
timeoutId = null;
previous = now;
f... | javascript | {
"resource": ""
} |
q33593 | debounce | train | function debounce(f, delay) {
var timeoutId = null;
return function debounceExecute_() {
clearTimeout(timeoutId);
var lastArgs = arguments;
timeoutId = setTimeout(function() {
timeoutId = null;
f.apply(null, lastArgs);
}, delay);
};
} | javascript | {
"resource": ""
} |
q33594 | forEach | train | function forEach(f, arr) {
if (NATIVE_ARRAY_FOREACH) {
if (arr) {
NATIVE_ARRAY_FOREACH.call(arr, f);
}
return;
}
for (var i = 0; i < arr.length; i++) {
f(arr[i], i, arr);
}
} | javascript | {
"resource": ""
} |
q33595 | objectKeys | train | function objectKeys(obj) {
if (!obj) { return null; }
if (Object.keys) {
return Object.keys(obj);
}
var out = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
out.push(key);
}
}
return out;
} | javascript | {
"resource": ""
} |
q33596 | eq | train | function eq(a, b, aStack, bStack) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if (a === b) {
return a !== 0 || 1 / a == 1 / b;
}
// A strict comparison is necessary because `null == und... | javascript | {
"resource": ""
} |
q33597 | functionBind | train | function functionBind(f, obj) {
if (NATIVE_FUNCTION_BIND) {
return NATIVE_FUNCTION_BIND.call(f, obj);
}
return function boundFunction_() {
return f.apply(obj, arguments);
};
} | javascript | {
"resource": ""
} |
q33598 | partial | train | function partial(f /*, args*/) {
var args = rest(arguments);
if (NATIVE_FUNCTION_BIND) {
args.unshift(undefined);
return NATIVE_FUNCTION_BIND.apply(f, args);
}
return function partialExecute_() {
var args2 = slice(arguments, 0);
return f.apply(this, args.concat(args2));
};
} | javascript | {
"resource": ""
} |
q33599 | train | function(options) {
this.options = options || {};
if (typeof this.options.getGeometry === 'function') {
this.getGeometry = this.options.getGeometry;
}
this.setData(this.options.data);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.