deps/v8/src/extensions/i18n/i18n-utils.js
/**
 * Parses Unicode extension into key - value map.
 * Returns empty object if the extension string is invalid.
 * We are not concerned with the validity of the values at this point.
 */
Parses Unicode extension into key - value map.
Returns empty object if the extension string is invalid.
We are not concerned with the validity of the values at this point.
Parses Unicode extension into key - value map . Returns empty object if the extension string is invalid . We are not concerned with the validity of the values at this point .
function parseExtension(extension) {
  var extensionSplit = extension.split('-');
  if (extensionSplit.length <= 2 ||
      (extensionSplit[0] !== '' && extensionSplit[1] !== 'u')) {
    return {};
  }
  var extensionMap = {};
  var previousKey = undefined;
  for (var i = 2; i < extensionSplit.length; ++i) {
    var length = extensionSplit[i].length;
    var element = extensionSplit[i];
    if (length === 2) {
      extensionMap[element] = undefined;
      previousKey = element;
    } else if (length >= 3 && length <=8 && previousKey !== undefined) {
      extensionMap[previousKey] = element;
      previousKey = undefined;
    } else {
      return {};
    }
  }
  return extensionMap;
}
function parseExtension ( extension ) { var extensionSplit = extension . split ( '-' ) ; if ( extensionSplit . length <= 2 || ( extensionSplit [ 0 ] !== '' && extensionSplit [ 1 ] !== 'u' ) ) { return { } ; } var extensionMap = { } ; var previousKey = undefined ; for ( var i = 2 ; i < extensionSplit . length ; ++ i ) { var length = extensionSplit [ i ] . length ; var element = extensionSplit [ i ] ; if ( length === 2 ) { extensionMap [ element ] = undefined ; previousKey = element ; } else if ( length >= 3 && length <= 8 && previousKey !== undefined ) { extensionMap [ previousKey ] = element ; previousKey = undefined ; } else { return { } ; } } return extensionMap ; }
Parses Unicode extension into key - value map.
Parses Unicode extension into key - value map .
// Assume ['', 'u', ...] input, but don't throw. // Key is {2}alphanum, value is {3,8}alphanum. // Some keys may not have explicit values (booleans). // There is a value that's too long, or that doesn't have a key.