_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q48900 | parseNode | train | function parseNode(sourceNode, sourceFile, sourceCode, state) {
// static nodes have no bindings
if (isStaticNode(sourceNode)) return [nodeToString(sourceNode), []]
return createDynamicNode(sourceNode, sourceFile, sourceCode, state)
} | javascript | {
"resource": ""
} |
q48901 | createAttributeExpressions | train | function createAttributeExpressions(sourceNode, sourceFile, sourceCode) {
return findDynamicAttributes(sourceNode)
.map(attribute => createExpression(attribute, sourceFile, sourceCode))
} | javascript | {
"resource": ""
} |
q48902 | createTextNodeExpressions | train | function createTextNodeExpressions(sourceNode, sourceFile, sourceCode) {
const childrenNodes = getChildrenNodes(sourceNode)
return childrenNodes
.filter(isTextNode)
.filter(hasExpressions)
.map(node => createExpression(
node,
sourceFile,
sourceCode,
childrenNodes.indexOf(node)
... | javascript | {
"resource": ""
} |
q48903 | extendTemplateProperty | train | function extendTemplateProperty(ast, sourceFile, sourceCode, sourceNode) {
types.visit(ast, {
visitProperty(path) {
if (path.value.key.value === TAG_TEMPLATE_PROPERTY) {
path.value.value = builders.functionExpression(
null,
[
TEMPLATE_FN,
EXPRESSION_TYPES,... | javascript | {
"resource": ""
} |
q48904 | extendTagProperty | train | function extendTagProperty(ast, exportDefaultNode) {
types.visit(ast, {
visitProperty(path) {
if (path.value.key.value === TAG_LOGIC_PROPERTY) {
path.value.value = exportDefaultNode.declaration
return false
}
this.traverse(path)
}
})
return ast
} | javascript | {
"resource": ""
} |
q48905 | groupSlots | train | function groupSlots(sourceNode) {
return getChildrenNodes(sourceNode).reduce((acc, node) => {
const slotAttribute = findSlotAttribute(node)
if (slotAttribute) {
acc[slotAttribute.value] = node
} else {
acc.default = createRootNode({
nodes: [...getChildrenNodes(acc.default), node]
... | javascript | {
"resource": ""
} |
q48906 | buildSlot | train | function buildSlot(id, sourceNode, sourceFile, sourceCode) {
const cloneNode = {
...sourceNode,
// avoid to render the slot attribute
attributes: getNodeAttributes(sourceNode).filter(attribute => attribute.name !== SLOT_ATTRIBUTE)
}
const [html, bindings] = build(cloneNode, sourceFile, sourceCode)
... | javascript | {
"resource": ""
} |
q48907 | generateLiteralStringChunksFromNode | train | function generateLiteralStringChunksFromNode(node, sourceCode) {
return node.expressions.reduce((chunks, expression, index) => {
const start = index ? node.expressions[index - 1].end : node.start
chunks.push(sourceCode.substring(start, expression.start))
// add the tail to the string
if (index === n... | javascript | {
"resource": ""
} |
q48908 | replacePathScope | train | function replacePathScope(path, property) {
path.replace(builders.memberExpression(
scope,
property,
false
))
} | javascript | {
"resource": ""
} |
q48909 | updateNodeScope | train | function updateNodeScope(path) {
if (!isGlobal(path)) {
replacePathScope(path, path.node)
return false
}
this.traverse(path)
} | javascript | {
"resource": ""
} |
q48910 | visitMemberExpression | train | function visitMemberExpression(path) {
if (!isGlobal({ node: path.node.object, scope: path.scope })) {
replacePathScope(path, isThisExpression(path.node.object) ? path.node.property : path.node)
}
return false
} | javascript | {
"resource": ""
} |
q48911 | visitProperty | train | function visitProperty(path) {
const value = path.node.value
if (isIdentifier(value)) {
updateNodeScope(path.get('value'))
} else {
this.traverse(path.get('value'))
}
return false
} | javascript | {
"resource": ""
} |
q48912 | createMeta | train | function createMeta(source, options) {
return {
tagName: null,
fragments: null,
options: {
...DEFAULT_OPTIONS,
...options
},
source
}
} | javascript | {
"resource": ""
} |
q48913 | hookGenerator | train | function hookGenerator(transformer, sourceNode, source, meta) {
if (
// filter missing nodes
!sourceNode ||
// filter nodes without children
(sourceNode.nodes && !sourceNode.nodes.length) ||
// filter empty javascript and css nodes
(!sourceNode.nodes && !sourceNode.text)) {
return result =... | javascript | {
"resource": ""
} |
q48914 | processHTML | train | function processHTML(cssSelectors = [], htmlDataIn = null, htmlOptionsIn = null) {
//read html files
if (OPTIONS.html !== '' && OPTIONS.html !== undefined && OPTIONS.special_reduce_with_html) {
var htmlFiles = OPTIONS.html;
tmpHTMLPaths = [];
//check for file or files
switch (typeof htmlFiles) {
... | javascript | {
"resource": ""
} |
q48915 | getFilePaths | train | function getFilePaths(strPath = '', exts = ['.css']) {
if (validUrl.isUri(strPath)){
switch(exts[0]) {
case '.css':
tmpCSSPaths.push(strPath);
break;
case '.html':
case '.htm':
tmpHTMLPaths.push(strPath);
break;
case '.js':
tmpJSPaths.push(strPath);
break;
}
} e... | javascript | {
"resource": ""
} |
q48916 | processRulesReset | train | function processRulesReset() {
declarationsNameCounts = null;
declarationsValueCounts = null;
valKey = null;
key = null;
declarationsValueCountsCount = null;
amountRemoved = 1;
duplicate_ids = null;
selectorPropertiesList = null;
} | javascript | {
"resource": ""
} |
q48917 | train | function(list){
localStorage.setItem(localStorageKey, JSON.stringify(list));
// if we used a real database, we would likely do the below in a callback
this.list = list;
this.trigger(list); // sends the updated list to all listening components (TodoApp)
} | javascript | {
"resource": ""
} | |
q48918 | train | function() {
var loadedList = localStorage.getItem(localStorageKey);
if (!loadedList) {
// If no list is in localstorage, start out with a default one
this.list = [{
key: todoCounter++,
created: new Date(),
... | javascript | {
"resource": ""
} | |
q48919 | getTargetScope | train | function getTargetScope() {
var targetElement = scope.ttElement ? angular.element(scope.ttElement) : element;
var targetScope = scope;
if (targetElement !== element && !scope.ttSourceScope)
targetScope = targetElement.scope();
return ... | javascript | {
"resource": ""
} |
q48920 | recursiveIssuer | train | function recursiveIssuer(module) {
if (module.issuer) {
return recursiveIssuer(module.issuer);
}
else if (module.name) {
return module.name;
}
else {
return false;
}
} | javascript | {
"resource": ""
} |
q48921 | readFile | train | function readFile(fileName) {
try {
return read(fileName);
} catch (e) {
print(fileName + ': ' + (e.message || e));
throw e;
}
} | javascript | {
"resource": ""
} |
q48922 | parseState | train | function parseState(s) {
switch (s) {
case "": return Profile.CodeState.COMPILED;
case "~": return Profile.CodeState.OPTIMIZABLE;
case "*": return Profile.CodeState.OPTIMIZED;
}
throw new Error("unknown code state: " + s);
} | javascript | {
"resource": ""
} |
q48923 | train | function () {
var deferred = Q.defer();
var that = this;
this._innerQueryIterator.nextItem(function (error, item, responseHeaders) {
if (error) {
addOrMergeHeadersForError(error, responseHeaders);
deferred.reject(error);
... | javascript | {
"resource": ""
} | |
q48924 | train | function () {
var deferred = Q.defer();
var that = this;
this._innerQueryIterator.executeNext(function (error, resources, responseHeaders) {
if (error) {
addOrMergeHeadersForError(error, responseHeaders);
deferred.reject(e... | javascript | {
"resource": ""
} | |
q48925 | train | function(sprocLink, params, options) {
var deferred = Q.defer();
this._innerDocumentclient.executeStoredProcedure(sprocLink, params, options, function (error, result, responseHeaders) {
if (error) {
addOrMergeHeadersForError(error, responseHeaders);
... | javascript | {
"resource": ""
} | |
q48926 | train | function() {
var target;
$('a[href^="#"]').not('.pldoc-tab-wrapper .pldoc-link').on('click', function(event) {
event.preventDefault();
target = $(event.currentTarget).attr('href');
$('html, body').stop().animate({
scrollTop: $... | javascript | {
"resource": ""
} | |
q48927 | range | train | function range(start, end) {
return Array(end - start + 1).fill().map(function (_, index) {
return start + index;
});
} | javascript | {
"resource": ""
} |
q48928 | ObjectID | train | function ObjectID(arg) {
if(!(this instanceof ObjectID)) return new ObjectID(arg);
if(arg && ((arg instanceof ObjectID) || arg._bsontype==="ObjectID"))
return arg;
var buf;
if(isBuffer(arg) || (Array.isArray(arg) && arg.length===12)) {
buf = Array.prototype.slice.call(arg);
}
else if(typeof arg ==... | javascript | {
"resource": ""
} |
q48929 | apiShowTip | train | function apiShowTip(element, event) {
// if we were given a mouse event then run the hover intent testing,
// otherwise, simply show the tooltip asap
if (isMouseEvent(event)) {
trackMouse(event);
session.previousX = event.pageX;
session.previousY = event.pageY;
$(element).data(DATA_DISPLAYCONTROLLER).... | javascript | {
"resource": ""
} |
q48930 | apiCloseTip | train | function apiCloseTip(element, immediate) {
var displayController;
// set immediate to true when no element is specified
immediate = element ? immediate : true;
// find the relevant display controller
if (element) {
displayController = $(element).first().data(DATA_DISPLAYCONTROLLER);
} else if (session.... | javascript | {
"resource": ""
} |
q48931 | apiToggle | train | function apiToggle(element, event) {
if (session.activeHover && session.activeHover.is(element)) {
// tooltip for element is active, so close it
$.powerTip.hide(element, !isMouseEvent(event));
} else {
// tooltip for element is not active, so open it
$.powerTip.show(element, event);
}
return element... | javascript | {
"resource": ""
} |
q48932 | train | function () {
var collisionEntities;
var data = this.data;
var el = this.el;
if (!data.collisionEntities) {
this.collisionEntities = [];
return;
}
collisionEntities = [].slice.call(el.sceneEl.querySelectorAll(data.collisionEntities));
this.collisionEntities = collisionEntities;... | javascript | {
"resource": ""
} | |
q48933 | train | function (i, next) {
// @todo We should add a property to define if the collisionEntity is dynamic or static
// If static we should do the map just once, otherwise we're recreating the array in every
// loop when aiming.
var meshes;
if (!this.data.collisionEntities) {
meshes = this.defaultColl... | javascript | {
"resource": ""
} | |
q48934 | createHitEntity | train | function createHitEntity (data) {
var cylinder;
var hitEntity;
var torus;
// Parent.
hitEntity = document.createElement('a-entity');
hitEntity.className = 'hitEntity';
// Torus.
torus = document.createElement('a-entity');
torus.setAttribute('geometry', {
primitive: 'torus',
radius: data.hitC... | javascript | {
"resource": ""
} |
q48935 | cloneSyntax | train | function cloneSyntax(stx) {
function F(){}
F.prototype = stx.__proto__;
var s = new F();
extend(s, stx);
s.token = extend({}, s.token);
return s;
} | javascript | {
"resource": ""
} |
q48936 | attach | train | function attach(bugout, identifier, wire, addr) {
debug("saw wire", wire.peerId, identifier);
wire.use(extension(bugout, identifier, wire));
wire.on("close", partial(detach, bugout, identifier, wire));
} | javascript | {
"resource": ""
} |
q48937 | processMessageNode | train | function processMessageNode (message) {
if (
(message.type === 'Literal' && typeof message.value === 'string' && !pattern.test(message.value)) ||
(message.type === 'TemplateLiteral' && message.quasis.length === 1 && !pattern.test(message.quasis[0].value.cooked))
) {
context.report({
... | javascript | {
"resource": ""
} |
q48938 | isExpectedUrl | train | function isExpectedUrl (node) {
return Boolean(
node &&
node.type === 'Literal' &&
typeof node.value === 'string' &&
(
expectedUrl === undefined ||
node.value === expectedUrl
)
);
} | javascript | {
"resource": ""
} |
q48939 | insertProperty | train | function insertProperty (fixer, node, propertyText) {
if (node.properties.length === 0) {
return fixer.replaceText(node, `{\n${propertyText}\n}`);
}
return fixer.insertTextAfter(
sourceCode.getLastToken(node.properties[node.properties.length - 1]),
`,\n${propertyText}`
);... | javascript | {
"resource": ""
} |
q48940 | isRangeAccess | train | function isRangeAccess (node) {
return node.type === 'MemberExpression' && node.property.type === 'Identifier' && node.property.name === 'range';
} | javascript | {
"resource": ""
} |
q48941 | argHashToArray | train | function argHashToArray(hash)
{
var keys = Object.keys(hash);
var result = [];
for (var i = 0; i < keys.length; i++)
{
result[parseInt(keys[i], 10)] = hash[keys[i]];
}
return result;
} | javascript | {
"resource": ""
} |
q48942 | makeBeanstalkCommand | train | function makeBeanstalkCommand(command, expectedResponse, sendsData)
{
// Commands are called as client.COMMAND(arg1, arg2, ... data, callback);
// They're sent to beanstalkd as: COMMAND arg1 arg2 ...
// followed by data.
// So we slice the callback & data from the passed-in arguments, prepend
// the command, then ... | javascript | {
"resource": ""
} |
q48943 | pushListener | train | function pushListener(event) {
var jsonString = event.data && event.data.text() ? event.data.text() : null;
if (!jsonString) {
console.log('Leanplum: Push received without payload, skipping display.');
return;
}
// noinspection JSCheckFunctionSignatures
var options = JSON.parse(jsonStr... | javascript | {
"resource": ""
} |
q48944 | notificationClickListener | train | function notificationClickListener(event) {
console.log('Leanplum: [Service Worker] Notification click received.');
event.notification.close();
if (!event.notification || !event.notification.tag) {
console.log('Leanplum: No notification or tag/id received, skipping open action.');
return;
... | javascript | {
"resource": ""
} |
q48945 | bitDepth | train | function bitDepth(input, original, target, output) {
validateBitDepth_(original);
validateBitDepth_(target);
/** @type {!Function} */
let toFunction = getBitDepthFunction_(original, target);
/** @type {!Object<string, number>} */
let options = {
oldMin: Math.pow(2, parseInt(original, 10)) / 2,
newMi... | javascript | {
"resource": ""
} |
q48946 | intToInt_ | train | function intToInt_(sample, args) {
if (sample > 0) {
sample = parseInt((sample / args.oldMax) * args.newMax, 10);
} else {
sample = parseInt((sample / args.oldMin) * args.newMin, 10);
}
return sample;
} | javascript | {
"resource": ""
} |
q48947 | floatToInt_ | train | function floatToInt_(sample, args) {
return parseInt(
sample > 0 ? sample * args.newMax : sample * args.newMin, 10);
} | javascript | {
"resource": ""
} |
q48948 | getBitDepthFunction_ | train | function getBitDepthFunction_(original, target) {
/** @type {!Function} */
let func = function(x) {return x;};
if (original != target) {
if (["32f", "64"].includes(original)) {
if (["32f", "64"].includes(target)) {
func = floatToFloat_;
} else {
func = floatToInt_;
}
} el... | javascript | {
"resource": ""
} |
q48949 | decode | train | function decode(adpcmSamples, blockAlign=256) {
/** @type {!Int16Array} */
let samples = new Int16Array(adpcmSamples.length * 2);
/** @type {!Array<number>} */
let block = [];
/** @type {number} */
let fileIndex = 0;
for (let i=0; i<adpcmSamples.length; i++) {
if (i % blockAlign == 0 && i != 0) { ... | javascript | {
"resource": ""
} |
q48950 | encodeBlock | train | function encodeBlock(block) {
/** @type {!Array<number>} */
let adpcmSamples = blockHead_(block[0]);
for (let i=3; i<block.length; i+=2) {
/** @type {number} */
let sample2 = encodeSample_(block[i]);
/** @type {number} */
let sample = encodeSample_(block[i + 1]);
adpcmSamples.push((sample << 4... | javascript | {
"resource": ""
} |
q48951 | decodeBlock | train | function decodeBlock(block) {
decoderPredicted_ = sign_((block[1] << 8) | block[0]);
decoderIndex_ = block[2];
decoderStep_ = STEP_TABLE[decoderIndex_];
/** @type {!Array<number>} */
let result = [
decoderPredicted_,
sign_((block[3] << 8) | block[2])
];
for (let i=4; i<block.length; i++) {
... | javascript | {
"resource": ""
} |
q48952 | encodeSample_ | train | function encodeSample_(sample) {
/** @type {number} */
let delta = sample - encoderPredicted_;
/** @type {number} */
let value = 0;
if (delta >= 0) {
value = 0;
} else {
value = 8;
delta = -delta;
}
/** @type {number} */
let step = STEP_TABLE[encoderIndex_];
/** @type {number} */
let d... | javascript | {
"resource": ""
} |
q48953 | decodeSample_ | train | function decodeSample_(nibble) {
/** @type {number} */
let difference = 0;
if (nibble & 4) {
difference += decoderStep_;
}
if (nibble & 2) {
difference += decoderStep_ >> 1;
}
if (nibble & 1) {
difference += decoderStep_ >> 2;
}
difference += decoderStep_ >> 3;
if (nibble & 8) {
diff... | javascript | {
"resource": ""
} |
q48954 | blockHead_ | train | function blockHead_(sample) {
encodeSample_(sample);
/** @type {!Array<number>} */
let adpcmSamples = [];
adpcmSamples.push(sample & 0xFF);
adpcmSamples.push((sample >> 8) & 0xFF);
adpcmSamples.push(encoderIndex_);
adpcmSamples.push(0);
return adpcmSamples;
} | javascript | {
"resource": ""
} |
q48955 | encodeSample | train | function encodeSample(sample) {
/** @type {number} */
let compandedValue;
sample = (sample ==-32768) ? -32767 : sample;
/** @type {number} */
let sign = ((~sample) >> 8) & 0x80;
if (!sign) {
sample = sample * -1;
}
if (sample > 32635) {
sample = 32635;
}
if (sample >= 256) {
/** @ty... | javascript | {
"resource": ""
} |
q48956 | decodeSample | train | function decodeSample(aLawSample) {
/** @type {number} */
let sign = 0;
aLawSample ^= 0x55;
if (aLawSample & 0x80) {
aLawSample &= ~(1 << 7);
sign = -1;
}
/** @type {number} */
let position = ((aLawSample & 0xF0) >> 4) + 4;
/** @type {number} */
let decoded = 0;
if (position != 4) {
deco... | javascript | {
"resource": ""
} |
q48957 | decode$1 | train | function decode$1(samples) {
/** @type {!Int16Array} */
let pcmSamples = new Int16Array(samples.length);
for (let i=0; i<samples.length; i++) {
pcmSamples[i] = decodeSample(samples[i]);
}
return pcmSamples;
} | javascript | {
"resource": ""
} |
q48958 | encodeSample$1 | train | function encodeSample$1(sample) {
/** @type {number} */
let sign;
/** @type {number} */
let exponent;
/** @type {number} */
let mantissa;
/** @type {number} */
let muLawSample;
/** get the sample into sign-magnitude **/
sign = (sample >> 8) & 0x80;
if (sign != 0) sample = -sample;
if (sample > C... | javascript | {
"resource": ""
} |
q48959 | decodeSample$1 | train | function decodeSample$1(muLawSample) {
/** @type {number} */
let sign;
/** @type {number} */
let exponent;
/** @type {number} */
let mantissa;
/** @type {number} */
let sample;
muLawSample = ~muLawSample;
sign = (muLawSample & 0x80);
exponent = (muLawSample >> 4) & 0x07;
mantissa = muLawSample &... | javascript | {
"resource": ""
} |
q48960 | swap | train | function swap(bytes, offset, index) {
offset--;
for(let x = 0; x < offset; x++) {
/** @type {*} */
let theByte = bytes[index + x];
bytes[index + x] = bytes[index + offset];
bytes[index + offset] = theByte;
offset--;
}
} | javascript | {
"resource": ""
} |
q48961 | pack | train | function pack(str, buffer, index=0) {
for (let i = 0, len = str.length; i < len; i++) {
/** @type {number} */
let codePoint = str.codePointAt(i);
if (codePoint < 128) {
buffer[index] = codePoint;
index++;
} else {
/** @type {number} */
let count = 0;
/** @type {number} */... | javascript | {
"resource": ""
} |
q48962 | unpackString | train | function unpackString(buffer, index=0, end=buffer.length) {
return unpack(buffer, index, end);
} | javascript | {
"resource": ""
} |
q48963 | unpackArrayTo | train | function unpackArrayTo(
buffer, theType, output, start=0, end=buffer.length, safe=false) {
theType = theType || {};
/** @type {NumberBuffer} */
let packer = new NumberBuffer(theType.bits, theType.fp, theType.signed);
/** @type {number} */
let offset = packer.offset;
// getUnpackLen_ will either fix the ... | javascript | {
"resource": ""
} |
q48964 | packTo | train | function packTo(value, theType, buffer, index=0) {
return packArrayTo([value], theType, buffer, index);
} | javascript | {
"resource": ""
} |
q48965 | unpackArray | train | function unpackArray(
buffer, theType, start=0, end=buffer.length, safe=false) {
/** @type {!Array<number>} */
let output = [];
unpackArrayTo(buffer, theType, output, start, end, safe);
return output;
} | javascript | {
"resource": ""
} |
q48966 | unpack$1 | train | function unpack$1(buffer, theType, index=0) {
return unpackArray(
buffer, theType, index, index + Math.ceil(theType.bits / 8), true)[0];
} | javascript | {
"resource": ""
} |
q48967 | train | function(layout, fail) {
if (_.isFunction(layout)) {
return layout;
}
if (!_.isString(layout)) {
fail('Layout should be specified by name or as a function');
}
if (_(defaultLayouts).has(layout)) {
return defaultLayouts[layout];
}
fail('The following named layouts are sup... | javascript | {
"resource": ""
} | |
q48968 | pathifyModel | train | function pathifyModel (model, store, prefix) {
let result = []
if (prefix) result.push(prefix)
if (get(model, '_internalModel.modelName') === 'uni-form') {
const propPath = propertyPath('payload', prefix)
if (model.get('payload') instanceof DS.Model) {
return result.concat(pathifyModel(model.get('p... | javascript | {
"resource": ""
} |
q48969 | train | function () {
options.menu = !fabricator.dom.root.classList.contains('f-menu-active');
fabricator.dom.root.classList.toggle('f-menu-active');
if (fabricator.test.sessionStorage) {
sessionStorage.setItem('fabricator', JSON.stringify(options));
}
} | javascript | {
"resource": ""
} | |
q48970 | train | function (list) {
if (!list.matches) {
root.classList.remove('f-menu-active');
} else {
if (fabricator.getOptions().menu) {
root.classList.add('f-menu-active');
} else {
root.classList.remove('f-menu-active');
}
}
} | javascript | {
"resource": ""
} | |
q48971 | getColors | train | function getColors(rawData) {
// Regular expression matching colors variables naming pattern
var REGEX = /^dc-(.*?)[0-9]+$/;
var content = rawData
.filter((item) => {
var group = item.group[0];
return group === 'colors'
&& item.context.type === 'variable'
... | javascript | {
"resource": ""
} |
q48972 | getSassReference | train | function getSassReference(rawData) {
// group sassdoc items (variables, mixins, functions, etc.) by @group
var content = _.groupBy(rawData, (item) => item.group[0]);
Object.keys(content).forEach((group) => {
content[group] = content[group].map((item) => {
// boolean flag for deprecated
... | javascript | {
"resource": ""
} |
q48973 | getErrorMessage | train | function getErrorMessage (err, target, defaultMsg) {
var errMessage;
if (err) {
errMessage = err.toString();
} else {
errMessage = defaultMsg;
}
return errMessage.replace('%target%', target);
} | javascript | {
"resource": ""
} |
q48974 | merkle | train | function merkle (values, digestFn) {
if (!Array.isArray(values)) throw TypeError('Expected values Array')
if (typeof digestFn !== 'function') throw TypeError('Expected digest Function')
if (values.length === 1) return values.concat()
var levels = [values]
var level = values
do {
level = _derive(level,... | javascript | {
"resource": ""
} |
q48975 | callOnFinish | train | function callOnFinish (original) {
return function (callback) {
if (concurrent === 0) {
original.call(this, callback);
} else {
pendingFinish = original.bind(this, callback);
}
}
} | javascript | {
"resource": ""
} |
q48976 | findPackages | train | function findPackages(path) {
return new Promise(function (resolve, reject) {
(0, _glob.glob)(path, function (err, res) {
if (err) {
reject(err);
}
resolve(res.filter(function (file) {
return file.endsWith('.json');
}));
});
});
} | javascript | {
"resource": ""
} |
q48977 | readPackages | train | function readPackages() {
var packages = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
return Promise.all(packages.map(readPackage)).then(function (labels) {
return labels.reduce(function (prev, curr) {
return prev.concat(curr);
});
});
} | javascript | {
"resource": ""
} |
q48978 | requestPromisfied | train | function requestPromisfied(options) {
return new Promise(function (resolve, reject) {
(0, _request2.default)(options, function (err, res) {
if (err) {
reject(err);
}
resolve(res.body);
});
});
} | javascript | {
"resource": ""
} |
q48979 | configure | train | function configure(_ref) {
var api = _ref.api;
var token = _ref.token;
var repo = _ref.repo;
return {
api: api,
repo: "repos/" + repo,
token: token
};
} | javascript | {
"resource": ""
} |
q48980 | add | train | function add(server, labels) {
return (0, _label.createLabels)((0, _config.configure)(server), labels).then(_handlers.createSuccessHandler).catch(_handlers.errorHandler);
} | javascript | {
"resource": ""
} |
q48981 | remove | train | function remove(server, labels) {
return (0, _label.deleteLabels)((0, _config.configure)(server), labels).then(_handlers.deleteSuccessHandler).catch(_handlers.errorHandler);
} | javascript | {
"resource": ""
} |
q48982 | createLabel | train | function createLabel(_ref, name, color) {
var api = _ref.api;
var token = _ref.token;
var repo = _ref.repo;
return (0, _request2.default)({
headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token },
url: api + '/' + repo + '/labels',
form: JSON.stringify({ name: name, color: color }),... | javascript | {
"resource": ""
} |
q48983 | deleteLabel | train | function deleteLabel(_ref2, name) {
var api = _ref2.api;
var token = _ref2.token;
var repo = _ref2.repo;
return (0, _request2.default)({
headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token },
url: api + '/' + repo + '/labels/' + name,
method: 'DELETE',
json: true
});
} | javascript | {
"resource": ""
} |
q48984 | getLabels | train | function getLabels(_ref3) {
var api = _ref3.api;
var token = _ref3.token;
var repo = _ref3.repo;
return (0, _request2.default)({
headers: { 'User-Agent': 'request', 'Authorization': 'token ' + token },
url: api + '/' + repo + '/labels',
method: 'GET',
json: true
});
} | javascript | {
"resource": ""
} |
q48985 | formatLabel | train | function formatLabel(_ref4) {
var name = _ref4.name;
var color = _ref4.color;
return { name: name, color: color.replace('#', '') };
} | javascript | {
"resource": ""
} |
q48986 | createLabels | train | function createLabels(server, labels) {
return Promise.all(labels.map(formatLabel).map(function (_ref5) {
var name = _ref5.name;
var color = _ref5.color;
return createLabel(server, name, color);
}));
} | javascript | {
"resource": ""
} |
q48987 | deleteLabels | train | function deleteLabels(server, labels) {
return Promise.all(labels.map(formatLabel).map(function (_ref6) {
var name = _ref6.name;
var color = _ref6.color;
return deleteLabel(server, name);
}));
} | javascript | {
"resource": ""
} |
q48988 | replaceParams | train | function replaceParams(ast, keys) {
Object.keys(ast)
.filter(key => {
const value = ast[key]
return Array.isArray(value) || (typeof value === 'object' && value !== null)
})
.forEach(key => {
const expr = ast[key]
if (!(typeof expr === 'object' && expr.type === 'param')) return rep... | javascript | {
"resource": ""
} |
q48989 | Mage | train | function Mage(mageRootModule) {
EventEmitter.call(this);
this.workerId = require('./worker').getId();
this.MageError = require('./MageError');
this.task = null;
this._runState = 'init';
this._modulesList = [];
this._modulePaths = [
applicationModulesPath
];
this._setupQueue = [];
this._teardownQueue = [];... | javascript | {
"resource": ""
} |
q48990 | recursiveFileList | train | function recursiveFileList(rootPath, cb) {
var fileList = [];
var errorList = [];
var q = async.queue(function (filename, callback) {
var filePath = path.join(rootPath, filename);
fs.stat(filePath, function (error, stat) {
if (error) {
errorList.push(error);
return callback(error);
}
// If no... | javascript | {
"resource": ""
} |
q48991 | purgeEmptyParentFolders | train | function purgeEmptyParentFolders(rootPath, subfolderPath, logger, cb) {
var fullPath = path.join(rootPath, subfolderPath);
// Don't delete if we have reached the base
if (!subfolderPath || subfolderPath === '.') {
return cb();
}
fs.rmdir(fullPath, function (error) {
if (error) {
return cb(error);
}
l... | javascript | {
"resource": ""
} |
q48992 | purgeEmptySubFolders | train | function purgeEmptySubFolders(rootPath, subfolderPath, logger, cb) {
subfolderPath = subfolderPath || '';
var fullPath = path.join(rootPath, subfolderPath);
fs.readdir(fullPath, function (error, files) {
if (error) {
return cb();
}
async.eachLimit(files, MAX_PARALLEL, function (file, callback) {
var fi... | javascript | {
"resource": ""
} |
q48993 | getAvailableMigrations | train | function getAvailableMigrations(vaultName, cb) {
var path = configuration.getMigrationsPath(vaultName);
fs.readdir(path, function (error, files) {
if (error) {
if (error.code === 'ENOENT') {
logger.warning('No migration folder found for vault', vaultName, '(skipping).');
return cb(null, []);
}
re... | javascript | {
"resource": ""
} |
q48994 | migrateVaultToVersion | train | function migrateVaultToVersion(vault, targetVersion, cb) {
var preventMigrate = mage.core.config.get(['archivist', 'vaults', vault.name, 'config', 'preventMigrate'], false);
if (preventMigrate) {
logger.warning(`Vault ${vault.name} has disabled migrate operation (skipping)`);
return cb();
}
if (typeof vault.ge... | javascript | {
"resource": ""
} |
q48995 | copy | train | function copy(from, to) {
var mode = fs.statSync(from).mode;
var src = fs.readFileSync(from, 'utf8');
var re = /%([0-9A-Z\_]+)%/g;
function replacer(_, match) {
// We support the %PERIOD% variable to allow .gitignore to be created. The reason:
// npm "kindly" ignores .gitignore files, so we have to use ... | javascript | {
"resource": ""
} |
q48996 | flagsToStr | train | function flagsToStr(flags) {
if (!flags) {
return;
}
var buff = new Buffer(4);
buff.writeUInt32BE(flags, 0);
// return a 0-byte terminated or 4-byte string
switch (0) {
case buff[0]:
return;
case buff[1]:
return buff.toString('utf8', 0, 1);
case buff[2]:
return buff.toString('utf8', 0, 2);
case buf... | javascript | {
"resource": ""
} |
q48997 | strToFlags | train | function strToFlags(str) {
if (!str) {
return;
}
var buff = new Buffer([0, 0, 0, 0]);
buff.write(str, 0, 4, 'ascii');
return buff.readUInt32BE(0);
} | javascript | {
"resource": ""
} |
q48998 | getRawRecursive | train | function getRawRecursive(matryoshka) {
if (matryoshka.type !== 'object') {
return matryoshka.value;
}
const returnObj = {};
for (const key of Object.keys(matryoshka.value)) {
returnObj[key] = getRawRecursive(matryoshka.value[key]);
}
return returnObj;
} | javascript | {
"resource": ""
} |
q48999 | merge | train | function merge(a, b) {
// If a is not a matryoshka, then return a copy of b (override).
if (!(a instanceof Matryoshka)) {
return b.copy();
}
// If b is not a matryoshka, then just keep a.
if (!(b instanceof Matryoshka)) {
return a.copy();
}
// If we reached here, both a and b are matryoshkas.
// Types ar... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.