MCPcopy Create free account
hub / github.com/betsol/angular-input-modified / compare

Function compare

src/directive/ngModel.js:200–216  ·  view source on GitHub ↗

* Returns true if specified values are equal, false otherwise. * Supports dates comparison. * * @param {*} value1 * @param {*} value2 * * @returns {boolean}

(value1, value2)

Source from the content-addressed store, hash-verified

198 * @returns {boolean}
199 */
200 function compare (value1, value2) {
201 value1 = normalizeValue(value1);
202 value2 = normalizeValue(value2);
203
204 if ('object' === typeof value1 && 'object' === typeof value2) {
205 if (value1 instanceof Date && value2 instanceof Date) {
206 // Comparing two dates.
207 return (value1.getTime() === value2.getTime());
208 } else {
209 // Comparing two objects.
210 return angular.equals(value1, value2);
211 }
212 }
213
214 // In all other cases using weak comparison.
215 return (value1 == value2);
216 }
217
218 /**
219 * Casting all null-like values to actual null for guaranteed comparison.

Callers 1

onInputValueChangedFunction · 0.85

Calls 1

normalizeValueFunction · 0.85

Tested by

no test coverage detected