@choksheak/ts-utils 0.2.9 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/{arrayBuffer.js → arrayBuffer.cjs} +0 -1
- package/arrayBuffer.d.mts +10 -0
- package/arrayBuffer.d.ts +4 -2
- 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.d.ts +3 -1
- 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.d.ts +3 -1
- 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.d.ts +4 -2
- 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.d.ts +15 -13
- 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.d.ts +15 -13
- 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.d.ts +3 -1
- 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/iterators.cjs +34 -0
- package/iterators.d.mts +4 -0
- package/iterators.d.ts +4 -0
- package/iterators.min.cjs +2 -0
- package/iterators.min.cjs.map +1 -0
- package/iterators.min.mjs +2 -0
- package/iterators.min.mjs.map +1 -0
- package/iterators.mjs +9 -0
- package/kvStore.cjs +365 -0
- package/kvStore.d.mts +139 -0
- package/kvStore.d.ts +95 -50
- 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 +333 -0
- package/localStore.cjs +267 -0
- package/localStore.d.mts +119 -0
- package/localStore.d.ts +119 -0
- package/localStore.min.cjs +2 -0
- package/localStore.min.cjs.map +1 -0
- package/localStore.min.mjs +2 -0
- package/localStore.min.mjs.map +1 -0
- package/localStore.mjs +235 -0
- package/{logging.js → logging.cjs} +0 -1
- package/logging.d.mts +4 -0
- package/logging.d.ts +4 -2
- 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.d.ts +3 -1
- 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.d.ts +3 -1
- 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 +447 -24
- package/{round.js → round.cjs} +0 -1
- package/{src/round.ts → round.d.mts} +4 -8
- package/round.d.ts +4 -2
- 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.d.ts +3 -1
- 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.d.ts +3 -1
- 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.d.ts +3 -1
- 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.d.ts +3 -1
- 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.d.ts +3 -1
- 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/storageAdapter.cjs +18 -0
- package/storageAdapter.d.mts +33 -0
- package/storageAdapter.d.ts +33 -0
- package/storageAdapter.min.cjs +2 -0
- package/storageAdapter.min.cjs.map +1 -0
- package/storageAdapter.min.mjs +1 -0
- package/storageAdapter.min.mjs.map +1 -0
- package/storageAdapter.mjs +0 -0
- package/{sum.js → sum.cjs} +0 -1
- package/sum.d.mts +7 -0
- package/sum.d.ts +3 -1
- 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.d.ts +16 -14
- 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.d.ts +4 -2
- 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.d.ts +0 -55
- package/localStorageCache.js +0 -121
- 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
|
@@ -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.d.ts
CHANGED
|
@@ -4,9 +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
|
-
|
|
7
|
+
declare function round(n: number, numDecimalPlaces?: number): number;
|
|
8
8
|
/**
|
|
9
9
|
* Returns a string with the number in the exact number of decimal places
|
|
10
10
|
* specified, in case the number ends with zeroes.
|
|
11
11
|
*/
|
|
12
|
-
|
|
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.d.ts
CHANGED
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
package/safeParseFloat.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns 0 or the given defaultValue if the string is not a valid number.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
declare function safeParseFloat<T>(s: string, defaultValue?: T | number): T | number;
|
|
5
|
+
|
|
6
|
+
export { safeParseFloat };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var b=(e,r)=>{for(var n in r)s(e,n,{get:r[n],enumerable:!0})},m=(e,r,n,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of i(r))!o.call(e,t)&&t!==n&&s(e,t,{get:()=>r[t],enumerable:!(u=a(r,t))||u.enumerable});return e};var N=e=>m(s({},"__esModule",{value:!0}),e);var c={};b(c,{safeParseFloat:()=>T});module.exports=N(c);function T(e,r=0){let n=Number(e);return isNaN(n)?r:n}0&&(module.exports={safeParseFloat});
|
|
2
|
+
//# sourceMappingURL=safeParseFloat.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/safeParseFloat.ts"],"sourcesContent":["/**\n * Returns 0 or the given defaultValue if the string is not a valid number.\n */\nexport function safeParseFloat<T>(\n s: string,\n defaultValue: T | number = 0,\n): T | number {\n const i = Number(s);\n return isNaN(i) ? defaultValue : i;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAGO,SAASE,EACdE,EACAC,EAA2B,EACf,CACZ,IAAMC,EAAI,OAAOF,CAAC,EAClB,OAAO,MAAME,CAAC,EAAID,EAAeC,CACnC","names":["safeParseFloat_exports","__export","safeParseFloat","__toCommonJS","s","defaultValue","i"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/safeParseFloat.ts"],"sourcesContent":["/**\n * Returns 0 or the given defaultValue if the string is not a valid number.\n */\nexport function safeParseFloat<T>(\n s: string,\n defaultValue: T | number = 0,\n): T | number {\n const i = Number(s);\n return isNaN(i) ? defaultValue : i;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/safeParseFloat.ts"],"sourcesContent":["/**\n * Returns 0 or the given defaultValue if the string is not a valid number.\n */\nexport function safeParseFloat<T>(\n s: string,\n defaultValue: T | number = 0,\n): T | number {\n const i = Number(s);\n return isNaN(i) ? defaultValue : i;\n}\n"],"mappings":"AAGO,SAASA,EACdC,EACAC,EAA2B,EACf,CACZ,IAAMC,EAAI,OAAOF,CAAC,EAClB,OAAO,MAAME,CAAC,EAAID,EAAeC,CACnC","names":["safeParseFloat","s","defaultValue","i"]}
|
package/safeParseInt.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns 0 or the given defaultValue if the string is not a valid number.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
declare function safeParseInt<T>(s: string, defaultValue?: T | number): T | number;
|
|
5
|
+
|
|
6
|
+
export { safeParseInt };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var b=(n,r)=>{for(var e in r)o(n,e,{get:r[e],enumerable:!0})},f=(n,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of a(r))!i.call(n,t)&&t!==e&&o(n,t,{get:()=>r[t],enumerable:!(s=u(r,t))||s.enumerable});return n};var m=n=>f(o({},"__esModule",{value:!0}),n);var T={};b(T,{safeParseInt:()=>N});module.exports=m(T);function N(n,r=0){let e=Number(n);return isNaN(e)?r:Math.floor(e)}0&&(module.exports={safeParseInt});
|
|
2
|
+
//# sourceMappingURL=safeParseInt.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/safeParseInt.ts"],"sourcesContent":["/**\n * Returns 0 or the given defaultValue if the string is not a valid number.\n */\nexport function safeParseInt<T>(\n s: string,\n defaultValue: T | number = 0,\n): T | number {\n const i = Number(s);\n return isNaN(i) ? defaultValue : Math.floor(i);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAGO,SAASE,EACdE,EACAC,EAA2B,EACf,CACZ,IAAMC,EAAI,OAAOF,CAAC,EAClB,OAAO,MAAME,CAAC,EAAID,EAAe,KAAK,MAAMC,CAAC,CAC/C","names":["safeParseInt_exports","__export","safeParseInt","__toCommonJS","s","defaultValue","i"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/safeParseInt.ts"],"sourcesContent":["/**\n * Returns 0 or the given defaultValue if the string is not a valid number.\n */\nexport function safeParseInt<T>(\n s: string,\n defaultValue: T | number = 0,\n): T | number {\n const i = Number(s);\n return isNaN(i) ? defaultValue : Math.floor(i);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/safeParseInt.ts"],"sourcesContent":["/**\n * Returns 0 or the given defaultValue if the string is not a valid number.\n */\nexport function safeParseInt<T>(\n s: string,\n defaultValue: T | number = 0,\n): T | number {\n const i = Number(s);\n return isNaN(i) ? defaultValue : Math.floor(i);\n}\n"],"mappings":"AAGO,SAASA,EACdC,EACAC,EAA2B,EACf,CACZ,IAAMC,EAAI,OAAOF,CAAC,EAClB,OAAO,MAAME,CAAC,EAAID,EAAe,KAAK,MAAMC,CAAC,CAC/C","names":["safeParseInt","s","defaultValue","i"]}
|
package/safeParseInt.mjs
ADDED
package/sha256.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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);
|
|
19
|
+
|
|
20
|
+
// src/sha256.ts
|
|
21
|
+
var sha256_exports = {};
|
|
22
|
+
__export(sha256_exports, {
|
|
23
|
+
sha256: () => sha256
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(sha256_exports);
|
|
26
|
+
async function sha256(input) {
|
|
27
|
+
const encoder = new TextEncoder();
|
|
28
|
+
const uint8Array = encoder.encode(input);
|
|
29
|
+
const arrayBuffer = await crypto.subtle.digest("SHA-256", uint8Array);
|
|
30
|
+
return arrayBuffer;
|
|
31
|
+
}
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
sha256
|
|
35
|
+
});
|
package/sha256.d.mts
ADDED
package/sha256.d.ts
CHANGED
package/sha256.min.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var n in r)a(e,n,{get:r[n],enumerable:!0})},i=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of s(r))!f.call(e,t)&&t!==n&&a(e,t,{get:()=>r[t],enumerable:!(o=c(r,t))||o.enumerable});return e};var y=e=>i(a({},"__esModule",{value:!0}),e);var A={};u(A,{sha256:()=>d});module.exports=y(A);async function d(e){let n=new TextEncoder().encode(e);return await crypto.subtle.digest("SHA-256",n)}0&&(module.exports={sha256});
|
|
2
|
+
//# sourceMappingURL=sha256.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sha256.ts"],"sourcesContent":["/**\n * SHA-256 hash an input string into an ArrayBuffer.\n */\nexport async function sha256(input: string): Promise<ArrayBuffer> {\n // Encode the input string as a Uint8Array\n const encoder = new TextEncoder();\n const uint8Array = encoder.encode(input);\n\n // Compute the SHA-256 hash using the SubtleCrypto API\n const arrayBuffer = await crypto.subtle.digest(\"SHA-256\", uint8Array);\n\n return arrayBuffer;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,IAAA,eAAAC,EAAAH,GAGA,eAAsBE,EAAOE,EAAqC,CAGhE,IAAMC,EADU,IAAI,YAAY,EACL,OAAOD,CAAK,EAKvC,OAFoB,MAAM,OAAO,OAAO,OAAO,UAAWC,CAAU,CAGtE","names":["sha256_exports","__export","sha256","__toCommonJS","input","uint8Array"]}
|
package/sha256.min.mjs
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sha256.ts"],"sourcesContent":["/**\n * SHA-256 hash an input string into an ArrayBuffer.\n */\nexport async function sha256(input: string): Promise<ArrayBuffer> {\n // Encode the input string as a Uint8Array\n const encoder = new TextEncoder();\n const uint8Array = encoder.encode(input);\n\n // Compute the SHA-256 hash using the SubtleCrypto API\n const arrayBuffer = await crypto.subtle.digest(\"SHA-256\", uint8Array);\n\n return arrayBuffer;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/sha256.ts"],"sourcesContent":["/**\n * SHA-256 hash an input string into an ArrayBuffer.\n */\nexport async function sha256(input: string): Promise<ArrayBuffer> {\n // Encode the input string as a Uint8Array\n const encoder = new TextEncoder();\n const uint8Array = encoder.encode(input);\n\n // Compute the SHA-256 hash using the SubtleCrypto API\n const arrayBuffer = await crypto.subtle.digest(\"SHA-256\", uint8Array);\n\n return arrayBuffer;\n}\n"],"mappings":"AAGA,eAAsBA,EAAOC,EAAqC,CAGhE,IAAMC,EADU,IAAI,YAAY,EACL,OAAOD,CAAK,EAKvC,OAFoB,MAAM,OAAO,OAAO,OAAO,UAAWC,CAAU,CAGtE","names":["sha256","input","uint8Array"]}
|
package/sha256.mjs
ADDED
package/{sleep.js → sleep.cjs}
RENAMED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Sleep for a given number of milliseconds. Note that this method is async,
|
|
3
3
|
* so please remember to call it with await, like `await sleep(1000);`.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
5
|
+
declare function sleep(ms: number): Promise<void>;
|
|
6
|
+
|
|
7
|
+
export { sleep };
|
package/sleep.d.ts
CHANGED
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
* Sleep for a given number of milliseconds. Note that this method is async,
|
|
3
3
|
* so please remember to call it with await, like `await sleep(1000);`.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
declare function sleep(ms: number): Promise<void>;
|
|
6
|
+
|
|
7
|
+
export { sleep };
|
package/sleep.min.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(o,e)=>{for(var i in e)n(o,i,{get:e[i],enumerable:!0})},P=(o,e,i,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of s(e))!u.call(o,r)&&r!==i&&n(o,r,{get:()=>e[r],enumerable:!(t=m(e,r))||t.enumerable});return o};var b=o=>P(n({},"__esModule",{value:!0}),o);var d={};p(d,{sleep:()=>c});module.exports=b(d);function c(o){return new Promise(e=>setTimeout(e,o))}0&&(module.exports={sleep});
|
|
2
|
+
//# sourceMappingURL=sleep.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sleep.ts"],"sourcesContent":["/**\n * Sleep for a given number of milliseconds. Note that this method is async,\n * so please remember to call it with await, like `await sleep(1000);`.\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,IAAA,eAAAC,EAAAH,GAIO,SAASE,EAAME,EAA2B,CAC/C,OAAO,IAAI,QAASC,GAAY,WAAWA,EAASD,CAAE,CAAC,CACzD","names":["sleep_exports","__export","sleep","__toCommonJS","ms","resolve"]}
|
package/sleep.min.mjs
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sleep.ts"],"sourcesContent":["/**\n * Sleep for a given number of milliseconds. Note that this method is async,\n * so please remember to call it with await, like `await sleep(1000);`.\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/sleep.ts"],"sourcesContent":["/**\n * Sleep for a given number of milliseconds. Note that this method is async,\n * so please remember to call it with await, like `await sleep(1000);`.\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"mappings":"AAIO,SAASA,EAAMC,EAA2B,CAC/C,OAAO,IAAI,QAASC,GAAY,WAAWA,EAASD,CAAE,CAAC,CACzD","names":["sleep","ms","resolve"]}
|
package/sleep.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/storageAdapter.ts
|
|
17
|
+
var storageAdapter_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(storageAdapter_exports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Duration } from './duration.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Most basic interface for a storage implementation. This is designed to be
|
|
5
|
+
* quite easily implemented by users to plug in any new underlying storage.
|
|
6
|
+
*/
|
|
7
|
+
type StorageAdapter<T> = {
|
|
8
|
+
set: (key: string, value: T) => Promise<void> | void;
|
|
9
|
+
get: (key: string) => Promise<T | undefined> | T | undefined;
|
|
10
|
+
delete: (key: string) => Promise<void> | void;
|
|
11
|
+
clear: () => Promise<void> | void;
|
|
12
|
+
};
|
|
13
|
+
/** Most basic interface for stored object. */
|
|
14
|
+
type StoredObject<T> = {
|
|
15
|
+
value: T;
|
|
16
|
+
storedMs: number;
|
|
17
|
+
expiryMs: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Full interface for a storage implementation. Each method can be either sync
|
|
21
|
+
* or async, and the interface works with either implementation scheme.
|
|
22
|
+
*/
|
|
23
|
+
type FullStorageAdapter<T> = StorageAdapter<T> & {
|
|
24
|
+
set: (key: string, value: T, expiryDeltaMs?: number | Duration) => Promise<void> | void;
|
|
25
|
+
getStoredObject: (key: string) => Promise<StoredObject<T> | undefined> | StoredObject<T> | undefined;
|
|
26
|
+
forEach(callback: (key: string, value: T, expiryMs: number, storedMs: number) => void | Promise<void>): Promise<void> | void;
|
|
27
|
+
size(): Promise<number> | number;
|
|
28
|
+
asMap<T>(): Promise<Map<string, StoredObject<T>>> | Map<string, StoredObject<T>>;
|
|
29
|
+
gc: () => Promise<void> | void;
|
|
30
|
+
gcNow: () => Promise<void> | void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type { FullStorageAdapter, StorageAdapter, StoredObject };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Duration } from './duration.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Most basic interface for a storage implementation. This is designed to be
|
|
5
|
+
* quite easily implemented by users to plug in any new underlying storage.
|
|
6
|
+
*/
|
|
7
|
+
type StorageAdapter<T> = {
|
|
8
|
+
set: (key: string, value: T) => Promise<void> | void;
|
|
9
|
+
get: (key: string) => Promise<T | undefined> | T | undefined;
|
|
10
|
+
delete: (key: string) => Promise<void> | void;
|
|
11
|
+
clear: () => Promise<void> | void;
|
|
12
|
+
};
|
|
13
|
+
/** Most basic interface for stored object. */
|
|
14
|
+
type StoredObject<T> = {
|
|
15
|
+
value: T;
|
|
16
|
+
storedMs: number;
|
|
17
|
+
expiryMs: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Full interface for a storage implementation. Each method can be either sync
|
|
21
|
+
* or async, and the interface works with either implementation scheme.
|
|
22
|
+
*/
|
|
23
|
+
type FullStorageAdapter<T> = StorageAdapter<T> & {
|
|
24
|
+
set: (key: string, value: T, expiryDeltaMs?: number | Duration) => Promise<void> | void;
|
|
25
|
+
getStoredObject: (key: string) => Promise<StoredObject<T> | undefined> | StoredObject<T> | undefined;
|
|
26
|
+
forEach(callback: (key: string, value: T, expiryMs: number, storedMs: number) => void | Promise<void>): Promise<void> | void;
|
|
27
|
+
size(): Promise<number> | number;
|
|
28
|
+
asMap<T>(): Promise<Map<string, StoredObject<T>>> | Map<string, StoredObject<T>>;
|
|
29
|
+
gc: () => Promise<void> | void;
|
|
30
|
+
gcNow: () => Promise<void> | void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type { FullStorageAdapter, StorageAdapter, StoredObject };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var m=(r,e,d,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of n(e))!a.call(r,o)&&o!==d&&t(r,o,{get:()=>e[o],enumerable:!(i=s(e,o))||i.enumerable});return r};var v=r=>m(t({},"__esModule",{value:!0}),r);var u={};module.exports=v(u);
|
|
2
|
+
//# sourceMappingURL=storageAdapter.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/storageAdapter.ts"],"sourcesContent":["import { Duration } from \"./duration\";\n\n/**\n * Most basic interface for a storage implementation. This is designed to be\n * quite easily implemented by users to plug in any new underlying storage.\n */\nexport type StorageAdapter<T> = {\n set: (key: string, value: T) => Promise<void> | void;\n get: (key: string) => Promise<T | undefined> | T | undefined;\n delete: (key: string) => Promise<void> | void;\n clear: () => Promise<void> | void;\n};\n\n/** Most basic interface for stored object. */\nexport type StoredObject<T> = {\n value: T;\n storedMs: number;\n expiryMs: number;\n};\n\n/**\n * Full interface for a storage implementation. Each method can be either sync\n * or async, and the interface works with either implementation scheme.\n */\nexport type FullStorageAdapter<T> = StorageAdapter<T> & {\n // Redefining `set()`, but with an optional expiration parameter.\n set: (\n key: string,\n value: T,\n expiryDeltaMs?: number | Duration,\n ) => Promise<void> | void;\n\n getStoredObject: (\n key: string,\n ) => Promise<StoredObject<T> | undefined> | StoredObject<T> | undefined;\n\n forEach(\n callback: (\n key: string,\n value: T,\n expiryMs: number,\n storedMs: number,\n ) => void | Promise<void>,\n ): Promise<void> | void;\n\n size(): Promise<number> | number;\n\n asMap<T>():\n | Promise<Map<string, StoredObject<T>>>\n | Map<string, StoredObject<T>>;\n\n gc: () => Promise<void> | void;\n\n gcNow: () => Promise<void> | void;\n};\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["storageAdapter_exports","__toCommonJS"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=storageAdapter.min.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
File without changes
|
package/{sum.js → sum.cjs}
RENAMED
package/sum.d.mts
ADDED
package/sum.d.ts
CHANGED
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
* Add all the numbers together in the given array. Treats null, undefined and
|
|
3
3
|
* NaN as zero.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
declare function sum(numbers: (number | null | undefined)[]): number;
|
|
6
|
+
|
|
7
|
+
export { sum };
|
package/sum.min.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var b=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var f=(n,e)=>{for(var u in e)b(n,u,{get:e[u],enumerable:!0})},o=(n,e,u,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!r.call(n,i)&&i!==u&&b(n,i,{get:()=>e[i],enumerable:!(m=d(e,i))||m.enumerable});return n};var s=n=>o(b({},"__esModule",{value:!0}),n);var a={};f(a,{sum:()=>t});module.exports=s(a);function t(n){return n.reduce((e,u)=>{let m=typeof u=="number"&&!isNaN(u)&&isFinite(u)?u:0;return e+m},0)}0&&(module.exports={sum});
|
|
2
|
+
//# sourceMappingURL=sum.min.cjs.map
|
package/sum.min.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sum.ts"],"sourcesContent":["/**\n * Add all the numbers together in the given array. Treats null, undefined and\n * NaN as zero.\n */\nexport function sum(numbers: (number | null | undefined)[]): number {\n return numbers.reduce(\n (accumulated: number, current: number | null | undefined) => {\n const value =\n typeof current === \"number\" && !isNaN(current) && isFinite(current)\n ? current\n : 0;\n\n return accumulated + value;\n },\n 0,\n );\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,SAAAE,IAAA,eAAAC,EAAAH,GAIO,SAASE,EAAIE,EAAgD,CAClE,OAAOA,EAAQ,OACb,CAACC,EAAqBC,IAAuC,CAC3D,IAAMC,EACJ,OAAOD,GAAY,UAAY,CAAC,MAAMA,CAAO,GAAK,SAASA,CAAO,EAC9DA,EACA,EAEN,OAAOD,EAAcE,CACvB,EACA,CACF,CACF","names":["sum_exports","__export","sum","__toCommonJS","numbers","accumulated","current","value"]}
|
package/sum.min.mjs
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sum.ts"],"sourcesContent":["/**\n * Add all the numbers together in the given array. Treats null, undefined and\n * NaN as zero.\n */\nexport function sum(numbers: (number | null | undefined)[]): number {\n return numbers.reduce(\n (accumulated: number, current: number | null | undefined) => {\n const value =\n typeof current === \"number\" && !isNaN(current) && isFinite(current)\n ? current\n : 0;\n\n return accumulated + value;\n },\n 0,\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/sum.ts"],"sourcesContent":["/**\n * Add all the numbers together in the given array. Treats null, undefined and\n * NaN as zero.\n */\nexport function sum(numbers: (number | null | undefined)[]): number {\n return numbers.reduce(\n (accumulated: number, current: number | null | undefined) => {\n const value =\n typeof current === \"number\" && !isNaN(current) && isFinite(current)\n ? current\n : 0;\n\n return accumulated + value;\n },\n 0,\n );\n}\n"],"mappings":"AAIO,SAASA,EAAIC,EAAgD,CAClE,OAAOA,EAAQ,OACb,CAACC,EAAqBC,IAAuC,CAC3D,IAAMC,EACJ,OAAOD,GAAY,UAAY,CAAC,MAAMA,CAAO,GAAK,SAASA,CAAO,EAC9DA,EACA,EAEN,OAAOD,EAAcE,CACvB,EACA,CACF,CACF","names":["sum","numbers","accumulated","current","value"]}
|
package/sum.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/sum.ts
|
|
2
|
+
function sum(numbers) {
|
|
3
|
+
return numbers.reduce(
|
|
4
|
+
(accumulated, current) => {
|
|
5
|
+
const value = typeof current === "number" && !isNaN(current) && isFinite(current) ? current : 0;
|
|
6
|
+
return accumulated + value;
|
|
7
|
+
},
|
|
8
|
+
0
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
sum
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Note that month and year do not have fixed durations, and hence are excluded
|
|
3
|
+
* from this file.
|
|
4
|
+
*/
|
|
5
|
+
declare const MS_PER_SECOND = 1000;
|
|
6
|
+
declare const MS_PER_MINUTE = 60000;
|
|
7
|
+
declare const MS_PER_HOUR = 3600000;
|
|
8
|
+
declare const MS_PER_DAY = 86400000;
|
|
9
|
+
declare const MS_PER_WEEK = 604800000;
|
|
10
|
+
declare const SECONDS_PER_MINUTE = 60;
|
|
11
|
+
declare const SECONDS_PER_HOUR = 3600;
|
|
12
|
+
declare const SECONDS_PER_DAY = 86400;
|
|
13
|
+
declare const SECONDS_PER_WEEK = 604800;
|
|
14
|
+
declare const MINUTES_PER_HOUR = 60;
|
|
15
|
+
declare const MINUTES_PER_DAY = 1440;
|
|
16
|
+
declare const MINUTES_PER_WEEK = 10080;
|
|
17
|
+
declare const HOURS_PER_DAY = 24;
|
|
18
|
+
declare const HOURS_PER_WEEK = 168;
|
|
19
|
+
|
|
20
|
+
export { HOURS_PER_DAY, HOURS_PER_WEEK, MINUTES_PER_DAY, MINUTES_PER_HOUR, MINUTES_PER_WEEK, MS_PER_DAY, MS_PER_HOUR, MS_PER_MINUTE, MS_PER_SECOND, MS_PER_WEEK, SECONDS_PER_DAY, SECONDS_PER_HOUR, SECONDS_PER_MINUTE, SECONDS_PER_WEEK };
|