UNPKG

4.26 kBTypeScriptView Raw
1/// <reference types="vinyl" />
2/// <reference types="node" />
3import { File } from "gulp-util";
4/**
5 * Creates a Gulp plugin stream that performs a user-defined transformation
6 * on file contents.
7 *
8 * @param encoding A character encoding used to convert the file contents to a string, or
9 * null to invoke the callback with a Buffer. Defaults to null.
10 * @param callback A callback describing the transformation. Invoked with (0) the file
11 * contents and (1) the File object. Returns either the new contents or a
12 * Promise for the new contents.
13 * @return Returns a Gulp plugin stream.
14 */
15declare function gulpTransform(encoding: gulpTransform.Encoding, callback: (contents: string, file: File) => string | PromiseLike<string>): NodeJS.ReadWriteStream;
16/**
17 * Creates a Gulp plugin stream that performs a user-defined transformation
18 * on file contents.
19 *
20 * @param encoding A character encoding used to convert the file contents to a string, or
21 * null to invoke the callback with a Buffer. Defaults to null.
22 * @param callback A callback describing the transformation. Invoked with (0) the file
23 * contents and (1) the File object. Returns either the new contents or a
24 * Promise for the new contents.
25 * @return Returns a Gulp plugin stream.
26 */
27declare function gulpTransform(encoding: null, callback: (contents: Buffer, file: File) => Buffer | PromiseLike<Buffer>): NodeJS.ReadWriteStream;
28/**
29 * Creates a Gulp plugin stream that performs a user-defined transformation
30 * on file contents.
31 *
32 * @param options An object that accepts the following options:
33 * - encoding: A character encoding used to convert the file contents to
34 * a string, or null to invoke the callback with a Buffer. Defaults to
35 * null.
36 * - thisArg: The value of this within the callback. Defaults to
37 * undefined.
38 * @param callback A callback describing the transformation. Invoked with (0) the file
39 * contents and (1) the File object. Returns either the new contents or a
40 * Promise for the new contents.
41 * @return Returns a Gulp plugin stream.
42 */
43declare function gulpTransform(options: {
44 encoding: gulpTransform.Encoding;
45 thisArg?: any;
46}, callback: (contents: string, file: File) => string | PromiseLike<string>): NodeJS.ReadWriteStream;
47/**
48 * Creates a Gulp plugin stream that performs a user-defined transformation
49 * on file contents.
50 *
51 * @param options An object that accepts the following options:
52 * - encoding: A character encoding used to convert the file contents to
53 * a string, or null to invoke the callback with a Buffer. Defaults to
54 * null.
55 * - thisArg: The value of this within the callback. Defaults to
56 * undefined.
57 * @param callback A callback describing the transformation. Invoked with (0) the file
58 * contents and (1) the File object. Returns either the new contents or a
59 * Promise for the new contents.
60 * @return Returns a Gulp plugin stream.
61 */
62declare function gulpTransform(options: {
63 encoding?: null;
64 thisArg?: any;
65}, callback: (contents: Buffer, file: File) => Buffer | PromiseLike<Buffer>): NodeJS.ReadWriteStream;
66/**
67 * Creates a Gulp plugin stream that performs a user-defined transformation
68 * on file contents.
69 *
70 * @param callback A callback describing the transformation. Invoked with (0) the file
71 * contents and (1) the File object. Returns either the new contents or a
72 * Promise for the new contents.
73 * @return Returns a Gulp plugin stream.
74 */
75declare function gulpTransform(callback: (contents: Buffer, file: File) => Buffer | PromiseLike<Buffer>): NodeJS.ReadWriteStream;
76declare namespace gulpTransform {
77 /**
78 * A character encoding supported by Node.js.
79 */
80 type Encoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex";
81}
82export = gulpTransform;