@fern-api/ui-core-utils 0.126.2-1fce154cd → 0.126.2-3354fa3cc
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/__test__/formatUtc.test.d.ts +2 -0
- package/dist/__test__/formatUtc.test.d.ts.map +1 -0
- package/dist/__test__/formatUtc.test.js +7 -0
- package/dist/bytes.d.ts +12 -3
- package/dist/bytes.d.ts.map +1 -1
- package/dist/bytes.js +27 -32
- package/dist/formatUtc.d.ts +2 -0
- package/dist/formatUtc.d.ts.map +1 -0
- package/dist/formatUtc.js +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatUtc.test.d.ts","sourceRoot":"","sources":["../../src/__test__/formatUtc.test.ts"],"names":[],"mappings":""}
|
package/dist/bytes.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
export declare function measureBytes(str: string): number;
|
|
2
|
+
/**
|
|
3
|
+
* Chunks a string into an array of strings, each of the specified byte size.
|
|
4
|
+
* @param str - The string to chunk.
|
|
5
|
+
* @param byteSize - The byte size of each chunk. i.e. 10KB = 50 * 1000
|
|
6
|
+
* @returns An array of strings, each of the specified byte size.
|
|
7
|
+
*/
|
|
8
|
+
export declare function chunkToBytes(str: string, byteSize: number): string[];
|
|
1
9
|
/**
|
|
2
10
|
* Truncates a string to the specified byte length.
|
|
3
|
-
*
|
|
4
|
-
* @
|
|
11
|
+
* @param str - The string to truncate.
|
|
12
|
+
* @param byteSize - The byte size of the truncated string. i.e. 10KB = 50 * 1000
|
|
13
|
+
* @returns The truncated string.
|
|
5
14
|
*/
|
|
6
|
-
export declare
|
|
15
|
+
export declare function truncateToBytes(str: string, byteSize: number): string;
|
|
7
16
|
//# sourceMappingURL=bytes.d.ts.map
|
package/dist/bytes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAapE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKrE"}
|
package/dist/bytes.js
CHANGED
|
@@ -1,37 +1,32 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
throw new Error("Input must be string");
|
|
4
|
-
}
|
|
5
|
-
let curByteLength = 0;
|
|
6
|
-
let codePoint;
|
|
7
|
-
let segment;
|
|
8
|
-
for (let i = 0; i < string.length; i += 1) {
|
|
9
|
-
codePoint = string.charCodeAt(i);
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11
|
-
segment = string[i];
|
|
12
|
-
if (isHighSurrogate(codePoint) && isLowSurrogate(string.charCodeAt(i + 1))) {
|
|
13
|
-
i += 1;
|
|
14
|
-
segment += string[i];
|
|
15
|
-
}
|
|
16
|
-
curByteLength += getLength(segment);
|
|
17
|
-
if (curByteLength === byteLength) {
|
|
18
|
-
return string.slice(0, i + 1);
|
|
19
|
-
}
|
|
20
|
-
else if (curByteLength > byteLength) {
|
|
21
|
-
return string.slice(0, i - segment.length + 1);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return string;
|
|
1
|
+
export function measureBytes(str) {
|
|
2
|
+
return new TextEncoder().encode(str).length;
|
|
25
3
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Chunks a string into an array of strings, each of the specified byte size.
|
|
6
|
+
* @param str - The string to chunk.
|
|
7
|
+
* @param byteSize - The byte size of each chunk. i.e. 10KB = 50 * 1000
|
|
8
|
+
* @returns An array of strings, each of the specified byte size.
|
|
9
|
+
*/
|
|
10
|
+
export function chunkToBytes(str, byteSize) {
|
|
11
|
+
const encoder = new TextEncoder();
|
|
12
|
+
// TODO: what if the string isn't utf8?
|
|
13
|
+
const utf8Bytes = encoder.encode(str);
|
|
14
|
+
const numChunks = Math.ceil(utf8Bytes.length / byteSize);
|
|
15
|
+
const chunks = new Array(numChunks);
|
|
16
|
+
for (let i = 0, o = 0; i < numChunks; ++i, o += byteSize) {
|
|
17
|
+
chunks[i] = new TextDecoder().decode(utf8Bytes.slice(o, o + byteSize));
|
|
18
|
+
}
|
|
19
|
+
return chunks;
|
|
31
20
|
}
|
|
32
21
|
/**
|
|
33
22
|
* Truncates a string to the specified byte length.
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
23
|
+
* @param str - The string to truncate.
|
|
24
|
+
* @param byteSize - The byte size of the truncated string. i.e. 10KB = 50 * 1000
|
|
25
|
+
* @returns The truncated string.
|
|
36
26
|
*/
|
|
37
|
-
export
|
|
27
|
+
export function truncateToBytes(str, byteSize) {
|
|
28
|
+
const encoder = new TextEncoder();
|
|
29
|
+
const utf8Bytes = encoder.encode(str);
|
|
30
|
+
const truncatedBytes = utf8Bytes.slice(0, byteSize);
|
|
31
|
+
return new TextDecoder().decode(truncatedBytes);
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatUtc.d.ts","sourceRoot":"","sources":["../src/formatUtc.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ export { visitObject, type ObjectPropertiesVisitor } from "./ObjectPropertiesVis
|
|
|
2
2
|
export { addPrefixToString } from "./addPrefixToString";
|
|
3
3
|
export { assertNever, assertNeverNoThrow } from "./assertNever";
|
|
4
4
|
export { assertVoidNoThrow } from "./assertVoidNoThrow";
|
|
5
|
-
export { truncateToBytes } from "./bytes";
|
|
5
|
+
export { chunkToBytes, measureBytes, truncateToBytes } from "./bytes";
|
|
6
6
|
export { combineURLs } from "./combineURLs";
|
|
7
7
|
export { delay } from "./delay/delay";
|
|
8
8
|
export { withMinimumTime } from "./delay/withMinimumTime";
|
|
9
9
|
export { EMPTY_ARRAY, EMPTY_OBJECT } from "./empty";
|
|
10
|
+
export { formatUtc } from "./formatUtc";
|
|
10
11
|
export { identity } from "./identity";
|
|
11
12
|
export { assertNonNullish, isNonNullish } from "./isNonNullish";
|
|
12
13
|
export { entries, type Entries } from "./objects/entries";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,12 @@ export { visitObject } from "./ObjectPropertiesVisitor";
|
|
|
2
2
|
export { addPrefixToString } from "./addPrefixToString";
|
|
3
3
|
export { assertNever, assertNeverNoThrow } from "./assertNever";
|
|
4
4
|
export { assertVoidNoThrow } from "./assertVoidNoThrow";
|
|
5
|
-
export { truncateToBytes } from "./bytes";
|
|
5
|
+
export { chunkToBytes, measureBytes, truncateToBytes } from "./bytes";
|
|
6
6
|
export { combineURLs } from "./combineURLs";
|
|
7
7
|
export { delay } from "./delay/delay";
|
|
8
8
|
export { withMinimumTime } from "./delay/withMinimumTime";
|
|
9
9
|
export { EMPTY_ARRAY, EMPTY_OBJECT } from "./empty";
|
|
10
|
+
export { formatUtc } from "./formatUtc";
|
|
10
11
|
export { identity } from "./identity";
|
|
11
12
|
export { assertNonNullish, isNonNullish } from "./isNonNullish";
|
|
12
13
|
export { entries } from "./objects/entries";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fern-api/ui-core-utils",
|
|
3
|
-
"version": "0.126.2-
|
|
3
|
+
"version": "0.126.2-3354fa3cc",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/fern-api/fern-platform.git",
|
|
@@ -57,6 +57,8 @@
|
|
|
57
57
|
"depcheck": "depcheck"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
+
"date-fns": "^4.1.0",
|
|
61
|
+
"date-fns-tz": "^3.2.0",
|
|
60
62
|
"strip-ansi": "^7.1.0",
|
|
61
63
|
"title": "^3.5.3",
|
|
62
64
|
"ua-parser-js": "^1.0.35"
|
|
@@ -68,10 +70,10 @@
|
|
|
68
70
|
"@types/ua-parser-js": "^0.7.39",
|
|
69
71
|
"depcheck": "^1.4.3",
|
|
70
72
|
"eslint": "^8.56.0",
|
|
71
|
-
"vitest": "^2.1.4",
|
|
72
73
|
"organize-imports-cli": "^0.10.0",
|
|
73
74
|
"prettier": "^3.3.2",
|
|
74
75
|
"stylelint": "^16.1.0",
|
|
75
|
-
"typescript": "5.4.3"
|
|
76
|
+
"typescript": "5.4.3",
|
|
77
|
+
"vitest": "^2.1.4"
|
|
76
78
|
}
|
|
77
79
|
}
|