This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Flatten an array of arbitrarily nested arrays of integers into a flat array of integers | |
* @param {Array} arr The array of arbitrarily nested arrays of integers | |
* @returns {Array[number]} Flat array of integers | |
*/ | |
const flatten = (arr = []) => | |
arr.reduce((acc, val) => (Array.isArray(val) ? acc.concat(flatten(val)) : acc.concat(val)), []); | |
it("works with no input", () => { | |
expect(flatten()).toEqual([]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://geraldkaszuba.com/tweaking-fish-shell/ for git branch support | |
function git_branch | |
set -g git_branch (git rev-parse --abbrev-ref HEAD ^ /dev/null) | |
if [ $status -ne 0 ] | |
set -ge git_branch | |
set -g git_dirty_count 0 | |
else | |
set -g git_dirty_count (git status --porcelain | wc -l | sed "s/ //g") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "returns the result in order", -> | |
candidates = [ | |
'Find And Replace: Selet All', | |
'Settings View: Uninstall Packages', | |
'Application: Install Update', | |
'install' | |
] | |
result = filter(candidates, 'install') | |
expect(result[0]).toBe candidates[3] | |
expect(result[1]).toBe candidates[2] |