@choksheak/ts-utils 0.2.9 → 0.3.0

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 (276) hide show
  1. package/README.md +2 -0
  2. package/{arrayBuffer.js → arrayBuffer.cjs} +0 -1
  3. package/arrayBuffer.d.mts +10 -0
  4. package/arrayBuffer.min.cjs +2 -0
  5. package/arrayBuffer.min.cjs.map +1 -0
  6. package/arrayBuffer.min.mjs +2 -0
  7. package/{arrayBuffer.js.map → arrayBuffer.min.mjs.map} +1 -1
  8. package/arrayBuffer.mjs +14 -0
  9. package/{assert.js → assert.cjs} +0 -1
  10. package/assert.d.mts +7 -0
  11. package/assert.min.cjs +2 -0
  12. package/assert.min.cjs.map +1 -0
  13. package/assert.min.mjs +2 -0
  14. package/{assert.js.map → assert.min.mjs.map} +1 -1
  15. package/assert.mjs +11 -0
  16. package/{average.js → average.cjs} +0 -1
  17. package/average.d.mts +7 -0
  18. package/average.min.cjs +2 -0
  19. package/{average.js.map → average.min.cjs.map} +1 -1
  20. package/average.min.mjs +2 -0
  21. package/average.min.mjs.map +1 -0
  22. package/average.mjs +20 -0
  23. package/{base64Url.js → base64Url.cjs} +0 -1
  24. package/base64Url.d.mts +10 -0
  25. package/base64Url.min.cjs +2 -0
  26. package/base64Url.min.cjs.map +1 -0
  27. package/base64Url.min.mjs +2 -0
  28. package/{base64Url.js.map → base64Url.min.mjs.map} +1 -1
  29. package/base64Url.mjs +14 -0
  30. package/{dateTimeStr.js → dateTimeStr.cjs} +0 -1
  31. package/dateTimeStr.d.mts +85 -0
  32. package/dateTimeStr.min.cjs +2 -0
  33. package/dateTimeStr.min.cjs.map +1 -0
  34. package/dateTimeStr.min.mjs +2 -0
  35. package/{dateTimeStr.js.map → dateTimeStr.min.mjs.map} +1 -1
  36. package/dateTimeStr.mjs +83 -0
  37. package/{duration.js → duration.cjs} +9 -11
  38. package/duration.d.mts +78 -0
  39. package/duration.min.cjs +2 -0
  40. package/duration.min.cjs.map +1 -0
  41. package/duration.min.mjs +2 -0
  42. package/duration.min.mjs.map +1 -0
  43. package/duration.mjs +154 -0
  44. package/{isEmpty.js → isEmpty.cjs} +0 -1
  45. package/isEmpty.d.mts +6 -0
  46. package/isEmpty.min.cjs +2 -0
  47. package/isEmpty.min.cjs.map +1 -0
  48. package/isEmpty.min.mjs +2 -0
  49. package/{isEmpty.js.map → isEmpty.min.mjs.map} +1 -1
  50. package/isEmpty.mjs +22 -0
  51. package/kvStore.cjs +333 -0
  52. package/kvStore.d.mts +97 -0
  53. package/kvStore.min.cjs +2 -0
  54. package/kvStore.min.cjs.map +1 -0
  55. package/kvStore.min.mjs +2 -0
  56. package/kvStore.min.mjs.map +1 -0
  57. package/kvStore.mjs +300 -0
  58. package/{localStorageCache.js → localStorageCache.cjs} +5 -7
  59. package/localStorageCache.d.mts +57 -0
  60. package/localStorageCache.min.cjs +2 -0
  61. package/localStorageCache.min.cjs.map +1 -0
  62. package/localStorageCache.min.mjs +2 -0
  63. package/localStorageCache.min.mjs.map +1 -0
  64. package/localStorageCache.mjs +92 -0
  65. package/{logging.js → logging.cjs} +0 -1
  66. package/logging.d.mts +4 -0
  67. package/logging.min.cjs +2 -0
  68. package/logging.min.cjs.map +1 -0
  69. package/logging.min.mjs +2 -0
  70. package/{logging.js.map → logging.min.mjs.map} +1 -1
  71. package/logging.mjs +21 -0
  72. package/{nonEmpty.js → nonEmpty.cjs} +0 -1
  73. package/nonEmpty.d.mts +10 -0
  74. package/nonEmpty.min.cjs +2 -0
  75. package/{nonEmpty.js.map → nonEmpty.min.cjs.map} +1 -1
  76. package/nonEmpty.min.mjs +2 -0
  77. package/nonEmpty.min.mjs.map +1 -0
  78. package/nonEmpty.mjs +30 -0
  79. package/{nonNil.js → nonNil.cjs} +0 -1
  80. package/{src/nonNil.ts → nonNil.d.mts} +3 -6
  81. package/nonNil.min.cjs +2 -0
  82. package/nonNil.min.cjs.map +1 -0
  83. package/nonNil.min.mjs +2 -0
  84. package/{nonNil.js.map → nonNil.min.mjs.map} +1 -1
  85. package/nonNil.mjs +10 -0
  86. package/package.json +414 -24
  87. package/{round.js → round.cjs} +0 -1
  88. package/{src/round.ts → round.d.mts} +4 -8
  89. package/round.min.cjs +2 -0
  90. package/round.min.cjs.map +1 -0
  91. package/round.min.mjs +2 -0
  92. package/{round.js.map → round.min.mjs.map} +1 -1
  93. package/round.mjs +12 -0
  94. package/{safeBtoa.js → safeBtoa.cjs} +0 -1
  95. package/safeBtoa.d.mts +6 -0
  96. package/safeBtoa.min.cjs +2 -0
  97. package/safeBtoa.min.cjs.map +1 -0
  98. package/safeBtoa.min.mjs +2 -0
  99. package/{safeBtoa.js.map → safeBtoa.min.mjs.map} +1 -1
  100. package/safeBtoa.mjs +9 -0
  101. package/{safeParseFloat.js → safeParseFloat.cjs} +0 -1
  102. package/safeParseFloat.d.mts +6 -0
  103. package/safeParseFloat.min.cjs +2 -0
  104. package/safeParseFloat.min.cjs.map +1 -0
  105. package/safeParseFloat.min.mjs +2 -0
  106. package/{safeParseFloat.js.map → safeParseFloat.min.mjs.map} +1 -1
  107. package/safeParseFloat.mjs +8 -0
  108. package/{safeParseInt.js → safeParseInt.cjs} +0 -1
  109. package/safeParseInt.d.mts +6 -0
  110. package/safeParseInt.min.cjs +2 -0
  111. package/safeParseInt.min.cjs.map +1 -0
  112. package/safeParseInt.min.mjs +2 -0
  113. package/{safeParseInt.js.map → safeParseInt.min.mjs.map} +1 -1
  114. package/safeParseInt.mjs +8 -0
  115. package/sha256.cjs +35 -0
  116. package/sha256.d.mts +6 -0
  117. package/sha256.min.cjs +2 -0
  118. package/sha256.min.cjs.map +1 -0
  119. package/sha256.min.mjs +2 -0
  120. package/{sha256.js.map → sha256.min.mjs.map} +1 -1
  121. package/sha256.mjs +10 -0
  122. package/{sleep.js → sleep.cjs} +0 -1
  123. package/{src/sleep.ts → sleep.d.mts} +3 -3
  124. package/sleep.min.cjs +2 -0
  125. package/sleep.min.cjs.map +1 -0
  126. package/sleep.min.mjs +2 -0
  127. package/{sleep.js.map → sleep.min.mjs.map} +1 -1
  128. package/sleep.mjs +7 -0
  129. package/{sum.js → sum.cjs} +0 -1
  130. package/sum.d.mts +7 -0
  131. package/sum.min.cjs +2 -0
  132. package/sum.min.cjs.map +1 -0
  133. package/sum.min.mjs +2 -0
  134. package/{sum.js.map → sum.min.mjs.map} +1 -1
  135. package/sum.mjs +13 -0
  136. package/{timeConstants.js → timeConstants.cjs} +0 -1
  137. package/timeConstants.d.mts +20 -0
  138. package/timeConstants.min.cjs +2 -0
  139. package/timeConstants.min.cjs.map +1 -0
  140. package/timeConstants.min.mjs +2 -0
  141. package/{timeConstants.js.map → timeConstants.min.mjs.map} +1 -1
  142. package/timeConstants.mjs +31 -0
  143. package/{timer.js → timer.cjs} +6 -6
  144. package/timer.d.mts +13 -0
  145. package/timer.min.cjs +2 -0
  146. package/timer.min.cjs.map +1 -0
  147. package/timer.min.mjs +2 -0
  148. package/timer.min.mjs.map +1 -0
  149. package/timer.mjs +161 -0
  150. package/docs/.nojekyll +0 -1
  151. package/docs/assets/hierarchy.js +0 -1
  152. package/docs/assets/highlight.css +0 -22
  153. package/docs/assets/icons.js +0 -18
  154. package/docs/assets/icons.svg +0 -1
  155. package/docs/assets/main.js +0 -60
  156. package/docs/assets/navigation.js +0 -1
  157. package/docs/assets/search.js +0 -1
  158. package/docs/assets/style.css +0 -1640
  159. package/docs/classes/kvStore.KVStore.html +0 -26
  160. package/docs/classes/kvStore.KVStoreField.html +0 -7
  161. package/docs/classes/timer.Timer.html +0 -8
  162. package/docs/functions/arrayBuffer.arrayBufferToBase64.html +0 -2
  163. package/docs/functions/arrayBuffer.arrayBufferToHex.html +0 -2
  164. package/docs/functions/assert.assert.html +0 -3
  165. package/docs/functions/average.average.html +0 -3
  166. package/docs/functions/base64Url.base64ToBase64URL.html +0 -2
  167. package/docs/functions/base64Url.base64UrlToBase64.html +0 -2
  168. package/docs/functions/dateTimeStr.getDisplayDateTime.html +0 -3
  169. package/docs/functions/dateTimeStr.getLongMonthNameOneIndexed.html +0 -4
  170. package/docs/functions/dateTimeStr.getLongMonthNameZeroIndexed.html +0 -4
  171. package/docs/functions/dateTimeStr.getShortMonthNameOneIndexed.html +0 -4
  172. package/docs/functions/dateTimeStr.getShortMonthNameZeroIndexed.html +0 -4
  173. package/docs/functions/dateTimeStr.hhMm.html +0 -4
  174. package/docs/functions/dateTimeStr.hhMmSs.html +0 -4
  175. package/docs/functions/dateTimeStr.hhMmSsMs.html +0 -5
  176. package/docs/functions/dateTimeStr.toDate.html +0 -4
  177. package/docs/functions/dateTimeStr.tzShort.html +0 -4
  178. package/docs/functions/dateTimeStr.yyyyMm.html +0 -4
  179. package/docs/functions/dateTimeStr.yyyyMmDd.html +0 -4
  180. package/docs/functions/duration.durationOrMsToMs.html +0 -2
  181. package/docs/functions/duration.durationToMs.html +0 -2
  182. package/docs/functions/duration.elapsed.html +0 -2
  183. package/docs/functions/duration.formatDuration.html +0 -4
  184. package/docs/functions/duration.msToDuration.html +0 -5
  185. package/docs/functions/duration.readableDuration.html +0 -4
  186. package/docs/functions/isEmpty.isEmpty.html +0 -2
  187. package/docs/functions/kvStore.kvStoreItem.html +0 -2
  188. package/docs/functions/localStorageCache.storeItem.html +0 -15
  189. package/docs/functions/logging.capLength.html +0 -1
  190. package/docs/functions/logging.stringify.html +0 -1
  191. package/docs/functions/nonEmpty.nonEmpty.html +0 -5
  192. package/docs/functions/nonNil.nonNil.html +0 -5
  193. package/docs/functions/round.round.html +0 -5
  194. package/docs/functions/round.roundS.html +0 -3
  195. package/docs/functions/safeBtoa.safeBtoa.html +0 -2
  196. package/docs/functions/safeParseFloat.safeParseFloat.html +0 -2
  197. package/docs/functions/safeParseInt.safeParseInt.html +0 -2
  198. package/docs/functions/sha256.sha256.html +0 -2
  199. package/docs/functions/sleep.sleep.html +0 -3
  200. package/docs/functions/sum.sum.html +0 -3
  201. package/docs/functions/timer.timer.html +0 -2
  202. package/docs/hierarchy.html +0 -1
  203. package/docs/index.html +0 -4
  204. package/docs/modules/arrayBuffer.html +0 -1
  205. package/docs/modules/assert.html +0 -1
  206. package/docs/modules/average.html +0 -1
  207. package/docs/modules/base64Url.html +0 -1
  208. package/docs/modules/dateTimeStr.html +0 -1
  209. package/docs/modules/duration.html +0 -1
  210. package/docs/modules/isEmpty.html +0 -1
  211. package/docs/modules/kvStore.html +0 -1
  212. package/docs/modules/localStorageCache.html +0 -1
  213. package/docs/modules/logging.html +0 -1
  214. package/docs/modules/nonEmpty.html +0 -1
  215. package/docs/modules/nonNil.html +0 -1
  216. package/docs/modules/round.html +0 -1
  217. package/docs/modules/safeBtoa.html +0 -1
  218. package/docs/modules/safeParseFloat.html +0 -1
  219. package/docs/modules/safeParseInt.html +0 -1
  220. package/docs/modules/sha256.html +0 -1
  221. package/docs/modules/sleep.html +0 -1
  222. package/docs/modules/sum.html +0 -1
  223. package/docs/modules/timeConstants.html +0 -1
  224. package/docs/modules/timer.html +0 -1
  225. package/docs/modules.html +0 -1
  226. package/docs/types/dateTimeStr.AnyDateTime.html +0 -1
  227. package/docs/types/duration.Duration.html +0 -6
  228. package/docs/types/duration.DurationStyle.html +0 -6
  229. package/docs/types/duration.DurationSuffixMap.html +0 -6
  230. package/docs/types/duration.DurationSuffixType.html +0 -1
  231. package/docs/types/duration.DurationType.html +0 -2
  232. package/docs/types/localStorageCache.StoredItem.html +0 -4
  233. package/docs/variables/duration.DURATION_STYLE_SUFFIX_MAP.html +0 -1
  234. package/docs/variables/duration.DURATION_TYPE_SEQUENCE.html +0 -2
  235. package/docs/variables/kvStore.DEFAULT_EXPIRY_DELTA_MS.html +0 -2
  236. package/docs/variables/kvStore.GC_INTERVAL_MS.html +0 -2
  237. package/docs/variables/kvStore.MILLIS_PER_DAY.html +0 -2
  238. package/docs/variables/kvStore.kvStore.html +0 -3
  239. package/docs/variables/timeConstants.HOURS_PER_DAY.html +0 -1
  240. package/docs/variables/timeConstants.HOURS_PER_WEEK.html +0 -1
  241. package/docs/variables/timeConstants.MINUTES_PER_DAY.html +0 -1
  242. package/docs/variables/timeConstants.MINUTES_PER_HOUR.html +0 -1
  243. package/docs/variables/timeConstants.MINUTES_PER_WEEK.html +0 -1
  244. package/docs/variables/timeConstants.MS_PER_DAY.html +0 -1
  245. package/docs/variables/timeConstants.MS_PER_HOUR.html +0 -1
  246. package/docs/variables/timeConstants.MS_PER_MINUTE.html +0 -1
  247. package/docs/variables/timeConstants.MS_PER_SECOND.html +0 -3
  248. package/docs/variables/timeConstants.MS_PER_WEEK.html +0 -1
  249. package/docs/variables/timeConstants.SECONDS_PER_DAY.html +0 -1
  250. package/docs/variables/timeConstants.SECONDS_PER_HOUR.html +0 -1
  251. package/docs/variables/timeConstants.SECONDS_PER_MINUTE.html +0 -1
  252. package/docs/variables/timeConstants.SECONDS_PER_WEEK.html +0 -1
  253. package/duration.js.map +0 -1
  254. package/kvStore.js +0 -383
  255. package/kvStore.js.map +0 -1
  256. package/localStorageCache.js.map +0 -1
  257. package/sha256.js +0 -58
  258. package/src/arrayBuffer.ts +0 -29
  259. package/src/assert.ts +0 -14
  260. package/src/average.ts +0 -13
  261. package/src/base64Url.ts +0 -20
  262. package/src/dateTimeStr.ts +0 -184
  263. package/src/duration.ts +0 -260
  264. package/src/isEmpty.ts +0 -32
  265. package/src/kvStore.ts +0 -444
  266. package/src/localStorageCache.ts +0 -121
  267. package/src/logging.ts +0 -26
  268. package/src/nonEmpty.ts +0 -18
  269. package/src/safeBtoa.ts +0 -15
  270. package/src/safeParseFloat.ts +0 -10
  271. package/src/safeParseInt.ts +0 -10
  272. package/src/sha256.ts +0 -13
  273. package/src/sum.ts +0 -17
  274. package/src/timeConstants.ts +0 -22
  275. package/src/timer.ts +0 -33
  276. package/timer.js.map +0 -1
package/nonEmpty.mjs ADDED
@@ -0,0 +1,30 @@
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
+ }
20
+
21
+ // src/nonEmpty.ts
22
+ function nonEmpty(t, varName = "value") {
23
+ if (isEmpty(t)) {
24
+ throw new Error(`Empty ${varName}: ${t}`);
25
+ }
26
+ return t;
27
+ }
28
+ export {
29
+ nonEmpty
30
+ };
@@ -33,4 +33,3 @@ function nonNil(t, varName = "value") {
33
33
  0 && (module.exports = {
34
34
  nonNil
35
35
  });
36
- //# sourceMappingURL=nonNil.js.map
@@ -5,9 +5,6 @@
5
5
  * @param varName The variable name to include in the error to throw when t is
6
6
  * nil. Defaults to 'value'.
7
7
  */
8
- export function nonNil<T>(t: T | null | undefined, varName = "value"): T {
9
- if (t === null || t === undefined) {
10
- throw new Error(`Missing ${varName}: ${t}`);
11
- }
12
- return t;
13
- }
8
+ declare function nonNil<T>(t: T | null | undefined, varName?: string): T;
9
+
10
+ export { nonNil };
package/nonNil.min.cjs ADDED
@@ -0,0 +1,2 @@
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
+ //# sourceMappingURL=nonNil.min.cjs.map
@@ -0,0 +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":"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 ADDED
@@ -0,0 +1,2 @@
1
+ function i(n,e="value"){if(n==null)throw new Error(`Missing ${e}: ${n}`);return n}export{i as nonNil};
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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,OAAU,GAAyB,UAAU,SAAY;AACvE,MAAI,MAAM,QAAQ,MAAM,QAAW;AACjC,UAAM,IAAI,MAAM,WAAW,OAAO,KAAK,CAAC,EAAE;AAAA,EAC5C;AACA,SAAO;AACT;","names":[]}
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 ADDED
@@ -0,0 +1,10 @@
1
+ // src/nonNil.ts
2
+ function nonNil(t, varName = "value") {
3
+ if (t === null || t === void 0) {
4
+ throw new Error(`Missing ${varName}: ${t}`);
5
+ }
6
+ return t;
7
+ }
8
+ export {
9
+ nonNil
10
+ };
package/package.json CHANGED
@@ -1,38 +1,428 @@
1
1
  {
2
2
  "name": "@choksheak/ts-utils",
3
3
  "license": "The Unlicense",
4
- "version": "0.2.9",
4
+ "version": "0.3.0",
5
5
  "description": "Random Typescript utilities with support for full tree-shaking",
6
6
  "private": false,
7
7
  "scripts": {
8
- "lint": "eslint src/**",
9
- "format": "prettier --write \"**/*.ts\"",
10
- "test": "npm run clean && jest",
11
- "test:watch": "npm run clean && jest --watch",
8
+ "lint": "eslint .",
9
+ "fix": "eslint . --fix",
10
+ "tsc": "npx tsc --noEmit --allowSyntheticDefaultImports",
11
+ "ft": "npm run fix && npm run tsc",
12
+ "test": "vitest run",
13
+ "test:watch": "vitest",
14
+ "ci": "npm run lint && npm run tsc && npm run build && npm run test",
15
+ "ls": "lint-staged",
16
+ "docs": "rm -rf docs && typedoc `find src -name '*.ts' ! -name '*.test.ts'` --out docs --name 'Chok’s Typescript Utilities'",
12
17
  "clean": "rm -rf dist",
13
- "ci": "npm run lint && npm run format && npm run test",
14
18
  "build": "tsup src/*",
15
19
  "gen-types": "tsc --emitDeclarationOnly --declaration",
16
- "docs": "rm -rf docs && typedoc `find src -name '*.ts' ! -name '*.test.ts'` --out docs --name 'Chok’s Typescript Utilities'",
17
- "pub": "scripts/publish.sh"
20
+ "gen-exports": "tsx scripts/gen-exports.ts",
21
+ "bump": "tsx scripts/bump-version.ts",
22
+ "bump:patch": "tsx scripts/bump-version.ts --patch",
23
+ "bump:minor": "tsx scripts/bump-version.ts --minor",
24
+ "bump:major": "tsx scripts/bump-version.ts --major",
25
+ "pkg": "scripts/package.sh",
26
+ "pub": "npm publish dist/ --access=public",
27
+ "commit": "scripts/commit-release.sh",
28
+ "release": "npm run ci && npm run bump && npm i && npm run pkg && npm run pub && npm run commit",
29
+ "postinstall": "simple-git-hooks"
30
+ },
31
+ "simple-git-hooks": {
32
+ "pre-commit": "npx lint-staged"
33
+ },
34
+ "lint-staged": {
35
+ "*.{ts,tsx,js,jsx}": [
36
+ "echo Using `eslint --fix` will revert changes without printing errors!",
37
+ "eslint ."
38
+ ],
39
+ "*.{ts,tsx}": [
40
+ "echo `tsc-files --noEmit` cannot read *.module.css files",
41
+ "npm run tsc"
42
+ ]
18
43
  },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/choksheak/ts-utils.git"
47
+ },
48
+ "keywords": [
49
+ "chok",
50
+ "TS",
51
+ "utils",
52
+ "typescript",
53
+ "library"
54
+ ],
55
+ "author": "ChokSheak Lau",
56
+ "type": "commonjs",
57
+ "homepage": "https://github.com/choksheak/ts-utils#readme",
19
58
  "devDependencies": {
20
- "@eslint/js": "^9.14.0",
21
- "@jest/globals": "^29.7.0",
22
- "@types/jest": "^27.5.2",
23
- "@types/node": "^16.18.97",
24
- "eslint": "^9.14.0",
59
+ "@eslint/compat": "^1.4.0",
60
+ "@eslint/js": "^9.38.0",
61
+ "@swc/core": "^1.14.0",
62
+ "@types/jest": "^30.0.0",
63
+ "@typescript-eslint/eslint-plugin": "^8.46.2",
64
+ "@typescript-eslint/parser": "^8.46.2",
65
+ "eslint": "^9.38.0",
66
+ "eslint-config": "^0.3.0",
67
+ "eslint-config-prettier": "^10.1.8",
68
+ "eslint-plugin-import": "^2.32.0",
69
+ "eslint-plugin-prettier": "^5.5.4",
70
+ "eslint-plugin-simple-import-sort": "^12.1.1",
25
71
  "fake-indexeddb": "^6.0.0",
26
- "globals": "^15.12.0",
27
- "jest": "^29.7.0",
72
+ "globals": "^16.4.0",
73
+ "jiti": "^2.6.1",
74
+ "lint-staged": "^16.2.6",
28
75
  "jest-environment-jsdom": "^29.7.0",
29
- "jest-localstorage-mock": "^2.4.26",
30
- "prettier": "^3.3.3",
31
- "ts-jest": "^29.2.5",
32
- "ts-node": "^10.9.2",
33
- "tsup": "^8.3.5",
34
- "typedoc": "^0.28.3",
35
- "typescript": "^5.4.5",
36
- "typescript-eslint": "^8.13.0"
76
+ "prettier": "^3.6.2",
77
+ "simple-git-hooks": "^2.13.1",
78
+ "tsup": "^8.5.0",
79
+ "tsx": "^4.20.6",
80
+ "typedoc": "^0.28.14",
81
+ "typescript": "^5.9.3",
82
+ "typescript-eslint": "^8.46.2",
83
+ "vitest": "^4.0.3"
84
+ },
85
+ "exports": {
86
+ "./package.json": "./package.json",
87
+ "./arrayBuffer": {
88
+ "types": "./arrayBuffer.d.ts",
89
+ "import": {
90
+ "production": "./arrayBuffer.min.mjs",
91
+ "development": "./arrayBuffer.mjs",
92
+ "default": "./arrayBuffer.mjs"
93
+ },
94
+ "require": {
95
+ "production": "./arrayBuffer.min.cjs",
96
+ "development": "./arrayBuffer.cjs",
97
+ "default": "./arrayBuffer.cjs"
98
+ }
99
+ },
100
+ "./assert": {
101
+ "types": "./assert.d.ts",
102
+ "import": {
103
+ "production": "./assert.min.mjs",
104
+ "development": "./assert.mjs",
105
+ "default": "./assert.mjs"
106
+ },
107
+ "require": {
108
+ "production": "./assert.min.cjs",
109
+ "development": "./assert.cjs",
110
+ "default": "./assert.cjs"
111
+ }
112
+ },
113
+ "./average": {
114
+ "types": "./average.d.ts",
115
+ "import": {
116
+ "production": "./average.min.mjs",
117
+ "development": "./average.mjs",
118
+ "default": "./average.mjs"
119
+ },
120
+ "require": {
121
+ "production": "./average.min.cjs",
122
+ "development": "./average.cjs",
123
+ "default": "./average.cjs"
124
+ }
125
+ },
126
+ "./base64Url": {
127
+ "types": "./base64Url.d.ts",
128
+ "import": {
129
+ "production": "./base64Url.min.mjs",
130
+ "development": "./base64Url.mjs",
131
+ "default": "./base64Url.mjs"
132
+ },
133
+ "require": {
134
+ "production": "./base64Url.min.cjs",
135
+ "development": "./base64Url.cjs",
136
+ "default": "./base64Url.cjs"
137
+ }
138
+ },
139
+ "./dateTimeStr": {
140
+ "types": "./dateTimeStr.d.ts",
141
+ "import": {
142
+ "production": "./dateTimeStr.min.mjs",
143
+ "development": "./dateTimeStr.mjs",
144
+ "default": "./dateTimeStr.mjs"
145
+ },
146
+ "require": {
147
+ "production": "./dateTimeStr.min.cjs",
148
+ "development": "./dateTimeStr.cjs",
149
+ "default": "./dateTimeStr.cjs"
150
+ }
151
+ },
152
+ "./duration": {
153
+ "types": "./duration.d.ts",
154
+ "import": {
155
+ "production": "./duration.min.mjs",
156
+ "development": "./duration.mjs",
157
+ "default": "./duration.mjs"
158
+ },
159
+ "require": {
160
+ "production": "./duration.min.cjs",
161
+ "development": "./duration.cjs",
162
+ "default": "./duration.cjs"
163
+ }
164
+ },
165
+ "./isEmpty": {
166
+ "types": "./isEmpty.d.ts",
167
+ "import": {
168
+ "production": "./isEmpty.min.mjs",
169
+ "development": "./isEmpty.mjs",
170
+ "default": "./isEmpty.mjs"
171
+ },
172
+ "require": {
173
+ "production": "./isEmpty.min.cjs",
174
+ "development": "./isEmpty.cjs",
175
+ "default": "./isEmpty.cjs"
176
+ }
177
+ },
178
+ "./kvStore": {
179
+ "types": "./kvStore.d.ts",
180
+ "import": {
181
+ "production": "./kvStore.min.mjs",
182
+ "development": "./kvStore.mjs",
183
+ "default": "./kvStore.mjs"
184
+ },
185
+ "require": {
186
+ "production": "./kvStore.min.cjs",
187
+ "development": "./kvStore.cjs",
188
+ "default": "./kvStore.cjs"
189
+ }
190
+ },
191
+ "./localStorageCache": {
192
+ "types": "./localStorageCache.d.ts",
193
+ "import": {
194
+ "production": "./localStorageCache.min.mjs",
195
+ "development": "./localStorageCache.mjs",
196
+ "default": "./localStorageCache.mjs"
197
+ },
198
+ "require": {
199
+ "production": "./localStorageCache.min.cjs",
200
+ "development": "./localStorageCache.cjs",
201
+ "default": "./localStorageCache.cjs"
202
+ }
203
+ },
204
+ "./logging": {
205
+ "types": "./logging.d.ts",
206
+ "import": {
207
+ "production": "./logging.min.mjs",
208
+ "development": "./logging.mjs",
209
+ "default": "./logging.mjs"
210
+ },
211
+ "require": {
212
+ "production": "./logging.min.cjs",
213
+ "development": "./logging.cjs",
214
+ "default": "./logging.cjs"
215
+ }
216
+ },
217
+ "./nonEmpty": {
218
+ "types": "./nonEmpty.d.ts",
219
+ "import": {
220
+ "production": "./nonEmpty.min.mjs",
221
+ "development": "./nonEmpty.mjs",
222
+ "default": "./nonEmpty.mjs"
223
+ },
224
+ "require": {
225
+ "production": "./nonEmpty.min.cjs",
226
+ "development": "./nonEmpty.cjs",
227
+ "default": "./nonEmpty.cjs"
228
+ }
229
+ },
230
+ "./nonNil": {
231
+ "types": "./nonNil.d.ts",
232
+ "import": {
233
+ "production": "./nonNil.min.mjs",
234
+ "development": "./nonNil.mjs",
235
+ "default": "./nonNil.mjs"
236
+ },
237
+ "require": {
238
+ "production": "./nonNil.min.cjs",
239
+ "development": "./nonNil.cjs",
240
+ "default": "./nonNil.cjs"
241
+ }
242
+ },
243
+ "./round": {
244
+ "types": "./round.d.ts",
245
+ "import": {
246
+ "production": "./round.min.mjs",
247
+ "development": "./round.mjs",
248
+ "default": "./round.mjs"
249
+ },
250
+ "require": {
251
+ "production": "./round.min.cjs",
252
+ "development": "./round.cjs",
253
+ "default": "./round.cjs"
254
+ }
255
+ },
256
+ "./safeBtoa": {
257
+ "types": "./safeBtoa.d.ts",
258
+ "import": {
259
+ "production": "./safeBtoa.min.mjs",
260
+ "development": "./safeBtoa.mjs",
261
+ "default": "./safeBtoa.mjs"
262
+ },
263
+ "require": {
264
+ "production": "./safeBtoa.min.cjs",
265
+ "development": "./safeBtoa.cjs",
266
+ "default": "./safeBtoa.cjs"
267
+ }
268
+ },
269
+ "./safeParseFloat": {
270
+ "types": "./safeParseFloat.d.ts",
271
+ "import": {
272
+ "production": "./safeParseFloat.min.mjs",
273
+ "development": "./safeParseFloat.mjs",
274
+ "default": "./safeParseFloat.mjs"
275
+ },
276
+ "require": {
277
+ "production": "./safeParseFloat.min.cjs",
278
+ "development": "./safeParseFloat.cjs",
279
+ "default": "./safeParseFloat.cjs"
280
+ }
281
+ },
282
+ "./safeParseInt": {
283
+ "types": "./safeParseInt.d.ts",
284
+ "import": {
285
+ "production": "./safeParseInt.min.mjs",
286
+ "development": "./safeParseInt.mjs",
287
+ "default": "./safeParseInt.mjs"
288
+ },
289
+ "require": {
290
+ "production": "./safeParseInt.min.cjs",
291
+ "development": "./safeParseInt.cjs",
292
+ "default": "./safeParseInt.cjs"
293
+ }
294
+ },
295
+ "./sha256": {
296
+ "types": "./sha256.d.ts",
297
+ "import": {
298
+ "production": "./sha256.min.mjs",
299
+ "development": "./sha256.mjs",
300
+ "default": "./sha256.mjs"
301
+ },
302
+ "require": {
303
+ "production": "./sha256.min.cjs",
304
+ "development": "./sha256.cjs",
305
+ "default": "./sha256.cjs"
306
+ }
307
+ },
308
+ "./sleep": {
309
+ "types": "./sleep.d.ts",
310
+ "import": {
311
+ "production": "./sleep.min.mjs",
312
+ "development": "./sleep.mjs",
313
+ "default": "./sleep.mjs"
314
+ },
315
+ "require": {
316
+ "production": "./sleep.min.cjs",
317
+ "development": "./sleep.cjs",
318
+ "default": "./sleep.cjs"
319
+ }
320
+ },
321
+ "./sum": {
322
+ "types": "./sum.d.ts",
323
+ "import": {
324
+ "production": "./sum.min.mjs",
325
+ "development": "./sum.mjs",
326
+ "default": "./sum.mjs"
327
+ },
328
+ "require": {
329
+ "production": "./sum.min.cjs",
330
+ "development": "./sum.cjs",
331
+ "default": "./sum.cjs"
332
+ }
333
+ },
334
+ "./timeConstants": {
335
+ "types": "./timeConstants.d.ts",
336
+ "import": {
337
+ "production": "./timeConstants.min.mjs",
338
+ "development": "./timeConstants.mjs",
339
+ "default": "./timeConstants.mjs"
340
+ },
341
+ "require": {
342
+ "production": "./timeConstants.min.cjs",
343
+ "development": "./timeConstants.cjs",
344
+ "default": "./timeConstants.cjs"
345
+ }
346
+ },
347
+ "./timer": {
348
+ "types": "./timer.d.ts",
349
+ "import": {
350
+ "production": "./timer.min.mjs",
351
+ "development": "./timer.mjs",
352
+ "default": "./timer.mjs"
353
+ },
354
+ "require": {
355
+ "production": "./timer.min.cjs",
356
+ "development": "./timer.cjs",
357
+ "default": "./timer.cjs"
358
+ }
359
+ }
360
+ },
361
+ "typesVersions": {
362
+ "*": {
363
+ "arrayBuffer": [
364
+ "./arrayBuffer.d.ts"
365
+ ],
366
+ "assert": [
367
+ "./assert.d.ts"
368
+ ],
369
+ "average": [
370
+ "./average.d.ts"
371
+ ],
372
+ "base64Url": [
373
+ "./base64Url.d.ts"
374
+ ],
375
+ "dateTimeStr": [
376
+ "./dateTimeStr.d.ts"
377
+ ],
378
+ "duration": [
379
+ "./duration.d.ts"
380
+ ],
381
+ "isEmpty": [
382
+ "./isEmpty.d.ts"
383
+ ],
384
+ "kvStore": [
385
+ "./kvStore.d.ts"
386
+ ],
387
+ "localStorageCache": [
388
+ "./localStorageCache.d.ts"
389
+ ],
390
+ "logging": [
391
+ "./logging.d.ts"
392
+ ],
393
+ "nonEmpty": [
394
+ "./nonEmpty.d.ts"
395
+ ],
396
+ "nonNil": [
397
+ "./nonNil.d.ts"
398
+ ],
399
+ "round": [
400
+ "./round.d.ts"
401
+ ],
402
+ "safeBtoa": [
403
+ "./safeBtoa.d.ts"
404
+ ],
405
+ "safeParseFloat": [
406
+ "./safeParseFloat.d.ts"
407
+ ],
408
+ "safeParseInt": [
409
+ "./safeParseInt.d.ts"
410
+ ],
411
+ "sha256": [
412
+ "./sha256.d.ts"
413
+ ],
414
+ "sleep": [
415
+ "./sleep.d.ts"
416
+ ],
417
+ "sum": [
418
+ "./sum.d.ts"
419
+ ],
420
+ "timeConstants": [
421
+ "./timeConstants.d.ts"
422
+ ],
423
+ "timer": [
424
+ "./timer.d.ts"
425
+ ]
426
+ }
37
427
  }
38
- }
428
+ }
@@ -36,4 +36,3 @@ function roundS(n, numDecimalPlaces = 0) {
36
36
  round,
37
37
  roundS
38
38
  });
39
- //# sourceMappingURL=round.js.map
@@ -4,15 +4,11 @@
4
4
  * at the end. To show the exact number of decimal places, you'll need to use
5
5
  * toFixed(). E.g. round(1.20, 2).toFixed(2).
6
6
  */
7
- export function round(n: number, numDecimalPlaces = 0): number {
8
- const multipler = Math.pow(10, numDecimalPlaces);
9
- return Math.round(n * multipler) / multipler;
10
- }
11
-
7
+ declare function round(n: number, numDecimalPlaces?: number): number;
12
8
  /**
13
9
  * Returns a string with the number in the exact number of decimal places
14
10
  * specified, in case the number ends with zeroes.
15
11
  */
16
- export function roundS(n: number, numDecimalPlaces = 0): string {
17
- return round(n, numDecimalPlaces).toFixed(numDecimalPlaces);
18
- }
12
+ declare function roundS(n: number, numDecimalPlaces?: number): string;
13
+
14
+ export { round, roundS };
package/round.min.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var u=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var x=(n,r)=>{for(var t in r)u(n,t,{get:r[t],enumerable:!0})},f=(n,r,t,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of p(r))!b.call(n,o)&&o!==t&&u(n,o,{get:()=>r[o],enumerable:!(e=i(r,o))||e.enumerable});return n};var h=n=>f(u({},"__esModule",{value:!0}),n);var M={};x(M,{round:()=>d,roundS:()=>m});module.exports=h(M);function d(n,r=0){let t=Math.pow(10,r);return Math.round(n*t)/t}function m(n,r=0){return d(n,r).toFixed(r)}0&&(module.exports={round,roundS});
2
+ //# sourceMappingURL=round.min.cjs.map
@@ -0,0 +1 @@
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 * 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\n/**\n * Returns a string with the number in the exact number of decimal places\n * specified, in case the number ends with zeroes.\n */\nexport function roundS(n: number, numDecimalPlaces = 0): string {\n return round(n, numDecimalPlaces).toFixed(numDecimalPlaces);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,WAAAC,IAAA,eAAAC,EAAAJ,GAMO,SAASE,EAAM,EAAWG,EAAmB,EAAW,CAC7D,IAAMC,EAAY,KAAK,IAAI,GAAID,CAAgB,EAC/C,OAAO,KAAK,MAAM,EAAIC,CAAS,EAAIA,CACrC,CAMO,SAASH,EAAO,EAAWE,EAAmB,EAAW,CAC9D,OAAOH,EAAM,EAAGG,CAAgB,EAAE,QAAQA,CAAgB,CAC5D","names":["round_exports","__export","round","roundS","__toCommonJS","numDecimalPlaces","multipler"]}
package/round.min.mjs ADDED
@@ -0,0 +1,2 @@
1
+ function o(n,r=0){let t=Math.pow(10,r);return Math.round(n*t)/t}function u(n,r=0){return o(n,r).toFixed(r)}export{o as round,u as roundS};
2
+ //# sourceMappingURL=round.min.mjs.map
@@ -1 +1 @@
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 * 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\n/**\n * Returns a string with the number in the exact number of decimal places\n * specified, in case the number ends with zeroes.\n */\nexport function roundS(n: number, numDecimalPlaces = 0): string {\n return round(n, numDecimalPlaces).toFixed(numDecimalPlaces);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,MAAM,GAAW,mBAAmB,GAAW;AAC7D,QAAM,YAAY,KAAK,IAAI,IAAI,gBAAgB;AAC/C,SAAO,KAAK,MAAM,IAAI,SAAS,IAAI;AACrC;AAMO,SAAS,OAAO,GAAW,mBAAmB,GAAW;AAC9D,SAAO,MAAM,GAAG,gBAAgB,EAAE,QAAQ,gBAAgB;AAC5D;","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 * 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\n/**\n * Returns a string with the number in the exact number of decimal places\n * specified, in case the number ends with zeroes.\n */\nexport function roundS(n: number, numDecimalPlaces = 0): string {\n return round(n, numDecimalPlaces).toFixed(numDecimalPlaces);\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,CAMO,SAASC,EAAO,EAAWF,EAAmB,EAAW,CAC9D,OAAOD,EAAM,EAAGC,CAAgB,EAAE,QAAQA,CAAgB,CAC5D","names":["round","numDecimalPlaces","multipler","roundS"]}
package/round.mjs ADDED
@@ -0,0 +1,12 @@
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
+ }
6
+ function roundS(n, numDecimalPlaces = 0) {
7
+ return round(n, numDecimalPlaces).toFixed(numDecimalPlaces);
8
+ }
9
+ export {
10
+ round,
11
+ roundS
12
+ };
@@ -32,4 +32,3 @@ function safeBtoa(input) {
32
32
  0 && (module.exports = {
33
33
  safeBtoa
34
34
  });
35
- //# sourceMappingURL=safeBtoa.js.map
package/safeBtoa.d.mts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Base 64 encode the given input string, but safely.
3
+ */
4
+ declare function safeBtoa(input: string): string;
5
+
6
+ export { safeBtoa };
@@ -0,0 +1,2 @@
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
+ //# sourceMappingURL=safeBtoa.min.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/safeBtoa.ts"],"sourcesContent":["/**\n * Base 64 encode the given input string, but safely.\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,GAGO,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"]}
@@ -0,0 +1,2 @@
1
+ function e(n){let t=new TextEncoder().encode(n),o=Array.from(t).map(r=>String.fromCodePoint(r)).join("");return btoa(o)}export{e as safeBtoa};
2
+ //# sourceMappingURL=safeBtoa.min.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/safeBtoa.ts"],"sourcesContent":["/**\n * Base 64 encode the given input string, but safely.\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,SAAS,OAAuB;AAE9C,QAAM,YAAY,IAAI,YAAY,EAAE,OAAO,KAAK;AAGhD,QAAM,eAAe,MAAM,KAAK,SAAS,EACtC,IAAI,CAAC,SAAS,OAAO,cAAc,IAAI,CAAC,EACxC,KAAK,EAAE;AAGV,SAAO,KAAK,YAAY;AAC1B;","names":[]}
1
+ {"version":3,"sources":["../src/safeBtoa.ts"],"sourcesContent":["/**\n * Base 64 encode the given input string, but safely.\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":"AAGO,SAASA,EAASC,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","input","utf8Bytes","binaryString","byte"]}
package/safeBtoa.mjs ADDED
@@ -0,0 +1,9 @@
1
+ // src/safeBtoa.ts
2
+ function safeBtoa(input) {
3
+ const utf8Bytes = new TextEncoder().encode(input);
4
+ const binaryString = Array.from(utf8Bytes).map((byte) => String.fromCodePoint(byte)).join("");
5
+ return btoa(binaryString);
6
+ }
7
+ export {
8
+ safeBtoa
9
+ };
@@ -31,4 +31,3 @@ function safeParseFloat(s, defaultValue = 0) {
31
31
  0 && (module.exports = {
32
32
  safeParseFloat
33
33
  });
34
- //# sourceMappingURL=safeParseFloat.js.map