_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q59500 | validation | function(yargs, classNames, packageName) {
let pkg = null;
packageName.split(".").forEach(seg => {
if (pkg === null) {
pkg = window[seg];
} else {
pkg = pkg[seg];
}
});
classNames.forEach(cmd => {
require("../../../" + packageName.replace(/\./g... | javascript | {
"resource": ""
} | |
q59501 | validation | function(msgId, ...args) {
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (typeof arg !== "string" && typeof arg !== "number" && arg !== null) {
args[i] = String(arg);
}
}
if (this.isMachineReadable()) {
let str = "##" + msgId + ":" + JSON.stri... | javascript | {
"resource": ""
} | |
q59502 | validation | function(msgId, ...args) {
var msg = qx.tool.compiler.Console.MESSAGE_IDS[msgId]||msgId;
var str = qx.lang.String.format(msg.message, args||[]);
return str;
} | javascript | {
"resource": ""
} | |
q59503 | validation | function(marker, showPosition) {
var msg = qx.tool.compiler.Console.MESSAGE_IDS[marker.msgId]||marker.msgId;
var str = "";
var pos = marker.pos;
if (showPosition !== false && pos && pos.start && pos.start.line) {
str += "[" + pos.start.line;
if (pos.start.column) {
str ... | javascript | {
"resource": ""
} | |
q59504 | validation | async function() {
let apps = [];
let argv = this.argv;
let result = {
target: argv.target,
outputPath: argv.outputPath||null,
locales: null,
writeAllTranslations: argv.writeAllTranslations,
environment: {},
applications: apps,
libraries: argv.li... | javascript | {
"resource": ""
} | |
q59505 | validation | function() {
return {
command: "migrate [options]",
desc: "migrates a qooxdoo application to the next major version",
usage: "migrate",
builder: {
"verbose": {
alias : "v",
describe: "enables additional progress output to console",
type... | javascript | {
"resource": ""
} | |
q59506 | validation | function(type) {
if (!type) {
return null;
}
if (type.$$type == "Class") {
return type;
}
if (type == "build") {
return qx.tool.compiler.targets.BuildTarget;
}
if (type == "source") {
return qx.tool.compiler.targets.SourceTarget;
}
if... | javascript | {
"resource": ""
} | |
q59507 | validation | function(callback) {
var t = this;
async.waterfall([
function readDb(callback) {
fs.exists(t.__dbFilename, function(exists) {
if (exists) {
fs.readFile(t.__dbFilename, {
encoding: "utf-8"
}, callback);
} else {
... | javascript | {
"resource": ""
} | |
q59508 | scanDir | validation | function scanDir(rootDir, dir, resource, doNotCopy, callback) {
// Get the list of files
fs.readdir(dir, function(err, files) {
if (err) {
callback(err);
return;
}
// and process each one
async.forEach(files... | javascript | {
"resource": ""
} |
q59509 | validation | function(srcPaths) {
var t = this;
var db = this.__db;
// Generate a lookup that maps the resource name to the meta file that
// contains the composite
var metas = {};
for (var libraryName in db.resources) {
var libraryData = db.resources[libraryName];
for (var reso... | javascript | {
"resource": ""
} | |
q59510 | validation | async function(data) {
let t = this;
let result = {};
return new Promise((resolve, reject) => {
async.forEach(data.libraries,
function(path, cb) {
t.__addLibrary(path, result, cb);
},
function(err) {
if (err) {
reject(err);
... | javascript | {
"resource": ""
} | |
q59511 | validation | function(rootDir, result, cb) {
var lib = new qx.tool.compiler.app.Library();
lib.loadManifest(rootDir, function(err) {
if (!err) {
let s = lib.getNamespace();
let libs = s.split(".");
result[libs[0]] = false;
}
return cb && cb(err, lib);
});
} | javascript | {
"resource": ""
} | |
q59512 | validation | function(str) {
if (str === null) {
return null;
}
str = str.trim();
if (!str) {
return null;
}
var ast = JsonToAst.parseToAst(str);
var json = JsonToAst.astToObject(ast);
return json;
} | javascript | {
"resource": ""
} | |
q59513 | validation | async function(filename) {
if (!await fs.existsAsync(filename)) {
return null;
}
var data = await fs.readFileAsync(filename, "utf8");
try {
return qx.tool.compiler.utils.Json.parseJson(data);
} catch (ex) {
throw new Error("Failed to load " + filename + ": " + ex);
... | javascript | {
"resource": ""
} | |
q59514 | validation | async function(filename, data) {
if (!data) {
if (await fs.existsAsync(filename)) {
fs.unlinkAsync(filename);
}
} else {
await fs.writeFileAsync(filename, JSON.stringify(data, null, 2), "utf8");
}
} | javascript | {
"resource": ""
} | |
q59515 | validation | function(from, to) {
return new Promise((resolve, reject) => {
util.mkParentPath(to, function() {
var rs = fs.createReadStream(from, { flags: "r", encoding: "binary" });
var ws = fs.createWriteStream(to, { flags: "w", encoding: "binary" });
rs.on("end", function() {
... | javascript | {
"resource": ""
} | |
q59516 | validation | function(filename) {
return new Promise((resolve, reject) => {
fs.stat(filename, function(err, stats) {
if (err && err.code != "ENOENT") {
reject(err);
} else {
resolve(err ? null : stats);
}
});
});
} | javascript | {
"resource": ""
} | |
q59517 | validation | function(filename) {
return new Promise((resolve, reject) => {
fs.unlink(filename, function(err) {
if (err && err.code != "ENOENT") {
reject(err);
} else {
resolve();
}
});
});
} | javascript | {
"resource": ""
} | |
q59518 | validation | async function(filename, length) {
if (await this.safeStat(filename) && length > 1) {
var lastFile = null;
for (var i = length; i > 0; i--) {
var tmp = filename + "." + i;
if (i == length) {
await this.safeUnlink(tmp);
} else if (await this.safeStat(tmp)) ... | javascript | {
"resource": ""
} | |
q59519 | validation | function(name) {
return new Promise((resolve, reject) => {
rimraf(name, err => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
} | javascript | {
"resource": ""
} | |
q59520 | validation | function(dir) {
var drivePrefix = "";
if (process.platform === "win32" && dir.match(/^[a-zA-Z]:/)) {
drivePrefix = dir.substring(0, 2);
dir = dir.substring(2);
}
dir = dir.replace(/\\/g, "/");
var segs = dir.split("/");
if (!segs.length) {
return drivePrefix +... | javascript | {
"resource": ""
} | |
q59521 | validation | function(args)
{
var opts;
for (var i=0, l=args.length; i<l; i++) {
if (args[i].indexOf("settings=") == 0) {
opts = args[i].substr(9);
break;
}
else if (args[i].indexOf("'settings=") == 0) {
opts = /'settings\=(.*?)'/.exec(args[i])[1];
brea... | javascript | {
"resource": ""
} | |
q59522 | ScaleColumns | validation | function ScaleColumns(colsByGroup, maxWidth, totalFlexGrow) {
// calculate total width and flexgrow points for coulumns that can be resized
angular.forEach(colsByGroup, (cols) => {
cols.forEach((column) => {
if (!column.canAutoResize){
maxWidth -= column.width;
totalFlexGrow -= column.flex... | javascript | {
"resource": ""
} |
q59523 | GetTotalFlexGrow | validation | function GetTotalFlexGrow(columns){
var totalFlexGrow = 0;
for (let c of columns) {
totalFlexGrow += c.flexGrow || 0;
}
return totalFlexGrow;
} | javascript | {
"resource": ""
} |
q59524 | ForceFillColumnWidths | validation | function ForceFillColumnWidths(allColumns, expectedWidth, startIdx){
var contentWidth = 0,
columnsToResize = startIdx > -1 ?
allColumns.slice(startIdx, allColumns.length).filter((c) => { return c.canAutoResize }) :
allColumns.filter((c) => { return c.canAutoResize });
allColumns.forEach((c) =... | javascript | {
"resource": ""
} |
q59525 | PDU | validation | function PDU() {
this.type = asn1ber.pduTypes.GetRequestPDU;
this.reqid = 1;
this.error = 0;
this.errorIndex = 0;
this.varbinds = [ new VarBind() ];
} | javascript | {
"resource": ""
} |
q59526 | clearRequest | validation | function clearRequest(reqs, reqid) {
var self = this;
var entry = reqs[reqid];
if (entry) {
if (entry.timeout) {
clearTimeout(entry.timeout);
}
delete reqs[reqid];
}
} | javascript | {
"resource": ""
} |
q59527 | parseSingleOid | validation | function parseSingleOid(oid) {
if (typeof oid !== 'string') {
return oid;
}
if (oid[0] !== '.') {
throw new Error('Invalid OID format');
}
oid = oid.split('.')
.filter(function (s) {
return s.length > 0;
})
.map(function (s) {
return ... | javascript | {
"resource": ""
} |
q59528 | parseOids | validation | function parseOids(options) {
if (options.oid) {
options.oid = parseSingleOid(options.oid);
}
if (options.oids) {
options.oids = options.oids.map(parseSingleOid);
}
} | javascript | {
"resource": ""
} |
q59529 | defaults | validation | function defaults(targ, _defs) {
[].slice.call(arguments, 1).forEach(function (def) {
Object.keys(def).forEach(function (key) {
if (!targ.hasOwnProperty(key)) {
targ[key] = def[key];
}
});
});
} | javascript | {
"resource": ""
} |
q59530 | compareOids | validation | function compareOids (oidA, oidB) {
var mlen, i;
// The undefined OID, if there is any, is deemed lesser.
if (typeof oidA === 'undefined' && typeof oidB !== 'undefined') {
return 1;
} else if (typeof oidA !== 'undefined' && typeof oidB === 'undefined') {
return -1;
}
// Check e... | javascript | {
"resource": ""
} |
q59531 | Session | validation | function Session(options) {
var self = this;
self.options = options || {};
defaults(self.options, exports.defaultOptions);
self.reqs = {};
self.socket = dgram.createSocket(self.options.family);
self.socket.on('message', msgReceived.bind(self));
self.socket.on('close', function () {
... | javascript | {
"resource": ""
} |
q59532 | inTree | validation | function inTree(root, oid) {
var i;
if (oid.length <= root.length) {
return false;
}
for (i = 0; i < root.length; i++) {
if (oid[i] !== root[i]) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} |
q59533 | wrapper | validation | function wrapper(type, contents) {
var buf, len, i;
// Get the encoded length of the contents
len = lengthArray(contents.length);
// Set up a buffer with the type and length bytes plus a straight copy of the content.
buf = new Buffer(1 + contents.length + len.length);
buf[0] = type;
for (i... | javascript | {
"resource": ""
} |
q59534 | oidArray | validation | function oidArray(oid) {
var bytes, i, val;
// Enforce some minimum requirements on the OID.
if (oid.length < 2) {
throw new Error("Minimum OID length is two.");
} else if (oid[0] > 2) {
throw new Error("Invalid OID");
} else if (oid[0] == 0 && oid[1] > 39) {
throw new Error... | javascript | {
"resource": ""
} |
q59535 | intArray | validation | function intArray(val) {
var array = [], encVal = val, bytes;
if (val === 0) {
array.push(0);
} else {
if (val < 0) {
bytes = Math.floor(1 + Math.log(-val) / LOG256);
// Encode negatives as 32-bit two's complement. Let's hope that fits.
encVal += Math.pow... | javascript | {
"resource": ""
} |
q59536 | insureFreshToken | validation | function insureFreshToken(conn, cb) {
var rh = conn.requestHeaders;
if (rh && rh.authorization &&
conn.user && rh.authorization.indexOf('Bearer ') === 0) {
var stashedToken = tokenMgmt.currentToken(conn.user, conn.loginBaseUrl, conn.mgmtServer);
if (tokenMgmt.isInvalidOrExpired(stashedToken)... | javascript | {
"resource": ""
} |
q59537 | validation | function (arg) {
var value = arg.value;
var flag = arg.flag;
var result = null;
if (value) {
value = Array.isArray(value) ? value : [value];
result = [];
value.forEach(function (path) {
... | javascript | {
"resource": ""
} | |
q59538 | scaleSankeySize | validation | function scaleSankeySize(graph, margin) {
var maxColumn = max(graph.nodes, function (node) {
return node.column;
});
var currentWidth = x1 - x0;
var currentHeight = y1 - y0;
var newWidth = currentWidth + margin.right + margin.left;
var newHeight = currentHeight + margin.top + margin.bot... | javascript | {
"resource": ""
} |
q59539 | computeNodeDepths | validation | function computeNodeDepths(graph) {
var nodes, next, x;
for (nodes = graph.nodes, next = [], x = 0; nodes.length; ++x, nodes = next, next = []) {
nodes.forEach(function (node) {
node.depth = x;
node.sourceLinks.forEach(function (link) {
if (next.indexOf(link.target) < 0 && !link... | javascript | {
"resource": ""
} |
q59540 | sortLinkColumnAscending | validation | function sortLinkColumnAscending(link1, link2) {
if (linkColumnDistance(link1) == linkColumnDistance(link2)) {
return link1.circularLinkType == 'bottom' ? sortLinkSourceYDescending(link1, link2) : sortLinkSourceYAscending(link1, link2);
} else {
return linkColumnDistance(link2) - linkColumnDistance(link1);
... | javascript | {
"resource": ""
} |
q59541 | selfLinking | validation | function selfLinking(link, id) {
return getNodeID(link.source, id) == getNodeID(link.target, id);
} | javascript | {
"resource": ""
} |
q59542 | find | validation | function find (nodeById, id) {
var node = nodeById.get(id)
if (!node) throw new Error('missing: ' + id)
return node
} | javascript | {
"resource": ""
} |
q59543 | computeNodeLinks | validation | function computeNodeLinks (graph) {
graph.nodes.forEach(function (node, i) {
node.index = i
node.sourceLinks = []
node.targetLinks = []
})
var nodeById = map(graph.nodes, id)
graph.links.forEach(function (link, i) {
link.index = i
var source = link.source
... | javascript | {
"resource": ""
} |
q59544 | linkAngle | validation | function linkAngle (link) {
var adjacent = Math.abs(link.y1 - link.y0)
var opposite = Math.abs(link.target.x0 - link.source.x1)
return Math.atan(opposite / adjacent)
} | javascript | {
"resource": ""
} |
q59545 | circularLinksCross | validation | function circularLinksCross (link1, link2) {
if (link1.source.column < link2.target.column) {
return false
} else if (link1.target.column > link2.source.column) {
return false
} else {
return true
}
} | javascript | {
"resource": ""
} |
q59546 | numberOfNonSelfLinkingCycles | validation | function numberOfNonSelfLinkingCycles (node, id) {
var sourceCount = 0
node.sourceLinks.forEach(function (l) {
sourceCount = l.circular && !selfLinking(l, id)
? sourceCount + 1
: sourceCount
})
var targetCount = 0
node.targetLinks.forEach(function (l) {
targetCount = l.c... | javascript | {
"resource": ""
} |
q59547 | onlyCircularLink | validation | function onlyCircularLink (link) {
var nodeSourceLinks = link.source.sourceLinks
var sourceCount = 0
nodeSourceLinks.forEach(function (l) {
sourceCount = l.circular ? sourceCount + 1 : sourceCount
})
var nodeTargetLinks = link.target.targetLinks
var targetCount = 0
nodeTargetLinks.for... | javascript | {
"resource": ""
} |
q59548 | nodesOverlap | validation | function nodesOverlap (nodeA, nodeB) {
// test if nodeA top partially overlaps nodeB
if (nodeA.y0 > nodeB.y0 && nodeA.y0 < nodeB.y1) {
return true
} else if (nodeA.y1 > nodeB.y0 && nodeA.y1 < nodeB.y1) {
// test if nodeA bottom partially overlaps nodeB
return true
} else if (nodeA.y0 <... | javascript | {
"resource": ""
} |
q59549 | validation | function (options, callback) {
if (!('headers' in options)) {
options.headers = {};
}
options.json = true;
options.headers['User-Agent'] = Poloniex.USER_AGENT;
options.strictSSL = Poloniex.STRICT_SSL;
options.timeout = Poloniex.TIMEOUT;
return new Promise(function (re... | javascript | {
"resource": ""
} | |
q59550 | validation | function (command, parameters, callback) {
if (typeof parameters === 'function') {
callback = parameters;
parameters = {};
}
parameters || (parameters = {});
parameters.command = command;
const options = {
method: 'GET',
url: PUBLIC_API_URL,
... | javascript | {
"resource": ""
} | |
q59551 | validation | function (command, parameters, callback) {
if (typeof parameters === 'function') {
callback = parameters;
parameters = {};
}
parameters || (parameters = {});
parameters.command = command;
parameters.nonce = nonce();
const options = {
method: 'POST',
... | javascript | {
"resource": ""
} | |
q59552 | spawnChildProcess | validation | function spawnChildProcess(bin, args, option) {
const result = spawnCancelableChild(bin, args, option);
return result.process;
} | javascript | {
"resource": ""
} |
q59553 | spawnCancelableChild | validation | function spawnCancelableChild(bin, args, option) {
let innerCancel = null;
let isCanceled = false;
const canceller = function () {
if (isCanceled) {
return;
}
isCanceled = true;
if (typeof innerCancel === 'function') {
innerCancel();
}
};
... | javascript | {
"resource": ""
} |
q59554 | CasStrategy | validation | function CasStrategy(options, verify) {
if (typeof options == 'function') {
verify = options;
options = undefined;
}
options = options || {};
if (!verify) { throw new TypeError('CasStrategy requires a verify callback'); }
if (!options.casURL) { throw new TypeError('CasStrategy requires a casURL o... | javascript | {
"resource": ""
} |
q59555 | PgtServer | validation | function PgtServer(casURL, pgtURL, serverCertificate, serverKey, serverCA) {
var parsedURL = url.parse(pgtURL);
var cas = new CAS({
base_url: casURL,
version: 2.0,
pgt_server: true,
pgt_host: parsedURL.hostname,
pgt_port: parsedURL.port,
ssl_key: serverKey,
ssl_cert: serverCertificate,
... | javascript | {
"resource": ""
} |
q59556 | validation | function(element, link) {
// Normalize the link parameter
if(angular.isFunction(link)) {
link = { post: link };
}
var compiledContents;
return {
pre: (link && link.pre) ? link.pre : null,
/**
* Compiles and re-adds the contents
*/
... | javascript | {
"resource": ""
} | |
q59557 | validation | function(scope, element, attrs, trvw) {
// Compile our template
if(!compiledContents) {
compiledContents = $compile(trvw.getNodeTpl());
}
// Add the compiled template
compiledContents(scope, function(clone) {
element.append(clone);
... | javascript | {
"resource": ""
} | |
q59558 | validation | function(baseDir, importPath) {
var parts = importPath.split('/');
var pathname = path.join(baseDir, importPath);
if (parts[0] === 'node_modules') {
// Gets all but the first element of array (i.e. node_modules).
importPath = parts.slice(1).join('/');
}
// Returns an array of all p... | javascript | {
"resource": ""
} | |
q59559 | validation | function (options, callback) {
if (_.isFunction(options) && !callback) {
callback = options;
options = {};
}
options = _.clone(options);
bootcode(function (err, code) {
if (err) { return callback(err); }
if (!code) { return callback(new Er... | javascript | {
"resource": ""
} | |
q59560 | extend | validation | function extend(klass, instance, override, methods) {
var extendee = instance ? klass.prototype : klass;
initializeClass(klass);
iterateOverObject(methods, function(name, method) {
var original = extendee[name];
var existed = hasOwnProperty(extendee, name);
if(typeof override === 'functio... | javascript | {
"resource": ""
} |
q59561 | buildObjectInstanceMethods | validation | function buildObjectInstanceMethods(set, target) {
extendSimilar(target, true, false, set, function(methods, name) {
methods[name + (name === 'equal' ? 's' : '')] = function() {
return object[name].apply(null, [this].concat(multiArgs(arguments)));
}
});
} | javascript | {
"resource": ""
} |
q59562 | arrayEach | validation | function arrayEach(arr, fn, startIndex, loop) {
var length, index, i;
if(startIndex < 0) startIndex = arr.length + startIndex;
i = isNaN(startIndex) ? 0 : startIndex;
length = loop === true ? arr.length + i : arr.length;
while(i < length) {
index = i % arr.length;
if(!(index in arr)) {
... | javascript | {
"resource": ""
} |
q59563 | collateStrings | validation | function collateStrings(a, b) {
var aValue, bValue, aChar, bChar, aEquiv, bEquiv, index = 0, tiebreaker = 0;
a = getCollationReadyString(a);
b = getCollationReadyString(b);
do {
aChar = getCollationCharacter(a, index);
bChar = getCollationCharacter(b, index);
aValue = getCollationVal... | javascript | {
"resource": ""
} |
q59564 | collectDateArguments | validation | function collectDateArguments(args, allowDuration) {
var obj, arr;
if(isObject(args[0])) {
return args;
} else if (isNumber(args[0]) && !isNumber(args[1])) {
return [args[0]];
} else if (isString(args[0]) && allowDuration) {
return [getDateParamsFromString(args[0]), args[1]];
}
... | javascript | {
"resource": ""
} |
q59565 | getFormatMatch | validation | function getFormatMatch(match, arr) {
var obj = {}, value, num;
arr.forEach(function(key, i) {
value = match[i + 1];
if(isUndefined(value) || value === '') return;
if(key === 'year') {
obj.yearAsString = value.replace(/'/, '');
}
num = parseFloat(value.replace(/'/, '').repl... | javascript | {
"resource": ""
} |
q59566 | getWeekNumber | validation | function getWeekNumber(date) {
date = date.clone();
var dow = callDateGet(date, 'Day') || 7;
date.addDays(4 - dow).reset();
return 1 + floor(date.daysSince(date.clone().beginningOfYear()) / 7);
} | javascript | {
"resource": ""
} |
q59567 | formatDate | validation | function formatDate(date, format, relative, localeCode) {
var adu, loc = getLocalization(localeCode), caps = regexp(/^[A-Z]/), value, shortcut;
if(!date.isValid()) {
return 'Invalid Date';
} else if(Date[format]) {
format = Date[format];
} else if(isFunction(format)) {
adu = getAdjuste... | javascript | {
"resource": ""
} |
q59568 | compareDate | validation | function compareDate(d, find, buffer, forceUTC) {
var p, t, min, max, minOffset, maxOffset, override, capitalized, accuracy = 0, loBuffer = 0, hiBuffer = 0;
p = getExtendedDate(find, null, null, forceUTC);
if(buffer > 0) {
loBuffer = hiBuffer = buffer;
override = true;
}
if(!p.date.isVal... | javascript | {
"resource": ""
} |
q59569 | validation | function (done) {
var dependencies = [],
addPackageToDependencies = function (pkg) {
dependencies.push(pkg.name);
};
this.bundler.on('package', addPackageToDependencies);
return this.compile(function (err) {
this.bundler.removeListener('packa... | javascript | {
"resource": ""
} | |
q59570 | Foscam | validation | function Foscam(config) {
if (!config) {
throw new Error('no config was supplied');
}
this.username = config.username;
this.password = config.password;
this.address = config.host;
this.port = config.port || 88;
this.protocol = config.protocol || 'http';
this.rejectUnauthorizedCe... | javascript | {
"resource": ""
} |
q59571 | put | validation | function put(point, data, octree, octant, depth) {
let children = octant.children;
let exists = false;
let done = false;
let i, l;
if(octant.contains(point, octree.bias)) {
if(children === null) {
if(octant.points === null) {
octant.points = [];
octant.data = [];
} else {
for(i = 0, l = ... | javascript | {
"resource": ""
} |
q59572 | fetch | validation | function fetch(point, octree, octant) {
const children = octant.children;
let result = null;
let i, l;
let points;
if(octant.contains(point, octree.bias)) {
if(children !== null) {
for(i = 0, l = children.length; result === null && i < l; ++i) {
result = fetch(point, octree, children[i]);
}
... | javascript | {
"resource": ""
} |
q59573 | move | validation | function move(point, position, octree, octant, parent, depth) {
const children = octant.children;
let result = null;
let i, l;
let points;
if(octant.contains(point, octree.bias)) {
if(octant.contains(position, octree.bias)) {
// The point and the new position both fall into the current octant.
if(chi... | javascript | {
"resource": ""
} |
q59574 | findPoints | validation | function findPoints(point, radius, skipSelf, octant, result) {
const children = octant.children;
let i, l;
if(children !== null) {
let child;
for(i = 0, l = children.length; i < l; ++i) {
child = children[i];
if(child.contains(point, radius)) {
findPoints(point, radius, skipSelf, child, result)... | javascript | {
"resource": ""
} |
q59575 | cull | validation | function cull(octant, region, result) {
const children = octant.children;
let i, l;
b.min = octant.min;
b.max = octant.max;
if(region.intersectsBox(b)) {
if(children !== null) {
for(i = 0, l = children.length; i < l; ++i) {
cull(children[i], region, result);
}
} else {
result.push(octant... | javascript | {
"resource": ""
} |
q59576 | findOctantsByLevel | validation | function findOctantsByLevel(octant, level, depth, result) {
const children = octant.children;
let i, l;
if(depth === level) {
result.push(octant);
} else if(children !== null) {
++depth;
for(i = 0, l = children.length; i < l; ++i) {
findOctantsByLevel(children[i], level, depth, result);
}
}
} | javascript | {
"resource": ""
} |
q59577 | findEntryOctant | validation | function findEntryOctant(tx0, ty0, tz0, txm, tym, tzm) {
let entry = 0;
// Find the entry plane.
if(tx0 > ty0 && tx0 > tz0) {
// YZ-plane.
if(tym < tx0) {
entry |= 2;
}
if(tzm < tx0) {
entry |= 1;
}
} else if(ty0 > tz0) {
// XZ-plane.
if(txm < ty0) {
entry |= 4;
}
if(tzm < ty... | javascript | {
"resource": ""
} |
q59578 | findNextOctant | validation | function findNextOctant(currentOctant, tx1, ty1, tz1) {
let min;
let exit = 0;
// Find the exit plane.
if(tx1 < ty1) {
min = tx1;
exit = 0; // YZ-plane.
} else {
min = ty1;
exit = 1; // XZ-plane.
}
if(tz1 < min) {
exit = 2; // XY-plane.
}
return octantTable[currentOctant][exit];
} | javascript | {
"resource": ""
} |
q59579 | raycastOctant | validation | function raycastOctant(octant, tx0, ty0, tz0, tx1, ty1, tz1, raycaster, intersects) {
const children = octant.children;
let currentOctant;
let txm, tym, tzm;
if(tx1 >= 0.0 && ty1 >= 0.0 && tz1 >= 0.0) {
if(children === null) {
// Leaf.
intersects.push(octant);
} else {
// Compute means.
txm =... | javascript | {
"resource": ""
} |
q59580 | deferred | validation | function deferred(options) {
let args = null;
const promise = new Promise((resolve, reject) => args = [resolve, reject, options]);
promise.defer = function defer() {
if (!args) throw new Error('defer has already been called');
const callback = callbackBuilder.apply(undefined, args);
args = null;
r... | javascript | {
"resource": ""
} |
q59581 | withTimeout | validation | function withTimeout(promise, delay, message) {
let timeout;
const timeoutPromise = new Promise((resolve, reject) => {
// Instantiate the error here to capture a more useful stack trace.
const error = message instanceof Error ? message : new Error(message || 'Operation timed out.');
timeout = setTimeout... | javascript | {
"resource": ""
} |
q59582 | waitOn | validation | function waitOn(emitter, event, waitError) {
if (waitError) {
return new Promise((resolve, reject) => {
function unbind() {
emitter.removeListener('error', onError);
emitter.removeListener(event, onEvent);
}
function onEvent(value) {
unbind();
resolve(value);
... | javascript | {
"resource": ""
} |
q59583 | promisify | validation | function promisify(orig, options) {
if (typeof orig !== 'function') {
throw new TypeError('promisify requires a function');
}
if (orig[kCustomPromisifiedSymbol]) {
const fn = orig[kCustomPromisifiedSymbol];
if (typeof fn !== 'function') {
throw new TypeError('The [util.promisify.custom] propert... | javascript | {
"resource": ""
} |
q59584 | promisifyMethod | validation | function promisifyMethod(obj, methodName, options) {
if (!obj) {
// This object could be anything, including a function, a real object, or an array.
throw new TypeError('promisify.method requires a truthy value');
}
return promisify(obj[methodName].bind(obj), options);
} | javascript | {
"resource": ""
} |
q59585 | promisifyMethods | validation | function promisifyMethods(obj, methodNames, options) {
if (!obj) {
// This object could be anything, including a function, a real object, or an array.
throw new TypeError('promisify.methods requires a truthy value');
}
const out = {};
for (let methodName of methodNames) {
out[methodName] = promisi... | javascript | {
"resource": ""
} |
q59586 | promisifyAll | validation | function promisifyAll(obj, options) {
if (!obj) {
// This object could be anything, including a function, a real object, or an array.
throw new TypeError('promisify.all requires a truthy value');
}
const out = {};
for (var name in obj) {
if (typeof obj[name] === 'function') {
out[name] = pro... | javascript | {
"resource": ""
} |
q59587 | unpatchPromise | validation | function unpatchPromise() {
for (let method of methods) {
if (Promise.prototype[method.name] === method) {
delete Promise.prototype[method.name];
}
}
} | javascript | {
"resource": ""
} |
q59588 | asCheckedCallback | validation | function asCheckedCallback(promise, cb, useOwnMethod) {
let called = false;
if (useOwnMethod) {
promise.asCallback(after);
} else {
asCallback(promise, after);
}
function after() {
expect(called).toBeFalsy();
called = true;
return cb.apply(this, arguments);
}
} | javascript | {
"resource": ""
} |
q59589 | asCallback | validation | function asCallback(promise, cb) {
promise.then((res) => cb(null, res), cb);
} | javascript | {
"resource": ""
} |
q59590 | sum | validation | function sum(arr, prop){
return arr.reduce(function(sum, obj){
return sum + obj.stats[prop];
}, 0);
} | javascript | {
"resource": ""
} |
q59591 | traverse | validation | function traverse(file) {
file = master.resolve(file);
fs.stat(file, function(err, stat){
if (!err) {
if (stat.isDirectory()) {
if (~exports.ignoreDirectories.indexOf(basename(file))) return;
fs.readdir(file, function(err, files){
files.map(function(f)... | javascript | {
"resource": ""
} |
q59592 | watch | validation | function watch(file) {
if (!~extensions.indexOf(extname(file))) return;
fs.watchFile(file, { interval: interval }, function(curr, prev){
if (curr.mtime > prev.mtime) {
console.log(' \033[36mchanged\033[0m \033[90m- %s\033[0m', file);
master.restartWorkers(signal);
}
... | javascript | {
"resource": ""
} |
q59593 | installWatcher | validation | function installWatcher (startingFolder, callback) {
bs.init({
server: config.commands.build.output,
port: config.commands.build.port,
ui: false,
open: false,
logLevel: 'silent'
})
const watcher = createWatcher(path.join(startingFolder, '**/data.xml'))
watcher.on('change', () => {
call... | javascript | {
"resource": ""
} |
q59594 | installDevelopmentWatcher | validation | function installDevelopmentWatcher (startingFolder, callback) {
const buildFolder = config.commands.build.output
// BrowserSync will watch for changes in the assets CSS.
// It will also create a server with the build folder and the assets.
bs.init({
server: [buildFolder, assets],
port: config.commands.... | javascript | {
"resource": ""
} |
q59595 | findAllFiles | validation | function findAllFiles (baseDir, {
ignoredFolders = [],
maxDepth = undefined
} = {}) {
let list = []
function search (dir, depth) {
fs.readdirSync(dir).forEach(file => {
file = path.join(dir, file)
// File or directory? Ok.
// Otherwise, discard the file.
let stat = fs.statSync(file... | javascript | {
"resource": ""
} |
q59596 | getElementHeight | validation | function getElementHeight (element) {
var clone = element.cloneNode(true)
clone.style.cssText = 'visibility: hidden; display: block; margin: -999px 0'
var height = (element.parentNode.appendChild(clone)).clientHeight
element.parentNode.removeChild(clone)
return height
} | javascript | {
"resource": ""
} |
q59597 | getAbsolutePageUrl | validation | function getAbsolutePageUrl (dataFilePath, pageType) {
const buildFolder = createAndGetBuildFolder()
const pageFolder = getPageFolder(buildFolder, dataFilePath, pageType)
const htmlFilePath = getHtmlFilePath(pageFolder)
const relativePath = path.posix.relative(buildFolder, htmlFilePath)
return path.posix.jo... | javascript | {
"resource": ""
} |
q59598 | createThumbnails | validation | async function createThumbnails (target, images) {
for (const x of images) {
const imagePath = path.join(target, x)
const thumbPath = path.join(target, `${x}.thumb.jpg`)
try {
// Background and flatten are for transparent PNGs/Gifs.
// We force a white background here.
await sharp(imag... | javascript | {
"resource": ""
} |
q59599 | createTemplate | validation | function createTemplate (type, destination) {
const templatePath = getTemplatePath(assets, type)
if (!templatePath) {
throw new Error('Missing template! Make sure your presskit has a "type" field (product/company)')
}
registerPartials(assets)
registerHelpers(destination)
const template = fs.readFileS... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.