_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q62100 | deltaRight | test | function deltaRight(left, top) {
let d = 0;
// If there is an edge, and no crossing edges, continue.
if(top[3] === 1 && left[1] !== 1 && left[3] !== 1) {
d += 1;
}
/* If an edge was previously found, there is another edge and there are no
crossing edges, continue. */
if(d === 1 && top[2] === 1 && left[0] ... | javascript | {
"resource": ""
} |
q62101 | bilinear | test | function bilinear(e) {
const a = lerp(e[0], e[1], 1.0 - 0.25);
const b = lerp(e[2], e[3], 1.0 - 0.25);
return lerp(a, b, 1.0 - 0.125);
} | javascript | {
"resource": ""
} |
q62102 | checkForm | test | function checkForm(that) {
var newValue = $(that).val()
var matches = newValue != '' ? newValue.match(timeRegEx) : ''
var error = $(that)
.closest('.time-spinner')
.find('.error_container')
var $closerTimeSpinner = $(that)
.closest('.time-spinner')
.find('.spinner-control')
... | javascript | {
"resource": ""
} |
q62103 | resetToMove | test | function resetToMove(contextControl) {
var left = contextControl.find('.source .transfer-group')
var right = contextControl.find('.target .transfer-group')
var textLeft = contextControl.find('.source .transfer-header span.num')
var textRight = contextControl.find('.target .transfer-header span.num')
... | javascript | {
"resource": ""
} |
q62104 | checkIfActive | test | function checkIfActive(
targetControl,
targetHeaderControl,
containerTypeControl,
addButtonControl
) {
$(targetControl).each(function(el) {
if ($(this).prop('checked')) {
if (!$(targetHeaderControl).hasClass('semi-checked')) {
$(targetHeaderControl).addClass('semi-checked')... | javascript | {
"resource": ""
} |
q62105 | sourceControl | test | function sourceControl(contextControl) {
var tocheck = contextControl.find('.transfer-scroll').find('input')
var checknum = tocheck.length
var targetText = contextControl
.find('.transfer-header')
.find('label span.num')
var header = contextControl.find('.transfer-header input')
$(heade... | javascript | {
"resource": ""
} |
q62106 | targetControl | test | function targetControl(targetControl) {
var tocheck = targetControl.find('input')
var checknum = tocheck.length
var targetText = tocheck
.closest('.it-transfer-wrapper')
.find('.transfer-header')
.find('label span.num')
var header = $(targetControl).find('.transfer-header input')
... | javascript | {
"resource": ""
} |
q62107 | checkToMove | test | function checkToMove(contextControl, targetControl) {
var elements = contextControl.find('.transfer-group').find('input:checked')
var sourceTag = $(elements).closest('.form-check')
$(elements).each(function() {
$(this).prop('checked', false)
$(sourceTag)
.detach()
.appendTo(targ... | javascript | {
"resource": ""
} |
q62108 | updateScrollPos | test | function updateScrollPos() {
if (!stickies.length) {
return
}
lastKnownScrollTop =
document.documentElement.scrollTop || document.body.scrollTop
// Only trigger a layout change if we’re not already waiting for one
if (!isAnimationRequested) {
isAnimationRequested = true
//... | javascript | {
"resource": ""
} |
q62109 | scoreText | test | function scoreText(score) {
if (score === -1) {
return options.shortPass
}
score = score < 0 ? 0 : score
if (score < 26) {
return options.shortPass
}
if (score < 51) {
return options.badPass
}
if (score < 76) {
return options.goodPass
... | javascript | {
"resource": ""
} |
q62110 | calculateScore | test | function calculateScore(password) {
var score = 0
// password < options.minimumLength
if (password.length < options.minimumLength) {
return -1
}
// password length
score += password.length * 4
score += checkRepetition(1, password).length - password.length
score ... | javascript | {
"resource": ""
} |
q62111 | checkRepetition | test | function checkRepetition(rLen, str) {
var res = '',
repeated = false
for (var i = 0; i < str.length; i++) {
repeated = true
for (var j = 0; j < rLen && j + i + rLen < str.length; j++) {
repeated = repeated && str.charAt(j + i) === str.charAt(j + i + rLen)
}
... | javascript | {
"resource": ""
} |
q62112 | init | test | function init() {
var shown = true
var $text = options.showText
var $graybar = $('<div>').addClass(
'password-meter progress rounded-0 position-absolute'
)
$graybar.append(`<div class="row position-absolute w-100 m-0">
<div class="col-3 border-left border-right border-whit... | javascript | {
"resource": ""
} |
q62113 | LevelUpArrayAdapter | test | function LevelUpArrayAdapter(name, db, serializer) {
this.db = Sublevel(db);
this.db = this.db.sublevel(name);
this.name = name;
this.serializer = serializer || {
encode: function(val, callback) {
callback(null, val);
},
decode: function(val, callback) {
callback(null, val);
}
};
} | javascript | {
"resource": ""
} |
q62114 | fixProps | test | function fixProps(tx, data) {
// ethereumjs-tx doesn't allow for a `0` value in fields, but we want it to
// in order to differentiate between a value that isn't set and a value
// that is set to 0 in a fake transaction.
// Once https://github.com/ethereumjs/ethereumjs-tx/issues/112 is figured
// out we can p... | javascript | {
"resource": ""
} |
q62115 | initData | test | function initData(tx, data) {
if (data) {
if (typeof data === "string") {
data = to.buffer(data);
}
if (Buffer.isBuffer(data)) {
data = rlp.decode(data);
}
const self = tx;
if (Array.isArray(data)) {
if (data.length > tx._fields.length) {
throw new Error("wrong number... | javascript | {
"resource": ""
} |
q62116 | TXRejectedError | test | function TXRejectedError(message) {
// Why not just Error.apply(this, [message])? See
// https://gist.github.com/justmoon/15511f92e5216fa2624b#anti-patterns
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
} | javascript | {
"resource": ""
} |
q62117 | RequestFunnel | test | function RequestFunnel() {
// We use an object here for O(1) lookups (speed).
this.methods = {
eth_call: true,
eth_getStorageAt: true,
eth_sendTransaction: true,
eth_sendRawTransaction: true,
// Ensure block filter and filter changes are process one at a time
// as well so filter requests t... | javascript | {
"resource": ""
} |
q62118 | compileSass | test | function compileSass(_path, ext, data, callback) {
const compiledCss = sass.renderSync({
data: data,
outputStyle: 'expanded',
importer: function (url, prev, done) {
if (url.startsWith('~')) {
const newUrl = path.join(__dirname, 'node_modules', url.substr(1));
return { file: newUrl };... | javascript | {
"resource": ""
} |
q62119 | requireBrocfile | test | function requireBrocfile(brocfilePath) {
let brocfile;
if (brocfilePath.match(/\.ts$/)) {
try {
require.resolve('ts-node');
} catch (e) {
throw new Error(`Cannot find module 'ts-node', please install`);
}
try {
require.resolve('typescript');
} catch (e) {
throw new Erro... | javascript | {
"resource": ""
} |
q62120 | runmath | test | function runmath(s) {
var ans;
try {// We want to catch parse errors and die appropriately
// Make a parser and feed the input
ans = new nearley.Parser(grammar.ParserRules, grammar.ParserStart)
.feed(s);
// Check if there are any results
if (ans.results.leng... | javascript | {
"resource": ""
} |
q62121 | test | function(arr, isSigned) {
if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));
var end = readPackedEnd(this);
arr = arr || [];
while (this.pos < end) arr.push(this.readVarint(isSigned));
return arr;
} | javascript | {
"resource": ""
} | |
q62122 | handleUnionSelections | test | function handleUnionSelections(
sqlASTNode,
children,
selections,
gqlType,
namespace,
depth,
options,
context,
internalOptions = {}
) {
for (let selection of selections) {
// we need to figure out what kind of selection this is
switch (selection.kind) {
case 'Field':
// has this fi... | javascript | {
"resource": ""
} |
q62123 | handleSelections | test | function handleSelections(
sqlASTNode,
children,
selections,
gqlType,
namespace,
depth,
options,
context,
internalOptions = {},
) {
for (let selection of selections) {
// we need to figure out what kind of selection this is
switch (selection.kind) {
// if its another field, recurse throu... | javascript | {
"resource": ""
} |
q62124 | columnToASTChild | test | function columnToASTChild(columnName, namespace) {
return {
type: 'column',
name: columnName,
fieldName: columnName,
as: namespace.generate('column', columnName)
}
} | javascript | {
"resource": ""
} |
q62125 | keyToASTChild | test | function keyToASTChild(key, namespace) {
if (typeof key === 'string') {
return columnToASTChild(key, namespace)
}
if (Array.isArray(key)) {
const clumsyName = toClumsyName(key)
return {
type: 'composite',
name: key,
fieldName: clumsyName,
as: namespace.generate('column', clumsy... | javascript | {
"resource": ""
} |
q62126 | stripRelayConnection | test | function stripRelayConnection(gqlType, queryASTNode, fragments) {
// get the GraphQL Type inside the list of edges inside the Node from the schema definition
const edgeType = stripNonNullType(gqlType._fields.edges.type)
const strippedType = stripNonNullType(stripNonNullType(edgeType.ofType)._fields.node.type)
/... | javascript | {
"resource": ""
} |
q62127 | spreadFragments | test | function spreadFragments(selections, fragments, typeName) {
return flatMap(selections, selection => {
switch (selection.kind) {
case 'FragmentSpread':
const fragmentName = selection.name.value
const fragment = fragments[fragmentName]
return spreadFragments(fragment.selectionSet.selections, f... | javascript | {
"resource": ""
} |
q62128 | getNode | test | async function getNode(typeName, resolveInfo, context, condition, dbCall, options = {}) {
// get the GraphQL type from the schema using the name
const type = resolveInfo.schema._typeMap[typeName]
assert(type, `Type "${typeName}" not found in your schema.`)
assert(type._typeConfig.sqlTable, `joinMonster can't fe... | javascript | {
"resource": ""
} |
q62129 | arrToConnection | test | function arrToConnection(data, sqlAST) {
// use "post-order" tree traversal
for (let astChild of sqlAST.children || []) {
if (Array.isArray(data)) {
for (let dataItem of data) {
recurseOnObjInData(dataItem, astChild)
}
} else if (data) {
recurseOnObjInData(data, astChild)
}
}... | javascript | {
"resource": ""
} |
q62130 | validate | test | function validate(rows) {
// its supposed to be an array of objects
if (Array.isArray(rows)) return rows
// a check for the most common error. a lot of ORMs return an object with the desired data on the `rows` property
if (rows && rows.rows) return rows.rows
throw new Error(
`"dbCall" function must retur... | javascript | {
"resource": ""
} |
q62131 | sortKeyToWhereCondition | test | function sortKeyToWhereCondition(keyObj, descending, sortTable, dialect) {
const { name, quote: q } = dialect
const sortColumns = []
const sortValues = []
for (let key in keyObj) {
sortColumns.push(`${q(sortTable)}.${q(key)}`)
sortValues.push(maybeQuote(keyObj[key], name))
}
const operator = descend... | javascript | {
"resource": ""
} |
q62132 | clone | test | function clone(frm, to) {
if (frm === null || typeof frm !== "object") {
return frm;
}
if (frm.constructor !== Object && frm.constructor !== Array) {
return frm;
}
if (frm.constructor === Date || frm.constructor === RegExp || frm.constructor === Function ||
frm.constructor === String || frm.constructor === N... | javascript | {
"resource": ""
} |
q62133 | buildString | test | function buildString (length, str) {
return Array.apply(null, new Array(length)).map(String.prototype.valueOf, str).join('')
} | javascript | {
"resource": ""
} |
q62134 | concatArray | test | function concatArray (arr, pretty, indentation, indentLevel) {
var currentIndent = buildString(indentLevel, indentation)
var closingBraceIndent = buildString(indentLevel - 1, indentation)
var join = pretty ? ',\n' + currentIndent : ', '
if (pretty) {
return '[\n' + currentIndent + arr.join(join) + '\n' + c... | javascript | {
"resource": ""
} |
q62135 | test | function (value, opts, indentLevel) {
indentLevel = indentLevel === undefined ? 1 : indentLevel + 1
switch (Object.prototype.toString.call(value)) {
case '[object Number]':
return value
case '[object Array]':
// Don't prettify arrays nto not take too much space
var pretty = ... | javascript | {
"resource": ""
} | |
q62136 | test | function(text, placeholders) {
if (text[text.length - 1] == "]" && text.lastIndexOf(" [") != -1) {
// Remove translation comments
text = text.substr(0, text.lastIndexOf(" ["));
}
var replaceAll = function(str, substr, replacement) {
return str.replace(
... | javascript | {
"resource": ""
} | |
q62137 | createNode | test | function createNode (media) {
var node = new Audio();
node.onplay = function () {
Media.onStatus(media.id, Media.MEDIA_STATE, Media.MEDIA_STARTING);
};
node.onplaying = function () {
Media.onStatus(media.id, Media.MEDIA_STATE, Media.MEDIA_RUNNING);
};
node.ondurationchange = f... | javascript | {
"resource": ""
} |
q62138 | test | function(win, lose, args) {
var id = args[0];
var srcUri = processUri(args[1]);
var createAudioNode = !!args[2];
var thisM = Media.get(id);
Media.prototype.node = null;
var prefix = args[1].split(':').shift();
var extension = srcUri.extension;
if (this... | javascript | {
"resource": ""
} | |
q62139 | test | function(win, lose, args) {
var id = args[0];
//var src = args[1];
//var options = args[2];
var thisM = Media.get(id);
// if Media was released, then node will be null and we need to create it again
if (!thisM.node) {
args[2] = true; // Setting createAudioNod... | javascript | {
"resource": ""
} | |
q62140 | test | function(win, lose, args) {
var id = args[0];
var milliseconds = args[1];
var thisM = Media.get(id);
try {
thisM.node.currentTime = milliseconds / 1000;
win(thisM.node.currentTime);
} catch (err) {
lose("Failed to seek: "+err);
}
} | javascript | {
"resource": ""
} | |
q62141 | test | function(win, lose, args) {
var id = args[0];
var thisM = Media.get(id);
try {
thisM.node.pause();
Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_PAUSED);
} catch (err) {
lose("Failed to pause: "+err);
}
} | javascript | {
"resource": ""
} | |
q62142 | test | function(win, lose, args) {
var id = args[0];
try {
var p = (Media.get(id)).node.currentTime;
win(p);
} catch (err) {
lose(err);
}
} | javascript | {
"resource": ""
} | |
q62143 | test | function(win, lose, args) {
var id = args[0];
var srcUri = processUri(args[1]);
var dest = parseUriToPathAndFilename(srcUri);
var destFileName = dest.fileName;
var success = function () {
Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_RUNNING);
};
... | javascript | {
"resource": ""
} | |
q62144 | test | function(win, lose, args) {
var id = args[0];
var thisM = Media.get(id);
var srcUri = processUri(thisM.src);
var dest = parseUriToPathAndFilename(srcUri);
var destPath = dest.path;
var destFileName = dest.fileName;
var fsType = dest.fsType;
var success =... | javascript | {
"resource": ""
} | |
q62145 | test | function(win, lose, args) {
var id = args[0];
var thisM = Media.get(id);
try {
if (thisM.node) {
thisM.node.onloadedmetadata = null;
// Unsubscribing as the media object is being released
thisM.node.onerror = null;
// Ne... | javascript | {
"resource": ""
} | |
q62146 | fullPathToAppData | test | function fullPathToAppData(uri) {
if (uri.schemeName === 'file') {
if (uri.rawUri.indexOf(Windows.Storage.ApplicationData.current.localFolder.path) !== -1) {
// Also remove path' beginning slash to avoid losing folder name part
uri = new Windows.Foundation.Uri(localFolderAppDataBaseP... | javascript | {
"resource": ""
} |
q62147 | cdvfileToAppData | test | function cdvfileToAppData(uri) {
var cdvFsRoot;
if (uri.schemeName === 'cdvfile') {
cdvFsRoot = uri.path.split('/')[1];
if (cdvFsRoot === 'temporary') {
return new Windows.Foundation.Uri(tempFolderAppDataBasePath, uri.path.split('/').slice(2).join('/'));
} else if (cdvFsRoot... | javascript | {
"resource": ""
} |
q62148 | processUri | test | function processUri(src) {
// Collapse double slashes (File plugin issue): ms-appdata:///temp//recs/memos/media.m4a => ms-appdata:///temp/recs/memos/media.m4a
src = src.replace(/([^\/:])(\/\/)([^\/])/g, '$1/$3');
// Remove beginning slashes
src = src.replace(/^[\\\/]{1,2}/, '');
var uri = setTempo... | javascript | {
"resource": ""
} |
q62149 | parseUriToPathAndFilename | test | function parseUriToPathAndFilename(uri) {
// Removing scheme and location, using backslashes: ms-appdata:///local/path/to/file.m4a -> path\\to\\file.m4a
var normalizedSrc = uri.path.split('/').slice(2).join('\\');
var path = normalizedSrc.substr(0, normalizedSrc.lastIndexOf('\\'));
var fileName = norma... | javascript | {
"resource": ""
} |
q62150 | Context | test | function Context (hook, opts) {
this.hook = hook;
// create new object, to avoid affecting input opts in other places
// For example context.opts.plugin = Object is done, then it affects by reference
this.opts = Object.assign({}, opts);
this.cmdLine = process.argv.join(' ');
// Lazy-load cordo... | javascript | {
"resource": ""
} |
q62151 | getUniqueCapabilities | test | function getUniqueCapabilities(capabilities) {
return capabilities.reduce(function(uniqueCaps, currCap) {
var isRepeated = uniqueCaps.some(function(cap) {
return getCapabilityName(cap) === getCapabilityName(currCap);
});
return isRepeated ? uniqueCaps : uniqueCaps.concat([currC... | javascript | {
"resource": ""
} |
q62152 | compareCapabilities | test | function compareCapabilities(firstCap, secondCap) {
var firstCapName = getCapabilityName(firstCap);
var secondCapName = getCapabilityName(secondCap);
if (firstCapName < secondCapName) {
return -1;
}
if (firstCapName > secondCapName) {
return 1;
}
return 0;
} | javascript | {
"resource": ""
} |
q62153 | isCordova | test | function isCordova (dir) {
if (!dir) {
// Prefer PWD over cwd so that symlinked dirs within your PWD work correctly (CB-5687).
var pwd = process.env.PWD;
var cwd = process.cwd();
if (pwd && pwd !== cwd && pwd !== 'undefined') {
return this.isCordova(pwd) || this.isCordova... | javascript | {
"resource": ""
} |
q62154 | cdProjectRoot | test | function cdProjectRoot () {
const projectRoot = this.getProjectRoot();
if (!origCwd) {
origCwd = process.env.PWD || process.cwd();
}
process.env.PWD = projectRoot;
process.chdir(projectRoot);
return projectRoot;
} | javascript | {
"resource": ""
} |
q62155 | deleteSvnFolders | test | function deleteSvnFolders (dir) {
var contents = fs.readdirSync(dir);
contents.forEach(function (entry) {
var fullpath = path.join(dir, entry);
if (isDirectory(fullpath)) {
if (entry === '.svn') {
fs.removeSync(fullpath);
} else module.exports.deleteSvnFol... | javascript | {
"resource": ""
} |
q62156 | findPlugins | test | function findPlugins (pluginDir) {
var plugins = [];
if (fs.existsSync(pluginDir)) {
plugins = fs.readdirSync(pluginDir).filter(function (fileName) {
var pluginPath = path.join(pluginDir, fileName);
var isPlugin = isDirectory(pluginPath) || isSymbolicLink(pluginPath);
... | javascript | {
"resource": ""
} |
q62157 | HooksRunner | test | function HooksRunner (projectRoot) {
var root = cordovaUtil.isCordova(projectRoot);
if (!root) throw new CordovaError('Not a Cordova project ("' + projectRoot + '"), can\'t use hooks.');
else this.projectRoot = root;
} | javascript | {
"resource": ""
} |
q62158 | extractSheBangInterpreter | test | function extractSheBangInterpreter (fullpath) {
// this is a modern cluster size. no need to read less
const chunkSize = 4096;
const fileData = readChunk.sync(fullpath, 0, chunkSize);
const fileChunk = fileData.toString();
const hookCmd = shebangCommand(fileChunk);
if (hookCmd && fileData.lengt... | javascript | {
"resource": ""
} |
q62159 | isHookDisabled | test | function isHookDisabled (opts, hook) {
if (opts === undefined || opts.nohooks === undefined) {
return false;
}
var disabledHooks = opts.nohooks;
var length = disabledHooks.length;
for (var i = 0; i < length; i++) {
if (hook.match(disabledHooks[i]) !== null) {
return true;... | javascript | {
"resource": ""
} |
q62160 | test | function() {
var modulemapper = require('cordova/modulemapper');
var channel = require('cordova/channel');
modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
channel.onNativeReady.fire();
document.addEventListener("visibilitychange", function(){
... | javascript | {
"resource": ""
} | |
q62161 | test | function (hook, opts) {
// args check
if (!hook) {
throw new Error('hook type is not specified');
}
return getApplicationHookScripts(hook, opts)
.concat(getPluginsHookScripts(hook, opts));
} | javascript | {
"resource": ""
} | |
q62162 | getPluginsHookScripts | test | function getPluginsHookScripts (hook, opts) {
// args check
if (!hook) {
throw new Error('hook type is not specified');
}
// In case before_plugin_install, after_plugin_install, before_plugin_uninstall hooks we receive opts.plugin and
// retrieve scripts exclusive for this plugin.
if (o... | javascript | {
"resource": ""
} |
q62163 | getApplicationHookScriptsFromDir | test | function getApplicationHookScriptsFromDir (dir) {
if (!(fs.existsSync(dir))) {
return [];
}
var compareNumbers = function (a, b) {
// TODO SG looks very complex, do we really need this?
return isNaN(parseInt(a, 10)) ? a.toLowerCase().localeCompare(b.toLowerCase ? b.toLowerCase() : b... | javascript | {
"resource": ""
} |
q62164 | getScriptsFromConfigXml | test | function getScriptsFromConfigXml (hook, opts) {
var configPath = cordovaUtil.projectConfig(opts.projectRoot);
var configXml = new ConfigParser(configPath);
return configXml.getHookScripts(hook, opts.cordova.platforms).map(function (scriptElement) {
return {
path: scriptElement.attrib.sr... | javascript | {
"resource": ""
} |
q62165 | getPluginScriptFiles | test | function getPluginScriptFiles (plugin, hook, platforms) {
var scriptElements = plugin.pluginInfo.getHookScripts(hook, platforms);
return scriptElements.map(function (scriptElement) {
return {
path: scriptElement.attrib.src,
fullPath: path.join(plugin.dir, scriptElement.attrib.sr... | javascript | {
"resource": ""
} |
q62166 | getAllPluginsHookScriptFiles | test | function getAllPluginsHookScriptFiles (hook, opts) {
var scripts = [];
var currentPluginOptions;
var plugins = (new PluginInfoProvider()).getAllWithinSearchPath(path.join(opts.projectRoot, 'plugins'));
plugins.forEach(function (pluginInfo) {
currentPluginOptions = {
id: pluginInfo.... | javascript | {
"resource": ""
} |
q62167 | ensureUniqueCapabilities | test | function ensureUniqueCapabilities(capabilities) {
var uniqueCapabilities = [];
capabilities.getchildren()
.forEach(function(el) {
var name = el.attrib.Name;
if (uniqueCapabilities.indexOf(name) !== -1) {
capabilities.remove(el);
} else {
uniqueCapabilities.pus... | javascript | {
"resource": ""
} |
q62168 | copyNewFile | test | function copyNewFile (plugin_dir, src, project_dir, dest, link) {
var target_path = path.resolve(project_dir, dest);
if (fs.existsSync(target_path))
throw new CordovaError('"' + target_path + '" already exists!');
copyFile(plugin_dir, src, project_dir, dest, !!link);
} | javascript | {
"resource": ""
} |
q62169 | PluginSpec | test | function PluginSpec (raw, scope, id, version) {
/** @member {String|null} The npm scope of the plugin spec or null if it does not have one */
this.scope = scope || null;
/** @member {String|null} The id of the plugin or the raw plugin spec if it is not an npm package */
this.id = id || raw;
/** @m... | javascript | {
"resource": ""
} |
q62170 | getPluginFilePath | test | function getPluginFilePath(plugin, pluginFile, targetDir) {
var src = path.resolve(plugin.dir, pluginFile);
return '$(ProjectDir)' + path.relative(targetDir, src);
} | javascript | {
"resource": ""
} |
q62171 | platform | test | function platform (command, targets, opts) {
// CB-10519 wrap function code into promise so throwing error
// would result in promise rejection instead of uncaught exception
return Promise.resolve().then(function () {
var msg;
var projectRoot = cordova_util.cdProjectRoot();
var hooks... | javascript | {
"resource": ""
} |
q62172 | getPlatforms | test | function getPlatforms (projectRoot) {
var xml = cordova_util.projectConfig(projectRoot);
var cfg = new ConfigParser(xml);
// If an engine's 'version' property is really its source, map that to the appropriate field.
var engines = cfg.getEngines().map(function (engine) {
var result = {
... | javascript | {
"resource": ""
} |
q62173 | getPlugins | test | function getPlugins (projectRoot) {
var xml = cordova_util.projectConfig(projectRoot);
var cfg = new ConfigParser(xml);
// Map variables object to an array
var plugins = cfg.getPlugins().map(function (plugin) {
var result = {
name: plugin.name
};
if (semver.validRan... | javascript | {
"resource": ""
} |
q62174 | test | function (plugin_id, plugins_dir, platformJson, pluginInfoProvider) {
var depsInfo;
if (typeof plugins_dir === 'object') { depsInfo = plugins_dir; } else { depsInfo = pkg.generateDependencyInfo(platformJson, plugins_dir, pluginInfoProvider); }
var graph = depsInfo.graph;
var dependencie... | javascript | {
"resource": ""
} | |
q62175 | createReplacement | test | function createReplacement(manifestFile, originalChange) {
var replacement = {
target: manifestFile,
parent: originalChange.parent,
after: originalChange.after,
xmls: originalChange.xmls,
versions: originalChange.versions,
devi... | javascript | {
"resource": ""
} |
q62176 | checkID | test | function checkID (expectedIdAndVersion, pinfo) {
if (!expectedIdAndVersion) return;
var parsedSpec = pluginSpec.parse(expectedIdAndVersion);
if (parsedSpec.id !== pinfo.id) {
throw new Error('Expected plugin to have ID "' + parsedSpec.id + '" but got "' + pinfo.id + '".');
}
if (parsedSpe... | javascript | {
"resource": ""
} |
q62177 | getPlatformDetailsFromDir | test | function getPlatformDetailsFromDir (dir, platformIfKnown) {
var libDir = path.resolve(dir);
var platform;
var version;
// console.log("getPlatformDetailsFromDir : ", dir, platformIfKnown, libDir);
try {
var pkgPath = path.join(libDir, 'package.json');
var pkg = cordova_util.require... | javascript | {
"resource": ""
} |
q62178 | platformFromName | test | function platformFromName (name) {
var platName = name;
var platMatch = /^cordova-([a-z0-9-]+)$/.exec(name);
if (platMatch && (platMatch[1] in platforms)) {
platName = platMatch[1];
events.emit('verbose', 'Removing "cordova-" prefix from ' + name);
}
return platName;
} | javascript | {
"resource": ""
} |
q62179 | processMessage | test | function processMessage(message) {
var firstChar = message.charAt(0);
if (firstChar == 'J') {
// This is deprecated on the .java side. It doesn't work with CSP enabled.
eval(message.slice(1));
} else if (firstChar == 'S' || firstChar == 'F') {
var success = firstChar == 'S';
... | javascript | {
"resource": ""
} |
q62180 | callEngineScripts | test | function callEngineScripts (engines, project_dir) {
return Promise.all(
engines.map(function (engine) {
// CB-5192; on Windows scriptSrc doesn't have file extension so we shouldn't check whether the script exists
var scriptPath = engine.scriptSrc || null;
if (scriptPath ... | javascript | {
"resource": ""
} |
q62181 | createPackageJson | test | function createPackageJson (plugin_path) {
var pluginInfo = new PluginInfo(plugin_path);
var defaults = {
id: pluginInfo.id,
version: pluginInfo.version,
description: pluginInfo.description,
license: pluginInfo.license,
keywords: pluginInfo.getKeywordsAndPlatforms(),
... | javascript | {
"resource": ""
} |
q62182 | preparePlatforms | test | function preparePlatforms (platformList, projectRoot, options) {
return Promise.all(platformList.map(function (platform) {
// TODO: this need to be replaced by real projectInfo
// instance for current project.
var project = {
root: projectRoot,
projectConfig: new Conf... | javascript | {
"resource": ""
} |
q62183 | test | function(icon, icon_size) {
// do I have a platform icon for that density already
var density = icon.density || sizeToDensityMap[icon_size];
if (!density) {
// invalid icon defition ( or unsupported size)
return;
}
var previous = android_icons[density];
... | javascript | {
"resource": ""
} | |
q62184 | mapImageResources | test | function mapImageResources(rootDir, subDir, type, resourceName) {
var pathMap = {};
shell.ls(path.join(rootDir, subDir, type + '-*'))
.forEach(function (drawableFolder) {
var imagePath = path.join(subDir, path.basename(drawableFolder), resourceName);
pathMap[imagePath] = null;
});
re... | javascript | {
"resource": ""
} |
q62185 | findAndroidLaunchModePreference | test | function findAndroidLaunchModePreference(platformConfig) {
var launchMode = platformConfig.getPreference('AndroidLaunchMode');
if (!launchMode) {
// Return a default value
return 'singleTop';
}
var expectedValues = ['standard', 'singleTop', 'singleTask', 'singleInstance'];
var valid... | javascript | {
"resource": ""
} |
q62186 | AndroidManifest | test | function AndroidManifest(path) {
this.path = path;
this.doc = xml.parseElementtreeSync(path);
if (this.doc.getroot().tag !== 'manifest') {
throw new Error('AndroidManifest at ' + path + ' has incorrect root node name (expected "manifest")');
}
} | javascript | {
"resource": ""
} |
q62187 | expectUnmetRequirements | test | function expectUnmetRequirements (expected) {
const actual = unmetRequirementsCollector.store;
expect(actual).toEqual(jasmine.arrayWithExactContents(expected));
} | javascript | {
"resource": ""
} |
q62188 | findVersion | test | function findVersion (versions, version) {
var cleanedVersion = semver.clean(version);
for (var i = 0; i < versions.length; i++) {
if (semver.clean(versions[i]) === cleanedVersion) {
return versions[i];
}
}
return null;
} | javascript | {
"resource": ""
} |
q62189 | listUnmetRequirements | test | function listUnmetRequirements (name, failedRequirements) {
events.emit('warn', 'Unmet project requirements for latest version of ' + name + ':');
failedRequirements.forEach(function (req) {
events.emit('warn', ' ' + req.dependency + ' (' + req.installed + ' in project, ' + req.required + ' required... | javascript | {
"resource": ""
} |
q62190 | test | function(folderName, task) {
var defer = Q.defer();
var vn = (task.name || folderName);
if (!task.id || !check.isUUID(task.id)) {
defer.reject(createError(vn + ': id is a required guid'));
};
if (!task.name || !check.isAlphanumeric(task.name)) {
defer.reject(createError(... | javascript | {
"resource": ""
} | |
q62191 | test | function (travisYML, newVersion, newCodeName, existingVersions) {
// Should only add the new version if it is not present in any form
if (existingVersions.versions.length === 0) return travisYML
const nodeVersionIndex = getNodeVersionIndex(existingVersions.versions, newVersion, newCodeName)
const travisYMLLines... | javascript | {
"resource": ""
} | |
q62192 | test | function (travisYML, newVersion, newCodeName, existingVersions) {
// Should only remove the old version if it is actually present in any form
if (existingVersions.versions.length === 0) return travisYML
const nodeVersionIndex = getNodeVersionIndex(existingVersions.versions, newVersion, newCodeName, true)
let tr... | javascript | {
"resource": ""
} | |
q62193 | travisTransform | test | function travisTransform (travisYML) {
try {
var travisJSON = yaml.safeLoad(travisYML, {
schema: yaml.FAILSAFE_SCHEMA
})
} catch (e) {
// ignore .travis.yml if it can not be parsed
return
}
// No node versions specified in root level of travis YML
// There may be node... | javascript | {
"resource": ""
} |
q62194 | isDependencyIgnoredInGroups | test | function isDependencyIgnoredInGroups (groups, packageFilePath, dependencyName) {
const groupName = getGroupForPackageFile(groups, packageFilePath)
return groupName && _.includes(groups[groupName].ignore, dependencyName)
} | javascript | {
"resource": ""
} |
q62195 | getDependencyURL | test | function getDependencyURL ({ repositoryURL, dependency }) {
// githubURL is an object!
const githubURL = url.parse(
githubFromGit(repositoryURL) || ''
)
if (dependency && !githubURL.href) {
return `https://www.npmjs.com/package/${dependency}`
}
return githubURL
} | javascript | {
"resource": ""
} |
q62196 | extractApis | test | function extractApis(services) {
var filterTypes = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
services = Array.isArray(services) ? services : [services];
var apis = services.reduce(function (total, service... | javascript | {
"resource": ""
} |
q62197 | extractNormalizedFacetValues | test | function extractNormalizedFacetValues(results, attribute) {
var predicate = {name: attribute};
if (results._state.isConjunctiveFacet(attribute)) {
var facet = find(results.facets, predicate);
if (!facet) return [];
return map(facet.data, function(v, k) {
return {
name: k,
count: v... | javascript | {
"resource": ""
} |
q62198 | recSort | test | function recSort(sortFn, node) {
if (!node.data || node.data.length === 0) {
return node;
}
var children = map(node.data, partial(recSort, sortFn));
var sortedChildren = sortFn(children);
var newNode = merge({}, node, {data: sortedChildren});
return newNode;
} | javascript | {
"resource": ""
} |
q62199 | test | function(attribute, operator, v) {
var value = valToNumber(v);
if (this.isNumericRefined(attribute, operator, value)) return this;
var mod = merge({}, this.numericRefinements);
mod[attribute] = merge({}, mod[attribute]);
if (mod[attribute][operator]) {
// Array copy
mod[attribute][op... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.