本文整理汇总了TypeScript中lodash.toNumber函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toNumber函数的具体用法?TypeScript toNumber怎么用?TypeScript toNumber使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toNumber函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: configureAxisOptions
function configureAxisOptions(data, options) {
var defaults = {
position: 'left',
show: panel.yaxes[0].show,
index: 1,
logBase: panel.yaxes[0].logBase || 1,
min: panel.yaxes[0].min ? _.toNumber(panel.yaxes[0].min) : null,
max: panel.yaxes[0].max ? _.toNumber(panel.yaxes[0].max) : null,
};
options.yaxes.push(defaults);
if (_.find(data, {yaxis: 2})) {
var secondY = _.clone(defaults);
secondY.index = 2;
secondY.show = panel.yaxes[1].show;
secondY.logBase = panel.yaxes[1].logBase || 1;
secondY.position = 'right';
secondY.min = panel.yaxes[1].min ? _.toNumber(panel.yaxes[1].min) : null;
secondY.max = panel.yaxes[1].max ? _.toNumber(panel.yaxes[1].max) : null;
options.yaxes.push(secondY);
applyLogScale(options.yaxes[1], data);
configureAxisMode(options.yaxes[1], panel.percentage && panel.stack ? "percent" : panel.yaxes[1].format);
}
applyLogScale(options.yaxes[0], data);
configureAxisMode(options.yaxes[0], panel.percentage && panel.stack ? "percent" : panel.yaxes[0].format);
}
示例2: tickFormatter
function tickFormatter(valIndex) {
let valueFormatted = tsBuckets[valIndex];
if (!_.isNaN(_.toNumber(valueFormatted)) && valueFormatted !== '') {
// Try to format numeric tick labels
valueFormatted = tickValueFormatter(decimals)(_.toNumber(valueFormatted));
}
return valueFormatted;
}
示例3: parseNumber
parseNumber(value: any) {
if (value === null || typeof value === 'undefined') {
return null;
}
return _.toNumber(value);
}
示例4: _getDuplicateFailure
private _getDuplicateFailure(key: string, imports: ImportOrExportDeclaration[]) {
const values = key.split('|');
const kind = _.toNumber(key.split('|')[0]);
const name = values[1];
const message = `order imports: duplicate ${ts.SyntaxKind[kind].toLowerCase()} '${name}' found and should be consolidated`;
return _.map(imports, x => this.createFailure(x.getStart(), x.getWidth(), message));
}
示例5: toNumber
/** Will return any value as a number or NaN */
function toNumber(value: any): number {
if (typeof value === 'number') {
return value;
}
if (value === null || value === undefined || Array.isArray(value)) {
return NaN; // lodash calls them 0
}
if (typeof value === 'boolean') {
return value ? 1 : 0;
}
return _.toNumber(value);
}
示例6: parseInt
export const fromConwayNotation = (notation: string) => {
const prefix = notation[0];
const number = parseInt(notation.substring(1));
if (platonicMapping.get(notation)) {
return platonicMapping.get(notation);
}
if (archimedeanMapping.get(notation)) {
return archimedeanMapping.get(notation);
}
if (prefix === 'J') {
return johnsonSolids[_.toNumber(number) - 1];
}
if (prefix === 'P') {
return `${polygonPrefixes.get(number)} prism`;
}
if (prefix === 'A') {
return `${polygonPrefixes.get(number)} antiprism`;
}
return '';
};
示例7: autoCastValue
export function autoCastValue(value: any): any {
if (_.isArray(value)) {
return value.map(value => value.toString());
}
if (_.isString(value)) { // String
return value;
}
if (_.isBoolean(value)) { // Boolean
return Boolean(value);
}
if (_.isNumber(value)) {
return _.toNumber(value);
}
if (Long.isLong(value)) {
return (value as Long).toNumber();
}
if (_.isDate(value)) { // Date
return new Date(value);
}
return value;
}
示例8: restoreTask
private restoreTask(taskId: number) {
taskId = _.toNumber(taskId);
if (this.taskStacks.has(taskId)) {
let stack = _.clone(this.taskStacks.get(taskId)),
section = stack[0].object,
sectionId = section.id;
let taskState = this.datastoreService.getState().get(Model.Task);
if (taskState &&
taskState.get((taskId as any)) &&
taskState.get(taskId).get('error')) {
_.last(stack).error = taskState.get(taskId).get('error').toJS();
}
if (this.currentStacks.has(sectionId)) {
this.currentStacks.set(sectionId, stack);
} else {
this.sectionRouters.get(sectionId).restore(stack);
}
this.eventDispatcherService.dispatch('sectionRestored', stack);
this.changeHash(_.last(stack).path);
}
}
示例9:
name => _.toNumber(name.substring(commonPrefix.length))
示例10: function
savers[n] = function() { return _.toNumber($('#'+n).val()); };