Skip to content

Instantly share code, notes, and snippets.

@ochaochaocha3
Created June 2, 2018 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochaochaocha3/dd00ea004d3825254af2b1f2fab637b1 to your computer and use it in GitHub Desktop.
Save ochaochaocha3/dd00ea004d3825254af2b1f2fab637b1 to your computer and use it in GitHub Desktop.
ファイル名の配列から .DS_Store を除外する
// ファイル名の配列
var files = [
'dir/.DS_Store', 'dir/img.jpg', 'dir2/img2.png'
];
// filterで.DS_Storeを除外する
files
.filter(filename => !filename.endsWith('.DS_Store'));
/*
dir/img.jpg,dir2/img2.png
*/
// filterをかけた後イテレートする
files
.filter(filename => !filename.endsWith('.DS_Store'))
.forEach(filename => {
// 何かする
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment