Skip to content
On this page

Home > entanclature > router

router() function

*Route for different parameters.

Signature:

typescript
export declare function router(path: string, meta: Meta, opts: Opts): Promise<Result>;

Parameters

ParameterTypeDescription
pathstringThe path of the image.
metaMetaThe meta information of the image.
optsOptsThe options for processing.

Returns:

Promise<Result>

The result of the processing.

Remarks

You can't use this function directly. You need to use it through entanclature.

This function passes the parameter to the fromFile() as the parameter is a file path.

In this case, you should tell us how to handle the image (meta) and manually specify the baseURL and fileDir.

Example

typescript
import { entanclature } from "entanclature";

import type { Meta, Opts } from "entanclature";

const filePath = "./path/for/an/image.png";
const meta = [
  { type: "image/png", quality: 80 },
  { type: "image/avif", quality: "+" },
  { type: "image/webp", quality: "-" },
];
const opts: Opts = {
  baseURL: "https://example.com",
  fileDir: "/images/",
};
const result = await entanclature(filePath, meta, opts);

console.log(result);

Released under the CC-BY-SA-4.0 License.