@dichovsky/testrail-api-client 1.0.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/src/utils.ts ADDED
@@ -0,0 +1,15 @@
1
+ /** Base64-encodes a string. Uses Buffer in Node.js, UTF-8-safe btoa in browsers. */
2
+ export function base64Encode(str: string): string {
3
+ if (typeof Buffer !== 'undefined') {
4
+ return Buffer.from(str).toString('base64');
5
+ }
6
+ // In browsers, encode the string as UTF-8 before using btoa
7
+ return btoa(
8
+ encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, p1: string) => String.fromCharCode(parseInt(p1, 16))),
9
+ );
10
+ }
11
+
12
+ /** Resolves after `ms` milliseconds. */
13
+ export function sleep(ms: number): Promise<void> {
14
+ return new Promise((resolve) => setTimeout(resolve, ms));
15
+ }