vendor/static/moment/src/lib/utils/compare-arrays.js
raw| 1 | import toInt from './to-int'; |
| 2 | |
| 3 | // compare two arrays, return the number of differences |
| 4 | export default function compareArrays(array1, array2, dontConvert) { |
| 5 | var len = Math.min(array1.length, array2.length), |
| 6 | lengthDiff = Math.abs(array1.length - array2.length), |
| 7 | diffs = 0, |
| 8 | i; |
| 9 | for (i = 0; i < len; i++) { |
| 10 | if ( |
| 11 | (dontConvert && array1[i] !== array2[i]) || |
| 12 | (!dontConvert && toInt(array1[i]) !== toInt(array2[i])) |
| 13 | ) { |
| 14 | diffs++; |
| 15 | } |
| 16 | } |
| 17 | return diffs + lengthDiff; |
| 18 | } |