Extract relevant lines from `.npmignore`

@param  {String} `npmignore` string
@return {Array} Array of lines
162207
function extract(npmignore) {
  if (npmignore == null) {
    throw new Error('npmignore expects a string.');
  }

  var lines = split(npmignore);
  var len = lines.length;
  var npmignored = false;
  var git = [];
  var npm = [];
  var i = 0;

  while (i < len) {
    var line = lines[i++];
    if (re.test(line)) {
      npmignored = true;
    }

    if (npmignored) {
      npm.push(line);
    } else {
      git.push(line);
    }
  }

  return npm;
}
378406
function _collectLinesWithStringLiterals(node, lineMap){
    	
    	// Create a map of line numbers to a list of literal nodes
    	if (typeof node.value === 'string' && node.value.length > 0){
    		if (node.value.toLowerCase() === 'use strict'){
    			return;
    		}
    		if(/^(?:[\.,-\/#!$%\^&\*;:{}=\-_`~()@\+\?><\[\]])$/.test(node.value)) {
    			return; //don't nag about punctuation
    		} else if(/^(?:==|!=|===|!==|=>)$/.test(node.value)) {
    			return; //don't nag about operators
    		}
    		if (node.parent){
    			switch(node.parent.type) {
    				case 'ImportDeclaration':
    				case 'MemberExpression':
    				case 'SwitchCase':
        			case 'ExportAllDeclaration' :
    				case 'UnaryExpression': {
    					return;
    				}
    				case 'BinaryExpression': {
    					if(node.parent.operator !== '+') {
    						return;
    					}
    					break;
    				}
    				case 'Property': {
    					if(node.parent.key === node) {
    						return;
    					}
						var _p = node.parent.parent.parent;
						if(_p && _p.type === 'CallExpression' && _p.callee && _p.callee.name === 'define') {
							return;
						}
    					break;
    				}
    				case 'NewExpression':
    				case 'CallExpression': {
    					var callee = node.parent.callee;
    					if(callee) {
    						if(callee.type === 'MemberExpression' && callee.property) {
    							if(callee.object && callee.object.type === "Identifier" && callee.object.name === "document" && _documentCallees[callee.property.name]) {
    								return;
    							} else if(_callees[callee.property.name]) {
	    							return;
								}
    						} else if(_callees[callee.name]) {
    							return;
    						}
    					}
    					break;
    				}
    				case 'ArrayExpression': {
    					_p = node.parent.parent;
    					if(_p.type === 'CallExpression' && (_p.callee.name === 'define' || _p.callee.name === 'require' || _p.callee.name === 'requirejs')) {
    						return;
    					}
    					break;
    				}
    			}
    		}
    		var lineNum = node.loc.end.line;
    		if (!lineMap[lineNum]){
    			lineMap[lineNum] = [];
    		}
    		lineMap[lineNum].push(node);
    	}
    }
169750
function(code) {
    var lines = [];
    code.split(/\n/).forEach(line => {
      var segs = line.split(/(\s*#)/);
      var ln = {code: segs[0]};
      if (segs.length > 1)
        ln.comment = segs.reduce((c, seg, i) => i > 1 ? c + seg : seg, '');
      lines.push(ln);
    });
    return lines;
  }
1232
function(code)
        {
            var lines = [],
                firstLine = parseInt(this.getParam('first-line'))
                ;

            eachLine(code, function(line, index)
            {
                lines.push(index + firstLine);
            });

            return lines;
        }
879410
function extract( line, from, to ) {
  return line.substring( from, to )
    .replace( /^\s+|\s+$/g, '' )
}
646959
function extract (/* pattern, ...args */) {
    var args = slice.call(arguments, 1);
    var context = this === exports ? null : this;
    var patternFn = getOrCompile(arguments[0]);
    return patternFn.call(context, args, runtime) || null;
  }
297539
function(str){
    var lines = str.match(/\n/g)
      , idx = str.lastIndexOf('\n');

    if (lines) this.lineno += lines.length;
    this.column = ~idx
      ? str.length - idx
      : this.column + str.length;
  }
949328
function extractBacktrace(lines) {
  var backtraceLines = [];
  while(lines.length && lines[lines.length - 1].trim().indexOf('at ') === 0) {
    backtraceLines.push(lines.pop());
  }
  return backtraceLines;
}
455166
function regexpPattern(pattern) {
  if (!pattern) {
    return pattern;
  }
  // A very simplified glob transform which allows passing legible strings like
  // "myPath/*.js" instead of a harder to read RegExp like /\/myPath\/.*\.js/.
  if (typeof pattern === 'string') {
    pattern = pattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
    if (pattern[0] !== '/') {
      pattern = '/' + pattern;
    }
    return new RegExp(pattern);
  }
  if (typeof pattern.test === 'function') {
    return pattern;
  }
  throw new Error(
    'flow-remove-types: includes and excludes must be RegExp or path strings. Got: ' + pattern
  );
}
693446
function (lines) {
    var regex = /[ ,]+/;
    // header= <num_data> <num_classes> 1
    var header = lines[0].split(regex);
    if (header.length < 3) {
      throw new Error('Header line needs three numbers');
    }
    var headerNumbers = [];
    try {
      for (var i = 0; i < 3; i++) {
        headerNumbers[i] = parseInt($.trim(header[i]));
      }
    }
    catch (e) {
      throw new Error('Header line element ' + i + ' is not a number');
    }
    if (headerNumbers[0] <= 0) {
      throw new Error(
        'Header line missing first number, number of data points');
    }
    if (headerNumbers[1] <= 0) {
      throw new Error(
        'Header line missing second number, number of classes');
    }
    var numClasses = headerNumbers[1];
    var numItems = headerNumbers[0];
    var classDefinitionLine = lines[1];
    classDefinitionLine = classDefinitionLine.substring(classDefinitionLine
      .indexOf('#') + 1);
    var classNames = $.trim(classDefinitionLine).split(regex);
    if (classNames.length < numClasses) {
      throw new Error('First line specifies ' + numClasses
        + ' classes, but found ' + classNames.length + '.');
    }
    var dataLine = lines[2];
    var assignments = dataLine.split(regex);
    // convert the assignments to names
    for (var i = 0; i < assignments.length; i++) {
      var assignment = $.trim(assignments[i]);
      var index = parseInt(assignment);
      var tmp = classNames[index];
      if (tmp !== undefined) {
        assignments[i] = tmp;
      }
    }
    return assignments;
  }
180027
function splitIniLine(line) {
  var separator = line.indexOf('=');
  if (separator === -1) {
    return [line];
  }
  return [
    line.substr(0, separator),
    line.substr(separator + 1)
  ];
}
1054977
function checkForIrregularLineTerminators(node) {
            const source = sourceCode.getText(),
                sourceLines = sourceCode.lines,
                linebreaks = source.match(LINE_BREAK);
            let lastLineIndex = -1,
                match;

            while ((match = IRREGULAR_LINE_TERMINATORS.exec(source)) !== null) {
                const lineIndex = linebreaks.indexOf(match[0], lastLineIndex + 1) || 0;
                const location = {
                    line: lineIndex + 1,
                    column: sourceLines[lineIndex].length
                };

                errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
                lastLineIndex = lineIndex;
            }
        }
997881
function transform(str) {
  str = str.split(/^lazy\(/gm).join('require(');
  var lines = str.split(/\r\n|\n/);
  var len = lines.length;
  var re = regex();
  var idx = 0;

  var start = false;
  var isExported = false;
  var namespace;
  var res = '';

  while (idx < len) {
    var line = lines[idx++];
    res += '\n';

    if (/(?:var fn = require|require = utils)/.test(line)) {
      continue;
    }
    if (/^require = fn/.test(line)) {
      continue;
    }
    // adding this line to catch other variable names than the more specific cases above
    if (/^require = (?:.*)/.test(line)) {
      continue;
    }

    var match = re.exec(line);
    if (!match) {
      res += line;
      continue;
    }

    if (match && (match[2] === 'lazy-cache' || match[3] === 'lazy-cache')) {
      namespace = toNamespace(match[1]);
      if (/module\.exports/.test(match[1])) {
        isExported = true;
      }
      line = 'var ' + namespace + ' = {};';
      start = true;
      res += line;
      continue;
    }

    if (!start) {
      res += line;
      continue;
    }

    var variable = toVariable(match);
    var prefix = toProperty(namespace, variable, match[2]);
    line = line.split(match[0]).join(prefix);
    res += line;
  }

  if (isExported) {
    res += '\nmodule.exports = ' + namespace + ';';
  }
  return res.replace(/^\s+/, '');
}
8613
function extractKeyValue (line) {
  var kv = {
    key: undefined,
    value: undefined,
  };

  var matches = kvRE.exec(line);
  if (matches !== null && matches.length === 3) {
    kv.key = matches[1];
    kv.value = matches[2];
  }

  return kv;
}
32796
function prettyLines(lines, theme) {
  if (!lines || !Array.isArray(lines)) throw new Error('Please supply an array of lines');
  if (!theme) throw new Error('Please supply a theme');

  function prettify(line) {
    if (!line) return null;
    return exports.line(line, theme);
  }

  return lines.map(prettify);
}
1045579
function getIgnoreRegexes(rootFolder) {
    const gasignoreFilepath = path.join(rootFolder, constants.IGNORE_FILE);

    let regexes = [];
    if (fs.existsSync(gasignoreFilepath)) {
        regexes = parse(fs.readFileSync(gasignoreFilepath));
    }
    return regexes;
}
578888
function unifiedDiff (err) {
  let indent = '      '
  function cleanUp (line) {
    if (line[0] === '+') {
      return indent + format.colorLines('green', line)
    }
    if (line[0] === '-') {
      return indent + format.colorLines('red', line)
    }
    if (line.match(/@@/)) {
      return null
    }
    if (line.match(/\\ No newline/)) {
      return null
    }
    if (line.trim().length) {
      line = format.colorLines('white', line)
    }
    return indent + line
  }
  function notBlank (line) {
    return typeof line !== 'undefined' && line !== null
  }
  let msg = diff.createPatch('string', err.actual, err.expected)
  let lines = msg.split('\n').splice(4)
  let diffResult = lines.map(cleanUp).filter(notBlank).join('\n')
  if (!diffResult.trim().length) {
    msg = diff.createPatch(
      'string',
      stringify(Object.keys(err._actual || err.actual).sort()),
      stringify(Object.keys(err._expected || err.expected).sort())
    )
    lines = msg.split('\n').splice(4)
    diffResult = format.red('       object keys not match: \n') + lines.map(cleanUp).filter(notBlank).join('\n')
  }
  return '\n      ' +
    format.colorLines('green', '+ expected') + ' ' +
    format.colorLines('red', '- actual') +
    '\n\n' +
    diffResult
}