<commit_before># worker-proxy
[![build status](https://travis-ci.org/ZenyWay/worker-proxy.svg?branch=master)](https://travis-ci.org/ZenyWay/worker-proxy)
[![Join the chat at https://gitter.im/ZenyWay/worker-proxy](https://badges.gitter.im/ZenyWay/worker-proxy.svg)](https://gitter.im/ZenyWay/worker-proxy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

proxy for web worker

# <a name="api"></a> API v0.0.1 experimental
Typescript compatible.

## example
### worker.ts (WorkerGlobalScope)
```ts
import { getWorkerServiceMixin } from 'worker-proxy'
/**
 * example:
 * export interface service {
 *   process (text: string): string
 * }
 */
import service from 'my-service'

const serviceMixin = getWorkerServiceMixin(service)
serviceMixin(self)
```

### index.ts
```ts
import { newServiceProxy } from 'worker-proxy'

const proxy = newServiceProxy('worker.ts')
const text = 'Hello World!'<commit_msg>simplify worker-side API<commit_after># worker-proxy
[![build status](https://travis-ci.org/ZenyWay/worker-proxy.svg?branch=master)](https://travis-ci.org/ZenyWay/worker-proxy)
[![Join the chat at https://gitter.im/ZenyWay/worker-proxy](https://badges.gitter.im/ZenyWay/worker-proxy.svg)](https://gitter.im/ZenyWay/worker-proxy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

local proxy for web worker running a given service.

# <a name="api"></a> API v0.0.1 experimental
Typescript compatible.

## example
### worker.ts (WorkerGlobalScope)
```ts
import { extendWorker } from 'worker-proxy'
/**
 * example:
 * export interface newService {
 *   (spec?: Object): service
 * }
 * export interface service {
 *   process (text: string): string
 * }
 */
import newService from 'my-service'
const spec = { /* service configuration options */ }
const service = newService(spec)

extendWorker(self, service)
// service can now be accessed from parent process
```

### index.ts
```ts
import { newServiceProxy } from 'worker-proxy'

const proxy = newServiceProxy('worker.ts') // spawn the Worker
const text = 'Hello World!'
{'fraction_non_alphanumeric': 0.157487922705314, 'fraction_numerical': 0.002898550724637681, 'mean_word_length': 5.2379518072289155, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4564057', 'n_tokens_mistral': 702, 'n_tokens_neox': 692, 'n_words': 143}