New paste Repaste Download
/**
* This defines a type 'Literable' which can be a boolean, an object, or a
* `PropertyKey` (a string, a number or symbol), plus null or undefined.
*
* @typedef {boolean | {} | PropertyKey | null | undefined} Literable
*/
/**
* This defines a type 'LiteralArray' with a generic type `Arr` that extends
* an array of `Literable` values or some other chosen constraint type.
*
* @template {LiteralArray<*[]>} Arr
* @typedef {Arr} LiteralArray
*/
/**
* This function takes in a variadic number of arguments and returns an array
* from the provided arguments, which is then frozen to prevent modification.
* Its purpose is to create a tuple of literal types, ensuring the original
* literal types of the arguments are preserved in the tuple.
*
* @template {Literable[]} T Represents an array of `Literable` values. `T`
* can be any array where each element is a `Literable` type (a `PropertyKey`,
* an object, a boolean, a null or an undefined).
*
* @param {LiteralArray<T>} args Literal values to be converted into a tuple.
*
* @returns {Readonly<T>} A tuple-array from the provided literal arguments.
*/
export default function createTuple(...args) { return Object.freeze(args); }
Filename: None. Size: 1kb. View raw, , hex, or download this file.

This paste expires on 2024-06-08 16:28:11.843460. Pasted through web.