# wkn

> wkn is easy possible to run a script operation in a background thread from module bundler.

Latest version **1.0.9** (published 2018-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install wkn
pnpm add wkn
yarn add wkn
bun add wkn
```

## 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.9 |
| Published | 2018-12-24 |
| First published | 2018-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | hand-dot |
| Maintainers | hand-dot |
| Keywords | web worker, module bundler |

## Links

- npm: https://www.npmjs.com/package/wkn
- Repository: https://github.com/hand-dot/wkn
- Homepage: https://github.com/hand-dot/wkn#readme
- Issues: https://github.com/hand-dot/wkn/issues
- npm.io page: https://npm.io/package/wkn

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 1.0.9 (latest) — 2018-12-24
- 1.0.8 — 2018-12-24
- 1.0.6 — 2018-12-19
- 1.0.5 — 2018-12-19
- 1.0.4 — 2018-09-30
- 1.0.3 — 2018-09-29
- 1.0.2 — 2018-09-29
- 1.0.1 — 2018-09-05
- 1.0.0 — 2018-09-03

## README

[![Build Status](https://travis-ci.org/hand-dot/wkn.svg?branch=master)](https://travis-ci.org/hand-dot/wkn)

![cooltext297452362996449](https://user-images.githubusercontent.com/24843808/45003797-faebce80-b020-11e8-95c8-021c2caf9e4f.gif)

wkn is easy possible to run the processing to another thread.
  

# Concept

* Simple API
* No Config
* Light

# Installing
```bash
$ npm install wkn
```

# Example
```javascript  
import wkn from 'wkn';

/**
* Takes function and arguments, moves the processing to another thread,
* and receives the processing result on Promise.
* @param {Function} function to have retunrn value. (Be processed in Web Worker context)
* @param  {...*}  [arguments] arguments
* @returns  {Promise} Returns Processing result as Promise
*/

// Simple usage
wkn(arg => arg + 1, 100)
  .then((value) => {
    console.log(value); // 101
  });

// Two arguments
wkn((arg1, arg2) => `${arg1}!${arg2}!`, 'hoge', 'foo')
  .then((value) => {
    console.log(value); // hoge!foo!
  });

// Use moment.js
wkn((years, months, days, hours, minutes, seconds) => {
  importScripts('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js');
  const m = moment(new Date(years, months, days, hours, minutes, seconds));
  return m.hours();
}, 2011, 2, 12, 5, 0, 0)
  .then((value) => {
    console.log(value); // 5
  });

// Heavy processing
wkn(() => {
  let num = 0;
  for (let i = 0; i < 100000000; i++) {
    num += i;
  }
  return num;
})
  .then((value) => {
    console.log(value); // 4999999950000000
  });

// onRejected
wkn(arg => arg.map(_ => `${_}!`), {})
  .then((value) => {
    console.log(value); // not fire
  }, (reason) => {
    console.error(reason); // arg.map is not a functio
  });
```

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