Created
August 3, 2016 08:30
-
-
Save floscr/9b220579b526b8f3d39d452d4f2fefbc to your computer and use it in GitHub Desktop.
Filter images from an array of files
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
// Test file list | |
let fileList = [ | |
'myFile.js', | |
'myImage.png', | |
'./subdir/image.jpg', | |
]; | |
// Filter images from the changed files list | |
let imageFiles = fileList.filter(fileName => { | |
return fileName.match(/\.(jpg|png|gif)$/); | |
}); | |
// -> ['myImage.png', './subdir/image.jpg',] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment