Skip to content

Instantly share code, notes, and snippets.

@ryanluker
Last active May 6, 2018 21:30
Show Gist options
  • Save ryanluker/ebd89e7e6f6f9bb2102e656c84bcc4d7 to your computer and use it in GitHub Desktop.
Save ryanluker/ebd89e7e6f6f9bb2102e656c84bcc4d7 to your computer and use it in GitHub Desktop.
example
const a = [...base].reverse();
const b = [...comparee].reverse();
// find the intersection and reverse it back into a string
const intersection = [...a].filter((x, i) => x === b[i]).reverse().join("");
// prevent file names from returning true, the intersection must include ###'s
// from the normalize process
if (!intersection.includes("###")) return false;
// if the whole word intersection is present in base, return true
return base.includes(intersection);
/**
tests:
1) "c:###dev###vscode-coverage-gutters###example###node###test-coverage.js"
1) "###home###ryanluker###dev###vscode-coverage-gutters###example###node###test-coverage.js"
2) "c:###dev###vscode-coverage-gutters###example###node###test.js"
2) "###home###ryanluker###dev###vscode-coverage-gutters###example###node###test.js"
3) "c:###dev###vscode-coverage-gutters###example###node###test.js"
3) "###home###ryanluker###dev###vscode-coverage-gutters###example###node###test-coverage.js"
3) "ve-###.js"
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment