_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21200 | doBidderSync | train | function doBidderSync(type, url, bidder, done) {
if (!url) {
utils.logError(`No sync url for bidder "${bidder}": ${url}`);
done();
} else if (type === 'image' || type === 'redirect') {
utils.logMessage(`Invoking image pixel user sync for bidder: "${bidder}"`);
utils.triggerPixel(url, done);
} else... | javascript | {
"resource": ""
} |
q21201 | doClientSideSyncs | train | function doClientSideSyncs(bidders) {
bidders.forEach(bidder => {
let clientAdapter = adapterManager.getBidAdapter(bidder);
if (clientAdapter && clientAdapter.registerSyncs) {
clientAdapter.registerSyncs([]);
}
});
} | javascript | {
"resource": ""
} |
q21202 | isModuleDirectory | train | function isModuleDirectory(filePath) {
try {
const manifestPath = path.join(filePath, MANIFEST);
if (fs.statSync(manifestPath).isFile()) {
const module = require(manifestPath);
return module && module.main;
}
} catch (error) {}
} | javascript | {
"resource": ""
} |
q21203 | buildUrlFromAdserverUrlComponents | train | function buildUrlFromAdserverUrlComponents(components, bid, options) {
const descriptionUrl = getDescriptionUrl(bid, components, 'search');
if (descriptionUrl) { components.search.description_url = descriptionUrl; }
const encodedCustomParams = getCustParams(bid, options);
components.search.cust_params = (compo... | javascript | {
"resource": ""
} |
q21204 | getDescriptionUrl | train | function getDescriptionUrl(bid, components, prop) {
if (config.getConfig('cache.url')) { return; }
if (!deepAccess(components, `${prop}.description_url`)) {
const vastUrl = bid && bid.vastUrl;
if (vastUrl) { return encodeURIComponent(vastUrl); }
} else {
logError(`input cannnot contain description_ur... | javascript | {
"resource": ""
} |
q21205 | getCustParams | train | function getCustParams(bid, options) {
const adserverTargeting = (bid && bid.adserverTargeting) || {};
let allTargetingData = {};
const adUnit = options && options.adUnit;
if (adUnit) {
let allTargeting = targeting.getAllTargeting(adUnit.code);
allTargetingData = (allTargeting) ? allTargeting[adUnit.co... | javascript | {
"resource": ""
} |
q21206 | readValue | train | function readValue(name) {
let value;
if (pubcidConfig.typeEnabled === COOKIE) {
value = getCookie(name);
} else if (pubcidConfig.typeEnabled === LOCAL_STORAGE) {
value = getStorageItem(name);
if (!value) {
value = getCookie(name);
}
}
if (value === 'undefined' || value === 'null') { re... | javascript | {
"resource": ""
} |
q21207 | writeValue | train | function writeValue(name, value, expInterval) {
if (name && value) {
if (pubcidConfig.typeEnabled === COOKIE) {
setCookie(name, value, expInterval);
} else if (pubcidConfig.typeEnabled === LOCAL_STORAGE) {
setStorageItem(name, value, expInterval);
}
}
} | javascript | {
"resource": ""
} |
q21208 | train | function () {
next = false;
// add listener to all next steps to provide next() functionality
event.dispatcher.on(event.step.after, () => {
recorder.add('Start next pause session', () => {
if (!next) return;
return pauseSession();
});
});
recorder.add('Start new session', pauseSession);
} | javascript | {
"resource": ""
} | |
q21209 | convertColorToRGBA | train | function convertColorToRGBA(color) {
const cstr = `${color}`.toLowerCase().trim() || '';
if (!/^rgba?\(.+?\)$/.test(cstr)) {
// Convert both color names and hex colors to rgba
const hexColor = convertColorNameToHex(color);
return convertHexColorToRgba(hexColor);
}
// Convert rgb to rgba
const ch... | javascript | {
"resource": ""
} |
q21210 | replaceValue | train | function replaceValue(obj, key, value) {
if (!obj) return;
if (obj instanceof Array) {
for (const i in obj) {
replaceValue(obj[i], key, value);
}
}
if (obj[key]) obj[key] = value;
if (typeof obj === 'object' && obj !== null) {
const children = Object.keys(obj);
for (let childIndex = 0; c... | javascript | {
"resource": ""
} |
q21211 | AssertionFailedError | train | function AssertionFailedError(params, template) {
this.params = params;
this.template = template;
// this.message = "AssertionFailedError";
let stack = new Error().stack;
// this.showDiff = true;
stack = stack ? stack.split('\n').filter(line =>
// @todo cut assert things nicer
line.indexOf('lib/asse... | javascript | {
"resource": ""
} |
q21212 | onlyForApps | train | function onlyForApps(expectedPlatform) {
const stack = new Error().stack || '';
const re = /Appium.(\w+)/g;
const caller = stack.split('\n')[2].trim();
const m = re.exec(caller);
if (!m) {
throw new Error(`Invalid caller ${caller}`);
}
const callerName = m[1] || m[2];
if (!expectedPlatform) {
... | javascript | {
"resource": ""
} |
q21213 | train | function(done) {
gzip(info.filePath, info.gzFilePath, function() {
info.gzTime = Date.now();
// Open and read the size of the minified+gzip output
readSize(info.gzFilePath, function(size) {
info.gzSize = size;
done();
});
})... | javascript | {
"resource": ""
} | |
q21214 | train | function(done) {
readBuffer(info.filePath, function(data) {
lzma.compress(data, 1, function(result, error) {
if (error) {
throw error;
}
writeBuffer(info.lzFilePath, new Buffer(result), function() {
info.lzTime = Date.now();... | javascript | {
"resource": ""
} | |
q21215 | trimTrailingWhitespace | train | function trimTrailingWhitespace(index, nextTag) {
for (var endTag = null; index >= 0 && _canTrimWhitespace(endTag); index--) {
var str = buffer[index];
var match = str.match(/^<\/([\w:-]+)>$/);
if (match) {
endTag = match[1];
}
else if (/>$/.test(str) || (buffer[index] = collap... | javascript | {
"resource": ""
} |
q21216 | squashTrailingWhitespace | train | function squashTrailingWhitespace(nextTag) {
var charsIndex = buffer.length - 1;
if (buffer.length > 1) {
var item = buffer[buffer.length - 1];
if (/^(?:<!|$)/.test(item) && item.indexOf(uidIgnore) === -1) {
charsIndex--;
}
}
trimTrailingWhitespace(charsIndex, nextTag);
} | javascript | {
"resource": ""
} |
q21217 | stripLoaderPrefix | train | function stripLoaderPrefix(str) {
if (typeof str === 'string') {
str = str.replace(
/(?:(\()|(^|\b|@))(\.\/~|\.{0,2}\/(?:[^\s]+\/)?node_modules)\/\w+-loader(\/[^?!]+)?(\?\?[\w_.-]+|\?({[\s\S]*?})?)?!/g,
'$1'
);
str = str.replace(/(\.?\.?(?:\/[^/ ]+)+)\s+\(\1\)/g, '$1');
str = replaceAll(str, process.cwd(... | javascript | {
"resource": ""
} |
q21218 | intersect | train | function intersect(a, b, not) {
return a.filter((c) => {
const index = ~indexOfDeclaration(b, c);
return not ? !index : index;
});
} | javascript | {
"resource": ""
} |
q21219 | isSupportedCached | train | function isSupportedCached(feature, browsers) {
const key = JSON.stringify({ feature, browsers });
let result = isSupportedCache[key];
if (!result) {
result = isSupported(feature, browsers);
isSupportedCache[key] = result;
}
return result;
} | javascript | {
"resource": ""
} |
q21220 | normalize | train | function normalize(values) {
if (values[0].toLowerCase() === auto) {
return values[1];
}
if (values[1].toLowerCase() === auto) {
return values[0];
}
if (
values[0].toLowerCase() === inherit &&
values[1].toLowerCase() === inherit
) {
return inherit;
}
return values.join(' ');
} | javascript | {
"resource": ""
} |
q21221 | filterFont | train | function filterFont({ atRules, values }) {
values = uniqs(values);
atRules.forEach((r) => {
const families = r.nodes.filter(({ prop }) => prop === 'font-family');
// Discard the @font-face if it has no font-family
if (!families.length) {
return r.remove();
}
families.forEach((family) => ... | javascript | {
"resource": ""
} |
q21222 | SessionStrategy | train | function SessionStrategy(options, deserializeUser) {
if (typeof options == 'function') {
deserializeUser = options;
options = undefined;
}
options = options || {};
Strategy.call(this);
this.name = 'session';
this._deserializeUser = deserializeUser;
} | javascript | {
"resource": ""
} |
q21223 | Authenticator | train | function Authenticator() {
this._key = 'passport';
this._strategies = {};
this._serializers = [];
this._deserializers = [];
this._infoTransformers = [];
this._framework = null;
this._userProperty = 'user';
this.init();
} | javascript | {
"resource": ""
} |
q21224 | getHelpContents | train | async function getHelpContents(args, output) {
if ('!' in args) {
return getAllCommands(process.stdout);
}
if (args._.length == 0) {
return getGeneralHelpContents(output);
}
else if (args._.length == 1) {
return getVerbHelp(args._[0], output);
} else if (args._.length >=... | javascript | {
"resource": ""
} |
q21225 | getGeneralHelpContents | train | function getGeneralHelpContents() {
let options = {
head: chalk.bold(`Available actions are:`),
table: [
[chalk.cyan.bold("add"), "add a resource"],
[chalk.cyan.bold("clone"), "clone a resource"],
[chalk.cyan.bold("delete"), "delete a resource"],
[chal... | javascript | {
"resource": ""
} |
q21226 | getAllCommands | train | function getAllCommands() {
let resourceTypes = [];
let tables = {};
operations.forEach((operation) => {
let opCategory = operation.target[0];
if (resourceTypes.indexOf(opCategory) < 0) {
resourceTypes.push(opCategory);
tables[opCategory] = [];
}
table... | javascript | {
"resource": ""
} |
q21227 | getFileInput | train | async function getFileInput(args) {
if (typeof args.in !== 'string') {
return null;
}
// Let any errors fall through to the runProgram() promise
return JSON.parse(await txtfile.read(path.resolve(args.in)));
} | javascript | {
"resource": ""
} |
q21228 | composeConfig | train | async function composeConfig() {
const { LUIS_APP_ID, LUIS_AUTHORING_KEY, LUIS_VERSION_ID, LUIS_REGION } = process.env;
const {
appId: args_appId,
authoringKey: args_authoringKey,
versionId: args_versionId,
region: args_region
} = args;
let luisrcJson = {};
let conf... | javascript | {
"resource": ""
} |
q21229 | composeConfig | train | async function composeConfig() {
const {QNAMAKER_SUBSCRIPTION_KEY, QNAMAKER_HOSTNAME, QNAMAKER_ENDPOINTKEY, QNAMAKER_KBID} = process.env;
const {subscriptionKey, hostname, endpointKey, kbId} = args;
let qnamakerrcJson = {};
let config;
try {
await fs.access(path.join(process.cwd(), '.qnamak... | javascript | {
"resource": ""
} |
q21230 | handleError | train | async function handleError(error) {
process.stderr.write('\n' + chalk.red.bold(error + '\n\n'));
await help(args);
return 1;
} | javascript | {
"resource": ""
} |
q21231 | processFiles | train | async function processFiles(inputDir, outputDir) {
return new Promise(async (resolve, reject) => {
let files = glob.sync(inputDir, { "ignore": ["**/node_modules/**"] });
for (let i = 0; i < files.length; i++) {
try {
let fileName = files[i];
if (files[i].l... | javascript | {
"resource": ""
} |
q21232 | runProgram | train | async function runProgram() {
const args = minimist(process.argv.slice(2));
if (args.prefix) {
intercept(function(txt) {
return `[${pkg.name}]\n${txt}`;
});
}
let latest = await latestVersion(pkg.name, { version: `>${pkg.version}` })
.catch(error => ... | javascript | {
"resource": ""
} |
q21233 | exitWithError | train | function exitWithError(error) {
if (error instanceof Error) {
process.stderr.write(chalk.red(error));
} else {
help();
}
process.exit(1);
} | javascript | {
"resource": ""
} |
q21234 | getHelpContents | train | async function getHelpContents(args, output) {
if ('!' in args) {
return getAllCommands(output);
}
if (args._.length == 0) {
return getGeneralHelpContents(output);
}
else if (args._.length == 1) {
return getVerbHelp(args._[0], output);
} else if (args._.length >= 2) {
... | javascript | {
"resource": ""
} |
q21235 | getAllCommands | train | function getAllCommands() {
let resourceTypes = [];
let tables = {};
Object.keys(manifest).forEach(key => {
const { [key]: category } = manifest;
Object.keys(category.operations).forEach((operationKey) => {
let operation = category.operations[operationKey];
let opCate... | javascript | {
"resource": ""
} |
q21236 | createConversationUpdate | train | function createConversationUpdate(args, membersAdded, membersRemoved) {
let conversationUpdateActivity = createActivity({
type: activitytypes.conversationupdate,
recipient: args[args.botId],
conversationId: args.conversation.id
});
conversationUpdateActivity.membersAdded = membersAdd... | javascript | {
"resource": ""
} |
q21237 | addAttachment | train | async function addAttachment(activity, arg) {
let parts = arg.trim().split(' ');
let contentUrl = parts[0].trim();
let contentType = (parts.length > 1) ? parts[1].trim() : undefined;
if (contentType) {
contentType = contentType.toLowerCase();
if (cardContentTypes[contentType])
... | javascript | {
"resource": ""
} |
q21238 | readAttachmentFile | train | async function readAttachmentFile(fileLocation, contentType) {
let resolvedFileLocation = path.join(workingDirectory, fileLocation);
let exists = fs.pathExistsSync(resolvedFileLocation);
// fallback to cwd
if (!exists) {
resolvedFileLocation = path.resolve(fileLocation);
}
// Throws if ... | javascript | {
"resource": ""
} |
q21239 | createActivity | train | function createActivity({ type = ActivityTypes.Message, recipient, from, conversationId }) {
const activity = new Activity({ from, recipient, type, id: '' + activityId++ });
activity.conversation = new ConversationAccount({ id: conversationId });
return activity;
} | javascript | {
"resource": ""
} |
q21240 | insertParametersFromObject | train | function insertParametersFromObject(parameterizedString, sourceObj) {
let result;
let payload = parameterizedString;
while ((result = tokenRegExp.exec(parameterizedString))) {
const token = result[1];
const propertyName = token.replace(/[{}]/g, '');
if (!(propertyName in sourceObj)) ... | javascript | {
"resource": ""
} |
q21241 | createPathRewriter | train | function createPathRewriter(rewriteConfig) {
let rulesCache;
if (!isValidRewriteConfig(rewriteConfig)) {
return;
}
if (_.isFunction(rewriteConfig)) {
const customRewriteFn = rewriteConfig;
return customRewriteFn;
}
else {
rulesCache = parsePathRewriteRules(rewrite... | javascript | {
"resource": ""
} |
q21242 | train | function () {
vid2.read(function (err, m2) {
if (writer2 === null)
writer2 = new cv.VideoWriter(filename2, 'DIVX', vid2.getFPS(), m2.size(), true);
x++;
writer2.write(m2, function(err){
if (x < 100) {
iter();
} else {
vid2.release();
writer2.release();
}
});
m2.release();
delete m2;
});
} | javascript | {
"resource": ""
} | |
q21243 | getPixelValues | train | function getPixelValues (pixelData) {
let minPixelValue = Number.MAX_VALUE;
let maxPixelValue = Number.MIN_VALUE;
const len = pixelData.length;
let pixel;
for (let i = 0; i < len; i++) {
pixel = pixelData[i];
minPixelValue = minPixelValue < pixel ? minPixelValue : pixel;
maxPixelValue = maxPixelV... | javascript | {
"resource": ""
} |
q21244 | getRestoreImageMethod | train | function getRestoreImageMethod (image) {
if (image.restore) {
return image.restore;
}
const color = image.color;
const rgba = image.rgba;
const cachedLut = image.cachedLut;
const slope = image.slope;
const windowWidth = image.windowWidth;
const windowCenter = image.windowCenter;
const minPixelVal... | javascript | {
"resource": ""
} |
q21245 | restoreImage | train | function restoreImage (image) {
if (image.restore && (typeof image.restore === 'function')) {
image.restore();
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q21246 | convertImageToFalseColorImage | train | function convertImageToFalseColorImage (image, colormap) {
if (image.color && !image.falseColor) {
throw new Error('Color transforms are not implemented yet');
}
// User can pass a colormap id or a colormap object
colormap = ensuresColormap(colormap);
const colormapId = colormap.getId();
// Doesn't d... | javascript | {
"resource": ""
} |
q21247 | convertToFalseColorImage | train | function convertToFalseColorImage (element, colormap) {
const enabledElement = getEnabledElement(element);
return convertImageToFalseColorImage(enabledElement.image, colormap);
} | javascript | {
"resource": ""
} |
q21248 | compileShader | train | function compileShader (gl, shaderSource, shaderType) {
// Create the shader object
const shader = gl.createShader(shaderType);
// Set the shader source code.
gl.shaderSource(shader, shaderSource);
// Compile the shader
gl.compileShader(shader);
// Check if it compiled
const success = gl.getShaderPa... | javascript | {
"resource": ""
} |
q21249 | createProgram | train | function createProgram (gl, vertexShader, fragmentShader) {
// Create a program.
const program = gl.createProgram();
// Attach the shaders.
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
// Link the program.
gl.linkProgram(program);
// Check if it linked.
const s... | javascript | {
"resource": ""
} |
q21250 | createViewport | train | function createViewport () {
const displayedArea = createDefaultDisplayedArea();
return {
scale: 1,
translation: {
x: 0,
y: 0
},
voi: {
windowWidth: undefined,
windowCenter: undefined
},
invert: false,
pixelReplication: false,
rotation: 0,
hflip: false,
... | javascript | {
"resource": ""
} |
q21251 | linearIndexLookupMain | train | function linearIndexLookupMain (v, p) {
let dIndex;
// NOTE: Added Math.floor since values were not integers? Check VTK source
if (v < p.Range[0]) {
dIndex = p.MaxIndex + BELOW_RANGE_COLOR_INDEX + 1.5;
} else if (v > p.Range[1]) {
dIndex = p.MaxIndex + ABOVE_RANGE_COLOR_INDEX + 1.5;
} else {
dInd... | javascript | {
"resource": ""
} |
q21252 | hasVoi | train | function hasVoi (viewport) {
const hasLut = viewport.voiLUT && viewport.voiLUT.lut && viewport.voiLUT.lut.length > 0;
return hasLut || (viewport.voi.windowWidth !== undefined && viewport.voi.windowCenter !== undefined);
} | javascript | {
"resource": ""
} |
q21253 | compare | train | function compare (a, b) {
if (a.timeStamp > b.timeStamp) {
return -1;
}
if (a.timeStamp < b.timeStamp) {
return 1;
}
return 0;
} | javascript | {
"resource": ""
} |
q21254 | getImageDataType | train | function getImageDataType (image) {
if (image.color) {
return 'rgb';
}
const pixelData = image.getPixelData();
if (pixelData instanceof Int16Array) {
return 'int16';
}
if (pixelData instanceof Uint16Array) {
return 'uint16';
}
if (pixelData instanceof Int8Array) {
return 'int8';
}
... | javascript | {
"resource": ""
} |
q21255 | purgeCacheIfNecessary | train | function purgeCacheIfNecessary () {
// If max cache size has not been exceeded, do nothing
if (cacheSizeInBytes <= maximumSizeInBytes) {
return;
}
// Cache size has been exceeded, create list of images sorted by timeStamp
// So we can purge the least recently used image
function compare (a, b) {
if... | javascript | {
"resource": ""
} |
q21256 | createCanvas | train | function createCanvas (element) {
const canvas = document.createElement('canvas');
canvas.style.display = 'block';
canvas.classList.add(CANVAS_CSS_CLASS);
element.appendChild(canvas);
return canvas;
} | javascript | {
"resource": ""
} |
q21257 | generateNonLinearVOILUT | train | function generateNonLinearVOILUT (voiLUT) {
// We don't trust the voiLUT.numBitsPerEntry, mainly thanks to Agfa!
const bitsPerEntry = Math.max(...voiLUT.lut).toString(2).length;
const shift = bitsPerEntry - 8;
const minValue = voiLUT.lut[0] >> shift;
const maxValue = voiLUT.lut[voiLUT.lut.length - 1] >> shift... | javascript | {
"resource": ""
} |
q21258 | syncViewports | train | function syncViewports (layers, activeLayer) {
// If we intend to keep the viewport's scale, translation and rotation in sync,
// loop through the layers
layers.forEach((layer) => {
// Don't do anything to the active layer
// Don't do anything if this layer has no viewport
if (layer === activeLayer ||... | javascript | {
"resource": ""
} |
q21259 | renderLayers | train | function renderLayers (context, layers, invalidated) {
// Loop through each layer and draw it to the canvas
layers.forEach((layer, index) => {
if (!layer.image) {
return;
}
context.save();
// Set the layer's canvas to the pixel coordinate system
layer.canvas = context.canvas;
setToPi... | javascript | {
"resource": ""
} |
q21260 | createLinearSegmentedColormap | train | function createLinearSegmentedColormap (segmentedData, N, gamma) {
let i;
const lut = [];
N = N === null ? 256 : N;
gamma = gamma === null ? 1 : gamma;
const redLut = makeMappingArray(N, segmentedData.red, gamma);
const greenLut = makeMappingArray(N, segmentedData.green, gamma);
const blueLut = makeMapp... | javascript | {
"resource": ""
} |
q21261 | setCanvasSize | train | function setCanvasSize (element, canvas) {
// The device pixel ratio is 1.0 for normal displays and > 1.0
// For high DPI displays like Retina
/*
This functionality is disabled due to buggy behavior on systems with mixed DPI's. If the canvas
is created on a display with high DPI (e.g. 2.0) and the... | javascript | {
"resource": ""
} |
q21262 | wasFitToWindow | train | function wasFitToWindow (enabledElement, oldCanvasWidth, oldCanvasHeight) {
const scale = enabledElement.viewport.scale;
const imageSize = getImageSize(enabledElement.image, enabledElement.viewport.rotation);
const imageWidth = Math.round(imageSize.width * scale);
const imageHeight = Math.round(imageSize.he... | javascript | {
"resource": ""
} |
q21263 | relativeRescale | train | function relativeRescale (enabledElement, oldCanvasWidth, oldCanvasHeight) {
const scale = enabledElement.viewport.scale;
const canvasWidth = enabledElement.canvas.width;
const canvasHeight = enabledElement.canvas.height;
const relWidthChange = canvasWidth / oldCanvasWidth;
const relHeightChange = canvas... | javascript | {
"resource": ""
} |
q21264 | loadImageFromImageLoader | train | function loadImageFromImageLoader (imageId, options) {
const colonIndex = imageId.indexOf(':');
const scheme = imageId.substring(0, colonIndex);
const loader = imageLoaders[scheme];
if (loader === undefined || loader === null) {
if (unknownImageLoader !== undefined) {
return unknownImageLoader... | javascript | {
"resource": ""
} |
q21265 | getMetaData | train | function getMetaData (type, imageId) {
// Invoke each provider in priority order until one returns something
for (let i = 0; i < providers.length; i++) {
const result = providers[i].provider(type, imageId);
if (result !== undefined) {
return result;
}
}
} | javascript | {
"resource": ""
} |
q21266 | run | train | async function run () {
if (options.help || Object.keys(options).length === 1) {
showHelp()
return
}
if (!options.name) {
console.error('You need to input -n, --name argv')
return
}
if (!options.title) {
options.title = options.name.split('-').join(' ')
}
let content = (await fs.readF... | javascript | {
"resource": ""
} |
q21267 | addKeyword | train | function addKeyword(keyword, definition) {
/* jshint validthis: true */
/* eslint no-shadow: 0 */
var RULES = this.RULES;
if (RULES.keywords[keyword])
throw new Error('Keyword ' + keyword + ' is already defined');
if (!IDENTIFIER.test(keyword))
throw new Error('Keyword ' + keyword + ' is not a valid ... | javascript | {
"resource": ""
} |
q21268 | validateKeyword | train | function validateKeyword(definition, throwError) {
validateKeyword.errors = null;
var v = this._validateKeyword = this._validateKeyword
|| this.compile(definitionSchema, true);
if (v(definition)) return true;
validateKeyword.errors = v.errors;
if (throwError)
throw new E... | javascript | {
"resource": ""
} |
q21269 | resolveSchema | train | function resolveSchema(root, ref) {
/* jshint validthis: true */
var p = URI.parse(ref)
, refPath = _getFullPath(p)
, baseId = getFullPath(this._getId(root.schema));
if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
var id = normalizeId(refPath);
var refVal = this._refs[id];
i... | javascript | {
"resource": ""
} |
q21270 | compile | train | function compile(schema, _meta) {
var schemaObj = this._addSchema(schema, undefined, _meta);
return schemaObj.validate || this._compile(schemaObj);
} | javascript | {
"resource": ""
} |
q21271 | addSchema | train | function addSchema(schema, key, _skipValidation, _meta) {
if (Array.isArray(schema)){
for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta);
return this;
}
var id = this._getId(schema);
if (id !== undefined && typeof id != 'string')
throw new Error('schema ... | javascript | {
"resource": ""
} |
q21272 | getSchema | train | function getSchema(keyRef) {
var schemaObj = _getSchemaObj(this, keyRef);
switch (typeof schemaObj) {
case 'object': return schemaObj.validate || this._compile(schemaObj);
case 'string': return this.getSchema(schemaObj);
case 'undefined': return _getSchemaFragment(this, keyRef);
}
} | javascript | {
"resource": ""
} |
q21273 | errorsText | train | function errorsText(errors, options) {
errors = errors || this.errors;
if (!errors) return 'No errors';
options = options || {};
var separator = options.separator === undefined ? ', ' : options.separator;
var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
var text = '';
for (var i=0;... | javascript | {
"resource": ""
} |
q21274 | addFormat | train | function addFormat(name, format) {
if (typeof format == 'string') format = new RegExp(format);
this._formats[name] = format;
return this;
} | javascript | {
"resource": ""
} |
q21275 | checkCompiling | train | function checkCompiling(schema, root, baseId) {
/* jshint validthis: true */
var index = compIndex.call(this, schema, root, baseId);
if (index >= 0) return { index: index, compiling: true };
index = this._compilations.length;
this._compilations[index] = {
schema: schema,
root: root,
baseId: baseId... | javascript | {
"resource": ""
} |
q21276 | endCompiling | train | function endCompiling(schema, root, baseId) {
/* jshint validthis: true */
var i = compIndex.call(this, schema, root, baseId);
if (i >= 0) this._compilations.splice(i, 1);
} | javascript | {
"resource": ""
} |
q21277 | compIndex | train | function compIndex(schema, root, baseId) {
/* jshint validthis: true */
for (var i=0; i<this._compilations.length; i++) {
var c = this._compilations[i];
if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
}
return -1;
} | javascript | {
"resource": ""
} |
q21278 | compileAsync | train | function compileAsync(schema, meta, callback) {
/* eslint no-shadow: 0 */
/* global Promise */
/* jshint validthis: true */
var self = this;
if (typeof this._opts.loadSchema != 'function')
throw new Error('options.loadSchema should be a function');
if (typeof meta == 'function') {
callback = meta;
... | javascript | {
"resource": ""
} |
q21279 | train | function() {
var self = this, vars, j;
// If this editor needs to be rendered by a macro template
if(this.template) {
vars = this.getWatchedFieldValues();
this.setValue(this.template(vars),false,true);
}
this._super();
} | javascript | {
"resource": ""
} | |
q21280 | train | function (event, type) {
if (!this.getMap()) {
return;
}
const eventType = type || this._getEventTypeToFire(event);
if (eventType === 'contextmenu' && this.listens('contextmenu')) {
stopPropagation(event);
preventDefault(event);
}
const... | javascript | {
"resource": ""
} | |
q21281 | train | function (e) {
const map = this.getMap();
const eventParam = {
'domEvent': e
};
const actual = e.touches && e.touches.length > 0 ? e.touches[0] : e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches[0] : e;
if (actual) {
const containerPoint... | javascript | {
"resource": ""
} | |
q21282 | train | function (coord1, coord2) {
if (!this.getProjection()) {
return null;
}
const p1 = new Coordinate(coord1),
p2 = new Coordinate(coord2);
if (p1.equals(p2)) {
return 0;
}
return this.getProjection().measureLength(p1, p2);
} | javascript | {
"resource": ""
} | |
q21283 | train | function (opts, callback) {
if (!opts) {
return this;
}
const reqLayers = opts['layers'];
if (!isArrayHasData(reqLayers)) {
return this;
}
const layers = [];
for (let i = 0, len = reqLayers.length; i < len; i++) {
if (isString(r... | javascript | {
"resource": ""
} | |
q21284 | train | function (styles, options, step) {
if (this._animPlayer) {
this._animPlayer.finish();
}
if (isFunction(options)) {
step = options;
}
if (!options) {
options = {};
}
const map = this.getMap(),
projection = this._getPr... | javascript | {
"resource": ""
} | |
q21285 | train | function (styles) {
const symbol = this._getInternalSymbol();
const stylesToAnimate = {};
for (const p in styles) {
if (styles.hasOwnProperty(p)) {
const v = styles[p];
if (p !== 'translate' && p !== 'symbol') {
//this.getRadius() /... | javascript | {
"resource": ""
} | |
q21286 | train | function (url, options, cb) {
if (isFunction(options)) {
const t = cb;
cb = options;
options = t;
}
if (IS_NODE && Ajax.get.node) {
return Ajax.get.node(url, cb, options);
}
const client = Ajax._getClient(cb);
client.open('G... | javascript | {
"resource": ""
} | |
q21287 | train | function (url, options, cb) {
let postData;
if (!isString(url)) {
//for compatible
//options, postData, cb
const t = cb;
postData = options;
options = url;
url = options.url;
cb = t;
} else {
if (isFu... | javascript | {
"resource": ""
} | |
q21288 | train | function (coordinate, options = {}, step) {
if (!coordinate) {
return this;
}
if (isFunction(options)) {
step = options;
options = {};
}
coordinate = new Coordinate(coordinate);
if (typeof (options['animation']) === 'undefined' || optio... | javascript | {
"resource": ""
} | |
q21289 | train | function (offset, options = {}, step) {
if (!offset) {
return this;
}
if (isFunction(options)) {
step = options;
options = {};
}
offset = new Point(offset);
this.onMoveStart();
if (typeof (options['animation']) === 'undefined' |... | javascript | {
"resource": ""
} | |
q21290 | rhumbBearing | train | function rhumbBearing(start, end, options = {}) {
let bear360;
if (options.final) bear360 = calculateRhumbBearing(end, start);
else bear360 = calculateRhumbBearing(start, end);
const bear180 = (bear360 > 180) ? -(360 - bear360) : bear360;
return bear180;
} | javascript | {
"resource": ""
} |
q21291 | train | function (helpers) {
Y.log('Importing helpers: ' + helpers, 'info', 'builder');
helpers.forEach(function (imp) {
if (!Y.Files.exists(imp) || Y.Files.exists(path.join(process.cwd(), imp))) {
imp = path.join(process.cwd(), imp);
}
... | javascript | {
"resource": ""
} | |
q21292 | train | function (md) {
var html = marked(md, this.options.markdown);
//Only reprocess if helpers were asked for
if (this.options.helpers || (html.indexOf('{{#crossLink') > -1)) {
//console.log('MD: ', html);
try {
// marked auto-escapes qu... | javascript | {
"resource": ""
} | |
q21293 | train | function () {
var self = this;
Y.log('External data received, mixing', 'info', 'builder');
self.options.externalData.forEach(function (exData) {
['files', 'classes', 'modules'].forEach(function (k) {
Y.each(exData[k], function (item, key) {
... | javascript | {
"resource": ""
} | |
q21294 | train | function (cb) {
var self = this,
info = self.options.external;
if (!info) {
cb();
return;
}
if (!info.merge) {
info.merge = 'mix';
}
if (!info.data) {
Y.log('External ... | javascript | {
"resource": ""
} | |
q21295 | train | function () {
var obj = {
meta: {
yuiSeedUrl: 'http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js',
yuiGridsUrl: 'http://yui.yahooapis.com/3.5.0/build/cssgrids/cssgrids-min.css'
}
};
if (!this._meta) {
... | javascript | {
"resource": ""
} | |
q21296 | train | function (opts) {
opts.meta.classes = [];
Y.each(this.data.classes, function (v) {
if (v.external) {
return;
}
opts.meta.classes.push({
displayName: v.name,
name: v.name,
... | javascript | {
"resource": ""
} | |
q21297 | train | function (opts) {
var self = this;
opts.meta.modules = [];
opts.meta.allModules = [];
Y.each(this.data.modules, function (v) {
if (v.external) {
return;
}
opts.meta.allModules.push({
d... | javascript | {
"resource": ""
} | |
q21298 | train | function (opts) {
var self = this;
opts.meta.files = [];
Y.each(this.data.files, function (v) {
if (v.external) {
return;
}
opts.meta.files.push({
displayName: v.name,
name: se... | javascript | {
"resource": ""
} | |
q21299 | train | function (a) {
var self = this;
if (a.file && a.line && !self.options.nocode) {
a.foundAt = '../files/' + self.filterFileName(a.file) + '.html#l' + a.line;
if (a.path) {
a.foundAt = a.path + '#l' + a.line;
}
}
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.