Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-bags-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@layerstack/utils': patch
---

feat(format): Support passing config option to easily set `type` and additional `options` as single object (ex. `format(number, { type: 'currency', options: { notation: 'compact' } })`)
5 changes: 5 additions & 0 deletions .changeset/two-doodles-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@layerstack/utils': patch
---

feat(format): Support passing PeriodTypeCode strings to easily format dates (ex. `format(date, 'day')`)
6 changes: 3 additions & 3 deletions packages/utils/src/lib/array.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest';

import { greatestAbs, sumObjects } from './array.js';
import { testDate } from './date.test.js';
import { testDateStr } from './date.test.js';

describe('sumObjects', () => {
it('Sum array of objects ', () => {
Expand All @@ -11,7 +11,7 @@ describe('sumObjects', () => {
{ one: null, two: null, three: null, four: null },
{ one: NaN, two: NaN, three: NaN, four: NaN },
{ one: 'NaN', two: 'NaN', three: 'NaN', four: 'NaN' },
{ one: '3', two: 6, four: '4', startDate: new Date(testDate) },
{ one: '3', two: 6, four: '4', startDate: new Date(testDateStr) },
];

const actual = sumObjects(values);
Expand All @@ -21,7 +21,7 @@ describe('sumObjects', () => {
three: 9,
four: 4,
extra: 0,
startDate: +new Date(testDate),
startDate: +new Date(testDateStr),
};

expect(actual).toEqual(expected);
Expand Down
Loading