Tag: filter

gulp-filter没有正确过滤排除的文件

我正在尝试使用gulpjs而不是grunt作为项目。 我试图在我的代码上运行jsHint时使用gulpfilter忽略供应商库。 我已经从自述文件示例中的代码中取出了代码,但文件没有被过滤。 我正在运行节点0.10.26,吞咽3.8.0和吞咽过滤0.4.1 我试图运行jshint目录wcui/app/js ,其中包含许多其他的JS文件目录,总共约120个js文件。 我只想排除vendor目录。 我的代码如下所示: var gulp = require('gulp'); var gulpFilter = require('gulp-filter'); var jshint = require('gulp-jshint'); var srcs = { scripts: ['wcui/app/js/**/*.js'], styles: ['wcui/app/css/**/*.less','wcui/app/css/**/*.css'] }; var dests = { scripts: 'wcui/static/js/', styles: 'wcui/static/css/' }; gulp.task('scripts', function() { var filter = gulpFilter('!wcui/app/js/vendor'); return gulp.src(srcs.scripts) .pipe(filter) .pipe(jshint()) .pipe(jshint.reporter('jshint-stylish')) .pipe(filter.restore) .pipe(gulp.dest(dests.scripts)); }); gulp.task('styles', function() […]

JavaScriptfilter首先等同于LINQ的Enumberable.First(谓词)

在C#中,我们有Enumerable.First(predicate) 。 鉴于这个JavaScript代码: function process() { var firstMatch = ['a', 'b', 'c'].filter(function(e) { return applyConditions(e); }).shift(); if(!firstMatch) { return; } // do something else } function applyConditions(element) { var min = 97; var max = 122; var random = Math.floor(Math.random() * (max – min + 1) + min); return element === String.fromCharCode(random); } 除了forEach ,使用循环,使用多个或操作符或隐式调用some(predicate) […]