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

@uniswap/conedison

Package Overview
Dependencies
Maintainers
19
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/conedison - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

3

dist/format.d.ts

@@ -6,2 +6,3 @@ import { Currency, CurrencyAmount, Percent, Price } from '@uniswap/sdk-core';

TokenTx = "token-tx",
SwapPrice = "swap-price",
SwapTradeAmount = "swap-trade-amount",

@@ -30,1 +31,3 @@ FiatTokenDetails = "fiat-token-details",

export declare function formatUSDPrice(price: Nullish<number | string>, type?: NumberType): string;
/** Formats USD and non-USD prices */
export declare function formatFiatPrice(price: Nullish<number>, currency?: string): string;

76

dist/format.js

@@ -26,9 +26,16 @@ var __read = (this && this.__read) || function (o, n) {

};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var _a;
// Number formatting follows the standards laid out in this spec:
// https://www.notion.so/uniswaplabs/Number-standards-fbb9f533f10e4e22820722c2f66d23c0
var FIVE_DECIMALS_NO_TRAILING_ZEROS = new Intl.NumberFormat('en-US', {
notation: 'standard',
maximumFractionDigits: 5,
});
var FIVE_DECIMALS_MAX_TWO_DECIMALS_MIN = new Intl.NumberFormat('en-US', {

@@ -45,2 +52,7 @@ notation: 'standard',

});
var NO_DECIMALS = new Intl.NumberFormat('en-US', {
notation: 'standard',
maximumFractionDigits: 0,
minimumFractionDigits: 0,
});
var THREE_DECIMALS_NO_TRAILING_ZEROS = new Intl.NumberFormat('en-US', {

@@ -88,5 +100,6 @@ notation: 'standard',

});
var SHORTHAND_FIVE_DECIMALS_NO_TRAILING_ZEROS = new Intl.NumberFormat('en-US', {
var SHORTHAND_ONE_DECIMAL = new Intl.NumberFormat('en-US', {
notation: 'compact',
maximumFractionDigits: 5,
minimumFractionDigits: 1,
maximumFractionDigits: 1,
});

@@ -158,2 +171,6 @@ var SHORTHAND_USD_TWO_DECIMALS = new Intl.NumberFormat('en-US', {

];
var swapPriceFormatter = __spreadArray([
{ exact: 0, formatter: '0' },
{ upperBound: 0.00001, formatter: '<0.00001' }
], __read(swapTradeAmountFormatter), false);
var fiatTokenDetailsFormatter = [

@@ -170,7 +187,5 @@ { exact: 0, formatter: '$0.00' },

{ upperBound: 0.00000001, formatter: '<$0.00000001' },
{ upperBound: 0.1, formatter: THREE_SIG_FIGS_USD },
{ upperBound: 1.05, formatter: THREE_DECIMALS_USD },
{ upperBound: 1000000, formatter: TWO_DECIMALS_USD },
{ upperBound: 1000000000000000, formatter: SHORTHAND_USD_TWO_DECIMALS },
{ upperBound: Infinity, formatter: '>$999T' }, // Use M/B/T abbreviations
{ upperBound: 1, formatter: THREE_SIG_FIGS_USD },
{ upperBound: 1e6, formatter: TWO_DECIMALS_USD },
{ upperBound: Infinity, formatter: SHORTHAND_USD_TWO_DECIMALS },
];

@@ -211,8 +226,4 @@ var fiatTokenStatsFormatter = [

var ntfCollectionStatsFormatter = [
{ exact: 0, formatter: '0' },
{ upperBound: 0.00001, formatter: '<0.00001' },
{ upperBound: 1, formatter: FIVE_DECIMALS_NO_TRAILING_ZEROS },
{ upperBound: 1e6, formatter: SIX_SIG_FIGS_NO_COMMAS },
{ upperBound: 1e15, formatter: SHORTHAND_FIVE_DECIMALS_NO_TRAILING_ZEROS },
{ upperBound: Infinity, formatter: '>999T' },
{ upperBound: 1000, formatter: NO_DECIMALS },
{ upperBound: Infinity, formatter: SHORTHAND_ONE_DECIMAL },
];

@@ -225,2 +236,5 @@ export var NumberType;

NumberType["TokenTx"] = "token-tx";
// this formatter is used for displaying swap price conversions
// below the input/output amounts
NumberType["SwapPrice"] = "swap-price";
// this formatter is only used for displaying the swap trade output amount

@@ -251,2 +265,3 @@ // in the text input boxes. Output amounts on review screen should use the above TokenTx formatter

_a[NumberType.TokenTx] = tokenTxFormatter,
_a[NumberType.SwapPrice] = swapPriceFormatter,
_a[NumberType.SwapTradeAmount] = swapTradeAmountFormatter,

@@ -264,10 +279,20 @@ _a[NumberType.FiatTokenQuantity] = fiatTokenQuantityFormatter,

function getFormatterRule(input, type) {
var e_1, _a;
var rules = TYPE_TO_FORMATTER_RULES[type];
for (var i = 0; i < rules.length; i++) {
var rule = rules[i];
if ((rule.exact !== undefined && input === rule.exact) ||
(rule.upperBound !== undefined && input < rule.upperBound)) {
return rule.formatter;
try {
for (var rules_1 = __values(rules), rules_1_1 = rules_1.next(); !rules_1_1.done; rules_1_1 = rules_1.next()) {
var rule = rules_1_1.value;
if ((rule.exact !== undefined && input === rule.exact) ||
(rule.upperBound !== undefined && input < rule.upperBound)) {
return rule.formatter;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (rules_1_1 && !rules_1_1.done && (_a = rules_1.return)) _a.call(rules_1);
}
finally { if (e_1) throw e_1.error; }
}
throw new Error("formatter for type ".concat(type, " not configured correctly"));

@@ -331,1 +356,8 @@ }

}
/** Formats USD and non-USD prices */
export function formatFiatPrice(price, currency) {
if (currency === void 0) { currency = 'USD'; }
if (price === null || price === undefined)
return '-';
return new Intl.NumberFormat('en-US', { style: 'currency', currency: currency }).format(price);
}
{
"name": "@uniswap/conedison",
"version": "1.6.0",
"version": "1.7.0",
"description": "Utilities for Uniswap front-end development",

@@ -5,0 +5,0 @@ "repository": "https://github.com/Uniswap/conedison",

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