@choksheak/ts-utils 0.3.6 → 0.3.7

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 (256) hide show
  1. package/arrayBuffer.cjs +39 -10
  2. package/arrayBuffer.min.cjs +1 -1
  3. package/arrayBuffer.min.cjs.map +1 -1
  4. package/arrayBuffer.min.mjs +1 -1
  5. package/arrayBuffer.min.mjs.map +1 -1
  6. package/arrayBuffer.mjs +10 -7
  7. package/asNumber.cjs +38 -6
  8. package/asNumber.min.cjs +1 -1
  9. package/asNumber.min.cjs.map +1 -1
  10. package/asNumber.min.mjs +1 -1
  11. package/asNumber.min.mjs.map +1 -1
  12. package/asNumber.mjs +11 -4
  13. package/assert.cjs +27 -4
  14. package/assert.min.cjs +1 -1
  15. package/assert.min.cjs.map +1 -1
  16. package/assert.min.mjs +1 -1
  17. package/assert.min.mjs.map +1 -1
  18. package/assert.mjs +0 -2
  19. package/base64Url.cjs +29 -5
  20. package/base64Url.min.cjs +1 -1
  21. package/base64Url.min.cjs.map +1 -1
  22. package/base64Url.min.mjs +1 -1
  23. package/base64Url.min.mjs.map +1 -1
  24. package/base64Url.mjs +0 -2
  25. package/capLength.cjs +71 -7
  26. package/capLength.min.cjs +5 -1
  27. package/capLength.min.cjs.map +1 -1
  28. package/capLength.min.mjs +5 -1
  29. package/capLength.min.mjs.map +1 -1
  30. package/capLength.mjs +41 -4
  31. package/concatIterators.cjs +27 -4
  32. package/concatIterators.min.cjs +1 -1
  33. package/concatIterators.min.cjs.map +1 -1
  34. package/concatIterators.min.mjs +1 -1
  35. package/concatIterators.min.mjs.map +1 -1
  36. package/concatIterators.mjs +0 -2
  37. package/dateTimeStr.cjs +119 -31
  38. package/dateTimeStr.min.cjs +1 -1
  39. package/dateTimeStr.min.cjs.map +1 -1
  40. package/dateTimeStr.min.mjs +1 -1
  41. package/dateTimeStr.min.mjs.map +1 -1
  42. package/dateTimeStr.mjs +69 -17
  43. package/duration.cjs +188 -24
  44. package/duration.min.cjs +1 -1
  45. package/duration.min.cjs.map +1 -1
  46. package/duration.min.mjs +1 -1
  47. package/duration.min.mjs.map +1 -1
  48. package/duration.mjs +144 -14
  49. package/getEnv.cjs +31 -7
  50. package/getEnv.min.cjs +1 -1
  51. package/getEnv.min.cjs.map +1 -1
  52. package/getEnv.min.mjs +1 -1
  53. package/getEnv.min.mjs.map +1 -1
  54. package/getEnv.mjs +0 -2
  55. package/isEmpty.cjs +46 -8
  56. package/isEmpty.min.cjs +1 -1
  57. package/isEmpty.min.cjs.map +1 -1
  58. package/isEmpty.min.mjs +1 -1
  59. package/isEmpty.min.mjs.map +1 -1
  60. package/isEmpty.mjs +19 -6
  61. package/isPromise.cjs +29 -5
  62. package/isPromise.min.cjs +1 -1
  63. package/isPromise.min.cjs.map +1 -1
  64. package/isPromise.min.mjs +1 -1
  65. package/isPromise.min.mjs.map +1 -1
  66. package/isPromise.mjs +0 -2
  67. package/kvStore.cjs +353 -15
  68. package/kvStore.min.cjs +1 -1
  69. package/kvStore.min.cjs.map +1 -1
  70. package/kvStore.min.mjs +1 -1
  71. package/kvStore.min.mjs.map +1 -1
  72. package/kvStore.mjs +319 -12
  73. package/localStore.cjs +264 -15
  74. package/localStore.min.cjs +1 -1
  75. package/localStore.min.cjs.map +1 -1
  76. package/localStore.min.mjs +1 -1
  77. package/localStore.min.mjs.map +1 -1
  78. package/localStore.mjs +230 -12
  79. package/mean.cjs +48 -8
  80. package/mean.min.cjs +1 -1
  81. package/mean.min.cjs.map +1 -1
  82. package/mean.min.mjs +1 -1
  83. package/mean.min.mjs.map +1 -1
  84. package/mean.mjs +18 -5
  85. package/median.cjs +41 -7
  86. package/median.min.cjs +1 -1
  87. package/median.min.cjs.map +1 -1
  88. package/median.min.mjs +1 -1
  89. package/median.min.mjs.map +1 -1
  90. package/median.mjs +11 -4
  91. package/nonEmpty.cjs +48 -8
  92. package/nonEmpty.min.cjs +1 -1
  93. package/nonEmpty.min.cjs.map +1 -1
  94. package/nonEmpty.min.mjs +1 -1
  95. package/nonEmpty.min.mjs.map +1 -1
  96. package/nonEmpty.mjs +19 -6
  97. package/nonNil.cjs +27 -4
  98. package/nonNil.min.cjs +1 -1
  99. package/nonNil.min.cjs.map +1 -1
  100. package/nonNil.min.mjs +1 -1
  101. package/nonNil.min.mjs.map +1 -1
  102. package/nonNil.mjs +0 -2
  103. package/package.json +1 -257
  104. package/round.cjs +32 -6
  105. package/round.min.cjs +1 -1
  106. package/round.min.cjs.map +1 -1
  107. package/round.min.mjs +1 -1
  108. package/round.min.mjs.map +1 -1
  109. package/round.mjs +5 -4
  110. package/roundToString.cjs +35 -7
  111. package/roundToString.min.cjs +1 -1
  112. package/roundToString.min.cjs.map +1 -1
  113. package/roundToString.min.mjs +1 -1
  114. package/roundToString.min.mjs.map +1 -1
  115. package/roundToString.mjs +5 -4
  116. package/safeBtoa.cjs +27 -4
  117. package/safeBtoa.min.cjs +1 -1
  118. package/safeBtoa.min.cjs.map +1 -1
  119. package/safeBtoa.min.mjs +1 -1
  120. package/safeBtoa.min.mjs.map +1 -1
  121. package/safeBtoa.mjs +0 -2
  122. package/sha256.cjs +34 -8
  123. package/sha256.min.cjs +1 -1
  124. package/sha256.min.cjs.map +1 -1
  125. package/sha256.min.mjs +1 -1
  126. package/sha256.min.mjs.map +1 -1
  127. package/sha256.mjs +7 -6
  128. package/sleep.cjs +27 -4
  129. package/sleep.min.cjs +1 -1
  130. package/sleep.min.cjs.map +1 -1
  131. package/sleep.min.mjs +1 -1
  132. package/sleep.min.mjs.map +1 -1
  133. package/sleep.mjs +0 -2
  134. package/storageAdapter.cjs +18 -1
  135. package/storageAdapter.min.cjs +2 -1
  136. package/storageAdapter.min.cjs.map +1 -1
  137. package/sum.cjs +45 -5
  138. package/sum.min.cjs +1 -1
  139. package/sum.min.cjs.map +1 -1
  140. package/sum.min.mjs +1 -1
  141. package/sum.min.mjs.map +1 -1
  142. package/sum.mjs +18 -5
  143. package/timeConstants.cjs +69 -35
  144. package/timeConstants.min.cjs +1 -1
  145. package/timeConstants.min.cjs.map +1 -1
  146. package/timeConstants.min.mjs +1 -1
  147. package/timeConstants.min.mjs.map +1 -1
  148. package/timeConstants.mjs +15 -19
  149. package/timer.cjs +180 -7
  150. package/timer.min.cjs +1 -1
  151. package/timer.min.cjs.map +1 -1
  152. package/timer.min.mjs +1 -1
  153. package/timer.min.mjs.map +1 -1
  154. package/timer.mjs +154 -8
  155. package/toReadableString.cjs +68 -6
  156. package/toReadableString.min.cjs +5 -1
  157. package/toReadableString.min.cjs.map +1 -1
  158. package/toReadableString.min.mjs +5 -1
  159. package/toReadableString.min.mjs.map +1 -1
  160. package/toReadableString.mjs +41 -4
  161. package/chunk-22JDWCOS.min.cjs +0 -2
  162. package/chunk-22JDWCOS.min.cjs.map +0 -1
  163. package/chunk-244NBT4Q.min.mjs +0 -2
  164. package/chunk-244NBT4Q.min.mjs.map +0 -1
  165. package/chunk-27MBP3ES.min.cjs +0 -2
  166. package/chunk-27MBP3ES.min.cjs.map +0 -1
  167. package/chunk-34ENP2B3.min.mjs +0 -438
  168. package/chunk-34ENP2B3.min.mjs.map +0 -1
  169. package/chunk-3EBQ2GO2.min.cjs +0 -2
  170. package/chunk-3EBQ2GO2.min.cjs.map +0 -1
  171. package/chunk-4GLOLTJ5.cjs +0 -167
  172. package/chunk-6TQBMXTL.min.cjs +0 -2
  173. package/chunk-6TQBMXTL.min.cjs.map +0 -1
  174. package/chunk-AWZBCFMG.min.cjs +0 -2
  175. package/chunk-AWZBCFMG.min.cjs.map +0 -1
  176. package/chunk-AXNETZET.cjs +0 -20
  177. package/chunk-BKZM6NWX.min.cjs +0 -2
  178. package/chunk-BKZM6NWX.min.cjs.map +0 -1
  179. package/chunk-BZKQXX3A.cjs +0 -40
  180. package/chunk-CERFUU5I.cjs +0 -93
  181. package/chunk-CSTKFJ6G.mjs +0 -239
  182. package/chunk-DUN4UY2Q.cjs +0 -239
  183. package/chunk-EDJJUP4K.min.cjs +0 -6
  184. package/chunk-EDJJUP4K.min.cjs.map +0 -1
  185. package/chunk-FFNQBZH5.cjs +0 -14
  186. package/chunk-FZZRSHSH.min.mjs +0 -6
  187. package/chunk-FZZRSHSH.min.mjs.map +0 -1
  188. package/chunk-GAP2HS5M.min.cjs +0 -2
  189. package/chunk-GAP2HS5M.min.cjs.map +0 -1
  190. package/chunk-GLYMAPS4.min.mjs +0 -2
  191. package/chunk-GLYMAPS4.min.mjs.map +0 -1
  192. package/chunk-I65KPVMO.min.cjs +0 -438
  193. package/chunk-I65KPVMO.min.cjs.map +0 -1
  194. package/chunk-ILGTU46T.cjs +0 -39
  195. package/chunk-IOKRXHKE.min.mjs +0 -2
  196. package/chunk-IOKRXHKE.min.mjs.map +0 -1
  197. package/chunk-ISP4SMRC.min.cjs +0 -2
  198. package/chunk-ISP4SMRC.min.cjs.map +0 -1
  199. package/chunk-KETP5HBF.cjs +0 -24
  200. package/chunk-KLHNGJ4Y.min.mjs +0 -2
  201. package/chunk-KLHNGJ4Y.min.mjs.map +0 -1
  202. package/chunk-KMNTU3DJ.mjs +0 -45
  203. package/chunk-LDVEXETI.cjs +0 -45
  204. package/chunk-LZENHV35.min.cjs +0 -2
  205. package/chunk-LZENHV35.min.cjs.map +0 -1
  206. package/chunk-M5PIM2HB.mjs +0 -42
  207. package/chunk-M6PYQYOX.mjs +0 -39
  208. package/chunk-MN5EYNZN.min.mjs +0 -2
  209. package/chunk-MN5EYNZN.min.mjs.map +0 -1
  210. package/chunk-NRIBJ2OJ.mjs +0 -16031
  211. package/chunk-NVLYXWLX.cjs +0 -32
  212. package/chunk-O352F2MT.mjs +0 -24
  213. package/chunk-O6B2TKFK.min.mjs +0 -2
  214. package/chunk-O6B2TKFK.min.mjs.map +0 -1
  215. package/chunk-OGF34H4T.min.cjs +0 -2
  216. package/chunk-OGF34H4T.min.cjs.map +0 -1
  217. package/chunk-OXSWWWOM.min.mjs +0 -2
  218. package/chunk-OXSWWWOM.min.mjs.map +0 -1
  219. package/chunk-PRUGHVRT.mjs +0 -14
  220. package/chunk-Q4WCMSOW.min.mjs +0 -2
  221. package/chunk-Q4WCMSOW.min.mjs.map +0 -1
  222. package/chunk-QH74JZCK.mjs +0 -9
  223. package/chunk-QNNJNLGK.min.cjs +0 -2
  224. package/chunk-QNNJNLGK.min.cjs.map +0 -1
  225. package/chunk-QWCFN7ZM.mjs +0 -15
  226. package/chunk-SDM2OPT6.mjs +0 -32
  227. package/chunk-SHKRZCF2.cjs +0 -16031
  228. package/chunk-SJDJDNDN.min.cjs +0 -2
  229. package/chunk-SJDJDNDN.min.cjs.map +0 -1
  230. package/chunk-SULNMALN.cjs +0 -328
  231. package/chunk-SV35RBZ7.min.mjs +0 -2
  232. package/chunk-SV35RBZ7.min.mjs.map +0 -1
  233. package/chunk-TJFYGFOW.mjs +0 -328
  234. package/chunk-UHRYBUUX.min.mjs +0 -2
  235. package/chunk-UHRYBUUX.min.mjs.map +0 -1
  236. package/chunk-UOU6IP3S.min.mjs +0 -2
  237. package/chunk-UOU6IP3S.min.mjs.map +0 -1
  238. package/chunk-V76XVNZ5.mjs +0 -20
  239. package/chunk-VFYQ7I5V.min.mjs +0 -2
  240. package/chunk-VFYQ7I5V.min.mjs.map +0 -1
  241. package/chunk-VG7VV7J2.mjs +0 -167
  242. package/chunk-VJCV56DO.cjs +0 -15
  243. package/chunk-VREA6AKG.cjs +0 -9
  244. package/chunk-W5I6Y5FK.min.mjs +0 -2
  245. package/chunk-W5I6Y5FK.min.mjs.map +0 -1
  246. package/chunk-Y7MC73BZ.cjs +0 -42
  247. package/chunk-YVWROQKU.mjs +0 -40
  248. package/chunk-ZKIZ5SWK.min.cjs +0 -2
  249. package/chunk-ZKIZ5SWK.min.cjs.map +0 -1
  250. package/chunk-ZZZB7NJX.mjs +0 -93
  251. package/magic-string.es-4UY437WL.min.mjs +0 -14
  252. package/magic-string.es-4UY437WL.min.mjs.map +0 -1
  253. package/magic-string.es-OAQWZQTY.mjs +0 -1323
  254. package/magic-string.es-UE2UVQEL.cjs +0 -1323
  255. package/magic-string.es-X6DNUB6Y.min.cjs +0 -14
  256. package/magic-string.es-X6DNUB6Y.min.cjs.map +0 -1
package/nonEmpty.min.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as r,b as o}from"./chunk-244NBT4Q.min.mjs";import"./chunk-UOU6IP3S.min.mjs";o();function f(n,e="value"){if(r(n))throw new Error(`Empty ${e}: ${n}`);return n}export{f as nonEmpty};
1
+ function r(n){if(!n)return!0;if(typeof n!="object")return!1;if("length"in n)return n.length===0;if("size"in n)return n.size===0;for(let e in n)return!1;return!0}function i(n,e="value"){if(r(n))throw new Error(`Empty ${e}: ${n}`);return n}export{i as nonEmpty};
2
2
  //# sourceMappingURL=nonEmpty.min.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/nonEmpty.ts"],"sourcesContent":["import { isEmpty } from \"./isEmpty\";\n\n/**\n * Type asserts that `t` is truthy.\n * Throws an error if `t` is null or undefined.\n *\n * @param varName The variable name to include in the error to throw when t is\n * empty. Defaults to 'value'.\n */\nexport function nonEmpty<T>(\n t: T | null | undefined | \"\" | 0 | -0 | 0n | false | typeof NaN,\n varName = \"value\",\n): T {\n if (isEmpty(t)) {\n throw new Error(`Empty ${varName}: ${t}`);\n }\n return t as T;\n}\n"],"mappings":"qFAAAA,IASO,SAASC,EACdC,EACAC,EAAU,QACP,CACH,GAAIC,EAAQF,CAAC,EACX,MAAM,IAAI,MAAM,SAASC,CAAO,KAAKD,CAAC,EAAE,EAE1C,OAAOA,CACT","names":["init_isEmpty","nonEmpty","t","varName","isEmpty"]}
1
+ {"version":3,"sources":["../src/isEmpty.ts","../src/nonEmpty.ts"],"sourcesContent":["/**\n * Returns true if `t` is empty.\n */\nexport function isEmpty(t: unknown): boolean {\n // Anything falsy is considered empty.\n if (!t) {\n return true;\n }\n\n // Arrays are also of type `object`.\n if (typeof t !== \"object\") {\n return false;\n }\n\n // `length` includes arrays as well.\n if (\"length\" in t) {\n return t.length === 0;\n }\n\n // `size` is for Set, Map, Blob etc.\n if (\"size\" in t) {\n return t.size === 0;\n }\n\n // Super fast check for object emptiness.\n // https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object\n for (const k in t) {\n return false;\n }\n\n return true;\n}\n","import { isEmpty } from \"./isEmpty\";\n\n/**\n * Type asserts that `t` is truthy.\n * Throws an error if `t` is null or undefined.\n *\n * @param varName The variable name to include in the error to throw when t is\n * empty. Defaults to 'value'.\n */\nexport function nonEmpty<T>(\n t: T | null | undefined | \"\" | 0 | -0 | 0n | false | typeof NaN,\n varName = \"value\",\n): T {\n if (isEmpty(t)) {\n throw new Error(`Empty ${varName}: ${t}`);\n }\n return t as T;\n}\n"],"mappings":"AAGO,SAASA,EAAQC,EAAqB,CAE3C,GAAI,CAACA,EACH,MAAO,GAIT,GAAI,OAAOA,GAAM,SACf,MAAO,GAIT,GAAI,WAAYA,EACd,OAAOA,EAAE,SAAW,EAItB,GAAI,SAAUA,EACZ,OAAOA,EAAE,OAAS,EAKpB,QAAWC,KAAKD,EACd,MAAO,GAGT,MAAO,EACT,CCtBO,SAASE,EACdC,EACAC,EAAU,QACP,CACH,GAAIC,EAAQF,CAAC,EACX,MAAM,IAAI,MAAM,SAASC,CAAO,KAAKD,CAAC,EAAE,EAE1C,OAAOA,CACT","names":["isEmpty","t","k","nonEmpty","t","varName","isEmpty"]}
package/nonEmpty.mjs CHANGED
@@ -1,11 +1,24 @@
1
- import {
2
- init_isEmpty,
3
- isEmpty
4
- } from "./chunk-SDM2OPT6.mjs";
5
- import "./chunk-M6PYQYOX.mjs";
1
+ // src/isEmpty.ts
2
+ function isEmpty(t) {
3
+ if (!t) {
4
+ return true;
5
+ }
6
+ if (typeof t !== "object") {
7
+ return false;
8
+ }
9
+ if ("length" in t) {
10
+ return t.length === 0;
11
+ }
12
+ if ("size" in t) {
13
+ return t.size === 0;
14
+ }
15
+ for (const k in t) {
16
+ return false;
17
+ }
18
+ return true;
19
+ }
6
20
 
7
21
  // src/nonEmpty.ts
8
- init_isEmpty();
9
22
  function nonEmpty(t, varName = "value") {
10
23
  if (isEmpty(t)) {
11
24
  throw new Error(`Empty ${varName}: ${t}`);
package/nonNil.cjs CHANGED
@@ -1,12 +1,35 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-ILGTU46T.cjs');
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
20
  // src/nonNil.ts
21
+ var nonNil_exports = {};
22
+ __export(nonNil_exports, {
23
+ nonNil: () => nonNil
24
+ });
25
+ module.exports = __toCommonJS(nonNil_exports);
4
26
  function nonNil(t, varName = "value") {
5
27
  if (t === null || t === void 0) {
6
28
  throw new Error(`Missing ${varName}: ${t}`);
7
29
  }
8
30
  return t;
9
31
  }
10
-
11
-
12
- exports.nonNil = nonNil;
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ nonNil
35
+ });
package/nonNil.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-QNNJNLGK.min.cjs');function i(n,e="value"){if(n==null)throw new Error(`Missing ${e}: ${n}`);return n}exports.nonNil = i;
1
+ "use strict";var u=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var T=(n,e)=>{for(var r in e)u(n,r,{get:e[r],enumerable:!0})},s=(n,e,r,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of d(e))!f.call(n,i)&&i!==r&&u(n,i,{get:()=>e[i],enumerable:!(l=o(e,i))||l.enumerable});return n};var w=n=>s(u({},"__esModule",{value:!0}),n);var a={};T(a,{nonNil:()=>$});module.exports=w(a);function $(n,e="value"){if(n==null)throw new Error(`Missing ${e}: ${n}`);return n}0&&(module.exports={nonNil});
2
2
  //# sourceMappingURL=nonNil.min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/nonNil.min.cjs","../src/nonNil.ts"],"names":["nonNil","t","varName"],"mappings":"AAAA,6GAAgC,SCOhBA,CAAAA,CAAUC,CAAAA,CAAyBC,CAAAA,CAAU,OAAA,CAAY,CACvE,EAAA,CAAID,CAAAA,EAAM,IAAA,CACR,MAAM,IAAI,KAAA,CAAM,CAAA,QAAA,EAAWC,CAAO,CAAA,EAAA,EAAKD,CAAC,CAAA,CAAA","file":"/Users/choksheaklau/src/ts-utils/dist/nonNil.min.cjs","sourcesContent":[null,"/**\n * Type asserts that `t` is neither null nor undefined.\n * Throws an error if `t` is null or undefined.\n *\n * @param varName The variable name to include in the error to throw when t is\n * nil. Defaults to 'value'.\n */\nexport function nonNil<T>(t: T | null | undefined, varName = \"value\"): T {\n if (t === null || t === undefined) {\n throw new Error(`Missing ${varName}: ${t}`);\n }\n return t;\n}\n"]}
1
+ {"version":3,"sources":["../src/nonNil.ts"],"sourcesContent":["/**\n * Type asserts that `t` is neither null nor undefined.\n * Throws an error if `t` is null or undefined.\n *\n * @param varName The variable name to include in the error to throw when t is\n * nil. Defaults to 'value'.\n */\nexport function nonNil<T>(t: T | null | undefined, varName = \"value\"): T {\n if (t === null || t === undefined) {\n throw new Error(`Missing ${varName}: ${t}`);\n }\n return t;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,IAAA,eAAAC,EAAAH,GAOO,SAASE,EAAUE,EAAyBC,EAAU,QAAY,CACvE,GAAID,GAAM,KACR,MAAM,IAAI,MAAM,WAAWC,CAAO,KAAKD,CAAC,EAAE,EAE5C,OAAOA,CACT","names":["nonNil_exports","__export","nonNil","__toCommonJS","t","varName"]}
package/nonNil.min.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import"./chunk-UOU6IP3S.min.mjs";function i(n,e="value"){if(n==null)throw new Error(`Missing ${e}: ${n}`);return n}export{i as nonNil};
1
+ function i(n,e="value"){if(n==null)throw new Error(`Missing ${e}: ${n}`);return n}export{i as nonNil};
2
2
  //# sourceMappingURL=nonNil.min.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/nonNil.ts"],"sourcesContent":["/**\n * Type asserts that `t` is neither null nor undefined.\n * Throws an error if `t` is null or undefined.\n *\n * @param varName The variable name to include in the error to throw when t is\n * nil. Defaults to 'value'.\n */\nexport function nonNil<T>(t: T | null | undefined, varName = \"value\"): T {\n if (t === null || t === undefined) {\n throw new Error(`Missing ${varName}: ${t}`);\n }\n return t;\n}\n"],"mappings":"iCAOO,SAASA,EAAUC,EAAyBC,EAAU,QAAY,CACvE,GAAID,GAAM,KACR,MAAM,IAAI,MAAM,WAAWC,CAAO,KAAKD,CAAC,EAAE,EAE5C,OAAOA,CACT","names":["nonNil","t","varName"]}
1
+ {"version":3,"sources":["../src/nonNil.ts"],"sourcesContent":["/**\n * Type asserts that `t` is neither null nor undefined.\n * Throws an error if `t` is null or undefined.\n *\n * @param varName The variable name to include in the error to throw when t is\n * nil. Defaults to 'value'.\n */\nexport function nonNil<T>(t: T | null | undefined, varName = \"value\"): T {\n if (t === null || t === undefined) {\n throw new Error(`Missing ${varName}: ${t}`);\n }\n return t;\n}\n"],"mappings":"AAOO,SAASA,EAAUC,EAAyBC,EAAU,QAAY,CACvE,GAAID,GAAM,KACR,MAAM,IAAI,MAAM,WAAWC,CAAO,KAAKD,CAAC,EAAE,EAE5C,OAAOA,CACT","names":["nonNil","t","varName"]}
package/nonNil.mjs CHANGED
@@ -1,5 +1,3 @@
1
- import "./chunk-M6PYQYOX.mjs";
2
-
3
1
  // src/nonNil.ts
4
2
  function nonNil(t, varName = "value") {
5
3
  if (t === null || t === void 0) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@choksheak/ts-utils",
3
3
  "license": "The Unlicense",
4
- "version": "0.3.6",
4
+ "version": "0.3.7",
5
5
  "description": "Random Typescript utilities with support for full tree-shaking",
6
6
  "private": false,
7
7
  "sideEffects": false,
@@ -151,201 +151,6 @@
151
151
  "default": "./capLength.cjs"
152
152
  }
153
153
  },
154
- "./chunk-4GLOLTJ5": {
155
- "types": "./chunk-4GLOLTJ5.d.ts",
156
- "import": {
157
- "production": "./chunk-4GLOLTJ5.min.mjs",
158
- "development": "./chunk-4GLOLTJ5.mjs",
159
- "default": "./chunk-4GLOLTJ5.mjs"
160
- },
161
- "require": {
162
- "production": "./chunk-4GLOLTJ5.min.cjs",
163
- "development": "./chunk-4GLOLTJ5.cjs",
164
- "default": "./chunk-4GLOLTJ5.cjs"
165
- }
166
- },
167
- "./chunk-AXNETZET": {
168
- "types": "./chunk-AXNETZET.d.ts",
169
- "import": {
170
- "production": "./chunk-AXNETZET.min.mjs",
171
- "development": "./chunk-AXNETZET.mjs",
172
- "default": "./chunk-AXNETZET.mjs"
173
- },
174
- "require": {
175
- "production": "./chunk-AXNETZET.min.cjs",
176
- "development": "./chunk-AXNETZET.cjs",
177
- "default": "./chunk-AXNETZET.cjs"
178
- }
179
- },
180
- "./chunk-BZKQXX3A": {
181
- "types": "./chunk-BZKQXX3A.d.ts",
182
- "import": {
183
- "production": "./chunk-BZKQXX3A.min.mjs",
184
- "development": "./chunk-BZKQXX3A.mjs",
185
- "default": "./chunk-BZKQXX3A.mjs"
186
- },
187
- "require": {
188
- "production": "./chunk-BZKQXX3A.min.cjs",
189
- "development": "./chunk-BZKQXX3A.cjs",
190
- "default": "./chunk-BZKQXX3A.cjs"
191
- }
192
- },
193
- "./chunk-CERFUU5I": {
194
- "types": "./chunk-CERFUU5I.d.ts",
195
- "import": {
196
- "production": "./chunk-CERFUU5I.min.mjs",
197
- "development": "./chunk-CERFUU5I.mjs",
198
- "default": "./chunk-CERFUU5I.mjs"
199
- },
200
- "require": {
201
- "production": "./chunk-CERFUU5I.min.cjs",
202
- "development": "./chunk-CERFUU5I.cjs",
203
- "default": "./chunk-CERFUU5I.cjs"
204
- }
205
- },
206
- "./chunk-DUN4UY2Q": {
207
- "types": "./chunk-DUN4UY2Q.d.ts",
208
- "import": {
209
- "production": "./chunk-DUN4UY2Q.min.mjs",
210
- "development": "./chunk-DUN4UY2Q.mjs",
211
- "default": "./chunk-DUN4UY2Q.mjs"
212
- },
213
- "require": {
214
- "production": "./chunk-DUN4UY2Q.min.cjs",
215
- "development": "./chunk-DUN4UY2Q.cjs",
216
- "default": "./chunk-DUN4UY2Q.cjs"
217
- }
218
- },
219
- "./chunk-FFNQBZH5": {
220
- "types": "./chunk-FFNQBZH5.d.ts",
221
- "import": {
222
- "production": "./chunk-FFNQBZH5.min.mjs",
223
- "development": "./chunk-FFNQBZH5.mjs",
224
- "default": "./chunk-FFNQBZH5.mjs"
225
- },
226
- "require": {
227
- "production": "./chunk-FFNQBZH5.min.cjs",
228
- "development": "./chunk-FFNQBZH5.cjs",
229
- "default": "./chunk-FFNQBZH5.cjs"
230
- }
231
- },
232
- "./chunk-ILGTU46T": {
233
- "types": "./chunk-ILGTU46T.d.ts",
234
- "import": {
235
- "production": "./chunk-ILGTU46T.min.mjs",
236
- "development": "./chunk-ILGTU46T.mjs",
237
- "default": "./chunk-ILGTU46T.mjs"
238
- },
239
- "require": {
240
- "production": "./chunk-ILGTU46T.min.cjs",
241
- "development": "./chunk-ILGTU46T.cjs",
242
- "default": "./chunk-ILGTU46T.cjs"
243
- }
244
- },
245
- "./chunk-KETP5HBF": {
246
- "types": "./chunk-KETP5HBF.d.ts",
247
- "import": {
248
- "production": "./chunk-KETP5HBF.min.mjs",
249
- "development": "./chunk-KETP5HBF.mjs",
250
- "default": "./chunk-KETP5HBF.mjs"
251
- },
252
- "require": {
253
- "production": "./chunk-KETP5HBF.min.cjs",
254
- "development": "./chunk-KETP5HBF.cjs",
255
- "default": "./chunk-KETP5HBF.cjs"
256
- }
257
- },
258
- "./chunk-LDVEXETI": {
259
- "types": "./chunk-LDVEXETI.d.ts",
260
- "import": {
261
- "production": "./chunk-LDVEXETI.min.mjs",
262
- "development": "./chunk-LDVEXETI.mjs",
263
- "default": "./chunk-LDVEXETI.mjs"
264
- },
265
- "require": {
266
- "production": "./chunk-LDVEXETI.min.cjs",
267
- "development": "./chunk-LDVEXETI.cjs",
268
- "default": "./chunk-LDVEXETI.cjs"
269
- }
270
- },
271
- "./chunk-NVLYXWLX": {
272
- "types": "./chunk-NVLYXWLX.d.ts",
273
- "import": {
274
- "production": "./chunk-NVLYXWLX.min.mjs",
275
- "development": "./chunk-NVLYXWLX.mjs",
276
- "default": "./chunk-NVLYXWLX.mjs"
277
- },
278
- "require": {
279
- "production": "./chunk-NVLYXWLX.min.cjs",
280
- "development": "./chunk-NVLYXWLX.cjs",
281
- "default": "./chunk-NVLYXWLX.cjs"
282
- }
283
- },
284
- "./chunk-SHKRZCF2": {
285
- "types": "./chunk-SHKRZCF2.d.ts",
286
- "import": {
287
- "production": "./chunk-SHKRZCF2.min.mjs",
288
- "development": "./chunk-SHKRZCF2.mjs",
289
- "default": "./chunk-SHKRZCF2.mjs"
290
- },
291
- "require": {
292
- "production": "./chunk-SHKRZCF2.min.cjs",
293
- "development": "./chunk-SHKRZCF2.cjs",
294
- "default": "./chunk-SHKRZCF2.cjs"
295
- }
296
- },
297
- "./chunk-SULNMALN": {
298
- "types": "./chunk-SULNMALN.d.ts",
299
- "import": {
300
- "production": "./chunk-SULNMALN.min.mjs",
301
- "development": "./chunk-SULNMALN.mjs",
302
- "default": "./chunk-SULNMALN.mjs"
303
- },
304
- "require": {
305
- "production": "./chunk-SULNMALN.min.cjs",
306
- "development": "./chunk-SULNMALN.cjs",
307
- "default": "./chunk-SULNMALN.cjs"
308
- }
309
- },
310
- "./chunk-VJCV56DO": {
311
- "types": "./chunk-VJCV56DO.d.ts",
312
- "import": {
313
- "production": "./chunk-VJCV56DO.min.mjs",
314
- "development": "./chunk-VJCV56DO.mjs",
315
- "default": "./chunk-VJCV56DO.mjs"
316
- },
317
- "require": {
318
- "production": "./chunk-VJCV56DO.min.cjs",
319
- "development": "./chunk-VJCV56DO.cjs",
320
- "default": "./chunk-VJCV56DO.cjs"
321
- }
322
- },
323
- "./chunk-VREA6AKG": {
324
- "types": "./chunk-VREA6AKG.d.ts",
325
- "import": {
326
- "production": "./chunk-VREA6AKG.min.mjs",
327
- "development": "./chunk-VREA6AKG.mjs",
328
- "default": "./chunk-VREA6AKG.mjs"
329
- },
330
- "require": {
331
- "production": "./chunk-VREA6AKG.min.cjs",
332
- "development": "./chunk-VREA6AKG.cjs",
333
- "default": "./chunk-VREA6AKG.cjs"
334
- }
335
- },
336
- "./chunk-Y7MC73BZ": {
337
- "types": "./chunk-Y7MC73BZ.d.ts",
338
- "import": {
339
- "production": "./chunk-Y7MC73BZ.min.mjs",
340
- "development": "./chunk-Y7MC73BZ.mjs",
341
- "default": "./chunk-Y7MC73BZ.mjs"
342
- },
343
- "require": {
344
- "production": "./chunk-Y7MC73BZ.min.cjs",
345
- "development": "./chunk-Y7MC73BZ.cjs",
346
- "default": "./chunk-Y7MC73BZ.cjs"
347
- }
348
- },
349
154
  "./concatIterators": {
350
155
  "types": "./concatIterators.d.ts",
351
156
  "import": {
@@ -450,19 +255,6 @@
450
255
  "default": "./localStore.cjs"
451
256
  }
452
257
  },
453
- "./magic-string.es-UE2UVQEL": {
454
- "types": "./magic-string.es-UE2UVQEL.d.ts",
455
- "import": {
456
- "production": "./magic-string.es-UE2UVQEL.min.mjs",
457
- "development": "./magic-string.es-UE2UVQEL.mjs",
458
- "default": "./magic-string.es-UE2UVQEL.mjs"
459
- },
460
- "require": {
461
- "production": "./magic-string.es-UE2UVQEL.min.cjs",
462
- "development": "./magic-string.es-UE2UVQEL.cjs",
463
- "default": "./magic-string.es-UE2UVQEL.cjs"
464
- }
465
- },
466
258
  "./mean": {
467
259
  "types": "./mean.d.ts",
468
260
  "import": {
@@ -663,51 +455,6 @@
663
455
  "capLength": [
664
456
  "./capLength.d.ts"
665
457
  ],
666
- "chunk-4GLOLTJ5": [
667
- "./chunk-4GLOLTJ5.d.ts"
668
- ],
669
- "chunk-AXNETZET": [
670
- "./chunk-AXNETZET.d.ts"
671
- ],
672
- "chunk-BZKQXX3A": [
673
- "./chunk-BZKQXX3A.d.ts"
674
- ],
675
- "chunk-CERFUU5I": [
676
- "./chunk-CERFUU5I.d.ts"
677
- ],
678
- "chunk-DUN4UY2Q": [
679
- "./chunk-DUN4UY2Q.d.ts"
680
- ],
681
- "chunk-FFNQBZH5": [
682
- "./chunk-FFNQBZH5.d.ts"
683
- ],
684
- "chunk-ILGTU46T": [
685
- "./chunk-ILGTU46T.d.ts"
686
- ],
687
- "chunk-KETP5HBF": [
688
- "./chunk-KETP5HBF.d.ts"
689
- ],
690
- "chunk-LDVEXETI": [
691
- "./chunk-LDVEXETI.d.ts"
692
- ],
693
- "chunk-NVLYXWLX": [
694
- "./chunk-NVLYXWLX.d.ts"
695
- ],
696
- "chunk-SHKRZCF2": [
697
- "./chunk-SHKRZCF2.d.ts"
698
- ],
699
- "chunk-SULNMALN": [
700
- "./chunk-SULNMALN.d.ts"
701
- ],
702
- "chunk-VJCV56DO": [
703
- "./chunk-VJCV56DO.d.ts"
704
- ],
705
- "chunk-VREA6AKG": [
706
- "./chunk-VREA6AKG.d.ts"
707
- ],
708
- "chunk-Y7MC73BZ": [
709
- "./chunk-Y7MC73BZ.d.ts"
710
- ],
711
458
  "concatIterators": [
712
459
  "./concatIterators.d.ts"
713
460
  ],
@@ -732,9 +479,6 @@
732
479
  "localStore": [
733
480
  "./localStore.d.ts"
734
481
  ],
735
- "magic-string.es-UE2UVQEL": [
736
- "./magic-string.es-UE2UVQEL.d.ts"
737
- ],
738
482
  "mean": [
739
483
  "./mean.d.ts"
740
484
  ],
package/round.cjs CHANGED
@@ -1,7 +1,33 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
- var _chunkVREA6AKGcjs = require('./chunk-VREA6AKG.cjs');
4
- require('./chunk-ILGTU46T.cjs');
5
-
6
-
7
- exports.round = _chunkVREA6AKGcjs.round;
20
+ // src/round.ts
21
+ var round_exports = {};
22
+ __export(round_exports, {
23
+ round: () => round
24
+ });
25
+ module.exports = __toCommonJS(round_exports);
26
+ function round(n, numDecimalPlaces = 0) {
27
+ const multipler = Math.pow(10, numDecimalPlaces);
28
+ return Math.round(n * multipler) / multipler;
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ round
33
+ });
package/round.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBKZM6NWXmincjs = require('./chunk-BKZM6NWX.min.cjs');require('./chunk-QNNJNLGK.min.cjs');exports.round = _chunkBKZM6NWXmincjs.a;
1
+ "use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var b=(r,n)=>{for(var t in n)o(r,t,{get:n[t],enumerable:!0})},c=(r,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of p(n))!a.call(r,u)&&u!==t&&o(r,u,{get:()=>n[u],enumerable:!(e=m(n,u))||e.enumerable});return r};var d=r=>c(o({},"__esModule",{value:!0}),r);var i={};b(i,{round:()=>h});module.exports=d(i);function h(r,n=0){let t=Math.pow(10,n);return Math.round(r*t)/t}0&&(module.exports={round});
2
2
  //# sourceMappingURL=round.min.cjs.map
package/round.min.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/round.min.cjs"],"names":[],"mappings":"AAAA,wIAAuC,oCAAiC,uCAAmB","file":"/Users/choksheaklau/src/ts-utils/dist/round.min.cjs"}
1
+ {"version":3,"sources":["../src/round.ts"],"sourcesContent":["/**\n * Simplifies rounding of floating point numbers. Note that if your number ends\n * with zeros, and you convert the number to string, you will lose the zeroes\n * at the end. To show the exact number of decimal places, you'll need to use\n * roundToString() or toFixed(). E.g. round(1.20, 2).toFixed(2).\n */\nexport function round(n: number, numDecimalPlaces = 0): number {\n const multipler = Math.pow(10, numDecimalPlaces);\n return Math.round(n * multipler) / multipler;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,IAAA,eAAAC,EAAAH,GAMO,SAASE,EAAME,EAAWC,EAAmB,EAAW,CAC7D,IAAMC,EAAY,KAAK,IAAI,GAAID,CAAgB,EAC/C,OAAO,KAAK,MAAMD,EAAIE,CAAS,EAAIA,CACrC","names":["round_exports","__export","round","__toCommonJS","n","numDecimalPlaces","multipler"]}
package/round.min.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-VFYQ7I5V.min.mjs";import"./chunk-UOU6IP3S.min.mjs";export{a as round};
1
+ function u(r,t=0){let n=Math.pow(10,t);return Math.round(r*n)/n}export{u as round};
2
2
  //# sourceMappingURL=round.min.mjs.map
package/round.min.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/round.ts"],"sourcesContent":["/**\n * Simplifies rounding of floating point numbers. Note that if your number ends\n * with zeros, and you convert the number to string, you will lose the zeroes\n * at the end. To show the exact number of decimal places, you'll need to use\n * roundToString() or toFixed(). E.g. round(1.20, 2).toFixed(2).\n */\nexport function round(n: number, numDecimalPlaces = 0): number {\n const multipler = Math.pow(10, numDecimalPlaces);\n return Math.round(n * multipler) / multipler;\n}\n"],"mappings":"AAMO,SAASA,EAAMC,EAAWC,EAAmB,EAAW,CAC7D,IAAMC,EAAY,KAAK,IAAI,GAAID,CAAgB,EAC/C,OAAO,KAAK,MAAMD,EAAIE,CAAS,EAAIA,CACrC","names":["round","n","numDecimalPlaces","multipler"]}
package/round.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import {
2
- round
3
- } from "./chunk-QH74JZCK.mjs";
4
- import "./chunk-M6PYQYOX.mjs";
1
+ // src/round.ts
2
+ function round(n, numDecimalPlaces = 0) {
3
+ const multipler = Math.pow(10, numDecimalPlaces);
4
+ return Math.round(n * multipler) / multipler;
5
+ }
5
6
  export {
6
7
  round
7
8
  };
package/roundToString.cjs CHANGED
@@ -1,15 +1,43 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
- var _chunkVREA6AKGcjs = require('./chunk-VREA6AKG.cjs');
4
- require('./chunk-ILGTU46T.cjs');
20
+ // src/roundToString.ts
21
+ var roundToString_exports = {};
22
+ __export(roundToString_exports, {
23
+ roundToString: () => roundToString
24
+ });
25
+ module.exports = __toCommonJS(roundToString_exports);
26
+
27
+ // src/round.ts
28
+ function round(n, numDecimalPlaces = 0) {
29
+ const multipler = Math.pow(10, numDecimalPlaces);
30
+ return Math.round(n * multipler) / multipler;
31
+ }
5
32
 
6
33
  // src/roundToString.ts
7
34
  function roundToString(n, numDecimalPlaces = 0) {
8
- return _chunkVREA6AKGcjs.round.call(void 0, n, numDecimalPlaces).toLocaleString("en-US", {
35
+ return round(n, numDecimalPlaces).toLocaleString("en-US", {
9
36
  minimumFractionDigits: numDecimalPlaces,
10
37
  maximumFractionDigits: numDecimalPlaces
11
38
  });
12
39
  }
13
-
14
-
15
- exports.roundToString = roundToString;
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ roundToString
43
+ });
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBKZM6NWXmincjs = require('./chunk-BKZM6NWX.min.cjs');require('./chunk-QNNJNLGK.min.cjs');function o(t,r=0){return _chunkBKZM6NWXmincjs.a.call(void 0, t,r).toLocaleString("en-US",{minimumFractionDigits:r,maximumFractionDigits:r})}exports.roundToString = o;
1
+ "use strict";var i=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(n,r)=>{for(var t in r)i(n,t,{get:r[t],enumerable:!0})},b=(n,r,t,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of g(r))!p.call(n,o)&&o!==t&&i(n,o,{get:()=>r[o],enumerable:!(u=e(r,o))||u.enumerable});return n};var f=n=>b(i({},"__esModule",{value:!0}),n);var S={};d(S,{roundToString:()=>x});module.exports=f(S);function m(n,r=0){let t=Math.pow(10,r);return Math.round(n*t)/t}function x(n,r=0){return m(n,r).toLocaleString("en-US",{minimumFractionDigits:r,maximumFractionDigits:r})}0&&(module.exports={roundToString});
2
2
  //# sourceMappingURL=roundToString.min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/roundToString.min.cjs","../src/roundToString.ts"],"names":["roundToString","n","numDecimalPlaces","round"],"mappings":"AAAA,wIAA4C,oCAAiC,SCO7DA,CAAAA,CAAcC,CAAAA,CAAWC,CAAAA,CAAmB,CAAA,CAAW,CACrE,OAAOC,oCAAAA,CAAMF,CAAGC,CAAgB,CAAA,CAAE,cAAA,CAAe,OAAA,CAAS,CACxD,qBAAA,CAAuBA,CAAAA,CACvB,qBAAA,CAAuBA,CACzB,CAAC,CACH,CAAA,0BAAA","file":"/Users/choksheaklau/src/ts-utils/dist/roundToString.min.cjs","sourcesContent":[null,"import { round } from \"./round\";\n\n/**\n * Returns a string with the number in the exact number of decimal places\n * specified, in case the number ends with zeroes, and adding commas for each\n * group of 3 significant digits.\n */\nexport function roundToString(n: number, numDecimalPlaces = 0): string {\n return round(n, numDecimalPlaces).toLocaleString(\"en-US\", {\n minimumFractionDigits: numDecimalPlaces,\n maximumFractionDigits: numDecimalPlaces,\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/roundToString.ts","../src/round.ts"],"sourcesContent":["import { round } from \"./round\";\n\n/**\n * Returns a string with the number in the exact number of decimal places\n * specified, in case the number ends with zeroes, and adding commas for each\n * group of 3 significant digits.\n */\nexport function roundToString(n: number, numDecimalPlaces = 0): string {\n return round(n, numDecimalPlaces).toLocaleString(\"en-US\", {\n minimumFractionDigits: numDecimalPlaces,\n maximumFractionDigits: numDecimalPlaces,\n });\n}\n","/**\n * Simplifies rounding of floating point numbers. Note that if your number ends\n * with zeros, and you convert the number to string, you will lose the zeroes\n * at the end. To show the exact number of decimal places, you'll need to use\n * roundToString() or toFixed(). E.g. round(1.20, 2).toFixed(2).\n */\nexport function round(n: number, numDecimalPlaces = 0): number {\n const multipler = Math.pow(10, numDecimalPlaces);\n return Math.round(n * multipler) / multipler;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GCMO,SAASI,EAAM,EAAWC,EAAmB,EAAW,CAC7D,IAAMC,EAAY,KAAK,IAAI,GAAID,CAAgB,EAC/C,OAAO,KAAK,MAAM,EAAIC,CAAS,EAAIA,CACrC,CDFO,SAASC,EAAc,EAAWC,EAAmB,EAAW,CACrE,OAAOC,EAAM,EAAGD,CAAgB,EAAE,eAAe,QAAS,CACxD,sBAAuBA,EACvB,sBAAuBA,CACzB,CAAC,CACH","names":["roundToString_exports","__export","roundToString","__toCommonJS","round","numDecimalPlaces","multipler","roundToString","numDecimalPlaces","round"]}
@@ -1,2 +1,2 @@
1
- import{a as i}from"./chunk-VFYQ7I5V.min.mjs";import"./chunk-UOU6IP3S.min.mjs";function o(t,r=0){return i(t,r).toLocaleString("en-US",{minimumFractionDigits:r,maximumFractionDigits:r})}export{o as roundToString};
1
+ function o(n,r=0){let t=Math.pow(10,r);return Math.round(n*t)/t}function m(n,r=0){return o(n,r).toLocaleString("en-US",{minimumFractionDigits:r,maximumFractionDigits:r})}export{m as roundToString};
2
2
  //# sourceMappingURL=roundToString.min.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/roundToString.ts"],"sourcesContent":["import { round } from \"./round\";\n\n/**\n * Returns a string with the number in the exact number of decimal places\n * specified, in case the number ends with zeroes, and adding commas for each\n * group of 3 significant digits.\n */\nexport function roundToString(n: number, numDecimalPlaces = 0): string {\n return round(n, numDecimalPlaces).toLocaleString(\"en-US\", {\n minimumFractionDigits: numDecimalPlaces,\n maximumFractionDigits: numDecimalPlaces,\n });\n}\n"],"mappings":"8EAOO,SAASA,EAAcC,EAAWC,EAAmB,EAAW,CACrE,OAAOC,EAAMF,EAAGC,CAAgB,EAAE,eAAe,QAAS,CACxD,sBAAuBA,EACvB,sBAAuBA,CACzB,CAAC,CACH","names":["roundToString","n","numDecimalPlaces","round"]}
1
+ {"version":3,"sources":["../src/round.ts","../src/roundToString.ts"],"sourcesContent":["/**\n * Simplifies rounding of floating point numbers. Note that if your number ends\n * with zeros, and you convert the number to string, you will lose the zeroes\n * at the end. To show the exact number of decimal places, you'll need to use\n * roundToString() or toFixed(). E.g. round(1.20, 2).toFixed(2).\n */\nexport function round(n: number, numDecimalPlaces = 0): number {\n const multipler = Math.pow(10, numDecimalPlaces);\n return Math.round(n * multipler) / multipler;\n}\n","import { round } from \"./round\";\n\n/**\n * Returns a string with the number in the exact number of decimal places\n * specified, in case the number ends with zeroes, and adding commas for each\n * group of 3 significant digits.\n */\nexport function roundToString(n: number, numDecimalPlaces = 0): string {\n return round(n, numDecimalPlaces).toLocaleString(\"en-US\", {\n minimumFractionDigits: numDecimalPlaces,\n maximumFractionDigits: numDecimalPlaces,\n });\n}\n"],"mappings":"AAMO,SAASA,EAAM,EAAWC,EAAmB,EAAW,CAC7D,IAAMC,EAAY,KAAK,IAAI,GAAID,CAAgB,EAC/C,OAAO,KAAK,MAAM,EAAIC,CAAS,EAAIA,CACrC,CCFO,SAASC,EAAc,EAAWC,EAAmB,EAAW,CACrE,OAAOC,EAAM,EAAGD,CAAgB,EAAE,eAAe,QAAS,CACxD,sBAAuBA,EACvB,sBAAuBA,CACzB,CAAC,CACH","names":["round","numDecimalPlaces","multipler","roundToString","numDecimalPlaces","round"]}
package/roundToString.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import {
2
- round
3
- } from "./chunk-QH74JZCK.mjs";
4
- import "./chunk-M6PYQYOX.mjs";
1
+ // src/round.ts
2
+ function round(n, numDecimalPlaces = 0) {
3
+ const multipler = Math.pow(10, numDecimalPlaces);
4
+ return Math.round(n * multipler) / multipler;
5
+ }
5
6
 
6
7
  // src/roundToString.ts
7
8
  function roundToString(n, numDecimalPlaces = 0) {
package/safeBtoa.cjs CHANGED
@@ -1,11 +1,34 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-ILGTU46T.cjs');
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
20
  // src/safeBtoa.ts
21
+ var safeBtoa_exports = {};
22
+ __export(safeBtoa_exports, {
23
+ safeBtoa: () => safeBtoa
24
+ });
25
+ module.exports = __toCommonJS(safeBtoa_exports);
4
26
  function safeBtoa(input) {
5
27
  const utf8Bytes = new TextEncoder().encode(input);
6
28
  const binaryString = Array.from(utf8Bytes).map((byte) => String.fromCodePoint(byte)).join("");
7
29
  return btoa(binaryString);
8
30
  }
9
-
10
-
11
- exports.safeBtoa = safeBtoa;
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ safeBtoa
34
+ });
package/safeBtoa.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-QNNJNLGK.min.cjs');function e(n){let t=new TextEncoder().encode(n),o=Array.from(t).map(r=>String.fromCodePoint(r)).join("");return btoa(o)}exports.safeBtoa = e;
1
+ "use strict";var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(t,n)=>{for(var o in n)i(t,o,{get:n[o],enumerable:!0})},g=(t,n,o,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of s(n))!c.call(t,r)&&r!==o&&i(t,r,{get:()=>n[r],enumerable:!(e=a(n,r))||e.enumerable});return t};var d=t=>g(i({},"__esModule",{value:!0}),t);var u={};f(u,{safeBtoa:()=>m});module.exports=d(u);function m(t){let n=new TextEncoder().encode(t),o=Array.from(n).map(e=>String.fromCodePoint(e)).join("");return btoa(o)}0&&(module.exports={safeBtoa});
2
2
  //# sourceMappingURL=safeBtoa.min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/choksheaklau/src/ts-utils/dist/safeBtoa.min.cjs","../src/safeBtoa.ts"],"names":["safeBtoa","input","utf8Bytes","binaryString","byte"],"mappings":"AAAA,6GAAgC,SCUhBA,CAAAA,CAASC,CAAAA,CAAuB,CAE9C,IAAMC,CAAAA,CAAY,IAAI,WAAA,CAAY,CAAA,CAAE,MAAA,CAAOD,CAAK,CAAA,CAG1CE,CAAAA,CAAe,KAAA,CAAM,IAAA,CAAKD,CAAS,CAAA,CACtC,GAAA,CAAKE,CAAAA,EAAS,MAAA,CAAO,aAAA,CAAcA,CAAI,CAAC,CAAA,CACxC,IAAA,CAAK,EAAE,CAAA,CAGV,OAAO,IAAA,CAAKD,CAAY,CAC1B,CAAA,qBAAA","file":"/Users/choksheaklau/src/ts-utils/dist/safeBtoa.min.cjs","sourcesContent":[null,"/**\n * Base 64 encode the given input string, but safely.\n *\n * Why using btoa() directly might not always work:\n * btoa() expects a \"binary string\" where each character is represented by a\n * single byte (0-255). Modern JavaScript strings, however, are encoded in\n * UTF-16 and can contain characters that require more than one byte (i.e.,\n * characters outside the Latin-1 range, such as those with code points greater\n * than 255).\n */\nexport function safeBtoa(input: string): string {\n // Convert the string to a UTF-8 encoded binary-safe string\n const utf8Bytes = new TextEncoder().encode(input);\n\n // Convert the binary data to a string for btoa\n const binaryString = Array.from(utf8Bytes)\n .map((byte) => String.fromCodePoint(byte))\n .join(\"\");\n\n // Use btoa to encode the binary-safe string\n return btoa(binaryString);\n}\n"]}
1
+ {"version":3,"sources":["../src/safeBtoa.ts"],"sourcesContent":["/**\n * Base 64 encode the given input string, but safely.\n *\n * Why using btoa() directly might not always work:\n * btoa() expects a \"binary string\" where each character is represented by a\n * single byte (0-255). Modern JavaScript strings, however, are encoded in\n * UTF-16 and can contain characters that require more than one byte (i.e.,\n * characters outside the Latin-1 range, such as those with code points greater\n * than 255).\n */\nexport function safeBtoa(input: string): string {\n // Convert the string to a UTF-8 encoded binary-safe string\n const utf8Bytes = new TextEncoder().encode(input);\n\n // Convert the binary data to a string for btoa\n const binaryString = Array.from(utf8Bytes)\n .map((byte) => String.fromCodePoint(byte))\n .join(\"\");\n\n // Use btoa to encode the binary-safe string\n return btoa(binaryString);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAUO,SAASE,EAASE,EAAuB,CAE9C,IAAMC,EAAY,IAAI,YAAY,EAAE,OAAOD,CAAK,EAG1CE,EAAe,MAAM,KAAKD,CAAS,EACtC,IAAKE,GAAS,OAAO,cAAcA,CAAI,CAAC,EACxC,KAAK,EAAE,EAGV,OAAO,KAAKD,CAAY,CAC1B","names":["safeBtoa_exports","__export","safeBtoa","__toCommonJS","input","utf8Bytes","binaryString","byte"]}