/** * Reads a list of files and joins their contents together with newlines * * @param {Array<string>} inputFiles Paths of the files to parse * @returns {string} Concatenated file contents */ function concatAllFiles( inputFiles ) { return inputFiles.map( ( inputFile ) => fs.readFileSync( inputFile, 'utf8' ) ).join( '\n' ); }
Object.keys( SUPPORTED_CURRENCIES ).map( ( value ) => { const { symbol } = getCurrencyDefaults( value ); const label = symbol === value ? value : `${ value } ${ trimEnd( symbol, '.' ) }`; return { value, label }; } )
static async getBySlug({ slug }) { const bookDoc = await this.findOne({ slug }); if (!bookDoc) { throw new Error('Book not found'); } const book = bookDoc.toObject(); book.chapters = (await Chapter.find({ bookId: book._id }, 'title slug').sort({ order: 1 })).map( (chapter) => chapter.toObject(), ); return book; }
async tablesSchema() { const tables = await this.query(`show tables in ${this.config.dbName}`); return { [this.config.dbName]: (await Promise.all(tables.map(async table => { const tableName = table.tab_name || table.tableName; const columns = await this.query(`describe ${this.config.dbName}.${tableName}`); return { [tableName]: columns.map(c => ({ name: c.col_name, type: c.data_type })) }; }))).reduce((a, b) => ({ ...a, ...b }), {}) }; }
processSpeedsForDisplay(speeds = []) { if (!speeds || speeds.length === 0) { return; } return speeds.map(speed => Number(speed) / 1024).join(', '); }
// should render on <head> helmetHeadComponents() { const keys = Object.keys(this.props.helmet) .filter(el => el !== 'htmlAttributes') .map(el => this.props.helmet[el].toComponent()) .filter( el => el.length > 0 || !(Object.keys(el).length === 0 && el.constructor === Object) ); return keys.length ? keys : []; }
colorsMap.map(color => { colorStories.add(color.name, () => ( <span style={{ color: color.code }}>{color.name} - {color.code}</span> )) })
cubeCardinalityQueries() { // TODO collect sub queries return R.fromPairs(this.allCubeNames .map(cube => [ cube, this.paramAllocator.buildSqlAndParams(`select count(*) as ${this.escapeColumnName('total_count')} from ${this.cubeSql(cube)} ${this.asSyntaxTable} ${this.cubeAlias(cube)}`) ])); }
// 'a' /** * Turn the # into 1s and . into 0s. for whole string * @param string * @returns {Array} */ function character(string: string): number[] { return string.trim().split('').map(integer); }
(process.env.NODE_PATH || '') .split(path.delimiter) .filter(folder => folder && !path.isAbsolute(folder)) .map(folder => path.resolve(appDirectory, folder)) .join(path.delimiter)
Object.keys(this.state.changedClientSettings).map(settingsKey => { const data = this.state.changedClientSettings[settingsKey]; if (data.overrideLocalSetting) { return data; } return {id: settingsKey, data}; })
Object.keys(options.cookie) .map( (key) => encodeURIComponent(key) + '=' + encodeURIComponent(options.cookie[key]), ) .join('; ')
Object.keys(props.dictionary.services).map(host => ( <option value={host}> <Text id={`integration.caldav.services.${host}.name`} /> </option> ))
function getValues() { var values = {}; var dir = path.join(__dirname, 'assets/values'); fs.readdirSync(dir).map(function(name) { values[name] = fs.readFileSync(path.join(dir, name), {encoding: 'utf8'}); }); return values; }
fontsMap.map(font => { fontsStories.add(font.name, () => ( <span style={{ fontFamily: font.family }}>{font.name} - {font.family}</span> )) })