# @asset-toolkit/core

> Core asset-toolkit

Latest version **0.10.8** (published 2022-05-31) · 0 weekly downloads

## Install

```sh
npm install @asset-toolkit/core
pnpm add @asset-toolkit/core
yarn add @asset-toolkit/core
bun add @asset-toolkit/core
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.8 |
| Published | 2022-05-31 |
| First published | 2021-05-31 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 81.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aquestdigital |

## Links

- npm: https://www.npmjs.com/package/@asset-toolkit/core
- npm.io page: https://npm.io/package/@asset-toolkit/core

## Dependencies (4)

- [del](https://npm.io/package/del.md) ^6.0.0
- [ora](https://npm.io/package/ora.md) ^5.4.0
- [uid](https://npm.io/package/uid.md) ^2.0.0
- [chalk](https://npm.io/package/chalk.md) ^4.1.1

## Recent versions

- 0.10.8 (latest) — 2022-05-31
- 0.10.7 — 2022-05-28
- 0.10.6 — 2022-05-28
- 0.10.5 — 2022-05-28
- 0.10.2 — 2022-04-16
- 0.10.1 — 2022-03-12
- 0.10.0 — 2022-03-08
- 0.9.4 — 2022-01-24
- 0.9.3 — 2022-01-04
- 0.9.1 — 2021-12-24
- 0.9.0 — 2021-12-22
- 0.8.3 — 2021-12-15
- 0.8.2 — 2021-12-13
- 0.8.0 — 2021-11-30
- 0.7.0 — 2021-11-29
- … 21 more at https://npm.io/package/@asset-toolkit/core/versions

## README

[@asset-toolkit/core](README.md) / Exports

# @asset-toolkit/core

## Table of contents

### Variables

- [removeDir](modules.md#removedir)

### Functions

- [changeExtension](modules.md#changeextension)
- [checkFileExt](modules.md#checkfileext)
- [copyFiles](modules.md#copyfiles)
- [getUID](modules.md#getuid)
- [logger](modules.md#logger)
- [pipeline](modules.md#pipeline)
- [prepareOutputDir](modules.md#prepareoutputdir)
- [watchPipeline](modules.md#watchpipeline)

## Variables

### removeDir

• `Const` **removeDir**: `any`

#### Defined in

index.d.ts:1

## Functions

### changeExtension

▸ `Const` **changeExtension**(`file`, `extension`): `string`

#### Parameters

| Name | Type |
| :------ | :------ |
| `file` | `string` |
| `extension` | `string` |

#### Returns

`string`

#### Defined in

index.d.ts:22

___

### checkFileExt

▸ `Const` **checkFileExt**(`file`, `exts`): `boolean`

#### Parameters

| Name | Type |
| :------ | :------ |
| `file` | `string` |
| `exts` | `string`[] |

#### Returns

`boolean`

#### Defined in

index.d.ts:8

___

### copyFiles

▸ `Const` **copyFiles**(`pathIn`, `pathOut`, `exts?`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `pathIn` | `string` |
| `pathOut` | `string` |
| `exts?` | `string`[] |

#### Returns

`void`

#### Defined in

index.d.ts:9

___

### getUID

▸ `Const` **getUID**(`size`): `any`

#### Parameters

| Name | Type |
| :------ | :------ |
| `size` | `number` |

#### Returns

`any`

#### Defined in

index.d.ts:11

___

### logger

▸ `Const` **logger**(): `Object`

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `error` | (`value`: `any`) => `any` |
| `info` | (`value`: `any`) => `any` |
| `start` | (`value`: `any`) => `any` |
| `success` | (`value`: `any`) => `any` |

#### Defined in

index.d.ts:2

___

### pipeline

▸ `Const` **pipeline**(...`fns`): (`props`: `any`, `options`: `any`[], `callback?`: `any`[]) => `any`

#### Parameters

| Name | Type |
| :------ | :------ |
| `...fns` | `any` |

#### Returns

`fn`

▸ (`props`, `options`, `callback?`): `any`

##### Parameters

| Name | Type |
| :------ | :------ |
| `props` | `any` |
| `options` | `any`[] |
| `callback?` | `any`[] |

##### Returns

`any`

#### Defined in

index.d.ts:12

___

### prepareOutputDir

▸ `Const` **prepareOutputDir**(`pathOut`, `exts`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `pathOut` | `string` |
| `exts` | `string`[] |

#### Returns

`void`

#### Defined in

index.d.ts:10

___

### watchPipeline

▸ `Const` **watchPipeline**(`pipeline`, `props`, `options?`, `callback?`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `pipeline` | `any` |
| `props` | `Object` |
| `props.pathIn` | `string` |
| `props.pathOut` | `string` |
| `options?` | `any`[] |
| `callback?` | `any`[] |

#### Returns

`void`

#### Defined in

index.d.ts:13



# Asset ToolKits

Node.js toolkits to optimize media assets.

## Use a pipeline

A pipe function to concatenate toolkits.

```js
const { pipeline } = require('@asset-toolkit/core')

const pipelineExample = pipeline(...fn)

pipelineExample({
  pathIn: './exampleIn/',
  pathOut: '../../exampleOut/',
})
```

## Example with pipeline

With **audio-sprite** and **json-minify** tools.
Use the function returned from _pipeline_ to pass **props** and **options**.

The **options** is an array of object.
Every object is linked to tools function passed to _pipeline_ by our order.

```bash
npm i
@asset-toolkit/core
@asset-toolkit/audio-sprite
@asset-toolkit/json-minify
```

```js
const { pipeline } = require('@asset-toolkit/core')
const audioSprite = require('@asset-toolkit/audio-sprite')
const jsonMinify = require('@asset-toolkit/json-minify')
```

```js
const options = [
  {
    output: 'spriteTrack',
    export: 'mp3, m4a',
  },
] // first argument for first tool in pipeline

const pipelineAudio = pipeline(audioSprite, jsonMinify)

pipelineAudio(
  {
    pathIn: './audio/',
    pathOut: '../public/audio',
  },
  options,
)
```

## Example with watcher

For relaunch automatically your pipeline everytime you add or modify the files in input folder.

```js
const { pipeline, watchPipeline } = require('@asset-toolkit/core')
const jsonMinify = require('@asset-toolkit/json-minify')
```

```js
const options = [
  {
    output: 'spriteTrack',
    export: 'mp3, m4a',
  },
] // first argument for first tool in pipeline

const pipelineJSON = pipeline(jsonMinify)

watchPipeline(pipelineJSON, {
  pathIn: './json/',
  pathOut: '../public/json',
})
```

## How to use

Create a js file "example.js", with your code (import and configure the pipelines like examples).

Run your code with node: **`node example.js`**

## License

[MIT](LICENSE.md)

---
_Source: https://npm.io/package/@asset-toolkit/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
