diff --git a/package.json b/package.json index 458016d..f407d4b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zeed", "type": "module", - "version": "0.16.5", + "version": "0.16.6", "description": "🌱 Simple foundation library", "author": { "name": "Dirk Holtwick", diff --git a/src/common/data/format.spec.ts b/src/common/data/format.spec.ts index 1ed7bf7..b15a9d4 100644 --- a/src/common/data/format.spec.ts +++ b/src/common/data/format.spec.ts @@ -1,14 +1,14 @@ -import { formatBytesToHuman, formatBytesToHumanBase1000, formatSecondsToTime } from './format' +import { formatBytesToHumanBase1000, formatBytesToHumanBase1024, formatSecondsToTime } from './format' describe('format.spec', () => { it('should format bytes in 1024 steps', async () => { - expect(formatBytesToHuman(123)).toMatchInlineSnapshot('"123 bytes"') - expect(formatBytesToHuman(16 * 1024)).toMatchInlineSnapshot('"16.00 KiB"') - expect(formatBytesToHuman(16 * 1024 * 1024)).toMatchInlineSnapshot('"16.00 MiB"') - expect(formatBytesToHuman(16 * 1024 + 123)).toMatchInlineSnapshot('"16.12 KiB"') - expect(formatBytesToHuman(16 * 1024 + 123, 0)).toMatchInlineSnapshot('"16 KiB"') - expect(formatBytesToHuman(-123)).toMatchInlineSnapshot('"0 bytes"') - expect(formatBytesToHuman(0)).toMatchInlineSnapshot('"0 bytes"') + expect(formatBytesToHumanBase1024(123)).toMatchInlineSnapshot('"123 bytes"') + expect(formatBytesToHumanBase1024(16 * 1024)).toMatchInlineSnapshot('"16.00 KiB"') + expect(formatBytesToHumanBase1024(16 * 1024 * 1024)).toMatchInlineSnapshot('"16.00 MiB"') + expect(formatBytesToHumanBase1024(16 * 1024 + 123)).toMatchInlineSnapshot('"16.12 KiB"') + expect(formatBytesToHumanBase1024(16 * 1024 + 123, 0)).toMatchInlineSnapshot('"16 KiB"') + expect(formatBytesToHumanBase1024(-123)).toMatchInlineSnapshot('"0 bytes"') + expect(formatBytesToHumanBase1024(0)).toMatchInlineSnapshot('"0 bytes"') }) it('should format bytes in 1000 steps', async () => { diff --git a/src/common/data/format.ts b/src/common/data/format.ts index 04577b0..ae42162 100644 --- a/src/common/data/format.ts +++ b/src/common/data/format.ts @@ -15,8 +15,6 @@ export function formatBytesToHumanBase1024(bytes: number, decimals = 2) { return (`${(1 / h).toFixed(i > 0 ? decimals : 0).toLocaleString()} ${units[i]}`) } -export const formatBytesToHuman = formatBytesToHumanBase1024 - /** Just a simple yet fast helper. Alternatively you may use Intl formatters http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat */ export function formatBytesToHumanBase1000(bytes: number, decimals = 2) { // https://en.wikipedia.org/wiki/Orders_of_magnitude_(data) diff --git a/src/common/data/index.ts b/src/common/data/index.ts index 6be9a49..1e88778 100644 --- a/src/common/data/index.ts +++ b/src/common/data/index.ts @@ -9,6 +9,7 @@ export * from './day' export * from './decimal' export * from './deep' export * from './diff' +export * from './format' export * from './html' export * from './is' export * from './json'