source: trip-planner-front/node_modules/primeng/esm2020/utils/objectutils.mjs@ e29cc2e

Last change on this file since e29cc2e was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 19.8 KB
Line 
1export class ObjectUtils {
2 static equals(obj1, obj2, field) {
3 if (field)
4 return (this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field));
5 else
6 return this.equalsByValue(obj1, obj2);
7 }
8 static equalsByValue(obj1, obj2) {
9 if (obj1 === obj2)
10 return true;
11 if (obj1 && obj2 && typeof obj1 == 'object' && typeof obj2 == 'object') {
12 var arrA = Array.isArray(obj1), arrB = Array.isArray(obj2), i, length, key;
13 if (arrA && arrB) {
14 length = obj1.length;
15 if (length != obj2.length)
16 return false;
17 for (i = length; i-- !== 0;)
18 if (!this.equalsByValue(obj1[i], obj2[i]))
19 return false;
20 return true;
21 }
22 if (arrA != arrB)
23 return false;
24 var dateA = obj1 instanceof Date, dateB = obj2 instanceof Date;
25 if (dateA != dateB)
26 return false;
27 if (dateA && dateB)
28 return obj1.getTime() == obj2.getTime();
29 var regexpA = obj1 instanceof RegExp, regexpB = obj2 instanceof RegExp;
30 if (regexpA != regexpB)
31 return false;
32 if (regexpA && regexpB)
33 return obj1.toString() == obj2.toString();
34 var keys = Object.keys(obj1);
35 length = keys.length;
36 if (length !== Object.keys(obj2).length)
37 return false;
38 for (i = length; i-- !== 0;)
39 if (!Object.prototype.hasOwnProperty.call(obj2, keys[i]))
40 return false;
41 for (i = length; i-- !== 0;) {
42 key = keys[i];
43 if (!this.equalsByValue(obj1[key], obj2[key]))
44 return false;
45 }
46 return true;
47 }
48 return obj1 !== obj1 && obj2 !== obj2;
49 }
50 static resolveFieldData(data, field) {
51 if (data && field) {
52 if (this.isFunction(field)) {
53 return field(data);
54 }
55 else if (field.indexOf('.') == -1) {
56 return data[field];
57 }
58 else {
59 let fields = field.split('.');
60 let value = data;
61 for (let i = 0, len = fields.length; i < len; ++i) {
62 if (value == null) {
63 return null;
64 }
65 value = value[fields[i]];
66 }
67 return value;
68 }
69 }
70 else {
71 return null;
72 }
73 }
74 static isFunction(obj) {
75 return !!(obj && obj.constructor && obj.call && obj.apply);
76 }
77 static reorderArray(value, from, to) {
78 let target;
79 if (value && from !== to) {
80 if (to >= value.length) {
81 to %= value.length;
82 from %= value.length;
83 }
84 value.splice(to, 0, value.splice(from, 1)[0]);
85 }
86 }
87 static insertIntoOrderedArray(item, index, arr, sourceArr) {
88 if (arr.length > 0) {
89 let injected = false;
90 for (let i = 0; i < arr.length; i++) {
91 let currentItemIndex = this.findIndexInList(arr[i], sourceArr);
92 if (currentItemIndex > index) {
93 arr.splice(i, 0, item);
94 injected = true;
95 break;
96 }
97 }
98 if (!injected) {
99 arr.push(item);
100 }
101 }
102 else {
103 arr.push(item);
104 }
105 }
106 static findIndexInList(item, list) {
107 let index = -1;
108 if (list) {
109 for (let i = 0; i < list.length; i++) {
110 if (list[i] == item) {
111 index = i;
112 break;
113 }
114 }
115 }
116 return index;
117 }
118 static contains(value, list) {
119 if (value != null && list && list.length) {
120 for (let val of list) {
121 if (this.equals(value, val))
122 return true;
123 }
124 }
125 return false;
126 }
127 static removeAccents(str) {
128 if (str && str.search(/[\xC0-\xFF]/g) > -1) {
129 str = str
130 .replace(/[\xC0-\xC5]/g, "A")
131 .replace(/[\xC6]/g, "AE")
132 .replace(/[\xC7]/g, "C")
133 .replace(/[\xC8-\xCB]/g, "E")
134 .replace(/[\xCC-\xCF]/g, "I")
135 .replace(/[\xD0]/g, "D")
136 .replace(/[\xD1]/g, "N")
137 .replace(/[\xD2-\xD6\xD8]/g, "O")
138 .replace(/[\xD9-\xDC]/g, "U")
139 .replace(/[\xDD]/g, "Y")
140 .replace(/[\xDE]/g, "P")
141 .replace(/[\xE0-\xE5]/g, "a")
142 .replace(/[\xE6]/g, "ae")
143 .replace(/[\xE7]/g, "c")
144 .replace(/[\xE8-\xEB]/g, "e")
145 .replace(/[\xEC-\xEF]/g, "i")
146 .replace(/[\xF1]/g, "n")
147 .replace(/[\xF2-\xF6\xF8]/g, "o")
148 .replace(/[\xF9-\xFC]/g, "u")
149 .replace(/[\xFE]/g, "p")
150 .replace(/[\xFD\xFF]/g, "y");
151 }
152 return str;
153 }
154}
155//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib2JqZWN0dXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBwL2NvbXBvbmVudHMvdXRpbHMvb2JqZWN0dXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxPQUFPLFdBQVc7SUFFYixNQUFNLENBQUMsTUFBTSxDQUFDLElBQVMsRUFBRSxJQUFTLEVBQUUsS0FBYztRQUNyRCxJQUFJLEtBQUs7WUFDTCxPQUFPLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLElBQUksRUFBRSxLQUFLLENBQUMsS0FBSyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxFQUFFLEtBQUssQ0FBQyxDQUFDLENBQUM7O1lBRW5GLE9BQU8sSUFBSSxDQUFDLGFBQWEsQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUM7SUFDOUMsQ0FBQztJQUVNLE1BQU0sQ0FBQyxhQUFhLENBQUMsSUFBUyxFQUFFLElBQVM7UUFDNUMsSUFBSSxJQUFJLEtBQUssSUFBSTtZQUFFLE9BQU8sSUFBSSxDQUFDO1FBRS9CLElBQUksSUFBSSxJQUFJLElBQUksSUFBSSxPQUFPLElBQUksSUFBSSxRQUFRLElBQUksT0FBTyxJQUFJLElBQUksUUFBUSxFQUFFO1lBQ3BFLElBQUksSUFBSSxHQUFHLEtBQUssQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLEVBQ3hCLElBQUksR0FBRyxLQUFLLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxFQUMxQixDQUFDLEVBQ0Q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WxzIHtcblxuICAgIHB1YmxpYyBzdGF0aWMgZXF1YWxzKG9iajE6IGFueSwgb2JqMjogYW55LCBmaWVsZD86IHN0cmluZyk6IGJvb2xlYW4ge1xuICAgICAgICBpZiAoZmllbGQpXG4gICAgICAgICAgICByZXR1cm4gKHRoaXMucmVzb2x2ZUZpZWxkRGF0YShvYmoxLCBmaWVsZCkgPT09IHRoaXMucmVzb2x2ZUZpZWxkRGF0YShvYmoyLCBmaWVsZCkpO1xuICAgICAgICBlbHNlXG4gICAgICAgICAgICByZXR1cm4gdGhpcy5lcXVhbHNCeVZhbHVlKG9iajEsIG9iajIpO1xuICAgIH1cblxuICAgIHB1YmxpYyBzdGF0aWMgZXF1YWxzQnlWYWx1ZShvYmoxOiBhbnksIG9iajI6IGFueSk6IGJvb2xlYW4ge1xuICAgICAgICBpZiAob2JqMSA9PT0gb2JqMikgcmV0dXJuIHRydWU7XG5cbiAgICAgICAgaWYgKG9iajEgJiYgb2JqMiAmJiB0eXBlb2Ygb2JqMSA9PSAnb2JqZWN0JyAmJiB0eXBlb2Ygb2JqMiA9PSAnb2JqZWN0Jykge1xuICAgICAgICAgICAgdmFyIGFyckEgPSBBcnJheS5pc0FycmF5KG9iajEpXG4gICAgICAgICAgICAgICAgLCBhcnJCID0gQXJyYXkuaXNBcnJheShvYmoyKVxuICAgICAgICAgICAgICAgICwgaVxuICAgICAgICAgICAgICAgICwgbGVuZ3RoXG4gICAgICAgICAgICAgICAgLCBrZXk7XG5cbiAgICAgICAgICAgIGlmIChhcnJBICYmIGFyckIpIHtcbiAgICAgICAgICAgICAgICBsZW5ndGggPSBvYmoxLmxlbmd0aDtcbiAgICAgICAgICAgICAgICBpZiAobGVuZ3RoICE9IG9iajIubGVuZ3RoKSByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgZm9yIChpID0gbGVuZ3RoOyBpLS0gIT09IDA7KVxuICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZXF1YWxzQnlWYWx1ZShvYmoxW2ldLCBvYmoyW2ldKSkgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoYXJyQSAhPSBhcnJCKSByZXR1cm4gZmFsc2U7XG5cbiAgICAgICAgICAgIHZhciBkYXRlQSA9IG9iajEgaW5zdGFuY2VvZiBEYXRlXG4gICAgICAgICAgICAgICAgLCBkYXRlQiA9IG9iajIgaW5zdGFuY2VvZiBEYXRlO1xuICAgICAgICAgICAgaWYgKGRhdGVBICE9IGRhdGVCKSByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICBpZiAoZGF0ZUEgJiYgZGF0ZUIpIHJldHVybiBvYmoxLmdldFRpbWUoKSA9PSBvYmoyLmdldFRpbWUoKTtcblxuICAgICAgICAgICAgdmFyIHJlZ2V4cEEgPSBvYmoxIGluc3RhbmNlb2YgUmVnRXhwXG4gICAgICAgICAgICAgICAgLCByZWdleHBCID0gb2JqMiBpbnN0YW5jZW9mIFJlZ0V4cDtcbiAgICAgICAgICAgIGlmIChyZWdleHBBICE9IHJlZ2V4cEIpIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIGlmIChyZWdleHBBICYmIHJlZ2V4cEIpIHJldHVybiBvYmoxLnRvU3RyaW5nKCkgPT0gb2JqMi50b1N0cmluZygpO1xuXG4gICAgICAgICAgICB2YXIga2V5cyA9IE9iamVjdC5rZXlzKG9iajEpO1xuICAgICAgICAgICAgbGVuZ3RoID0ga2V5cy5sZW5ndGg7XG5cbiAgICAgICAgICAgIGlmIChsZW5ndGggIT09IE9iamVjdC5rZXlzKG9iajIpLmxlbmd0aClcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG5cbiAgICAgICAgICAgIGZvciAoaSA9IGxlbmd0aDsgaS0tICE9PSAwOylcbiAgICAgICAgICAgICAgICBpZiAoIU9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChvYmoyLCBrZXlzW2ldKSkgcmV0dXJuIGZhbHNlO1xuXG4gICAgICAgICAgICBmb3IgKGkgPSBsZW5ndGg7IGktLSAhPT0gMDspIHtcbiAgICAgICAgICAgICAgICBrZXkgPSBrZXlzW2ldO1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5lcXVhbHNCeVZhbHVlKG9iajFba2V5XSwgb2JqMltrZXldKSkgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBvYmoxICE9PSBvYmoxICYmIG9iajIgIT09IG9iajI7XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyByZXNvbHZlRmllbGREYXRhKGRhdGE6IGFueSwgZmllbGQ6IGFueSk6IGFueSB7XG4gICAgICAgIGlmIChkYXRhICYmIGZpZWxkKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5pc0Z1bmN0aW9uKGZpZWxkKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmaWVsZChkYXRhKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKGZpZWxkLmluZGV4T2YoJy4nKSA9PSAtMSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkYXRhW2ZpZWxkXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIGxldCBmaWVsZHM6IHN0cmluZ1tdID0gZmllbGQuc3BsaXQoJy4nKTtcbiAgICAgICAgICAgICAgICBsZXQgdmFsdWUgPSBkYXRhO1xuICAgICAgICAgICAgICAgIGZvcihsZXQgaSA9IDAsIGxlbiA9IGZpZWxkcy5sZW5ndGg7IGkgPCBsZW47ICsraSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSB2YWx1ZVtmaWVsZHNbaV1dO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHB1YmxpYyBzdGF0aWMgaXNGdW5jdGlvbihvYmo6IGFueSkge1xuICAgICAgICByZXR1cm4gISEob2JqICYmIG9iai5jb25zdHJ1Y3RvciAmJiBvYmouY2FsbCAmJiBvYmouYXBwbHkpO1xuICAgIH1cblxuICAgIHB1YmxpYyBzdGF0aWMgcmVvcmRlckFycmF5KHZhbHVlOiBhbnlbXSwgZnJvbTogbnVtYmVyLCB0bzogbnVtYmVyKSB7XG4gICAgICAgIGxldCB0YXJnZXQ6IG51bWJlcjtcbiAgICAgICAgaWYgKHZhbHVlICYmIGZyb20gIT09IHRvKSB7XG4gICAgICAgICAgICBpZiAodG8gPj0gdmFsdWUubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgdG8gJT0gdmFsdWUubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGZyb20gJT0gdmFsdWUubGVuZ3RoO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFsdWUuc3BsaWNlKHRvLCAwLCB2YWx1ZS5zcGxpY2UoZnJvbSwgMSlbMF0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyBpbnNlcnRJbnRvT3JkZXJlZEFycmF5KGl0ZW06IGFueSwgaW5kZXg6IG51bWJlciwgYXJyOiBhbnlbXSwgc291cmNlQXJyOiBhbnlbXSk6IHZvaWQge1xuICAgICAgICBpZiAoYXJyLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIGxldCBpbmplY3RlZCA9IGZhbHNlO1xuICAgICAgICAgICAgZm9yKGxldCBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGxldCBjdXJyZW50SXRlbUluZGV4ID0gdGhpcy5maW5kSW5kZXhJbkxpc3QoYXJyW2ldLCBzb3VyY2VBcnIpO1xuICAgICAgICAgICAgICAgIGlmIChjdXJyZW50SXRlbUluZGV4ID4gaW5kZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgYXJyLnNwbGljZShpLCAwLCBpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgaW5qZWN0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICghaW5qZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICBhcnIucHVzaChpdGVtKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGFyci5wdXNoKGl0ZW0pO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyBmaW5kSW5kZXhJbkxpc3QoaXRlbTogYW55LCBsaXN0OiBhbnkpOiBudW1iZXIge1xuICAgICAgICBsZXQgaW5kZXg6IG51bWJlciA9IC0xO1xuXG4gICAgICAgIGlmIChsaXN0KSB7XG4gICAgICAgICAgICBmb3IobGV0IGkgPSAwOyBpIDwgbGlzdC5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGlmIChsaXN0W2ldID09IGl0ZW0pIHtcbiAgICAgICAgICAgICAgICAgICAgaW5kZXggPSBpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gaW5kZXg7XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyBjb250YWlucyh2YWx1ZSwgbGlzdCkge1xuICAgICAgICBpZiAodmFsdWUgIT0gbnVsbCAmJiBsaXN0ICYmIGxpc3QubGVuZ3RoKSB7XG4gICAgICAgICAgICBmb3IgKGxldCB2YWwgb2YgbGlzdCkge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmVxdWFscyh2YWx1ZSwgdmFsKSlcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuXG4gICAgcHVibGljIHN0YXRpYyByZW1vdmVBY2NlbnRzKHN0cikge1xuICAgICAgICBpZiAoc3RyICYmIHN0ci5zZWFyY2goL1tcXHhDMC1cXHhGRl0vZykgPiAtMSkge1xuICAgICAgICAgICAgc3RyID0gc3RyXG4gICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4QzAtXFx4QzVdL2csIFwiQVwiKVxuICAgICAgICAgICAgICAgICAgICAucmVwbGFjZSgvW1xceEM2XS9nLCBcIkFFXCIpXG4gICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4QzddL2csIFwiQ1wiKVxuICAgICAgICAgICAgICAgICAgICAucmVwbGFjZSgvW1xceEM4LVxceENCXS9nLCBcIkVcIilcbiAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoL1tcXHhDQy1cXHhDRl0vZywgXCJJXCIpXG4gICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4RDBdL2csIFwiRFwiKVxuICAgICAgICAgICAgICAgICAgICAucmVwbGFjZSgvW1xceEQxXS9nLCBcIk5cIilcbiAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoL1tcXHhEMi1cXHhENlxceEQ4XS9nLCBcIk9cIilcbiAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoL1tcXHhEOS1cXHhEQ10vZywgXCJVXCIpXG4gICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4RERdL2csIFwiWVwiKVxuICAgICAgICAgICAgICAgICAgICAucmVwbGFjZSgvW1xceERFXS9nLCBcIlBcIilcbiAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoL1tcXHhFMC1cXHhFNV0vZywgXCJhXCIpXG4gICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4RTZdL2csIFwiYWVcIilcbiAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoL1tcXHhFN10vZywgXCJjXCIpXG4gICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4RTgtXFx4RUJdL2csIFwiZVwiKVxuICAgICAgICAgICAgICAgICAgICAucmVwbGFjZSgvW1xceEVDLVxceEVGXS9nLCBcImlcIilcbiAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoL1tcXHhGMV0vZywgXCJuXCIpXG4gICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4RjItXFx4RjZcXHhGOF0vZywgXCJvXCIpXG4gICAgICAgICAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4RjktXFx4RkNdL2csIFwidVwiKVxuICAgICAgICAgICAgICAgICAgICAucmVwbGFjZSgvW1xceEZFXS9nLCBcInBcIilcbiAgICAgICAgICAgICAgICAgICAgLnJlcGxhY2UoL1tcXHhGRFxceEZGXS9nLCBcInlcIik7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gc3RyO1xuICAgICAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.