UNPKG

77.3 kBJavaScriptView Raw
1import { __decorate, __spread, __read, __extends } from 'tslib';
2import { Pipe, NgModule } from '@angular/core';
3
4var DiffPipe = /** @class */ (function () {
5 function DiffPipe() {
6 }
7 DiffPipe.prototype.transform = function (input) {
8 var args = [];
9 for (var _i = 1; _i < arguments.length; _i++) {
10 args[_i - 1] = arguments[_i];
11 }
12 if (!Array.isArray(input)) {
13 return input;
14 }
15 // tslint:disable-next-line no-bitwise
16 return args.reduce(function (d, c) { return d.filter(function (e) { return !~c.indexOf(e); }); }, input);
17 };
18 DiffPipe = __decorate([
19 Pipe({ name: 'diff' })
20 ], DiffPipe);
21 return DiffPipe;
22}());
23
24var InitialPipe = /** @class */ (function () {
25 function InitialPipe() {
26 }
27 InitialPipe.prototype.transform = function (input, num) {
28 if (num === void 0) { num = 0; }
29 return Array.isArray(input) ? input.slice(0, input.length - num) : input;
30 };
31 InitialPipe = __decorate([
32 Pipe({ name: 'initial' })
33 ], InitialPipe);
34 return InitialPipe;
35}());
36
37var FlattenPipe = /** @class */ (function () {
38 function FlattenPipe() {
39 }
40 FlattenPipe.prototype.transform = function (input, shallow) {
41 if (shallow === void 0) { shallow = false; }
42 if (!Array.isArray(input)) {
43 return input;
44 }
45 return shallow ? [].concat.apply([], input) : this.flatten(input);
46 };
47 FlattenPipe.prototype.flatten = function (array) {
48 var _this = this;
49 return array.reduce(function (arr, elm) {
50 if (Array.isArray(elm)) {
51 return arr.concat(_this.flatten(elm));
52 }
53 return arr.concat(elm);
54 }, []);
55 };
56 FlattenPipe = __decorate([
57 Pipe({ name: 'flatten' })
58 ], FlattenPipe);
59 return FlattenPipe;
60}());
61
62var IntersectionPipe = /** @class */ (function () {
63 function IntersectionPipe() {
64 }
65 IntersectionPipe.prototype.transform = function (input) {
66 var args = [];
67 for (var _i = 1; _i < arguments.length; _i++) {
68 args[_i - 1] = arguments[_i];
69 }
70 if (!Array.isArray(input)) {
71 return input;
72 }
73 // tslint:disable-next-line no-bitwise
74 return args.reduce(function (n, c) { return n.filter(function (e) { return !!~c.indexOf(e); }); }, input);
75 };
76 IntersectionPipe = __decorate([
77 Pipe({ name: 'intersection' })
78 ], IntersectionPipe);
79 return IntersectionPipe;
80}());
81
82function isUndefined(value) {
83 return typeof value === 'undefined';
84}
85function isFunction(value) {
86 return typeof value === 'function';
87}
88function isNumber(value) {
89 return typeof value === 'number';
90}
91function isString(value) {
92 return typeof value === 'string';
93}
94function isBoolean(value) {
95 return typeof value === 'boolean';
96}
97function isObject(value) {
98 return value !== null && typeof value === 'object';
99}
100function isNumberFinite(value) {
101 return isNumber(value) && isFinite(value);
102}
103function isVowel(letter) {
104 var vowels = ['a', 'e', 'i', 'o', 'u'];
105 return vowels.indexOf(letter) !== -1;
106}
107function ucFirst(text) {
108 var _a = __read(text.split(/\s/g)), part = _a[0], split = _a.slice(1);
109 var ucd = part
110 .toLowerCase()
111 .split(/(?=['|-])/g)
112 .map(function (word) {
113 return word.indexOf('-') + word.indexOf("'") > -2
114 ? word.slice(0, 2).toUpperCase() + word.slice(2)
115 : word.slice(0, 1).toUpperCase() + word.slice(1);
116 })
117 .join('');
118 return __spread([ucd], split).join(' ');
119}
120function applyPrecision(num, precision) {
121 if (precision <= 0) {
122 return Math.round(num);
123 }
124 var tho = Math.pow(10, precision);
125 return Math.round(num * tho) / tho;
126}
127function extractDeepPropertyByMapKey(obj, map) {
128 var keys = map.split('.');
129 var head = keys.shift();
130 return keys.reduce(function (prop, key) {
131 return !isUndefined(prop) && !isUndefined(prop[key]) ? prop[key] : undefined;
132 }, obj[head || '']);
133}
134function extractDeepPropertyByParentMapKey(obj, map) {
135 var keys = map.split('.');
136 var tail = keys.pop();
137 var props = extractDeepPropertyByMapKey(obj, keys.join('.'));
138 return { props: props, tail: tail };
139}
140function getKeysTwoObjects(obj, other) {
141 return __spread(Object.keys(obj), Object.keys(other)).filter(function (key, index, array) { return array.indexOf(key) === index; });
142}
143function isDeepEqual(obj, other) {
144 if (!isObject(obj) || !isObject(other)) {
145 return obj === other;
146 }
147 return getKeysTwoObjects(obj, other).every(function (key) {
148 if (!isObject(obj[key]) && !isObject(other[key])) {
149 return obj[key] === other[key];
150 }
151 if (!isObject(obj[key]) || !isObject(other[key])) {
152 return false;
153 }
154 return isDeepEqual(obj[key], other[key]);
155 });
156}
157
158var ReversePipe = /** @class */ (function () {
159 function ReversePipe() {
160 }
161 ReversePipe.prototype.transform = function (input) {
162 if (isString(input)) {
163 return input
164 .split('')
165 .reverse()
166 .join('');
167 }
168 return Array.isArray(input) ? input.slice().reverse() : input;
169 };
170 ReversePipe = __decorate([
171 Pipe({ name: 'reverse' })
172 ], ReversePipe);
173 return ReversePipe;
174}());
175
176var TailPipe = /** @class */ (function () {
177 function TailPipe() {
178 }
179 TailPipe.prototype.transform = function (input, num) {
180 if (num === void 0) { num = 0; }
181 return Array.isArray(input) ? input.slice(num) : input;
182 };
183 TailPipe = __decorate([
184 Pipe({ name: 'tail' })
185 ], TailPipe);
186 return TailPipe;
187}());
188
189var TrurthifyPipe = /** @class */ (function () {
190 function TrurthifyPipe() {
191 }
192 TrurthifyPipe.prototype.transform = function (input) {
193 return Array.isArray(input) ? input.filter(function (e) { return !!e; }) : input;
194 };
195 TrurthifyPipe = __decorate([
196 Pipe({ name: 'truthify' })
197 ], TrurthifyPipe);
198 return TrurthifyPipe;
199}());
200
201var UnionPipe = /** @class */ (function () {
202 function UnionPipe() {
203 }
204 UnionPipe.prototype.transform = function (input, args) {
205 if (args === void 0) { args = []; }
206 if (!Array.isArray(input) || !Array.isArray(args)) {
207 return input;
208 }
209 return args.reduce(function (newArr, currArr) {
210 return newArr.concat(currArr.reduce(function (noDupArr, curr) {
211 // tslint:disable-next-line:no-bitwise
212 return !~noDupArr.indexOf(curr) && !~newArr.indexOf(curr) ? noDupArr.concat([curr]) : noDupArr;
213 }, []));
214 }, input);
215 };
216 UnionPipe = __decorate([
217 Pipe({ name: 'union' })
218 ], UnionPipe);
219 return UnionPipe;
220}());
221
222var UniquePipe = /** @class */ (function () {
223 function UniquePipe() {
224 }
225 UniquePipe.prototype.transform = function (input, propertyName) {
226 var uniques = [];
227 return Array.isArray(input)
228 ? isUndefined(propertyName)
229 ? input.filter(function (e, i) { return input.indexOf(e) === i; })
230 : input.filter(function (e, i) {
231 var value = extractDeepPropertyByMapKey(e, propertyName);
232 value = isObject(value) ? JSON.stringify(value) : value;
233 if (isUndefined(value) || uniques[value]) {
234 return false;
235 }
236 uniques[value] = true;
237 return true;
238 })
239 : input;
240 };
241 UniquePipe = __decorate([
242 Pipe({ name: 'unique' })
243 ], UniquePipe);
244 return UniquePipe;
245}());
246
247var WithoutPipe = /** @class */ (function () {
248 function WithoutPipe() {
249 }
250 WithoutPipe.prototype.transform = function (input, args) {
251 if (args === void 0) { args = []; }
252 return Array.isArray(input)
253 ? // tslint:disable-next-line:no-bitwise
254 input.filter(function (e) { return !~args.indexOf(e); })
255 : input;
256 };
257 WithoutPipe = __decorate([
258 Pipe({ name: 'without' })
259 ], WithoutPipe);
260 return WithoutPipe;
261}());
262
263var PluckPipe = /** @class */ (function () {
264 function PluckPipe() {
265 }
266 PluckPipe.prototype.transform = function (input, map) {
267 if (Array.isArray(input)) {
268 return input.map(function (e) { return extractDeepPropertyByMapKey(e, map); });
269 }
270 return isObject(input) ? extractDeepPropertyByMapKey(input, map) : input;
271 };
272 PluckPipe = __decorate([
273 Pipe({ name: 'pluck', pure: false })
274 ], PluckPipe);
275 return PluckPipe;
276}());
277
278var ShufflePipe = /** @class */ (function () {
279 function ShufflePipe() {
280 }
281 // Using a version of the Fisher-Yates shuffle algorithm
282 // https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
283 ShufflePipe.prototype.transform = function (input) {
284 var _a;
285 if (!Array.isArray(input)) {
286 return input;
287 }
288 var shuffled = __spread(input);
289 var n = input.length - 1;
290 for (var i = 0; i < n; ++i) {
291 var j = Math.floor(Math.random() * (n - i + 1)) + i;
292 _a = __read([shuffled[j], shuffled[i]], 2), shuffled[i] = _a[0], shuffled[j] = _a[1];
293 }
294 return shuffled;
295 };
296 ShufflePipe = __decorate([
297 Pipe({ name: 'shuffle' })
298 ], ShufflePipe);
299 return ShufflePipe;
300}());
301
302var EveryPipe = /** @class */ (function () {
303 function EveryPipe() {
304 }
305 EveryPipe.prototype.transform = function (input, predicate) {
306 return Array.isArray(input) ? input.every(predicate) : false;
307 };
308 EveryPipe = __decorate([
309 Pipe({ name: 'every' })
310 ], EveryPipe);
311 return EveryPipe;
312}());
313
314var SomePipe = /** @class */ (function () {
315 function SomePipe() {
316 }
317 SomePipe.prototype.transform = function (input, predicate) {
318 return Array.isArray(input) ? input.some(predicate) : input;
319 };
320 SomePipe = __decorate([
321 Pipe({ name: 'some' })
322 ], SomePipe);
323 return SomePipe;
324}());
325
326var SamplePipe = /** @class */ (function () {
327 function SamplePipe() {
328 }
329 SamplePipe.prototype.transform = function (input, len) {
330 if (len === void 0) { len = 1; }
331 if (!Array.isArray(input)) {
332 return input;
333 }
334 var sample = [];
335 var tmp = __spread(input);
336 var l = len < tmp.length ? len : tmp.length;
337 for (var i = 0; i < l; ++i) {
338 sample = sample.concat(tmp.splice(Math.floor(Math.random() * tmp.length), 1));
339 }
340 return sample;
341 };
342 SamplePipe = __decorate([
343 Pipe({ name: 'sample' })
344 ], SamplePipe);
345 return SamplePipe;
346}());
347
348var GroupByPipe = /** @class */ (function () {
349 function GroupByPipe() {
350 }
351 GroupByPipe.prototype.transform = function (input, discriminator, delimiter) {
352 if (discriminator === void 0) { discriminator = []; }
353 if (delimiter === void 0) { delimiter = '|'; }
354 if (!Array.isArray(input)) {
355 return input;
356 }
357 return this.groupBy(input, discriminator, delimiter);
358 };
359 GroupByPipe.prototype.groupBy = function (list, discriminator, delimiter) {
360 var _this = this;
361 return list.reduce(function (acc, payload) {
362 var key = _this.extractKeyByDiscriminator(discriminator, payload, delimiter);
363 acc[key] = Array.isArray(acc[key]) ? acc[key].concat([payload]) : [payload];
364 return acc;
365 }, {});
366 };
367 GroupByPipe.prototype.extractKeyByDiscriminator = function (discriminator, payload, delimiter) {
368 if (isFunction(discriminator)) {
369 return discriminator(payload);
370 }
371 if (Array.isArray(discriminator)) {
372 return discriminator.map(function (k) { return extractDeepPropertyByMapKey(payload, k); }).join(delimiter);
373 }
374 return extractDeepPropertyByMapKey(payload, discriminator);
375 };
376 GroupByPipe = __decorate([
377 Pipe({ name: 'groupBy' })
378 ], GroupByPipe);
379 return GroupByPipe;
380}());
381
382// tslint:disable no-bitwise
383var FilterByPipe = /** @class */ (function () {
384 function FilterByPipe() {
385 }
386 FilterByPipe.prototype.transform = function (input, props, search, strict) {
387 if (search === void 0) { search = ''; }
388 if (strict === void 0) { strict = false; }
389 if (!Array.isArray(input) ||
390 (!Array.isArray(search) && !isString(search) && !isNumberFinite(search) && !isBoolean(search))) {
391 return input;
392 }
393 var terms = String(search)
394 .toLowerCase()
395 .split(',');
396 return input.filter(function (obj) {
397 return props.some(function (prop) {
398 return terms.some(function (term) {
399 var value = extractDeepPropertyByMapKey(obj, prop);
400 /* tslint:disable */
401 var _a = extractDeepPropertyByParentMapKey(obj, prop), props = _a.props, tail = _a.tail;
402 if (isUndefined(value) && !isUndefined(props) && Array.isArray(props)) {
403 return props.some(function (parent) {
404 var str = String(parent[tail]).toLowerCase();
405 return strict ? str === term : !!~str.indexOf(term);
406 });
407 }
408 if (isUndefined(value)) {
409 return false;
410 }
411 var strValue = String(value).toLowerCase();
412 return strict ? term === strValue : !!~strValue.indexOf(term);
413 });
414 });
415 });
416 };
417 FilterByPipe = __decorate([
418 Pipe({ name: 'filterBy' })
419 ], FilterByPipe);
420 return FilterByPipe;
421}());
422
423var OrderByPipe = /** @class */ (function () {
424 function OrderByPipe() {
425 }
426 OrderByPipe_1 = OrderByPipe;
427 OrderByPipe.prototype.transform = function (input, config) {
428 if (!Array.isArray(input)) {
429 return input;
430 }
431 var out = __spread(input);
432 // sort by multiple properties
433 if (Array.isArray(config)) {
434 return out.sort(function (a, b) {
435 var l = config.length;
436 for (var i = 0; i < l; ++i) {
437 var _a = __read(OrderByPipe_1.extractFromConfig(config[i]), 2), prop = _a[0], asc = _a[1];
438 var pos = OrderByPipe_1.orderCompare(prop, asc, a, b);
439 if (pos !== 0) {
440 return pos;
441 }
442 }
443 return 0;
444 });
445 }
446 // sort by a single property value
447 if (isString(config)) {
448 var _a = __read(OrderByPipe_1.extractFromConfig(config), 3), prop = _a[0], asc = _a[1], sign = _a[2];
449 if (config.length === 1) {
450 // tslint:disable-next-line:switch-default
451 switch (sign) {
452 case '+':
453 return out.sort(OrderByPipe_1.simpleSort.bind(this));
454 case '-':
455 return out.sort(OrderByPipe_1.simpleSort.bind(this)).reverse();
456 }
457 }
458 return out.sort(OrderByPipe_1.orderCompare.bind(this, prop, asc));
459 }
460 // default sort by value
461 return out.sort(OrderByPipe_1.simpleSort.bind(this));
462 };
463 OrderByPipe.simpleSort = function (a, b) {
464 return isString(a) && isString(b) ? a.toLowerCase().localeCompare(b.toLowerCase()) : a - b;
465 };
466 OrderByPipe.orderCompare = function (prop, asc, a, b) {
467 var first = extractDeepPropertyByMapKey(a, prop);
468 var second = extractDeepPropertyByMapKey(b, prop);
469 if (first === second) {
470 return 0;
471 }
472 if (isUndefined(first) || first === '') {
473 return 1;
474 }
475 if (isUndefined(second) || second === '') {
476 return -1;
477 }
478 if (isString(first) && isString(second)) {
479 var pos = first.toLowerCase().localeCompare(second.toLowerCase());
480 return asc ? pos : -pos;
481 }
482 return asc ? first - second : second - first;
483 };
484 OrderByPipe.extractFromConfig = function (config) {
485 var sign = config.substr(0, 1);
486 var prop = config.replace(/^[-+]/, '');
487 var asc = sign !== '-';
488 return [prop, asc, sign];
489 };
490 var OrderByPipe_1;
491 OrderByPipe = OrderByPipe_1 = __decorate([
492 Pipe({ name: 'orderBy' })
493 ], OrderByPipe);
494 return OrderByPipe;
495}());
496
497// tslint:disable use-pipe-transform-interface
498var GroupByImpurePipe = /** @class */ (function (_super) {
499 __extends(GroupByImpurePipe, _super);
500 function GroupByImpurePipe() {
501 return _super !== null && _super.apply(this, arguments) || this;
502 }
503 GroupByImpurePipe = __decorate([
504 Pipe({ name: 'groupByImpure', pure: false })
505 ], GroupByImpurePipe);
506 return GroupByImpurePipe;
507}(GroupByPipe));
508
509// tslint:disable use-pipe-transform-interface
510var FilterByImpurePipe = /** @class */ (function (_super) {
511 __extends(FilterByImpurePipe, _super);
512 function FilterByImpurePipe() {
513 return _super !== null && _super.apply(this, arguments) || this;
514 }
515 FilterByImpurePipe = __decorate([
516 Pipe({ name: 'filterByImpure', pure: false })
517 ], FilterByImpurePipe);
518 return FilterByImpurePipe;
519}(FilterByPipe));
520
521// tslint:disable use-pipe-transform-interface
522var OrderByImpurePipe = /** @class */ (function (_super) {
523 __extends(OrderByImpurePipe, _super);
524 function OrderByImpurePipe() {
525 return _super !== null && _super.apply(this, arguments) || this;
526 }
527 OrderByImpurePipe = __decorate([
528 Pipe({ name: 'orderByImpure', pure: false })
529 ], OrderByImpurePipe);
530 return OrderByImpurePipe;
531}(OrderByPipe));
532
533var RangePipe = /** @class */ (function () {
534 function RangePipe() {
535 }
536 RangePipe.prototype.transform = function (start, count, step) {
537 if (start === void 0) { start = 1; }
538 if (count === void 0) { count = 0; }
539 if (step === void 0) { step = 1; }
540 return Array(count)
541 .fill('')
542 .map(function (v, i) { return step * i + start; });
543 };
544 RangePipe = __decorate([
545 Pipe({ name: 'range' })
546 ], RangePipe);
547 return RangePipe;
548}());
549
550var ChunkPipe = /** @class */ (function () {
551 function ChunkPipe() {
552 }
553 ChunkPipe.prototype.transform = function (input, size) {
554 if (size === void 0) { size = 1; }
555 if (isString(input)) {
556 return this.chunk(input
557 .split(''), size);
558 }
559 return Array.isArray(input) ? this.chunk(input, size) : input;
560 };
561 ChunkPipe.prototype.chunk = function (input, size) {
562 return Array(Math.ceil(input.length / size))
563 .fill([])
564 .map(function (_, index) { return index * size; })
565 .map(function (begin) { return input.slice(begin, begin + size); });
566 };
567 ChunkPipe = __decorate([
568 Pipe({ name: 'chunk' })
569 ], ChunkPipe);
570 return ChunkPipe;
571}());
572
573var FromPairsPipe = /** @class */ (function () {
574 function FromPairsPipe() {
575 }
576 FromPairsPipe.prototype.transform = function (input) {
577 if (!Array.isArray(input)) {
578 return input;
579 }
580 return input.reduce(function (obj, arr) {
581 if (!Array.isArray(arr)) {
582 return obj;
583 }
584 var _a = __read(arr, 2), prop = _a[0], val = _a[1];
585 obj[prop] = val;
586 return obj;
587 }, {});
588 };
589 FromPairsPipe = __decorate([
590 Pipe({ name: 'fromPairs' })
591 ], FromPairsPipe);
592 return FromPairsPipe;
593}());
594
595var ARRAY_PIPES = [
596 DiffPipe,
597 FlattenPipe,
598 InitialPipe,
599 IntersectionPipe,
600 ReversePipe,
601 TailPipe,
602 TrurthifyPipe,
603 UnionPipe,
604 UniquePipe,
605 WithoutPipe,
606 PluckPipe,
607 ShufflePipe,
608 EveryPipe,
609 SomePipe,
610 SamplePipe,
611 GroupByPipe,
612 GroupByImpurePipe,
613 FilterByPipe,
614 FilterByImpurePipe,
615 OrderByPipe,
616 OrderByImpurePipe,
617 RangePipe,
618 ChunkPipe,
619 FromPairsPipe
620];
621var NgArrayPipesModule = /** @class */ (function () {
622 function NgArrayPipesModule() {
623 }
624 NgArrayPipesModule = __decorate([
625 NgModule({
626 declarations: ARRAY_PIPES,
627 imports: [],
628 exports: ARRAY_PIPES,
629 })
630 ], NgArrayPipesModule);
631 return NgArrayPipesModule;
632}());
633
634var KeysPipe = /** @class */ (function () {
635 function KeysPipe() {
636 }
637 KeysPipe.prototype.transform = function (obj) {
638 if (Array.isArray(obj) || !isObject(obj)) {
639 return obj;
640 }
641 return Object.keys(obj);
642 };
643 KeysPipe = __decorate([
644 Pipe({ name: 'keys' })
645 ], KeysPipe);
646 return KeysPipe;
647}());
648
649var ValuesPipe = /** @class */ (function () {
650 function ValuesPipe() {
651 }
652 ValuesPipe.prototype.transform = function (obj) {
653 if (Array.isArray(obj) || !isObject(obj)) {
654 return obj;
655 }
656 return Object.keys(obj).map(function (k) { return obj[k]; });
657 };
658 ValuesPipe = __decorate([
659 Pipe({ name: 'values' })
660 ], ValuesPipe);
661 return ValuesPipe;
662}());
663
664var PairsPipe = /** @class */ (function () {
665 function PairsPipe() {
666 }
667 PairsPipe.prototype.transform = function (obj) {
668 if (Array.isArray(obj) || !isObject(obj)) {
669 return obj;
670 }
671 return Object.entries(obj);
672 };
673 PairsPipe = __decorate([
674 Pipe({ name: 'pairs' })
675 ], PairsPipe);
676 return PairsPipe;
677}());
678
679var PickPipe = /** @class */ (function () {
680 function PickPipe() {
681 }
682 PickPipe.prototype.transform = function (obj) {
683 var args = [];
684 for (var _i = 1; _i < arguments.length; _i++) {
685 args[_i - 1] = arguments[_i];
686 }
687 if (Array.isArray(obj) || !isObject(obj)) {
688 return obj;
689 }
690 return args.reduce(function (o, k) {
691 var _a;
692 return Object.assign(o, (_a = {}, _a[k] = obj[k], _a));
693 }, {});
694 };
695 PickPipe = __decorate([
696 Pipe({ name: 'pick' })
697 ], PickPipe);
698 return PickPipe;
699}());
700
701var OmitPipe = /** @class */ (function () {
702 function OmitPipe() {
703 }
704 OmitPipe.prototype.transform = function (obj) {
705 var args = [];
706 for (var _i = 1; _i < arguments.length; _i++) {
707 args[_i - 1] = arguments[_i];
708 }
709 if (Array.isArray(obj) || !isObject(obj)) {
710 return obj;
711 }
712 return (Object.keys(obj)
713 // tslint:disable-next-line:no-bitwise
714 .filter(function (k) { return !~args.indexOf(k); })
715 .reduce(function (o, k) {
716 var _a;
717 return Object.assign(o, (_a = {}, _a[k] = obj[k], _a));
718 }, {}));
719 };
720 OmitPipe = __decorate([
721 Pipe({ name: 'omit' })
722 ], OmitPipe);
723 return OmitPipe;
724}());
725
726var InvertPipe = /** @class */ (function () {
727 function InvertPipe() {
728 }
729 InvertPipe.prototype.transform = function (obj) {
730 if (Array.isArray(obj) || !isObject(obj)) {
731 return obj;
732 }
733 return Object.keys(obj).reduce(function (o, k) {
734 var _a;
735 return Object.assign(o, (_a = {}, _a[obj[k]] = k, _a));
736 }, {});
737 };
738 InvertPipe = __decorate([
739 Pipe({ name: 'invert' })
740 ], InvertPipe);
741 return InvertPipe;
742}());
743
744var InvertByPipe = /** @class */ (function () {
745 function InvertByPipe() {
746 }
747 InvertByPipe.prototype.transform = function (obj, cb) {
748 if (Array.isArray(obj) || !isObject(obj)) {
749 return obj;
750 }
751 return Object.keys(obj).reduce(function (o, k) {
752 var _a;
753 var key = cb ? cb(obj[k]) : obj[k];
754 return Array.isArray(o[key]) ? (o[key].push(k), o) : Object.assign(o, (_a = {}, _a[key] = [k], _a));
755 }, {});
756 };
757 InvertByPipe = __decorate([
758 Pipe({ name: 'invertBy' })
759 ], InvertByPipe);
760 return InvertByPipe;
761}());
762
763var DiffObjPipe = /** @class */ (function () {
764 function DiffObjPipe() {
765 }
766 DiffObjPipe.prototype.transform = function (obj, original) {
767 if (original === void 0) { original = {}; }
768 if (Array.isArray(obj) || Array.isArray(original) || !isObject(obj) || !isObject(original)) {
769 return {};
770 }
771 return getKeysTwoObjects(obj, original).reduce(function (diff, key) {
772 if (!isDeepEqual(original[key], obj[key])) {
773 diff[key] = obj[key];
774 }
775 return diff;
776 }, {});
777 };
778 DiffObjPipe = __decorate([
779 Pipe({ name: 'diffObj' })
780 ], DiffObjPipe);
781 return DiffObjPipe;
782}());
783
784var OBJECT_PIPES = [KeysPipe, ValuesPipe, PairsPipe, PickPipe, InvertPipe, InvertByPipe, OmitPipe, DiffObjPipe];
785var NgObjectPipesModule = /** @class */ (function () {
786 function NgObjectPipesModule() {
787 }
788 NgObjectPipesModule = __decorate([
789 NgModule({
790 declarations: OBJECT_PIPES,
791 imports: [],
792 exports: OBJECT_PIPES,
793 })
794 ], NgObjectPipesModule);
795 return NgObjectPipesModule;
796}());
797
798var AorAnPipe = /** @class */ (function () {
799 function AorAnPipe() {
800 this.irregularMap = {
801 herb: 'an',
802 honor: 'an',
803 honorable: 'an',
804 hour: 'an',
805 mba: 'an',
806 msc: 'an',
807 'm.sc.': 'an',
808 unicorn: 'a',
809 };
810 }
811 AorAnPipe.prototype.transform = function (stringEntity) {
812 if (!stringEntity || stringEntity === '') {
813 return '';
814 }
815 else {
816 var firstWord = stringEntity.trim().split(' ')[0];
817 if (this.irregularMap[firstWord.toLocaleLowerCase()]) {
818 return this.irregularMap[firstWord.toLocaleLowerCase()] + " " + stringEntity;
819 }
820 else {
821 return isVowel(stringEntity[0]) ? "an " + stringEntity : "a " + stringEntity;
822 }
823 }
824 };
825 AorAnPipe = __decorate([
826 Pipe({
827 name: 'aOrAn',
828 })
829 /**
830 * Takes a string and returns the string prepended by 'a' or 'an'.
831 * Uses both naive and holdout-list approaches.
832 * @constructor
833 * @param {string} stringEntity - Entity to prepend 'a' or 'an' to.
834 */
835 ], AorAnPipe);
836 return AorAnPipe;
837}());
838
839var UcWordsPipe = /** @class */ (function () {
840 function UcWordsPipe() {
841 }
842 UcWordsPipe.prototype.transform = function (text) {
843 if (isString(text)) {
844 return text
845 .split(' ')
846 .map(function (sub) { return ucFirst(sub); })
847 .join(' ');
848 }
849 return text;
850 };
851 UcWordsPipe = __decorate([
852 Pipe({ name: 'ucwords' })
853 ], UcWordsPipe);
854 return UcWordsPipe;
855}());
856
857var LeftTrimPipe = /** @class */ (function () {
858 function LeftTrimPipe() {
859 }
860 LeftTrimPipe.prototype.transform = function (text, chars) {
861 if (chars === void 0) { chars = '\\s'; }
862 return isString(text) ? text.replace(new RegExp("^[" + chars + "]+"), '') : text;
863 };
864 LeftTrimPipe = __decorate([
865 Pipe({ name: 'ltrim' })
866 ], LeftTrimPipe);
867 return LeftTrimPipe;
868}());
869
870var RepeatPipe = /** @class */ (function () {
871 function RepeatPipe() {
872 }
873 RepeatPipe.prototype.transform = function (str, n, separator) {
874 if (n === void 0) { n = 1; }
875 if (separator === void 0) { separator = ''; }
876 if (n <= 0) {
877 throw new RangeError();
878 }
879 return n === 1 ? str : this.repeat(str, n - 1, separator);
880 };
881 RepeatPipe.prototype.repeat = function (str, n, separator) {
882 return isString(str) ? (n === 0 ? str : str + separator + this.repeat(str, n - 1, separator)) : str;
883 };
884 RepeatPipe = __decorate([
885 Pipe({ name: 'repeat' })
886 ], RepeatPipe);
887 return RepeatPipe;
888}());
889
890var RightTrimPipe = /** @class */ (function () {
891 function RightTrimPipe() {
892 }
893 RightTrimPipe.prototype.transform = function (text, chars) {
894 if (chars === void 0) { chars = '\\s'; }
895 return isString(text) ? text.replace(new RegExp("[" + chars + "]+$"), '') : text;
896 };
897 RightTrimPipe = __decorate([
898 Pipe({ name: 'rtrim' })
899 ], RightTrimPipe);
900 return RightTrimPipe;
901}());
902
903var ScanPipe = /** @class */ (function () {
904 function ScanPipe() {
905 }
906 ScanPipe.prototype.transform = function (text, args) {
907 if (args === void 0) { args = []; }
908 return isString(text)
909 ? text.replace(/\{(\d+)}/g, function (match, index) { return (!isUndefined(args[index]) ? args[index] : match); })
910 : text;
911 };
912 ScanPipe = __decorate([
913 Pipe({ name: 'scan' })
914 ], ScanPipe);
915 return ScanPipe;
916}());
917
918var ShortenPipe = /** @class */ (function () {
919 function ShortenPipe() {
920 }
921 ShortenPipe.prototype.transform = function (text, length, suffix, wordBreak) {
922 if (length === void 0) { length = 0; }
923 if (suffix === void 0) { suffix = ''; }
924 if (wordBreak === void 0) { wordBreak = true; }
925 if (!isString(text)) {
926 return text;
927 }
928 if (text.length > length) {
929 if (wordBreak) {
930 return text.slice(0, length) + suffix;
931 }
932 // tslint:disable-next-line:no-bitwise
933 if (!!~text.indexOf(' ', length)) {
934 return text.slice(0, text.indexOf(' ', length)) + suffix;
935 }
936 }
937 return text;
938 };
939 ShortenPipe = __decorate([
940 Pipe({ name: 'shorten' })
941 ], ShortenPipe);
942 return ShortenPipe;
943}());
944
945var StripTagsPipe = /** @class */ (function () {
946 function StripTagsPipe() {
947 }
948 StripTagsPipe.prototype.transform = function (text) {
949 var allowedTags = [];
950 for (var _i = 1; _i < arguments.length; _i++) {
951 allowedTags[_i - 1] = arguments[_i];
952 }
953 return allowedTags.length > 0
954 ? text.replace(new RegExp("<(?!/?(" + allowedTags.join('|') + ")s*/?)[^>]+>", 'g'), '')
955 : text.replace(/<(?:.|\s)*?>/g, '');
956 };
957 StripTagsPipe = __decorate([
958 Pipe({ name: 'stripTags' })
959 ], StripTagsPipe);
960 return StripTagsPipe;
961}());
962
963var TrimPipe = /** @class */ (function () {
964 function TrimPipe() {
965 }
966 TrimPipe.prototype.transform = function (text, chars) {
967 if (chars === void 0) { chars = '\\s'; }
968 return isString(text) ? text.replace(new RegExp("^[" + chars + "]+|[" + chars + "]+$", 'g'), '') : text;
969 };
970 TrimPipe = __decorate([
971 Pipe({ name: 'trim' })
972 ], TrimPipe);
973 return TrimPipe;
974}());
975
976var UcFirstPipe = /** @class */ (function () {
977 function UcFirstPipe() {
978 }
979 UcFirstPipe.prototype.transform = function (text) {
980 return isString(text) ? ucFirst(text) : text;
981 };
982 UcFirstPipe = __decorate([
983 Pipe({ name: 'ucfirst' })
984 ], UcFirstPipe);
985 return UcFirstPipe;
986}());
987
988var SlugifyPipe = /** @class */ (function () {
989 function SlugifyPipe() {
990 }
991 SlugifyPipe.prototype.transform = function (str) {
992 return isString(str)
993 ? str
994 .toLowerCase()
995 .trim()
996 .replace(/[^\w\-]+/g, ' ')
997 .replace(/\s+/g, '-')
998 : str;
999 };
1000 SlugifyPipe = __decorate([
1001 Pipe({ name: 'slugify' })
1002 ], SlugifyPipe);
1003 return SlugifyPipe;
1004}());
1005
1006var CamelizePipe = /** @class */ (function () {
1007 function CamelizePipe() {
1008 }
1009 CamelizePipe.prototype.transform = function (text, chars) {
1010 if (!isString(text)) {
1011 return text;
1012 }
1013 return text
1014 .toLowerCase()
1015 .split(/[-_\s]/g)
1016 .filter(function (v) { return !!v; })
1017 .map(function (word, key) {
1018 return !key ? word : word.slice(0, 1).toUpperCase() + word.slice(1);
1019 })
1020 .join('');
1021 };
1022 CamelizePipe = __decorate([
1023 Pipe({ name: 'camelize' })
1024 ], CamelizePipe);
1025 return CamelizePipe;
1026}());
1027
1028var LatinisePipe = /** @class */ (function () {
1029 function LatinisePipe() {
1030 // Source: http://semplicewebsites.com/removing-accents-javascript
1031 // tslint:disable-next-line whitespace max-line-length object-literal-key-quotes
1032 this.latinMap = {
1033 Á: 'A',
1034 Ă: 'A',
1035 Ắ: 'A',
1036 Ặ: 'A',
1037 Ằ: 'A',
1038 Ẳ: 'A',
1039 Ẵ: 'A',
1040 Ǎ: 'A',
1041 Â: 'A',
1042 Ấ: 'A',
1043 Ậ: 'A',
1044 Ầ: 'A',
1045 Ẩ: 'A',
1046 Ẫ: 'A',
1047 Ä: 'A',
1048 Ǟ: 'A',
1049 Ȧ: 'A',
1050 Ǡ: 'A',
1051 Ạ: 'A',
1052 Ȁ: 'A',
1053 À: 'A',
1054 Ả: 'A',
1055 Ȃ: 'A',
1056 Ā: 'A',
1057 Ą: 'A',
1058 Å: 'A',
1059 Ǻ: 'A',
1060 Ḁ: 'A',
1061 Ⱥ: 'A',
1062 Ã: 'A',
1063 Ꜳ: 'AA',
1064 Æ: 'AE',
1065 Ǽ: 'AE',
1066 Ǣ: 'AE',
1067 Ꜵ: 'AO',
1068 Ꜷ: 'AU',
1069 Ꜹ: 'AV',
1070 Ꜻ: 'AV',
1071 Ꜽ: 'AY',
1072 Ḃ: 'B',
1073 Ḅ: 'B',
1074 Ɓ: 'B',
1075 Ḇ: 'B',
1076 Ƀ: 'B',
1077 Ƃ: 'B',
1078 Ć: 'C',
1079 Č: 'C',
1080 Ç: 'C',
1081 Ḉ: 'C',
1082 Ĉ: 'C',
1083 Ċ: 'C',
1084 Ƈ: 'C',
1085 Ȼ: 'C',
1086 Ď: 'D',
1087 Ḑ: 'D',
1088 Ḓ: 'D',
1089 Ḋ: 'D',
1090 Ḍ: 'D',
1091 Ɗ: 'D',
1092 Ḏ: 'D',
1093 Dz: 'D',
1094 Dž: 'D',
1095 Đ: 'D',
1096 Ƌ: 'D',
1097 DZ: 'DZ',
1098 DŽ: 'DZ',
1099 É: 'E',
1100 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ᴎ: 'N',
1400 ᴙ: 'R',
1401 ꜱ: 'S',
1402 ᴛ: 'T',
1403 ⱻ: 'E',
1404 ᴚ: 'R',
1405 ᴜ: 'U',
1406 ᴠ: 'V',
1407 ᴡ: 'W',
1408 ʏ: 'Y',
1409 ᴢ: 'Z',
1410 á: 'a',
1411 ă: 'a',
1412 ắ: 'a',
1413 ặ: 'a',
1414 ằ: 'a',
1415 ẳ: 'a',
1416 ẵ: 'a',
1417 ǎ: 'a',
1418 â: 'a',
1419 ấ: 'a',
1420 ậ: 'a',
1421 ầ: 'a',
1422 ẩ: 'a',
1423 ẫ: 'a',
1424 ä: 'a',
1425 ǟ: 'a',
1426 ȧ: 'a',
1427 ǡ: 'a',
1428 ạ: 'a',
1429 ȁ: 'a',
1430 à: 'a',
1431 ả: 'a',
1432 ȃ: 'a',
1433 ā: 'a',
1434 ą: 'a',
1435 ᶏ: 'a',
1436 ẚ: 'a',
1437 å: 'a',
1438 ǻ: 'a',
1439 ḁ: 'a',
1440 ⱥ: 'a',
1441 ã: 'a',
1442 ꜳ: 'aa',
1443 æ: 'ae',
1444 ǽ: 'ae',
1445 ǣ: 'ae',
1446 ꜵ: 'ao',
1447 ꜷ: 'au',
1448 ꜹ: 'av',
1449 ꜻ: 'av',
1450 ꜽ: 'ay',
1451 ḃ: 'b',
1452 ḅ: 'b',
1453 ɓ: 'b',
1454 ḇ: 'b',
1455 ᵬ: 'b',
1456 ᶀ: 'b',
1457 ƀ: 'b',
1458 ƃ: 'b',
1459 ɵ: 'o',
1460 ć: 'c',
1461 č: 'c',
1462 ç: 'c',
1463 ḉ: 'c',
1464 ĉ: 'c',
1465 ɕ: 'c',
1466 ċ: 'c',
1467 ƈ: 'c',
1468 ȼ: 'c',
1469 ď: 'd',
1470 ḑ: 'd',
1471 ḓ: 'd',
1472 ȡ: 'd',
1473 ḋ: 'd',
1474 ḍ: 'd',
1475 ɗ: 'd',
1476 ᶑ: 'd',
1477 ḏ: 'd',
1478 ᵭ: 'd',
1479 ᶁ: 'd',
1480 đ: 'd',
1481 ɖ: 'd',
1482 ƌ: 'd',
1483 ı: 'i',
1484 ȷ: 'j',
1485 ɟ: 'j',
1486 ʄ: 'j',
1487 dz: 'dz',
1488 dž: 'dz',
1489 é: 'e',
1490 ĕ: 'e',
1491 ě: 'e',
1492 ȩ: 'e',
1493 ḝ: 'e',
1494 ê: 'e',
1495 ế: 'e',
1496 ệ: 'e',
1497 ề: 'e',
1498 ể: 'e',
1499 ễ: 'e',
1500 ḙ: 'e',
1501 ë: 'e',
1502 ė: 'e',
1503 ẹ: 'e',
1504 ȅ: 'e',
1505 è: 'e',
1506 ẻ: 'e',
1507 ȇ: 'e',
1508 ē: 'e',
1509 ḗ: 'e',
1510 ḕ: 'e',
1511 ⱸ: 'e',
1512 ę: 'e',
1513 ᶒ: 'e',
1514 ɇ: 'e',
1515 ẽ: 'e',
1516 ḛ: 'e',
1517 ꝫ: 'et',
1518 ḟ: 'f',
1519 ƒ: 'f',
1520 ᵮ: 'f',
1521 ᶂ: 'f',
1522 ǵ: 'g',
1523 ğ: 'g',
1524 ǧ: 'g',
1525 ģ: 'g',
1526 ĝ: 'g',
1527 ġ: 'g',
1528 ɠ: 'g',
1529 ḡ: 'g',
1530 ᶃ: 'g',
1531 ǥ: 'g',
1532 ḫ: 'h',
1533 ȟ: 'h',
1534 ḩ: 'h',
1535 ĥ: 'h',
1536 ⱨ: 'h',
1537 ḧ: 'h',
1538 ḣ: 'h',
1539 ḥ: 'h',
1540 ɦ: 'h',
1541 ẖ: 'h',
1542 ħ: 'h',
1543 ƕ: 'hv',
1544 í: 'i',
1545 ĭ: 'i',
1546 ǐ: 'i',
1547 î: 'i',
1548 ï: 'i',
1549 ḯ: 'i',
1550 ị: 'i',
1551 ȉ: 'i',
1552 ì: 'i',
1553 ỉ: 'i',
1554 ȋ: 'i',
1555 ī: 'i',
1556 į: 'i',
1557 ᶖ: 'i',
1558 ɨ: 'i',
1559 ĩ: 'i',
1560 ḭ: 'i',
1561 ꝺ: 'd',
1562 ꝼ: 'f',
1563 ᵹ: 'g',
1564 ꞃ: 'r',
1565 ꞅ: 's',
1566 ꞇ: 't',
1567 ꝭ: 'is',
1568 ǰ: 'j',
1569 ĵ: 'j',
1570 ʝ: 'j',
1571 ɉ: 'j',
1572 ḱ: 'k',
1573 ǩ: 'k',
1574 ķ: 'k',
1575 ⱪ: 'k',
1576 ꝃ: 'k',
1577 ḳ: 'k',
1578 ƙ: 'k',
1579 ḵ: 'k',
1580 ᶄ: 'k',
1581 ꝁ: 'k',
1582 ꝅ: 'k',
1583 ĺ: 'l',
1584 ƚ: 'l',
1585 ɬ: 'l',
1586 ľ: 'l',
1587 ļ: 'l',
1588 ḽ: 'l',
1589 ȴ: 'l',
1590 ḷ: 'l',
1591 ḹ: 'l',
1592 ⱡ: 'l',
1593 ꝉ: 'l',
1594 ḻ: 'l',
1595 ŀ: 'l',
1596 ɫ: 'l',
1597 ᶅ: 'l',
1598 ɭ: 'l',
1599 ł: 'l',
1600 lj: 'lj',
1601 ſ: 's',
1602 ẜ: 's',
1603 ẛ: 's',
1604 ẝ: 's',
1605 ḿ: 'm',
1606 ṁ: 'm',
1607 ṃ: 'm',
1608 ɱ: 'm',
1609 ᵯ: 'm',
1610 ᶆ: 'm',
1611 ń: 'n',
1612 ň: 'n',
1613 ņ: 'n',
1614 ṋ: 'n',
1615 ȵ: 'n',
1616 ṅ: 'n',
1617 ṇ: 'n',
1618 ǹ: 'n',
1619 ɲ: 'n',
1620 ṉ: 'n',
1621 ƞ: 'n',
1622 ᵰ: 'n',
1623 ᶇ: 'n',
1624 ɳ: 'n',
1625 ñ: 'n',
1626 nj: 'nj',
1627 ó: 'o',
1628 ŏ: 'o',
1629 ǒ: 'o',
1630 ô: 'o',
1631 ố: 'o',
1632 ộ: 'o',
1633 ồ: 'o',
1634 ổ: 'o',
1635 ỗ: 'o',
1636 ö: 'o',
1637 ȫ: 'o',
1638 ȯ: 'o',
1639 ȱ: 'o',
1640 ọ: 'o',
1641 ő: 'o',
1642 ȍ: 'o',
1643 ò: 'o',
1644 ỏ: 'o',
1645 ơ: 'o',
1646 ớ: 'o',
1647 ợ: 'o',
1648 ờ: 'o',
1649 ở: 'o',
1650 ỡ: 'o',
1651 ȏ: 'o',
1652 ꝋ: 'o',
1653 ꝍ: 'o',
1654 ⱺ: 'o',
1655 ō: 'o',
1656 ṓ: 'o',
1657 ṑ: 'o',
1658 ǫ: 'o',
1659 ǭ: 'o',
1660 ø: 'o',
1661 ǿ: 'o',
1662 õ: 'o',
1663 ṍ: 'o',
1664 ṏ: 'o',
1665 ȭ: 'o',
1666 ƣ: 'oi',
1667 ꝏ: 'oo',
1668 ɛ: 'e',
1669 ᶓ: 'e',
1670 ɔ: 'o',
1671 ᶗ: 'o',
1672 ȣ: 'ou',
1673 ṕ: 'p',
1674 ṗ: 'p',
1675 ꝓ: 'p',
1676 ƥ: 'p',
1677 ᵱ: 'p',
1678 ᶈ: 'p',
1679 ꝕ: 'p',
1680 ᵽ: 'p',
1681 ꝑ: 'p',
1682 ꝙ: 'q',
1683 ʠ: 'q',
1684 ɋ: 'q',
1685 ꝗ: 'q',
1686 ŕ: 'r',
1687 ř: 'r',
1688 ŗ: 'r',
1689 ṙ: 'r',
1690 ṛ: 'r',
1691 ṝ: 'r',
1692 ȑ: 'r',
1693 ɾ: 'r',
1694 ᵳ: 'r',
1695 ȓ: 'r',
1696 ṟ: 'r',
1697 ɼ: 'r',
1698 ᵲ: 'r',
1699 ᶉ: 'r',
1700 ɍ: 'r',
1701 ɽ: 'r',
1702 ↄ: 'c',
1703 ꜿ: 'c',
1704 ɘ: 'e',
1705 ɿ: 'r',
1706 ś: 's',
1707 ṥ: 's',
1708 š: 's',
1709 ṧ: 's',
1710 ş: 's',
1711 ŝ: 's',
1712 ș: 's',
1713 ṡ: 's',
1714 ṣ: 's',
1715 ṩ: 's',
1716 ʂ: 's',
1717 ᵴ: 's',
1718 ᶊ: 's',
1719 ȿ: 's',
1720 ɡ: 'g',
1721 ß: 'ss',
1722 ᴑ: 'o',
1723 ᴓ: 'o',
1724 ᴝ: 'u',
1725 ť: 't',
1726 ţ: 't',
1727 ṱ: 't',
1728 ț: 't',
1729 ȶ: 't',
1730 ẗ: 't',
1731 ⱦ: 't',
1732 ṫ: 't',
1733 ṭ: 't',
1734 ƭ: 't',
1735 ṯ: 't',
1736 ᵵ: 't',
1737 ƫ: 't',
1738 ʈ: 't',
1739 ŧ: 't',
1740 ᵺ: 'th',
1741 ɐ: 'a',
1742 ᴂ: 'ae',
1743 ǝ: 'e',
1744 ᵷ: 'g',
1745 ɥ: 'h',
1746 ʮ: 'h',
1747 ʯ: 'h',
1748 ᴉ: 'i',
1749 ʞ: 'k',
1750 ꞁ: 'l',
1751 ɯ: 'm',
1752 ɰ: 'm',
1753 ᴔ: 'oe',
1754 ɹ: 'r',
1755 ɻ: 'r',
1756 ɺ: 'r',
1757 ⱹ: 'r',
1758 ʇ: 't',
1759 ʌ: 'v',
1760 ʍ: 'w',
1761 ʎ: 'y',
1762 ꜩ: 'tz',
1763 ú: 'u',
1764 ŭ: 'u',
1765 ǔ: 'u',
1766 û: 'u',
1767 ṷ: 'u',
1768 ü: 'u',
1769 ǘ: 'u',
1770 ǚ: 'u',
1771 ǜ: 'u',
1772 ǖ: 'u',
1773 ṳ: 'u',
1774 ụ: 'u',
1775 ű: 'u',
1776 ȕ: 'u',
1777 ù: 'u',
1778 ủ: 'u',
1779 ư: 'u',
1780 ứ: 'u',
1781 ự: 'u',
1782 ừ: 'u',
1783 ử: 'u',
1784 ữ: 'u',
1785 ȗ: 'u',
1786 ū: 'u',
1787 ṻ: 'u',
1788 ų: 'u',
1789 ᶙ: 'u',
1790 ů: 'u',
1791 ũ: 'u',
1792 ṹ: 'u',
1793 ṵ: 'u',
1794 ᵫ: 'ue',
1795 ꝸ: 'um',
1796 ⱴ: 'v',
1797 ꝟ: 'v',
1798 ṿ: 'v',
1799 ʋ: 'v',
1800 ᶌ: 'v',
1801 ⱱ: 'v',
1802 ṽ: 'v',
1803 ꝡ: 'vy',
1804 ẃ: 'w',
1805 ŵ: 'w',
1806 ẅ: 'w',
1807 ẇ: 'w',
1808 ẉ: 'w',
1809 ẁ: 'w',
1810 ⱳ: 'w',
1811 ẘ: 'w',
1812 ẍ: 'x',
1813 ẋ: 'x',
1814 ᶍ: 'x',
1815 ý: 'y',
1816 ŷ: 'y',
1817 ÿ: 'y',
1818 ẏ: 'y',
1819 ỵ: 'y',
1820 ỳ: 'y',
1821 ƴ: 'y',
1822 ỷ: 'y',
1823 ỿ: 'y',
1824 ȳ: 'y',
1825 ẙ: 'y',
1826 ɏ: 'y',
1827 ỹ: 'y',
1828 ź: 'z',
1829 ž: 'z',
1830 ẑ: 'z',
1831 ʑ: 'z',
1832 ⱬ: 'z',
1833 ż: 'z',
1834 ẓ: 'z',
1835 ȥ: 'z',
1836 ẕ: 'z',
1837 ᵶ: 'z',
1838 ᶎ: 'z',
1839 ʐ: 'z',
1840 ƶ: 'z',
1841 ɀ: 'z',
1842 ff: 'ff',
1843 ffi: 'ffi',
1844 ffl: 'ffl',
1845 fi: 'fi',
1846 fl: 'fl',
1847 ij: 'ij',
1848 œ: 'oe',
1849 st: 'st',
1850 ₐ: 'a',
1851 ₑ: 'e',
1852 ᵢ: 'i',
1853 ⱼ: 'j',
1854 ₒ: 'o',
1855 ᵣ: 'r',
1856 ᵤ: 'u',
1857 ᵥ: 'v',
1858 ₓ: 'x',
1859 };
1860 }
1861 LatinisePipe.prototype.transform = function (text, chars) {
1862 var _this = this;
1863 return isString(text)
1864 ? text.replace(/[^A-Za-z0-9]/g, function (key) {
1865 return _this.latinMap[key] || key;
1866 })
1867 : text;
1868 };
1869 LatinisePipe = __decorate([
1870 Pipe({ name: 'latinise' })
1871 ], LatinisePipe);
1872 return LatinisePipe;
1873}());
1874
1875var LinesPipe = /** @class */ (function () {
1876 function LinesPipe() {
1877 }
1878 LinesPipe.prototype.transform = function (text, chars) {
1879 return isString(text) ? text.replace(/\r\n/g, '\n').split('\n') : text;
1880 };
1881 LinesPipe = __decorate([
1882 Pipe({ name: 'lines' })
1883 ], LinesPipe);
1884 return LinesPipe;
1885}());
1886
1887var UnderscorePipe = /** @class */ (function () {
1888 function UnderscorePipe() {
1889 }
1890 UnderscorePipe.prototype.transform = function (text, chars) {
1891 return isString(text)
1892 ? text
1893 .trim()
1894 .replace(/\s+/g, '')
1895 .replace(/[A-Z]/g, function (c, k) {
1896 return k ? "_" + c.toLowerCase() : c.toLowerCase();
1897 })
1898 : text;
1899 };
1900 UnderscorePipe = __decorate([
1901 Pipe({ name: 'underscore' })
1902 ], UnderscorePipe);
1903 return UnderscorePipe;
1904}());
1905
1906var MatchPipe = /** @class */ (function () {
1907 function MatchPipe() {
1908 }
1909 MatchPipe.prototype.transform = function (text, pattern, flags) {
1910 if (!isString(text)) {
1911 return text;
1912 }
1913 return text.match(new RegExp(pattern, flags));
1914 };
1915 MatchPipe = __decorate([
1916 Pipe({ name: 'match' })
1917 ], MatchPipe);
1918 return MatchPipe;
1919}());
1920
1921var TestPipe = /** @class */ (function () {
1922 function TestPipe() {
1923 }
1924 TestPipe.prototype.transform = function (text, pattern, flags) {
1925 if (!isString(text)) {
1926 return text;
1927 }
1928 return new RegExp(pattern, flags).test(text);
1929 };
1930 TestPipe = __decorate([
1931 Pipe({ name: 'test' })
1932 ], TestPipe);
1933 return TestPipe;
1934}());
1935
1936var LeftPadPipe = /** @class */ (function () {
1937 function LeftPadPipe() {
1938 }
1939 LeftPadPipe.prototype.transform = function (str, length, padCharacter) {
1940 if (padCharacter === void 0) { padCharacter = ' '; }
1941 if (!isString(str) || str.length >= length) {
1942 return str;
1943 }
1944 while (str.length < length) {
1945 str = padCharacter + str;
1946 }
1947 return str;
1948 };
1949 LeftPadPipe = __decorate([
1950 Pipe({ name: 'lpad' })
1951 ], LeftPadPipe);
1952 return LeftPadPipe;
1953}());
1954
1955var RightPadPipe = /** @class */ (function () {
1956 function RightPadPipe() {
1957 }
1958 RightPadPipe.prototype.transform = function (str, length, padCharacter) {
1959 if (length === void 0) { length = 1; }
1960 if (padCharacter === void 0) { padCharacter = ' '; }
1961 if (!isString(str) || str.length >= length) {
1962 return str;
1963 }
1964 while (str.length < length) {
1965 str = str + padCharacter;
1966 }
1967 return str;
1968 };
1969 RightPadPipe = __decorate([
1970 Pipe({ name: 'rpad' })
1971 ], RightPadPipe);
1972 return RightPadPipe;
1973}());
1974
1975var MakePluralStringPipe = /** @class */ (function () {
1976 function MakePluralStringPipe() {
1977 this.irregularMap = {
1978 addendum: 'addenda',
1979 alga: 'algae',
1980 alumna: 'alumnae',
1981 alumnus: 'alumni',
1982 analysis: 'analyses',
1983 antenna: 'antennae',
1984 appendix: 'appendices',
1985 aquarium: 'aquaria',
1986 arch: 'arches',
1987 axe: 'axes',
1988 axis: 'axes',
1989 bacillus: 'bacilli',
1990 bacterium: 'bacteria',
1991 basis: 'bases',
1992 batch: 'batches',
1993 beach: 'beaches',
1994 beau: 'beaux',
1995 bison: 'bison',
1996 brush: 'brushes',
1997 buffalo: 'buffaloes',
1998 bureau: 'bureaus',
1999 bus: 'busses',
2000 cactus: 'cacti',
2001 calf: 'calves',
2002 chateau: 'chateaux',
2003 cherry: 'cherries',
2004 child: 'children',
2005 church: 'churches',
2006 circus: 'circuses',
2007 cod: 'cod',
2008 corps: 'corps',
2009 corpus: 'corpora',
2010 crisis: 'crises',
2011 criterion: 'criteria',
2012 curriculum: 'curricula',
2013 datum: 'data',
2014 deer: 'deer',
2015 diagnosis: 'diagnoses',
2016 die: 'dice',
2017 domino: 'dominoes',
2018 dwarf: 'dwarves',
2019 echo: 'echoes',
2020 elf: 'elves',
2021 ellipsis: 'ellipses',
2022 embargo: 'embargoes',
2023 emphasis: 'emphases',
2024 erratum: 'errata',
2025 fax: 'faxes',
2026 fireman: 'firemen',
2027 fish: 'fish',
2028 flush: 'flushes',
2029 focus: 'foci',
2030 foot: 'feet',
2031 formula: 'formulas',
2032 fungus: 'fungi',
2033 genus: 'genera',
2034 goose: 'geese',
2035 grafito: 'grafiti',
2036 half: 'halves',
2037 hero: 'heroes',
2038 hoax: 'hoaxes',
2039 hoof: 'hooves',
2040 hypothesis: 'hypotheses',
2041 index: 'indices',
2042 kiss: 'kisses',
2043 knife: 'knives',
2044 leaf: 'leaves',
2045 life: 'lives',
2046 loaf: 'loaves',
2047 louse: 'lice',
2048 man: 'men',
2049 mango: 'mangoes',
2050 matrix: 'matrices',
2051 means: 'means',
2052 medium: 'media',
2053 memorandum: 'memoranda',
2054 millennium: 'milennia',
2055 moose: 'moose',
2056 mosquito: 'mosquitoes',
2057 motto: 'mottoes',
2058 mouse: 'mice',
2059 nebula: 'nebulae',
2060 neurosis: 'neuroses',
2061 nucleus: 'nuclei',
2062 oasis: 'oases',
2063 octopus: 'octopodes',
2064 ovum: 'ova',
2065 ox: 'oxen',
2066 paralysis: 'paralyses',
2067 parenthesis: 'parentheses',
2068 person: 'people',
2069 phenomenon: 'phenomena',
2070 plateau: 'plateaux',
2071 potato: 'potatoes',
2072 quiz: 'quizzes',
2073 radius: 'radii',
2074 reflex: 'reflexes',
2075 'runner-up': 'runners-up',
2076 scampo: 'scampi',
2077 scarf: 'scarves',
2078 scissors: 'scissors',
2079 scratch: 'scratches',
2080 self: 'selves',
2081 series: 'series',
2082 sheaf: 'sheaves',
2083 sheep: 'sheep',
2084 shelf: 'shelves',
2085 'son-in-law': 'sons-in-law',
2086 species: 'species',
2087 splash: 'splashes',
2088 stimulus: 'stimuli',
2089 stitch: 'stitches',
2090 stratum: 'strata',
2091 syllabus: 'syllabi',
2092 symposium: 'symposia',
2093 synopsis: 'synopses',
2094 synthesis: 'syntheses',
2095 tableau: 'tableaux',
2096 tax: 'taxes',
2097 that: 'those',
2098 thesis: 'theses',
2099 thief: 'thieves',
2100 this: 'these',
2101 tomato: 'tomatoes',
2102 tooth: 'teeth',
2103 tornado: 'tornadoes',
2104 torpedo: 'torpedoes',
2105 vertebra: 'vertebrae',
2106 veto: 'vetoes',
2107 vita: 'vitae',
2108 volcano: 'volcanoes',
2109 waltz: 'waltzes',
2110 wash: 'washes',
2111 watch: 'watches',
2112 wharf: 'wharves',
2113 wife: 'wives',
2114 wolf: 'wolves',
2115 woman: 'women',
2116 zero: 'zeroes',
2117 };
2118 }
2119 MakePluralStringPipe.prototype.transform = function (singularEntity, quantity) {
2120 if (quantity === void 0) { quantity = 0; }
2121 if (!singularEntity || singularEntity === '') {
2122 return '';
2123 }
2124 if (quantity === 1) {
2125 return singularEntity;
2126 }
2127 else {
2128 var lastWord = singularEntity.trim().split(' ')[singularEntity.trim().split(' ').length - 1];
2129 if (this.irregularMap[lastWord.toLocaleLowerCase()]) {
2130 if (lastWord[0] === lastWord[0].toLocaleUpperCase()) {
2131 return singularEntity.replace(lastWord, this.irregularMap[lastWord.toLocaleLowerCase()].replace(this.irregularMap[lastWord.toLocaleLowerCase()][0], this.irregularMap[lastWord.toLocaleLowerCase()][0].toLocaleUpperCase()));
2132 }
2133 return singularEntity.replace(lastWord, this.irregularMap[lastWord.toLocaleLowerCase()]);
2134 }
2135 else if (lastWord[lastWord.length - 1] === 'y') {
2136 // Naive approach:
2137 // consonant+y = word - 'y' +'ies'
2138 // vowel+y = word + 's'
2139 return isVowel(lastWord[lastWord.length - 2])
2140 ? singularEntity + 's'
2141 : singularEntity.replace(lastWord, lastWord.slice(0, -1) + 'ies');
2142 }
2143 else if (lastWord[lastWord.length - 1] === 's') {
2144 return singularEntity + 'es';
2145 }
2146 else {
2147 return singularEntity + 's';
2148 }
2149 }
2150 };
2151 MakePluralStringPipe = __decorate([
2152 Pipe({
2153 name: 'makePluralString',
2154 })
2155 /**
2156 * Takes a singular entity string and pluralizes it.
2157 * Uses both naive and holdout-list approaches.
2158 * If several words appear in the string, only the last word is pluralized -- this
2159 * means that if "your story" was passed in, "your stories" would be passed out.
2160 *
2161 * @param {string} singularEntity - Entity to pluralize. Pass as a singular ('story' or 'house').
2162 * NOTE: The last word is examined. So you can pass in e.g. 'my story'.
2163 * @param {number} [quantity=0] quantity - How many of the entity are there? If left blank, this will
2164 * pluralize the string (e.g. 'story' -> 'stories', 'house' -> 'houses'). If given a value,
2165 * this will pluralize appropriately (e.g. ('story', 1) -> 'story', ('story', 2) -> 'stories').
2166 */
2167 ], MakePluralStringPipe);
2168 return MakePluralStringPipe;
2169}());
2170
2171var WrapPipe = /** @class */ (function () {
2172 function WrapPipe() {
2173 }
2174 WrapPipe.prototype.transform = function (str, prefix, suffix) {
2175 if (prefix === void 0) { prefix = ''; }
2176 if (suffix === void 0) { suffix = ''; }
2177 if (!isString(str)) {
2178 return str;
2179 }
2180 return (!!prefix && isString(prefix) ? prefix : '') + str + (!!suffix && isString(suffix) ? suffix : '');
2181 };
2182 WrapPipe = __decorate([
2183 Pipe({ name: 'wrap' })
2184 ], WrapPipe);
2185 return WrapPipe;
2186}());
2187
2188var STRING_PIPES = [
2189 AorAnPipe,
2190 LeftTrimPipe,
2191 RepeatPipe,
2192 RightTrimPipe,
2193 ScanPipe,
2194 ShortenPipe,
2195 StripTagsPipe,
2196 TrimPipe,
2197 UcFirstPipe,
2198 UcWordsPipe,
2199 SlugifyPipe,
2200 CamelizePipe,
2201 LatinisePipe,
2202 LinesPipe,
2203 UnderscorePipe,
2204 MatchPipe,
2205 TestPipe,
2206 LeftPadPipe,
2207 RightPadPipe,
2208 MakePluralStringPipe,
2209 WrapPipe,
2210];
2211var NgStringPipesModule = /** @class */ (function () {
2212 function NgStringPipesModule() {
2213 }
2214 NgStringPipesModule = __decorate([
2215 NgModule({
2216 declarations: STRING_PIPES,
2217 imports: [],
2218 exports: STRING_PIPES,
2219 })
2220 ], NgStringPipesModule);
2221 return NgStringPipesModule;
2222}());
2223
2224var MaxPipe = /** @class */ (function () {
2225 function MaxPipe() {
2226 }
2227 MaxPipe.prototype.transform = function (arr) {
2228 return Array.isArray(arr) ? Math.max.apply(Math, __spread(arr)) : arr;
2229 };
2230 MaxPipe = __decorate([
2231 Pipe({ name: 'max' })
2232 ], MaxPipe);
2233 return MaxPipe;
2234}());
2235
2236var MinPipe = /** @class */ (function () {
2237 function MinPipe() {
2238 }
2239 MinPipe.prototype.transform = function (arr) {
2240 return Array.isArray(arr) ? Math.min.apply(Math, __spread(arr)) : arr;
2241 };
2242 MinPipe = __decorate([
2243 Pipe({ name: 'min' })
2244 ], MinPipe);
2245 return MinPipe;
2246}());
2247
2248var PercentagePipe = /** @class */ (function () {
2249 function PercentagePipe() {
2250 }
2251 PercentagePipe.prototype.transform = function (num, total, floor) {
2252 if (total === void 0) { total = 100; }
2253 if (floor === void 0) { floor = false; }
2254 if (isNaN(num)) {
2255 return num;
2256 }
2257 var percent = (num * 100) / total;
2258 return floor ? Math.floor(percent) : percent;
2259 };
2260 PercentagePipe = __decorate([
2261 Pipe({ name: 'percentage' })
2262 ], PercentagePipe);
2263 return PercentagePipe;
2264}());
2265
2266var SumPipe = /** @class */ (function () {
2267 function SumPipe() {
2268 }
2269 SumPipe.prototype.transform = function (arr) {
2270 return Array.isArray(arr) ? arr.reduce(function (sum, curr) { return sum + curr; }, 0) : arr;
2271 };
2272 SumPipe = __decorate([
2273 Pipe({ name: 'sum' })
2274 ], SumPipe);
2275 return SumPipe;
2276}());
2277
2278var FloorPipe = /** @class */ (function () {
2279 function FloorPipe() {
2280 }
2281 FloorPipe.prototype.transform = function (num, precision) {
2282 if (precision === void 0) { precision = 0; }
2283 if (precision <= 0) {
2284 return Math.floor(num);
2285 }
2286 var tho = Math.pow(10, precision);
2287 return Math.floor(num * tho) / tho;
2288 };
2289 FloorPipe = __decorate([
2290 Pipe({ name: 'floor' })
2291 ], FloorPipe);
2292 return FloorPipe;
2293}());
2294
2295var RoundPipe = /** @class */ (function () {
2296 function RoundPipe() {
2297 }
2298 RoundPipe.prototype.transform = function (num, precision) {
2299 if (precision === void 0) { precision = 0; }
2300 return applyPrecision(num, precision);
2301 };
2302 RoundPipe = __decorate([
2303 Pipe({ name: 'round' })
2304 ], RoundPipe);
2305 return RoundPipe;
2306}());
2307
2308var SqrtPipe = /** @class */ (function () {
2309 function SqrtPipe() {
2310 }
2311 SqrtPipe.prototype.transform = function (num) {
2312 return !isNaN(num) ? Math.sqrt(num) : num;
2313 };
2314 SqrtPipe = __decorate([
2315 Pipe({ name: 'sqrt' })
2316 ], SqrtPipe);
2317 return SqrtPipe;
2318}());
2319
2320var PowerPipe = /** @class */ (function () {
2321 function PowerPipe() {
2322 }
2323 PowerPipe.prototype.transform = function (num, power) {
2324 if (power === void 0) { power = 2; }
2325 return !isNaN(num) ? Math.pow(num, power) : num;
2326 };
2327 PowerPipe = __decorate([
2328 Pipe({ name: 'pow' })
2329 ], PowerPipe);
2330 return PowerPipe;
2331}());
2332
2333var CeilPipe = /** @class */ (function () {
2334 function CeilPipe() {
2335 }
2336 CeilPipe.prototype.transform = function (num, precision) {
2337 if (precision === void 0) { precision = 0; }
2338 if (precision <= 0) {
2339 return Math.ceil(num);
2340 }
2341 var tho = Math.pow(10, precision);
2342 return Math.ceil(num * tho) / tho;
2343 };
2344 CeilPipe = __decorate([
2345 Pipe({ name: 'ceil' })
2346 ], CeilPipe);
2347 return CeilPipe;
2348}());
2349
2350var DegreesPipe = /** @class */ (function () {
2351 function DegreesPipe() {
2352 }
2353 DegreesPipe.prototype.transform = function (radians) {
2354 if (!isNumberFinite(radians)) {
2355 return NaN;
2356 }
2357 return (radians * 180) / Math.PI;
2358 };
2359 DegreesPipe = __decorate([
2360 Pipe({ name: 'degrees' })
2361 ], DegreesPipe);
2362 return DegreesPipe;
2363}());
2364
2365var BytesPipe = /** @class */ (function () {
2366 function BytesPipe() {
2367 this.dictionary = [
2368 { max: 1024, type: 'B' },
2369 { max: 1048576, type: 'KB' },
2370 { max: 1073741824, type: 'MB' },
2371 { max: 1.0995116e12, type: 'GB' },
2372 ];
2373 }
2374 BytesPipe.prototype.transform = function (value, precision) {
2375 if (!isNumberFinite(value)) {
2376 return NaN;
2377 }
2378 var format = this.dictionary.find(function (d) { return value < d.max; }) || this.dictionary[this.dictionary.length - 1];
2379 var calc = value / (format.max / 1024);
2380 var num = isUndefined(precision) ? calc : applyPrecision(calc, precision);
2381 return num + " " + format.type;
2382 };
2383 BytesPipe = __decorate([
2384 Pipe({ name: 'bytes' })
2385 ], BytesPipe);
2386 return BytesPipe;
2387}());
2388
2389var RadiansPipe = /** @class */ (function () {
2390 function RadiansPipe() {
2391 }
2392 RadiansPipe.prototype.transform = function (degrees) {
2393 if (!isNumberFinite(degrees)) {
2394 return NaN;
2395 }
2396 return (degrees * Math.PI) / 180;
2397 };
2398 RadiansPipe = __decorate([
2399 Pipe({ name: 'radians' })
2400 ], RadiansPipe);
2401 return RadiansPipe;
2402}());
2403
2404var MATH_PIPES = [
2405 MaxPipe,
2406 MinPipe,
2407 PercentagePipe,
2408 SumPipe,
2409 FloorPipe,
2410 RoundPipe,
2411 SqrtPipe,
2412 PowerPipe,
2413 CeilPipe,
2414 DegreesPipe,
2415 BytesPipe,
2416 RadiansPipe,
2417];
2418var NgMathPipesModule = /** @class */ (function () {
2419 function NgMathPipesModule() {
2420 }
2421 NgMathPipesModule = __decorate([
2422 NgModule({
2423 declarations: MATH_PIPES,
2424 imports: [],
2425 exports: MATH_PIPES,
2426 })
2427 ], NgMathPipesModule);
2428 return NgMathPipesModule;
2429}());
2430
2431var IsDefinedPipe = /** @class */ (function () {
2432 function IsDefinedPipe() {
2433 }
2434 IsDefinedPipe.prototype.transform = function (input) {
2435 return !isUndefined(input);
2436 };
2437 IsDefinedPipe = __decorate([
2438 Pipe({ name: 'isDefined' })
2439 ], IsDefinedPipe);
2440 return IsDefinedPipe;
2441}());
2442
2443var IsNullPipe = /** @class */ (function () {
2444 function IsNullPipe() {
2445 }
2446 IsNullPipe.prototype.transform = function (input) {
2447 return input === null;
2448 };
2449 IsNullPipe = __decorate([
2450 Pipe({ name: 'isNull' })
2451 ], IsNullPipe);
2452 return IsNullPipe;
2453}());
2454
2455var IsUndefinedPipe = /** @class */ (function () {
2456 function IsUndefinedPipe() {
2457 }
2458 IsUndefinedPipe.prototype.transform = function (input) {
2459 return isUndefined(input);
2460 };
2461 IsUndefinedPipe = __decorate([
2462 Pipe({ name: 'isUndefined' })
2463 ], IsUndefinedPipe);
2464 return IsUndefinedPipe;
2465}());
2466
2467var IsStringPipe = /** @class */ (function () {
2468 function IsStringPipe() {
2469 }
2470 IsStringPipe.prototype.transform = function (input) {
2471 return isString(input);
2472 };
2473 IsStringPipe = __decorate([
2474 Pipe({ name: 'isString' })
2475 ], IsStringPipe);
2476 return IsStringPipe;
2477}());
2478
2479var IsFunctionPipe = /** @class */ (function () {
2480 function IsFunctionPipe() {
2481 }
2482 IsFunctionPipe.prototype.transform = function (input) {
2483 return isFunction(input);
2484 };
2485 IsFunctionPipe = __decorate([
2486 Pipe({ name: 'isFunction' })
2487 ], IsFunctionPipe);
2488 return IsFunctionPipe;
2489}());
2490
2491var IsNumberPipe = /** @class */ (function () {
2492 function IsNumberPipe() {
2493 }
2494 IsNumberPipe.prototype.transform = function (input) {
2495 return isNumber(input);
2496 };
2497 IsNumberPipe = __decorate([
2498 Pipe({ name: 'isNumber' })
2499 ], IsNumberPipe);
2500 return IsNumberPipe;
2501}());
2502
2503var IsArrayPipe = /** @class */ (function () {
2504 function IsArrayPipe() {
2505 }
2506 IsArrayPipe.prototype.transform = function (input) {
2507 return Array.isArray(input);
2508 };
2509 IsArrayPipe = __decorate([
2510 Pipe({ name: 'isArray' })
2511 ], IsArrayPipe);
2512 return IsArrayPipe;
2513}());
2514
2515var IsObjectPipe = /** @class */ (function () {
2516 function IsObjectPipe() {
2517 }
2518 IsObjectPipe.prototype.transform = function (input) {
2519 return isObject(input);
2520 };
2521 IsObjectPipe = __decorate([
2522 Pipe({ name: 'isObject' })
2523 ], IsObjectPipe);
2524 return IsObjectPipe;
2525}());
2526
2527var IsGreaterEqualThanPipe = /** @class */ (function () {
2528 function IsGreaterEqualThanPipe() {
2529 }
2530 IsGreaterEqualThanPipe.prototype.transform = function (input, other) {
2531 return input >= other;
2532 };
2533 IsGreaterEqualThanPipe = __decorate([
2534 Pipe({ name: 'isGreaterEqualThan' })
2535 ], IsGreaterEqualThanPipe);
2536 return IsGreaterEqualThanPipe;
2537}());
2538
2539var IsGreaterThanPipe = /** @class */ (function () {
2540 function IsGreaterThanPipe() {
2541 }
2542 IsGreaterThanPipe.prototype.transform = function (input, other) {
2543 return input > other;
2544 };
2545 IsGreaterThanPipe = __decorate([
2546 Pipe({ name: 'isGreaterThan' })
2547 ], IsGreaterThanPipe);
2548 return IsGreaterThanPipe;
2549}());
2550
2551var IsLessEqualThanPipe = /** @class */ (function () {
2552 function IsLessEqualThanPipe() {
2553 }
2554 IsLessEqualThanPipe.prototype.transform = function (input, other) {
2555 return input <= other;
2556 };
2557 IsLessEqualThanPipe = __decorate([
2558 Pipe({ name: 'isLessEqualThan' })
2559 ], IsLessEqualThanPipe);
2560 return IsLessEqualThanPipe;
2561}());
2562
2563var IsEqualToPipe = /** @class */ (function () {
2564 function IsEqualToPipe() {
2565 }
2566 IsEqualToPipe.prototype.transform = function (input, other) {
2567 // tslint:disable-next-line:triple-equals
2568 return input == other;
2569 };
2570 IsEqualToPipe = __decorate([
2571 Pipe({ name: 'isEqualTo' })
2572 ], IsEqualToPipe);
2573 return IsEqualToPipe;
2574}());
2575
2576var IsNotEqualToPipe = /** @class */ (function () {
2577 function IsNotEqualToPipe() {
2578 }
2579 IsNotEqualToPipe.prototype.transform = function (input, other) {
2580 // tslint:disable-next-line:triple-equals
2581 return input != other;
2582 };
2583 IsNotEqualToPipe = __decorate([
2584 Pipe({ name: 'isNotEqualTo' })
2585 ], IsNotEqualToPipe);
2586 return IsNotEqualToPipe;
2587}());
2588
2589var IsIdenticalToPipe = /** @class */ (function () {
2590 function IsIdenticalToPipe() {
2591 }
2592 IsIdenticalToPipe.prototype.transform = function (input, other) {
2593 return input === other;
2594 };
2595 IsIdenticalToPipe = __decorate([
2596 Pipe({ name: 'isIdenticalTo' })
2597 ], IsIdenticalToPipe);
2598 return IsIdenticalToPipe;
2599}());
2600
2601var IsNotIdenticalToPipe = /** @class */ (function () {
2602 function IsNotIdenticalToPipe() {
2603 }
2604 IsNotIdenticalToPipe.prototype.transform = function (input, other) {
2605 return input !== other;
2606 };
2607 IsNotIdenticalToPipe = __decorate([
2608 Pipe({ name: 'isNotIdenticalTo' })
2609 ], IsNotIdenticalToPipe);
2610 return IsNotIdenticalToPipe;
2611}());
2612
2613var IsLessThanPipe = /** @class */ (function () {
2614 function IsLessThanPipe() {
2615 }
2616 IsLessThanPipe.prototype.transform = function (input, other) {
2617 return input < other;
2618 };
2619 IsLessThanPipe = __decorate([
2620 Pipe({ name: 'isLessThan' })
2621 ], IsLessThanPipe);
2622 return IsLessThanPipe;
2623}());
2624
2625var BOOLEAN_PIPES = [
2626 IsDefinedPipe,
2627 IsNullPipe,
2628 IsUndefinedPipe,
2629 IsStringPipe,
2630 IsFunctionPipe,
2631 IsNumberPipe,
2632 IsArrayPipe,
2633 IsObjectPipe,
2634 IsGreaterEqualThanPipe,
2635 IsGreaterThanPipe,
2636 IsLessEqualThanPipe,
2637 IsLessEqualThanPipe,
2638 IsEqualToPipe,
2639 IsNotEqualToPipe,
2640 IsIdenticalToPipe,
2641 IsNotIdenticalToPipe,
2642 IsLessThanPipe,
2643];
2644var NgBooleanPipesModule = /** @class */ (function () {
2645 function NgBooleanPipesModule() {
2646 }
2647 NgBooleanPipesModule = __decorate([
2648 NgModule({
2649 declarations: BOOLEAN_PIPES,
2650 imports: [],
2651 exports: BOOLEAN_PIPES,
2652 })
2653 ], NgBooleanPipesModule);
2654 return NgBooleanPipesModule;
2655}());
2656
2657var TimeAgoPipe = /** @class */ (function () {
2658 function TimeAgoPipe() {
2659 }
2660 TimeAgoPipe_1 = TimeAgoPipe;
2661 /**
2662 * @param inputDate: Date | Moment - not included as TypeScript interface,
2663 * in order to keep `ngx-pipes` "pure" from dependencies!
2664 */
2665 TimeAgoPipe.prototype.transform = function (inputDate) {
2666 if (!inputDate || (!inputDate.getTime && !inputDate.toDate)) {
2667 return 'Invalid date';
2668 }
2669 var past = inputDate.toDate ? inputDate.toDate() : inputDate.getTime();
2670 var now = +new Date();
2671 if (past > now) {
2672 return 'in the future';
2673 }
2674 for (var i = 0, l = TimeAgoPipe_1.MAPPER.length, ms = now - past, div = TimeAgoPipe_1.YEAR_MS; i < l; ++i) {
2675 var elm = TimeAgoPipe_1.MAPPER[i];
2676 var unit = Math.floor(ms / (div /= elm.div));
2677 if (unit >= 1) {
2678 return unit === 1 ? elm.single : unit + " " + elm.many + " ago";
2679 }
2680 }
2681 return 'just now';
2682 };
2683 var TimeAgoPipe_1;
2684 TimeAgoPipe.YEAR_MS = 1000 * 60 * 60 * 24 * 7 * 4 * 12;
2685 TimeAgoPipe.MAPPER = [
2686 { single: 'last year', many: 'years', div: 1 },
2687 { single: 'last month', many: 'months', div: 12 },
2688 { single: 'last week', many: 'weeks', div: 4 },
2689 { single: 'yesterday', many: 'days', div: 7 },
2690 { single: 'an hour ago', many: 'hours', div: 24 },
2691 { single: 'just now', many: 'minutes', div: 60 },
2692 ];
2693 TimeAgoPipe = TimeAgoPipe_1 = __decorate([
2694 Pipe({ name: 'timeAgo' })
2695 ], TimeAgoPipe);
2696 return TimeAgoPipe;
2697}());
2698
2699var DATE_PIPES = [TimeAgoPipe];
2700var NgDatePipesModule = /** @class */ (function () {
2701 function NgDatePipesModule() {
2702 }
2703 NgDatePipesModule = __decorate([
2704 NgModule({
2705 declarations: DATE_PIPES,
2706 imports: [],
2707 exports: DATE_PIPES,
2708 })
2709 ], NgDatePipesModule);
2710 return NgDatePipesModule;
2711}());
2712
2713var NgPipesModule = /** @class */ (function () {
2714 function NgPipesModule() {
2715 }
2716 NgPipesModule = __decorate([
2717 NgModule({
2718 exports: [
2719 NgArrayPipesModule,
2720 NgStringPipesModule,
2721 NgMathPipesModule,
2722 NgBooleanPipesModule,
2723 NgObjectPipesModule,
2724 NgDatePipesModule,
2725 ],
2726 })
2727 ], NgPipesModule);
2728 return NgPipesModule;
2729}());
2730
2731export { 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 };
2732//# sourceMappingURL=ngx-pipes.js.map