compile(pipeline) { let code; if (Array.isArray(pipeline) && pipeline[0].startsWith('//')) { code = pipeline.slice(1).join('\n'); } else { code = Array.isArray(pipeline) ? pipeline.join('\n') : pipeline; } const header = '(async () => {\n'; const footer = '\n})();'; const wrapped = header + this.transpile(code) + footer; return wrapped; }
test('can handle strings', () => { const dataFormatter = new DataFormatter('a big string'); const indices = dataFormatter.toIndexes('a big string'); indices.forEach((value) => expect(value >= 0)); expect(dataFormatter.toCharacters(indices).join('')).toBe('a big string'); });
get dataSource() { const dataSources = R.uniq(this.allCubeNames.map(c => this.cubeDataSource(c))); if (dataSources.length > 1) { throw new UserError(`Joins across data sources aren't supported in community edition. Found data sources: ${dataSources.join(', ')}`); } return dataSources[0]; }
throwErrorsIfAny() { if (this.errors.length) { throw new UserError(`SQL Parsing Error:\n${this.errors.map(({ msg, column, line }) => `${line}:${column} ${msg}`).join('\n')}`); } }
function formatDate() { var date = new Date(); var result = []; result.push(date.getFullYear()); result.push(padding(date.getMonth() + 1)); result.push(padding(date.getDate())); result.push(padding(date.getHours())); result.push(padding(date.getMinutes())); result.push(padding(date.getSeconds())); result.push(paddingMS(date.getMilliseconds())); return result.join(''); }
/** * Render the scale "Key". Something like: * @return {String} */ renderScaleKey() { if (this.scaleKey === false) return ''; if (this.state.submitted) return ''; let scale = this.scale.map(item => ` ${item.name} - ${item.message}`); let key = ['', ...scale].map(item => this.styles.muted(item)); return key.join('\n'); }
/* * Paths to / */ const pathsToRoot = (startFrom = process.cwd()) => { return _(_.range(path.dirname(startFrom).split(path.sep).length)) .map(end => _.dropRight(path.dirname(startFrom).split(path.sep), end).join(path.sep)) .unshift(startFrom) .dropRight() .value(); }
(process.env.NODE_PATH || '') .split(path.delimiter) .filter(folder => folder && !path.isAbsolute(folder)) .map(folder => path.resolve(appDirectory, folder)) .join(path.delimiter)
aggregateSubQueryMeasureJoin(keyCubeName, measures, measuresJoin, primaryKeyDimension, measureSubQueryDimensions) { return this.ungroupedMeasureSelect(() => this.withCubeAliasPrefix(`${keyCubeName}_measure_join`, () => { const columns = [primaryKeyDimension.selectColumns()].concat(measures.map(m => m.selectColumns())) .filter(s => !!s).join(', '); return `SELECT ${columns} FROM ${this.joinQuery(measuresJoin, measureSubQueryDimensions)}`; })); }
this.trajectories.forEach( function ( line ) { write( '\u001b[' + self.scoreboardWidth + 'C' ); write( line.join( '' ) ); write( '\n' ); } );
function generateRecordingName(context) { const { currentTest } = context; const parts = [currentTest.title]; let parent = currentTest.parent; while (parent && parent.title) { parts.push(parent.title); parent = parent.parent; } return parts.reverse().join('/'); }
_(data) .map((value, index) => new Table(value, opts)) .map(table => table.toString()) .thru(data => data.join(os.EOL)) .value()
set mode(mode) { const possibleModes = Object.values(MODES); assert( `Invalid mode provided: "${mode}". Possible modes: ${possibleModes.join( ', ' )}.`, possibleModes.includes(mode) ); this.config.mode = mode; }
prompt.run() .then(function(answer = []) { console.log(answer); console.log('Your preferred order of colors is:'); console.log(answer.map(key => colors[key](key)).join('\n')); }) .catch(console.error);