UNPKG

64.1 kBJavaScriptView Raw
1import { __decorate } from 'tslib';
2import { Pipe, NgModule } from '@angular/core';
3
4let DiffPipe = class DiffPipe {
5 transform(input, ...args) {
6 if (!Array.isArray(input)) {
7 return input;
8 }
9 // tslint:disable-next-line no-bitwise
10 return args.reduce((d, c) => d.filter((e) => !~c.indexOf(e)), input);
11 }
12};
13DiffPipe = __decorate([
14 Pipe({ name: 'diff' })
15], DiffPipe);
16
17let InitialPipe = class InitialPipe {
18 transform(input, num = 0) {
19 return Array.isArray(input) ? input.slice(0, input.length - num) : input;
20 }
21};
22InitialPipe = __decorate([
23 Pipe({ name: 'initial' })
24], InitialPipe);
25
26let FlattenPipe = class FlattenPipe {
27 transform(input, shallow = false) {
28 if (!Array.isArray(input)) {
29 return input;
30 }
31 return shallow ? [].concat.apply([], input) : this.flatten(input);
32 }
33 flatten(array) {
34 return array.reduce((arr, elm) => {
35 if (Array.isArray(elm)) {
36 return arr.concat(this.flatten(elm));
37 }
38 return arr.concat(elm);
39 }, []);
40 }
41};
42FlattenPipe = __decorate([
43 Pipe({ name: 'flatten' })
44], FlattenPipe);
45
46let IntersectionPipe = class IntersectionPipe {
47 transform(input, ...args) {
48 if (!Array.isArray(input)) {
49 return input;
50 }
51 // tslint:disable-next-line no-bitwise
52 return args.reduce((n, c) => n.filter((e) => !!~c.indexOf(e)), input);
53 }
54};
55IntersectionPipe = __decorate([
56 Pipe({ name: 'intersection' })
57], IntersectionPipe);
58
59function isUndefined(value) {
60 return typeof value === 'undefined';
61}
62function isFunction(value) {
63 return typeof value === 'function';
64}
65function isNumber(value) {
66 return typeof value === 'number';
67}
68function isString(value) {
69 return typeof value === 'string';
70}
71function isBoolean(value) {
72 return typeof value === 'boolean';
73}
74function isObject(value) {
75 return value !== null && typeof value === 'object';
76}
77function isNumberFinite(value) {
78 return isNumber(value) && isFinite(value);
79}
80function isVowel(letter) {
81 const vowels = ['a', 'e', 'i', 'o', 'u'];
82 return vowels.indexOf(letter) !== -1;
83}
84function ucFirst(text) {
85 const [part, ...split] = text.split(/\s/g);
86 const ucd = part
87 .toLowerCase()
88 .split(/(?=['|-])/g)
89 .map((word) => word.indexOf('-') + word.indexOf("'") > -2
90 ? word.slice(0, 2).toUpperCase() + word.slice(2)
91 : word.slice(0, 1).toUpperCase() + word.slice(1))
92 .join('');
93 return [ucd, ...split].join(' ');
94}
95function applyPrecision(num, precision) {
96 if (precision <= 0) {
97 return Math.round(num);
98 }
99 const tho = Math.pow(10, precision);
100 return Math.round(num * tho) / tho;
101}
102function extractDeepPropertyByMapKey(obj, map) {
103 const keys = map.split('.');
104 const head = keys.shift();
105 return keys.reduce((prop, key) => {
106 return !isUndefined(prop) && !isUndefined(prop[key]) ? prop[key] : undefined;
107 }, obj[head || '']);
108}
109function extractDeepPropertyByParentMapKey(obj, map) {
110 const keys = map.split('.');
111 const tail = keys.pop();
112 const props = extractDeepPropertyByMapKey(obj, keys.join('.'));
113 return { props, tail };
114}
115function getKeysTwoObjects(obj, other) {
116 return [...Object.keys(obj), ...Object.keys(other)].filter((key, index, array) => array.indexOf(key) === index);
117}
118function isDeepEqual(obj, other) {
119 if (!isObject(obj) || !isObject(other)) {
120 return obj === other;
121 }
122 return getKeysTwoObjects(obj, other).every((key) => {
123 if (!isObject(obj[key]) && !isObject(other[key])) {
124 return obj[key] === other[key];
125 }
126 if (!isObject(obj[key]) || !isObject(other[key])) {
127 return false;
128 }
129 return isDeepEqual(obj[key], other[key]);
130 });
131}
132
133let ReversePipe = class ReversePipe {
134 transform(input) {
135 if (isString(input)) {
136 return input
137 .split('')
138 .reverse()
139 .join('');
140 }
141 return Array.isArray(input) ? input.slice().reverse() : input;
142 }
143};
144ReversePipe = __decorate([
145 Pipe({ name: 'reverse' })
146], ReversePipe);
147
148let TailPipe = class TailPipe {
149 transform(input, num = 0) {
150 return Array.isArray(input) ? input.slice(num) : input;
151 }
152};
153TailPipe = __decorate([
154 Pipe({ name: 'tail' })
155], TailPipe);
156
157let TrurthifyPipe = class TrurthifyPipe {
158 transform(input) {
159 return Array.isArray(input) ? input.filter(e => !!e) : input;
160 }
161};
162TrurthifyPipe = __decorate([
163 Pipe({ name: 'truthify' })
164], TrurthifyPipe);
165
166let UnionPipe = class UnionPipe {
167 transform(input, args = []) {
168 if (!Array.isArray(input) || !Array.isArray(args)) {
169 return input;
170 }
171 return args.reduce((newArr, currArr) => {
172 return newArr.concat(currArr.reduce((noDupArr, curr) => {
173 // tslint:disable-next-line:no-bitwise
174 return !~noDupArr.indexOf(curr) && !~newArr.indexOf(curr) ? noDupArr.concat([curr]) : noDupArr;
175 }, []));
176 }, input);
177 }
178};
179UnionPipe = __decorate([
180 Pipe({ name: 'union' })
181], UnionPipe);
182
183let UniquePipe = class UniquePipe {
184 transform(input, propertyName) {
185 const uniques = [];
186 return Array.isArray(input)
187 ? isUndefined(propertyName)
188 ? input.filter((e, i) => input.indexOf(e) === i)
189 : input.filter((e, i) => {
190 let value = extractDeepPropertyByMapKey(e, propertyName);
191 value = isObject(value) ? JSON.stringify(value) : value;
192 if (isUndefined(value) || uniques[value]) {
193 return false;
194 }
195 uniques[value] = true;
196 return true;
197 })
198 : input;
199 }
200};
201UniquePipe = __decorate([
202 Pipe({ name: 'unique' })
203], UniquePipe);
204
205let WithoutPipe = class WithoutPipe {
206 transform(input, args = []) {
207 return Array.isArray(input)
208 ? // tslint:disable-next-line:no-bitwise
209 input.filter(e => !~args.indexOf(e))
210 : input;
211 }
212};
213WithoutPipe = __decorate([
214 Pipe({ name: 'without' })
215], WithoutPipe);
216
217let PluckPipe = class PluckPipe {
218 transform(input, map) {
219 if (Array.isArray(input)) {
220 return input.map(e => extractDeepPropertyByMapKey(e, map));
221 }
222 return isObject(input) ? extractDeepPropertyByMapKey(input, map) : input;
223 }
224};
225PluckPipe = __decorate([
226 Pipe({ name: 'pluck', pure: false })
227], PluckPipe);
228
229let ShufflePipe = class ShufflePipe {
230 // Using a version of the Fisher-Yates shuffle algorithm
231 // https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
232 transform(input) {
233 if (!Array.isArray(input)) {
234 return input;
235 }
236 const shuffled = [...input];
237 const n = input.length - 1;
238 for (let i = 0; i < n; ++i) {
239 const j = Math.floor(Math.random() * (n - i + 1)) + i;
240 [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
241 }
242 return shuffled;
243 }
244};
245ShufflePipe = __decorate([
246 Pipe({ name: 'shuffle' })
247], ShufflePipe);
248
249let EveryPipe = class EveryPipe {
250 transform(input, predicate) {
251 return Array.isArray(input) ? input.every(predicate) : false;
252 }
253};
254EveryPipe = __decorate([
255 Pipe({ name: 'every' })
256], EveryPipe);
257
258let SomePipe = class SomePipe {
259 transform(input, predicate) {
260 return Array.isArray(input) ? input.some(predicate) : input;
261 }
262};
263SomePipe = __decorate([
264 Pipe({ name: 'some' })
265], SomePipe);
266
267let SamplePipe = class SamplePipe {
268 transform(input, len = 1) {
269 if (!Array.isArray(input)) {
270 return input;
271 }
272 let sample = [];
273 const tmp = [...input];
274 const l = len < tmp.length ? len : tmp.length;
275 for (let i = 0; i < l; ++i) {
276 sample = sample.concat(tmp.splice(Math.floor(Math.random() * tmp.length), 1));
277 }
278 return sample;
279 }
280};
281SamplePipe = __decorate([
282 Pipe({ name: 'sample' })
283], SamplePipe);
284
285let GroupByPipe = class GroupByPipe {
286 transform(input, discriminator = [], delimiter = '|') {
287 if (!Array.isArray(input)) {
288 return input;
289 }
290 return this.groupBy(input, discriminator, delimiter);
291 }
292 groupBy(list, discriminator, delimiter) {
293 return list.reduce((acc, payload) => {
294 const key = this.extractKeyByDiscriminator(discriminator, payload, delimiter);
295 acc[key] = Array.isArray(acc[key]) ? acc[key].concat([payload]) : [payload];
296 return acc;
297 }, {});
298 }
299 extractKeyByDiscriminator(discriminator, payload, delimiter) {
300 if (isFunction(discriminator)) {
301 return discriminator(payload);
302 }
303 if (Array.isArray(discriminator)) {
304 return discriminator.map(k => extractDeepPropertyByMapKey(payload, k)).join(delimiter);
305 }
306 return extractDeepPropertyByMapKey(payload, discriminator);
307 }
308};
309GroupByPipe = __decorate([
310 Pipe({ name: 'groupBy' })
311], GroupByPipe);
312
313// tslint:disable no-bitwise
314let FilterByPipe = class FilterByPipe {
315 transform(input, props, search = '', strict = false) {
316 if (!Array.isArray(input) ||
317 (!Array.isArray(search) && !isString(search) && !isNumberFinite(search) && !isBoolean(search))) {
318 return input;
319 }
320 const terms = String(search)
321 .toLowerCase()
322 .split(',');
323 return input.filter(obj => {
324 return props.some(prop => {
325 return terms.some(term => {
326 const value = extractDeepPropertyByMapKey(obj, prop);
327 /* tslint:disable */
328 const { props, tail } = extractDeepPropertyByParentMapKey(obj, prop);
329 if (isUndefined(value) && !isUndefined(props) && Array.isArray(props)) {
330 return props.some(parent => {
331 const str = String(parent[tail]).toLowerCase();
332 return strict ? str === term : !!~str.indexOf(term);
333 });
334 }
335 if (isUndefined(value)) {
336 return false;
337 }
338 const strValue = String(value).toLowerCase();
339 return strict ? term === strValue : !!~strValue.indexOf(term);
340 });
341 });
342 });
343 }
344};
345FilterByPipe = __decorate([
346 Pipe({ name: 'filterBy' })
347], FilterByPipe);
348
349var OrderByPipe_1;
350let OrderByPipe = OrderByPipe_1 = class OrderByPipe {
351 transform(input, config) {
352 if (!Array.isArray(input)) {
353 return input;
354 }
355 const out = [...input];
356 // sort by multiple properties
357 if (Array.isArray(config)) {
358 return out.sort((a, b) => {
359 const l = config.length;
360 for (let i = 0; i < l; ++i) {
361 const [prop, asc] = OrderByPipe_1.extractFromConfig(config[i]);
362 const pos = OrderByPipe_1.orderCompare(prop, asc, a, b);
363 if (pos !== 0) {
364 return pos;
365 }
366 }
367 return 0;
368 });
369 }
370 // sort by a single property value
371 if (isString(config)) {
372 const [prop, asc, sign] = OrderByPipe_1.extractFromConfig(config);
373 if (config.length === 1) {
374 // tslint:disable-next-line:switch-default
375 switch (sign) {
376 case '+':
377 return out.sort(OrderByPipe_1.simpleSort.bind(this));
378 case '-':
379 return out.sort(OrderByPipe_1.simpleSort.bind(this)).reverse();
380 }
381 }
382 return out.sort(OrderByPipe_1.orderCompare.bind(this, prop, asc));
383 }
384 // default sort by value
385 return out.sort(OrderByPipe_1.simpleSort.bind(this));
386 }
387 static simpleSort(a, b) {
388 return isString(a) && isString(b) ? a.toLowerCase().localeCompare(b.toLowerCase()) : a - b;
389 }
390 static orderCompare(prop, asc, a, b) {
391 const first = extractDeepPropertyByMapKey(a, prop);
392 const second = extractDeepPropertyByMapKey(b, prop);
393 if (first === second) {
394 return 0;
395 }
396 if (isUndefined(first) || first === '') {
397 return 1;
398 }
399 if (isUndefined(second) || second === '') {
400 return -1;
401 }
402 if (isString(first) && isString(second)) {
403 const pos = first.toLowerCase().localeCompare(second.toLowerCase());
404 return asc ? pos : -pos;
405 }
406 return asc ? first - second : second - first;
407 }
408 static extractFromConfig(config) {
409 const sign = config.substr(0, 1);
410 const prop = config.replace(/^[-+]/, '');
411 const asc = sign !== '-';
412 return [prop, asc, sign];
413 }
414};
415OrderByPipe = OrderByPipe_1 = __decorate([
416 Pipe({ name: 'orderBy' })
417], OrderByPipe);
418
419// tslint:disable use-pipe-transform-interface
420let GroupByImpurePipe = class GroupByImpurePipe extends GroupByPipe {
421};
422GroupByImpurePipe = __decorate([
423 Pipe({ name: 'groupByImpure', pure: false })
424], GroupByImpurePipe);
425
426// tslint:disable use-pipe-transform-interface
427let FilterByImpurePipe = class FilterByImpurePipe extends FilterByPipe {
428};
429FilterByImpurePipe = __decorate([
430 Pipe({ name: 'filterByImpure', pure: false })
431], FilterByImpurePipe);
432
433// tslint:disable use-pipe-transform-interface
434let OrderByImpurePipe = class OrderByImpurePipe extends OrderByPipe {
435};
436OrderByImpurePipe = __decorate([
437 Pipe({ name: 'orderByImpure', pure: false })
438], OrderByImpurePipe);
439
440let RangePipe = class RangePipe {
441 transform(start = 1, count = 0, step = 1) {
442 return Array(count)
443 .fill('')
444 .map((v, i) => step * i + start);
445 }
446};
447RangePipe = __decorate([
448 Pipe({ name: 'range' })
449], RangePipe);
450
451let ChunkPipe = class ChunkPipe {
452 transform(input, size = 1) {
453 if (isString(input)) {
454 return this.chunk(input
455 .split(''), size);
456 }
457 return Array.isArray(input) ? this.chunk(input, size) : input;
458 }
459 chunk(input, size) {
460 return Array(Math.ceil(input.length / size))
461 .fill([])
462 .map((_, index) => index * size)
463 .map(begin => input.slice(begin, begin + size));
464 }
465};
466ChunkPipe = __decorate([
467 Pipe({ name: 'chunk' })
468], ChunkPipe);
469
470let FromPairsPipe = class FromPairsPipe {
471 transform(input) {
472 if (!Array.isArray(input)) {
473 return input;
474 }
475 return input.reduce((obj, arr) => {
476 if (!Array.isArray(arr)) {
477 return obj;
478 }
479 const [prop, val] = arr;
480 obj[prop] = val;
481 return obj;
482 }, {});
483 }
484};
485FromPairsPipe = __decorate([
486 Pipe({ name: 'fromPairs' })
487], FromPairsPipe);
488
489const ARRAY_PIPES = [
490 DiffPipe,
491 FlattenPipe,
492 InitialPipe,
493 IntersectionPipe,
494 ReversePipe,
495 TailPipe,
496 TrurthifyPipe,
497 UnionPipe,
498 UniquePipe,
499 WithoutPipe,
500 PluckPipe,
501 ShufflePipe,
502 EveryPipe,
503 SomePipe,
504 SamplePipe,
505 GroupByPipe,
506 GroupByImpurePipe,
507 FilterByPipe,
508 FilterByImpurePipe,
509 OrderByPipe,
510 OrderByImpurePipe,
511 RangePipe,
512 ChunkPipe,
513 FromPairsPipe
514];
515let NgArrayPipesModule = class NgArrayPipesModule {
516};
517NgArrayPipesModule = __decorate([
518 NgModule({
519 declarations: ARRAY_PIPES,
520 imports: [],
521 exports: ARRAY_PIPES,
522 })
523], NgArrayPipesModule);
524
525let KeysPipe = class KeysPipe {
526 transform(obj) {
527 if (Array.isArray(obj) || !isObject(obj)) {
528 return obj;
529 }
530 return Object.keys(obj);
531 }
532};
533KeysPipe = __decorate([
534 Pipe({ name: 'keys' })
535], KeysPipe);
536
537let ValuesPipe = class ValuesPipe {
538 transform(obj) {
539 if (Array.isArray(obj) || !isObject(obj)) {
540 return obj;
541 }
542 return Object.keys(obj).map(k => obj[k]);
543 }
544};
545ValuesPipe = __decorate([
546 Pipe({ name: 'values' })
547], ValuesPipe);
548
549let PairsPipe = class PairsPipe {
550 transform(obj) {
551 if (Array.isArray(obj) || !isObject(obj)) {
552 return obj;
553 }
554 return Object.entries(obj);
555 }
556};
557PairsPipe = __decorate([
558 Pipe({ name: 'pairs' })
559], PairsPipe);
560
561let PickPipe = class PickPipe {
562 transform(obj, ...args) {
563 if (Array.isArray(obj) || !isObject(obj)) {
564 return obj;
565 }
566 return args.reduce((o, k) => {
567 return Object.assign(o, { [k]: obj[k] });
568 }, {});
569 }
570};
571PickPipe = __decorate([
572 Pipe({ name: 'pick' })
573], PickPipe);
574
575let OmitPipe = class OmitPipe {
576 transform(obj, ...args) {
577 if (Array.isArray(obj) || !isObject(obj)) {
578 return obj;
579 }
580 return (Object.keys(obj)
581 // tslint:disable-next-line:no-bitwise
582 .filter(k => !~args.indexOf(k))
583 .reduce((o, k) => {
584 return Object.assign(o, { [k]: obj[k] });
585 }, {}));
586 }
587};
588OmitPipe = __decorate([
589 Pipe({ name: 'omit' })
590], OmitPipe);
591
592let InvertPipe = class InvertPipe {
593 transform(obj) {
594 if (Array.isArray(obj) || !isObject(obj)) {
595 return obj;
596 }
597 return Object.keys(obj).reduce((o, k) => {
598 return Object.assign(o, { [obj[k]]: k });
599 }, {});
600 }
601};
602InvertPipe = __decorate([
603 Pipe({ name: 'invert' })
604], InvertPipe);
605
606let InvertByPipe = class InvertByPipe {
607 transform(obj, cb) {
608 if (Array.isArray(obj) || !isObject(obj)) {
609 return obj;
610 }
611 return Object.keys(obj).reduce((o, k) => {
612 const key = cb ? cb(obj[k]) : obj[k];
613 return Array.isArray(o[key]) ? (o[key].push(k), o) : Object.assign(o, { [key]: [k] });
614 }, {});
615 }
616};
617InvertByPipe = __decorate([
618 Pipe({ name: 'invertBy' })
619], InvertByPipe);
620
621let DiffObjPipe = class DiffObjPipe {
622 transform(obj, original = {}) {
623 if (Array.isArray(obj) || Array.isArray(original) || !isObject(obj) || !isObject(original)) {
624 return {};
625 }
626 return getKeysTwoObjects(obj, original).reduce((diff, key) => {
627 if (!isDeepEqual(original[key], obj[key])) {
628 diff[key] = obj[key];
629 }
630 return diff;
631 }, {});
632 }
633};
634DiffObjPipe = __decorate([
635 Pipe({ name: 'diffObj' })
636], DiffObjPipe);
637
638const OBJECT_PIPES = [KeysPipe, ValuesPipe, PairsPipe, PickPipe, InvertPipe, InvertByPipe, OmitPipe, DiffObjPipe];
639let NgObjectPipesModule = class NgObjectPipesModule {
640};
641NgObjectPipesModule = __decorate([
642 NgModule({
643 declarations: OBJECT_PIPES,
644 imports: [],
645 exports: OBJECT_PIPES,
646 })
647], NgObjectPipesModule);
648
649let AorAnPipe =
650/**
651 * Takes a string and returns the string prepended by 'a' or 'an'.
652 * Uses both naive and holdout-list approaches.
653 * @constructor
654 * @param {string} stringEntity - Entity to prepend 'a' or 'an' to.
655 */
656class AorAnPipe {
657 constructor() {
658 this.irregularMap = {
659 herb: 'an',
660 honor: 'an',
661 honorable: 'an',
662 hour: 'an',
663 mba: 'an',
664 msc: 'an',
665 'm.sc.': 'an',
666 unicorn: 'a',
667 };
668 }
669 transform(stringEntity) {
670 if (!stringEntity || stringEntity === '') {
671 return '';
672 }
673 else {
674 const firstWord = stringEntity.trim().split(' ')[0];
675 if (this.irregularMap[firstWord.toLocaleLowerCase()]) {
676 return `${this.irregularMap[firstWord.toLocaleLowerCase()]} ${stringEntity}`;
677 }
678 else {
679 return isVowel(stringEntity[0]) ? `an ${stringEntity}` : `a ${stringEntity}`;
680 }
681 }
682 }
683};
684AorAnPipe = __decorate([
685 Pipe({
686 name: 'aOrAn',
687 })
688 /**
689 * Takes a string and returns the string prepended by 'a' or 'an'.
690 * Uses both naive and holdout-list approaches.
691 * @constructor
692 * @param {string} stringEntity - Entity to prepend 'a' or 'an' to.
693 */
694], AorAnPipe);
695
696let UcWordsPipe = class UcWordsPipe {
697 transform(text) {
698 if (isString(text)) {
699 return text
700 .split(' ')
701 .map((sub) => ucFirst(sub))
702 .join(' ');
703 }
704 return text;
705 }
706};
707UcWordsPipe = __decorate([
708 Pipe({ name: 'ucwords' })
709], UcWordsPipe);
710
711let LeftTrimPipe = class LeftTrimPipe {
712 transform(text, chars = '\\s') {
713 return isString(text) ? text.replace(new RegExp(`^[${chars}]+`), '') : text;
714 }
715};
716LeftTrimPipe = __decorate([
717 Pipe({ name: 'ltrim' })
718], LeftTrimPipe);
719
720let RepeatPipe = class RepeatPipe {
721 transform(str, n = 1, separator = '') {
722 if (n <= 0) {
723 throw new RangeError();
724 }
725 return n === 1 ? str : this.repeat(str, n - 1, separator);
726 }
727 repeat(str, n, separator) {
728 return isString(str) ? (n === 0 ? str : str + separator + this.repeat(str, n - 1, separator)) : str;
729 }
730};
731RepeatPipe = __decorate([
732 Pipe({ name: 'repeat' })
733], RepeatPipe);
734
735let RightTrimPipe = class RightTrimPipe {
736 transform(text, chars = '\\s') {
737 return isString(text) ? text.replace(new RegExp(`[${chars}]+$`), '') : text;
738 }
739};
740RightTrimPipe = __decorate([
741 Pipe({ name: 'rtrim' })
742], RightTrimPipe);
743
744let ScanPipe = class ScanPipe {
745 transform(text, args = []) {
746 return isString(text)
747 ? text.replace(/\{(\d+)}/g, (match, index) => (!isUndefined(args[index]) ? args[index] : match))
748 : text;
749 }
750};
751ScanPipe = __decorate([
752 Pipe({ name: 'scan' })
753], ScanPipe);
754
755let ShortenPipe = class ShortenPipe {
756 transform(text, length = 0, suffix = '', wordBreak = true) {
757 if (!isString(text)) {
758 return text;
759 }
760 if (text.length > length) {
761 if (wordBreak) {
762 return text.slice(0, length) + suffix;
763 }
764 // tslint:disable-next-line:no-bitwise
765 if (!!~text.indexOf(' ', length)) {
766 return text.slice(0, text.indexOf(' ', length)) + suffix;
767 }
768 }
769 return text;
770 }
771};
772ShortenPipe = __decorate([
773 Pipe({ name: 'shorten' })
774], ShortenPipe);
775
776let StripTagsPipe = class StripTagsPipe {
777 transform(text, ...allowedTags) {
778 return allowedTags.length > 0
779 ? text.replace(new RegExp(`<(?!\/?(${allowedTags.join('|')})\s*\/?)[^>]+>`, 'g'), '')
780 : text.replace(/<(?:.|\s)*?>/g, '');
781 }
782};
783StripTagsPipe = __decorate([
784 Pipe({ name: 'stripTags' })
785], StripTagsPipe);
786
787let TrimPipe = class TrimPipe {
788 transform(text, chars = '\\s') {
789 return isString(text) ? text.replace(new RegExp(`^[${chars}]+|[${chars}]+$`, 'g'), '') : text;
790 }
791};
792TrimPipe = __decorate([
793 Pipe({ name: 'trim' })
794], TrimPipe);
795
796let UcFirstPipe = class UcFirstPipe {
797 transform(text) {
798 return isString(text) ? ucFirst(text) : text;
799 }
800};
801UcFirstPipe = __decorate([
802 Pipe({ name: 'ucfirst' })
803], UcFirstPipe);
804
805let SlugifyPipe = class SlugifyPipe {
806 transform(str) {
807 return isString(str)
808 ? str
809 .toLowerCase()
810 .trim()
811 .replace(/[^\w\-]+/g, ' ')
812 .replace(/\s+/g, '-')
813 : str;
814 }
815};
816SlugifyPipe = __decorate([
817 Pipe({ name: 'slugify' })
818], SlugifyPipe);
819
820let CamelizePipe = class CamelizePipe {
821 transform(text, chars = '\\s') {
822 if (!isString(text)) {
823 return text;
824 }
825 return text
826 .toLowerCase()
827 .split(/[-_\s]/g)
828 .filter((v) => !!v)
829 .map((word, key) => {
830 return !key ? word : word.slice(0, 1).toUpperCase() + word.slice(1);
831 })
832 .join('');
833 }
834};
835CamelizePipe = __decorate([
836 Pipe({ name: 'camelize' })
837], CamelizePipe);
838
839let LatinisePipe = class LatinisePipe {
840 constructor() {
841 // Source: http://semplicewebsites.com/removing-accents-javascript
842 // tslint:disable-next-line whitespace max-line-length object-literal-key-quotes
843 this.latinMap = {
844 Á: 'A',
845 Ă: 'A',
846 Ắ: 'A',
847 Ặ: 'A',
848 Ằ: 'A',
849 Ẳ: 'A',
850 Ẵ: 'A',
851 Ǎ: 'A',
852 Â: 'A',
853 Ấ: 'A',
854 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 à: 'a',
1242 ả: 'a',
1243 ȃ: 'a',
1244 ā: 'a',
1245 ą: 'a',
1246 ᶏ: 'a',
1247 ẚ: 'a',
1248 å: 'a',
1249 ǻ: 'a',
1250 ḁ: 'a',
1251 ⱥ: 'a',
1252 ã: 'a',
1253 ꜳ: 'aa',
1254 æ: 'ae',
1255 ǽ: 'ae',
1256 ǣ: 'ae',
1257 ꜵ: 'ao',
1258 ꜷ: 'au',
1259 ꜹ: 'av',
1260 ꜻ: 'av',
1261 ꜽ: 'ay',
1262 ḃ: 'b',
1263 ḅ: 'b',
1264 ɓ: 'b',
1265 ḇ: 'b',
1266 ᵬ: 'b',
1267 ᶀ: 'b',
1268 ƀ: 'b',
1269 ƃ: 'b',
1270 ɵ: 'o',
1271 ć: 'c',
1272 č: 'c',
1273 ç: 'c',
1274 ḉ: 'c',
1275 ĉ: 'c',
1276 ɕ: 'c',
1277 ċ: 'c',
1278 ƈ: 'c',
1279 ȼ: 'c',
1280 ď: 'd',
1281 ḑ: 'd',
1282 ḓ: 'd',
1283 ȡ: 'd',
1284 ḋ: 'd',
1285 ḍ: 'd',
1286 ɗ: 'd',
1287 ᶑ: 'd',
1288 ḏ: 'd',
1289 ᵭ: 'd',
1290 ᶁ: 'd',
1291 đ: 'd',
1292 ɖ: 'd',
1293 ƌ: 'd',
1294 ı: 'i',
1295 ȷ: 'j',
1296 ɟ: 'j',
1297 ʄ: 'j',
1298 dz: 'dz',
1299 dž: 'dz',
1300 é: 'e',
1301 ĕ: 'e',
1302 ě: 'e',
1303 ȩ: 'e',
1304 ḝ: 'e',
1305 ê: 'e',
1306 ế: 'e',
1307 ệ: 'e',
1308 ề: 'e',
1309 ể: 'e',
1310 ễ: 'e',
1311 ḙ: 'e',
1312 ë: 'e',
1313 ė: 'e',
1314 ẹ: 'e',
1315 ȅ: 'e',
1316 è: 'e',
1317 ẻ: 'e',
1318 ȇ: 'e',
1319 ē: 'e',
1320 ḗ: 'e',
1321 ḕ: 'e',
1322 ⱸ: 'e',
1323 ę: 'e',
1324 ᶒ: 'e',
1325 ɇ: 'e',
1326 ẽ: 'e',
1327 ḛ: 'e',
1328 ꝫ: 'et',
1329 ḟ: 'f',
1330 ƒ: 'f',
1331 ᵮ: 'f',
1332 ᶂ: 'f',
1333 ǵ: 'g',
1334 ğ: 'g',
1335 ǧ: 'g',
1336 ģ: 'g',
1337 ĝ: 'g',
1338 ġ: 'g',
1339 ɠ: 'g',
1340 ḡ: 'g',
1341 ᶃ: 'g',
1342 ǥ: 'g',
1343 ḫ: 'h',
1344 ȟ: 'h',
1345 ḩ: 'h',
1346 ĥ: 'h',
1347 ⱨ: 'h',
1348 ḧ: 'h',
1349 ḣ: 'h',
1350 ḥ: 'h',
1351 ɦ: 'h',
1352 ẖ: 'h',
1353 ħ: 'h',
1354 ƕ: 'hv',
1355 í: 'i',
1356 ĭ: 'i',
1357 ǐ: 'i',
1358 î: 'i',
1359 ï: 'i',
1360 ḯ: 'i',
1361 ị: 'i',
1362 ȉ: 'i',
1363 ì: 'i',
1364 ỉ: 'i',
1365 ȋ: 'i',
1366 ī: 'i',
1367 į: 'i',
1368 ᶖ: 'i',
1369 ɨ: 'i',
1370 ĩ: 'i',
1371 ḭ: 'i',
1372 ꝺ: 'd',
1373 ꝼ: 'f',
1374 ᵹ: 'g',
1375 ꞃ: 'r',
1376 ꞅ: 's',
1377 ꞇ: 't',
1378 ꝭ: 'is',
1379 ǰ: 'j',
1380 ĵ: 'j',
1381 ʝ: 'j',
1382 ɉ: 'j',
1383 ḱ: 'k',
1384 ǩ: 'k',
1385 ķ: 'k',
1386 ⱪ: 'k',
1387 ꝃ: 'k',
1388 ḳ: 'k',
1389 ƙ: 'k',
1390 ḵ: 'k',
1391 ᶄ: 'k',
1392 ꝁ: 'k',
1393 ꝅ: 'k',
1394 ĺ: 'l',
1395 ƚ: 'l',
1396 ɬ: 'l',
1397 ľ: 'l',
1398 ļ: 'l',
1399 ḽ: 'l',
1400 ȴ: 'l',
1401 ḷ: 'l',
1402 ḹ: 'l',
1403 ⱡ: 'l',
1404 ꝉ: 'l',
1405 ḻ: 'l',
1406 ŀ: 'l',
1407 ɫ: 'l',
1408 ᶅ: 'l',
1409 ɭ: 'l',
1410 ł: 'l',
1411 lj: 'lj',
1412 ſ: 's',
1413 ẜ: 's',
1414 ẛ: 's',
1415 ẝ: 's',
1416 ḿ: 'm',
1417 ṁ: 'm',
1418 ṃ: 'm',
1419 ɱ: 'm',
1420 ᵯ: 'm',
1421 ᶆ: 'm',
1422 ń: 'n',
1423 ň: 'n',
1424 ņ: 'n',
1425 ṋ: 'n',
1426 ȵ: 'n',
1427 ṅ: 'n',
1428 ṇ: 'n',
1429 ǹ: 'n',
1430 ɲ: 'n',
1431 ṉ: 'n',
1432 ƞ: 'n',
1433 ᵰ: 'n',
1434 ᶇ: 'n',
1435 ɳ: 'n',
1436 ñ: 'n',
1437 nj: 'nj',
1438 ó: 'o',
1439 ŏ: 'o',
1440 ǒ: 'o',
1441 ô: 'o',
1442 ố: 'o',
1443 ộ: 'o',
1444 ồ: 'o',
1445 ổ: 'o',
1446 ỗ: 'o',
1447 ö: 'o',
1448 ȫ: 'o',
1449 ȯ: 'o',
1450 ȱ: 'o',
1451 ọ: 'o',
1452 ő: 'o',
1453 ȍ: 'o',
1454 ò: 'o',
1455 ỏ: 'o',
1456 ơ: 'o',
1457 ớ: 'o',
1458 ợ: 'o',
1459 ờ: 'o',
1460 ở: 'o',
1461 ỡ: 'o',
1462 ȏ: 'o',
1463 ꝋ: 'o',
1464 ꝍ: 'o',
1465 ⱺ: 'o',
1466 ō: 'o',
1467 ṓ: 'o',
1468 ṑ: 'o',
1469 ǫ: 'o',
1470 ǭ: 'o',
1471 ø: 'o',
1472 ǿ: 'o',
1473 õ: 'o',
1474 ṍ: 'o',
1475 ṏ: 'o',
1476 ȭ: 'o',
1477 ƣ: 'oi',
1478 ꝏ: 'oo',
1479 ɛ: 'e',
1480 ᶓ: 'e',
1481 ɔ: 'o',
1482 ᶗ: 'o',
1483 ȣ: 'ou',
1484 ṕ: 'p',
1485 ṗ: 'p',
1486 ꝓ: 'p',
1487 ƥ: 'p',
1488 ᵱ: 'p',
1489 ᶈ: 'p',
1490 ꝕ: 'p',
1491 ᵽ: 'p',
1492 ꝑ: 'p',
1493 ꝙ: 'q',
1494 ʠ: 'q',
1495 ɋ: 'q',
1496 ꝗ: 'q',
1497 ŕ: 'r',
1498 ř: 'r',
1499 ŗ: 'r',
1500 ṙ: 'r',
1501 ṛ: 'r',
1502 ṝ: 'r',
1503 ȑ: 'r',
1504 ɾ: 'r',
1505 ᵳ: 'r',
1506 ȓ: 'r',
1507 ṟ: 'r',
1508 ɼ: 'r',
1509 ᵲ: 'r',
1510 ᶉ: 'r',
1511 ɍ: 'r',
1512 ɽ: 'r',
1513 ↄ: 'c',
1514 ꜿ: 'c',
1515 ɘ: 'e',
1516 ɿ: 'r',
1517 ś: 's',
1518 ṥ: 's',
1519 š: 's',
1520 ṧ: 's',
1521 ş: 's',
1522 ŝ: 's',
1523 ș: 's',
1524 ṡ: 's',
1525 ṣ: 's',
1526 ṩ: 's',
1527 ʂ: 's',
1528 ᵴ: 's',
1529 ᶊ: 's',
1530 ȿ: 's',
1531 ɡ: 'g',
1532 ß: 'ss',
1533 ᴑ: 'o',
1534 ᴓ: 'o',
1535 ᴝ: 'u',
1536 ť: 't',
1537 ţ: 't',
1538 ṱ: 't',
1539 ț: 't',
1540 ȶ: 't',
1541 ẗ: 't',
1542 ⱦ: 't',
1543 ṫ: 't',
1544 ṭ: 't',
1545 ƭ: 't',
1546 ṯ: 't',
1547 ᵵ: 't',
1548 ƫ: 't',
1549 ʈ: 't',
1550 ŧ: 't',
1551 ᵺ: 'th',
1552 ɐ: 'a',
1553 ᴂ: 'ae',
1554 ǝ: 'e',
1555 ᵷ: 'g',
1556 ɥ: 'h',
1557 ʮ: 'h',
1558 ʯ: 'h',
1559 ᴉ: 'i',
1560 ʞ: 'k',
1561 ꞁ: 'l',
1562 ɯ: 'm',
1563 ɰ: 'm',
1564 ᴔ: 'oe',
1565 ɹ: 'r',
1566 ɻ: 'r',
1567 ɺ: 'r',
1568 ⱹ: 'r',
1569 ʇ: 't',
1570 ʌ: 'v',
1571 ʍ: 'w',
1572 ʎ: 'y',
1573 ꜩ: 'tz',
1574 ú: 'u',
1575 ŭ: 'u',
1576 ǔ: 'u',
1577 û: 'u',
1578 ṷ: 'u',
1579 ü: 'u',
1580 ǘ: 'u',
1581 ǚ: 'u',
1582 ǜ: 'u',
1583 ǖ: 'u',
1584 ṳ: 'u',
1585 ụ: 'u',
1586 ű: 'u',
1587 ȕ: 'u',
1588 ù: 'u',
1589 ủ: 'u',
1590 ư: 'u',
1591 ứ: 'u',
1592 ự: 'u',
1593 ừ: 'u',
1594 ử: 'u',
1595 ữ: 'u',
1596 ȗ: 'u',
1597 ū: 'u',
1598 ṻ: 'u',
1599 ų: 'u',
1600 ᶙ: 'u',
1601 ů: 'u',
1602 ũ: 'u',
1603 ṹ: 'u',
1604 ṵ: 'u',
1605 ᵫ: 'ue',
1606 ꝸ: 'um',
1607 ⱴ: 'v',
1608 ꝟ: 'v',
1609 ṿ: 'v',
1610 ʋ: 'v',
1611 ᶌ: 'v',
1612 ⱱ: 'v',
1613 ṽ: 'v',
1614 ꝡ: 'vy',
1615 ẃ: 'w',
1616 ŵ: 'w',
1617 ẅ: 'w',
1618 ẇ: 'w',
1619 ẉ: 'w',
1620 ẁ: 'w',
1621 ⱳ: 'w',
1622 ẘ: 'w',
1623 ẍ: 'x',
1624 ẋ: 'x',
1625 ᶍ: 'x',
1626 ý: 'y',
1627 ŷ: 'y',
1628 ÿ: 'y',
1629 ẏ: 'y',
1630 ỵ: 'y',
1631 ỳ: 'y',
1632 ƴ: 'y',
1633 ỷ: 'y',
1634 ỿ: 'y',
1635 ȳ: 'y',
1636 ẙ: 'y',
1637 ɏ: 'y',
1638 ỹ: 'y',
1639 ź: 'z',
1640 ž: 'z',
1641 ẑ: 'z',
1642 ʑ: 'z',
1643 ⱬ: 'z',
1644 ż: 'z',
1645 ẓ: 'z',
1646 ȥ: 'z',
1647 ẕ: 'z',
1648 ᵶ: 'z',
1649 ᶎ: 'z',
1650 ʐ: 'z',
1651 ƶ: 'z',
1652 ɀ: 'z',
1653 ff: 'ff',
1654 ffi: 'ffi',
1655 ffl: 'ffl',
1656 fi: 'fi',
1657 fl: 'fl',
1658 ij: 'ij',
1659 œ: 'oe',
1660 st: 'st',
1661 ₐ: 'a',
1662 ₑ: 'e',
1663 ᵢ: 'i',
1664 ⱼ: 'j',
1665 ₒ: 'o',
1666 ᵣ: 'r',
1667 ᵤ: 'u',
1668 ᵥ: 'v',
1669 ₓ: 'x',
1670 };
1671 }
1672 transform(text, chars = '\\s') {
1673 return isString(text)
1674 ? text.replace(/[^A-Za-z0-9]/g, (key) => {
1675 return this.latinMap[key] || key;
1676 })
1677 : text;
1678 }
1679};
1680LatinisePipe = __decorate([
1681 Pipe({ name: 'latinise' })
1682], LatinisePipe);
1683
1684let LinesPipe = class LinesPipe {
1685 transform(text, chars = '\\s') {
1686 return isString(text) ? text.replace(/\r\n/g, '\n').split('\n') : text;
1687 }
1688};
1689LinesPipe = __decorate([
1690 Pipe({ name: 'lines' })
1691], LinesPipe);
1692
1693let UnderscorePipe = class UnderscorePipe {
1694 transform(text, chars = '\\s') {
1695 return isString(text)
1696 ? text
1697 .trim()
1698 .replace(/\s+/g, '')
1699 .replace(/[A-Z]/g, (c, k) => {
1700 return k ? `_${c.toLowerCase()}` : c.toLowerCase();
1701 })
1702 : text;
1703 }
1704};
1705UnderscorePipe = __decorate([
1706 Pipe({ name: 'underscore' })
1707], UnderscorePipe);
1708
1709let MatchPipe = class MatchPipe {
1710 transform(text, pattern, flags) {
1711 if (!isString(text)) {
1712 return text;
1713 }
1714 return text.match(new RegExp(pattern, flags));
1715 }
1716};
1717MatchPipe = __decorate([
1718 Pipe({ name: 'match' })
1719], MatchPipe);
1720
1721let TestPipe = class TestPipe {
1722 transform(text, pattern, flags) {
1723 if (!isString(text)) {
1724 return text;
1725 }
1726 return new RegExp(pattern, flags).test(text);
1727 }
1728};
1729TestPipe = __decorate([
1730 Pipe({ name: 'test' })
1731], TestPipe);
1732
1733let LeftPadPipe = class LeftPadPipe {
1734 transform(str, length, padCharacter = ' ') {
1735 if (!isString(str) || str.length >= length) {
1736 return str;
1737 }
1738 while (str.length < length) {
1739 str = padCharacter + str;
1740 }
1741 return str;
1742 }
1743};
1744LeftPadPipe = __decorate([
1745 Pipe({ name: 'lpad' })
1746], LeftPadPipe);
1747
1748let RightPadPipe = class RightPadPipe {
1749 transform(str, length = 1, padCharacter = ' ') {
1750 if (!isString(str) || str.length >= length) {
1751 return str;
1752 }
1753 while (str.length < length) {
1754 str = str + padCharacter;
1755 }
1756 return str;
1757 }
1758};
1759RightPadPipe = __decorate([
1760 Pipe({ name: 'rpad' })
1761], RightPadPipe);
1762
1763let MakePluralStringPipe =
1764/**
1765 * Takes a singular entity string and pluralizes it.
1766 * Uses both naive and holdout-list approaches.
1767 * If several words appear in the string, only the last word is pluralized -- this
1768 * means that if "your story" was passed in, "your stories" would be passed out.
1769 *
1770 * @param {string} singularEntity - Entity to pluralize. Pass as a singular ('story' or 'house').
1771 * NOTE: The last word is examined. So you can pass in e.g. 'my story'.
1772 * @param {number} [quantity=0] quantity - How many of the entity are there? If left blank, this will
1773 * pluralize the string (e.g. 'story' -> 'stories', 'house' -> 'houses'). If given a value,
1774 * this will pluralize appropriately (e.g. ('story', 1) -> 'story', ('story', 2) -> 'stories').
1775 */
1776class MakePluralStringPipe {
1777 constructor() {
1778 this.irregularMap = {
1779 addendum: 'addenda',
1780 alga: 'algae',
1781 alumna: 'alumnae',
1782 alumnus: 'alumni',
1783 analysis: 'analyses',
1784 antenna: 'antennae',
1785 appendix: 'appendices',
1786 aquarium: 'aquaria',
1787 arch: 'arches',
1788 axe: 'axes',
1789 axis: 'axes',
1790 bacillus: 'bacilli',
1791 bacterium: 'bacteria',
1792 basis: 'bases',
1793 batch: 'batches',
1794 beach: 'beaches',
1795 beau: 'beaux',
1796 bison: 'bison',
1797 brush: 'brushes',
1798 buffalo: 'buffaloes',
1799 bureau: 'bureaus',
1800 bus: 'busses',
1801 cactus: 'cacti',
1802 calf: 'calves',
1803 chateau: 'chateaux',
1804 cherry: 'cherries',
1805 child: 'children',
1806 church: 'churches',
1807 circus: 'circuses',
1808 cod: 'cod',
1809 corps: 'corps',
1810 corpus: 'corpora',
1811 crisis: 'crises',
1812 criterion: 'criteria',
1813 curriculum: 'curricula',
1814 datum: 'data',
1815 deer: 'deer',
1816 diagnosis: 'diagnoses',
1817 die: 'dice',
1818 domino: 'dominoes',
1819 dwarf: 'dwarves',
1820 echo: 'echoes',
1821 elf: 'elves',
1822 ellipsis: 'ellipses',
1823 embargo: 'embargoes',
1824 emphasis: 'emphases',
1825 erratum: 'errata',
1826 fax: 'faxes',
1827 fireman: 'firemen',
1828 fish: 'fish',
1829 flush: 'flushes',
1830 focus: 'foci',
1831 foot: 'feet',
1832 formula: 'formulas',
1833 fungus: 'fungi',
1834 genus: 'genera',
1835 goose: 'geese',
1836 grafito: 'grafiti',
1837 half: 'halves',
1838 hero: 'heroes',
1839 hoax: 'hoaxes',
1840 hoof: 'hooves',
1841 hypothesis: 'hypotheses',
1842 index: 'indices',
1843 kiss: 'kisses',
1844 knife: 'knives',
1845 leaf: 'leaves',
1846 life: 'lives',
1847 loaf: 'loaves',
1848 louse: 'lice',
1849 man: 'men',
1850 mango: 'mangoes',
1851 matrix: 'matrices',
1852 means: 'means',
1853 medium: 'media',
1854 memorandum: 'memoranda',
1855 millennium: 'milennia',
1856 moose: 'moose',
1857 mosquito: 'mosquitoes',
1858 motto: 'mottoes',
1859 mouse: 'mice',
1860 nebula: 'nebulae',
1861 neurosis: 'neuroses',
1862 nucleus: 'nuclei',
1863 oasis: 'oases',
1864 octopus: 'octopodes',
1865 ovum: 'ova',
1866 ox: 'oxen',
1867 paralysis: 'paralyses',
1868 parenthesis: 'parentheses',
1869 person: 'people',
1870 phenomenon: 'phenomena',
1871 plateau: 'plateaux',
1872 potato: 'potatoes',
1873 quiz: 'quizzes',
1874 radius: 'radii',
1875 reflex: 'reflexes',
1876 'runner-up': 'runners-up',
1877 scampo: 'scampi',
1878 scarf: 'scarves',
1879 scissors: 'scissors',
1880 scratch: 'scratches',
1881 self: 'selves',
1882 series: 'series',
1883 sheaf: 'sheaves',
1884 sheep: 'sheep',
1885 shelf: 'shelves',
1886 'son-in-law': 'sons-in-law',
1887 species: 'species',
1888 splash: 'splashes',
1889 stimulus: 'stimuli',
1890 stitch: 'stitches',
1891 stratum: 'strata',
1892 syllabus: 'syllabi',
1893 symposium: 'symposia',
1894 synopsis: 'synopses',
1895 synthesis: 'syntheses',
1896 tableau: 'tableaux',
1897 tax: 'taxes',
1898 that: 'those',
1899 thesis: 'theses',
1900 thief: 'thieves',
1901 this: 'these',
1902 tomato: 'tomatoes',
1903 tooth: 'teeth',
1904 tornado: 'tornadoes',
1905 torpedo: 'torpedoes',
1906 vertebra: 'vertebrae',
1907 veto: 'vetoes',
1908 vita: 'vitae',
1909 volcano: 'volcanoes',
1910 waltz: 'waltzes',
1911 wash: 'washes',
1912 watch: 'watches',
1913 wharf: 'wharves',
1914 wife: 'wives',
1915 wolf: 'wolves',
1916 woman: 'women',
1917 zero: 'zeroes',
1918 };
1919 }
1920 transform(singularEntity, quantity = 0) {
1921 if (!singularEntity || singularEntity === '') {
1922 return '';
1923 }
1924 if (quantity === 1) {
1925 return singularEntity;
1926 }
1927 else {
1928 const lastWord = singularEntity.trim().split(' ')[singularEntity.trim().split(' ').length - 1];
1929 if (this.irregularMap[lastWord.toLocaleLowerCase()]) {
1930 if (lastWord[0] === lastWord[0].toLocaleUpperCase()) {
1931 return singularEntity.replace(lastWord, this.irregularMap[lastWord.toLocaleLowerCase()].replace(this.irregularMap[lastWord.toLocaleLowerCase()][0], this.irregularMap[lastWord.toLocaleLowerCase()][0].toLocaleUpperCase()));
1932 }
1933 return singularEntity.replace(lastWord, this.irregularMap[lastWord.toLocaleLowerCase()]);
1934 }
1935 else if (lastWord[lastWord.length - 1] === 'y') {
1936 // Naive approach:
1937 // consonant+y = word - 'y' +'ies'
1938 // vowel+y = word + 's'
1939 return isVowel(lastWord[lastWord.length - 2])
1940 ? singularEntity + 's'
1941 : singularEntity.replace(lastWord, lastWord.slice(0, -1) + 'ies');
1942 }
1943 else if (lastWord[lastWord.length - 1] === 's') {
1944 return singularEntity + 'es';
1945 }
1946 else {
1947 return singularEntity + 's';
1948 }
1949 }
1950 }
1951};
1952MakePluralStringPipe = __decorate([
1953 Pipe({
1954 name: 'makePluralString',
1955 })
1956 /**
1957 * Takes a singular entity string and pluralizes it.
1958 * Uses both naive and holdout-list approaches.
1959 * If several words appear in the string, only the last word is pluralized -- this
1960 * means that if "your story" was passed in, "your stories" would be passed out.
1961 *
1962 * @param {string} singularEntity - Entity to pluralize. Pass as a singular ('story' or 'house').
1963 * NOTE: The last word is examined. So you can pass in e.g. 'my story'.
1964 * @param {number} [quantity=0] quantity - How many of the entity are there? If left blank, this will
1965 * pluralize the string (e.g. 'story' -> 'stories', 'house' -> 'houses'). If given a value,
1966 * this will pluralize appropriately (e.g. ('story', 1) -> 'story', ('story', 2) -> 'stories').
1967 */
1968], MakePluralStringPipe);
1969
1970let WrapPipe = class WrapPipe {
1971 transform(str, prefix = '', suffix = '') {
1972 if (!isString(str)) {
1973 return str;
1974 }
1975 return (!!prefix && isString(prefix) ? prefix : '') + str + (!!suffix && isString(suffix) ? suffix : '');
1976 }
1977};
1978WrapPipe = __decorate([
1979 Pipe({ name: 'wrap' })
1980], WrapPipe);
1981
1982const STRING_PIPES = [
1983 AorAnPipe,
1984 LeftTrimPipe,
1985 RepeatPipe,
1986 RightTrimPipe,
1987 ScanPipe,
1988 ShortenPipe,
1989 StripTagsPipe,
1990 TrimPipe,
1991 UcFirstPipe,
1992 UcWordsPipe,
1993 SlugifyPipe,
1994 CamelizePipe,
1995 LatinisePipe,
1996 LinesPipe,
1997 UnderscorePipe,
1998 MatchPipe,
1999 TestPipe,
2000 LeftPadPipe,
2001 RightPadPipe,
2002 MakePluralStringPipe,
2003 WrapPipe,
2004];
2005let NgStringPipesModule = class NgStringPipesModule {
2006};
2007NgStringPipesModule = __decorate([
2008 NgModule({
2009 declarations: STRING_PIPES,
2010 imports: [],
2011 exports: STRING_PIPES,
2012 })
2013], NgStringPipesModule);
2014
2015let MaxPipe = class MaxPipe {
2016 transform(arr) {
2017 return Array.isArray(arr) ? Math.max(...arr) : arr;
2018 }
2019};
2020MaxPipe = __decorate([
2021 Pipe({ name: 'max' })
2022], MaxPipe);
2023
2024let MinPipe = class MinPipe {
2025 transform(arr) {
2026 return Array.isArray(arr) ? Math.min(...arr) : arr;
2027 }
2028};
2029MinPipe = __decorate([
2030 Pipe({ name: 'min' })
2031], MinPipe);
2032
2033let PercentagePipe = class PercentagePipe {
2034 transform(num, total = 100, floor = false) {
2035 if (isNaN(num)) {
2036 return num;
2037 }
2038 const percent = (num * 100) / total;
2039 return floor ? Math.floor(percent) : percent;
2040 }
2041};
2042PercentagePipe = __decorate([
2043 Pipe({ name: 'percentage' })
2044], PercentagePipe);
2045
2046let SumPipe = class SumPipe {
2047 transform(arr) {
2048 return Array.isArray(arr) ? arr.reduce((sum, curr) => sum + curr, 0) : arr;
2049 }
2050};
2051SumPipe = __decorate([
2052 Pipe({ name: 'sum' })
2053], SumPipe);
2054
2055let FloorPipe = class FloorPipe {
2056 transform(num, precision = 0) {
2057 if (precision <= 0) {
2058 return Math.floor(num);
2059 }
2060 const tho = Math.pow(10, precision);
2061 return Math.floor(num * tho) / tho;
2062 }
2063};
2064FloorPipe = __decorate([
2065 Pipe({ name: 'floor' })
2066], FloorPipe);
2067
2068let RoundPipe = class RoundPipe {
2069 transform(num, precision = 0) {
2070 return applyPrecision(num, precision);
2071 }
2072};
2073RoundPipe = __decorate([
2074 Pipe({ name: 'round' })
2075], RoundPipe);
2076
2077let SqrtPipe = class SqrtPipe {
2078 transform(num) {
2079 return !isNaN(num) ? Math.sqrt(num) : num;
2080 }
2081};
2082SqrtPipe = __decorate([
2083 Pipe({ name: 'sqrt' })
2084], SqrtPipe);
2085
2086let PowerPipe = class PowerPipe {
2087 transform(num, power = 2) {
2088 return !isNaN(num) ? Math.pow(num, power) : num;
2089 }
2090};
2091PowerPipe = __decorate([
2092 Pipe({ name: 'pow' })
2093], PowerPipe);
2094
2095let CeilPipe = class CeilPipe {
2096 transform(num, precision = 0) {
2097 if (precision <= 0) {
2098 return Math.ceil(num);
2099 }
2100 const tho = Math.pow(10, precision);
2101 return Math.ceil(num * tho) / tho;
2102 }
2103};
2104CeilPipe = __decorate([
2105 Pipe({ name: 'ceil' })
2106], CeilPipe);
2107
2108let DegreesPipe = class DegreesPipe {
2109 transform(radians) {
2110 if (!isNumberFinite(radians)) {
2111 return NaN;
2112 }
2113 return (radians * 180) / Math.PI;
2114 }
2115};
2116DegreesPipe = __decorate([
2117 Pipe({ name: 'degrees' })
2118], DegreesPipe);
2119
2120let BytesPipe = class BytesPipe {
2121 constructor() {
2122 this.dictionary = [
2123 { max: 1024, type: 'B' },
2124 { max: 1048576, type: 'KB' },
2125 { max: 1073741824, type: 'MB' },
2126 { max: 1.0995116e12, type: 'GB' },
2127 ];
2128 }
2129 transform(value, precision) {
2130 if (!isNumberFinite(value)) {
2131 return NaN;
2132 }
2133 const format = this.dictionary.find(d => value < d.max) || this.dictionary[this.dictionary.length - 1];
2134 const calc = value / (format.max / 1024);
2135 const num = isUndefined(precision) ? calc : applyPrecision(calc, precision);
2136 return `${num} ${format.type}`;
2137 }
2138};
2139BytesPipe = __decorate([
2140 Pipe({ name: 'bytes' })
2141], BytesPipe);
2142
2143let RadiansPipe = class RadiansPipe {
2144 transform(degrees) {
2145 if (!isNumberFinite(degrees)) {
2146 return NaN;
2147 }
2148 return (degrees * Math.PI) / 180;
2149 }
2150};
2151RadiansPipe = __decorate([
2152 Pipe({ name: 'radians' })
2153], RadiansPipe);
2154
2155const MATH_PIPES = [
2156 MaxPipe,
2157 MinPipe,
2158 PercentagePipe,
2159 SumPipe,
2160 FloorPipe,
2161 RoundPipe,
2162 SqrtPipe,
2163 PowerPipe,
2164 CeilPipe,
2165 DegreesPipe,
2166 BytesPipe,
2167 RadiansPipe,
2168];
2169let NgMathPipesModule = class NgMathPipesModule {
2170};
2171NgMathPipesModule = __decorate([
2172 NgModule({
2173 declarations: MATH_PIPES,
2174 imports: [],
2175 exports: MATH_PIPES,
2176 })
2177], NgMathPipesModule);
2178
2179let IsDefinedPipe = class IsDefinedPipe {
2180 transform(input) {
2181 return !isUndefined(input);
2182 }
2183};
2184IsDefinedPipe = __decorate([
2185 Pipe({ name: 'isDefined' })
2186], IsDefinedPipe);
2187
2188let IsNullPipe = class IsNullPipe {
2189 transform(input) {
2190 return input === null;
2191 }
2192};
2193IsNullPipe = __decorate([
2194 Pipe({ name: 'isNull' })
2195], IsNullPipe);
2196
2197let IsUndefinedPipe = class IsUndefinedPipe {
2198 transform(input) {
2199 return isUndefined(input);
2200 }
2201};
2202IsUndefinedPipe = __decorate([
2203 Pipe({ name: 'isUndefined' })
2204], IsUndefinedPipe);
2205
2206let IsStringPipe = class IsStringPipe {
2207 transform(input) {
2208 return isString(input);
2209 }
2210};
2211IsStringPipe = __decorate([
2212 Pipe({ name: 'isString' })
2213], IsStringPipe);
2214
2215let IsFunctionPipe = class IsFunctionPipe {
2216 transform(input) {
2217 return isFunction(input);
2218 }
2219};
2220IsFunctionPipe = __decorate([
2221 Pipe({ name: 'isFunction' })
2222], IsFunctionPipe);
2223
2224let IsNumberPipe = class IsNumberPipe {
2225 transform(input) {
2226 return isNumber(input);
2227 }
2228};
2229IsNumberPipe = __decorate([
2230 Pipe({ name: 'isNumber' })
2231], IsNumberPipe);
2232
2233let IsArrayPipe = class IsArrayPipe {
2234 transform(input) {
2235 return Array.isArray(input);
2236 }
2237};
2238IsArrayPipe = __decorate([
2239 Pipe({ name: 'isArray' })
2240], IsArrayPipe);
2241
2242let IsObjectPipe = class IsObjectPipe {
2243 transform(input) {
2244 return isObject(input);
2245 }
2246};
2247IsObjectPipe = __decorate([
2248 Pipe({ name: 'isObject' })
2249], IsObjectPipe);
2250
2251let IsGreaterEqualThanPipe = class IsGreaterEqualThanPipe {
2252 transform(input, other) {
2253 return input >= other;
2254 }
2255};
2256IsGreaterEqualThanPipe = __decorate([
2257 Pipe({ name: 'isGreaterEqualThan' })
2258], IsGreaterEqualThanPipe);
2259
2260let IsGreaterThanPipe = class IsGreaterThanPipe {
2261 transform(input, other) {
2262 return input > other;
2263 }
2264};
2265IsGreaterThanPipe = __decorate([
2266 Pipe({ name: 'isGreaterThan' })
2267], IsGreaterThanPipe);
2268
2269let IsLessEqualThanPipe = class IsLessEqualThanPipe {
2270 transform(input, other) {
2271 return input <= other;
2272 }
2273};
2274IsLessEqualThanPipe = __decorate([
2275 Pipe({ name: 'isLessEqualThan' })
2276], IsLessEqualThanPipe);
2277
2278let IsEqualToPipe = class IsEqualToPipe {
2279 transform(input, other) {
2280 // tslint:disable-next-line:triple-equals
2281 return input == other;
2282 }
2283};
2284IsEqualToPipe = __decorate([
2285 Pipe({ name: 'isEqualTo' })
2286], IsEqualToPipe);
2287
2288let IsNotEqualToPipe = class IsNotEqualToPipe {
2289 transform(input, other) {
2290 // tslint:disable-next-line:triple-equals
2291 return input != other;
2292 }
2293};
2294IsNotEqualToPipe = __decorate([
2295 Pipe({ name: 'isNotEqualTo' })
2296], IsNotEqualToPipe);
2297
2298let IsIdenticalToPipe = class IsIdenticalToPipe {
2299 transform(input, other) {
2300 return input === other;
2301 }
2302};
2303IsIdenticalToPipe = __decorate([
2304 Pipe({ name: 'isIdenticalTo' })
2305], IsIdenticalToPipe);
2306
2307let IsNotIdenticalToPipe = class IsNotIdenticalToPipe {
2308 transform(input, other) {
2309 return input !== other;
2310 }
2311};
2312IsNotIdenticalToPipe = __decorate([
2313 Pipe({ name: 'isNotIdenticalTo' })
2314], IsNotIdenticalToPipe);
2315
2316let IsLessThanPipe = class IsLessThanPipe {
2317 transform(input, other) {
2318 return input < other;
2319 }
2320};
2321IsLessThanPipe = __decorate([
2322 Pipe({ name: 'isLessThan' })
2323], IsLessThanPipe);
2324
2325const BOOLEAN_PIPES = [
2326 IsDefinedPipe,
2327 IsNullPipe,
2328 IsUndefinedPipe,
2329 IsStringPipe,
2330 IsFunctionPipe,
2331 IsNumberPipe,
2332 IsArrayPipe,
2333 IsObjectPipe,
2334 IsGreaterEqualThanPipe,
2335 IsGreaterThanPipe,
2336 IsLessEqualThanPipe,
2337 IsLessEqualThanPipe,
2338 IsEqualToPipe,
2339 IsNotEqualToPipe,
2340 IsIdenticalToPipe,
2341 IsNotIdenticalToPipe,
2342 IsLessThanPipe,
2343];
2344let NgBooleanPipesModule = class NgBooleanPipesModule {
2345};
2346NgBooleanPipesModule = __decorate([
2347 NgModule({
2348 declarations: BOOLEAN_PIPES,
2349 imports: [],
2350 exports: BOOLEAN_PIPES,
2351 })
2352], NgBooleanPipesModule);
2353
2354var TimeAgoPipe_1;
2355let TimeAgoPipe = TimeAgoPipe_1 = class TimeAgoPipe {
2356 /**
2357 * @param inputDate: Date | Moment - not included as TypeScript interface,
2358 * in order to keep `ngx-pipes` "pure" from dependencies!
2359 */
2360 transform(inputDate) {
2361 if (!inputDate || (!inputDate.getTime && !inputDate.toDate)) {
2362 return 'Invalid date';
2363 }
2364 const past = inputDate.toDate ? inputDate.toDate() : inputDate.getTime();
2365 const now = +new Date();
2366 if (past > now) {
2367 return 'in the future';
2368 }
2369 for (let i = 0, l = TimeAgoPipe_1.MAPPER.length, ms = now - past, div = TimeAgoPipe_1.YEAR_MS; i < l; ++i) {
2370 const elm = TimeAgoPipe_1.MAPPER[i];
2371 const unit = Math.floor(ms / (div /= elm.div));
2372 if (unit >= 1) {
2373 return unit === 1 ? elm.single : `${unit} ${elm.many} ago`;
2374 }
2375 }
2376 return 'just now';
2377 }
2378};
2379TimeAgoPipe.YEAR_MS = 1000 * 60 * 60 * 24 * 7 * 4 * 12;
2380TimeAgoPipe.MAPPER = [
2381 { single: 'last year', many: 'years', div: 1 },
2382 { single: 'last month', many: 'months', div: 12 },
2383 { single: 'last week', many: 'weeks', div: 4 },
2384 { single: 'yesterday', many: 'days', div: 7 },
2385 { single: 'an hour ago', many: 'hours', div: 24 },
2386 { single: 'just now', many: 'minutes', div: 60 },
2387];
2388TimeAgoPipe = TimeAgoPipe_1 = __decorate([
2389 Pipe({ name: 'timeAgo' })
2390], TimeAgoPipe);
2391
2392const DATE_PIPES = [TimeAgoPipe];
2393let NgDatePipesModule = class NgDatePipesModule {
2394};
2395NgDatePipesModule = __decorate([
2396 NgModule({
2397 declarations: DATE_PIPES,
2398 imports: [],
2399 exports: DATE_PIPES,
2400 })
2401], NgDatePipesModule);
2402
2403let NgPipesModule = class NgPipesModule {
2404};
2405NgPipesModule = __decorate([
2406 NgModule({
2407 exports: [
2408 NgArrayPipesModule,
2409 NgStringPipesModule,
2410 NgMathPipesModule,
2411 NgBooleanPipesModule,
2412 NgObjectPipesModule,
2413 NgDatePipesModule,
2414 ],
2415 })
2416], NgPipesModule);
2417
2418export { AorAnPipe, BOOLEAN_PIPES, BytesPipe, CamelizePipe, CeilPipe, ChunkPipe, DATE_PIPES, DegreesPipe, DiffObjPipe, DiffPipe, EveryPipe, FilterByImpurePipe, FilterByPipe, FlattenPipe, FloorPipe, GroupByImpurePipe, GroupByPipe, InitialPipe, IntersectionPipe, InvertByPipe, InvertPipe, IsArrayPipe, IsDefinedPipe, IsEqualToPipe, IsFunctionPipe, IsGreaterEqualThanPipe, IsGreaterThanPipe, IsIdenticalToPipe, IsLessEqualThanPipe, IsLessThanPipe, IsNotEqualToPipe, IsNotIdenticalToPipe, IsNullPipe, IsNumberPipe, IsObjectPipe, IsStringPipe, IsUndefinedPipe, KeysPipe, LatinisePipe, LeftPadPipe, LeftTrimPipe, LinesPipe, MATH_PIPES, MakePluralStringPipe, MatchPipe, MaxPipe, MinPipe, NgArrayPipesModule, NgBooleanPipesModule, NgDatePipesModule, NgMathPipesModule, NgObjectPipesModule, NgPipesModule, NgStringPipesModule, OmitPipe, OrderByImpurePipe, OrderByPipe, PairsPipe, PercentagePipe, PickPipe, PluckPipe, PowerPipe, RangePipe, RepeatPipe, ReversePipe, RightPadPipe, RightTrimPipe, RoundPipe, STRING_PIPES, SamplePipe, ScanPipe, ShortenPipe, ShufflePipe, SlugifyPipe, SomePipe, SqrtPipe, StripTagsPipe, SumPipe, TailPipe, TestPipe, TimeAgoPipe, TrimPipe, TrurthifyPipe, UcFirstPipe, UcWordsPipe, UnderscorePipe, UnionPipe, UniquePipe, ValuesPipe, WithoutPipe, WrapPipe, isString as ɵa, FromPairsPipe as ɵb, RadiansPipe as ɵc };
2419//# sourceMappingURL=ngx-pipes.js.map