# waifulabs-api

> Minimal OOP implementation to interact with waifulabs API

Latest version **1.0.1** (published 2021-01-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install waifulabs-api
pnpm add waifulabs-api
yarn add waifulabs-api
bun add waifulabs-api
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-01-30 |
| First published | 2021-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yuu6883 |
| Maintainers | yuu6883 |
| Keywords | waifu, waifulabs |

## Links

- npm: https://www.npmjs.com/package/waifulabs-api
- Repository: https://github.com/Yuu6883/WaifulabsAPI
- Homepage: https://github.com/Yuu6883/WaifulabsAPI#readme
- Issues: https://github.com/Yuu6883/WaifulabsAPI/issues
- npm.io page: https://npm.io/package/waifulabs-api

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1

## Recent versions

- 1.0.1 (latest) — 2021-01-30
- 1.0.0 — 2021-01-30

## README

# Waifulabs-API
Minimal (<50 lines) OOP implementation to interact with waifulabs API

## Installation
npm i waifulabs-api

## Example
Also available in `example.js`.
```js
const fs = require("fs"), Waifu = require("waifulabs-api");

const dir = i => `example-step-${i}`;
// Clean up directory
for (const i in "0000") fs.existsSync(dir(i)) && fs.rmSync(dir(i), { recursive: true, force: true }), fs.mkdirSync(dir(i));

// Helper function to dump the buffers
const dumper = (step = 0, prefix = "waifu") =>
    (d, i) => fs.writeFileSync(`${dir(step)}/${[prefix, i].join("-")}.jpg`, d.image);

(async() => {
    // Generate new waifu(s)
    const waifu = await Waifu.generate();
    waifu.images.map(dumper(waifu.step)); // Step0 doesn't have a selected waifu

    // waifu.proceed takes an index from -1 to 15 where -1 is to keep the current one while 0 - 15 are to choose from the generated ones
    for (let _ = 0; _ < 3; _++) {
        await waifu.proceed(); // Default to 0 on step0 or -1 otherwise
        waifu.images.concat([waifu.curr]).map(dumper(waifu.step));
    }

    // Go back to previous selected waifu
    waifu.back();
    waifu.back();
    waifu.back();

    // Now proceed again but with 11th waifu as baseline
    for (let _ = 0; _ < 3; _++) {
        await waifu.proceed(10);
        waifu.images.concat([waifu.curr]).map(dumper(waifu.step, "new"));
    }

    // Refresh waifu with current step and seeds
    await waifu.refresh();
    waifu.images.concat([waifu.curr]).map(dumper(waifu.step, "refreshed"));

    // Getting product (PILLOW or POSTER) images in buffers
    fs.writeFileSync(`${dir(3)}/pillow.jpg`, await waifu.getProduct("PILLOW"));
    fs.writeFileSync(`${dir(3)}/post.jpg`, await waifu.getProduct("POSTER"));
})();
```

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