diff --git a/package.json b/package.json index 5c2483b..d58b882 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@octocloud/core", - "version": "1.0.55", + "version": "1.0.56", "license": "ISC", "author": "", "exports": { diff --git a/src/index.ts b/src/index.ts index 8213353..caf2fa3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,6 @@ export * from './models/SubRequestRetryData'; export * from './models/UnitItemsHelper'; export * from './models/DefaultResponseHandler'; export * from './models/PhoneParser'; -export * from './models/FinanceHelper'; export * from './services/DataGenerationService'; diff --git a/src/models/FinanceHelper.ts b/src/models/FinanceHelper.ts deleted file mode 100644 index 48b2cfb..0000000 --- a/src/models/FinanceHelper.ts +++ /dev/null @@ -1,11 +0,0 @@ -export class FinanceHelper { - public bankersRounding(value: number, decimalPlaces?: number): number { - const m = 10 ** (decimalPlaces || 0); - const n = +(decimalPlaces ? value * m : value).toFixed(8); - const i = Math.floor(n); - const f = n - i; - const e = 1e-8; - const r = f > 0.5 - e && f < 0.5 + e ? (i % 2 === 0 ? i : i + 1) : Math.round(n); - return decimalPlaces ? r / m : r; - } -} diff --git a/src/models/__tests__/FinanceHelper.test.ts b/src/models/__tests__/FinanceHelper.test.ts deleted file mode 100644 index cc8a967..0000000 --- a/src/models/__tests__/FinanceHelper.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { describe, expect, it } from 'vitest'; -import { FinanceHelper } from '../FinanceHelper'; - -describe('FinanceHelper', () => { - const financeHelper = new FinanceHelper(); - - describe('bankersRounding', () => { - it('should round the value using bankers rounding', () => { - // Test case 1 - expect(financeHelper.bankersRounding(1.4)).toBe(1); - - // Test case 2 - expect(financeHelper.bankersRounding(1.5)).toBe(2); - - // Test case 3 - expect(financeHelper.bankersRounding(1.6)).toBe(2); - - // Test case 4 - expect(financeHelper.bankersRounding(2.5)).toBe(2); - - // Test case 5 - expect(financeHelper.bankersRounding(2.6)).toBe(3); - }); - - it('should round the value to the specified decimal places', () => { - // Test case 6 - expect(financeHelper.bankersRounding(1.23456789, 2)).toBe(1.23); - - // Test case 7 - expect(financeHelper.bankersRounding(1.23556789, 2)).toBe(1.24); - - // Test case 8 - expect(financeHelper.bankersRounding(1.23656789, 2)).toBe(1.24); - }); - }); -});