CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
README.md81 linesDownload Raw Back to ee-first
1# EE First2 3[![NPM version][npm-image]][npm-url]4[![Build status][travis-image]][travis-url]5[![Test coverage][coveralls-image]][coveralls-url]6[![License][license-image]][license-url]7[![Downloads][downloads-image]][downloads-url]8[![Gittip][gittip-image]][gittip-url]9 10Get the first event in a set of event emitters and event pairs,11then clean up after itself.12 13## Install14 15```sh16$ npm install ee-first17```18 19## API20 21```js22var first = require('ee-first')23```24 25### first(arr, listener)26 27Invoke `listener` on the first event from the list specified in `arr`. `arr` is28an array of arrays, with each array in the format `[ee, ...event]`. `listener`29will be called only once, the first time any of the given events are emitted. If30`error` is one of the listened events, then if that fires first, the `listener`31will be given the `err` argument.32 33The `listener` is invoked as `listener(err, ee, event, args)`, where `err` is the34first argument emitted from an `error` event, if applicable; `ee` is the event35emitter that fired; `event` is the string event name that fired; and `args` is an36array of the arguments that were emitted on the event.37 38```js39var ee1 = new EventEmitter()40var ee2 = new EventEmitter()41 42first([43  [ee1, 'close', 'end', 'error'],44  [ee2, 'error']45], function (err, ee, event, args) {46  // listener invoked47})48```49 50#### .cancel()51 52The group of listeners can be cancelled before being invoked and have all the event53listeners removed from the underlying event emitters.54 55```js56var thunk = first([57  [ee1, 'close', 'end', 'error'],58  [ee2, 'error']59], function (err, ee, event, args) {60  // listener invoked61})62 63// cancel and clean up64thunk.cancel()65```66 67[npm-image]: https://img.shields.io/npm/v/ee-first.svg?style=flat-square68[npm-url]: https://npmjs.org/package/ee-first69[github-tag]: http://img.shields.io/github/tag/jonathanong/ee-first.svg?style=flat-square70[github-url]: https://github.com/jonathanong/ee-first/tags71[travis-image]: https://img.shields.io/travis/jonathanong/ee-first.svg?style=flat-square72[travis-url]: https://travis-ci.org/jonathanong/ee-first73[coveralls-image]: https://img.shields.io/coveralls/jonathanong/ee-first.svg?style=flat-square74[coveralls-url]: https://coveralls.io/r/jonathanong/ee-first?branch=master75[license-image]: http://img.shields.io/npm/l/ee-first.svg?style=flat-square76[license-url]: LICENSE.md77[downloads-image]: http://img.shields.io/npm/dm/ee-first.svg?style=flat-square78[downloads-url]: https://npmjs.org/package/ee-first79[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square80[gittip-url]: https://www.gittip.com/jonathanong/81