@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
41 lines • 1.82 kB
TypeScript
/**
* Default `maxPieces` for functions that return one array element per generated piece
* (`splitIntervalByUnit*`, `intervalDivideEqually*`, `mapDatesInRange`, `mapZonedDatesInRange`).
*
* Owner decision A2 (CORE-8): an output that would be larger returns the sentinel `[]` rather
* than exhausting the heap, which aborts the process where no caller can catch it.
*/
export declare const DEFAULT_MAX_PIECES = 1000000;
/** ECMA-262 §10.4.2 (Array exotic objects): an array length is at most 2^32 - 1. */
export declare const MAX_ARRAY_LENGTH: number;
/**
* Read the `maxPieces` option.
*
* - Omitted options, or an omitted/`undefined` `maxPieces`, give `DEFAULT_MAX_PIECES`
* (Temporal GetOption reads `undefined` as absent).
* - A non-object options argument returns `null` (Temporal GetOptionsObject throws `TypeError`).
* - `maxPieces` must be a positive safe integer, otherwise `null`.
*
* @param options the caller's options argument
* @returns the piece limit, or `null` when the option is invalid
*
* @example resolveMaxPieces(undefined) // 1000000
* @example resolveMaxPieces({ maxPieces: 10 }) // 10
* @example resolveMaxPieces({ maxPieces: 0 }) // null
*/
export declare function resolveMaxPieces(options: {
maxPieces?: number;
} | undefined): number | null;
/**
* Whether an output of `count` pieces is over the limit.
*
* - Over `maxPieces`, or over the longest array a JavaScript engine can hold.
*
* @param count number of pieces the output would hold
* @param maxPieces resolved limit from `resolveMaxPieces`
* @returns `true` when the function must return its sentinel instead
*
* @example exceedsPieceLimit(11, 10) // true
* @example exceedsPieceLimit(2 ** 32, 2 ** 40) // true
*/
export declare function exceedsPieceLimit(count: number, maxPieces: number): boolean;