File: index.d.ts

package info (click to toggle)
node-gulp-util 3.0.36%2B~cs7.1.15-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 708 kB
  • sloc: javascript: 1,591; makefile: 3
file content (53 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/// <reference types="node" />
import File = require("vinyl");

/**
 * Represents options for `gulp-replace`.
 */
interface Options {
    /**
     * A value indicating whether binary files should be skipped.
     */
    skipBinary?: boolean
}

/**
 * The context of the replacer-function.
 */
interface ReplacerContext {
    /**
     * The file being processed.
     */
    file: File
}

/**
 * Represents a method for replacing contents of a vinyl-file.
 */
type Replacer = (this: ReplacerContext, match: string, ...args: any[]) => string;

/**
 * Searches and replaces a portion of text using a `string` or a `RegExp`.
 *
 * @param search       The `string` or `RegExp` to search for.
 *
 * @param replacement  The replacement string or a function for generating a replacement.
 *
 *                     If `replacement` is a function, it will be called once for each match and will be passed the string
 *                     that is to be replaced. The value of `this.file` will be equal to the vinyl instance for the file
 *                     being processed.
 *
 *                     Read more at [`String.prototype.replace()` at MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter").
 *
 * @param options      `options.skipBinary` will be equal to `true` by default.
 *
 *                     Skip binary files. This option is `true` by default. If
 *                     you want to replace content in binary files, you must explicitly set it to `false`.
 */
declare function replace(
    search: string | RegExp,
    replacement: string | Replacer,
    options?: Options
): NodeJS.ReadWriteStream;

export = replace;