https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/includes
489141
function contains(origin, search, start) {
  'use strict';
  if (typeof start !== 'number') {
    start = 0;
  }
  if (start + search.length > origin.length) {
    return false;
  } else {
    return origin.indexOf(search, start) !== -1;
  }
}
386942
function stringify(data, exclude) {
    let base = '';
    Object.keys(data).sort().map(key=>{
        if(!exclude || !exclude[key]) {
            base += key + data[key];
        }
    });
    return base;
}
442502
def getDirsToInclude(string):
    
    dirs = []
    a = string.strip()
    obj = a.split('-')

    if len(obj) == 1 and obj[0]:
        for module in obj:
            try:
                exec('import {}'.format(module))
            except ImportError:
                raise FileNotFoundError("The module '{}' does not"
                                        "exist".format(module))
            try:
                dirs.append('-I{}'.format(eval(module).get_include()))
            except AttributeError:
                print(NOT_NEEDED_MESSAGE.format(module))
    return dirs
1013328
function stringify(obj) {
  if (!isObject(obj)) {
    throw new Error('`Stringify`\'s first argument should be an object')
  }

  var meta = Object.keys(obj)
    .map(function (key) {
      return getLine(key, obj[key])
    }).join('')

  return '// ==UserScript==\n' + meta + '// ==/UserScript==\n'
}
268677
function stringify (parsedPackageName) {
  const { scope, version } = parsedPackageName
  let name = parsedPackageName.name

  if (scope) {
    name = `@${scope}/${name}`
  }

  if (version) {
    name = `${name}@${version}`
  }

  return name
}
784763
function getIncludePath(path, options) {
  var includePath;
  var filePath;
  var views = options.views;

  // Abs path
  if (path.charAt(0) == '/') {
    includePath = exports.resolveInclude(path.replace(/^\/*/,''), options.root || '/', true);
  }
  // Relative paths
  else {
    // Look relative to a passed filename first
    if (options.filename) {
      filePath = exports.resolveInclude(path, options.filename);
      if (fs.existsSync(filePath)) {
        includePath = filePath;
      }
    }
    // Then look in any views directories
    if (!includePath) {
      if (Array.isArray(views) && views.some(function (v) {
        filePath = exports.resolveInclude(path, v, true);
        return fs.existsSync(filePath);
      })) {
        includePath = filePath;
      }
    }
    if (!includePath) {
      throw new Error('Could not find the include file "' +
          options.escapeFunction(path) + '"');
    }
  }
  return includePath;
}
963904
function tweakI18nStrings(data) {
  // Rip off the CommonJS header/footer
  var output = '';
  data.replace(outline, function(m, inner) {
    // Remove the trailing spaces
    output += inner.replace(/ *$/, '');
  });

  if (output === '') {
    throw new Error('Mismatch in lib/gcli/nls/strings.js');
  }

  var strings = [];

  // Convert each of the string definitions
  var reply = output.replace(singleString, function(m, note, x, name, value) {
    strings.push({
      note: note,
      noteAlsoFor: [],
      name: name,
      value: value
    });
    return '';
  });

  console.log('reply="' + reply + '"');

  strings = strings.filter(function(string) {
    return ignoreStrings.indexOf(string.name) === -1;
  });

  // All strings should have a note, but sometimes we describe several strings
  // with one note, so if a string has no note then we add it to noteAlsoFor
  // in the last string with a note
  var lastStringWithNote = -1;
  strings.forEach(function(string, i) {
    if (string.note === '') {
      strings[lastStringWithNote].noteAlsoFor.push(string.name);
    }
    else {
      lastStringWithNote = i;
    }
  });

  // Make a single one line string from the the multi-line JS comments
  strings.forEach(function(string) {
    if (string.note !== '') {
      string.note = string.note.replace(/\n? *\/\/ */g, ' ')
                               .replace(/^ /, '')
                               .replace(/\n$/, '');
    }
  });

  // Add the 'LOCALIZATION NOTE' and word wrap
  strings.forEach(function(string) {
    if (string.note !== '') {
      string.noteAlsoFor.unshift(string.name);
      var names = '';
      if (string.noteAlsoFor.length > 1) {
        names = ' (' + string.noteAlsoFor.join(', ') + ')';
      }

      string.note = 'LOCALIZATION NOTE' + names + ': ' + string.note;
      string.note = '\n# ' + wordWrap(string.note, 77).join('\n# ') + '\n';
    }
  });

  // The values were escaped JavaScript strings to be property values they
  // need unescaping
  strings.forEach(function(string) {
    string.value = string.value.replace(/\\\\/g, '\\').replace(/\\'/g, '\'');
  });

  // Join to get the output
  output = strings.map(function(string) {
    return string.note + string.name + '=' + string.value + '\n';
  }).join('');

  return '' +
    '# This Source Code Form is subject to the terms of the Mozilla Public\n' +
    '# License, v. 2.0. If a copy of the MPL was not distributed with this\n' +
    '# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n' +
    '\n' +
    '# LOCALIZATION NOTE These strings are used inside the Web Console\n' +
    '# command line which is available from the Web Developer sub-menu\n' +
    '# -> \'Web Console\'.\n' +
    '# The correct localization of this file might be to keep it in\n' +
    '# English, or another language commonly spoken among web developers.\n' +
    '# You want to make that choice consistent across the developer tools.\n' +
    '# A good criteria is the language in which you\'d find the best\n' +
    '# documentation on web development on the web.\n' +
    '\n' +
    '# For each command there are in general two strings. As an example consider\n' +
    '# the \'pref\' command.\n' +
    '# commandDesc (e.g. prefDesc for the command \'pref\'): this string contains a\n' +
    '# very short description of the command. It\'s designed to be shown in a menu\n' +
    '# alongside the command name, which is why it should be as short as possible.\n' +
    '# commandManual (e.g. prefManual for the command \'pref\'): this string will\n' +
    '# contain a fuller description of the command. It\'s diplayed when the user\n' +
    '# asks for help about a specific command (e.g. \'help pref\').\n' +
    output;
}
597500
function arrayIncludesAll(arr, searchElms, fromIndex) {
	if (!Array.isArray(arr)) {
		throw new TypeError('Expected the first argument of array-includes-all to be an array, but got ' + appendType(arr) + '.');
	}

	if (!Array.isArray(searchElms)) {
		throw new TypeError('Expected the second argument of array-includes-all to be an array, but got ' + appendType(searchElms) + '.');
	}

	if (searchElms.length === 0) {
		throw new RangeError('Expected the second argument of array-includes-all to include at least one value, but recieved an empty array.');
	}

	if (arr.length === 0) {
		return false;
	}

	return searchElms.every(function checkIfArrIncludesElm(elm) {
		return arr.includes(elm, fromIndex);
	});
}
1352198
function(_string, _locale) {
            var rules = loadRulesFor(_locale);
            return rules ? applyRules(_string, rules.plural, rules.uncountable) : _string;
          }
327556
function (string) {
  if (typeof string !== 'string') {
    throw Error('NOT_STRING')
  } else {
    string = string.trim();
  }

  if (string[0] === '$') {
    var expressionIdentifier = string.substr(1, 2);

    if (['ge', 'pg', 'ng', 'np'].includes(expressionIdentifier)) {
      var paramtersString = string;
      var fullIdentifier = null;

      switch (expressionIdentifier) {
        case 'ge':
          fullIdentifier = 'gettext';
          paramtersString = paramtersString.substr(8);
          break
        case 'pg':
          fullIdentifier = 'pgettext';
          paramtersString = paramtersString.substr(9);
          break
        case 'ng':
          fullIdentifier = 'ngettext';
          paramtersString = paramtersString.substr(9);
          break
        case 'np':
          fullIdentifier = 'npgettext';
          paramtersString = paramtersString.substr(10);
      }

      var parameters = parseParameters(expressionIdentifier, paramtersString.trim());

      return {
        identifier: fullIdentifier,
        parameters: parameters
      }
    } else {
      throw Error('NO_GETTEXT_IDENTIFIER')
    }
  } else {
    throw Error('INVALID_START')
  }

  function parseParameters (expressionIdentifier, parametersString) {
    var parameters = [];
    var inputLength = parametersString.length;

    if (inputLength > 0) {
      if (parametersString[0] !== '(') {
        throw Error('NO_START_BRACKET')
      }
      if (parametersString[inputLength - 1] !== ')') {
        throw Error('NO_END_BRACKET')
      }

      // Parameters structure.
      parametersString = parametersString.substr(1).slice(0, -1);
      var allowedNumberOfParameters = (function () {
        switch (expressionIdentifier) {
          case 'ge':
            return 1
          case 'pg':
            return 2
          case 'ng':
            return 3
          case 'np':
            return 4
        }
      })();

      // Characters iterator.
      var allowedQuoteSymbol = null;
      var parameterBuffer = [];
      for (var i = 0; i < parametersString.length; i++) {
        var char = parametersString.charAt(i);

        // Handle characters when parsing the last paramter that's supposed to be an integer and must not be wrapped with quotation marks.
        if (allowedQuoteSymbol === ',') {
          if (parameterBuffer.length > 0) {
            parameterBuffer.push(char);
          } else {
            if (char.trim().length === 0) {
              continue
            } else if (char === ',') {
              parameterBuffer.push(' ');
            } else {
              throw Error('MISSING_COMMA_BEFORE_LAST_PARAMETER')
            }
          }

          if (i === parametersString.length - 1) {
            if (parameterBuffer.length === 0) {
              throw Error('UNDEFINED_LAST_PARAMETER')
            } else {
              var parameterValue = parameterBuffer.join('').trim();

              if (!(!isNaN(+parameterValue) || parameterValue === '$n')) {
                if (parameterValue.indexOf(',') !== -1) {
                  throw Error('TOO_MANY_PARAMETERS')
                }
                throw Error('LAST_PARAMETER_NOT_NUMBER')
              }

              parameters.push(parameterValue === '$n' ? '$n' : +parameterValue);
            }
          }

          continue
        }

        // Handle characters when parsing normal text parameters.
        if (allowedQuoteSymbol === null && (char === '\'' || char === '"')) {
          allowedQuoteSymbol = char;
        } else if ((allowedQuoteSymbol === '\'' && char === '\'') || (allowedQuoteSymbol === '"' && char === '"')) {
          var previousChar = i >= 1 ? parametersString.charAt(i - 1) : null;

          if (previousChar !== '\\') {
            if (parameters.length >= allowedNumberOfParameters) {
              throw Error('TOO_MANY_PARAMETERS')
            } else {
              var parameterValue$1 = parameterBuffer.join('');

              // Add a valid parameter to the parameters array.
              parameters.push(parameterValue$1);
              parameterBuffer = [];

              // Change the quote symbol when expecting the next parameter to be an integer instead of a string.
              if ((expressionIdentifier === 'ng' && parameters.length === 2) || (expressionIdentifier === 'np' && parameters.length === 3)) {
                allowedQuoteSymbol = ',';
              } else {
                allowedQuoteSymbol = null;
              }
            }
          } else {
            parameterBuffer.push(char);
          }
        } else if (allowedQuoteSymbol !== null && allowedQuoteSymbol !== undefined && allowedQuoteSymbol !== false && char !== '\\') {
          parameterBuffer.push(char);
        }
      }

      if (parameters.length < allowedNumberOfParameters) {
        throw Error('PARAMETERS_INCORRECT')
      } else {
        return parameters
      }
    } else {
      throw Error('NO_PARAMETERS')
    }
  }
}
1336221
function Array_includes(searchElement, // @arg Any
                        position) {    // @arg Integer = 0
                                       // @ret Boolean
    position = position || 0;
    var iz = this.length;

    if (iz === 0) {
        return false;
    }

    var i = 0;

    if (position >= 0) {
        i = position;
    } else {
        i = position + iz;
        if (i < 0) {
            i = 0;
        }
    }

    if (searchElement === searchElement) {
        for (; i < iz; ++i) {
            if (this[i] === searchElement) {
                return true;
            }
        }
    } else if (isNaN(searchElement)) {
        for (; i < iz; ++i) {
            if (isNaN(this[i])) {
                return true;
            }
        }
    } else { // maybe Symble, ... etc
        throw TypeError("Unsupported type");
    }
    return false;
}
349426
function parseIncludes(codes, includes) {
    const result = {};
    for (const id of Object.keys(codes)) {
        const code = codes[id];
        result[id] = code.split('\n').map(function(line) {
            if (line.trim().substr(0, 8) !== '#include') return line;
            const pos = line.indexOf('#include') + 8;
            let includeName = line.substr(pos).trim();
            // We accept all this systaxes:
            // #include foo
            // #include 'foo'
            // #include <foo>
            // #include "foo"
            if ("'<\"".indexOf(includeName.charAt(0)) > -1) {
                includeName = includeName.substr(1, includeName.length - 2);
            }
            const snippet = includes[includeName];
            if (typeof snippet !== 'string') {
                console.error("Include <" + includeName + "> not found in ", includes);
                throw Error("Include not found in shader: " + includeName);
            }
            return snippet;
        }).join("\n");
    }
    return result;
}
464043
function(opt) {
  var strings = (opt.string || "").split(","),
      abbr, full, metavar;
  for (var i = 0; i < strings.length; i++) {
    var string = strings[i].trim(),
        matches;
    if (matches = string.match(/^\-([^-])(?:\s+(.*))?$/)) {
      abbr = matches[1];
      metavar = matches[2];
    }
    else if (matches = string.match(/^\-\-(.+?)(?:[=\s]+(.+))?$/)) {
      full = matches[1];
      metavar = metavar || matches[2];
    }
  }

  matches = matches || [];
  var abbr = opt.abbr || abbr,   // e.g. v from -v
      full = opt.full || full, // e.g. verbose from --verbose
      metavar = opt.metavar || metavar;  // e.g. PATH from '--config=PATH'

  var string;
  if (opt.string) {
    string = opt.string;
  }
  else if (opt.position === undefined) {
    string = "";
    if (abbr) {
      string += "-" + abbr;
      if (metavar)
        string += " " + metavar
      string += ", ";
    }
    string += "--" + (full || opt.name);
    if (metavar) {
      string += " " + metavar;
    }
  }

  opt = _(opt).extend({
    name: opt.name || full || abbr,
    string: string,
    abbr: abbr,
    full: full,
    metavar: metavar,
    matches: function(arg) {
      return opt.full == arg || opt.abbr == arg || opt.position == arg
        || opt.name == arg || (opt.list && arg >= opt.position);
    }
  });
  return opt;
}
509341
function(string) {
    var translated = Documentation.TRANSLATIONS[string];
    if (typeof translated == 'undefined')
      return string;
    return (typeof translated == 'string') ? translated : translated[0];
  }
659274
def _check_inclusions(self, f, domains=None):
        '''  '''

        filename = f if isinstance(f, six.string_types) else f.path

        if domains is None:
            domains = list(self.domains.values())

        # Inject the Layout at the first position for global include/exclude
        domains = list(domains)
        domains.insert(0, self)

        for dom in domains:
            # If file matches any include regex, then True
            if dom.include:
                for regex in dom.include:
                    if re.search(regex, filename):
                        return True
                return False
            else:
                # If file matches any exclude regex, then False
                for regex in dom.exclude:
                    if re.search(regex, filename, flags=re.UNICODE):
                        return False
        return True
1158875
function stringify (elements, options = {}) {
  const {
    embedAssets = true,
    assetPath = '',
    baseUrl = '',
    assetLoader = (filename) => fs.readFileAsync(filename, 'utf-8')
  } = options

  const [headWrappers, modifiers, assets] = extractTypes(elements, [HeadWrapper, PageModifier, Asset])

  const latestById = {}
  headWrappers.forEach(w => {
    if (w.options.id) {
      latestById[w.options.id] = w
    }
  })

  const bodyClassesMap = {}
  modifiers
    .filter(m => m.options.type === 'body-classed')
    .forEach(m => {
      bodyClassesMap[m.options.class] = m.options.classed
    })

  const bodyClass = Object.keys(bodyClassesMap)
    .filter(c => bodyClassesMap[c])
    .join(' ')

  const headElements = headWrappers
    .filter(w => w.options.id ? w === latestById[w.options.id] : true)
    .map(w => w.element)
    .map(e => e.stringify ? e.stringify() : (isString(e) ? e : ''))
    .join('')

  const bodyElements = elements
    .map(e => e !== undefined && e.stringify ? e.stringify() : (isString(e) ? e : ''))
    .join('')

  // only keep unique assets
  const uniqueAssetsMap = {}
  const anonymousAssets = []
  assets.forEach(asset => {
    if (asset.url) {
      uniqueAssetsMap[asset.url] = asset
    } else {
      anonymousAssets.push(asset)
    }
  })
  const uniqueAssets = Object.keys(uniqueAssetsMap).map(k => uniqueAssetsMap[k])

  const exportAssets = []

  const stylesheets = Promise.all(uniqueAssets.filter(a => a.url.endsWith('.css')).map(s => {
    if (embedAssets) {
      if (s.content) {
        return `<style>${s.content}</style>`
      } else {
        return assetLoader(s.filename)
          .then(content => `<style>${content}</style>`)
      }
    } else {
      exportAssets.push(s)
      return `<link rel="stylesheet" href="${path.join(baseUrl, assetPath, s.url)}"></link>`
    }
  }))

  const anonymousStylesheets = anonymousAssets.filter(a => a.type === 'css').map(s => {
    if (s.content) {
      return `<style>${s.content}</style>`
    } else {
      return assetLoader(s.filename)
        .then(content => `<style>${content}</style>`)
    }
  })

  const scripts = Promise.all(uniqueAssets.filter(a => a.url.endsWith('.js')).map(s => {
    if (embedAssets) {
      if (s.content) {
        return `<script>${s.content}</script>`
      } else {
        return assetLoader(s.filename)
          .then(content => `<script>${content}</script>`)
      }
    } else {
      exportAssets.push(s)
      return `<script src="${path.join(baseUrl, assetPath, s.url)}"></script>`
    }
  }))

  const anonymousScripts = anonymousAssets.filter(a => a.type === 'js').map(s => {
    if (s.content) {
      return `<script>${s.content}</script>`
    } else {
      return assetLoader(s.filename)
        .then(content => `<script>${content}</script>`)
    }
  })

  // Also export any un-embeddable assets
  uniqueAssets.forEach(asset => {
    if (!asset.url.endsWith('.js') && !asset.url.endsWith('.css')) {
      exportAssets.push(asset)
    }
  })

  return Promise.all([stylesheets, scripts])
    .spread((stylesheets, scripts) => {
      const bodyClasses = 'qm-body-font' + (bodyClass ? ' ' + bodyClass : '')
      const head = `<head>${stylesheets.join('')}${anonymousStylesheets.join('')}${headElements}</head>`
      const body = `<body class="${bodyClasses}">${bodyElements}${scripts.join('')}${anonymousScripts.join('')}</body>`
      const html = `<!DOCTYPE html>\n<html>\n${head}\n${body}</html>`
      return {
        html: html,
        assets: exportAssets
      }
    })
}
270345
function resolveGlobal(moduleName: string): ?string {
  const modulePath = path.join(getGlobalPath(), moduleName);
  return pathExists(modulePath) ? modulePath : null;
}