From 1a00637a1e10b63492b6bd6eff2361fdfc219b5f Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Tue, 23 Jan 2024 21:11:27 +0100 Subject: [PATCH 1/2] fix: export formatHuman --- src/common/data/format.spec.ts | 16 ++++++++-------- src/common/data/format.ts | 2 -- src/common/data/index.ts | 1 + 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/common/data/format.spec.ts b/src/common/data/format.spec.ts index 1ed7bf72..b15a9d4e 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 04577b08..ae42162d 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 6be9a49e..1e887784 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' From 11fc6900bdbc63dfb86a1f87af5fe8ccec09f102 Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Tue, 23 Jan 2024 21:11:30 +0100 Subject: [PATCH 2/2] 0.16.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 458016d6..f407d4b7 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",