# tokalite

> An alternative api for the opentok js library.

Latest version **0.0.3** (published 2016-02-19) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2016-02-19 |
| First published | 2016-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrew Morris |
| Maintainers | voltrevo |
| Keywords | opentok, tokbox, webrtc, video |

## Links

- npm: https://www.npmjs.com/package/tokalite
- Repository: https://github.com/voltrevo/tokalite
- Homepage: https://github.com/voltrevo/tokalite#readme
- Issues: https://github.com/voltrevo/tokalite/issues
- npm.io page: https://npm.io/package/tokalite

## Dependencies (3)

- [bluebird](https://npm.io/package/bluebird.md) ^3.1.2
- [js-base64](https://npm.io/package/js-base64.md) ^2.1.9
- [event-emitter](https://npm.io/package/event-emitter.md) ^0.3.4

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2016-02-19
- 0.0.2 — 2016-01-27
- 0.0.1 — 2016-01-25

## README

# tokalite [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]
> An alternative api for the opentok js library.


## Install

```sh
$ npm install --save tokalite
```


## Usage

### Publish to a session and subscribe to all streams

```js
'use strict';

var tokalite = require('tokalite');

var token = '(your opentok token)';

Promise.all(
  tokalite.connect(token),
  tokalite.createPublisher()
).then(function(res) {
  var session = res[0];
  var publisher = res[1];

  publisher.publish(session);

  session.on('stream', function(stream) {
    stream.subscribe();
  });
});
```

### `tokalite.connect(token)`

Takes an opentok token and returns a promise to a `Session`.

### `Session`

| Method | Description |
|--------|-------------|
| `.isConnected()` | Returns a boolean indicating whether the connection is still alive. |
| `.getDisconnectionPromise()` | Returns a promise that resolves when the session is disconnected. |
| `.getStreams()` | Returns an array of external streams associated with the session (no publishers). |

| Event | Description |
|-------|-------------|
| stream | Emits a `Stream` when one becomes available. |

### `Stream`

| Method | Description |
|--------|-------------|
| `.subscribe(targetElement?, properties?)` | Returns a promise to a `Subscriber`. Optional arguments `targetElement` and `properties` are passed to [`session.subscribe`](https://tokbox.com/developer/sdks/js/reference/Session.html#subscribe) in opentok.js |
| `.isConnected()` | Returns a boolean indicating whether the stream is still available. |
| `.getDisconnectionPromise()` | Returns a promise that resolves when the stream becomes unavailable. |

### `Subscriber`

| Method | Description |
|--------|-------------|
| remove | Removes the subscriber from the DOM and the subscription to the stream. |

| Property | Description |
|----------|-------------|
| stream | The stream being subscribed to. |

### `tokalite.createPublisher(targetElement?, properties?)`

Returns a promise to a `Publisher`. `targetElement` and `properties` are optional and passed to [`OT.initPublisher()`](https://tokbox.com/developer/sdks/js/reference/OT.html#initPublisher).

### `Publisher`

| Method | Description |
|--------|-------------|
| `.publish(session)` | Publishes to the provided session. Returns a promise to a `PublishHandle`. |
| `.remove()` | Removes the publisher from the DOM and any session published to. |

### `PublishHandle`

| Method | Description |
|--------|-------------|
| `.stop()` | Stops publishing to the session. |

## License

MIT © [Andrew Morris](https://andrewmorris.io/)


[npm-image]: https://badge.fury.io/js/tokalite.svg
[npm-url]: https://npmjs.org/package/tokalite
[travis-image]: https://travis-ci.org/voltrevo/tokalite.svg?branch=master
[travis-url]: https://travis-ci.org/voltrevo/tokalite
[daviddm-image]: https://david-dm.org/voltrevo/tokalite.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/voltrevo/tokalite
[coveralls-image]: https://coveralls.io/repos/voltrevo/tokalite/badge.svg
[coveralls-url]: https://coveralls.io/r/voltrevo/tokalite

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