<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [syncGlob](#syncglob)
-   [NotifyCallback](#notifycallback)
-   [CloseFunc](#closefunc)
-   [copyFile](#copyfile)
-   [copyDir](#copydir)
-   [remove](#remove)
-   [TransformFunc](#transformfunc)
-   [isGlob](#isglob)
-   [resolveTarget](#resolvetarget)
-   [ResolveTargetFunc](#resolvetargetfunc)
-   [sourcesBases](#sourcesbases)
-   [trimQuotes](#trimquotes)

## syncGlob

Synchronise files, directories and/or glob patterns, optionally watching for changes.

**Parameters**

-   `sources` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>)** A list of files, directories and/or glob patterns.
-   `target` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The destination directory.
-   `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** An optional configuration object.
    -   `options.watch` **bool?** Enable or disable watch mode. (optional, default `false`)
    -   `options.delete` **bool?** Whether to delete the `target`'s content initially. (optional, default `true`)
    -   `options.depth` **bool?** Chokidars `depth` (If set, limits how many levels of subdirectories will be traversed). (optional, default `Infinity`)
    -   `options.transform` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** A module path resolved by node's `require`. (optional, default `false`)
-   `notify` **[NotifyCallback](#notifycallback)?** An optional notification callback.

Returns **[CloseFunc](#closefunc)** Returns a close function which cancels active promises and watch mode.

## NotifyCallback

This callback notifies you about various steps, like:

-   **copy:** File or directory has been copied to `target`.
-   **remove:** File or directory has been removed from `target`.
-   **no-delete:** No initial deletion of `target`s contents.
-   **mirror:** Initial copy of all `sources` to `target` done.
-   **watch:** Watch mode has started.
-   **error:** Any error which may occurred during program execution.

Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)

**Parameters**

-   `type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The type of notification.
-   `args` **...any** Event specific variadic arguments.

## CloseFunc

A cleanup function which cancels all active promises and closes watch mode if enabled.

Type: [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)

## copyFile

Copy file from `source` to `target`.

**Parameters**

-   `source` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** A file to be copied.
-   `target` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** A destination path where to copy.
-   `transform` **[TransformFunc](#transformfunc)?** Optional transformation function.

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** 

## copyDir

Copy a directory from `source` to `target` (w/o contents).

**Parameters**

-   `source` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** A directory to be copied.
-   `target` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** A destination path where to copy.

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** 

## remove

Remove a file or directory.

**Parameters**

-   `fileordir` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The file or directory to remove.

Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** 

## TransformFunc

A custom function which transforms a given `file` contents and/or `target`.

Type: [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)

**Parameters**

-   `file` **File** A file object obtained by `fs.readFile`.
-   `target` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The destination where to copy this `file`.

Returns **(File | {data: File, target: [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)})** Returns the transformed `file` and/or renamed `target`.

## isGlob

Determines whether a provided string contains a glob pattern.

**Parameters**

-   `str` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** The string to test for glob patterns.

Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Returns the index of the first glob pattern or `-1` if it is not a glob.

## resolveTarget

Determines the target structure by resolving a given `source` against a list of base paths.

**Parameters**

-   `bases` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>** An array of base paths.

Returns **[ResolveTargetFunc](#resolvetargetfunc)** Returns an `source` to `target` resolving function.

## ResolveTargetFunc

A function which resolves a given `source` to a given `target` based on list of base paths.

Type: [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)

**Parameters**

-   `source` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** A file or dir to be resolved against a list of base paths.
-   `target` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** A destination folder where to append the diff of `source` and `bases`.

Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returns an expanded `target`.

## sourcesBases

Determine the base paths of `sources` like:

-   **files:** `foo/bar.txt` -> `foo`
-   **directories:** `foo/bar/` -> `foo/bar`
-   **globs:** `foo/*` -> `foo`

**Parameters**

-   `sources` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>)** One or more files, directors or glob patterns.

Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>** Returns the base paths of `sources`.

## trimQuotes

Trim quotes of a given string.

**Parameters**

-   `str` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** A string.

Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Returns `str`, but trimmed from quotes like `'`, `"`.
