@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.
- package/README.md +2 -0
- package/{arrayBuffer.js → arrayBuffer.cjs} +0 -1
- package/arrayBuffer.d.mts +10 -0
- package/arrayBuffer.min.cjs +2 -0
- package/arrayBuffer.min.cjs.map +1 -0
- package/arrayBuffer.min.mjs +2 -0
- package/{arrayBuffer.js.map → arrayBuffer.min.mjs.map} +1 -1
- package/arrayBuffer.mjs +14 -0
- package/{assert.js → assert.cjs} +0 -1
- package/assert.d.mts +7 -0
- package/assert.min.cjs +2 -0
- package/assert.min.cjs.map +1 -0
- package/assert.min.mjs +2 -0
- package/{assert.js.map → assert.min.mjs.map} +1 -1
- package/assert.mjs +11 -0
- package/{average.js → average.cjs} +0 -1
- package/average.d.mts +7 -0
- package/average.min.cjs +2 -0
- package/{average.js.map → average.min.cjs.map} +1 -1
- package/average.min.mjs +2 -0
- package/average.min.mjs.map +1 -0
- package/average.mjs +20 -0
- package/{base64Url.js → base64Url.cjs} +0 -1
- package/base64Url.d.mts +10 -0
- package/base64Url.min.cjs +2 -0
- package/base64Url.min.cjs.map +1 -0
- package/base64Url.min.mjs +2 -0
- package/{base64Url.js.map → base64Url.min.mjs.map} +1 -1
- package/base64Url.mjs +14 -0
- package/{dateTimeStr.js → dateTimeStr.cjs} +0 -1
- package/dateTimeStr.d.mts +85 -0
- package/dateTimeStr.min.cjs +2 -0
- package/dateTimeStr.min.cjs.map +1 -0
- package/dateTimeStr.min.mjs +2 -0
- package/{dateTimeStr.js.map → dateTimeStr.min.mjs.map} +1 -1
- package/dateTimeStr.mjs +83 -0
- package/{duration.js → duration.cjs} +9 -11
- package/duration.d.mts +78 -0
- package/duration.min.cjs +2 -0
- package/duration.min.cjs.map +1 -0
- package/duration.min.mjs +2 -0
- package/duration.min.mjs.map +1 -0
- package/duration.mjs +154 -0
- package/{isEmpty.js → isEmpty.cjs} +0 -1
- package/isEmpty.d.mts +6 -0
- package/isEmpty.min.cjs +2 -0
- package/isEmpty.min.cjs.map +1 -0
- package/isEmpty.min.mjs +2 -0
- package/{isEmpty.js.map → isEmpty.min.mjs.map} +1 -1
- package/isEmpty.mjs +22 -0
- package/kvStore.cjs +333 -0
- package/kvStore.d.mts +97 -0
- package/kvStore.min.cjs +2 -0
- package/kvStore.min.cjs.map +1 -0
- package/kvStore.min.mjs +2 -0
- package/kvStore.min.mjs.map +1 -0
- package/kvStore.mjs +300 -0
- package/{localStorageCache.js → localStorageCache.cjs} +5 -7
- package/localStorageCache.d.mts +57 -0
- package/localStorageCache.min.cjs +2 -0
- package/localStorageCache.min.cjs.map +1 -0
- package/localStorageCache.min.mjs +2 -0
- package/localStorageCache.min.mjs.map +1 -0
- package/localStorageCache.mjs +92 -0
- package/{logging.js → logging.cjs} +0 -1
- package/logging.d.mts +4 -0
- package/logging.min.cjs +2 -0
- package/logging.min.cjs.map +1 -0
- package/logging.min.mjs +2 -0
- package/{logging.js.map → logging.min.mjs.map} +1 -1
- package/logging.mjs +21 -0
- package/{nonEmpty.js → nonEmpty.cjs} +0 -1
- package/nonEmpty.d.mts +10 -0
- package/nonEmpty.min.cjs +2 -0
- package/{nonEmpty.js.map → nonEmpty.min.cjs.map} +1 -1
- package/nonEmpty.min.mjs +2 -0
- package/nonEmpty.min.mjs.map +1 -0
- package/nonEmpty.mjs +30 -0
- package/{nonNil.js → nonNil.cjs} +0 -1
- package/{src/nonNil.ts → nonNil.d.mts} +3 -6
- package/nonNil.min.cjs +2 -0
- package/nonNil.min.cjs.map +1 -0
- package/nonNil.min.mjs +2 -0
- package/{nonNil.js.map → nonNil.min.mjs.map} +1 -1
- package/nonNil.mjs +10 -0
- package/package.json +414 -24
- package/{round.js → round.cjs} +0 -1
- package/{src/round.ts → round.d.mts} +4 -8
- package/round.min.cjs +2 -0
- package/round.min.cjs.map +1 -0
- package/round.min.mjs +2 -0
- package/{round.js.map → round.min.mjs.map} +1 -1
- package/round.mjs +12 -0
- package/{safeBtoa.js → safeBtoa.cjs} +0 -1
- package/safeBtoa.d.mts +6 -0
- package/safeBtoa.min.cjs +2 -0
- package/safeBtoa.min.cjs.map +1 -0
- package/safeBtoa.min.mjs +2 -0
- package/{safeBtoa.js.map → safeBtoa.min.mjs.map} +1 -1
- package/safeBtoa.mjs +9 -0
- package/{safeParseFloat.js → safeParseFloat.cjs} +0 -1
- package/safeParseFloat.d.mts +6 -0
- package/safeParseFloat.min.cjs +2 -0
- package/safeParseFloat.min.cjs.map +1 -0
- package/safeParseFloat.min.mjs +2 -0
- package/{safeParseFloat.js.map → safeParseFloat.min.mjs.map} +1 -1
- package/safeParseFloat.mjs +8 -0
- package/{safeParseInt.js → safeParseInt.cjs} +0 -1
- package/safeParseInt.d.mts +6 -0
- package/safeParseInt.min.cjs +2 -0
- package/safeParseInt.min.cjs.map +1 -0
- package/safeParseInt.min.mjs +2 -0
- package/{safeParseInt.js.map → safeParseInt.min.mjs.map} +1 -1
- package/safeParseInt.mjs +8 -0
- package/sha256.cjs +35 -0
- package/sha256.d.mts +6 -0
- package/sha256.min.cjs +2 -0
- package/sha256.min.cjs.map +1 -0
- package/sha256.min.mjs +2 -0
- package/{sha256.js.map → sha256.min.mjs.map} +1 -1
- package/sha256.mjs +10 -0
- package/{sleep.js → sleep.cjs} +0 -1
- package/{src/sleep.ts → sleep.d.mts} +3 -3
- package/sleep.min.cjs +2 -0
- package/sleep.min.cjs.map +1 -0
- package/sleep.min.mjs +2 -0
- package/{sleep.js.map → sleep.min.mjs.map} +1 -1
- package/sleep.mjs +7 -0
- package/{sum.js → sum.cjs} +0 -1
- package/sum.d.mts +7 -0
- package/sum.min.cjs +2 -0
- package/sum.min.cjs.map +1 -0
- package/sum.min.mjs +2 -0
- package/{sum.js.map → sum.min.mjs.map} +1 -1
- package/sum.mjs +13 -0
- package/{timeConstants.js → timeConstants.cjs} +0 -1
- package/timeConstants.d.mts +20 -0
- package/timeConstants.min.cjs +2 -0
- package/timeConstants.min.cjs.map +1 -0
- package/timeConstants.min.mjs +2 -0
- package/{timeConstants.js.map → timeConstants.min.mjs.map} +1 -1
- package/timeConstants.mjs +31 -0
- package/{timer.js → timer.cjs} +6 -6
- package/timer.d.mts +13 -0
- package/timer.min.cjs +2 -0
- package/timer.min.cjs.map +1 -0
- package/timer.min.mjs +2 -0
- package/timer.min.mjs.map +1 -0
- package/timer.mjs +161 -0
- package/docs/.nojekyll +0 -1
- package/docs/assets/hierarchy.js +0 -1
- package/docs/assets/highlight.css +0 -22
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1640
- package/docs/classes/kvStore.KVStore.html +0 -26
- package/docs/classes/kvStore.KVStoreField.html +0 -7
- package/docs/classes/timer.Timer.html +0 -8
- package/docs/functions/arrayBuffer.arrayBufferToBase64.html +0 -2
- package/docs/functions/arrayBuffer.arrayBufferToHex.html +0 -2
- package/docs/functions/assert.assert.html +0 -3
- package/docs/functions/average.average.html +0 -3
- package/docs/functions/base64Url.base64ToBase64URL.html +0 -2
- package/docs/functions/base64Url.base64UrlToBase64.html +0 -2
- package/docs/functions/dateTimeStr.getDisplayDateTime.html +0 -3
- package/docs/functions/dateTimeStr.getLongMonthNameOneIndexed.html +0 -4
- package/docs/functions/dateTimeStr.getLongMonthNameZeroIndexed.html +0 -4
- package/docs/functions/dateTimeStr.getShortMonthNameOneIndexed.html +0 -4
- package/docs/functions/dateTimeStr.getShortMonthNameZeroIndexed.html +0 -4
- package/docs/functions/dateTimeStr.hhMm.html +0 -4
- package/docs/functions/dateTimeStr.hhMmSs.html +0 -4
- package/docs/functions/dateTimeStr.hhMmSsMs.html +0 -5
- package/docs/functions/dateTimeStr.toDate.html +0 -4
- package/docs/functions/dateTimeStr.tzShort.html +0 -4
- package/docs/functions/dateTimeStr.yyyyMm.html +0 -4
- package/docs/functions/dateTimeStr.yyyyMmDd.html +0 -4
- package/docs/functions/duration.durationOrMsToMs.html +0 -2
- package/docs/functions/duration.durationToMs.html +0 -2
- package/docs/functions/duration.elapsed.html +0 -2
- package/docs/functions/duration.formatDuration.html +0 -4
- package/docs/functions/duration.msToDuration.html +0 -5
- package/docs/functions/duration.readableDuration.html +0 -4
- package/docs/functions/isEmpty.isEmpty.html +0 -2
- package/docs/functions/kvStore.kvStoreItem.html +0 -2
- package/docs/functions/localStorageCache.storeItem.html +0 -15
- package/docs/functions/logging.capLength.html +0 -1
- package/docs/functions/logging.stringify.html +0 -1
- package/docs/functions/nonEmpty.nonEmpty.html +0 -5
- package/docs/functions/nonNil.nonNil.html +0 -5
- package/docs/functions/round.round.html +0 -5
- package/docs/functions/round.roundS.html +0 -3
- package/docs/functions/safeBtoa.safeBtoa.html +0 -2
- package/docs/functions/safeParseFloat.safeParseFloat.html +0 -2
- package/docs/functions/safeParseInt.safeParseInt.html +0 -2
- package/docs/functions/sha256.sha256.html +0 -2
- package/docs/functions/sleep.sleep.html +0 -3
- package/docs/functions/sum.sum.html +0 -3
- package/docs/functions/timer.timer.html +0 -2
- package/docs/hierarchy.html +0 -1
- package/docs/index.html +0 -4
- package/docs/modules/arrayBuffer.html +0 -1
- package/docs/modules/assert.html +0 -1
- package/docs/modules/average.html +0 -1
- package/docs/modules/base64Url.html +0 -1
- package/docs/modules/dateTimeStr.html +0 -1
- package/docs/modules/duration.html +0 -1
- package/docs/modules/isEmpty.html +0 -1
- package/docs/modules/kvStore.html +0 -1
- package/docs/modules/localStorageCache.html +0 -1
- package/docs/modules/logging.html +0 -1
- package/docs/modules/nonEmpty.html +0 -1
- package/docs/modules/nonNil.html +0 -1
- package/docs/modules/round.html +0 -1
- package/docs/modules/safeBtoa.html +0 -1
- package/docs/modules/safeParseFloat.html +0 -1
- package/docs/modules/safeParseInt.html +0 -1
- package/docs/modules/sha256.html +0 -1
- package/docs/modules/sleep.html +0 -1
- package/docs/modules/sum.html +0 -1
- package/docs/modules/timeConstants.html +0 -1
- package/docs/modules/timer.html +0 -1
- package/docs/modules.html +0 -1
- package/docs/types/dateTimeStr.AnyDateTime.html +0 -1
- package/docs/types/duration.Duration.html +0 -6
- package/docs/types/duration.DurationStyle.html +0 -6
- package/docs/types/duration.DurationSuffixMap.html +0 -6
- package/docs/types/duration.DurationSuffixType.html +0 -1
- package/docs/types/duration.DurationType.html +0 -2
- package/docs/types/localStorageCache.StoredItem.html +0 -4
- package/docs/variables/duration.DURATION_STYLE_SUFFIX_MAP.html +0 -1
- package/docs/variables/duration.DURATION_TYPE_SEQUENCE.html +0 -2
- package/docs/variables/kvStore.DEFAULT_EXPIRY_DELTA_MS.html +0 -2
- package/docs/variables/kvStore.GC_INTERVAL_MS.html +0 -2
- package/docs/variables/kvStore.MILLIS_PER_DAY.html +0 -2
- package/docs/variables/kvStore.kvStore.html +0 -3
- package/docs/variables/timeConstants.HOURS_PER_DAY.html +0 -1
- package/docs/variables/timeConstants.HOURS_PER_WEEK.html +0 -1
- package/docs/variables/timeConstants.MINUTES_PER_DAY.html +0 -1
- package/docs/variables/timeConstants.MINUTES_PER_HOUR.html +0 -1
- package/docs/variables/timeConstants.MINUTES_PER_WEEK.html +0 -1
- package/docs/variables/timeConstants.MS_PER_DAY.html +0 -1
- package/docs/variables/timeConstants.MS_PER_HOUR.html +0 -1
- package/docs/variables/timeConstants.MS_PER_MINUTE.html +0 -1
- package/docs/variables/timeConstants.MS_PER_SECOND.html +0 -3
- package/docs/variables/timeConstants.MS_PER_WEEK.html +0 -1
- package/docs/variables/timeConstants.SECONDS_PER_DAY.html +0 -1
- package/docs/variables/timeConstants.SECONDS_PER_HOUR.html +0 -1
- package/docs/variables/timeConstants.SECONDS_PER_MINUTE.html +0 -1
- package/docs/variables/timeConstants.SECONDS_PER_WEEK.html +0 -1
- package/duration.js.map +0 -1
- package/kvStore.js +0 -383
- package/kvStore.js.map +0 -1
- package/localStorageCache.js.map +0 -1
- package/sha256.js +0 -58
- package/src/arrayBuffer.ts +0 -29
- package/src/assert.ts +0 -14
- package/src/average.ts +0 -13
- package/src/base64Url.ts +0 -20
- package/src/dateTimeStr.ts +0 -184
- package/src/duration.ts +0 -260
- package/src/isEmpty.ts +0 -32
- package/src/kvStore.ts +0 -444
- package/src/localStorageCache.ts +0 -121
- package/src/logging.ts +0 -26
- package/src/nonEmpty.ts +0 -18
- package/src/safeBtoa.ts +0 -15
- package/src/safeParseFloat.ts +0 -10
- package/src/safeParseInt.ts +0 -10
- package/src/sha256.ts +0 -13
- package/src/sum.ts +0 -17
- package/src/timeConstants.ts +0 -22
- package/src/timer.ts +0 -33
- 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
|
+
};
|
package/{nonNil.js → nonNil.cjs}
RENAMED
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
@@ -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":"
|
|
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
package/package.json
CHANGED
|
@@ -1,38 +1,428 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@choksheak/ts-utils",
|
|
3
3
|
"license": "The Unlicense",
|
|
4
|
-
"version": "0.
|
|
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
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
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
|
-
"
|
|
17
|
-
"
|
|
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/
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"@types/
|
|
24
|
-
"eslint": "^
|
|
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": "^
|
|
27
|
-
"
|
|
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
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"typescript": "^
|
|
36
|
-
"
|
|
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
|
+
}
|
package/{round.js → round.cjs}
RENAMED
|
@@ -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
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
@@ -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":"
|
|
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
|
+
};
|
package/safeBtoa.d.mts
ADDED
package/safeBtoa.min.cjs
ADDED
|
@@ -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"]}
|
package/safeBtoa.min.mjs
ADDED
|
@@ -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":"
|
|
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