### Installing Kefir via Bower Source: https://github.com/kefirjs/kefir/blob/master/README.md This command installs the Kefir library using Bower. It's used for front-end package management, making Kefir available for web projects. ```sh bower install kefir ``` -------------------------------- ### Installing Kefir via NPM Source: https://github.com/kefirjs/kefir/blob/master/README.md This command installs the Kefir library using the Node Package Manager (NPM). It adds Kefir as a dependency to your project, making it available for use in JavaScript applications. ```sh npm install kefir ``` -------------------------------- ### Running Kefir Development Scripts Source: https://github.com/kefirjs/kefir/blob/master/README.md This snippet lists various `npm run` commands used for Kefir development. These scripts automate tasks such as code formatting (`prettify`), JavaScript bundling (`build-js`), running tests (`test`, `test-only`, `test-debug`), and building documentation (`build-docs`), streamlining the development workflow. ```sh npm run prettify # makes source code pretty (you must run it before a PR could be merged) npm run build-js # builds js bundlers npm run test # runs all the checks npm run test-only # runs only unit tests without other checks npm run test-debug # runs tests with a chrome inspector connected to the node process npm run build-docs # builds the documentation html file ``` -------------------------------- ### Using Kefir with Flow Type Checking Source: https://github.com/kefirjs/kefir/blob/master/README.md This JavaScript snippet demonstrates how to use Kefir with Flow for type checking. It shows how Flow can infer stream types (e.g., Kefir.Observable) and ensure type safety when working with observable values, improving code reliability. ```js // @flow import Kefir from 'kefir' function foo(numberStream: Kefir.Observable) { numberStream.onValue(x => { // Flow knows x is a number here }) } const s = Kefir.constant(5) // Flow can automatically infer the type of values in the stream and determine // that `s` is of type Kefir.Observable here. foo(s) ``` -------------------------------- ### Checking Awaiting Status with `awaiting` in Kefir.js Source: https://github.com/kefirjs/kefir/blob/master/deprecated-api-docs.md Returns a property that represents the awaiting status of two observables, answering whether the primary observable has emitted a value since the last value from the `otherObs` observable was emitted. This method helps track the synchronization or pending state between two observable streams. ```JavaScript var foo = Kefir.sequentially(100, [1, 2, 3]); var bar = Kefir.sequentially(100, [1, 2, 3]).delay(40); var result = foo.awaiting(bar); result.log(); ``` -------------------------------- ### Converting Errors to Values with `errorsToValues` in Kefir.js Source: https://github.com/kefirjs/kefir/blob/master/deprecated-api-docs.md Converts errors emitted by an observable into values, acting as the inverse of `valuesToErrors`. A custom `handler` function can be provided, which receives the error and must return an object `{convert: Boolean, value: AnyType}`. If `convert` is true, the specified `value` is emitted; otherwise, the original error is passed through. ```JavaScript var source = Kefir.sequentially(100, [0, -1, 2, -3]).valuesToErrors(); var result = source.errorsToValues(x => { return { convert: x >= 0, value: x * 2 }; }); result.log(); ``` -------------------------------- ### Converting Values to Errors with `valuesToErrors` in Kefir.js Source: https://github.com/kefirjs/kefir/blob/master/deprecated-api-docs.md Converts values emitted by an observable into errors. By default, all values are converted. A custom `handler` function can be provided, which receives the value and must return an object `{convert: Boolean, error: AnyType}`. If `convert` is true, the specified `error` is emitted; otherwise, the original value is passed through. ```JavaScript var source = Kefir.sequentially(100, [0, -1, 2, -3]); var result = source.valuesToErrors(x => { return { convert: x < 0, error: x * 2 }; }); result.log(); ``` -------------------------------- ### Ending Observable on First Error with `endOnError` in Kefir.js Source: https://github.com/kefirjs/kefir/blob/master/deprecated-api-docs.md Modifies an observable to terminate (end) immediately upon emitting its first error. Subsequent values or errors from the original source will not be propagated after an error occurs. ```JavaScript var source = Kefir.sequentially(100, [0, -1, 2, -3]) .valuesToErrors(x => { return {convert: x < 0, error: x}; }); var result = source.endOnError() result.log(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.