Skip to content

Commit 42c433c

Browse files
authored
🤖 Merge PR DefinitelyTyped#72557 gulp-flatmap: add type for package by @SamB
1 parent a5ef554 commit 42c433c

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

types/gulp-flatmap/.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import gulp = require("gulp");
2+
import flatmap = require("gulp-flatmap");
3+
import uglify = require("gulp-uglify");
4+
import path = require("path");
5+
import concat = require("gulp-concat");
6+
7+
gulp.task("default", function() {
8+
return gulp.src("*.json")
9+
.pipe(flatmap(function(stream, file) {
10+
var contents = JSON.parse(file.contents!.toString("utf8"));
11+
// contents.files is an array
12+
return gulp.src(contents.files)
13+
// uglify each file individually
14+
.pipe(uglify())
15+
// combine the files
16+
.pipe(concat(path.basename(file.path)));
17+
}))
18+
.pipe(gulp.dest("dist"));
19+
});

types/gulp-flatmap/index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as File from "vinyl";
2+
3+
export = gulp_flatmap;
4+
5+
/**
6+
* @param func
7+
*
8+
* The flatmap method takes one argument, a function. This function is called once for each file
9+
* piped to flatmap and is passed a stream as its first argument and the vinyl file as its second
10+
* argument. The stream contains only one file.
11+
*
12+
* You can now pipe this stream through as many steps as you want, before returning it from the
13+
* function. All the streams returned from flatmap will be combined and their contents will be
14+
* emited by flatmap.
15+
*
16+
* @todo Generify if <https://github.com/DefinitelyTyped/DefinitelyTyped/issues/2134> is ever solved
17+
*/
18+
declare function gulp_flatmap(
19+
func: (stream: NodeJS.ReadableStream, file: File) => NodeJS.ReadableStream,
20+
): NodeJS.ReadWriteStream;

types/gulp-flatmap/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"private": true,
3+
"name": "@types/gulp-flatmap",
4+
"version": "1.0.9999",
5+
"projects": [
6+
"https://github.com/mariusGundersen/gulp-flatmap#readme"
7+
],
8+
"devDependencies": {
9+
"@types/gulp": "*",
10+
"@types/gulp-concat": "*",
11+
"@types/gulp-flatmap": "workspace:.",
12+
"@types/gulp-uglify": "*"
13+
},
14+
"dependencies": {
15+
"@types/node": "*",
16+
"@types/vinyl": "*"
17+
},
18+
"owners": [
19+
{
20+
"name": "Samuel Bronson",
21+
"githubUsername": "SamB"
22+
}
23+
]
24+
}

types/gulp-flatmap/tsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"module": "node16",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"types": [],
12+
"noEmit": true,
13+
"forceConsistentCasingInFileNames": true
14+
},
15+
"files": [
16+
"index.d.ts",
17+
"gulp-flatmap-tests.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)