_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q24600 | RenderingGroup | train | function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
if (transparentSortCompareFn ==... | javascript | {
"resource": ""
} |
q24601 | UniformBuffer | train | function UniformBuffer(engine, data, dynamic) {
this._engine = engine;
this._noUBO = !engine.supportsUniformBuffers;
this._dynamic = dynamic;
this._data = data || [];
this._uniformLocations = {};
this._uniformSizes = {};
this._uniformLo... | javascript | {
"resource": ""
} |
q24602 | ColorGradingTexture | train | function ColorGradingTexture(url, scene) {
var _this = _super.call(this, scene) || this;
if (!url) {
return _this;
}
_this._textureMatrix = BABYLON.Matrix.Identity();
_this.name = url;
_this.url = url;
_this.hasAlpha = f... | javascript | {
"resource": ""
} |
q24603 | train | function (value) {
if (this._transparencyMode === value) {
return;
}
this._transparencyMode = value;
if (value === BABYLON.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND) {
this._forceAlphaTest = t... | javascript | {
"resource": ""
} | |
q24604 | PBRMetallicRoughnessMaterial | train | function PBRMetallicRoughnessMaterial(name, scene) {
var _this = _super.call(this, name, scene) || this;
_this._useRoughnessFromMetallicTextureAlpha = false;
_this._useRoughnessFromMetallicTextureGreen = true;
_this._useMetallnessFromMetallicTextureBlue = true;
... | javascript | {
"resource": ""
} |
q24605 | PBRSpecularGlossinessMaterial | train | function PBRSpecularGlossinessMaterial(name, scene) {
var _this = _super.call(this, name, scene) || this;
_this._useMicroSurfaceFromReflectivityMapAlpha = true;
return _this;
} | javascript | {
"resource": ""
} |
q24606 | train | function (value) {
var previousNeedCube = this.needCube();
this._direction = value;
if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
this._shadowGenerator.recreateShadowMap();
}
} | javascript | {
"resource": ""
} | |
q24607 | train | function () {
for (var index = 0; index < this.actions.length; index++) {
var action = this.actions[index];
if (action.trigger >= ActionManager._OnPickTrigger && action.trigger <= ActionManager._OnPointerOutTrigger) {
return true;
... | javascript | {
"resource": ""
} | |
q24608 | train | function () {
for (var t in ActionManager.Triggers) {
if (ActionManager.Triggers.hasOwnProperty(t)) {
var t_int = parseInt(t);
if (t_int >= ActionManager._OnPickTrigger && t_int <= ActionManager._OnPickUpTrigger) {
... | javascript | {
"resource": ""
} | |
q24609 | train | function (name, params) {
var newInstance = Object.create(BABYLON.Tools.Instantiate("BABYLON." + name).prototype);
newInstance.constructor.apply(newInstance, params);
return newInstance;
} | javascript | {
"resource": ""
} | |
q24610 | train | function (value) {
if (this._intersectionThreshold === value) {
return;
}
this._intersectionThreshold = value;
if (this.geometry) {
this.geometry.boundingBias = new BABYLON.Vector2(0, value);
}
... | javascript | {
"resource": ""
} | |
q24611 | getChildByName | train | function getChildByName(node, name) {
return node.getChildMeshes(false, function (n) { return n.name === name; })[0];
} | javascript | {
"resource": ""
} |
q24612 | getImmediateChildByName | train | function getImmediateChildByName(node, name) {
return node.getChildMeshes(true, function (n) { return n.name == name; })[0];
} | javascript | {
"resource": ""
} |
q24613 | train | function (subMesh) {
var mesh = subMesh.getRenderingMesh();
if (_this._meshExcluded(mesh)) {
return;
}
var scene = mesh.getScene();
var engine = scene.getEngine();
// Culling
engine.setSta... | javascript | {
"resource": ""
} | |
q24614 | train | function (v) {
if (this._idealKernel === v) {
return;
}
v = Math.max(v, 1);
this._idealKernel = v;
this._kernel = this._nearestBestKernel(v);
this._updateParameters();
} | javascript | {
"resource": ""
} | |
q24615 | HDRCubeTexture | train | function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator, onLoad, onError) {
if (noMipmap === void 0) { noMipmap = false; }
if (generateHarmonics === void 0) { generateHarmonics = true; }
if (useInGammaSpace === void 0) { useInGammaSpa... | javascript | {
"resource": ""
} |
q24616 | zOrder | train | function zOrder(x, y, minX, minY, size) {
// coords are transformed into non-negative 15-bit integer range
x = 32767 * (x - minX) / size;
y = 32767 * (y - minY) / size;
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
x = (x | (x << 2)) & 0x33333333;
... | javascript | {
"resource": ""
} |
q24617 | DynamicFloatArray | train | function DynamicFloatArray(stride, initialElementCount) {
this.compareValueOffset = null;
this.sortingAscending = true;
this._stride = stride;
this.buffer = new Float32Array(stride * initialElementCount);
this._lastUsed = 0;
this._firstFree = 0;
... | javascript | {
"resource": ""
} |
q24618 | EdgesRenderer | train | function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
if (epsilon === void 0) { epsilon = 0.95; }
if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
this.edgesWidthScalerForOrthographic = 1000.0;
this.edgesWidthScal... | javascript | {
"resource": ""
} |
q24619 | HighlightLayer | train | function HighlightLayer(name, scene, options) {
this.name = name;
this._vertexBuffers = {};
this._mainTextureDesiredSize = { width: 0, height: 0 };
this._meshes = {};
this._maxSize = 0;
this._shouldRender = false;
this._instanceGlowingM... | javascript | {
"resource": ""
} |
q24620 | RectPackingMap | train | function RectPackingMap(size, margin) {
if (margin === void 0) { margin = 0; }
var _this = _super.call(this, null, null, BABYLON.Vector2.Zero(), size) || this;
_this._margin = margin;
_this._root = _this;
return _this;
} | javascript | {
"resource": ""
} |
q24621 | train | function () {
return this._attachedCamera.inertialAlphaOffset !== 0 ||
this._attachedCamera.inertialBetaOffset !== 0 ||
this._attachedCamera.inertialRadiusOffset !== 0 ||
this._attachedCamera.inertialPanningX !== 0 ||
this._... | javascript | {
"resource": ""
} | |
q24622 | train | function (value) {
var _this = this;
if (this._autoTransitionRange === value) {
return;
}
this._autoTransitionRange = value;
var camera = this._attachedCamera;
if (value) {
this._onMes... | javascript | {
"resource": ""
} | |
q24623 | drawScene | train | function drawScene() {
// Clear the canvas before we start drawing on it.
gl.clearColor(0, 0, 0, 1);
gl.clearDepth(1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Establish the perspective with which we want to view the
// scene. Our field of view is 45 degrees, with a width/height
// ratio... | javascript | {
"resource": ""
} |
q24624 | initShaders | train | function initShaders() {
var fragmentShader = getShader(gl, fragmentShaderSource, false);
var vertexShader = getShader(gl, vertexShaderSource, true);
// Create the shader program
shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertexShader);
gl.attachShader(shaderProgram, fragmentShader... | javascript | {
"resource": ""
} |
q24625 | createHttpTaskWithToken | train | async function createHttpTaskWithToken(
project,
location,
queue,
url,
email,
payload,
inSeconds
) {
// [START cloud_tasks_create_http_task_with_token]
// Imports the Google Cloud Tasks library.
const {v2beta3} = require('@google-cloud/tasks');
// Instantiates a client.
const client = new v2bet... | javascript | {
"resource": ""
} |
q24626 | createQueue | train | async function createQueue(
project = 'my-project-id', // Your GCP Project id
queue = 'my-appengine-queue', // Name of the Queue to create
location = 'us-central1' // The GCP region in which to create the queue
) {
// Imports the Google Cloud Tasks library.
const cloudTasks = require('@google-cloud/tasks');
... | javascript | {
"resource": ""
} |
q24627 | deleteQueue | train | async function deleteQueue(
project = 'my-project-id', // Your GCP Project id
queue = 'my-appengine-queue', // Name of the Queue to delete
location = 'us-central1' // The GCP region in which to delete the queue
) {
// Imports the Google Cloud Tasks library.
const cloudTasks = require('@google-cloud/tasks');
... | javascript | {
"resource": ""
} |
q24628 | getColspanNum | train | function getColspanNum(data = [], num = 1) {
let childs = [];
for (let i = 0; i < data.length; i += 1) {
if (data[i].children) {
childs = childs.concat(data[i].children);
}
}
if (childs && childs.length > 0) {
num = getColspanNum(childs, num + 1);
}
return num;
} | javascript | {
"resource": ""
} |
q24629 | getRowspanNum | train | function getRowspanNum(data = [], child = []) {
let childs = [];
for (let i = 0; i < data.length; i += 1) {
if (!data[i].children) {
childs.push(data[i]);
} else if (data[i].children && data[i].children.length > 0) {
childs = childs.concat(getRowspanNum(data[i].children, child));
}
}
ret... | javascript | {
"resource": ""
} |
q24630 | getSectionName | train | function getSectionName(article) {
const { tiles } = article;
if (!tiles) {
return null;
}
const slices = tiles.reduce((acc, tile) => {
acc.push(...tile.slices);
return acc;
}, []);
const sections = slices.reduce((acc, slice) => {
acc.push(...slice.sections);
return acc;
}, []);
co... | javascript | {
"resource": ""
} |
q24631 | str_serialize | train | function str_serialize(result, key, value) {
// encode newlines as \r\n cause the html spec says so
value = value.replace(/(\r)?\n/g, '\r\n');
value = encodeURIComponent(value);
// spaces should be '+' rather than '%20'.
value = value.replace(/%20/g, '+');
return result + (result ? '&' : '') + encodeURICom... | javascript | {
"resource": ""
} |
q24632 | sendBeacon | train | function sendBeacon(url, callback){
var self = this,
img = document.createElement('img'),
loaded = false;
img.onload = function() {
loaded = true;
if ('naturalHeight' in this) {
if (this.naturalHeight + this.naturalWidth === 0) {
this.onerror();
return;
}
} else ... | javascript | {
"resource": ""
} |
q24633 | mapNode | train | function mapNode(visitor) {
const nodeMapper = node => {
if (node == null) {
return node;
}
const mappingFunction = (() => {
if ('*' in visitor && typeof visitor['*'] === 'function') {
return visitor['*'];
}
if (node.Type in visitor && typeof visitor[node.Type] === 'funct... | javascript | {
"resource": ""
} |
q24634 | makeLexer | train | function makeLexer() {
const mooLexer = moo.compile(tokens);
return {
current: null,
lines: [],
get line() {
return mooLexer.line;
},
get col() {
return mooLexer.col;
},
save() {
return mooLexer.save();
},
reset(chunk, info) {
this.lines = chunk.split('\n... | javascript | {
"resource": ""
} |
q24635 | parseImports | train | function parseImports(ast, compiler) {
const imports = {};
let hasMemory = false;
compiler.walkNode({
Import(node, _) {
// Import nodes consist of field and a string literal node
const [fields, module] = node.params;
if (imports[module.value] == null) {
imports[module.value] = [];
... | javascript | {
"resource": ""
} |
q24636 | buildTree | train | function buildTree(index, api) {
const modules = {};
const dependency = (module, parent) => {
const filepath = api.resolve(module, parent);
if (modules[filepath] != null) {
return modules[filepath];
}
const src = api.getFileContents(module, parent, "utf8");
const basic = api.parser(src);... | javascript | {
"resource": ""
} |
q24637 | build | train | function build(importsObj, tree) {
const modules = {};
const instantiate = filepath => {
if (modules[filepath] != null) {
return modules[filepath];
}
const mod = tree.modules[filepath];
const promise = Promise.all(
Object.entries(mod.deps).map(([key, dep]) => {
return instantia... | javascript | {
"resource": ""
} |
q24638 | _getHost | train | function _getHost (fauxton_ip) {
if (fauxton_ip) {
return fauxton_ip;
}
//making some assumptions here
const interfaces = os.networkInterfaces();
const eth0 = interfaces[Object.keys(interfaces)[1]];
return eth0.find(function (item) {
return item.family === 'IPv4';
}).address;
} | javascript | {
"resource": ""
} |
q24639 | train | function (options) {
options = Object.assign({
msg: 'Notification Event Triggered!',
type: 'info',
escape: true,
clear: false
}, options);
if (FauxtonAPI.reduxDispatch) {
FauxtonAPI.reduxDispatch({
type: 'ADD_NOTIFICATION',
options: {
info: options
... | javascript | {
"resource": ""
} | |
q24640 | train | function (carousel) {
/**
* Reference to the core.
* @protected
* @type {Owl}
*/
this.owl = carousel;
/**
* All DOM elements for thumbnails
* @protected
* @type {Object}
*/
this._thumbcontent = [];
/**
... | javascript | {
"resource": ""
} | |
q24641 | showWarning | train | function showWarning() {
var method = showWarning.caller.name;
if (!configurations.areTestsRunnning()) {
console.warn('This method (' + method + ') is deprecated and its going to be removed on next versions');
}
} | javascript | {
"resource": ""
} |
q24642 | sandboxMode | train | function sandboxMode(enabled) {
showWarning();
configurations.sandbox = (enabled !== undefined) ? (enabled === true) : configurations.sandbox;
} | javascript | {
"resource": ""
} |
q24643 | getAccessToken | train | function getAccessToken() {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return requestManager.generateAccessToken(callback);
} | javascript | {
"resource": ""
} |
q24644 | createPreference | train | function createPreference(preferences) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preferencesModule.create(preferences, callback);
} | javascript | {
"resource": ""
} |
q24645 | getPreference | train | function getPreference(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preferencesModule.get(id, callback);
} | javascript | {
"resource": ""
} |
q24646 | createPreapprovalPayment | train | function createPreapprovalPayment(preapproval) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.create(preapproval, callback);
} | javascript | {
"resource": ""
} |
q24647 | getPreapprovalPayment | train | function getPreapprovalPayment(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.get(id, callback);
} | javascript | {
"resource": ""
} |
q24648 | cancelPreapprovalPayment | train | function cancelPreapprovalPayment(id) {
var callback = preConditions.getCallback(arguments[arguments.length - 1]);
showWarning();
return preapprovalModule.update({
id: id,
status: 'cancelled'
}, callback);
} | javascript | {
"resource": ""
} |
q24649 | train | function (resolve, reject, callback) {
callback = preConditions.getCallback(callback);
return requestManager.generateAccessToken().then(function () {
return requestManager.exec(execOptions);
}).then(function (response) {
resolve(response);
return callback.apply(null, [null, response]);
}).catch(fun... | javascript | {
"resource": ""
} | |
q24650 | setCSS | train | function setCSS(el, properties) {
var key;
for (key in properties) {
if (properties.hasOwnProperty(key)) {
el.style[key] = properties[key];
}
}
} | javascript | {
"resource": ""
} |
q24651 | bulkUpdateCSS | train | function bulkUpdateCSS(data, callback) {
executeNextFrame(function () {
var i, item;
for (i = 0; i < data.length; i++) {
item = data[i];
setCSS(item.el, item.css);
}
// Run optional callback
if (typeof callback === 'function') {
executeNextFrame(callback);
... | javascript | {
"resource": ""
} |
q24652 | getData | train | function getData(el, attr, isInt, prefix) {
if (prefix === undefined) {
prefix = 'wookmark-';
}
var val = el.getAttribute('data-' + prefix + attr);
if (isInt === true) {
return parseInt(val, 10);
}
return val;
} | javascript | {
"resource": ""
} |
q24653 | setData | train | function setData(el, attr, val, prefix) {
if (prefix === undefined) {
prefix = 'wookmark-';
}
el.setAttribute('data-' + prefix + attr, val);
} | javascript | {
"resource": ""
} |
q24654 | removeDuplicates | train | function removeDuplicates(items) {
var temp = {}, result = [], x, i = items.length;
while (i--) {
x = getData(items[i], 'id', true);
if (!temp.hasOwnProperty(x)) {
temp[x] = 1;
result.push(items[i]);
}
}
return result;
} | javascript | {
"resource": ""
} |
q24655 | indexOf | train | function indexOf(items, item) {
var len = items.length, i;
for (i = 0; i < len; i++) {
if (items[i] === item) {
return i;
}
}
return -1;
} | javascript | {
"resource": ""
} |
q24656 | renderCLI | train | function renderCLI ({ url, status, time, size }) {
return logUpdate(boxen(
`${chalk.bgBlue.black(' HEML ')}\n\n` +
`- ${chalk.bold('Preview:')} ${url}\n` +
`- ${chalk.bold('Status:')} ${status}\n` +
`- ${chalk.bold('Compile time:')} ${time}ms\n` +
`- ${chalk.bold('Total size:')... | javascript | {
"resource": ""
} |
q24657 | startDevServer | train | function startDevServer (directory, port = 3000) {
let url
const app = express()
const { reload } = reloadServer(app)
let preview = ''
app.get('/', (req, res) => res.send(preview))
app.use(express.static(directory))
function update ({ html, errors, metadata }) {
let status = errors.length ? chalk.re... | javascript | {
"resource": ""
} |
q24658 | heml | train | async function heml (contents, options = {}) {
const results = {}
const {
beautify: beautifyOptions = {},
validate: validateOption = 'soft'
} = options
options.elements = flattenDeep(toArray(coreElements).concat(options.elements || []))
/** parse it ✂️ */
const $heml = parse(contents, options)
... | javascript | {
"resource": ""
} |
q24659 | replaceElementTagMentions | train | function replaceElementTagMentions (element, selector) {
const processor = selectorParser((selectors) => {
let nodesToReplace = []
/**
* looping breaks if we replace dynamically
* so instead collect an array of nodes to swap and do it at the end
*/
selectors.walk((node) => {
if (node... | javascript | {
"resource": ""
} |
q24660 | replaceElementPseudoMentions | train | function replaceElementPseudoMentions (element, selector) {
const processor = selectorParser((selectors) => {
let nodesToReplace = []
/**
* looping breaks if we replace dynamically
* so instead collect an array of nodes to swap and do it at the end
*/
selectors.each((selector) => {
l... | javascript | {
"resource": ""
} |
q24661 | expandElementRule | train | function expandElementRule (element, selectors = [], originalRule) {
/** early return if we don't have any selectors */
if (selectors.length === 0) return []
let usedProps = []
let expandedRules = []
let defaultRules = []
/** create the base rule */
const baseRule = originalRule.clone()
baseRule.selec... | javascript | {
"resource": ""
} |
q24662 | preRenderElements | train | async function preRenderElements (elements, globals) {
for (let element of elements) {
await element.preRender(globals)
}
} | javascript | {
"resource": ""
} |
q24663 | postRenderElements | train | async function postRenderElements (elements, globals) {
for (let element of elements) {
await element.postRender(globals)
}
} | javascript | {
"resource": ""
} |
q24664 | renderElements | train | async function renderElements (elements, globals) {
const { $ } = globals
const elementMap = keyBy(elements, 'tagName')
const metaTagNames = filter(elements, { parent: [ 'head' ] }).map(({ tagName }) => tagName)
const nonMetaTagNames = difference(elements.map(({ tagName }) => tagName), metaTagNames)
const $n... | javascript | {
"resource": ""
} |
q24665 | findAtDecl | train | function findAtDecl (decls, prop) {
const foundDecls = decls.filter((decl) => {
return (isPlainObject(decl) &&
Object.keys(decl).length > 0 &&
Object.keys(decl)[0] === `@${prop}`) || decl === `@${prop}`
})
if (foundDecls.length === 0) { return }
const decl = foundDecls[0]
return isP... | javascript | {
"resource": ""
} |
q24666 | toRegExp | train | function toRegExp (string) {
if (isString(string) && string.startsWith('/') && string.lastIndexOf('/') !== 0) {
const pattern = string.substr(1, string.lastIndexOf('/') - 1)
const opts = string.substr(string.lastIndexOf('/') + 1).toLowerCase()
return new RegExp(pattern, opts.includes('i') ? opts : `${opt... | javascript | {
"resource": ""
} |
q24667 | targetsTag | train | function targetsTag (selector) {
const selectors = simpleSelectorParser.process(selector).res
return selectors.filter((selector) => {
let selectorNodes = selector.nodes.concat([]).reverse() // clone the array
for (const node of selectorNodes) {
if (node.type === 'cominator') { break }
if (nod... | javascript | {
"resource": ""
} |
q24668 | targetsElementPseudo | train | function targetsElementPseudo (element, selector) {
const selectors = simpleSelectorParser.process(selector).res
return selectors.filter((selector) => {
let selectorNodes = selector.nodes.concat([]).reverse() // clone the array
for (const node of selectorNodes) {
if (node.type === 'cominator') { bre... | javascript | {
"resource": ""
} |
q24669 | appendElementSelector | train | function appendElementSelector (element, selector) {
const processor = selectorParser((selectors) => {
let combinatorNode = null
/**
* looping breaks if we insert dynamically
*/
selectors.each((selector) => {
const elementNode = selectorParser.tag({ value: element.tag })
selector.wa... | javascript | {
"resource": ""
} |
q24670 | inlineMargins | train | function inlineMargins ($) {
$('table[style*=margin]').toNodes().forEach(($el) => {
const { left, right } = getSideMargins($el.attr('style'))
if (left === 'auto' && right === 'auto') {
$el.attr('align', 'center')
} else if (left === 'auto' && right !== 'auto') {
$el.attr('align', 'right')
... | javascript | {
"resource": ""
} |
q24671 | getSideMargins | train | function getSideMargins (style) {
const margins = compact(style.split(';')).map((decl) => {
const split = decl.split(':')
return {
prop: first(split).trim().toLowerCase(),
value: last(split).trim().toLowerCase()
}
}).filter(({ prop, value }) => prop.indexOf('margin') === 0)
let left = 0
... | javascript | {
"resource": ""
} |
q24672 | createTextElement | train | function createTextElement (name, element = {}) {
let classToAdd = ''
const Tag = name
if (/^h\d$/i.test(name)) {
classToAdd = 'header'
} else {
classToAdd = 'text'
}
return createElement(name, merge({
attrs: true,
rules: {
[`.${name}.${classToAdd}`]: [ { '@pseudo': 'root' }, '@defau... | javascript | {
"resource": ""
} |
q24673 | sumShards | train | function sumShards(store, cb) {
exports.lazy(store.metaDb.createValueStream(), cb)
.map(function(stream) {
return stream.Shards.filter(function(shard) {
return shard.SequenceNumberRange.EndingSequenceNumber == null
}).length
})
.sum(function(sum) { return cb(null, sum) })
} | javascript | {
"resource": ""
} |
q24674 | onActFinished | train | function onActFinished(context, next) {
const msg = context.response.payload
// pass to act context
if (msg) {
context.request$ = msg.request || {}
context.trace$ = msg.trace || {}
context.meta$ = msg.meta || {}
}
// calculate request duration
const now = Util.nowHrTime()
const diff = now - ... | javascript | {
"resource": ""
} |
q24675 | print | train | function print(tableContent) {
for (let i = 0; i < tableContent.length; i += 1) {
console.log(`dim: ${tableContent[i].qValue[0].qText} val: ${tableContent[i].qValue[1].qText}`);
}
} | javascript | {
"resource": ""
} |
q24676 | emptyObject | train | function emptyObject(obj) {
Object.keys(obj).forEach((key) => {
const config = Object.getOwnPropertyDescriptor(obj, key);
if (config.configurable && !isSpecialProperty(obj, key)) {
delete obj[key];
}
});
} | javascript | {
"resource": ""
} |
q24677 | compare | train | function compare(a, b) {
let isIdentical = true;
if (isObject(a) && isObject(b)) {
if (Object.keys(a).length !== Object.keys(b).length) {
return false;
}
Object.keys(a).forEach((key) => {
if (!compare(a[key], b[key])) {
isIdentical = false;
}
});
return isIdentical;
... | javascript | {
"resource": ""
} |
q24678 | patchArray | train | function patchArray(original, newA, basePath) {
let patches = [];
const oldA = original.slice();
let tmpIdx = -1;
function findIndex(a, id, idx) {
if (a[idx] && isUndef(a[idx].qInfo)) {
return null;
} if (a[idx] && a[idx].qInfo.qId === id) {
// shortcut if identical
return idx;
}
... | javascript | {
"resource": ""
} |
q24679 | Eth | train | function Eth(cprovider, options) {
if (!(this instanceof Eth)) { throw new Error('[ethjs] the Eth object requires you construct it with the "new" flag (i.e. `const eth = new Eth(...);`).'); }
const self = this;
self.options = options || {};
const query = new EthQuery(cprovider, self.options.query);
Object.key... | javascript | {
"resource": ""
} |
q24680 | generateJsdocConfig | train | async function generateJsdocConfig({targetPath, tmpPath, namespace, projectName, version, variants}) {
// Backlash needs to be escaped as double-backslash
// This is not only relevant for win32 paths but also for
// Unix directory names that contain a backslash in their name
const backslashRegex = /\\/g;
// Resol... | javascript | {
"resource": ""
} |
q24681 | writeJsdocConfig | train | async function writeJsdocConfig(targetDirPath, config) {
const configPath = path.join(targetDirPath, "jsdoc-config.json");
await writeFile(configPath, config);
return configPath;
} | javascript | {
"resource": ""
} |
q24682 | buildJsdoc | train | async function buildJsdoc({sourcePath, configPath}) {
const args = [
require.resolve("jsdoc/jsdoc"),
"-c",
configPath,
"--verbose",
sourcePath
];
return new Promise((resolve, reject) => {
const child = spawn("node", args, {
stdio: ["ignore", "ignore", process.stderr]
});
child.on("close", function... | javascript | {
"resource": ""
} |
q24683 | fromUI5LegacyName | train | function fromUI5LegacyName(name, suffix) {
// UI5 only supports a few names with dots in them, anything else will be converted to slashes
if ( name.startsWith("sap.ui.thirdparty.jquery.jquery-") ) {
name = "sap/ui/thirdparty/jquery/jquery-" + name.slice("sap.ui.thirdparty.jquery.jquery-".length);
} else if ( name.... | javascript | {
"resource": ""
} |
q24684 | addType | train | function addType(typeName, type) {
if (types[typeName]) {
throw new Error("Type already registered '" + typeName + "'");
}
types[typeName] = type;
} | javascript | {
"resource": ""
} |
q24685 | train | async function({workspace, dependencies, options} = {}) {
if (!options || !options.projectName || !options.namespace || !options.version || !options.pattern) {
throw new Error("[generateJsdoc]: One or more mandatory options not provided");
}
const {sourcePath: resourcePath, targetPath, tmpPath} = await generateJs... | javascript | {
"resource": ""
} | |
q24686 | createTmpDirs | train | async function createTmpDirs(projectName) {
const {path: tmpDirPath} = await createTmpDir(projectName);
const sourcePath = path.join(tmpDirPath, "src"); // dir will be created by writing project resources below
await makeDir(sourcePath, {fs});
const targetPath = path.join(tmpDirPath, "target"); // dir will be crea... | javascript | {
"resource": ""
} |
q24687 | createTmpDir | train | function createTmpDir(projectName, keep = false) {
// Remove all non alpha-num characters from project name
const sanitizedProjectName = projectName.replace(/[^A-Za-z0-9]/g, "");
return new Promise((resolve, reject) => {
tmp.dir({
prefix: `ui5-tooling-tmp-jsdoc-${sanitizedProjectName}-`,
keep,
unsafeClean... | javascript | {
"resource": ""
} |
q24688 | writeResourcesToDir | train | async function writeResourcesToDir({workspace, pattern, targetPath}) {
const fsTarget = resourceFactory.createAdapter({
fsBasePath: targetPath,
virBasePath: "/resources/"
});
let allResources;
if (workspace.byGlobSource) { // API only available on duplex collections
allResources = await workspace.byGlobSourc... | javascript | {
"resource": ""
} |
q24689 | writeDependencyApisToDir | train | async function writeDependencyApisToDir({dependencies, targetPath}) {
const depApis = await dependencies.byGlob("/test-resources/**/designtime/api.json");
// Clone resources before changing their path
const apis = await Promise.all(depApis.map((resource) => resource.clone()));
for (let i = 0; i < apis.length; i++... | javascript | {
"resource": ""
} |
q24690 | getElapsedTime | train | function getElapsedTime(startTime) {
const prettyHrtime = require("pretty-hrtime");
const timeDiff = process.hrtime(startTime);
return prettyHrtime(timeDiff);
} | javascript | {
"resource": ""
} |
q24691 | composeTaskList | train | function composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTasks}) {
let selectedTasks = Object.keys(definedTasks).reduce((list, key) => {
list[key] = true;
return list;
}, {});
// Exclude non default tasks
selectedTasks.generateManifestBundle = false;
selectedTasks.generateStandaloneAppBundl... | javascript | {
"resource": ""
} |
q24692 | registrationIds | train | function registrationIds() {
const ids = [];
for (const regid of findChildren(sapFioriAppData, "registrationId")) {
ids.push(regid._);
}
return ids.length > 0 ? ids : undefined;
} | javascript | {
"resource": ""
} |
q24693 | createDependencyGraph | train | function createDependencyGraph(pool, moduleNames, indegreeOnly) {
const graph = Object.create(null);
const promises = moduleNames.map( (moduleName) => {
return pool.getModuleInfo(moduleName).
then( (module) => {
let node = graph[moduleName];
if ( node == null ) {
node = new GraphNode(moduleName, in... | javascript | {
"resource": ""
} |
q24694 | isString | train | function isString(node, literal) {
if ( node == null || node.type !== Syntax.Literal || typeof node.value !== "string" ) {
return false;
}
return literal == null ? true : node.value === literal;
} | javascript | {
"resource": ""
} |
q24695 | getStringArray | train | function getStringArray(array, skipNonStringLiterals) {
return array.elements.reduce( (result, item) => {
if ( isString(item) ) {
result.push(item.value);
} else if ( !skipNonStringLiterals ) {
throw new TypeError("array element is not a string literal:" + item.type);
}
return result;
}, []);
} | javascript | {
"resource": ""
} |
q24696 | copyFile | train | function copyFile(remotePath, targetRemotePath, options) {
const copyOptions = merge(baseOptions, options || {});
return copy.copyFile(remotePath, targetRemotePath, copyOptions);
} | javascript | {
"resource": ""
} |
q24697 | createReadStream | train | function createReadStream(remoteFilename, options) {
const createOptions = merge(baseOptions, options || {});
return createStream.createReadStream(remoteFilename, createOptions);
} | javascript | {
"resource": ""
} |
q24698 | createWriteStream | train | function createWriteStream(remoteFilename, options) {
const createOptions = merge(baseOptions, options || {});
return createStream.createWriteStream(remoteFilename, createOptions);
} | javascript | {
"resource": ""
} |
q24699 | deleteFile | train | function deleteFile(remotePath, options) {
const deleteOptions = merge(baseOptions, options || {});
return deletion.deleteFile(remotePath, deleteOptions);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.