Skip to content

Commit

Permalink
1.0.0-rc.5
Browse files Browse the repository at this point in the history
  • Loading branch information
napalmpapalam committed Aug 2, 2023
1 parent 13d0fe7 commit d9f3310
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 18 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [1.0.0-rc.5] - 2023-08-02
### Fixed
- `@distributedlab/tools` - `BN` format group sizes

## [1.0.0-rc.4] - 2023-07-31
### Fixed
- `@distributedlab/tools` - `BN` format decimals size of the output value
Expand Down Expand Up @@ -315,7 +319,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[old repo]: https://github.com/distributed-lab/web-kit-old

[Unreleased]: https://github.com/distributed-lab/web-kit/compare/1.0.0-rc.4...HEAD
[Unreleased]: https://github.com/distributed-lab/web-kit/compare/1.0.0-rc.5...HEAD
[1.0.0-rc.5]: https://github.com/distributed-lab/web-kit/compare/1.0.0-rc.4...1.0.0-rc.5
[1.0.0-rc.4]: https://github.com/distributed-lab/web-kit/compare/1.0.0-rc.3...1.0.0-rc.4
[1.0.0-rc.3]: https://github.com/distributed-lab/web-kit/compare/1.0.0-rc.2...1.0.0-rc.3
[1.0.0-rc.2]: https://github.com/distributed-lab/web-kit/compare/1.0.0-rc.1...1.0.0-rc.2
Expand Down
2 changes: 1 addition & 1 deletion packages/fetcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@distributedlab/fetcher",
"version": "1.0.0-rc.4",
"version": "1.0.0-rc.5",
"description": "Fetch API wrapper with the extended functionality and simple interface",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/jac/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@distributedlab/jac",
"version": "1.0.0-rc.4",
"version": "1.0.0-rc.5",
"description": "A library for constructing JSON-API compliant requests and responses",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@distributedlab/reactivity",
"version": "1.0.0-rc.4",
"version": "1.0.0-rc.5",
"description": "Implementation of the reactivity connections to propagate changes between objects",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@distributedlab/tools",
"version": "1.0.0-rc.4",
"version": "1.0.0-rc.5",
"description": "Collection of common utility functions and classes",
"repository": {
"type": "git",
Expand Down
12 changes: 6 additions & 6 deletions packages/tools/src/bn/bn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,15 +670,15 @@ describe('performs BN unit test', () => {
decimals: 6,
groupSeparator: ',',
}),
).toBe('122,334,444,23.123123')
).toBe('12,233,444,423.123123')

expect(
BN.fromRaw('12233444423.123123123123123', 18).format({
decimals: 6,
groupSeparator: '.',
decimalSeparator: ',',
}),
).toBe('122.334.444.23,123123')
).toBe('12.233.444.423,123123')

expect(
BN.fromRaw('12233444423.123123123123123', 18).format({
Expand All @@ -687,7 +687,7 @@ describe('performs BN unit test', () => {
decimalSeparator: '.',
groupSize: 3,
}),
).toBe('122 334 444 23.123123')
).toBe('12 233 444 423.123123')

expect(
BN.fromRaw('12233444423.123123123123123', 18).format({
Expand All @@ -697,18 +697,18 @@ describe('performs BN unit test', () => {
decimalSeparator: '.',
groupSize: 3,
}),
).toBe('122 334 444 23.12 31 23')
).toBe('12 233 444 423.12 31 23')

expect(
BN.fromRaw('12233444423.123123123123123', 18).format({
decimals: 6,
decimals: 9,
groupSeparator: ' ',
fractionGroupSize: 2,
fractionGroupSeparator: '_',
decimalSeparator: '.',
groupSize: 3,
}),
).toBe('122 334 444 23.12_31_23')
).toBe('12 233 444 423.1_23_12_31_23')
})
})
})
16 changes: 10 additions & 6 deletions packages/tools/src/bn/format.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assert } from '@/helpers'
import { assert, reverseString } from '@/helpers'
import type { BnFormatConfig } from '@/types'

export const format = (value: string, format: BnFormatConfig) => {
Expand Down Expand Up @@ -27,7 +27,9 @@ export const format = (value: string, format: BnFormatConfig) => {
if (sign) whole = whole.slice(1)

if (groupSize && groupSeparator) {
whole = insertCharEveryN(whole, groupSeparator, groupSize)
whole = reverseString(
insertCharEveryN(reverseString(whole), groupSeparator, groupSize),
)
}

if (decimals) {
Expand All @@ -38,10 +40,12 @@ export const format = (value: string, format: BnFormatConfig) => {
}

if (fractionGroupSeparator && fractionGroupSize) {
fraction = insertCharEveryN(
fraction,
fractionGroupSeparator,
fractionGroupSize,
fraction = reverseString(
insertCharEveryN(
reverseString(fraction),
fractionGroupSeparator,
fractionGroupSize,
),
)
}

Expand Down
4 changes: 4 additions & 0 deletions packages/tools/src/helpers/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ export function assert(
): asserts expression is false {
if (!expression) throw new RuntimeError(message)
}

export const reverseString = (str: string): string => {
return str.split('').reverse().join('')
}
2 changes: 1 addition & 1 deletion packages/w3p/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@distributedlab/w3p",
"version": "1.0.0-rc.4",
"version": "1.0.0-rc.5",
"description": "Wrapper for Web3 Providers",
"repository": {
"type": "git",
Expand Down

0 comments on commit d9f3310

Please sign in to comment.