Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@contrail/types

Package Overview
Dependencies
Maintainers
9
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrail/types - npm Package Compare versions

Comparing version 3.0.18 to 3.0.19

lib/formatter/formatNumber.d.ts

4

lib/formatter/property-value-formatter.d.ts
import { DateFormatingOptions, NumberFormatingOptions, TypeProperty } from '../type-properties';
export interface LocalizationConfig {
currencyCode: string;
currencyCode?: string;
currency?: string;
locale: string;

@@ -15,3 +16,2 @@ }

formatValue(value: any, propertyType: any, numberFormat?: NumberFormatingOptions, dateFormat?: DateFormatingOptions): string;
private formatNumber;
formatCurrencyValue(value: any): string;

@@ -18,0 +18,0 @@ formatDate(date: any, dateFormatOptions?: DateFormatingOptions): string;

@@ -5,2 +5,3 @@ "use strict";

const type_properties_1 = require("../type-properties");
const formatNumber_1 = require("./formatNumber");
class PropertyValueFormatter {

@@ -72,15 +73,15 @@ constructor() {

case type_properties_1.PropertyType.Currency: {
formattedValue = this.formatNumber(value, numberFormat || { format: type_properties_1.NumberFormat.Currency });
formattedValue = (0, formatNumber_1.formatNumber)(value, numberFormat || { format: type_properties_1.NumberFormat.Currency }, this.localizationConfig);
break;
}
case type_properties_1.PropertyType.Percent: {
formattedValue = this.formatNumber(value, numberFormat || { format: type_properties_1.NumberFormat.Percent });
formattedValue = (0, formatNumber_1.formatNumber)(value, numberFormat || { format: type_properties_1.NumberFormat.Percent }, this.localizationConfig);
break;
}
case type_properties_1.PropertyType.Number: {
formattedValue = this.formatNumber(value, numberFormat || { format: type_properties_1.NumberFormat.Decimal });
formattedValue = (0, formatNumber_1.formatNumber)(value, numberFormat || { format: type_properties_1.NumberFormat.Decimal }, this.localizationConfig);
break;
}
case type_properties_1.PropertyType.Formula: {
formattedValue = this.formatNumber(value, numberFormat || { format: type_properties_1.NumberFormat.Decimal });
formattedValue = (0, formatNumber_1.formatNumber)(value, numberFormat || { format: type_properties_1.NumberFormat.Decimal }, this.localizationConfig);
break;

@@ -103,32 +104,4 @@ }

}
formatNumber(value, numberFormat = { format: type_properties_1.NumberFormat.Decimal }) {
if (!value) {
return value;
}
let val = value;
try {
val = parseFloat(val);
}
catch (e) {
console.log(`ERROR: Non number value ${value} in PropertyValueFormatter.formatNumber`);
}
const options = {};
if (numberFormat.precision !== null) {
options.maximumFractionDigits = numberFormat.precision;
options.minimumFractionDigits = numberFormat.precision;
}
if (numberFormat.format === type_properties_1.NumberFormat.Currency) {
options.style = 'currency';
options.currency = this.localizationConfig.currencyCode;
if (value && value[this.localizationConfig.currencyCode] || value[this.localizationConfig.currencyCode.toLowerCase()]) {
val = value[this.localizationConfig.currencyCode] || value[this.localizationConfig.currencyCode.toLowerCase()];
}
}
if (numberFormat.format === type_properties_1.NumberFormat.Percent) {
options.style = 'percent';
}
return new Intl.NumberFormat(this.localizationConfig.locale, options).format(val);
}
formatCurrencyValue(value) {
return this.formatNumber(value, { format: type_properties_1.NumberFormat.Currency });
return (0, formatNumber_1.formatNumber)(value, { format: type_properties_1.NumberFormat.Currency }, this.localizationConfig);
}

@@ -135,0 +108,0 @@ formatDate(date, dateFormatOptions = { includeTime: false }) {

@@ -8,3 +8,3 @@ import { Type } from "../types";

options?: any;
maxDepth?: number;
maxDepth: number;
name?: string;

@@ -11,0 +11,0 @@ }

@@ -32,2 +32,3 @@ import { PropertyType } from '.';

notes?: string;
searchable?: boolean;
}

@@ -34,0 +35,0 @@ export interface TypePropertyOptionSet {

{
"name": "@contrail/types",
"version": "3.0.18",
"version": "3.0.19",
"description": "Types Utility module",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc