@bouko/ts 0.3.7 → 0.3.9
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.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/sorters.d.ts +1 -0
- package/dist/utils/sorters.js +1 -0
- package/dist/utils/time.d.ts +2 -0
- package/dist/utils/time.js +8 -0
- package/package.json +2 -2
- package/dist/core/safety.d.ts +0 -0
- package/dist/core/safety.js +0 -1
- package/dist/types.d.ts +0 -15
- package/dist/types.js +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./utils/parsers";
|
|
|
10
10
|
export * from "./utils/converters";
|
|
11
11
|
export * from "./utils/log";
|
|
12
12
|
export * from "./utils/time";
|
|
13
|
+
export * from "./utils/sorters";
|
|
13
14
|
export declare const safely: <T>(action: () => T) => T | undefined;
|
|
14
15
|
export declare const safelyThru: <T>(arr: T[], action: (item: T) => void) => void;
|
|
15
16
|
export declare const isJsonMap: (value: unknown) => value is JsonMap;
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const byName: (a: string, b: string) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const byName = (a, b) => a.localeCompare(b, undefined, { sensitivity: "base" });
|
package/dist/utils/time.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare function mmSS(timestamp: number): string;
|
|
2
2
|
export declare const secToMs: (sec: number) => number;
|
|
3
3
|
export declare function isoToMs(duration: string): number;
|
|
4
|
+
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
5
|
+
export declare const isExpired: (date: Date | string) => boolean;
|
package/dist/utils/time.js
CHANGED
|
@@ -25,3 +25,11 @@ export function isoToMs(duration) {
|
|
|
25
25
|
parseFloat(seconds || "0")) * 1000;
|
|
26
26
|
return ms;
|
|
27
27
|
}
|
|
28
|
+
export const sleep = (ms) => {
|
|
29
|
+
return new Promise((res) => setTimeout(res, ms));
|
|
30
|
+
};
|
|
31
|
+
export const isExpired = (date) => {
|
|
32
|
+
if (typeof date === "string")
|
|
33
|
+
date = new Date(date);
|
|
34
|
+
return new Date() > date;
|
|
35
|
+
};
|
package/package.json
CHANGED
package/dist/core/safety.d.ts
DELETED
|
File without changes
|
package/dist/core/safety.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/types.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for common data structures.
|
|
3
|
-
*
|
|
4
|
-
* - `StringMap`: Map of string keys to string values.
|
|
5
|
-
* - `JsonMap`: Object of primitives, arrays, or nested maps.
|
|
6
|
-
* - `JsonValue`: Union type representing a valid JSON value.
|
|
7
|
-
*
|
|
8
|
-
* They are intended to facilitate type-safe handling
|
|
9
|
-
* of generic objects (ex. forms)
|
|
10
|
-
**/
|
|
11
|
-
export type StringMap = Record<string, string>;
|
|
12
|
-
export type JsonMap = {
|
|
13
|
-
[key: string]: JsonValue | JsonValue[];
|
|
14
|
-
};
|
|
15
|
-
export type JsonValue = string | number | boolean | null | undefined | JsonMap;
|
package/dist/types.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for common data structures.
|
|
3
|
-
*
|
|
4
|
-
* - `StringMap`: Map of string keys to string values.
|
|
5
|
-
* - `JsonMap`: Object of primitives, arrays, or nested maps.
|
|
6
|
-
* - `JsonValue`: Union type representing a valid JSON value.
|
|
7
|
-
*
|
|
8
|
-
* They are intended to facilitate type-safe handling
|
|
9
|
-
* of generic objects (ex. forms)
|
|
10
|
-
**/
|
|
11
|
-
export {};
|
|
12
|
-
// clean
|