_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q46000 | mimeMatch | train | function mimeMatch (expected, actual) {
// invalid type
if (expected === false) {
return false
}
// split types
var actualParts = actual.split('/')
var expectedParts = expected.split('/')
// invalid format
if (actualParts.length !== 2 || expectedParts.length !== 2) {
return false
}
// val... | javascript | {
"resource": ""
} |
q46001 | normalizeType | train | function normalizeType (value) {
// parse the type
var type = typer.parse(value)
// remove the parameters
type.parameters = undefined
// reformat it
return typer.format(type)
} | javascript | {
"resource": ""
} |
q46002 | isErrorMessage | train | function isErrorMessage(message) {
const level = message.fatal ? 2 : message.severity;
if (Array.isArray(level)) {
return level[0] > 1;
}
return level > 1;
} | javascript | {
"resource": ""
} |
q46003 | countFixableErrorMessage | train | function countFixableErrorMessage(count, message) {
return count + Number(isErrorMessage(message) && message.fix !== undefined);
} | javascript | {
"resource": ""
} |
q46004 | countFixableWarningMessage | train | function countFixableWarningMessage(count, message) {
return count + Number(message.severity === 1 && message.fix !== undefined);
} | javascript | {
"resource": ""
} |
q46005 | gulpEslint | train | function gulpEslint(options) {
options = migrateOptions(options) || {};
const linter = new CLIEngine(options);
return transform((file, enc, cb) => {
const filePath = relative(process.cwd(), file.path);
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new PluginError('gulp-... | javascript | {
"resource": ""
} |
q46006 | train | function(focusWindow, fromPoint, toPoint, duration, callback){
this.currentDataTransferItem = null;
this.focusWindow = focusWindow;
// A series of events to simulate a drag operation
this._mouseOver(fromPoint);
this._mouseEnter(fromPoint);
this._mouseMove(fromPoint);
this._mouseDown(fromPoint);
this._... | javascript | {
"resource": ""
} | |
q46007 | train | function(point, eventName, options){
if (point){
var targetElement = elementFromPoint(point, this.focusWindow);
syn.trigger(targetElement, eventName, options);
}
} | javascript | {
"resource": ""
} | |
q46008 | train | function(dataFlavor, value){
var tempdata = {};
tempdata.dataFlavor = dataFlavor;
tempdata.val = value;
this.data.push(tempdata);
} | javascript | {
"resource": ""
} | |
q46009 | train | function(dataFlavor){
for (var i = 0; i < this.data.length; i++){
var tempdata = this.data[i];
if (tempdata.dataFlavor === dataFlavor){
return tempdata.val;
}
}
} | javascript | {
"resource": ""
} | |
q46010 | train | function (el, type) {
while (el && el.nodeName.toLowerCase() !== type.toLowerCase()) {
el = el.parentNode;
}
return el;
} | javascript | {
"resource": ""
} | |
q46011 | train | function (el, func) {
var res;
while (el && res !== false) {
res = func(el);
el = el.parentNode;
}
return el;
} | javascript | {
"resource": ""
} | |
q46012 | train | function (elem) {
var attributeNode;
// IE8 Standards doesn't like this on some elements
if (elem.getAttributeNode) {
attributeNode = elem.getAttributeNode("tabIndex");
}
return this.focusable.test(elem.nodeName) ||
(attributeNode && attributeNode.specified) &&
syn.isVisible(elem);
} | javascript | {
"resource": ""
} | |
q46013 | train | function (elem) {
var attributeNode = elem.getAttributeNode("tabIndex");
return attributeNode && attributeNode.specified && (parseInt(elem.getAttribute('tabIndex')) || 0);
} | javascript | {
"resource": ""
} | |
q46014 | toQueryParams | train | function toQueryParams(object){
return Object.keys(object)
.filter(key => !!object[key])
.map(key => key + "=" + encodeURIComponent(object[key]))
.join("&")
} | javascript | {
"resource": ""
} |
q46015 | copy | train | function copy(cb) {
gulp.src(['adal-angular.d.ts']).pipe(gulp.dest('./dist/'));
console.log('adal-angular.d.ts Copied to Dist Directory');
gulp.src(['README.md']).pipe(gulp.dest('./dist/'));
console.log('README.md Copied to Dist Directory');
cb();
} | javascript | {
"resource": ""
} |
q46016 | replace_d | train | function replace_d(cb) {
gulp.src('./dist/adal.service.d.ts')
.pipe(replace('../adal-angular.d.ts', './adal-angular.d.ts'))
.pipe(gulp.dest('./dist/'));
console.log('adal.service.d.ts Path Updated');
cb();
} | javascript | {
"resource": ""
} |
q46017 | bump_version | train | function bump_version(cb) {
gulp.src('./package.json')
.pipe(bump({
type: 'patch'
}))
.pipe(gulp.dest('./'));
console.log('Version Bumped');
cb();
} | javascript | {
"resource": ""
} |
q46018 | git_commit | train | function git_commit(cb) {
var package = require('./package.json');
exec('git commit -m "Version ' + package.version + ' release."', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
} | javascript | {
"resource": ""
} |
q46019 | doOverride | train | function doOverride(uiSchema, params) {
Object.keys(params).forEach(field => {
let appendVal = params[field];
let fieldUiSchema = uiSchema[field];
if (!fieldUiSchema) {
uiSchema[field] = appendVal;
} else if (typeof appendVal === "object" && !Array.isArray(appendVal)) {
doOverride(fieldUiS... | javascript | {
"resource": ""
} |
q46020 | doAppend | train | function doAppend(uiSchema, params) {
Object.keys(params).forEach(field => {
let appendVal = params[field];
let fieldUiSchema = uiSchema[field];
if (!fieldUiSchema) {
uiSchema[field] = appendVal;
} else if (Array.isArray(fieldUiSchema)) {
toArray(appendVal)
.filter(v => !fieldUiSch... | javascript | {
"resource": ""
} |
q46021 | asRegExp | train | function asRegExp(pattern) {
// if regex then return it
if (isRegExp(pattern)) {
return pattern;
}
// if string then test for valid regex then convert to regex and return
const match = pattern.match(REGEX);
if (match) {
return new RegExp(match[1], match[2]);
}
return new RegExp(pattern);
} | javascript | {
"resource": ""
} |
q46022 | styledJSON | train | function styledJSON (obj) {
let json = JSON.stringify(obj, null, 2)
if (cli.color.enabled) {
let cardinal = require('cardinal')
let theme = require('cardinal/themes/jq')
cli.log(cardinal.highlight(json, {json: true, theme: theme}))
} else {
cli.log(json)
}
} | javascript | {
"resource": ""
} |
q46023 | styledHeader | train | function styledHeader (header) {
cli.log(cli.color.dim('=== ') + cli.color.bold(header))
} | javascript | {
"resource": ""
} |
q46024 | styledObject | train | function styledObject (obj, keys) {
let keyLengths = Object.keys(obj).map(key => key.toString().length)
let maxKeyLength = Math.max.apply(Math, keyLengths) + 2
function pp (obj) {
if (typeof obj === 'string' || typeof obj === 'number') {
return obj
} else if (typeof obj === 'object') {
return ... | javascript | {
"resource": ""
} |
q46025 | preauth | train | function preauth (app, heroku, secondFactor) {
return heroku.request({
method: 'PUT',
path: `/apps/${app}/pre-authorizations`,
headers: { 'Heroku-Two-Factor-Code': secondFactor }
})
} | javascript | {
"resource": ""
} |
q46026 | promiseOrCallback | train | function promiseOrCallback (fn) {
return function () {
if (typeof arguments[arguments.length - 1] === 'function') {
let args = Array.prototype.slice.call(arguments)
let callback = args.pop()
fn.apply(null, args).then(function () {
let args = Array.prototype.slice.call(arguments)
... | javascript | {
"resource": ""
} |
q46027 | groupTextsByFontFamilyProps | train | function groupTextsByFontFamilyProps(
textByPropsArray,
availableFontFaceDeclarations
) {
const snappedTexts = _.flatMapDeep(textByPropsArray, textAndProps => {
const family = textAndProps.props['font-family'];
if (family === undefined) {
return [];
}
// Find all the families in the traced ... | javascript | {
"resource": ""
} |
q46028 | getSharedProperties | train | function getSharedProperties(configA, configB) {
const bKeys = Object.keys(configB);
return Object.keys(configA).filter(p => bKeys.includes(p));
} | javascript | {
"resource": ""
} |
q46029 | generateBundleName | train | function generateBundleName(name, modules, conditionValueOrVariationObject) {
// first check if the given modules already matches an existing bundle
let existingBundleName;
for (const bundleName of Object.keys(bundles)) {
const bundleModules = bundles[bundleName].modules;
if (
containsM... | javascript | {
"resource": ""
} |
q46030 | intersectModules | train | function intersectModules(modulesA, modulesB) {
const intersection = [];
for (const module of modulesA) {
if (modulesB.includes(module)) {
intersection.push(module);
}
}
return intersection;
} | javascript | {
"resource": ""
} |
q46031 | subtractModules | train | function subtractModules(modulesA, modulesB) {
const subtracted = [];
for (const module of modulesA) {
if (!modulesB.includes(module)) {
subtracted.push(module);
}
}
return subtracted;
} | javascript | {
"resource": ""
} |
q46032 | downloadGoogleFonts | train | async function downloadGoogleFonts(
fontProps,
{ formats = ['woff2', 'woff'], fontDisplay = 'swap', text } = {}
) {
const sortedFormats = [];
for (const format of formatOrder) {
if (formats.includes(format)) {
sortedFormats.push(format);
}
}
const result = {};
const googleFontId = getGoogl... | javascript | {
"resource": ""
} |
q46033 | findCustomPropertyDefinitions | train | function findCustomPropertyDefinitions(cssAssets) {
const definitionsByProp = {};
const incomingReferencesByProp = {};
for (const cssAsset of cssAssets) {
cssAsset.eachRuleInParseTree(cssRule => {
if (
cssRule.parent.type === 'rule' &&
cssRule.type === 'decl' &&
/^--/.test(cssRul... | javascript | {
"resource": ""
} |
q46034 | getMinimumIeVersionUsage | train | function getMinimumIeVersionUsage(asset, stack = []) {
if (asset.type === 'Html') {
return 1;
}
if (minimumIeVersionByAsset.has(asset)) {
return minimumIeVersionByAsset.get(asset);
}
stack.push(asset);
const minimumIeVersion = Math.min(
...asset.incomingRelati... | javascript | {
"resource": ""
} |
q46035 | fieldsFromMongo | train | function fieldsFromMongo(projection = {}, includeIdDefault = false) {
const fields = _.reduce(projection, (memo, value, key) => {
if (key !== '_id' && value !== undefined && !value) {
throw new TypeError('projection includes exclusion, but we do not support that');
}
if (value || (key === '_id' && v... | javascript | {
"resource": ""
} |
q46036 | resolveFields | train | function resolveFields(desiredFields, allowedFields, overrideFields) {
if (desiredFields != null && !Array.isArray(desiredFields)) {
throw new TypeError('expected nullable array for desiredFields');
}
if (allowedFields != null && !_.isObject(allowedFields)) {
throw new TypeError('expected nullable plain ... | javascript | {
"resource": ""
} |
q46037 | _joiVector | train | function _joiVector(proto) {
let arr = Joi.array();
if (arr.includes) {
return arr.includes(proto);
}
return arr.items(proto);
} | javascript | {
"resource": ""
} |
q46038 | deepLoad | train | function deepLoad(module, callback, parentLocation, id) {
// If this module is already loading then don't proceed.
// This is a bug.
// If a module is requested but not loaded then the module isn't ready,
// but we callback as if it is. Oh well, 1k!
if (module.g) {
return callback(module.e, mo... | javascript | {
"resource": ""
} |
q46039 | resolveModuleOrGetExports | train | function resolveModuleOrGetExports(baseOrModule, relative, resolved) {
// This should really be after the relative check, but because we are
// `throw`ing, it messes up the optimizations. If we are being called
// as resolveModule then the string `base` won't have the `e` property,
// so we're fine.
... | javascript | {
"resource": ""
} |
q46040 | Generate | train | function Generate(options) {
if (!(this instanceof Generate)) {
return new Generate(options);
}
Assemble.call(this, options);
this.is('generate');
this.initGenerate(this.options);
if (!setArgs) {
setArgs = true;
this.base.option(utils.argv);
}
} | javascript | {
"resource": ""
} |
q46041 | verify_nylas_request | train | function verify_nylas_request(req) {
const digest = crypto
.createHmac('sha256', config.nylasClientSecret)
.update(req.rawBody)
.digest('hex');
return digest === req.get('x-nylas-signature');
} | javascript | {
"resource": ""
} |
q46042 | buildUmdDev | train | function buildUmdDev() {
return rollup.rollup({
entry: 'src/index.js',
plugins: [
babel(babelOptions)
]
}).then(function (bundle) {
bundle.generate({
format: 'umd',
banner: banner,
name: 'rc-datetime-picker'
}).then(({ code }) => {
return write('dist/rc-datetime-pic... | javascript | {
"resource": ""
} |
q46043 | determineFreqCategories | train | function determineFreqCategories() {
if (mean - sd < 0) {
var lowrange = 0 + mean / 3;
} else {
var lowrange = mean - sd;
}
var midrange = [mean + sd, lowrange];
var highrange = mean + sd;
var i = 0;
for (; i < potentialexamples.length; i++) {
var word = potentialexamples[... | javascript | {
"resource": ""
} |
q46044 | makeRequest | train | function makeRequest(url, handler) {
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = handler.type;
xhr.onload = function onLoad(e) {
if (this.status === 200 || this.status === 0) {
handler.fn(null, xhr);
return;
}
handler.fn(e, xhr);
};
xhr.onerror ... | javascript | {
"resource": ""
} |
q46045 | arraybufferHandler | train | function arraybufferHandler(callback) {
return {
type: 'arraybuffer',
fn: (error, xhrObject) => {
if (error) {
callback(error);
return;
}
callback(null, xhrObject.response);
},
};
} | javascript | {
"resource": ""
} |
q46046 | showGlInfo | train | function showGlInfo(gl) {
const vertexUnits = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
const fragmentUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
const combinedUnits = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
console.log('vertex texture image units:', vertexUnits);
console.log(... | javascript | {
"resource": ""
} |
q46047 | compileShader | train | function compileShader(gl, src, type) {
const shader = gl.createShader(type);
gl.shaderSource(shader, src);
// Compile and check status
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
// Something went wrong during compilation; get the error
const lastError = gl.ge... | javascript | {
"resource": ""
} |
q46048 | applyProgramDataMapping | train | function applyProgramDataMapping(
gl,
programName,
mappingName,
glConfig,
glResources
) {
const program = glResources.programs[programName];
const mapping = glConfig.mappings[mappingName];
mapping.forEach((bufferMapping) => {
const glBuffer = glResources.buffers[bufferMapping.id];
gl.bindBuffe... | javascript | {
"resource": ""
} |
q46049 | bindTextureToFramebuffer | train | function bindTextureToFramebuffer(gl, fbo, texture) {
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(
gl.TEXTURE_2D,
0,
gl.RGBA,
fbo.width,
fbo.height,
0,
gl.RGBA,
gl.UNSIGNED_BYTE,
null
);
gl.framebufferTexture2D(
gl.FR... | javascript | {
"resource": ""
} |
q46050 | freeGLResources | train | function freeGLResources(glResources) {
const gl = glResources.gl;
// Delete each program
Object.keys(glResources.programs).forEach((programName) => {
const program = glResources.programs[programName];
const shaders = program.shaders;
let count = shaders.length;
// Delete shaders
while (cou... | javascript | {
"resource": ""
} |
q46051 | createGLResources | train | function createGLResources(gl, glConfig) {
const resources = {
gl,
buffers: {},
textures: {},
framebuffers: {},
programs: {},
};
const buffers = glConfig.resources.buffers || [];
const textures = glConfig.resources.textures || [];
const framebuffers = glConfig.resources.framebuffers || [];... | javascript | {
"resource": ""
} |
q46052 | styleRows | train | function styleRows(selection, self) {
selection
.classed(style.row, true)
.style('height', `${self.rowHeight}px`)
.style(
transformCSSProp,
(d, i) => `translate3d(0,${d.key * self.rowHeight}px,0)`
);
} | javascript | {
"resource": ""
} |
q46053 | styleBoxes | train | function styleBoxes(selection, self) {
selection
.style('width', `${self.boxWidth}px`)
.style('height', `${self.boxHeight}px`);
// .style('margin', `${self.boxMargin / 2}px`)
} | javascript | {
"resource": ""
} |
q46054 | getFieldRow | train | function getFieldRow(name) {
if (model.nest === null) return 0;
const foundRow = model.nest.reduce((prev, item, i) => {
const val = item.value.filter((def) => def.name === name);
if (val.length > 0) {
return item.key;
}
return prev;
}, 0);
return foundRow;
} | javascript | {
"resource": ""
} |
q46055 | updateStatusBarVisibility | train | function updateStatusBarVisibility() {
const cntnr = d3.select(model.container);
if (model.statusBarVisible) {
cntnr
.select('.status-bar-container')
.style('width', function updateWidth() {
return this.dataset.width;
});
cntnr.select('.show-button').classed(style.h... | javascript | {
"resource": ""
} |
q46056 | singleClick | train | function singleClick(d, i) {
// single click handler
const overCoords = d3.mouse(model.container);
const info = findGroupAndBin(overCoords);
if (info.radius > veryOutermostRadius) {
showAllChords();
} else if (
info.radius > outerRadius ||
... | javascript | {
"resource": ""
} |
q46057 | flushDataToListener | train | function flushDataToListener(dataListener, dataChanged) {
try {
if (dataListener) {
const dataToForward = dataHandler.get(
model[dataContainerName],
dataListener.request,
dataChanged
);
if (
dataToForward &&
(JSON.stringify(dataToForwar... | javascript | {
"resource": ""
} |
q46058 | getMouseEventInfo | train | function getMouseEventInfo(event, divElt) {
const clientRect = divElt.getBoundingClientRect();
return {
relX: event.clientX - clientRect.left,
relY: event.clientY - clientRect.top,
eltBounds: clientRect,
};
} | javascript | {
"resource": ""
} |
q46059 | ensureRuleNumbers | train | function ensureRuleNumbers(rule) {
if (!rule || rule.length === 0) {
return;
}
const ruleSelector = rule.type;
if (ruleSelector === 'rule') {
ensureRuleNumbers(rule.rule);
}
if (ruleSelector === 'logical') {
rule.terms.filter((r, idx) => idx > 0).forEach((r) => ensureRuleNumbers(r));
}
if ... | javascript | {
"resource": ""
} |
q46060 | md2json | train | function md2json(tree) {
var slide = null;
var slides = [];
var globalProperties = {}
var elements = tree.slice(1);
for (var i = 0; i < elements.length; ++i) {
var el = elements[i];
var add = true;
if (el[0] === 'header' && el[1].level === 1) {
if (slide) slides.push(Slide(slide.md_tree, sli... | javascript | {
"resource": ""
} |
q46061 | addAction | train | function addAction(codemirror, slideNumer, action) {
// parse properties from the new actions to next compare with
// the current ones in the slide
var currentActions = O.Template.parseProperties(action);
var currentLine;
var c = 0;
var blockStart;
// search for a actions block
for (var... | javascript | {
"resource": ""
} |
q46062 | placeActionButtons | train | function placeActionButtons(el, codemirror) {
// search for h1's
var positions = [];
var lineNumber = 0;
codemirror.eachLine(function(a) {
if (SLIDE_REGEXP.exec(a.text)) {
positions.push({
pos: codemirror.heightAtLine(lineNumber)-66, // header height
line: lineNumbe... | javascript | {
"resource": ""
} |
q46063 | Debug | train | function Debug() {
function _debug() {};
_debug.log = function(_) {
return Action({
enter: function() {
console.log("STATE =>", _, arguments);
},
update: function() {
console.log("STATE (.)", _, arguments);
},
exit: function() {
console.log("STATE <=", ... | javascript | {
"resource": ""
} |
q46064 | leaflet_method | train | function leaflet_method(name) {
_map[name] = function() {
var args = arguments;
return Action(function() {
map[name].apply(map, args);
});
};
} | javascript | {
"resource": ""
} |
q46065 | train | function(elem) {
// is this already initialized?
if ($(elem).data('spriteanim')) return $(elem).data('spriteanim');
var spriteanim = new SpriteAnim(elem);
$(elem).data('spriteanim', spriteanim);
return spriteanim;
} | javascript | {
"resource": ""
} | |
q46066 | Edge | train | function Edge(a, b) {
var s = 0;
function t() {}
a._story(null, function() {
if(s !== 0) {
t.trigger();
}
s = 0;
});
b._story(null, function() {
if(s !== 1) {
t.trigger();
}
s = 1;
});
return Trigger(t);
} | javascript | {
"resource": ""
} |
q46067 | processFeature | train | function processFeature(_raw, _name, _feature, _other, _do) {
if(_feature === '.' || _feature === true) {
var skip = [_name];
if(_other) skip.push.apply(skip, angular.isArray(_other) ? _other : [_other]);
exclude(_raw, skip, _do);
} else if(typeof _feature === 'string') {
exclude(_raw[_f... | javascript | {
"resource": ""
} |
q46068 | applyHooks | train | function applyHooks(_target, _hooks, _owner) {
for(var key in _hooks) {
if(_hooks.hasOwnProperty(key)) {
_target.$on(key, wrapHook(_hooks[key], _owner));
}
}
} | javascript | {
"resource": ""
} |
q46069 | processGroup | train | function processGroup(_records, _target, _params) {
// extract targets
var targets = [], record;
for(var i = 0, l = _records.length; i < l; i++) {
record = _records[i][_target];
if(angular.isArray(record)) {
targets.push.apply(targets, record);
} else if(record) {
targets.... | javascript | {
"resource": ""
} |
q46070 | train | function() {
return {
/**
* @memberof BuilderApi#
*
* @description Sets an attribute mapping.
*
* Allows a explicit server to model property mapping to be defined.
*
* For example, to map the response property `stats.create... | javascript | {
"resource": ""
} | |
q46071 | train | function(_chain) {
for(var i = 0, l = _chain.length; i < l; i++) {
this.mixin(_chain[i]);
}
} | javascript | {
"resource": ""
} | |
q46072 | train | function(_mix) {
if(_mix.$$chain) {
this.chain(_mix.$$chain);
} else if(typeof _mix === 'string') {
this.mixin($injector.get(_mix));
} else if(isArray(_mix)) {
this.chain(_mix);
} else if(isFunction(_mix)) {
_mix.call(this.dsl, $injector);
} else {
t... | javascript | {
"resource": ""
} | |
q46073 | buildAsyncSaveFun | train | function buildAsyncSaveFun(_this, _oldSave, _promise, _oldPromise) {
return function() {
// swap promises so save behaves like it has been called during the original call.
var currentPromise = _this.$promise;
_this.$promise = _oldPromise;
// when save resolves, the timeout promise is resol... | javascript | {
"resource": ""
} |
q46074 | applyRules | train | function applyRules(_string, _ruleSet, _skip) {
if(_skip.indexOf(_string.toLowerCase()) === -1) {
var i = 0, rule;
while(rule = _ruleSet[i++]) {
if(_string.match(rule[0])) {
return _string.replace(rule[0], rule[1]);
}
}
}
return _string;
} | javascript | {
"resource": ""
} |
q46075 | train | function(_hook, _args, _ctx) {
var cbs = hooks[_hook], i, cb;
if(cbs) {
for(i = 0; !!(cb = cbs[i]); i++) {
cb.apply(_ctx || this, _args || []);
}
}
return this;
} | javascript | {
"resource": ""
} | |
q46076 | train | function(_items) {
var list = new List();
if(_items) list.push.apply(list, _items);
return list;
} | javascript | {
"resource": ""
} | |
q46077 | train | function(_params, _scope) {
_params = this.$params ? angular.extend({}, this.$params, _params) : _params;
return newCollection(_params, _scope || this.$scope);
} | javascript | {
"resource": ""
} | |
q46078 | helpDefine | train | function helpDefine(_api, _name, _fun) {
var api = APIS[_api];
Utils.assert(!!api, 'Invalid api name $1', _api);
if(_name) {
api[_name] = Utils.override(api[_name], _fun);
} else {
Utils.extendOverriden(api, _fun);
}
} | javascript | {
"resource": ""
} |
q46079 | validateFile | train | async function validateFile (file, options) {
if (file instanceof File === false) {
return null
}
await file.setOptions(Object.assign(file.validationOptions, options)).runValidations()
return _.size(file.error()) ? file.error().message : null
} | javascript | {
"resource": ""
} |
q46080 | train | function (type, data) {
if (type === 'size') {
return `File size should be less than ${bytes(data.size)}`
}
if (type === 'type') {
const verb = data.types.length === 1 ? 'is' : 'are'
return `Invalid file type ${data.subtype} or ${data.type}. Only ${data.types.join(', ')} ${verb} allowed`
}
if (t... | javascript | {
"resource": ""
} | |
q46081 | _empty | train | function _empty( x, y, force ) {
if ( x < 0 || x >= that.width || y < 0 || y >= that.height ) return;
var pos = that.pos(x, y);
var d = that.grid[pos];
if (d && (d & SLAB_MASK) && (force || !(d & APPLE_MASK))) {
that.grid[pos] &= ~SLAB_MASK; // clear ou... | javascript | {
"resource": ""
} |
q46082 | directoryHTML | train | function directoryHTML( res, urldir, pathname, list ) {
var ulist = [];
function sendHTML( list ) {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.send('<!DOCTYPE html>' +
'<html>\n' +
'<title>Directory listing for '+htmlsafe(urldir)+'</title>\n' +
'<body>... | javascript | {
"resource": ""
} |
q46083 | _check | train | function _check(err, id) {
updateProgress(1);
if (err) {
alert('Failed to load ' + id + ': ' + err);
}
loadc++;
if (itemc == loadc) callback();
} | javascript | {
"resource": ""
} |
q46084 | _fill_canvas | train | function _fill_canvas(canvas, items) {
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#ddd';
for (var i = 0; i < ITEM_COUNT; i++) {
var asset = items[i];
ctx.save();
ctx.shadowColor = "rgba(0,0,0,0.5)";
ctx.shadowO... | javascript | {
"resource": ""
} |
q46085 | _find | train | function _find( items, id ) {
for ( var i=0; i < items.length; i++ ) {
if (items[i].id == id) return i;
}
} | javascript | {
"resource": ""
} |
q46086 | _check_slot | train | function _check_slot(offset, result) {
if (now - that.lastUpdate > SPINTIME) {
var c = parseInt(Math.abs(offset / SLOT_HEIGHT)) % ITEM_COUNT;
if (c == result) {
if (result == 0) {
if (Math.abs(offset + (ITEM_COUNT * SLOT_HEIGHT)) < (SLOT_SPEED * 1.5)) ... | javascript | {
"resource": ""
} |
q46087 | initAudio | train | function initAudio( audios, callback ) {
var format = 'mp3';
var elem = document.createElement('audio');
if ( elem ) {
// Check if we can play mp3, if not then fall back to ogg
if( !elem.canPlayType( 'audio/mpeg;' ) && elem.canPlayType('audio/ogg;')) format = 'ogg';
}
var AudioCont... | javascript | {
"resource": ""
} |
q46088 | _build_object | train | function _build_object( game, x, y, speed ) {
var car_asset = game.carAssets[parseInt(Math.random()*game.carAssets.length)]
var framex = car_asset.w * parseInt(Math.random() * car_asset.count);
return {
collided: 0,
width: car_asset.w,
height: car_asset.h,
img: car_asset.img,
framex: framex,
pos: {
... | javascript | {
"resource": ""
} |
q46089 | select | train | function select(elems) {
var r = Math.random();
var ref = 0;
for(var i=0; i < elems.length; i++) {
var elem= elems[i];
ref += elem[1];
if (r < ref) return elem[0];
}
// This happens only if probabilities don't add up to 1
return null;
} | javascript | {
"resource": ""
} |
q46090 | configStripper | train | function configStripper (c) {
return {
DeadLetterConfig: c.DeadLetterConfig,
Description: c.Description,
Environment: c.Environment,
Handler: c.Handler,
MemorySize: c.MemorySize,
Role: c.Role,
Runtime: c.Runtime,
Timeout: c.Timeout,
TracingConfig: c.TracingConfig
}
} | javascript | {
"resource": ""
} |
q46091 | validateTicket | train | function validateTicket(req, options, callback) {
var query = {
service: utils.getPath('service', options),
ticket: req.query.ticket
};
var logger = utils.getLogger(req, options);
if (options.paths.proxyCallback) query.pgtUrl = utils.getPath('pgtUrl', options);
var casServerValidPath = utils.getPath... | javascript | {
"resource": ""
} |
q46092 | retrievePGTFromPGTIOU | train | function retrievePGTFromPGTIOU(req, res, callback, pgtIou, options) {
var logger = utils.getLogger(req, options);
logger.info('Trying to retrieve pgtId from pgtIou...');
req.sessionStore.get(pgtIou, function(err, session) {
/* istanbul ignore if */
if (err) {
logger.error('Get pgtId from sessionSto... | javascript | {
"resource": ""
} |
q46093 | requestPT | train | function requestPT(path, callback, retryHandler) {
logger.info('Trying to request proxy ticket from ', proxyPath);
var startTime = Date.now();
utils.getRequest(path, function(err, response) {
/* istanbul ignore if */
logger.access('|GET|' + path + '|' + (err ? 500 : response.status) + "|" + (Da... | javascript | {
"resource": ""
} |
q46094 | isMatchRule | train | function isMatchRule(req, pathname, rule) {
if (typeof rule === 'string') {
return pathname.indexOf(rule) > -1;
} else if (rule instanceof RegExp) {
return rule.test(pathname);
} else if (typeof rule === 'function') {
return rule(pathname, req);
}
} | javascript | {
"resource": ""
} |
q46095 | shouldIgnore | train | function shouldIgnore(req, options) {
var logger = getLogger(req, options);
if (options.match && options.match.splice && options.match.length) {
var matchedRule;
var hasMatch = options.match.some(function (rule) {
matchedRule = rule;
return isMatchRule(req, req.path, rule);
});
if (hasM... | javascript | {
"resource": ""
} |
q46096 | getRequest | train | function getRequest(path, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {
method: 'get'
};
} else {
options.method = 'get';
}
if (options.params) {
var uri = url.parse(path, true);
uri.query = _.merge({}, uri.query, options.params);
pa... | javascript | {
"resource": ""
} |
q46097 | schema_jsonSchema | train | function schema_jsonSchema(name) {
let result;
name = name || this.options.name;
if (this.__buildingSchema) {
this.__jsonSchemaId =
this.__jsonSchemaId ||
'#schema-' + (++schema_jsonSchema.__jsonSchemaIdCounter);
return {'$ref': this.__jsonSchemaId}
}
if (!this.__jsonSchem... | javascript | {
"resource": ""
} |
q46098 | simpleType_jsonSchema | train | function simpleType_jsonSchema(name) {
var result = {};
result.type = this.instance.toLowerCase();
__processOptions(result, this.options)
return result;
} | javascript | {
"resource": ""
} |
q46099 | objectId_jsonSchema | train | function objectId_jsonSchema(name) {
var result = simpleType_jsonSchema.call(this, name);
result.type = 'string';
result.pattern = '^[0-9a-fA-F]{24}$';
return result;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.