Here is a code snippet from a gulp file. I'd like to understand passing of argument "file" to internal functions. More importantly, I'd like to understand this idiom because I see it often in Javascript. My guess is that "tsResult.js" iterates through various javascript files in this Typescript project and the "file" argument is each such file. How can I decipher such usage below and in future
gulp.task('scripts', ['clean'], () => {
const tsResult = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject());
return tsResult.js.pipe(sourcemaps.write({
includeContent: false,
sourceRoot: function (file) {
return path.relative(path.dirname(file.path), file.base);
}
}))
.pipe(gulp.dest(OUTPUT_FOLDER));
});