@digitalwalletcorp/utils 0.2.0 → 0.4.1

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.
Files changed (112) hide show
  1. package/README.md +13 -13
  2. package/lib/crypto-util-DFJqfmuw.js +46 -0
  3. package/lib/crypto-util-DFJqfmuw.js.map +1 -0
  4. package/lib/crypto-util-DeZSGetI.cjs +2 -0
  5. package/lib/crypto-util-DeZSGetI.cjs.map +1 -0
  6. package/lib/crypto-util.cjs +2 -0
  7. package/lib/crypto-util.cjs.map +1 -0
  8. package/lib/crypto-util.d.cts +28 -0
  9. package/lib/crypto-util.d.ts +28 -0
  10. package/lib/crypto-util.js +7 -0
  11. package/lib/crypto-util.js.map +1 -0
  12. package/lib/date-util-CG7L8nSP.js +184 -0
  13. package/lib/date-util-CG7L8nSP.js.map +1 -0
  14. package/lib/date-util-DopNKy3u.cjs +2 -0
  15. package/lib/date-util-DopNKy3u.cjs.map +1 -0
  16. package/lib/date-util.cjs +2 -0
  17. package/lib/date-util.cjs.map +1 -0
  18. package/lib/date-util.d.cts +231 -0
  19. package/lib/date-util.d.ts +231 -0
  20. package/lib/date-util.js +23 -0
  21. package/lib/date-util.js.map +1 -0
  22. package/lib/decimal.cjs +2 -0
  23. package/lib/decimal.cjs.map +1 -0
  24. package/lib/decimal.d.cts +197 -0
  25. package/lib/decimal.d.ts +197 -0
  26. package/lib/decimal.js +227 -0
  27. package/lib/decimal.js.map +1 -0
  28. package/lib/file-util-D09BvDYY.cjs +2 -0
  29. package/lib/file-util-D09BvDYY.cjs.map +1 -0
  30. package/lib/file-util-H-c_eQcd.js +140 -0
  31. package/lib/file-util-H-c_eQcd.js.map +1 -0
  32. package/lib/file-util.cjs +2 -0
  33. package/lib/file-util.cjs.map +1 -0
  34. package/lib/file-util.d.cts +119 -0
  35. package/lib/file-util.d.ts +119 -0
  36. package/lib/file-util.js +18 -0
  37. package/lib/file-util.js.map +1 -0
  38. package/lib/html-util-CcRJtzod.js +56 -0
  39. package/lib/html-util-CcRJtzod.js.map +1 -0
  40. package/lib/html-util-ClGIpzW1.cjs +2 -0
  41. package/lib/html-util-ClGIpzW1.cjs.map +1 -0
  42. package/lib/html-util.cjs +2 -0
  43. package/lib/html-util.cjs.map +1 -0
  44. package/lib/html-util.d.cts +84 -0
  45. package/lib/html-util.d.ts +84 -0
  46. package/lib/html-util.js +10 -0
  47. package/lib/html-util.js.map +1 -0
  48. package/lib/index.cjs +1 -1
  49. package/lib/index.d.cts +8 -0
  50. package/lib/index.d.ts +8 -0
  51. package/lib/index.js +18 -2
  52. package/lib/index.js.map +1 -1
  53. package/lib/json-util-5mq7fsX_.cjs +4 -0
  54. package/lib/json-util-5mq7fsX_.cjs.map +1 -0
  55. package/lib/json-util-CF-O1b7m.js +149 -0
  56. package/lib/json-util-CF-O1b7m.js.map +1 -0
  57. package/lib/json-util.cjs +2 -0
  58. package/lib/json-util.cjs.map +1 -0
  59. package/lib/json-util.d.cts +58 -0
  60. package/lib/json-util.d.ts +58 -0
  61. package/lib/json-util.js +8 -0
  62. package/lib/json-util.js.map +1 -0
  63. package/lib/number-util-BA4KVFyF.js +198 -0
  64. package/lib/number-util-BA4KVFyF.js.map +1 -0
  65. package/lib/number-util-BaSf1wWH.cjs +2 -0
  66. package/lib/number-util-BaSf1wWH.cjs.map +1 -0
  67. package/lib/number-util.cjs +1 -1
  68. package/lib/number-util.d.cts +65 -51
  69. package/lib/number-util.d.ts +65 -51
  70. package/lib/number-util.js +19 -14
  71. package/lib/object-util-6uts5Xax.cjs +2 -0
  72. package/lib/object-util-6uts5Xax.cjs.map +1 -0
  73. package/lib/object-util-auzl09b5.js +204 -0
  74. package/lib/object-util-auzl09b5.js.map +1 -0
  75. package/lib/object-util.cjs +2 -0
  76. package/lib/object-util.cjs.map +1 -0
  77. package/lib/object-util.d.cts +157 -0
  78. package/lib/object-util.d.ts +157 -0
  79. package/lib/object-util.js +16 -0
  80. package/lib/object-util.js.map +1 -0
  81. package/lib/string-util-Cw0VgbIH.js +52 -0
  82. package/lib/string-util-Cw0VgbIH.js.map +1 -0
  83. package/lib/string-util-w2I5EYuY.cjs +2 -0
  84. package/lib/string-util-w2I5EYuY.cjs.map +1 -0
  85. package/lib/string-util.cjs +2 -0
  86. package/lib/string-util.cjs.map +1 -0
  87. package/lib/string-util.d.cts +51 -0
  88. package/lib/string-util.d.ts +51 -0
  89. package/lib/string-util.js +8 -0
  90. package/lib/string-util.js.map +1 -0
  91. package/package.json +26 -8
  92. package/src/crypto-util.ts +84 -0
  93. package/src/date-util.ts +448 -0
  94. package/src/decimal.ts +294 -0
  95. package/src/file-util.ts +281 -0
  96. package/src/html-util.ts +215 -0
  97. package/src/index.ts +8 -0
  98. package/src/json-util.ts +291 -0
  99. package/src/number-util.ts +141 -194
  100. package/src/object-util.ts +482 -0
  101. package/src/string-util.ts +115 -0
  102. package/lib/number-util-DHq-ux31.js +0 -253
  103. package/lib/number-util-DHq-ux31.js.map +0 -1
  104. package/lib/number-util-DiMi-j7B.cjs +0 -2
  105. package/lib/number-util-DiMi-j7B.cjs.map +0 -1
  106. package/lib/reg-exp-matcher.cjs +0 -2
  107. package/lib/reg-exp-matcher.cjs.map +0 -1
  108. package/lib/reg-exp-matcher.d.cts +0 -85
  109. package/lib/reg-exp-matcher.d.ts +0 -85
  110. package/lib/reg-exp-matcher.js +0 -94
  111. package/lib/reg-exp-matcher.js.map +0 -1
  112. package/src/reg-exp-matcher.ts +0 -154
@@ -0,0 +1,197 @@
1
+ /**
2
+ * 数値として扱える値の型
3
+ */
4
+ export type NumberSource = number | string | bigint;
5
+ /**
6
+ * 丸めモード
7
+ */
8
+ export declare const ROUNDING_MODE: {
9
+ /**
10
+ * Rounds towards zero.
11
+ * I.e. truncate, no rounding.
12
+ */
13
+ readonly roundDown: 0;
14
+ /**
15
+ * Rounds towards nearest neighbour.
16
+ * If equidistant, rounds away from zero.
17
+ */
18
+ readonly roundHalfUp: 1;
19
+ /**
20
+ * Rounds towards nearest neighbour.
21
+ * If equidistant, rounds towards even neighbour.
22
+ */
23
+ readonly roundHalfEven: 2;
24
+ /**
25
+ * Rounds away from zero.
26
+ */
27
+ readonly roundUp: 3;
28
+ };
29
+ export type RoundingMode = typeof ROUNDING_MODE[keyof typeof ROUNDING_MODE];
30
+ /**
31
+ * Decimalの生成・演算に渡せる値の型
32
+ * null/undefined/空文字/NaNは0とみなす(divの割る値は1とみなす)
33
+ */
34
+ export type DecimalSource = NumberSource | Decimal | null | undefined;
35
+ /**
36
+ * 任意精度の10進数を表す不変オブジェクト
37
+ * 演算メソッドは自身を変更せず、結果を新しいインスタンスで返す
38
+ * 除算は小数20桁(roundHalfUp)まで保持し、それ以降の桁は切り捨てではなく丸める
39
+ */
40
+ export declare class Decimal {
41
+ /** 丸めモード */
42
+ static readonly ROUNDING_MODE: {
43
+ /**
44
+ * Rounds towards zero.
45
+ * I.e. truncate, no rounding.
46
+ */
47
+ readonly roundDown: 0;
48
+ /**
49
+ * Rounds towards nearest neighbour.
50
+ * If equidistant, rounds away from zero.
51
+ */
52
+ readonly roundHalfUp: 1;
53
+ /**
54
+ * Rounds towards nearest neighbour.
55
+ * If equidistant, rounds towards even neighbour.
56
+ */
57
+ readonly roundHalfEven: 2;
58
+ /**
59
+ * Rounds away from zero.
60
+ */
61
+ readonly roundUp: 3;
62
+ };
63
+ /**
64
+ * 算術演算インスタンス
65
+ */
66
+ private big;
67
+ /**
68
+ * @param {DecimalSource} value 数値、数値文字列、bigint、Decimal
69
+ * null/undefined/空文字/NaNは0とみなす
70
+ * 数値として解釈できない文字列・Infinityは TypeError をスローする
71
+ */
72
+ constructor(value: DecimalSource);
73
+ private static toBig;
74
+ private static wrap;
75
+ /**
76
+ * 加算した結果を返す
77
+ * null/undefined/空文字/NaNは0とみなす
78
+ *
79
+ * @param {DecimalSource} value
80
+ * @returns {Decimal}
81
+ */
82
+ add(value: DecimalSource): Decimal;
83
+ /**
84
+ * 減算した結果を返す
85
+ * null/undefined/空文字/NaNは0とみなす
86
+ *
87
+ * @param {DecimalSource} value
88
+ * @returns {Decimal}
89
+ */
90
+ sub(value: DecimalSource): Decimal;
91
+ /**
92
+ * 乗算した結果を返す
93
+ * null/undefined/空文字/NaNは0とみなすため、結果は0になる
94
+ * 元の値を保持したい場合は times(discount ?? 1) のようにフォールバック値を指定する
95
+ *
96
+ * @param {DecimalSource} value
97
+ * @returns {Decimal}
98
+ */
99
+ times(value: DecimalSource): Decimal;
100
+ /**
101
+ * 除算した結果を返す
102
+ * 結果は小数20桁(roundHalfUp)まで保持する
103
+ * 割る値のnull/undefined/空文字/NaNは1とみなすため、結果は元の値と同じになる
104
+ * 割る値に0を指定した場合は RangeError をスローする
105
+ *
106
+ * @param {DecimalSource} value
107
+ * @returns {Decimal}
108
+ */
109
+ div(value: DecimalSource): Decimal;
110
+ /**
111
+ * 指定した小数桁で丸めた結果を返す
112
+ * 負の桁数を指定すると整数部を丸める(-2 なら百の位)
113
+ *
114
+ * @param {number} [scale] 小数桁数 デフォルトは0
115
+ * @param {RoundingMode} [roundingMode] 丸めモード デフォルトはROUNDING_MODE.roundHalfUp(四捨五入・half-away-from-zero)
116
+ * @returns {Decimal}
117
+ */
118
+ round(scale?: number, roundingMode?: RoundingMode): Decimal;
119
+ /**
120
+ * 絶対値を返す
121
+ *
122
+ * @returns {Decimal}
123
+ */
124
+ abs(): Decimal;
125
+ /**
126
+ * 値を比較する
127
+ * null/undefined/空文字/NaNは0とみなす
128
+ *
129
+ * @param {DecimalSource} value
130
+ * @returns {-1 | 0 | 1} 自身が小さければ-1、等しければ0、大きければ1
131
+ */
132
+ compareTo(value: DecimalSource): -1 | 0 | 1;
133
+ /**
134
+ * 等しいか判定する
135
+ * null/undefined/空文字/NaNは0とみなす
136
+ *
137
+ * @param {DecimalSource} value
138
+ * @returns {boolean}
139
+ */
140
+ eq(value: DecimalSource): boolean;
141
+ /**
142
+ * 自身が小さいか判定する
143
+ * null/undefined/空文字/NaNは0とみなす
144
+ *
145
+ * @param {DecimalSource} value
146
+ * @returns {boolean}
147
+ */
148
+ lt(value: DecimalSource): boolean;
149
+ /**
150
+ * 自身が小さいか等しいか判定する
151
+ * null/undefined/空文字/NaNは0とみなす
152
+ *
153
+ * @param {DecimalSource} value
154
+ * @returns {boolean}
155
+ */
156
+ lte(value: DecimalSource): boolean;
157
+ /**
158
+ * 自身が大きいか判定する
159
+ * null/undefined/空文字/NaNは0とみなす
160
+ *
161
+ * @param {DecimalSource} value
162
+ * @returns {boolean}
163
+ */
164
+ gt(value: DecimalSource): boolean;
165
+ /**
166
+ * 自身が大きいか等しいか判定する
167
+ * null/undefined/空文字/NaNは0とみなす
168
+ *
169
+ * @param {DecimalSource} value
170
+ * @returns {boolean}
171
+ */
172
+ gte(value: DecimalSource): boolean;
173
+ /**
174
+ * numberに変換する
175
+ * Number.MAX_SAFE_INTEGERを超える値や、numberで表現できない桁数の小数は精度が落ちる
176
+ *
177
+ * @returns {number}
178
+ */
179
+ toNumber(): number;
180
+ /**
181
+ * 指定した小数桁で丸め、小数桁を0で埋めた文字列に変換する
182
+ * 指数表記にはならず、通常の表記で返す
183
+ * 丸めた結果が0になる場合は符号を付けない
184
+ *
185
+ * @param {number} scale 小数桁数
186
+ * @param {RoundingMode} [roundingMode] 丸めモード デフォルトはROUNDING_MODE.roundHalfUp(四捨五入・half-away-from-zero)
187
+ * @returns {string}
188
+ */
189
+ toFixed(scale: number, roundingMode?: RoundingMode): string;
190
+ /**
191
+ * 文字列に変換する
192
+ * 指数表記にはならず、通常の表記で返す
193
+ *
194
+ * @returns {string}
195
+ */
196
+ toString(): string;
197
+ }
@@ -0,0 +1,197 @@
1
+ /**
2
+ * 数値として扱える値の型
3
+ */
4
+ export type NumberSource = number | string | bigint;
5
+ /**
6
+ * 丸めモード
7
+ */
8
+ export declare const ROUNDING_MODE: {
9
+ /**
10
+ * Rounds towards zero.
11
+ * I.e. truncate, no rounding.
12
+ */
13
+ readonly roundDown: 0;
14
+ /**
15
+ * Rounds towards nearest neighbour.
16
+ * If equidistant, rounds away from zero.
17
+ */
18
+ readonly roundHalfUp: 1;
19
+ /**
20
+ * Rounds towards nearest neighbour.
21
+ * If equidistant, rounds towards even neighbour.
22
+ */
23
+ readonly roundHalfEven: 2;
24
+ /**
25
+ * Rounds away from zero.
26
+ */
27
+ readonly roundUp: 3;
28
+ };
29
+ export type RoundingMode = typeof ROUNDING_MODE[keyof typeof ROUNDING_MODE];
30
+ /**
31
+ * Decimalの生成・演算に渡せる値の型
32
+ * null/undefined/空文字/NaNは0とみなす(divの割る値は1とみなす)
33
+ */
34
+ export type DecimalSource = NumberSource | Decimal | null | undefined;
35
+ /**
36
+ * 任意精度の10進数を表す不変オブジェクト
37
+ * 演算メソッドは自身を変更せず、結果を新しいインスタンスで返す
38
+ * 除算は小数20桁(roundHalfUp)まで保持し、それ以降の桁は切り捨てではなく丸める
39
+ */
40
+ export declare class Decimal {
41
+ /** 丸めモード */
42
+ static readonly ROUNDING_MODE: {
43
+ /**
44
+ * Rounds towards zero.
45
+ * I.e. truncate, no rounding.
46
+ */
47
+ readonly roundDown: 0;
48
+ /**
49
+ * Rounds towards nearest neighbour.
50
+ * If equidistant, rounds away from zero.
51
+ */
52
+ readonly roundHalfUp: 1;
53
+ /**
54
+ * Rounds towards nearest neighbour.
55
+ * If equidistant, rounds towards even neighbour.
56
+ */
57
+ readonly roundHalfEven: 2;
58
+ /**
59
+ * Rounds away from zero.
60
+ */
61
+ readonly roundUp: 3;
62
+ };
63
+ /**
64
+ * 算術演算インスタンス
65
+ */
66
+ private big;
67
+ /**
68
+ * @param {DecimalSource} value 数値、数値文字列、bigint、Decimal
69
+ * null/undefined/空文字/NaNは0とみなす
70
+ * 数値として解釈できない文字列・Infinityは TypeError をスローする
71
+ */
72
+ constructor(value: DecimalSource);
73
+ private static toBig;
74
+ private static wrap;
75
+ /**
76
+ * 加算した結果を返す
77
+ * null/undefined/空文字/NaNは0とみなす
78
+ *
79
+ * @param {DecimalSource} value
80
+ * @returns {Decimal}
81
+ */
82
+ add(value: DecimalSource): Decimal;
83
+ /**
84
+ * 減算した結果を返す
85
+ * null/undefined/空文字/NaNは0とみなす
86
+ *
87
+ * @param {DecimalSource} value
88
+ * @returns {Decimal}
89
+ */
90
+ sub(value: DecimalSource): Decimal;
91
+ /**
92
+ * 乗算した結果を返す
93
+ * null/undefined/空文字/NaNは0とみなすため、結果は0になる
94
+ * 元の値を保持したい場合は times(discount ?? 1) のようにフォールバック値を指定する
95
+ *
96
+ * @param {DecimalSource} value
97
+ * @returns {Decimal}
98
+ */
99
+ times(value: DecimalSource): Decimal;
100
+ /**
101
+ * 除算した結果を返す
102
+ * 結果は小数20桁(roundHalfUp)まで保持する
103
+ * 割る値のnull/undefined/空文字/NaNは1とみなすため、結果は元の値と同じになる
104
+ * 割る値に0を指定した場合は RangeError をスローする
105
+ *
106
+ * @param {DecimalSource} value
107
+ * @returns {Decimal}
108
+ */
109
+ div(value: DecimalSource): Decimal;
110
+ /**
111
+ * 指定した小数桁で丸めた結果を返す
112
+ * 負の桁数を指定すると整数部を丸める(-2 なら百の位)
113
+ *
114
+ * @param {number} [scale] 小数桁数 デフォルトは0
115
+ * @param {RoundingMode} [roundingMode] 丸めモード デフォルトはROUNDING_MODE.roundHalfUp(四捨五入・half-away-from-zero)
116
+ * @returns {Decimal}
117
+ */
118
+ round(scale?: number, roundingMode?: RoundingMode): Decimal;
119
+ /**
120
+ * 絶対値を返す
121
+ *
122
+ * @returns {Decimal}
123
+ */
124
+ abs(): Decimal;
125
+ /**
126
+ * 値を比較する
127
+ * null/undefined/空文字/NaNは0とみなす
128
+ *
129
+ * @param {DecimalSource} value
130
+ * @returns {-1 | 0 | 1} 自身が小さければ-1、等しければ0、大きければ1
131
+ */
132
+ compareTo(value: DecimalSource): -1 | 0 | 1;
133
+ /**
134
+ * 等しいか判定する
135
+ * null/undefined/空文字/NaNは0とみなす
136
+ *
137
+ * @param {DecimalSource} value
138
+ * @returns {boolean}
139
+ */
140
+ eq(value: DecimalSource): boolean;
141
+ /**
142
+ * 自身が小さいか判定する
143
+ * null/undefined/空文字/NaNは0とみなす
144
+ *
145
+ * @param {DecimalSource} value
146
+ * @returns {boolean}
147
+ */
148
+ lt(value: DecimalSource): boolean;
149
+ /**
150
+ * 自身が小さいか等しいか判定する
151
+ * null/undefined/空文字/NaNは0とみなす
152
+ *
153
+ * @param {DecimalSource} value
154
+ * @returns {boolean}
155
+ */
156
+ lte(value: DecimalSource): boolean;
157
+ /**
158
+ * 自身が大きいか判定する
159
+ * null/undefined/空文字/NaNは0とみなす
160
+ *
161
+ * @param {DecimalSource} value
162
+ * @returns {boolean}
163
+ */
164
+ gt(value: DecimalSource): boolean;
165
+ /**
166
+ * 自身が大きいか等しいか判定する
167
+ * null/undefined/空文字/NaNは0とみなす
168
+ *
169
+ * @param {DecimalSource} value
170
+ * @returns {boolean}
171
+ */
172
+ gte(value: DecimalSource): boolean;
173
+ /**
174
+ * numberに変換する
175
+ * Number.MAX_SAFE_INTEGERを超える値や、numberで表現できない桁数の小数は精度が落ちる
176
+ *
177
+ * @returns {number}
178
+ */
179
+ toNumber(): number;
180
+ /**
181
+ * 指定した小数桁で丸め、小数桁を0で埋めた文字列に変換する
182
+ * 指数表記にはならず、通常の表記で返す
183
+ * 丸めた結果が0になる場合は符号を付けない
184
+ *
185
+ * @param {number} scale 小数桁数
186
+ * @param {RoundingMode} [roundingMode] 丸めモード デフォルトはROUNDING_MODE.roundHalfUp(四捨五入・half-away-from-zero)
187
+ * @returns {string}
188
+ */
189
+ toFixed(scale: number, roundingMode?: RoundingMode): string;
190
+ /**
191
+ * 文字列に変換する
192
+ * 指数表記にはならず、通常の表記で返す
193
+ *
194
+ * @returns {string}
195
+ */
196
+ toString(): string;
197
+ }
package/lib/decimal.js ADDED
@@ -0,0 +1,227 @@
1
+ import { Big as u } from "big.js";
2
+ const s = {
3
+ /**
4
+ * Rounds towards zero.
5
+ * I.e. truncate, no rounding.
6
+ */
7
+ roundDown: 0,
8
+ /**
9
+ * Rounds towards nearest neighbour.
10
+ * If equidistant, rounds away from zero.
11
+ */
12
+ roundHalfUp: 1,
13
+ /**
14
+ * Rounds towards nearest neighbour.
15
+ * If equidistant, rounds towards even neighbour.
16
+ */
17
+ roundHalfEven: 2,
18
+ /**
19
+ * Rounds away from zero.
20
+ */
21
+ roundUp: 3
22
+ }, b = 20, g = /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i, n = u();
23
+ n.DP = b;
24
+ n.RM = s.roundHalfUp;
25
+ const e = (o) => o == null || o === "" || typeof o == "number" && Number.isNaN(o);
26
+ class t {
27
+ /** 丸めモード */
28
+ static ROUNDING_MODE = s;
29
+ /**
30
+ * 算術演算インスタンス
31
+ */
32
+ big;
33
+ /**
34
+ * @param {DecimalSource} value 数値、数値文字列、bigint、Decimal
35
+ * null/undefined/空文字/NaNは0とみなす
36
+ * 数値として解釈できない文字列・Infinityは TypeError をスローする
37
+ */
38
+ constructor(r) {
39
+ this.big = t.toBig(r);
40
+ }
41
+ static toBig(r) {
42
+ if (e(r))
43
+ return n(0);
44
+ if (r instanceof t)
45
+ return r.big;
46
+ switch (typeof r) {
47
+ case "number":
48
+ if (!Number.isFinite(r))
49
+ throw new TypeError(`Invalid number: ${r}`);
50
+ return n(r);
51
+ case "bigint":
52
+ return n(r.toString());
53
+ default: {
54
+ const i = r.trim();
55
+ if (!g.test(i))
56
+ throw new TypeError(`Invalid number: ${r}`);
57
+ return n(i.replace(/^\+/, ""));
58
+ }
59
+ }
60
+ }
61
+ static wrap(r) {
62
+ const i = new t(0);
63
+ return i.big = r, i;
64
+ }
65
+ /**
66
+ * 加算した結果を返す
67
+ * null/undefined/空文字/NaNは0とみなす
68
+ *
69
+ * @param {DecimalSource} value
70
+ * @returns {Decimal}
71
+ */
72
+ add(r) {
73
+ return t.wrap(this.big.add(t.toBig(r)));
74
+ }
75
+ /**
76
+ * 減算した結果を返す
77
+ * null/undefined/空文字/NaNは0とみなす
78
+ *
79
+ * @param {DecimalSource} value
80
+ * @returns {Decimal}
81
+ */
82
+ sub(r) {
83
+ return t.wrap(this.big.sub(t.toBig(r)));
84
+ }
85
+ /**
86
+ * 乗算した結果を返す
87
+ * null/undefined/空文字/NaNは0とみなすため、結果は0になる
88
+ * 元の値を保持したい場合は times(discount ?? 1) のようにフォールバック値を指定する
89
+ *
90
+ * @param {DecimalSource} value
91
+ * @returns {Decimal}
92
+ */
93
+ times(r) {
94
+ return t.wrap(this.big.times(t.toBig(r)));
95
+ }
96
+ /**
97
+ * 除算した結果を返す
98
+ * 結果は小数20桁(roundHalfUp)まで保持する
99
+ * 割る値のnull/undefined/空文字/NaNは1とみなすため、結果は元の値と同じになる
100
+ * 割る値に0を指定した場合は RangeError をスローする
101
+ *
102
+ * @param {DecimalSource} value
103
+ * @returns {Decimal}
104
+ */
105
+ div(r) {
106
+ if (e(r))
107
+ return t.wrap(this.big);
108
+ const i = t.toBig(r);
109
+ if (i.eq(0))
110
+ throw new RangeError("Division by zero");
111
+ return t.wrap(this.big.div(i));
112
+ }
113
+ /**
114
+ * 指定した小数桁で丸めた結果を返す
115
+ * 負の桁数を指定すると整数部を丸める(-2 なら百の位)
116
+ *
117
+ * @param {number} [scale] 小数桁数 デフォルトは0
118
+ * @param {RoundingMode} [roundingMode] 丸めモード デフォルトはROUNDING_MODE.roundHalfUp(四捨五入・half-away-from-zero)
119
+ * @returns {Decimal}
120
+ */
121
+ round(r = 0, i = s.roundHalfUp) {
122
+ return t.wrap(this.big.round(r, i));
123
+ }
124
+ /**
125
+ * 絶対値を返す
126
+ *
127
+ * @returns {Decimal}
128
+ */
129
+ abs() {
130
+ return t.wrap(this.big.abs());
131
+ }
132
+ /**
133
+ * 値を比較する
134
+ * null/undefined/空文字/NaNは0とみなす
135
+ *
136
+ * @param {DecimalSource} value
137
+ * @returns {-1 | 0 | 1} 自身が小さければ-1、等しければ0、大きければ1
138
+ */
139
+ compareTo(r) {
140
+ return this.big.cmp(t.toBig(r));
141
+ }
142
+ /**
143
+ * 等しいか判定する
144
+ * null/undefined/空文字/NaNは0とみなす
145
+ *
146
+ * @param {DecimalSource} value
147
+ * @returns {boolean}
148
+ */
149
+ eq(r) {
150
+ return this.compareTo(r) === 0;
151
+ }
152
+ /**
153
+ * 自身が小さいか判定する
154
+ * null/undefined/空文字/NaNは0とみなす
155
+ *
156
+ * @param {DecimalSource} value
157
+ * @returns {boolean}
158
+ */
159
+ lt(r) {
160
+ return this.compareTo(r) < 0;
161
+ }
162
+ /**
163
+ * 自身が小さいか等しいか判定する
164
+ * null/undefined/空文字/NaNは0とみなす
165
+ *
166
+ * @param {DecimalSource} value
167
+ * @returns {boolean}
168
+ */
169
+ lte(r) {
170
+ return this.compareTo(r) <= 0;
171
+ }
172
+ /**
173
+ * 自身が大きいか判定する
174
+ * null/undefined/空文字/NaNは0とみなす
175
+ *
176
+ * @param {DecimalSource} value
177
+ * @returns {boolean}
178
+ */
179
+ gt(r) {
180
+ return 0 < this.compareTo(r);
181
+ }
182
+ /**
183
+ * 自身が大きいか等しいか判定する
184
+ * null/undefined/空文字/NaNは0とみなす
185
+ *
186
+ * @param {DecimalSource} value
187
+ * @returns {boolean}
188
+ */
189
+ gte(r) {
190
+ return 0 <= this.compareTo(r);
191
+ }
192
+ /**
193
+ * numberに変換する
194
+ * Number.MAX_SAFE_INTEGERを超える値や、numberで表現できない桁数の小数は精度が落ちる
195
+ *
196
+ * @returns {number}
197
+ */
198
+ toNumber() {
199
+ return this.big.toNumber();
200
+ }
201
+ /**
202
+ * 指定した小数桁で丸め、小数桁を0で埋めた文字列に変換する
203
+ * 指数表記にはならず、通常の表記で返す
204
+ * 丸めた結果が0になる場合は符号を付けない
205
+ *
206
+ * @param {number} scale 小数桁数
207
+ * @param {RoundingMode} [roundingMode] 丸めモード デフォルトはROUNDING_MODE.roundHalfUp(四捨五入・half-away-from-zero)
208
+ * @returns {string}
209
+ */
210
+ toFixed(r, i = s.roundHalfUp) {
211
+ return this.big.round(r, i).toFixed(r);
212
+ }
213
+ /**
214
+ * 文字列に変換する
215
+ * 指数表記にはならず、通常の表記で返す
216
+ *
217
+ * @returns {string}
218
+ */
219
+ toString() {
220
+ return this.big.toFixed();
221
+ }
222
+ }
223
+ export {
224
+ t as Decimal,
225
+ s as ROUNDING_MODE
226
+ };
227
+ //# sourceMappingURL=decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.js","sources":["../src/decimal.ts"],"sourcesContent":["/**\n * このクラス Decimal の役割は、算術演算の実体としての Big を内部に閉じ込め、利用者側に露出させないことにある。\n * 2026-10-08時点では big.js に依存しているが、将来的に演算演算のライブラリを変更した場合に\n * 安全・簡単に移行できることを目的としている。\n */\nimport { Big } from 'big.js';\n\n/**\n * 数値として扱える値の型\n */\nexport type NumberSource = number | string | bigint;\n\n/**\n * 丸めモード\n */\nexport const ROUNDING_MODE = {\n /**\n * Rounds towards zero.\n * I.e. truncate, no rounding.\n */\n roundDown: 0,\n /**\n * Rounds towards nearest neighbour.\n * If equidistant, rounds away from zero.\n */\n roundHalfUp: 1,\n /**\n * Rounds towards nearest neighbour.\n * If equidistant, rounds towards even neighbour.\n */\n roundHalfEven: 2,\n /**\n * Rounds away from zero.\n */\n roundUp: 3\n} as const;\n\nexport type RoundingMode = typeof ROUNDING_MODE[keyof typeof ROUNDING_MODE];\n\n/**\n * Decimalの生成・演算に渡せる値の型\n * null/undefined/空文字/NaNは0とみなす(divの割る値は1とみなす)\n */\nexport type DecimalSource = NumberSource | Decimal | null | undefined;\n\n/** 除算で保持する小数桁数 */\nconst DIVISION_SCALE = 20;\n\n/** 数値として解釈できる文字列のパターン(符号・小数点・指数表記) */\nconst NUMERIC_STRING_PATTERN = /^[+-]?(\\d+\\.?\\d*|\\.\\d+)(e[+-]?\\d+)?$/i;\n\n// 独立したコンストラクタにすることで、利用側がグローバルの Big.DP / Big.RM を書き換えても影響を受けないようにする\nconst BigNumber = Big();\nBigNumber.DP = DIVISION_SCALE;\nBigNumber.RM = ROUNDING_MODE.roundHalfUp;\n\n// null/undefined/空文字/NaNはtrueを返す\nconst isEmpty = (value: DecimalSource): value is null | undefined | '' => value == null || value === '' || (typeof value === 'number' && Number.isNaN(value));\n\n/**\n * 任意精度の10進数を表す不変オブジェクト\n * 演算メソッドは自身を変更せず、結果を新しいインスタンスで返す\n * 除算は小数20桁(roundHalfUp)まで保持し、それ以降の桁は切り捨てではなく丸める\n */\nexport class Decimal {\n /** 丸めモード */\n public static readonly ROUNDING_MODE = ROUNDING_MODE;\n\n /**\n * 算術演算インスタンス\n */\n private big: Big;\n\n /**\n * @param {DecimalSource} value 数値、数値文字列、bigint、Decimal\n * null/undefined/空文字/NaNは0とみなす\n * 数値として解釈できない文字列・Infinityは TypeError をスローする\n */\n constructor(value: DecimalSource) {\n this.big = Decimal.toBig(value);\n }\n\n private static toBig(value: DecimalSource): Big {\n if (isEmpty(value)) {\n return BigNumber(0);\n }\n if (value instanceof Decimal) {\n return value.big;\n }\n switch (typeof value) {\n case 'number':\n if (!Number.isFinite(value)) {\n throw new TypeError(`Invalid number: ${value}`);\n }\n return BigNumber(value);\n case 'bigint':\n return BigNumber(value.toString());\n default: {\n const trimmed = value.trim();\n if (!NUMERIC_STRING_PATTERN.test(trimmed)) {\n throw new TypeError(`Invalid number: ${value}`);\n }\n // 先頭の '+' は数値として解釈できる表記だが、内部の算術ライブラリが受け付けないため取り除く\n return BigNumber(trimmed.replace(/^\\+/, ''));\n }\n }\n }\n\n private static wrap(big: Big): Decimal {\n const decimal = new Decimal(0);\n decimal.big = big;\n return decimal;\n }\n\n /**\n * 加算した結果を返す\n * null/undefined/空文字/NaNは0とみなす\n *\n * @param {DecimalSource} value\n * @returns {Decimal}\n */\n public add(value: DecimalSource): Decimal {\n return Decimal.wrap(this.big.add(Decimal.toBig(value)));\n }\n\n /**\n * 減算した結果を返す\n * null/undefined/空文字/NaNは0とみなす\n *\n * @param {DecimalSource} value\n * @returns {Decimal}\n */\n public sub(value: DecimalSource): Decimal {\n return Decimal.wrap(this.big.sub(Decimal.toBig(value)));\n }\n\n /**\n * 乗算した結果を返す\n * null/undefined/空文字/NaNは0とみなすため、結果は0になる\n * 元の値を保持したい場合は times(discount ?? 1) のようにフォールバック値を指定する\n *\n * @param {DecimalSource} value\n * @returns {Decimal}\n */\n public times(value: DecimalSource): Decimal {\n // 掛ける値が空のとき、0とみなすべきか元の値を保持すべきかは計算対象によって異なる\n // 手数料 x 件数: 件数が未定義なら総額は0が適切\n // 商品価格 x 割引率: 割引率が未定義なら元の価格が適切\n // 1とみなすと、new Decimal(null).times(3) は 0、new Decimal(3).times(null) は 3 になり、引数の順序で結果が変わる\n // そのため常に0とみなし、元の値を保持したい場合は呼び出し側でフォールバック値を指定する\n return Decimal.wrap(this.big.times(Decimal.toBig(value)));\n }\n\n /**\n * 除算した結果を返す\n * 結果は小数20桁(roundHalfUp)まで保持する\n * 割る値のnull/undefined/空文字/NaNは1とみなすため、結果は元の値と同じになる\n * 割る値に0を指定した場合は RangeError をスローする\n *\n * @param {DecimalSource} value\n * @returns {Decimal}\n */\n public div(value: DecimalSource): Decimal {\n // 割る値が空のとき、0とみなすとすべてゼロ除算エラーになり計算が成り立たないため1とみなす\n if (isEmpty(value)) {\n return Decimal.wrap(this.big);\n }\n const divisor = Decimal.toBig(value);\n if (divisor.eq(0)) {\n throw new RangeError('Division by zero');\n }\n return Decimal.wrap(this.big.div(divisor));\n }\n\n /**\n * 指定した小数桁で丸めた結果を返す\n * 負の桁数を指定すると整数部を丸める(-2 なら百の位)\n *\n * @param {number} [scale] 小数桁数 デフォルトは0\n * @param {RoundingMode} [roundingMode] 丸めモード デフォルトはROUNDING_MODE.roundHalfUp(四捨五入・half-away-from-zero)\n * @returns {Decimal}\n */\n public round(scale: number = 0, roundingMode: RoundingMode = ROUNDING_MODE.roundHalfUp): Decimal {\n return Decimal.wrap(this.big.round(scale, roundingMode));\n }\n\n /**\n * 絶対値を返す\n *\n * @returns {Decimal}\n */\n public abs(): Decimal {\n return Decimal.wrap(this.big.abs());\n }\n\n /**\n * 値を比較する\n * null/undefined/空文字/NaNは0とみなす\n *\n * @param {DecimalSource} value\n * @returns {-1 | 0 | 1} 自身が小さければ-1、等しければ0、大きければ1\n */\n public compareTo(value: DecimalSource): -1 | 0 | 1 {\n return this.big.cmp(Decimal.toBig(value));\n }\n\n /**\n * 等しいか判定する\n * null/undefined/空文字/NaNは0とみなす\n *\n * @param {DecimalSource} value\n * @returns {boolean}\n */\n public eq(value: DecimalSource): boolean {\n return this.compareTo(value) === 0;\n }\n\n /**\n * 自身が小さいか判定する\n * null/undefined/空文字/NaNは0とみなす\n *\n * @param {DecimalSource} value\n * @returns {boolean}\n */\n public lt(value: DecimalSource): boolean {\n return this.compareTo(value) < 0;\n }\n\n /**\n * 自身が小さいか等しいか判定する\n * null/undefined/空文字/NaNは0とみなす\n *\n * @param {DecimalSource} value\n * @returns {boolean}\n */\n public lte(value: DecimalSource): boolean {\n return this.compareTo(value) <= 0;\n }\n\n /**\n * 自身が大きいか判定する\n * null/undefined/空文字/NaNは0とみなす\n *\n * @param {DecimalSource} value\n * @returns {boolean}\n */\n public gt(value: DecimalSource): boolean {\n return 0 < this.compareTo(value);\n }\n\n /**\n * 自身が大きいか等しいか判定する\n * null/undefined/空文字/NaNは0とみなす\n *\n * @param {DecimalSource} value\n * @returns {boolean}\n */\n public gte(value: DecimalSource): boolean {\n return 0 <= this.compareTo(value);\n }\n\n /**\n * numberに変換する\n * Number.MAX_SAFE_INTEGERを超える値や、numberで表現できない桁数の小数は精度が落ちる\n *\n * @returns {number}\n */\n public toNumber(): number {\n return this.big.toNumber();\n }\n\n /**\n * 指定した小数桁で丸め、小数桁を0で埋めた文字列に変換する\n * 指数表記にはならず、通常の表記で返す\n * 丸めた結果が0になる場合は符号を付けない\n *\n * @param {number} scale 小数桁数\n * @param {RoundingMode} [roundingMode] 丸めモード デフォルトはROUNDING_MODE.roundHalfUp(四捨五入・half-away-from-zero)\n * @returns {string}\n */\n public toFixed(scale: number, roundingMode: RoundingMode = ROUNDING_MODE.roundHalfUp): string {\n return this.big.round(scale, roundingMode).toFixed(scale);\n }\n\n /**\n * 文字列に変換する\n * 指数表記にはならず、通常の表記で返す\n *\n * @returns {string}\n */\n public toString(): string {\n return this.big.toFixed();\n }\n}\n"],"names":["ROUNDING_MODE","DIVISION_SCALE","NUMERIC_STRING_PATTERN","BigNumber","Big","isEmpty","value","Decimal","trimmed","big","decimal","divisor","scale","roundingMode"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ "use strict";const p=/^data:([^;,]+)?(?:;[^,]*)?;base64,(.*)$/s,T="application/octet-stream";const d=/^\ufeff?\s*(?:<\?xml[^>]*>\s*)?(?:<!--[\s\S]*?-->\s*)*(?:<!DOCTYPE[^>]*>\s*)?<svg[\s>]/i,E=[{entry:"word/",type:{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}},{entry:"xl/",type:{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}},{entry:"ppt/",type:{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}}],c=e=>e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),x=e=>c(e).slice().buffer,i=(e,t,r=0)=>{const n=typeof t=="string"?Array.from(t,o=>o.charCodeAt(0)):t;return e.length<r+n.length?!1:n.every((o,R)=>e[r+R]===o)},w=e=>{if(i(e,[137,80,78,71,13,10,26,10]))return{ext:"png",mime:"image/png"};if(i(e,[255,216,255]))return{ext:"jpg",mime:"image/jpeg"};if(i(e,"GIF87a")||i(e,"GIF89a"))return{ext:"gif",mime:"image/gif"};if(i(e,"RIFF")&&i(e,"WEBP",8))return{ext:"webp",mime:"image/webp"};if(i(e,"BM"))return{ext:"bmp",mime:"image/bmp"};if(i(e,[73,73,42,0])||i(e,[77,77,0,42]))return{ext:"tif",mime:"image/tiff"};if(i(e,"%PDF-"))return{ext:"pdf",mime:"application/pdf"};if(i(e,[80,75,3,4])||i(e,[80,75,5,6])||i(e,[80,75,7,8])){const t=new TextDecoder("latin1").decode(e),r=E.find(n=>t.includes(n.entry));return r?r.type:{ext:"zip",mime:"application/zip"}}return d.test(new TextDecoder().decode(e))?{ext:"svg",mime:"image/svg+xml"}:null};function u(e,t){return`data:${t||T};base64,${e}`}function A(e){const t=p.exec(e),r=t?t[2]:e;return[r,f(r)?.mime??t?.[1]??T]}async function B(e){if(typeof e=="string")return p.test(e)?e:y(e);if(e instanceof Blob){const t=await e.arrayBuffer();return a(t,e.type||f(t)?.mime)}return a(e,f(e)?.mime)}async function U(e){return typeof e=="string"?m(e):e instanceof Blob?e.arrayBuffer():x(e)}function y(e,t){return e&&u(e,t||f(e)?.mime)}function s(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r.buffer}function l(e){return p.exec(e)?.[2]??e}function m(e){return s(l(e))}function g(e){const t=c(e);let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return btoa(r)}function a(e,t){return u(g(e),t)}function h(e){return m(e).byteLength}function F(e){if(!e)return new Blob([]);let t;if(typeof e=="string"){const r=`\uFEFF${e}`,n=new Uint16Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);t=[n]}else t=[new Uint8Array([255,254]),x(e)];return new Blob(t,{type:"text/csv;charset=utf-16;"})}function f(e){let t;if(typeof e=="string"){const r=l(e).slice(0,16384);try{t=c(s(r.slice(0,r.length-r.length%4)))}catch{return null}}else t=c(e);return w(t)}function L(e){return e.replace(/[\\/:*?"<>|]/g,"")}const D=Object.freeze(Object.defineProperty({__proto__:null,analyzeFileType:f,arrayBufferToBase64:g,arrayBufferToDataURL:a,base64ToArrayBuffer:s,base64ToDataURL:y,calcSize:h,convertUTF16withBOM:F,createDataURL:u,dataURLToArrayBuffer:m,dataURLToBase64:l,parseDataURL:A,readAsArrayBuffer:U,readAsDataURL:B,sanitizeFileName:L},Symbol.toStringTag,{value:"Module"}));exports.analyzeFileType=f;exports.arrayBufferToBase64=g;exports.arrayBufferToDataURL=a;exports.base64ToArrayBuffer=s;exports.base64ToDataURL=y;exports.calcSize=h;exports.convertUTF16withBOM=F;exports.createDataURL=u;exports.dataURLToArrayBuffer=m;exports.dataURLToBase64=l;exports.fileUtil=D;exports.parseDataURL=A;exports.readAsArrayBuffer=U;exports.readAsDataURL=B;exports.sanitizeFileName=L;
2
+ //# sourceMappingURL=file-util-D09BvDYY.cjs.map