private static replaceAnnotations(comment: Comment, reflections: Reflection[]) { const replacer = (_, name) => { const reflection = reflections.find((reflection) => reflection.name === name); return this.toLink(name, reflection); } comment.text = comment.text.replace(linkRegex, replacer); comment.shortText = comment.shortText.replace(linkRegex, replacer); }
const cleanupEntities = function(luisObject) { let consolidatedList = []; luisObject.composites.forEach(item => consolidatedList.push(item)); luisObject.closedLists.forEach(item => consolidatedList.push(item)); luisObject.regex_entities.forEach(item => consolidatedList.push(item)); luisObject.prebuiltEntities.forEach(item => consolidatedList.push(item)); let idxToRemove = []; luisObject.entities.forEach((item, idx) => { if (consolidatedList.find(e => e.name == item.name) !== undefined) idxToRemove.push(idx); }) idxToRemove.sort((a, b) => a-b).forEach(idx => luisObject.entities.splice(idx, 1)) }
async downloadPackages() { await this.downloadRepo(); await decompress(this.repoArchivePath, this.tmpFolderPath, { plugins: [decompressTargz()], }); const dir = fs.readdirSync(this.tmpFolderPath).find((name) => !name.endsWith('tar.gz')); await executeCommand('npm', ['install'], { cwd: path.resolve(this.tmpFolderPath, dir) }); return { packagesPath: path.join(this.tmpFolderPath, dir, 'packages'), }; }
modifyFeed(id, feedToModify, callback) { const modifiedFeed = this.feeds.find(feed => feed.options._id === id); modifiedFeed.stopReader(); modifiedFeed.modify(feedToModify); this.modifyItem(id, feedToModify, err => { callback(err); }); }
function createDefaultMainField(schema) { if (!schema) return 'id'; const mainField = Object.keys(schema.attributes).find( key => schema.attributes[key].type === 'string' && !['id', schema.primaryKey].includes(key) ); return mainField || 'id'; }
/** * Checks whether some Reflection is in the inheritedReflections list. * @param search The Reflection to search for in the list. */ private isInherited(search: Reflection): boolean { if (this.inheritedReflections.find((inh: Reflection) => inh.id === search.id && inh.name === search.name)) { return true; } return false; }
// Resolve file paths in the same order as webpack const resolveModule = (resolveFn, filePath) => { const extension = moduleFileExtensions.find(extension => fs.existsSync(resolveFn(`${filePath}.${extension}`)) ); if (extension) { return resolveFn(`${filePath}.${extension}`); } return resolveFn(`${filePath}.js`); }
/** * @see DefaultTheme.getMapping * Return the template mapping for the given reflection. * * @param reflection The reflection whose mapping should be resolved. * @returns The found mapping or undefined if no mapping could be found. */ static getMapping(reflection: DeclarationReflection): TemplateMapping | undefined { return MarkdownTheme.MAPPINGS.find((mapping) => reflection.kindOf(mapping.kind)); }
const FileIcon = ({ ext }) => { const iconName = Object.keys(extensions).find(key => extensions[key].includes(ext)) || 'alt'; return ( <Wrapper type="file" colored={iconName === 'pdf'}> <FontAwesomeIcon icon={['far', `file-${iconName}`]} /> </Wrapper> ); }
const indexByLocation = (attributes, lines) => { const pair = Object.entries(attributes).find(([k, v]) => locations[k]); if (pair) { const _pair = _slicedToArray(pair, 2), k = _pair[0], v = _pair[1]; return locations[k](v, lines); } return -1; }
/** * Check there is available endpoint * * @returns * @memberof EndpointList */ hasAvailable() { return this.endpoints.find(ep => ep.isAvailable) != null; }
function getByName(name) { /* istanbul ignore next */ if (!name) return null; let n = Object.keys(Cachers).find(n => n.toLowerCase() == name.toLowerCase()); if (n) return Cachers[n]; }
const indexByLocation = (attributes: any, lines: string[]): number => { const pair = Object.entries(attributes).find(([k, _]) => locations[k]) if (pair) { const [k, v] = pair return locations[k](v, lines) } return -1 }
// Resolve file paths in the same order as webpack const resolveModule = (resolveFn, filePath) => { const extension = moduleFileExtensions.find(extension => fs.existsSync(resolveFn(`${filePath}.${extension}`)) ); if (extension) { return resolveFn(`${filePath}.${extension}`); } return resolveFn(`${filePath}.js`); }
function getByName(name) { /* istanbul ignore next */ if (!name) return null; let n = Object.keys(Validators).find(n => n.toLowerCase() == name.toLowerCase()); if (n) return Validators[n]; }