@stackone/utils 0.8.1 → 0.8.2

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/dist/index.d.mts CHANGED
@@ -118,9 +118,11 @@ declare const isNumber: (value: unknown) => value is number;
118
118
  declare const isBoolean: (value: unknown) => value is boolean;
119
119
  declare const isDate: (value: unknown) => value is Date;
120
120
  declare const isObject: (value: unknown) => value is Record<string, unknown>;
121
+ declare const isFunction: (value: unknown) => value is (...args: unknown[]) => unknown;
122
+ declare const isFutureUnixTimestamp: (value: unknown) => boolean;
121
123
  //#endregion
122
124
  //#region src/uuids.d.ts
123
125
  declare const isValidUUID: (uuid: string) => boolean;
124
126
  declare const generateRequestId: (randomUUIDGenerator?: typeof randomUUID) => string;
125
127
  //#endregion
126
- export { NormalizedKeyMap, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isMissing, isNumber, isObject, isString, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString };
128
+ export { NormalizedKeyMap, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isFunction, isFutureUnixTimestamp, isMissing, isNumber, isObject, isString, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString };
package/dist/index.d.ts CHANGED
@@ -118,9 +118,11 @@ declare const isNumber: (value: unknown) => value is number;
118
118
  declare const isBoolean: (value: unknown) => value is boolean;
119
119
  declare const isDate: (value: unknown) => value is Date;
120
120
  declare const isObject: (value: unknown) => value is Record<string, unknown>;
121
+ declare const isFunction: (value: unknown) => value is (...args: unknown[]) => unknown;
122
+ declare const isFutureUnixTimestamp: (value: unknown) => boolean;
121
123
  //#endregion
122
124
  //#region src/uuids.d.ts
123
125
  declare const isValidUUID: (uuid: string) => boolean;
124
126
  declare const generateRequestId: (randomUUIDGenerator?: typeof randomUUID) => string;
125
127
  //#endregion
126
- export { NormalizedKeyMap, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isMissing, isNumber, isObject, isString, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString };
128
+ export { NormalizedKeyMap, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isFunction, isFutureUnixTimestamp, isMissing, isNumber, isObject, isString, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString };
package/dist/index.js CHANGED
@@ -8510,6 +8510,18 @@ const isNumber = (value) => typeof value === "number";
8510
8510
  const isBoolean = (value) => typeof value === "boolean";
8511
8511
  const isDate = (value) => value instanceof Date;
8512
8512
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8513
+ const isFunction = (value) => typeof value === "function";
8514
+ const isFutureUnixTimestamp = (value) => {
8515
+ const numberValue = Number(value);
8516
+ if (Number.isNaN(numberValue)) return false;
8517
+ const fiveMinutesInSeconds = 5 * 60;
8518
+ const fiveMinutesInMilliseconds = fiveMinutesInSeconds * 1e3;
8519
+ const currentSeconds = Math.floor(Date.now() / 1e3) - fiveMinutesInSeconds;
8520
+ const currentMilliseconds = Date.now() - fiveMinutesInMilliseconds;
8521
+ const secondsMaxFuture = currentSeconds + 10 * 365 * 24 * 60 * 60;
8522
+ const millisecondsMaxFuture = currentMilliseconds + 10 * 365 * 24 * 60 * 60 * 1e3;
8523
+ return numberValue >= currentSeconds && numberValue <= secondsMaxFuture || numberValue >= currentMilliseconds && numberValue <= millisecondsMaxFuture;
8524
+ };
8513
8525
 
8514
8526
  //#endregion
8515
8527
  //#region src/parsers.ts
@@ -8733,6 +8745,8 @@ exports.getCountrySubDivisionNameBySubDivisionCode = getCountrySubDivisionNameBy
8733
8745
  exports.getCountrySubDivisionsByAlpha2Code = getCountrySubDivisionsByAlpha2Code;
8734
8746
  exports.isBoolean = isBoolean;
8735
8747
  exports.isDate = isDate;
8748
+ exports.isFunction = isFunction;
8749
+ exports.isFutureUnixTimestamp = isFutureUnixTimestamp;
8736
8750
  exports.isMissing = isMissing;
8737
8751
  exports.isNumber = isNumber;
8738
8752
  exports.isObject = isObject;
package/dist/index.mjs CHANGED
@@ -8488,6 +8488,18 @@ const isNumber = (value) => typeof value === "number";
8488
8488
  const isBoolean = (value) => typeof value === "boolean";
8489
8489
  const isDate = (value) => value instanceof Date;
8490
8490
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8491
+ const isFunction = (value) => typeof value === "function";
8492
+ const isFutureUnixTimestamp = (value) => {
8493
+ const numberValue = Number(value);
8494
+ if (Number.isNaN(numberValue)) return false;
8495
+ const fiveMinutesInSeconds = 5 * 60;
8496
+ const fiveMinutesInMilliseconds = fiveMinutesInSeconds * 1e3;
8497
+ const currentSeconds = Math.floor(Date.now() / 1e3) - fiveMinutesInSeconds;
8498
+ const currentMilliseconds = Date.now() - fiveMinutesInMilliseconds;
8499
+ const secondsMaxFuture = currentSeconds + 10 * 365 * 24 * 60 * 60;
8500
+ const millisecondsMaxFuture = currentMilliseconds + 10 * 365 * 24 * 60 * 60 * 1e3;
8501
+ return numberValue >= currentSeconds && numberValue <= secondsMaxFuture || numberValue >= currentMilliseconds && numberValue <= millisecondsMaxFuture;
8502
+ };
8491
8503
 
8492
8504
  //#endregion
8493
8505
  //#region src/parsers.ts
@@ -8678,4 +8690,4 @@ const generateRequestId = (randomUUIDGenerator = randomUUID) => {
8678
8690
  };
8679
8691
 
8680
8692
  //#endregion
8681
- export { NormalizedKeyMap, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isMissing, isNumber, isObject, isString, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString };
8693
+ export { NormalizedKeyMap, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isFunction, isFutureUnixTimestamp, isMissing, isNumber, isObject, isString, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@stackone/utils",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
- "module": "dist/index.es.mjs",
7
- "types": "dist/types/index.d.ts",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
8
  "files": [
9
9
  "dist",
10
10
  "package.json",
@@ -12,8 +12,8 @@
12
12
  ],
13
13
  "exports": {
14
14
  ".": {
15
- "types": "./dist/types/index.d.ts",
16
- "import": "./dist/index.es.mjs",
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
17
  "require": "./dist/index.js"
18
18
  },
19
19
  "./package.json": "./package.json"
@@ -40,7 +40,8 @@
40
40
  "author": "StackOne",
41
41
  "license": "ISC",
42
42
  "dependencies": {
43
- "date-fns": "^4.1.0"
43
+ "date-fns": "^4.1.0",
44
+ "mathjs": "^11.11.1"
44
45
  },
45
46
  "devDependencies": {
46
47
  "tsdown": "^0.12.9"