_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q28500 | resolveNative | train | function resolveNative(success, fail, path, fsType, options, size) {
window.webkitRequestFileSystem(
fsType,
size,
function (fs) {
if (path === '') {
//no path provided, call success with root file system
success(createEntryFromNative(fs.root));
... | javascript | {
"resource": ""
} |
q28501 | train | function (pattern, repeat) {
repeat = (typeof repeat !== 'undefined') ? repeat : -1;
pattern = pattern.unshift(0); // add a 0 at beginning for backwards compatibility from w3c spec
exec(null, null, 'Vibration', 'vibrateWithPattern', [pattern, repeat]);
} | javascript | {
"resource": ""
} | |
q28502 | read | train | function read(context) {
const projectRoot = getProjectRoot(context);
const configXml = getConfigXml(projectRoot);
const branchXml = getBranchXml(configXml);
const branchPreferences = getBranchPreferences(
context,
configXml,
branchXml
);
validateBranchPreferences(branchPrefer... | javascript | {
"resource": ""
} |
q28503 | getConfigXml | train | function getConfigXml(projectRoot) {
const pathToConfigXml = path.join(projectRoot, "config.xml");
const configXml = xmlHelper.readXmlAsJson(pathToConfigXml);
if (configXml == null) {
throw new Error(
"BRANCH SDK: A config.xml is not found in project's root directory. Docs https://goo.gl/GijG... | javascript | {
"resource": ""
} |
q28504 | getProjectName | train | function getProjectName(configXml) {
let output = null;
if (configXml.widget.hasOwnProperty("name")) {
const name = configXml.widget.name[0];
if (typeof name === "string") {
// handle <name>Branch Cordova</name>
output = configXml.widget.name[0];
} else {
// handle <nam... | javascript | {
"resource": ""
} |
q28505 | getProjectModule | train | function getProjectModule(context) {
const projectRoot = getProjectRoot(context);
const projectPath = path.join(projectRoot, "platforms", "ios");
try {
// pre 5.0 cordova structure
return context
.requireCordovaModule("cordova-lib/src/plugman/platforms")
.ios.parseProjectFile(pr... | javascript | {
"resource": ""
} |
q28506 | updateNpmVersion | train | function updateNpmVersion(pluginConfig, config, callback) {
const files = readFilePaths(FILES);
const version = config.nextRelease.version;
let git = "";
for (let i = 0; i < files.length; i++) {
// update
const file = files[i];
const content = readContent(file);
const updated = ... | javascript | {
"resource": ""
} |
q28507 | updateVersion | train | function updateVersion(file, content, version) {
const prev = /id="branch-cordova-sdk"[\s]*version="\d+\.\d+\.\d+"/gim;
const next = `id="branch-cordova-sdk"\n version="${version}"`;
try {
if (isFileXml(file)) {
content = content.replace(prev, next);
} else {
isChange = content... | javascript | {
"resource": ""
} |
q28508 | readFilePaths | train | function readFilePaths(files) {
const locations = [];
for (let i = 0; i < files.length; i++) {
const file = files[i];
const location = path.join(__dirname, "../../../", file);
locations.push(location);
}
return locations;
} | javascript | {
"resource": ""
} |
q28509 | commitChanges | train | function commitChanges(git, version) {
git += `git commit -m "chore: updated npm version to ${version}" && git push`;
exec(git, (err, stdout, stderr) => {
if (err) {
throw new Error(
"BRANCH SDK: Failed to commit git changes for the npm version. Docs https://goo.gl/GijGKP"
);
... | javascript | {
"resource": ""
} |
q28510 | registerComponent | train | function registerComponent(Vue, name, definition) {
Vue._shards_vue_components_ = Vue._shards_vue_components_ || {};
var loaded = Vue._shards_vue_components_[name];
if (!loaded && definition && name) {
Vue._shards_vue_components_[name] = true;
Vue.component(name, definit... | javascript | {
"resource": ""
} |
q28511 | registerComponents | train | function registerComponents(Vue, components) {
for (var component in components) {
registerComponent(Vue, component, components[component]);
}
} | javascript | {
"resource": ""
} |
q28512 | registerDirective | train | function registerDirective(Vue, name, definition) {
Vue._shards_vue_directives_ = Vue._shards_vue_directives_ || {};
var loaded = Vue._shards_vue_directives_[name];
if (!loaded && definition && name) {
Vue._shards_vue_directives_[name] = true;
Vue.directive(name, definit... | javascript | {
"resource": ""
} |
q28513 | registerDirectives | train | function registerDirectives(Vue, directives) {
for (var directive in directives) {
registerDirective(Vue, directive, directives[directive]);
}
} | javascript | {
"resource": ""
} |
q28514 | train | function (el, className) {
if (className && isElement(el)) {
return el.classList.contains(className)
}
return false
} | javascript | {
"resource": ""
} | |
q28515 | train | function (el, attr, value) {
if (attr && isElement(el)) {
el.setAttribute(attr, value);
}
} | javascript | {
"resource": ""
} | |
q28516 | train | function (el) {
return !isElement(el)
|| el.disabled
|| el.classList.contains('disabled')
|| Boolean(el.getAttribute('disabled'))
} | javascript | {
"resource": ""
} | |
q28517 | train | function (el) {
return isElement(el)
&& document.body.contains(el)
&& el.getBoundingClientRect().height > 0
&& el.getBoundingClientRect().width > 0
} | javascript | {
"resource": ""
} | |
q28518 | train | function (selector, root) {
if (!isElement(root)) {
root = document;
}
return root.querySelector(selector) || null
} | javascript | {
"resource": ""
} | |
q28519 | train | function (selector, root) {
if (!isElement(root)) {
return null
}
var Closest = Element.prototype.closest ||
function (sel) {
var element = this;
if (!document.documentElement.contains(element)) {
return null
... | javascript | {
"resource": ""
} | |
q28520 | train | function (type, breakpoint, val) {
if (!!val === false) {
return false
}
var className = type;
if (breakpoint) {
className += "-" + (breakpoint.replace(type, '')); // -md ?
}
if (type === 'col' && (val === '' || val === true)) {
retu... | javascript | {
"resource": ""
} | |
q28521 | generateProp | train | function generateProp(type, defaultVal) {
if ( type === void 0 ) type = [Boolean, String, Number];
if ( defaultVal === void 0 ) defaultVal = null;
return {
default: defaultVal,
type: type
}
} | javascript | {
"resource": ""
} |
q28522 | createBreakpointMap | train | function createBreakpointMap(propGenArgs, defaultValue, breakpointWrapper) {
if ( propGenArgs === void 0 ) propGenArgs = null;
if ( breakpointWrapper === void 0 ) breakpointWrapper = null;
var breakpointWrapperArgs = [], len = arguments.length - 3;
while ( len-- > 0 ) breakpointWrapperAr... | javascript | {
"resource": ""
} |
q28523 | CancelableEvent | train | function CancelableEvent (type, eventInit) {
if ( eventInit === void 0 ) eventInit = {};
Object.assign(this, CancelableEvent.defaults(), eventInit, { type: type });
Object.defineProperties(this, {
type: _makeCancelableEventProps(),
cancelable: _makeCancelableEventProps(... | javascript | {
"resource": ""
} |
q28524 | train | function () {
if (this$1._config.animation) {
var initConfigAnimation = this$1._config.animation || false;
if (getAttr(TPElement, 'x-placement') !== null) {
return
}
removeClass(TPElement, TP_STATE_CLASSES.FADE... | javascript | {
"resource": ""
} | |
q28525 | DOMObserver | train | function DOMObserver (el, callback, opts) {
if ( opts === void 0 ) opts = null;
if (opts === null) {
opts = {
subtree: true,
childList: true,
characterData: true,
attributes: true,
attributeFilter: ['class', 's... | javascript | {
"resource": ""
} |
q28526 | getUpdatedConfig | train | function getUpdatedConfig() {
var updatedConfig = Object.assign({}, this.baseConfig);
// override title if slot is used
if (this.$refs.title) {
updatedConfig.title = this.$refs.title;
updatedConfig.html = true;
}
... | javascript | {
"resource": ""
} |
q28527 | parseBindings | train | function parseBindings(bindings) {
var config = {};
switch (typeof bindings.value) {
case 'string':
case 'function':
config.title = bindings.value;
break
case 'object':
config = Object.assign({}, bindings.value);
... | javascript | {
"resource": ""
} |
q28528 | mergeDefaultOptions | train | function mergeDefaultOptions(opts) {
const copy = {};
copyKeys(copy, _defaultOptions);
copyKeys(copy, opts);
Object.keys(_defaultOptions).forEach((key) => {
const obj = _defaultOptions[key];
if (typeof obj === 'object') {
const objCopy = {};
copyKeys(objCopy, obj)... | javascript | {
"resource": ""
} |
q28529 | parseAttribute | train | function parseAttribute(attribute, defaultValue) {
// 1em, 1.0em, 0.1em, .1em, 1. em
const re = /^(-{0,1}\.{0,1}\d+(\.\d+)?)[\s|\.]*(\w*)$/;
if (attribute && re.test(attribute)) {
const match = re.exec(attribute);
const number = match[1];
const units = match[3] || 'px';
re... | javascript | {
"resource": ""
} |
q28530 | setHTML | train | function setHTML(container, content) {
if (container) {
// Clear out everything in the container
while (container.firstChild) {
container.removeChild(container.firstChild);
}
if (content) {
if (typeof content === 'string') {
container.innerHTML... | javascript | {
"resource": ""
} |
q28531 | toLatLng | train | function toLatLng(v) {
if (v !== undefined && v !== null) {
if (v instanceof google.maps.LatLng) {
return v;
} else if (v.lat !== undefined && v.lng !== undefined) {
return new google.maps.LatLng(v);
}
}
return null;
} | javascript | {
"resource": ""
} |
q28532 | applyCss | train | function applyCss(element, args) {
if (element && args) {
for (var i = 0; i < args.length; i++) {
var className = args[i];
if (className) {
if (element.className) {
... | javascript | {
"resource": ""
} |
q28533 | blueRadiosAT | train | function blueRadiosAT(command){
if (! wsclient.listeners('notification').length) {
console.log('subscribe to RX notification');
//listen for notification response
wsclient.on('notification', function(peripheralId, serviceUuid, characteristicUuid, data) {
// console.log("NOTIFICATION: " + data.toString('hex') +... | javascript | {
"resource": ""
} |
q28534 | dumpLog | train | function dumpLog(type, peripheralId, serviceUuid, uuid, data ){
var dumpFile=dumpPath + '/' + peripheralId + '.log';
if (servicesLookup[serviceUuid]) {
var serviceName = servicesLookup[serviceUuid].name;
var characteristicName = servicesLookup[serviceUuid].characteristics[uuid].name;
}
... | javascript | {
"resource": ""
} |
q28535 | formatUuid | train | function formatUuid(Uuid) {
var formatted='';
//expand short service/characteristic UUID
if (Uuid.length == 4) {
formatted='0000' + Uuid + '-0000-1000-8000-00805f9b34fb';
}
else { //just add dashes
formatted = Uuid.slice(0,8)+'-'+Uuid.slice(8,12)+'-'+Uuid.slice(12,16)+'-'+Uuid.slice(16,20)+'-'+Uuid.slice(20,3... | javascript | {
"resource": ""
} |
q28536 | lockCrc | train | function lockCrc(inputStr){
res = 0xff;
inputHex = new Buffer(inputStr,'hex');
//start from the second byte
for (i = 1; i<= inputHex.length; i++) {
res = res ^ inputHex[i];
}
//add padding
reshex = (res+0x100).toString(16).substr(-2);
// console.log(reshex);
return(inputStr+reshex);
} | javascript | {
"resource": ""
} |
q28537 | checkFile | train | function checkFile(peripheralId, callback) {
if (overWriteServices) {
callback(false);
} else {
fs.stat(devicesPath + '/' + peripheralId + '.srv.json', function(err, stat) {
if(err == null) {
callback(true);
// console.log('File exists');
} else {
callback(false)
}... | javascript | {
"resource": ""
} |
q28538 | readRaw | train | function readRaw(peripheralId, serviceUuid, uuid, callback){
//todo catch exceptions
var handle = servicesCache[peripheralId].services[serviceUuid].characteristics[uuid].handle;
var peripheral = peripherals[peripheralId];
//if not connected, connect
checkConnected(peripheral, function(){
peripheral.readH... | javascript | {
"resource": ""
} |
q28539 | writeRaw | train | function writeRaw(peripheralId, serviceUuid, uuid, data, withoutResponse, callback){
//todo catch exceptions
var handle = servicesCache[peripheralId].services[serviceUuid].characteristics[uuid].handle;
var peripheral = peripherals[peripheralId];
//if not connected, connect
checkConnected(peripheral, function... | javascript | {
"resource": ""
} |
q28540 | checkConnected | train | function checkConnected(peripheral, callback){
if (peripheral.state === 'connected') {
debug(' - connected');
if (callback) { callback(); }
} else if (peripheral.state === 'connecting'){
debug(' - connecting....');
//wait until the connection completes, invoke callback
peripheral.once('conne... | javascript | {
"resource": ""
} |
q28541 | index | train | function index(a, fn) {
let i, l;
for (i = 0, l = a.length; i < l; i++) {
if (fn(a[i]))
return i;
}
return -1;
} | javascript | {
"resource": ""
} |
q28542 | slice | train | function slice(array) {
const newArray = new Array(array.length);
let i,
l;
for (i = 0, l = array.length; i < l; i++)
newArray[i] = array[i];
return newArray;
} | javascript | {
"resource": ""
} |
q28543 | cloneRegexp | train | function cloneRegexp(re) {
const pattern = re.source;
let flags = '';
if (re.global) flags += 'g';
if (re.multiline) flags += 'm';
if (re.ignoreCase) flags += 'i';
if (re.sticky) flags += 'y';
if (re.unicode) flags += 'u';
return new RegExp(pattern, flags);
} | javascript | {
"resource": ""
} |
q28544 | cloner | train | function cloner(deep, item) {
if (!item ||
typeof item !== 'object' ||
item instanceof Error ||
item instanceof MonkeyDefinition ||
item instanceof Monkey ||
('ArrayBuffer' in global && item instanceof ArrayBuffer))
return item;
// Array
if (type.array(item)) {
if (deep) {
... | javascript | {
"resource": ""
} |
q28545 | compare | train | function compare(object, description) {
let ok = true,
k;
// If we reached here via a recursive call, object may be undefined because
// not all items in a collection will have the same deep nesting structure.
if (!object)
return false;
for (k in description) {
if (type.object(description[k]))... | javascript | {
"resource": ""
} |
q28546 | freezer | train | function freezer(deep, o) {
if (typeof o !== 'object' ||
o === null ||
o instanceof Monkey)
return;
Object.freeze(o);
if (!deep)
return;
if (Array.isArray(o)) {
// Iterating through the elements
let i,
l;
for (i = 0, l = o.length; i < l; i++)
deepFreeze(o[i]);
... | javascript | {
"resource": ""
} |
q28547 | makeSetter | train | function makeSetter(name, typeChecker) {
/**
* Binding a setter method to the Cursor class and having the following
* definition.
*
* Note: this is not really possible to make those setters variadic because
* it would create an impossible polymorphism with path.
*
* @todo: perform value validati... | javascript | {
"resource": ""
} |
q28548 | extendData | train | function extendData({
data,
lengthAngle: totalAngle,
totalValue,
paddingAngle,
}) {
const total = totalValue || sumValues(data);
const normalizedTotalAngle = valueBetween(totalAngle, -360, 360);
const numberOfPaddings =
Math.abs(normalizedTotalAngle) === 360 ? data.length : data.length - 1;
const de... | javascript | {
"resource": ""
} |
q28549 | train | function(req, res, next) {
if (req.headers.accept && req.headers.accept.startsWith('text/html')) {
req.url = '/index.html'; // eslint-disable-line no-param-reassign
}
next();
} | javascript | {
"resource": ""
} | |
q28550 | showPreset | train | function showPreset(name, pos){
console.log(_colors.magenta('Preset: ' + name));
// create a new progress bar with preset
var bar = new _progress.Bar({
align: pos
}, _progress.Presets[name] || _progress.Presets.legacy);
bar.start(200, 0);
// random value 1..200
bar.update(Math.floor((... | javascript | {
"resource": ""
} |
q28551 | getDateTime | train | function getDateTime(obj) {
// get date, hour, minute, second, year, month and day
var date = new Date()
, hour = date.getHours()
, min = date.getMinutes()
, sec = date.getSeconds()
, year = date.getFullYear()
, month = date.getMonth() + 1
, day = date.getDate()
;
... | javascript | {
"resource": ""
} |
q28552 | Openfile | train | function Openfile(i, path) {
// !Optimized: use child_process module to open local file with local path
(function() {
var cmdArr = [
'nautilus ' + path
, 'start "" "' + path + '"'
, 'konqueror ' + path
, 'o... | javascript | {
"resource": ""
} |
q28553 | parseGroupValue | train | function parseGroupValue(code, value) {
if(code <= 9) return value;
if(code >= 10 && code <= 59) return parseFloat(value);
if(code >= 60 && code <= 99) return parseInt(value);
if(code >= 100 && code <= 109) return value;
if(code >= 110 && code <= 149) return parseFloat(value);
if(code >= 160 && code <= 179) retur... | javascript | {
"resource": ""
} |
q28554 | getExtraTasks | train | async function getExtraTasks() {
config = config || (await getConfig());
switch (config.env) {
case 'pl':
extraTasks.patternLab = require('./pattern-lab-tasks');
break;
case 'static':
extraTasks.static = require('./static-tasks');
break;
case 'pwa':
delete require.cache[re... | javascript | {
"resource": ""
} |
q28555 | getFileHash | train | function getFileHash(filePath, callback) {
var stream = fs.ReadStream(filePath);
var md5sum = crypto.createHash('md5');
stream.on('data', function(data) {
md5sum.update(data);
});
stream.on('end', function() {
callback(md5sum.digest('hex'));
});
} | javascript | {
"resource": ""
} |
q28556 | mkDirs | train | async function mkDirs() {
config = config || (await getConfig());
try {
return Promise.all([
config.wwwDir ? mkdirp(config.wwwDir) : null,
config.dataDir ? mkdirp(config.dataDir) : null,
config.buildDir ? mkdirp(config.buildDir) : null,
]);
} catch (error) {
log.errorAndExit('Could ... | javascript | {
"resource": ""
} |
q28557 | setupServer | train | async function setupServer() {
return new Promise(async (resolve, reject) => {
config = config || (await getConfig());
config.components.individual = [];
config.prod = true;
config.enableCache = true;
config.mode = 'server';
config.env = 'pwa';
config.sourceMaps = false;
config.copy = ... | javascript | {
"resource": ""
} |
q28558 | receiveIframeMessage | train | function receiveIframeMessage(event) {
// does the origin sending the message match the current host? if not dev/null the request
if (
window.location.protocol !== 'file:' &&
event.origin !== window.location.protocol + '//' + window.location.host
) {
return;
}
let path;
let data = {};
try {
... | javascript | {
"resource": ""
} |
q28559 | buildWebpackEntry | train | async function buildWebpackEntry() {
const { components } = await getBoltManifest();
const entry = {};
const globalEntryName = 'bolt-global';
if (components.global) {
entry[globalEntryName] = [];
components.global.forEach(component => {
if (component.assets.style) {
entry... | javascript | {
"resource": ""
} |
q28560 | readYamlFile | train | function readYamlFile(file) {
return new Promise((resolve, reject) => {
readFile(file, 'utf8')
.then(data => resolve(fromYaml(data)))
.catch(reject);
});
} | javascript | {
"resource": ""
} |
q28561 | writeYamlFile | train | function writeYamlFile(file, data) {
return new Promise((resolve, reject) => {
writeFile(file, toYaml(data))
.then(resolve)
.catch(reject);
});
} | javascript | {
"resource": ""
} |
q28562 | generatePackageData | train | async function generatePackageData() {
boltPackages.forEach(async pkg => {
if (pkg.version !== '0.0.0' && pkg.private !== true) {
const name = pkg.name;
try {
const pkgInfo = await packageJson(name, {
allVersions: true,
});
processedPackages.push(pkgInfo);
nu... | javascript | {
"resource": ""
} |
q28563 | getPage | train | async function getPage(file) {
config = config || (await asyncConfig());
if (config.verbosity > 3) {
log.dim(`Getting info for: ${file}`);
}
const url = path
.relative(config.srcDir, file)
.replace('.md', '.html')
.split('/')
.map(x => x.replace(/^[0-9]*-/, '')) // Removing number prefix `0... | javascript | {
"resource": ""
} |
q28564 | getPages | train | async function getPages(srcDir) {
config = config || (await asyncConfig());
/** @type Array<String> */
const allPaths = await globby([
path.join(srcDir, '**/*.{md,html}'),
'!**/_*/**/*.{md,html}',
'!**/pattern-lab/**/*',
'!**/_*.{md,html}',
]);
return Promise.all(allPaths.map(getPage)).then(p... | javascript | {
"resource": ""
} |
q28565 | getSiteData | train | async function getSiteData(pages) {
config = config || (await asyncConfig());
const nestedPages = await getNestedPages(config.srcDir);
const site = {
nestedPages,
pages: pages.map(page => ({
url: page.url,
meta: page.meta,
// choosing not to have `page.body` in here on purpose
})),
... | javascript | {
"resource": ""
} |
q28566 | compile | train | async function compile(exitOnError = true) {
config = config || (await asyncConfig());
const startMessage = chalk.blue('Compiling Static Site...');
const startTime = timer.start();
let spinner;
if (config.verbosity > 2) {
console.log(startMessage);
} else {
spinner = ora(startMessage).start();
}
... | javascript | {
"resource": ""
} |
q28567 | init | train | async function init(keepAlive = false) {
state = STATES.STARTING;
const config = await getConfig();
const relativeFrom = path.dirname(config.configFileUsed);
// console.log({ config });
twigNamespaces = await getTwigNamespaceConfig(
relativeFrom,
config.extraTwigNamespaces,
);
twigRenderer = new T... | javascript | {
"resource": ""
} |
q28568 | render | train | async function render(template, data = {}, keepAlive = false) {
await prep(keepAlive);
const results = await twigRenderer.render(template, data);
return results;
} | javascript | {
"resource": ""
} |
q28569 | renderString | train | async function renderString(templateString, data = {}, keepAlive = false) {
await prep(keepAlive);
const results = await twigRenderer.renderString(templateString, data);
// console.log({ results });
return results;
} | javascript | {
"resource": ""
} |
q28570 | uniqueArray | train | function uniqueArray(item) {
const u = {};
const newArray = [];
for (let i = 0, l = item.length; i < l; ++i) {
if (!{}.hasOwnProperty.call(u, item[i])) {
newArray.push(item[i]);
u[item[i]] = 1;
}
}
return newArray;
} | javascript | {
"resource": ""
} |
q28571 | ensureFileExists | train | function ensureFileExists(filePath) {
fs.access(filePath, err => {
if (err) {
log.errorAndExit(
'This file ^^^ does not exist and it was referenced in package.json for that component, please make sure the file path is correct.',
filePath,
);
}
});
} | javascript | {
"resource": ""
} |
q28572 | dirExists | train | async function dirExists(path) {
try {
const stats = await stat(path);
return stats.isDirectory() ? true : false;
} catch (err) {
return false;
}
} | javascript | {
"resource": ""
} |
q28573 | execAndReport | train | async function execAndReport({ cmd, name }) {
try {
const {
failed,
// code,
// timedOut,
stdout,
stderr,
// message,
} = await execa.shell(cmd);
process.stdout.write(stdout);
process.stderr.write(stderr);
await setCheckRun({
name,
status: 'completed... | javascript | {
"resource": ""
} |
q28574 | sh | train | async function sh(
cmd,
args,
exitOnError,
streamOutput,
showCmdOnError = true,
exitImmediately = false,
) {
return new Promise((resolve, reject) => {
const child = execa(cmd, args);
let output = '';
if (streamOutput) {
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.... | javascript | {
"resource": ""
} |
q28575 | addNestedLevelProps | train | function addNestedLevelProps(childNode, level) {
let currentLevel = level;
if (childNode.tagName) {
childNode.level = currentLevel;
}
return currentLevel;
} | javascript | {
"resource": ""
} |
q28576 | updateConfig | train | async function updateConfig(options, programInstance) {
await configStore.updateConfig(config => {
originalConfig = config;
config.verbosity =
typeof program.verbosity === 'undefined'
? config.verbosity
: program.verbosity;
config.openServerAtStart =
... | javascript | {
"resource": ""
} |
q28577 | translateColor | train | function translateColor(colorArr, variationName, execMode) {
const [colorVar, alpha] = colorArr;
// returns the real color representation
if (!options.palette) {
options.palette = getColorPalette();
}
const underlineColor = options.palette[variationName][colorVar];
if (!underlineColor) {
// varia... | javascript | {
"resource": ""
} |
q28578 | processRules | train | function processRules(root) {
root.walkRules(rule => {
if (!hasThemify(rule.toString())) {
return;
}
let aggragatedSelectorsMap = {};
let aggragatedSelectors = [];
let createdRules = [];
const variationRules = {
[defaultVariation]: rule,
};
rule.walkDecls(decl => {
... | javascript | {
"resource": ""
} |
q28579 | createRuleWithVariation | train | function createRuleWithVariation(rule, variationName) {
const selector = getSelectorName(rule, variationName);
return postcss.rule({
selector,
});
} | javascript | {
"resource": ""
} |
q28580 | createFallbackRuleWithVariation | train | function createFallbackRuleWithVariation(rule, variationName) {
const selector = getSelectorName(rule, variationName, true);
return postcss.rule({
selector,
});
} | javascript | {
"resource": ""
} |
q28581 | getSelectorName | train | function getSelectorName(rule, variationName, isFallbackSelector = false) {
const selectorPrefix = `.${options.classPrefix || ''}${variationName}`;
// console.log(variationName);
if (isFallbackSelector) {
return rule.selectors
.map(selector => {
let selectors = [];
let initialSelector ... | javascript | {
"resource": ""
} |
q28582 | errorAndExit | train | function errorAndExit(msg, logMe) {
// @todo Only trigger if `verbosity > 1`
if (logMe) {
// Adding some empty lines before error message for readability
console.log();
console.log();
console.log(logMe);
}
error(`Error: ${msg}`);
// There's a few ways to handle exiting
// This is suggested... | javascript | {
"resource": ""
} |
q28583 | activateGumshoeLink | train | function activateGumshoeLink() {
const originalTarget = nav.nav;
let originalTargetHref;
let normalizedTarget;
if (originalTarget) {
originalTargetHref = originalTarget.getAttribute('href');
} else {
originalTargetHref = nav.nav.ge... | javascript | {
"resource": ""
} |
q28584 | flattenDeep | train | function flattenDeep(arr1) {
return arr1.reduce(
(acc, val) =>
Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val),
[],
);
} | javascript | {
"resource": ""
} |
q28585 | aggregateBoltDependencies | train | async function aggregateBoltDependencies(data) {
let componentDependencies = [];
let componentsWithoutDeps = data;
componentsWithoutDeps.forEach(item => {
if (item.deps) {
componentDependencies.push([...item.deps]);
}
});
componentDependencies = flattenDeep(componentDependencies);
component... | javascript | {
"resource": ""
} |
q28586 | getAllDirs | train | async function getAllDirs(relativeFrom) {
const dirs = [];
const manifest = await getBoltManifest();
[manifest.components.global, manifest.components.individual].forEach(
componentList => {
componentList.forEach(component => {
dirs.push(
relativeFrom
? path.relative(relativ... | javascript | {
"resource": ""
} |
q28587 | getTwigNamespaceConfig | train | async function getTwigNamespaceConfig(relativeFrom, extraNamespaces = {}) {
const config = await getConfig();
const namespaces = {};
const allDirs = [];
const manifest = await getBoltManifest();
const global = manifest.components.global;
const individual = manifest.components.individual;
[global, individ... | javascript | {
"resource": ""
} |
q28588 | Socket | train | function Socket(options) {
if (!(this instanceof Socket)) {
return new Socket(options);
}
var tty = process.binding('tty_wrap');
var guessHandleType = tty.guessHandleType;
tty.guessHandleType = function() {
return 'PIPE';
};
net.Socket.call(this, options);
tty.guessHandleType = guessHandleType;
... | javascript | {
"resource": ""
} |
q28589 | Agent | train | function Agent(file, args, env, cwd, cols, rows, debug) {
var self = this;
// Increment the number of pipes created.
pipeIncr++;
// Unique identifier per pipe created.
var timestamp = Date.now();
// The data pipe is the direct connection to the forked terminal.
this.dataPipe = '\\\\.\\pipe\\winpty-data... | javascript | {
"resource": ""
} |
q28590 | isWildcardRange | train | function isWildcardRange(range, constraints) {
if (range instanceof Array && !range.length) {
return false;
}
if (constraints.length !== 2) {
return false;
}
return range.length === (constraints[1] - (constraints[0] < 1 ? - 1 : 0));
} | javascript | {
"resource": ""
} |
q28591 | CronExpression | train | function CronExpression (fields, options) {
this._options = options;
this._utc = options.utc || false;
this._tz = this._utc ? 'UTC' : options.tz;
this._currentDate = new CronDate(options.currentDate, this._tz);
this._startDate = options.startDate ? new CronDate(options.startDate, this._tz) : null;
this._end... | javascript | {
"resource": ""
} |
q28592 | parseRepeat | train | function parseRepeat (val) {
var repeatInterval = 1;
var atoms = val.split('/');
if (atoms.length > 1) {
return parseRange(atoms[0], atoms[atoms.length - 1]);
}
return parseRange(val, repeatInterval);
} | javascript | {
"resource": ""
} |
q28593 | matchSchedule | train | function matchSchedule (value, sequence) {
for (var i = 0, c = sequence.length; i < c; i++) {
if (sequence[i] >= value) {
return sequence[i] === value;
}
}
return sequence[0] === value;
} | javascript | {
"resource": ""
} |
q28594 | isNthDayMatch | train | function isNthDayMatch(date, nthDayOfWeek) {
if (nthDayOfWeek < 6) {
if (
date.getDate() < 8 &&
nthDayOfWeek === 1 // First occurence has to happen in first 7 days of the month
) {
return true;
}
var offset = date.getDate() % 7 ? 1 : 0; // Math is off by 1 when dayOf... | javascript | {
"resource": ""
} |
q28595 | train | function(){
// Update the next frame
updateId = requestAnimationFrame(update);
var now = Date.now();
if (emitter)
emitter.update((now - elapsed) * 0.001);
framerate.innerHTML = (1000 / (now - elapsed)).toFixed(2);
elapsed = now;
if(emitter && particleCount)
particleCount.innerHTML = em... | javascript | {
"resource": ""
} | |
q28596 | train | function(a, b) {
a = a.trim().toLowerCase();
b = b.trim().toLowerCase();
if (a === b) return 0;
if (a < b) return 1;
return -1;
} | javascript | {
"resource": ""
} | |
q28597 | train | function(sort, antiStabilize) {
return function(a, b) {
var unstableResult = sort(a.td, b.td);
if (unstableResult === 0) {
if (antiStabilize) return b.index - a.index;
return a.index - b.index;
}
return unstableResult;
};
} | javascript | {
"resource": ""
} | |
q28598 | extendContext | train | function extendContext(context, opts) {
Object.defineProperties(context, {
[CONTEXT_SESSION]: {
get() {
if (this[_CONTEXT_SESSION]) return this[_CONTEXT_SESSION];
this[_CONTEXT_SESSION] = new ContextSession(this, opts);
return this[_CONTEXT_SESSION];
},
enumerable: true
... | javascript | {
"resource": ""
} |
q28599 | Router | train | function Router(opts) {
if (!(this instanceof Router)) {
return new Router(opts);
}
this.opts = opts || {};
this.methods = this.opts.methods || [
'HEAD',
'OPTIONS',
'GET',
'PUT',
'PATCH',
'POST',
'DELETE'
];
this.params = {};
this.stack = [];
this.MATCHS = {};
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.