lib/cookie.js
/* Section 5.4 part 2:
 * "*  Cookies with longer paths are listed before cookies with
 *     shorter paths.
 *
 *  *  Among cookies that have equal-length path fields, cookies with
 *     earlier creation-times are listed before cookies with later
 *     creation-times."
 */
Section 5.4 part 2:
"*  Cookies with longer paths are listed before cookies with
shorter paths.

Among cookies that have equal-length path fields, cookies with
earlier creation-times are listed before cookies with later
creation-times."
Section 5 . 4 part 2 : " * Cookies with longer paths are listed before cookies with shorter paths . Among cookies that have equal - length path fields cookies with earlier creation - times are listed before cookies with later creation - times . "
function cookieCompare(a, b) {
  validators.validate(validators.isObject(a), a);
  validators.validate(validators.isObject(b), b);
  let cmp = 0;
  const aPathLen = a.path ? a.path.length : 0;
  const bPathLen = b.path ? b.path.length : 0;
  cmp = bPathLen - aPathLen;
  if (cmp !== 0) {
    return cmp;
  }
  const aTime = a.creation ? a.creation.getTime() : MAX_TIME;
  const bTime = b.creation ? b.creation.getTime() : MAX_TIME;
  cmp = aTime - bTime;
  if (cmp !== 0) {
    return cmp;
  }
  cmp = a.creationIndex - b.creationIndex;
  return cmp;
}
function cookieCompare ( a , b ) { validators . validate ( validators . isObject ( a ) , a ) ; validators . validate ( validators . isObject ( b ) , b ) ; let cmp = 0 ; const aPathLen = a . path ? a . path . length : 0 ; const bPathLen = b . path ? b . path . length : 0 ; cmp = bPathLen - aPathLen ; if ( cmp !== 0 ) { return cmp ; } const aTime = a . creation ? a . creation . getTime ( ) : MAX_TIME ; const bTime = b . creation ? b . creation . getTime ( ) : MAX_TIME ; cmp = aTime - bTime ; if ( cmp !== 0 ) { return cmp ; } cmp = a . creationIndex - b . creationIndex ; return cmp ; }
Section 5.4 part 2:
 "*  Cookies with longer paths are listed before cookies with
     shorter paths.
Section 5 . 4 part 2 : " * Cookies with longer paths are listed before cookies with shorter paths .
// descending for length: b CMP a // ascending for time: a CMP b // break ties for the same millisecond (precision of JavaScript's clock)