@ynmstudio/utils
Version:
YNM Utilities for Angular
41 lines (37 loc) • 1.4 kB
JavaScript
import * as i0 from '@angular/core';
import { Pipe } from '@angular/core';
import { isArray } from '@ynmstudio/utils/helpers';
class JoinIntlPipe {
constructor() {
this.defaultOptions = {
style: "long",
type: "conjunction",
};
}
transform(input, locale, options) {
if (!isArray(input)) {
return input;
}
try {
return new Intl.ListFormat(locale ?? undefined, { ...this.defaultOptions, ...options }).format(input);
}
catch (e) {
return Array.from(input).join(', ');
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: JoinIntlPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: JoinIntlPipe, isStandalone: true, name: "joinIntl" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: JoinIntlPipe, decorators: [{
type: Pipe,
args: [{
standalone: true,
name: 'joinIntl',
pure: true
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { JoinIntlPipe };
//# sourceMappingURL=ynmstudio-utils-pipes-join-intl.mjs.map