UNPKG

linguist-js

Version:

Analyse the programming languages used in a folder or from raw content, using the same rules that GitHub Linguist does.

10 lines (9 loc) 343 B
export default function parseGitignore(content) { const readableData = content // Remove comments unless escaped .replace(/(?<!\\)#.+/g, '') // Remove whitespace unless escaped .replace(/(?:(?<!\\)\s)+$/g, ''); const arrayData = readableData.split(/\r?\n/).filter(data => data); return arrayData; }