mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-22 13:15:49 +00:00
- Removes need for bundlers to polyfill the `Buffer` class. `UInt8Array` are used instead which are native to the browser and node. - Reduces bundle size 7.1kb gzipped and eliminates 4 runtime dependencies: `base-x`, `base64-js`, `buffer`, and `ieee754`. BREAKING CHANGE: All methods that previously took a `Buffer` now accept a `UInt8Array`. --------- Co-authored-by: Jackson Mills <jmills@ripple.com>
17 lines
589 B
TypeScript
17 lines
589 B
TypeScript
const { quality } = require('../src/coretypes')
|
|
const { bytesToHex } = require('@xrplf/isomorphic/utils')
|
|
|
|
describe('Quality encode/decode', function () {
|
|
const bookDirectory =
|
|
'4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5D06F4C3362FE1D0'
|
|
const expectedQuality = '195796912.5171664'
|
|
it('can decode', function () {
|
|
const decimal = quality.decode(bookDirectory)
|
|
expect(decimal.toString()).toBe(expectedQuality)
|
|
})
|
|
it('can encode', function () {
|
|
const bytes = quality.encode(expectedQuality)
|
|
expect(bytesToHex(bytes)).toBe(bookDirectory.slice(-16))
|
|
})
|
|
})
|