source: trip-planner-front/node_modules/@angular/common/esm2015/src/pipes/keyvalue_pipe.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 12.5 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { KeyValueDiffers, Pipe } from '@angular/core';
9function makeKeyValuePair(key, value) {
10 return { key: key, value: value };
11}
12/**
13 * @ngModule CommonModule
14 * @description
15 *
16 * Transforms Object or Map into an array of key value pairs.
17 *
18 * The output array will be ordered by keys.
19 * By default the comparator will be by Unicode point value.
20 * You can optionally pass a compareFn if your keys are complex types.
21 *
22 * @usageNotes
23 * ### Examples
24 *
25 * This examples show how an Object or a Map can be iterated by ngFor with the use of this
26 * keyvalue pipe.
27 *
28 * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}
29 *
30 * @publicApi
31 */
32export class KeyValuePipe {
33 constructor(differs) {
34 this.differs = differs;
35 this.keyValues = [];
36 this.compareFn = defaultComparator;
37 }
38 transform(input, compareFn = defaultComparator) {
39 if (!input || (!(input instanceof Map) && typeof input !== 'object')) {
40 return null;
41 }
42 if (!this.differ) {
43 // make a differ for whatever type we've been passed in
44 this.differ = this.differs.find(input).create();
45 }
46 const differChanges = this.differ.diff(input);
47 const compareFnChanged = compareFn !== this.compareFn;
48 if (differChanges) {
49 this.keyValues = [];
50 differChanges.forEachItem((r) => {
51 this.keyValues.push(makeKeyValuePair(r.key, r.currentValue));
52 });
53 }
54 if (differChanges || compareFnChanged) {
55 this.keyValues.sort(compareFn);
56 this.compareFn = compareFn;
57 }
58 return this.keyValues;
59 }
60}
61KeyValuePipe.decorators = [
62 { type: Pipe, args: [{ name: 'keyvalue', pure: false },] }
63];
64KeyValuePipe.ctorParameters = () => [
65 { type: KeyValueDiffers }
66];
67export function defaultComparator(keyValueA, keyValueB) {
68 const a = keyValueA.key;
69 const b = keyValueB.key;
70 // if same exit with 0;
71 if (a === b)
72 return 0;
73 // make sure that undefined are at the end of the sort.
74 if (a === undefined)
75 return 1;
76 if (b === undefined)
77 return -1;
78 // make sure that nulls are at the end of the sort.
79 if (a === null)
80 return 1;
81 if (b === null)
82 return -1;
83 if (typeof a == 'string' && typeof b == 'string') {
84 return a < b ? -1 : 1;
85 }
86 if (typeof a == 'number' && typeof b == 'number') {
87 return a - b;
88 }
89 if (typeof a == 'boolean' && typeof b == 'boolean') {
90 return a < b ? -1 : 1;
91 }
92 // `a` and `b` are of different types. Compare their string values.
93 const aString = String(a);
94 const bString = String(b);
95 return aString == bString ? 0 : aString < bString ? -1 : 1;
96}
97//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia2V5dmFsdWVfcGlwZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbW1vbi9zcmMvcGlwZXMva2V5dmFsdWVfcGlwZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQXdELGVBQWUsRUFBRSxJQUFJLEVBQWdCLE1BQU0sZUFBZSxDQUFDO0FBRTFILFNBQVMsZ0JBQWdCLENBQU8sR0FBTSxFQUFFLEtBQVE7SUFDOUMsT0FBTyxFQUFDLEdBQUcsRUFBRSxHQUFHLEVBQUUsS0FBSyxFQUFFLEtBQUssRUFBQyxDQUFDO0FBQ2xDLENBQUM7QUFhRDs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQW1CRztBQUVILE1BQU0sT0FBTyxZQUFZO0lBQ3ZCLFlBQTZCLE9BQXdCO1FBQXhCLFlBQU8sR0FBUCxPQUFPLENBQWlCO1FBRzdDLGNBQVMsR0FBOEIsRUFBRSxDQUFDO1FBQzFDLGNBQVMsR0FBNkQsaUJBQWlCLENBQUM7SUFK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