New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bloks/numbers

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bloks/numbers - npm Package Compare versions

Comparing version 27.2.0 to 27.3.0

dist/index.mjs

6

dist/index.d.ts

@@ -23,3 +23,3 @@ import { BigNumber } from 'bignumber.js';

static fromString(asset: string): Asset;
static fromSymbol({ symbol, amount }: {
static fromSymbol({ symbol, amount, }: {
symbol: Symbol;

@@ -48,3 +48,3 @@ amount: BigNumber.Instance;

});
static fromRaw({ quantity, contract }: {
static fromRaw({ quantity, contract, }: {
quantity: string;

@@ -83,3 +83,3 @@ contract: string;

constructor(sym: Symbol, contract: string);
static fromRaw({ sym, contract }: {
static fromRaw({ sym, contract, }: {
sym: string;

@@ -86,0 +86,0 @@ contract: string;

@@ -130,3 +130,6 @@ "use strict";

}
static fromSymbol({ symbol, amount }) {
static fromSymbol({
symbol,
amount
}) {
if (!(symbol instanceof Symbol2)) {

@@ -148,3 +151,6 @@ throw new Error("Invalid symbol");

toString() {
return `${new import_bignumber.BigNumber(this.amount).toFixed(this.symbol.precision, import_bignumber.BigNumber.ROUND_DOWN)} ${this.symbol.code}`;
return `${new import_bignumber.BigNumber(this.amount).toFixed(
this.symbol.precision,
import_bignumber.BigNumber.ROUND_DOWN
)} ${this.symbol.code}`;
}

@@ -186,3 +192,6 @@ modifyAmount(x, method) {

}
static fromRaw({ quantity, contract }) {
static fromRaw({
quantity,
contract
}) {
return new ExtendedAsset({

@@ -416,3 +425,7 @@ quantity: Asset.fromString(quantity),

}
return (0, import_numbro.default)(number).format({ thousandSeparated: true, mantissa: precision, trimMantissa });
return (0, import_numbro.default)(number).format({
thousandSeparated: true,
mantissa: precision,
trimMantissa
});
}

@@ -431,3 +444,8 @@ function displayNumberAsAsset(number, symbol, precision, trimMantissa = false) {

function displayRawNumberAsAsset(number, symbol, precision, trimMantissa = false) {
return displayNumberAsAsset(number / Math.pow(10, precision), symbol, precision, trimMantissa);
return displayNumberAsAsset(
number / Math.pow(10, precision),
symbol,
precision,
trimMantissa
);
}

@@ -434,0 +452,0 @@

{
"name": "@bloks/numbers",
"version": "27.2.0",
"version": "27.3.0",
"author": "jafri",

@@ -19,3 +19,3 @@ "module": "dist/api.esm.js",

"dayjs": "^1.8.18",
"@proton/tsconfig": "1.2.0"
"@proton/tsconfig": "1.3.0"
},

@@ -27,5 +27,5 @@ "devDependencies": {

"scripts": {
"build": "tsup src/index.ts --format cjs --dts",
"build": "tsup src/index.ts --format cjs,esm --dts",
"dev": "tsup src/index.ts --watch"
}
}
# Installation
```

@@ -9,24 +10,24 @@ npm i @bloks/numbers

```js
import { Asset } from '@bloks/numbers'
import { Asset } from "@bloks/numbers";
const asset1 = new Asset({
code: 'XPR',
code: "XPR",
precision: 4,
amount: 10
})
amount: 10,
});
console.log(asset1.symbol.code) // "XPR"
console.log(asset1.symbol.precision) // 4
console.log(asset1.amount) // BN(10)
console.log(asset1.amount.toNumber()) // 10
console.log(asset1.amount.toString()) // "10""
console.log(asset1.symbol.code); // "XPR"
console.log(asset1.symbol.precision); // 4
console.log(asset1.amount); // BN(10)
console.log(asset1.amount.toNumber()); // 10
console.log(asset1.amount.toString()); // "10""
const asset2 = new Asset({
code: 'XPR',
code: "XPR",
precision: 4,
amount: 100
})
amount: 100,
});
console.log(asset1.isEqualTo(asset2)) // false
console.log(asset1.isLooselyEqualTo(asset2)) // true
```
console.log(asset1.isEqualTo(asset2)); // false
console.log(asset1.isLooselyEqualTo(asset2)); // true
```
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