@etsoo/shared 1.1.75 → 1.1.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
1
  import { NumberUtils } from '../src/NumberUtils';
2
2
 
3
3
  test('Tests for format', () => {
4
- expect(NumberUtils.format(undefined)).toBeUndefined();
5
4
  expect(NumberUtils.format(12.4, 'zh-CN', { style: 'percent' })).toBe(
6
5
  '1,240%'
7
6
  );
@@ -15,7 +15,7 @@ export declare namespace NumberUtils {
15
15
  * @param options Options
16
16
  * @returns Result
17
17
  */
18
- function format(input?: number | bigint, locale?: string | string[], options?: Intl.NumberFormatOptions): string | undefined;
18
+ function format(input: number | bigint, locale?: string | string[], options?: Intl.NumberFormatOptions): string;
19
19
  /**
20
20
  * Format money
21
21
  * @param input Input
@@ -25,12 +25,12 @@ export declare namespace NumberUtils {
25
25
  * @param options Options
26
26
  * @returns Result
27
27
  */
28
- function formatMoney(input?: number | bigint, currency?: string, locale?: string | string[], isInteger?: boolean, options?: Intl.NumberFormatOptions): string | undefined;
28
+ function formatMoney(input: number | bigint, currency?: string, locale?: string | string[], isInteger?: boolean, options?: Intl.NumberFormatOptions): string;
29
29
  /**
30
30
  * Parse float value
31
31
  * @param rawData Raw data
32
32
  */
33
- const parse: (rawData: string | number | undefined | object) => number;
33
+ const parse: (rawData: unknown) => number;
34
34
  /**
35
35
  * Parse float value and unit
36
36
  * @param input Input string
@@ -19,8 +19,6 @@ var NumberUtils;
19
19
  * @returns Result
20
20
  */
21
21
  function format(input, locale, options) {
22
- if (input == null)
23
- return undefined;
24
22
  // Formatter
25
23
  const intl = new Intl.NumberFormat(locale, options);
26
24
  return intl.format(input);
@@ -15,7 +15,7 @@ export declare namespace NumberUtils {
15
15
  * @param options Options
16
16
  * @returns Result
17
17
  */
18
- function format(input?: number | bigint, locale?: string | string[], options?: Intl.NumberFormatOptions): string | undefined;
18
+ function format(input: number | bigint, locale?: string | string[], options?: Intl.NumberFormatOptions): string;
19
19
  /**
20
20
  * Format money
21
21
  * @param input Input
@@ -25,12 +25,12 @@ export declare namespace NumberUtils {
25
25
  * @param options Options
26
26
  * @returns Result
27
27
  */
28
- function formatMoney(input?: number | bigint, currency?: string, locale?: string | string[], isInteger?: boolean, options?: Intl.NumberFormatOptions): string | undefined;
28
+ function formatMoney(input: number | bigint, currency?: string, locale?: string | string[], isInteger?: boolean, options?: Intl.NumberFormatOptions): string;
29
29
  /**
30
30
  * Parse float value
31
31
  * @param rawData Raw data
32
32
  */
33
- const parse: (rawData: string | number | undefined | object) => number;
33
+ const parse: (rawData: unknown) => number;
34
34
  /**
35
35
  * Parse float value and unit
36
36
  * @param input Input string
@@ -16,8 +16,6 @@ export var NumberUtils;
16
16
  * @returns Result
17
17
  */
18
18
  function format(input, locale, options) {
19
- if (input == null)
20
- return undefined;
21
19
  // Formatter
22
20
  const intl = new Intl.NumberFormat(locale, options);
23
21
  return intl.format(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.1.75",
3
+ "version": "1.1.77",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -26,15 +26,12 @@ export namespace NumberUtils {
26
26
  * @returns Result
27
27
  */
28
28
  export function format(
29
- input?: number | bigint,
29
+ input: number | bigint,
30
30
  locale?: string | string[],
31
31
  options?: Intl.NumberFormatOptions
32
32
  ) {
33
- if (input == null) return undefined;
34
-
35
33
  // Formatter
36
34
  const intl = new Intl.NumberFormat(locale, options);
37
-
38
35
  return intl.format(input);
39
36
  }
40
37
 
@@ -48,7 +45,7 @@ export namespace NumberUtils {
48
45
  * @returns Result
49
46
  */
50
47
  export function formatMoney(
51
- input?: number | bigint,
48
+ input: number | bigint,
52
49
  currency?: string,
53
50
  locale?: string | string[],
54
51
  isInteger: boolean = false,
@@ -73,9 +70,7 @@ export namespace NumberUtils {
73
70
  * Parse float value
74
71
  * @param rawData Raw data
75
72
  */
76
- export const parse = (
77
- rawData: string | number | undefined | object
78
- ): number => {
73
+ export const parse = (rawData: unknown): number => {
79
74
  if (rawData == null) {
80
75
  return Number.NaN;
81
76
  }