javascript - Node.js filter array with multiple terms -


i have files array contains set of text files in format:

[test/fixturedata/fixturedata2/test3.inc, test/fixturedata/fixturedata3/test5.inc, test/fixturedata/test1.inc, ,test/fixturedata/test6.ssi ,test/fixturedata/test9.html]

i want filter array filters out '.ssi' , '.html' files. , code below:

var recursivereadsync = require('recursive-readdir-sync'), var fs = require('fs');  var foundfiles = []; var files = fs.readdirsync(url); 

i've recursed through file , simplicity of not pasting whole code, assume files array contains items listed above. i'm not sure how filter files array, i've looked @ few nodejs api's , haven't found

array.filter looking (if want ssi/inc files, remove not operator !):

files.filter(function(filename) {    return !filename.match(/\.(inc|ssi)$/); }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -