Convert String-formatted options into Object-formatted ones and store in cache
12033
function createOptions(options) {
    var object = optionsCache[options] = {};(options.match(rnotwhite) || []).forEach(function (flag) {
        object[flag] = true;
    });
    return object;
}
917297
function(text, options) {
    var execute, queried;
    queried = p.defer();
    // caching disabled unless duration is specified
    options = options != null ? options : {
      duration: 0
    };
    execute = function(params) {
      return db.prepare(text).then(function(stmt) {
        return stmt.execute(params).then(function(results) {
          if (options.duration > 0) {
            cache.store(text, results.rows, options.duration);
          }
          return queried.resolve(results.rows);
        }).done();
      }).done();
    };
    // return results directly if cache hit, run query if cache miss
    cache.get(text).then(function(results) {
      return queried.resolve(results);
    }, function(err) {
      if (err != null) {
        return queried.reject(err);
      } else {
        return execute();
      }
    }).done();
    return queried.promise;
  }
1212353
def prepare_string_for_hashing(obj, ignore_string_type_changes=False, ignore_string_case=False):
    
    original_type = obj.__class__.__name__
    if isinstance(obj, bytes):
        obj = obj.decode('utf-8')
    if not ignore_string_type_changes:
        obj = KEY_TO_VAL_STR.format(original_type, obj)
    if ignore_string_case:
        obj = obj.lower()
    return obj
335435
function objectToString(object, tabs) {
            var result = [];
            var keys = Object.keys(object);

            keys.forEach(function (key, keyIndex) {
                var line;
                var formatedKey;

                if (-1 < key.indexOf('@')) {
                    formatedKey = '\'' + key + '\'';
                } else {
                    formatedKey = key;
                }

                if (typeof object[key] === 'object') {
                    if (Array.isArray(object[key])) {
                        var newTabs = (tabs + 1);

                        line = getTabs(tabs) + '' + formatedKey + ': [';

                        object[key].forEach(function (item, itemIndex) {
                            if (typeof item === 'object') {
                                line += "\n" + getTabs(newTabs) + '{';
                                line += "\n" + objectToString(item, (newTabs + 1));
                                line += "\n" + getTabs(newTabs) + '}';
                            } else if (typeof item === 'string') {
                                line += "\n" + getTabs(newTabs) + '\'' + addslashes(item) + '\'';
                            } else if (typeof item === 'boolean') {
                                line += "\n" + getTabs(newTabs) + '' + item;
                            } else if (typeof item === 'number') {
                                line += "\n" + getTabs(newTabs) + '' + item;
                            }

                            if (itemIndex < (object[key].length - 1)) {
                                line += ',';
                            }
                        });

                        line += "\n" + getTabs(tabs) + ']';
                    } else {
                        line = getTabs(tabs) + '' + formatedKey + ': {' + "\n";
                        line += objectToString(object[key], (tabs + 1));
                        line += "\n" + getTabs(tabs) + '}';
                    }
                } else if (typeof object[key] === 'string') {
                    line = getTabs(tabs) + '' + formatedKey + ': \'' + addslashes(object[key]) + '\'';
                } else if (typeof object[key] === 'boolean') {
                    line = getTabs(tabs) + '' + formatedKey + ': ' + object[key];
                } else if (typeof object[key] === 'number') {
                    line = getTabs(tabs) + '' + formatedKey + ': ' + object[key];
                }

                if (keyIndex < (keys.length - 1)) {
                    line += ',';
                }

                result.push(line);
            });

            return result.join("\n");
        }
1207743
def _converttobitstring(cls, bs, offset=0, cache={}):
        
        if isinstance(bs, Bits):
            return bs
        try:
            return cache[(bs, offset)]
        except KeyError:
            if isinstance(bs, basestring):
                b = cls()
                try:
                    _, tokens = tokenparser(bs)
                except ValueError as e:
                    raise CreationError(*e.args)
                if tokens:
                    b._append(Bits._init_with_token(*tokens[0]))
                    b._datastore = offsetcopy(b._datastore, offset)
                    for token in tokens[1:]:
                        b._append(Bits._init_with_token(*token))
                assert b._assertsanity()
                assert b.len == 0 or b._offset == offset
                if len(cache) < CACHE_SIZE:
                    cache[(bs, offset)] = b
                return b
        except TypeError:
            # Unhashable type
            pass
        return cls(bs)
281813
function parseString(str, options){
  var ret = reduce(String(str).split(options.separator), function(ret, pair){
    var eql = indexOf(pair, '=')
      , brace = lastBraceInKey(pair)
      , key = pair.substr(0, brace || eql)
      , val = pair.substr(brace || eql, pair.length)
      , val = val.substr(indexOf(val, '=') + 1, val.length);

    // ?foo
    if ('' == key) key = pair, val = '';
    if ('' == key) return ret;

    return merge(ret, decode(key), decode(val));
  }, { base: {} }).base;

  return compact(ret);
}
1261050
def _format_option_strings(self, option, mvarfmt=' <%s>', optsep=', '):
        
        opts = []

        if option._short_opts:
            opts.append(option._short_opts[0])
        if option._long_opts:
            opts.append(option._long_opts[0])
        if len(opts) > 1:
            opts.insert(1, optsep)

        if option.takes_value():
            metavar = option.metavar or option.dest.lower()
            opts.append(mvarfmt % metavar.lower())

        return ''.join(opts)
395492
function format(extensions) {
  return Object.keys(extensions)
    .map((extension) => {
      let configurations = extensions[extension];
      if (!Array.isArray(configurations)) configurations = [configurations];
      return configurations
        .map((params) => {
          return [extension]
            .concat(
              Object.keys(params).map((k) => {
                let values = params[k];
                if (!Array.isArray(values)) values = [values];
                return values
                  .map((v) => (v === true ? k : `${k}=${v}`))
                  .join('; ');
              })
            )
            .join('; ');
        })
        .join(', ');
    })
    .join(', ');
}
1117729
function(str, methodDec, methodName, method, methodsMap, options){
    var methodValue = getMethodValue(methodDec, methodName, method, methodsMap, options);
    if(str === methodDec) return methodValue;
    return str.replace(methodDec, function(){ return methodValue; });
  }
1154004
public static function processOptions($model_and_method, $existing_object = null, $where = [], $existing_values = [], $skip_values = [], $options = []) {
		// put changes into options
		$options['where'] = array_merge_hard($options['where'] ?? [], $where);
		$options['existing_values'] = $existing_values;
		$options['skip_values'] = $skip_values;
		// see if we have cached version
		$hash = sha1($model_and_method . serialize($options));
		if (isset(self::$cached_options[$hash])) {
			return self::$cached_options[$hash];
		} else {
			$temp = explode('::', $model_and_method);
			if (count($temp) == 1) {
				$model = $temp[0];
				$method = 'options';
			} else {
				$model = $temp[0];
				$method = $temp[1];
			}
			if ($model == 'this' && !empty($existing_object)) {
				$object = $existing_object;
			} else {
				$object = \Factory::model($model, true);
			}
			self::$cached_options[$hash] = $object->{$method}($options);
			return self::$cached_options[$hash];
		}
	}
711611
function createOptions( options ) {
    var object = optionsCache[ options ] = {};
    _each( options.split( /\s+/ ), function( flag ) {
      object[ flag ] = true;
    });
    return object;
  }
950129
function format(obj, opts, fn) {
  if (typeof opts === 'function') {
    fn = opts; opts = {};
  }

  opts = opts || {};
  if (Array.isArray(opts.filter) || typeof opts.filter === 'string') {
    obj = filter(obj, opts.filter);
  }

  var keys = Object.keys(obj);
  var len = keys.length, i = 0;
  var str = '';
  var total = len;

  while (len--) {
    var fp = keys[i++];
    var ctx = context(read(fp), fn);
    var name = basename(fp);
    str += heading(name, fp);

    var list = obj[fp];
    var methods = Object.keys(list);
    total += methods.length;

    str += listify(fp, methods, ctx);
  }

  var res = {};
  res.list = str;
  res.total = total;
  return res;
}
339340
function dumpObject(obj, cache, currentPath, options){
	// do this on the first call
	var data = '';
	var dataType = getDataType(obj);
	var isSimpleType = (SIMPLETYPES.indexOf(dataType) >= 0);
	var bFirstCall = (currentPath.length == 0);
	var label = dataType;
	var expand = true;
	var expandCells = true;

	if(bFirstCall){
		var topPath = TOP;
		cache.bFilteredLevel = false;
		if(options.label){
			label = options.label + ' - ' + label;
			/*topPath += ' ' + options.label;
			if(topPath.length > CIRCULARTOPSTRINGLIMIT)
				topPath = topPath.substr(0, CIRCULARTOPSTRINGLIMIT) + '...';
			topPath += ' - ' + dataType;*/
		}
		currentPath = [topPath];
	}

	var bEmpty = false;
	var bHeader = !isSimpleType;

	if(isSimpleType){ // Simple types

		switch(dataType){
			case 'Boolean':
				var val = '<span class="'+(obj ? 'nodedump-yes' : 'nodedump-no')+'">' + obj + '</span>';
				data = doRow(dataType, label, val, expand, expandCells);
			break;
			case 'String':
				if(obj.length === 0)
					bEmpty = true;
				else {
					var val = escapeHtml(obj);
					//var val = '<pre><code class="lang-html">' + hljs.highlight('xml', obj).value + '</code></pre>';
					data = doRow(dataType, label, val, expand, expandCells);
				}
			break;
			case 'Math':
			case 'Undefined':
			case 'Null':
				data = doRow1Col(dataType, label, expand);
			break;
			default:
				data = doRow(dataType, label, obj.toString(), expand, expandCells);
			break;
		}

	} else { // Non-Simple types

		// figure out if it should be expanded/collapsed
		expand = options.expand;
		if(typeof options.expand == 'object'){
			expand = expand.indexOf(dataType) > -1 || expand.indexOf(dataType.toLowerCase()) > -1;
		}
		if(expand){
			if(options.collapse == true || (
					typeof options.collapse == 'object' 
					&& (options.collapse.indexOf(dataType) > -1 || options.collapse.indexOf(dataType.toLowerCase()) > -1)
				)
			)
				expand = false;
		}

		switch(dataType){
			case 'RegExp':
			case 'Error':
				data += doRowHeader1Col(dataType, label, expand);
				data += doRow1Col(dataType, obj.toString(), expand);
			break;
			case 'Function':
				bHeader = true;
				data += doRowHeader1Col(dataType, label, expand);
				var txt = obj.toString();
				if(options.syntaxHighlight){
					var purtyText = hljs.highlight('javascript', txt);
					//var purtyText = hljs.highlightAuto(txt);
					txt = purtyText.value;
				} else {
					var txt = escapeHtml(obj.toString());
				}

				data += doRow1Col(dataType, '<pre><code class="lang-javascript">'+txt+'</code></pre>', expand);
				//data += doRow1Col(dataType, '<pre><code>'+escapeHtml(obj.toString())+'</code></pre>', expand);
			break;
			case 'Array':
			case 'Object':
			default:
				// set keys to collapse if an array of types was passed for expand and the current data-type is one of them
				expandCells = expand;
				if(typeof options.expand == 'object' && expand)
					expandCells = false;

				// check for circular references
				var circPath = getPathToCircularRef(obj, cache, currentPath);
				if(circPath.length > 0){
					dataType = CIRCULARREFERENCE;
					data = doRow(dataType, dataType, circPath.join(CIRCULARSPLITSTRING), expand);
				} else {
					var subPath;
					var loopObj = [];
					for(var key in obj)
						loopObj.push(key);
					if(dataType != 'Array' && options.sortKeys){
						loopObj.sort(function (a, b) {
							return a.toLowerCase().localeCompare(b.toLowerCase());
						});
					}

					cache.level++;
					var filtered = [];
					var bFilteredTop = false;
					var numTotalKeys = loopObj.length;
					var key, val;
					var numKeysShown = 0;
					var numKeysHidden = 0;
					var errThrown;
					for (var i = 0; i < loopObj.length; i++) {
						key = loopObj[i];
						errThrown = '';
						try{
							val = obj[key];
						} catch(err){
							errThrown = err.toString();
						}
						if(bFirstCall){
							if(!(!options.show || (options.show.length && (options.show.indexOf(key) >= 0 || options.show.indexOf(Number(key)) >= 0)))){
								numKeysHidden++;
								continue;
							} else if(options.hide && options.hide.length && (options.hide.indexOf(key) >= 0 || options.hide.indexOf(Number(key)) >= 0)){
								numKeysHidden++;
								continue;
							}
							if(options.top > 0 && numKeysShown === options.top){
								bFilteredTop = true;
								break;
							}
						}
						// skip any data types that should be hidden
						if(options.hideTypes){
							var subDataType = getDataType(val);
							if(options.hideTypes.indexOf(subDataType) > -1 || options.hideTypes.indexOf(subDataType.toLowerCase()) > -1){
								numKeysHidden++;
								continue;
							}
						}

						numKeysShown++;
						if(options.levels !== null && currentPath.length > options.levels){
							cache.bFilteredLevel = true;
							data += doRow(dataType, key, '', true);
							continue;
						}
						
						if(errThrown.length > 0){
							var errorRow = doRowHeader1Col(ERRORDATATYPE, ERRORDATATYPE, true)
											+ doRow1Col(ERRORDATATYPE, '<pre><code class="lang-javascript">'+hljs.highlight('javascript', errThrown).value+'</code></pre>', true);
											//+ doRow1Col(ERRORDATATYPE, errThrown, true);
							data += doRow(dataType, key, doTable(ERRORDATATYPE, errorRow), expandCells);
							continue;
						}
						subPath = clone(currentPath, 'Array');
						subPath.push(key);

						data += doRow(dataType, key, dumpObject(val, cache, subPath, options), expand, expandCells);
					}
					
					if(numTotalKeys === 0)
						bEmpty = true;
					else {
						if(bFirstCall){
							if(numKeysShown !== numTotalKeys){
								if(options.show || options.hideTypes){
									filtered.push(format(TITLEFILTEREDSHOWN, numKeysShown, numTotalKeys));
								} else if(options.hide){
									filtered.push(format(TITLEFILTEREDHIDDEN, numKeysHidden, numTotalKeys));
									numTotalKeys = numTotalKeys - numKeysHidden;
								}
								if(!(options.show || options.hideTypes) && bFilteredTop)
									filtered.push(format(TITLEFILTEREDTOP, numKeysShown, numTotalKeys));
							}
							if(cache.bFilteredLevel)
								filtered.push(format(TITLEFILTEREDLEVELS, options.levels));

						} else if(options.hideTypes && numKeysShown !== numTotalKeys){
							// show the filtered label for types being hidden
							filtered.push(format(TITLEFILTEREDSHOWN, numKeysShown, numTotalKeys));
						}
						if(filtered.length > 0)
							label += format(TITLEFILTERED, filtered.join(', '));

						data = doRowHeader(dataType, label, expand) + data;
					}
				}
			break;
		}

	}

    if(bEmpty)
            data = bHeader ? doRowHeaderEmpty(dataType, label) : doRowEmpty(dataType, label);

    return doTable(dataType, data);
}
806474
function convert(opts) {
  let res = '';

  // eslint-disable-next-line
  for (const key in opts) {
    if (hasOwn(opts, key)) {
      if (/^expires$/i.test(key)) {
        let expires = opts[key];

        if (typeof expires !== 'object') {
          expires += typeof expires === 'number' ? 'D' : '';
          expires = computeExpires(expires);
        }
        res += `;${key}=${expires.toUTCString()}`;
      } else if (/^secure$/.test(key)) {
        if (opts[key]) {
          res += `;${key}`;
        }
      } else {
        res += `;${key}=${opts[key]}`;
      }
    }
  }

  if (!hasOwn(opts, 'path')) {
    res += ';path=/';
  }

  return res;
}
188878
function formatOpts(opts) {
  opts = opts || {};
  // key
  opts.key = opts.key || 'koa:sess';

  // back-compat maxage
  if (!('maxAge' in opts)) opts.maxAge = opts.maxage;

  // defaults
  if (opts.overwrite == null) opts.overwrite = true;
  if (opts.httpOnly == null) opts.httpOnly = true;
  if (opts.signed == null) opts.signed = true;

  debug('session options %j', opts);

  // setup encoding/decoding
  if (typeof opts.encode !== 'function') {
    opts.encode = util.encode;
  }
  if (typeof opts.decode !== 'function') {
    opts.decode = util.decode;
  }

  const store = opts.store;
  if (store) {
    assert(is.function(store.get), 'store.get must be function');
    assert(is.function(store.set), 'store.set must be function');
    assert(is.function(store.destroy), 'store.destroy must be function');
  }

  const ContextStore = opts.ContextStore;
  if (ContextStore) {
    assert(is.class(ContextStore), 'ContextStore must be a class');
    assert(is.function(ContextStore.prototype.get), 'ContextStore.prototype.get must be function');
    assert(is.function(ContextStore.prototype.set), 'ContextStore.prototype.set must be function');
    assert(is.function(ContextStore.prototype.destroy), 'ContextStore.prototype.destroy must be function');
  }

  if (!opts.genid) {
    if (opts.prefix) opts.genid = () => opts.prefix + uid.sync(24);
    else opts.genid = () => uid.sync(24);
  }

  return opts;
}
184164
function (str) {
    if (caches[str]) {
      return caches[str];
    }
    
    // special regexp chars (., +, etc.)
    reg = str.replace(/[.+^$()|{}]/g, function (match, offset, s) {
      return s[offset - 1] === '\\' ? match : '\\' + match;
    });
    // ? and *
    reg = reg.replace(/[?*]/g, function (match, offset, s) {
      if (s[offset - 1] === '\\') {
        return match;
      }
      return match === '?' ? '.' : '.*';
    });
    // special regexp escapings (\d, \S, etc.)
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
    reg = reg.replace(/\\([dDsSwWtrnvfbB0cxu])/g, '$1');
    return caches[str] = new RegExp('^' + reg + '$');
  }
315471
function parseStoredType(value /* , context */) {
    const regex = /^(\w+)(\((.*?)\))?$/;
    const result = value.match(regex);
    if (!result) throw new ImplementationError(`Invalid storedType "${value}"`);

    const type = result[1];
    const options = {};
    if (result[2]) {
        const regexOptions = /^(\w+)=(.*)/;
        result[3].split(';').forEach(o => {
            const resultOptions = o.match(regexOptions);
            if (!resultOptions) throw new ImplementationError(`Invalid storedType "${value}"`);
            options[resultOptions[1]] = resultOptions[2];
        });
    }

    return { type, options };
}