UNPKG

3.49 kBTypeScriptView Raw
1import * as querystring from 'querystring';
2import { PassThrough } from 'stream';
3export declare function normalize<T = {}, U = Function>(optionsOrCallback?: T | U, cb?: U): {
4 options: T;
5 callback: U;
6};
7/**
8 * Flatten an object into an Array of arrays, [[key, value], ..].
9 * Implements Object.entries() for Node.js <8
10 * @internal
11 */
12export declare function objectEntries<T>(obj: {
13 [key: string]: T;
14}): Array<[string, T]>;
15/**
16 * Encode `str` with encodeURIComponent, plus these
17 * reserved characters: `! * ' ( )`.
18 *
19 * See {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent| MDN: fixedEncodeURIComponent}
20 *
21 * @param {string} str The URI component to encode.
22 * @return {string} The encoded string.
23 */
24export declare function fixedEncodeURIComponent(str: string): string;
25/**
26 * URI encode `uri` for generating signed URLs, using fixedEncodeURIComponent.
27 *
28 * Encode every byte except `A-Z a-Z 0-9 ~ - . _`.
29 *
30 * @param {string} uri The URI to encode.
31 * @param [boolean=false] encodeSlash If `true`, the "/" character is not encoded.
32 * @return {string} The encoded string.
33 */
34export declare function encodeURI(uri: string, encodeSlash: boolean): string;
35/**
36 * Serialize an object to a URL query string using util.encodeURI(uri, true).
37 * @param {string} url The object to serialize.
38 * @return {string} Serialized string.
39 */
40export declare function qsStringify(qs: querystring.ParsedUrlQueryInput): string;
41export declare function objectKeyToLowercase<T>(object: {
42 [key: string]: T;
43}): {
44 [key: string]: T;
45};
46/**
47 * JSON encode str, with unicode \u+ representation.
48 * @param {object} obj The object to encode.
49 * @return {string} Serialized string.
50 */
51export declare function unicodeJSONStringify(obj: object): string;
52/**
53 * Converts the given objects keys to snake_case
54 * @param {object} obj object to convert keys to snake case.
55 * @returns {object} object with keys converted to snake case.
56 */
57export declare function convertObjKeysToSnakeCase(obj: object): object;
58/**
59 * Formats the provided date object as a UTC ISO string.
60 * @param {Date} dateTimeToFormat date object to be formatted.
61 * @param {boolean} includeTime flag to include hours, minutes, seconds in output.
62 * @param {string} dateDelimiter delimiter between date components.
63 * @param {string} timeDelimiter delimiter between time components.
64 * @returns {string} UTC ISO format of provided date obect.
65 */
66export declare function formatAsUTCISO(dateTimeToFormat: Date, includeTime?: boolean, dateDelimiter?: string, timeDelimiter?: string): string;
67/**
68 * Examines the runtime environment and returns the appropriate tracking string.
69 * @returns {string} metrics tracking string based on the current runtime environment.
70 */
71export declare function getRuntimeTrackingString(): string;
72/**
73 * Looks at package.json and creates the user-agent string to be applied to request headers.
74 * @returns {string} user agent string.
75 */
76export declare function getUserAgentString(): string;
77export declare function getDirName(): string;
78export declare function getModuleFormat(): "ESM" | "CJS";
79export declare class PassThroughShim extends PassThrough {
80 private shouldEmitReading;
81 private shouldEmitWriting;
82 _read(size: number): void;
83 _write(chunk: never, encoding: BufferEncoding, callback: (error?: Error | null | undefined) => void): void;
84 _final(callback: (error?: Error | null | undefined) => void): void;
85}