@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
30 lines (28 loc) • 1 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
const require_utils_intl = require('../utils/intl.cjs');
let _intlayer_config_built = require("@intlayer/config/built");
//#region src/formatters/list.ts
/**
* Formats an array of values into a localized list string using the Intl API.
*
* @example
* list(['apple', 'banana', 'orange']);
* // "apple, banana, and orange"
*
* @example
* list(['red', 'green', 'blue'], { locale: Locales.FRENCH, type: 'disjunction' });
* // "rouge, vert ou bleu"
*
* @example
* list([1, 2, 3], { type: 'unit' });
* // "1, 2, 3"
*/
const list = (values, options) => require_utils_intl.getCachedIntl(Intl.ListFormat, options?.locale ?? _intlayer_config_built.internationalization?.defaultLocale, {
type: options?.type ?? "conjunction",
style: options?.style ?? "long",
...options
}).format(values.map(String));
//#endregion
exports.list = list;
//# sourceMappingURL=list.cjs.map