_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q17600 | fixAcornEsmImport | train | function fixAcornEsmImport() {
return {
name: 'fix-acorn-esm-import',
renderChunk(code, chunk, options) {
if (/esm?/.test(options.format)) {
let found = false;
const fixedCode = code.replace(expectedAcornImport, () => {
found = true;
return newAcornImport;
});
if (!found) {
this.e... | javascript | {
"resource": ""
} |
q17601 | parseIpfsPath | train | function parseIpfsPath (ipfsPath) {
const invalidPathErr = new Error('invalid ipfs ref path')
ipfsPath = ipfsPath.replace(/^\/ipfs\//, '')
const matched = ipfsPath.match(/([^/]+(?:\/[^/]+)*)\/?$/)
if (!matched) {
throw invalidPathErr
}
const [hash, ...links] = matched[1].split('/')
// check that a C... | javascript | {
"resource": ""
} |
q17602 | follow | train | function follow (cid, links, err, obj) {
if (err) {
return cb(err)
}
if (!links.length) {
// done tracing, obj is the target node
return cb(null, cid.buffer)
}
const linkName = links[0]
const nextObj = obj.links.find(link => link.name === linkName)
if ... | javascript | {
"resource": ""
} |
q17603 | parseRabinString | train | function parseRabinString (chunker) {
const options = {}
const parts = chunker.split('-')
switch (parts.length) {
case 1:
options.avgChunkSize = 262144
break
case 2:
options.avgChunkSize = parseChunkSize(parts[1], 'avg')
break
case 4:
options.minChunkSize = parseChunkSize... | javascript | {
"resource": ""
} |
q17604 | resolve | train | function resolve (cid, path, callback) {
let value, remainderPath
doUntil(
(cb) => {
self.block.get(cid, (err, block) => {
if (err) return cb(err)
const r = self._ipld.resolvers[cid.codec]
if (!r) {
return cb(new Error(`No resolver found for codec "${cid... | javascript | {
"resource": ""
} |
q17605 | train | function(doc) {
// Heuristic for the custom docs in the lib/selenium-webdriver/ folder.
if (doc.name && doc.name.startsWith('webdriver')) {
return;
}
var template = _.template('https://github.com/angular/protractor/blob/' +
'<%= linksHash %>/lib/<%= fileName %>.ts');
doc.sourceLink = template({
... | javascript | {
"resource": ""
} | |
q17606 | train | function(str, doc) {
var oldStr = null;
while (str != oldStr) {
oldStr = str;
var matches = /{\s*@link[plain]*\s+([^]+?)\s*}/.exec(str);
if (matches) {
var str = str.replace(
new RegExp('{\\s*@link[plain]*\\s+' +
matches[1].replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '\\s*}... | javascript | {
"resource": ""
} | |
q17607 | train | function(param) {
var str = param.typeExpression;
var type = param.type;
if (!type) {
return escape(str);
}
var replaceWithLinkIfPresent = function(type) {
if (type.name) {
str = str.replace(type.name, toMarkdownLinkFormat(type.name));
}
};
if (type.type === 'FunctionType') {
_.eac... | javascript | {
"resource": ""
} | |
q17608 | train | function(item) {
var parts = item.displayName.split('.');
for (var i = parts.length - 1; i > 0; i--) {
var name = parts.slice(0, i).join('.');
if (itemsByName[name]) {
return itemsByName[name];
}
}
} | javascript | {
"resource": ""
} | |
q17609 | train | function(doc) {
// Skip if the function has a name.
if (doc.name) {
return doc.name;
}
try {
var node = doc.codeNode;
// Is this a simple declaration? "var element = function() {".
if (node.declarations && node.declarations.length) {
return node.declarations[0].id.name;
}
// Is ... | javascript | {
"resource": ""
} | |
q17610 | buildName | train | function buildName(obj) {
if (!obj) {
return parts.join('.');
}
if (obj.property && obj.property.name) {
parts.unshift(obj.property.name);
}
if (obj.object && obj.object.name) {
parts.unshift(obj.object.name);
}
return buildName(ob... | javascript | {
"resource": ""
} |
q17611 | train | function(doc) {
if (doc.params) {
_.each(doc.params, function(param) {
replaceNewLines(param, 'description');
});
}
// Replace new lines in the return and params descriptions.
var returns = doc.returns;
if (returns) {
replaceNewLines(returns, 'description');
}
} | javascript | {
"resource": ""
} | |
q17612 | train | function(callback) {
if (window.angular) {
var hooks = getNg1Hooks(rootSelector);
if (!hooks){
callback(); // not an angular1 app
}
else{
if (hooks.$$testability) {
hooks.$$testability.whenStable(callback);
} else if (hooks.$injector) {
... | javascript | {
"resource": ""
} | |
q17613 | train | function() {
if (window.getAngularTestability) {
if (rootSelector) {
var testability = null;
var el = document.querySelector(rootSelector);
try{
testability = window.getAngularTestability(el);
}
catch(e){}
if (testability) {
... | javascript | {
"resource": ""
} | |
q17614 | findRepeaterRows | train | function findRepeaterRows(repeater, exact, index, using) {
using = using || document;
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
var rows = [];
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat';
var repeatElems = using.querySelectorAll('[' + attr + ']');
... | javascript | {
"resource": ""
} |
q17615 | findAllRepeaterRows | train | function findAllRepeaterRows(repeater, exact, using) {
using = using || document;
var rows = [];
var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
for (var p = 0; p < prefixes.length; ++p) {
var attr = prefixes[p] + 'repeat';
var repeatElems = using.querySelectorAll('[' + attr + ']');
at... | javascript | {
"resource": ""
} |
q17616 | _convertUnicode | train | function _convertUnicode(originalStr) {
let m;
let c;
let cStr;
let lastI = 0;
// Matches \u#### but not \\u####
const unicodeRegex = /\\u[0-9a-fA-F]{4}/g;
let convertedStr = '';
while ((m = unicodeRegex.exec(originalStr))) {
// Don't convert if the backslash itself is escaped
if (originalStr[... | javascript | {
"resource": ""
} |
q17617 | parseEndpoints | train | function parseEndpoints(document) {
const defaultParent = WORKSPACE_ID;
const paths = Object.keys(document.paths);
const endpointsSchemas = paths
.map(path => {
const schemasPerMethod = document.paths[path];
const methods = Object.keys(schemasPerMethod);
return methods
.filter(meth... | javascript | {
"resource": ""
} |
q17618 | importRequest | train | function importRequest(endpointSchema, id, parentId) {
const name = endpointSchema.summary || `${endpointSchema.method} ${endpointSchema.path}`;
return {
_type: 'request',
_id: id,
parentId: parentId,
name,
method: endpointSchema.method.toUpperCase(),
url: '{{ base_url }}' + pathWithParamsAs... | javascript | {
"resource": ""
} |
q17619 | prepareQueryParams | train | function prepareQueryParams(endpointSchema) {
const isSendInQuery = p => p.in === 'query';
const parameters = endpointSchema.parameters || [];
const queryParameters = parameters.filter(isSendInQuery);
return convertParameters(queryParameters);
} | javascript | {
"resource": ""
} |
q17620 | prepareHeaders | train | function prepareHeaders(endpointSchema) {
const isSendInHeader = p => p.in === 'header';
const parameters = endpointSchema.parameters || [];
const headerParameters = parameters.filter(isSendInHeader);
return convertParameters(headerParameters);
} | javascript | {
"resource": ""
} |
q17621 | convertParameters | train | function convertParameters(parameters) {
return parameters.map(parameter => {
const { required, name } = parameter;
return {
name,
disabled: required !== true,
value: `${generateParameterExample(parameter)}`,
};
});
} | javascript | {
"resource": ""
} |
q17622 | replaceHintMatch | train | function replaceHintMatch(cm, self, data) {
const cur = cm.getCursor();
const from = CodeMirror.Pos(cur.line, cur.ch - data.segment.length);
const to = CodeMirror.Pos(cur.line, cur.ch);
const prevStart = CodeMirror.Pos(from.line, from.ch - 10);
const prevChars = cm.getRange(prevStart, from);
const nextEnd... | javascript | {
"resource": ""
} |
q17623 | matchSegments | train | function matchSegments(listOfThings, segment, type, limit = -1) {
if (!Array.isArray(listOfThings)) {
console.warn('Autocomplete received items in non-list form', listOfThings);
return [];
}
const matches = [];
for (const t of listOfThings) {
const name = typeof t === 'string' ? t : t.name;
con... | javascript | {
"resource": ""
} |
q17624 | replaceWithSurround | train | function replaceWithSurround(text, find, prefix, suffix) {
const escapedString = escapeRegex(find);
const re = new RegExp(escapedString, 'gi');
return text.replace(re, matched => prefix + matched + suffix);
} | javascript | {
"resource": ""
} |
q17625 | renderHintMatch | train | function renderHintMatch(li, self, data) {
// Bold the matched text
const { displayText, segment } = data;
const markedName = replaceWithSurround(displayText, segment, '<strong>', '</strong>');
const { char, title } = ICONS[data.type];
const safeValue = escapeHTML(data.displayValue);
li.className += ` fan... | javascript | {
"resource": ""
} |
q17626 | _getResourceGroupSymmetricKey | train | async function _getResourceGroupSymmetricKey(resourceGroupId) {
let key = resourceGroupSymmetricKeysCache[resourceGroupId];
if (!key) {
const resourceGroup = await fetchResourceGroup(resourceGroupId);
const accountPrivateKey = await session.getPrivateKey();
const symmetricKeyStr = crypt.decryptRSAWith... | javascript | {
"resource": ""
} |
q17627 | _pbkdf2Passphrase | train | async function _pbkdf2Passphrase(passphrase, salt) {
if (window.crypto && window.crypto.subtle) {
console.log('[crypt] Using native PBKDF2');
const k = await window.crypto.subtle.importKey(
'raw',
Buffer.from(passphrase, 'utf8'),
{ name: 'PBKDF2' },
false,
['deriveBits'],
);... | javascript | {
"resource": ""
} |
q17628 | getAllDocs | train | async function getAllDocs() {
// Restore docs in parent->child->grandchild order
const allDocs = [
...(await models.settings.all()),
...(await models.workspace.all()),
...(await models.workspaceMeta.all()),
...(await models.environment.all()),
...(await models.cookieJar.all()),
...(await mod... | javascript | {
"resource": ""
} |
q17629 | addNativeNodeListener | train | function addNativeNodeListener (node, eventName, handler) {
if (isNullOrUndefined(node.data.on)) {
node.data.on = {};
}
mergeVNodeListeners(node.data.on, eventName, handler);
} | javascript | {
"resource": ""
} |
q17630 | addComponentNodeListener | train | function addComponentNodeListener (node, eventName, handler) {
/* istanbul ignore next */
if (!node.componentOptions.listeners) {
node.componentOptions.listeners = {};
}
mergeVNodeListeners(node.componentOptions.listeners, eventName, handler);
} | javascript | {
"resource": ""
} |
q17631 | shouldValidate | train | function shouldValidate (ctx, model) {
// when an immediate/initial validation is needed and wasn't done before.
if (!ctx._ignoreImmediate && ctx.immediate) {
return true;
}
// when the value changes for whatever reason.
if (ctx.value !== model.value) {
return true;
}
// when it needs validation... | javascript | {
"resource": ""
} |
q17632 | addListeners | train | function addListeners (node) {
const model = findModel(node);
// cache the input eventName.
this._inputEventName = this._inputEventName || getInputEventName(node, model);
onRenderUpdate.call(this, model);
const { onInput, onBlur, onValidate } = createCommonHandlers(this);
addVNodeListener(node, this._inpu... | javascript | {
"resource": ""
} |
q17633 | train | function() {
// UI initialized, it is OK to cancel last operation.
self.initialized_ = true;
// retrieve is only called if auto sign-in is enabled. Otherwise, it will
// get skipped.
var retrieveCredential = Promise.resolve(null);
if (!autoSignInDisabled) {
retrieveCredential... | javascript | {
"resource": ""
} | |
q17634 | train | function(resp, opt_error) {
if (resp && resp['account'] && opt_onAccountSelected) {
opt_onAccountSelected(
firebaseui.auth.Account.fromPlainObject(resp['account']));
} else if (opt_onAddAccount) {
// Check if accountchooser.com is available and pass to add account.
var isUnavailable ... | javascript | {
"resource": ""
} | |
q17635 | train | function(done, fail, tries) {
// The default retrial policy.
if (typeof tries === 'undefined') {
tries = FLAKY_TEST_RETRIAL;
}
// executeScript runs the passed method in the "window" context of
// the current test. JSUnit exposes hooks into the test's status through
// the "G_testRunner" g... | javascript | {
"resource": ""
} | |
q17636 | train | function(isAvailable) {
var app = getApp();
if (!app) {
return;
}
firebaseui.auth.widget.handler.common.handleAcAddAccountResponse_(
isAvailable, app, container, uiShownCallback);
} | javascript | {
"resource": ""
} | |
q17637 | train | function(error) {
// Ignore error if cancelled by the client.
if (error['name'] && error['name'] == 'cancel') {
return;
}
// Check if the error was due to an expired credential.
// This may happen in the email mismatch case where the user waits more
// than an hour and then proceeds to sig... | javascript | {
"resource": ""
} | |
q17638 | train | function(error) {
// Clear pending redirect status if redirect on Cordova fails.
firebaseui.auth.storage.removePendingRedirectStatus(app.getAppId());
// Ignore error if cancelled by the client.
if (error['name'] && error['name'] == 'cancel') {
return;
}
switch (error['code']) {
case ... | javascript | {
"resource": ""
} | |
q17639 | train | function() {
firebaseui.auth.storage.setPendingRedirectStatus(app.getAppId());
app.registerPending(component.executePromiseRequest(
/** @type {function (): !goog.Promise} */ (
goog.bind(app.startSignInWithRedirect, app)),
[provider],
function() {
// Only run below l... | javascript | {
"resource": ""
} | |
q17640 | train | function(firebaseCredential) {
var status = false;
var p = component.executePromiseRequest(
/** @type {function (): !goog.Promise} */ (
goog.bind(app.startSignInWithCredential, app)),
[firebaseCredential],
function(result) {
var container = component.getContainer();... | javascript | {
"resource": ""
} | |
q17641 | train | function(providerId, opt_email) {
// If popup flow enabled, this will fail and fallback to redirect.
// TODO: Optimize to force redirect mode only.
// For non-Google providers (not supported yet). This may end up signing the
// user with a provider using different email. Even for Google, a user can
... | javascript | {
"resource": ""
} | |
q17642 | compile | train | function compile(srcs, out, args) {
// Get the compiler arguments, using the defaults if not specified.
const combinedArgs = Object.assign({}, COMPILER_DEFAULT_ARGS, args);
return gulp
.src(srcs)
.pipe(closureCompiler({
compilerPath: COMPILER_PATH,
fileName: path.basename(out),
... | javascript | {
"resource": ""
} |
q17643 | repeatTaskForAllLocales | train | function repeatTaskForAllLocales(taskName, dependencies, operation) {
return ALL_LOCALES.map((locale) => {
// Convert build-js-$ to build-js-fr, for example.
const replaceTokens = (name) => name.replace(/\$/g, locale);
const localeTaskName = replaceTokens(taskName);
const localeDependencies = dependen... | javascript | {
"resource": ""
} |
q17644 | buildFirebaseUiJs | train | function buildFirebaseUiJs(locale) {
const flags = {
closure_entry_point: 'firebaseui.auth.exports',
define: `goog.LOCALE='${locale}'`,
externs: [
'node_modules/firebase/externs/firebase-app-externs.js',
'node_modules/firebase/externs/firebase-auth-externs.js',
'node_modules/firebase/ext... | javascript | {
"resource": ""
} |
q17645 | concatWithDeps | train | function concatWithDeps(locale, outBaseName, outputWrapper) {
const localeForFileName = getLocaleForFileName(locale);
// Get a list of the FirebaseUI JS and its dependencies.
const srcs = JS_DEPS.concat([getTmpJsPath(locale)]);
const outputPath = `${DEST_DIR}/${outBaseName}__${localeForFileName}.js`;
return c... | javascript | {
"resource": ""
} |
q17646 | buildCss | train | function buildCss(isRtl) {
const mdlSrcs = gulp.src('stylesheet/mdl.scss')
.pipe(sass.sync().on('error', sass.logError))
.pipe(cssInlineImages({
webRoot: 'node_modules/material-design-lite/src',
}));
const dialogPolyfillSrcs = gulp.src(
'node_modules/dialog-polyfill/dialog-polyfill.c... | javascript | {
"resource": ""
} |
q17647 | loadRecaptcha | train | function loadRecaptcha(container) {
var root = goog.dom.getElement(container);
var recaptchaContainer =
goog.dom.getElementByClass('firebaseui-recaptcha-container', root);
recaptchaContainer.style.display = 'block';
var img = goog.dom.createElement('img');
img.src = '../image/test/recaptcha-widget.png';... | javascript | {
"resource": ""
} |
q17648 | train | function() {
firebaseui.auth.widget.handler.common.sendEmailLinkForSignIn(
app,
component,
email,
onCancelClick,
function(error) {
// The email provided could be an invalid one or some other error
// could occur.
... | javascript | {
"resource": ""
} | |
q17649 | assertIsDirectory | train | function assertIsDirectory(path) {
try {
if (!fs.lstatSync(path).isDirectory()) {
console.log('Path "' + path + '" is not a directory.');
process.exit();
}
} catch (e) {
console.log('Directory "' + path + '" could not be found.');
process.exit();
}
} | javascript | {
"resource": ""
} |
q17650 | train | function() {
var errorMessage =
firebaseui.auth.widget.handler.common.getErrorMessage(emailExistsError);
firebaseui.auth.ui.element.setValid(component.getEmailElement(), false);
firebaseui.auth.ui.element.show(
component.getEmailErrorElement(), errorMessage);
component.getEmailElement().... | javascript | {
"resource": ""
} | |
q17651 | train | function(phoneAuthResult) {
// Display the dialog that the code was sent.
var container = component.getContainer();
component.showProgressDialog(
firebaseui.auth.ui.element.progressDialog.State.DONE,
firebaseui.auth.soy2.strings.dialogCodeSent().toString());
// Ke... | javascript | {
"resource": ""
} | |
q17652 | getUiConfig | train | function getUiConfig() {
return {
'callbacks': {
// Called when the user has been successfully signed in.
'signInSuccessWithAuthResult': function(authResult, redirectUrl) {
if (authResult.user) {
handleSignedInUser(authResult.user);
}
if (authResult.additionalUserInfo... | javascript | {
"resource": ""
} |
q17653 | train | function(authResult, redirectUrl) {
if (authResult.user) {
handleSignedInUser(authResult.user);
}
if (authResult.additionalUserInfo) {
document.getElementById('is-new-user').textContent =
authResult.additionalUserInfo.isNewUser ?
'New User' : 'Exis... | javascript | {
"resource": ""
} | |
q17654 | train | function(user) {
document.getElementById('user-signed-in').style.display = 'block';
document.getElementById('user-signed-out').style.display = 'none';
document.getElementById('name').textContent = user.displayName;
document.getElementById('email').textContent = user.email;
document.getElementById('phone').tex... | javascript | {
"resource": ""
} | |
q17655 | train | function() {
document.getElementById('user-signed-in').style.display = 'none';
document.getElementById('user-signed-out').style.display = 'block';
ui.start('#firebaseui-container', getUiConfig());
} | javascript | {
"resource": ""
} | |
q17656 | train | function() {
firebase.auth().currentUser.delete().catch(function(error) {
if (error.code == 'auth/requires-recent-login') {
// The user's credential is too old. She needs to sign in again.
firebase.auth().signOut().then(function() {
// The timeout allows the message to be displayed after the U... | javascript | {
"resource": ""
} | |
q17657 | handleConfigChange | train | function handleConfigChange() {
var newRecaptchaValue = document.querySelector(
'input[name="recaptcha"]:checked').value;
var newEmailSignInMethodValue = document.querySelector(
'input[name="emailSignInMethod"]:checked').value;
location.replace(
location.pathname + '#recaptcha=' + newRecaptchaVa... | javascript | {
"resource": ""
} |
q17658 | train | function() {
document.getElementById('sign-in-with-redirect').addEventListener(
'click', signInWithRedirect);
document.getElementById('sign-in-with-popup').addEventListener(
'click', signInWithPopup);
document.getElementById('sign-out').addEventListener('click', function() {
firebase.auth().signOu... | javascript | {
"resource": ""
} | |
q17659 | train | function() {
var email = component.checkAndGetEmail();
if (!email) {
component.getEmailElement().focus();
return;
}
component.dispose();
onContinue(app, container, email, link);
} | javascript | {
"resource": ""
} | |
q17660 | train | function() {
component.dispose();
// Render previous phone sign in start page.
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.PHONE_SIGN_IN_START, app,
container, phoneNumberValue);
} | javascript | {
"resource": ""
} | |
q17661 | train | function(userCredential) {
component.dismissDialog();
// Show code verified dialog.
component.showProgressDialog(
firebaseui.auth.ui.element.progressDialog.State.DONE,
firebaseui.auth.soy2.strings.dialogCodeVerified().toString());
// Keep on display for long enoug... | javascript | {
"resource": ""
} | |
q17662 | train | function(error) {
if (error['name'] && error['name'] == 'cancel') {
// Close dialog.
component.dismissDialog();
return;
}
// Get error message.
var errorMessage =
firebaseui.auth.widget.handler.common.getErrorMessage(error);
// Some error... | javascript | {
"resource": ""
} | |
q17663 | markChangesSweep | train | function markChangesSweep(drafts) {
// The natural order of drafts in the `scope` array is based on when they
// were accessed. By processing drafts in reverse natural order, we have a
// better chance of processing leaf nodes first. When a leaf node is known to
// have changed, we can avoid any travers... | javascript | {
"resource": ""
} |
q17664 | clone | train | function clone (obj, parent) {
let cloned = new obj.constructor()
for (let i of Object.keys(obj || {})) {
let value = obj[i]
if (i === 'parent' && typeof value === 'object') {
if (parent) {
cloned[i] = parent
}
} else if (i === 'source' || i === null) {
cloned[i] = value
}... | javascript | {
"resource": ""
} |
q17665 | f | train | function f (data, opts, callback) {
data = unpack(data)
if (!callback) {
[callback, opts] = [opts, {}]
}
let match = opts.match || /\sx($|\s)/
let need = []
for (let browser in data.stats) {
let versions = data.stats[browser]
for (let version in versions) {
let support = versions[versio... | javascript | {
"resource": ""
} |
q17666 | getMSDecls | train | function getMSDecls (area, addRowSpan = false, addColumnSpan = false) {
return [].concat(
{
prop: '-ms-grid-row',
value: String(area.row.start)
},
(area.row.span > 1 || addRowSpan) ? {
prop: '-ms-grid-row-span',
value: String(area.row.span)
} : [],
{
prop: '-ms-grid-c... | javascript | {
"resource": ""
} |
q17667 | changeDuplicateAreaSelectors | train | function changeDuplicateAreaSelectors (ruleSelectors, templateSelectors) {
ruleSelectors = ruleSelectors.map(selector => {
let selectorBySpace = list.space(selector)
let selectorByComma = list.comma(selector)
if (selectorBySpace.length > selectorByComma.length) {
selector = selectorBySpace.slice(-1... | javascript | {
"resource": ""
} |
q17668 | selectorsEqual | train | function selectorsEqual (ruleA, ruleB) {
return ruleA.selectors.some(sel => {
return ruleB.selectors.some(s => s === sel)
})
} | javascript | {
"resource": ""
} |
q17669 | warnMissedAreas | train | function warnMissedAreas (areas, decl, result) {
let missed = Object.keys(areas)
decl.root().walkDecls('grid-area', gridArea => {
missed = missed.filter(e => e !== gridArea.value)
})
if (missed.length > 0) {
decl.warn(result, 'Can not find grid areas: ' + missed.join(', '))
}
return undefined
} | javascript | {
"resource": ""
} |
q17670 | shouldInheritGap | train | function shouldInheritGap (selA, selB) {
let result
// get arrays of selector split in 3-deep array
let splitSelectorArrA = splitSelector(selA)
let splitSelectorArrB = splitSelector(selB)
if (splitSelectorArrA[0].length < splitSelectorArrB[0].length) {
// abort if selectorA has lower descendant specific... | javascript | {
"resource": ""
} |
q17671 | inheritGridGap | train | function inheritGridGap (decl, gap) {
let rule = decl.parent
let mediaRule = getParentMedia(rule)
let root = rule.root()
// get an array of selector split in 3-deep array
let splitSelectorArr = splitSelector(rule.selector)
// abort if the rule already has gaps
if (Object.keys(gap).length > 0) {
retu... | javascript | {
"resource": ""
} |
q17672 | autoplaceGridItems | train | function autoplaceGridItems (decl, result, gap, autoflowValue = 'row') {
let { parent } = decl
let rowDecl = parent.nodes.find(i => i.prop === 'grid-template-rows')
let rows = normalizeRowColumn(rowDecl.value)
let columns = normalizeRowColumn(decl.value)
// Build array of area names with dummy values. If we... | javascript | {
"resource": ""
} |
q17673 | substitutePreCodeTags | train | function substitutePreCodeTags (doc) {
var pres = doc.querySelectorAll('pre'),
presPH = [];
for (var i = 0; i < pres.length; ++i) {
if (pres[i].childElementCount === 1 && pres[i].firstChild.tagName.toLowerCase() === 'code') {
var content = pres[i].firstChild.innerHTML.trim(),
... | javascript | {
"resource": ""
} |
q17674 | train | function() {
return new Promise(function(resolve, reject) {
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
user.getIdToken().then(function(idToken) {
resolve(idToken);
}, function(error) {
resolve(null);
});
} else {
resolve(null);
... | javascript | {
"resource": ""
} | |
q17675 | runTypedoc | train | function runTypedoc() {
const typeSource = apiType === 'node' ? tempNodeSourcePath : sourceFile;
const command = `${repoPath}/node_modules/.bin/typedoc ${typeSource} \
--out ${docPath} \
--readme ${tempHomePath} \
--options ${__dirname}/typedoc.js \
--theme ${__dirname}/theme`;
console.log('Running comma... | javascript | {
"resource": ""
} |
q17676 | moveFilesToRoot | train | function moveFilesToRoot(subdir) {
return exec(`mv ${docPath}/${subdir}/* ${docPath}`)
.then(() => {
exec(`rmdir ${docPath}/${subdir}`);
})
.catch(e => console.error(e));
} | javascript | {
"resource": ""
} |
q17677 | fixLinks | train | function fixLinks(file) {
return fs.readFile(file, 'utf8').then(data => {
const flattenedLinks = data
.replace(/\.\.\//g, '')
.replace(/(modules|interfaces|classes)\//g, '');
let caseFixedLinks = flattenedLinks;
for (const lower in lowerToUpperLookup) {
const re = new RegExp(lower, 'g');... | javascript | {
"resource": ""
} |
q17678 | generateTempHomeMdFile | train | function generateTempHomeMdFile(tocRaw, homeRaw) {
const { toc } = yaml.safeLoad(tocRaw);
let tocPageLines = [homeRaw, '# API Reference'];
toc.forEach(group => {
tocPageLines.push(`\n## [${group.title}](${stripPath(group.path)}.html)`);
group.section.forEach(item => {
tocPageLines.push(`- [${item.ti... | javascript | {
"resource": ""
} |
q17679 | checkForMissingFilesAndFixFilenameCase | train | function checkForMissingFilesAndFixFilenameCase() {
// Get filenames from toc.yaml.
const filenames = tocText
.split('\n')
.filter(line => line.includes('path:'))
.map(line => line.split(devsitePath)[1]);
// Logs warning to console if a file from TOC is not found.
const fileCheckPromises = filenames... | javascript | {
"resource": ""
} |
q17680 | writeGeneratedFileList | train | function writeGeneratedFileList(htmlFiles) {
const fileList = htmlFiles.map(filename => {
return {
title: filename,
path: `${devsitePath}${filename}`
};
});
const generatedTocYAML = yaml.safeDump({ toc: fileList });
return fs
.writeFile(`${docPath}/_toc_autogenerated.yaml`, generatedTocY... | javascript | {
"resource": ""
} |
q17681 | fixAllLinks | train | function fixAllLinks(htmlFiles) {
const writePromises = [];
htmlFiles.forEach(file => {
// Update links in each html file to match flattened file structure.
writePromises.push(fixLinks(`${docPath}/${file}.html`));
});
return Promise.all(writePromises);
} | javascript | {
"resource": ""
} |
q17682 | generateNodeSource | train | async function generateNodeSource() {
const sourceText = await fs.readFile(sourceFile, 'utf8');
// Parse index.d.ts. A dummy filename is required but it doesn't create a
// file.
let typescriptSourceFile = typescript.createSourceFile(
'temp.d.ts',
sourceText,
typescript.ScriptTarget.ES2015,
/*s... | javascript | {
"resource": ""
} |
q17683 | train | function() {
// Remove current resume listener.
if (onResume) {
doc.removeEventListener('resume', onResume, false);
}
// Remove visibility change listener.
if (onVisibilityChange) {
doc.removeEventListener('visibilitychange', onVisibilityChange, false);
}
// Cancel onClose promis... | javascript | {
"resource": ""
} | |
q17684 | train | function(eventData) {
initialResolve = true;
// Cancel no event timer.
if (noEventTimer) {
noEventTimer.cancel();
}
// Incoming link detected.
// Check for any stored partial event.
self.getPartialStoredEvent_().then(function(event) {
// Initialize to an unknown event.
var ... | javascript | {
"resource": ""
} | |
q17685 | train | function() {
// Get time until expiration minus the refresh offset.
var waitInterval =
self.stsTokenManager_.getExpirationTime() - goog.now() -
fireauth.TokenRefreshTime.OFFSET_DURATION;
// Set to zero if wait interval is negative.
return waitInterval > 0 ? waitIn... | javascript | {
"resource": ""
} | |
q17686 | logAtLevel_ | train | function logAtLevel_(message, level) {
if (message != null) {
var messageDiv = $('<div></div>');
messageDiv.addClass(level);
if (typeof message === 'object') {
messageDiv.text(JSON.stringify(message, null, ' '));
} else {
messageDiv.text(message);
}
$('.logs').append(messageDiv);
... | javascript | {
"resource": ""
} |
q17687 | alertMessage_ | train | function alertMessage_(message, cssClass) {
var alertBox = $('<div></div>')
.addClass(cssClass)
.css('display', 'none')
.text(message);
$('#alert-messages').prepend(alertBox);
alertBox.fadeIn({
complete: function() {
setTimeout(function() {
alertBox.slideUp();
}, 3000);
... | javascript | {
"resource": ""
} |
q17688 | refreshUserData | train | function refreshUserData() {
if (activeUser()) {
var user = activeUser();
$('.profile').show();
$('body').addClass('user-info-displayed');
$('div.profile-email,span.profile-email').text(user.email || 'No Email');
$('div.profile-phone,span.profile-phone')
.text(user.phoneNumber || 'No Phone... | javascript | {
"resource": ""
} |
q17689 | addProviderIcon | train | function addProviderIcon(providerId) {
var pElt = $('<i>').addClass('fa ' + providersIcons[providerId])
.attr('title', providerId)
.data({
'toggle': 'tooltip',
'placement': 'bottom'
});
$('.profile-providers').append(pElt);
pElt.tooltip();
} | javascript | {
"resource": ""
} |
q17690 | onSetLanguageCode | train | function onSetLanguageCode() {
var languageCode = $('#language-code').val() || null;
try {
auth.languageCode = languageCode;
alertSuccess('Language code changed to "' + languageCode + '".');
} catch (error) {
alertError('Error: ' + error.code);
}
} | javascript | {
"resource": ""
} |
q17691 | onSetPersistence | train | function onSetPersistence() {
var type = $('#persistence-type').val();
try {
auth.setPersistence(type).then(function() {
log('Persistence state change to "' + type + '".');
alertSuccess('Persistence state change to "' + type + '".');
}, function(error) {
alertError('Error: ' + error.code);... | javascript | {
"resource": ""
} |
q17692 | onSignUp | train | function onSignUp() {
var email = $('#signup-email').val();
var password = $('#signup-password').val();
auth.createUserWithEmailAndPassword(email, password)
.then(onAuthUserCredentialSuccess, onAuthError);
} | javascript | {
"resource": ""
} |
q17693 | onSignInWithEmailAndPassword | train | function onSignInWithEmailAndPassword() {
var email = $('#signin-email').val();
var password = $('#signin-password').val();
auth.signInWithEmailAndPassword(email, password)
.then(onAuthUserCredentialSuccess, onAuthError);
} | javascript | {
"resource": ""
} |
q17694 | onSignInWithEmailLink | train | function onSignInWithEmailLink() {
var email = $('#sign-in-with-email-link-email').val();
var link = $('#sign-in-with-email-link-link').val() || undefined;
if (auth.isSignInWithEmailLink(link)) {
auth.signInWithEmailLink(email, link).then(onAuthSuccess, onAuthError);
} else {
alertError('Sign in link is... | javascript | {
"resource": ""
} |
q17695 | onLinkWithEmailLink | train | function onLinkWithEmailLink() {
var email = $('#link-with-email-link-email').val();
var link = $('#link-with-email-link-link').val() || undefined;
var credential = firebase.auth.EmailAuthProvider
.credentialWithLink(email, link);
activeUser().linkWithCredential(credential)
.then(onAuthUserCredentia... | javascript | {
"resource": ""
} |
q17696 | onReauthenticateWithEmailLink | train | function onReauthenticateWithEmailLink() {
var email = $('#link-with-email-link-email').val();
var link = $('#link-with-email-link-link').val() || undefined;
var credential = firebase.auth.EmailAuthProvider
.credentialWithLink(email, link);
activeUser().reauthenticateWithCredential(credential)
.then... | javascript | {
"resource": ""
} |
q17697 | onSignInWithCustomToken | train | function onSignInWithCustomToken(event) {
// The token can be directly specified on the html element.
var token = $('#user-custom-token').val();
auth.signInWithCustomToken(token)
.then(onAuthUserCredentialSuccess, onAuthError);
} | javascript | {
"resource": ""
} |
q17698 | onSignInWithGenericIdPCredential | train | function onSignInWithGenericIdPCredential() {
var providerId = $('#signin-generic-idp-provider-id').val();
var idToken = $('#signin-generic-idp-id-token').val();
var accessToken = $('#signin-generic-idp-access-token').val();
var provider = new firebase.auth.OAuthProvider(providerId);
auth.signInWithCredential... | javascript | {
"resource": ""
} |
q17699 | makeApplicationVerifier | train | function makeApplicationVerifier(submitButtonId) {
var container = recaptchaSize === 'invisible' ?
submitButtonId :
'recaptcha-container';
applicationVerifier = new firebase.auth.RecaptchaVerifier(container,
{'size': recaptchaSize});
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.