{"id":19063424,"url":"https://github.com/nmuldavin/observableoperators","last_synced_at":"2025-08-06T16:27:44.539Z","repository":{"id":57313096,"uuid":"101717288","full_name":"nmuldavin/ObservableOperators","owner":"nmuldavin","description":"A library of simple ES observable operations","archived":false,"fork":false,"pushed_at":"2018-05-06T17:40:08.000Z","size":1413,"stargazers_count":7,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T14:34:19.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nmuldavin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-29T04:01:14.000Z","updated_at":"2018-06-27T08:10:50.000Z","dependencies_parsed_at":"2022-09-20T23:21:28.835Z","dependency_job_id":null,"html_url":"https://github.com/nmuldavin/ObservableOperators","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmuldavin%2FObservableOperators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmuldavin%2FObservableOperators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmuldavin%2FObservableOperators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmuldavin%2FObservableOperators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nmuldavin","download_url":"https://codeload.github.com/nmuldavin/ObservableOperators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250847532,"owners_count":21497211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T00:35:49.646Z","updated_at":"2025-04-25T15:44:14.901Z","avatar_url":"https://github.com/nmuldavin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ObservableOperators\n\n[![Build Status](https://travis-ci.org/nmuldavin/ObservableOperators.svg?branch=master)](https://travis-ci.org/nmuldavin/ObservableOperators)\n[![Coverage Status](https://coveralls.io/repos/github/nmuldavin/ObservableOperators/badge.svg?branch=master)](https://coveralls.io/github/nmuldavin/ObservableOperators?branch=master)\n[![npm version](https://badge.fury.io/js/observable-operators.svg)](https://badge.fury.io/js/observable-operators)\n\nA library of [Reactive Operators](http://reactivex.io/documentation/operators.html) built with [ECMAScript Observables](https://github.com/tc39/proposal-observable) from the ground up.\n\n* Flexible - Operators can be expressed in functional or fluent format\n* Small - If you want everything there's RxJS, this library has a small set of canonical operators\n* Well [documented](https://nmuldavin.github.io/ObservableOperators/)\n\n\n## Install\n\nInstall with `npm` or `yarn`:\n\n```\nnpm install observable-operators\n```\n\nYou will need an ES Observable polyfill. I recommend [zen-observable](https://github.com/zenparsing/zen-observable).\n\n## Use\n\nThis library's default export will add all available methods to the `Observable` constructor and prototype so that they may be chained in the reactive style:\n\n```\nimport addAll from 'observable-operators';\n\naddAll();\n\nObservable.fromEvent(document, 'click')\n  .merge(otherClicks)\n  .map(parseEvent)\n  .filter(theOnesICareAbout)\n  .subscribe(console.log);\n```\n\nWith `require` the `addAll` method can be called inline:\n\n```\nrequire('observable-operators').addAll();\n```\n\n`Observable` and `Observable.prototype` *will not be modified unless this function is invoked*. If you wish to have all operators available, you should import this module somewhere high-up so that it runs before the rest of your code.\n\n### Specifying another target\n\nIf you do not wish to modify the global `Observable` you can pass in a different target object:\n\n```\naddAll(MyObservable)\n```\n\nThis will allow chaining on your custom Observable as long as it has the core methods specified in the [Observable proposal](https://github.com/tc39/proposal-observable).\n\n### Method types\n\nThis library distinguishes between `Operators` and `Creators`\n* `Operators`: Functions that take at least one Observable as input and return something else (either another Observable, a Promise, or other value). All Operators take an Observable as the first argument. This allows them to be used either directly as functions:\n\n  ```\n  import { map } from 'observable-operators';\n\n  map(Observable.of(1, 2, 3), x =\u003e x + 1)\n    .subscribe(console.log)\n  ```\n\n  or as chainable methods once the operators are added to `Observable.prototype`:\n\n  ```\n  Observable.of(1, 2, 3)\n    .map(x =\u003e x + 1)\n    .merge(otherStream)\n    .filter(isOdd)\n    .subscribe(console.log)\n  ```\n\n  The helper method `addOperators` is used to add operators to `Observable.prototype` as part of the library's root method. If you wish to cherrypick operators you can do so:\n  ```\n  import { addOperators, filter, merge } from 'observable-operators'\n\n  addOperators(Observable.prototype, [filter, merge])\n  ```\n\n* `Creators`: Functions that take other things as inputs and return Observables. Creators may be used directly as functions:\n\n  ```\n  import { fromEvent } from 'observable-operators'\n\n  fromEvent(document, 'click').subscribe(handleEvent)\n  ```\n\n  or once added to the `Observable` constructor or another constructor, may be accessed as static methods:\n\n  ```\n  Observable.fromEvent(document, 'click').subscribe(handleEvent)\n  ```\n\n  If used as static methods creators will return an instance of the Constructor method to which they are assigned:\n  ```\n  MyObservable.interval(1) instanceof MyObservable // true\n  ```\n  If used directly as a function, a Constructor may be passed in as an optional final argument:\n  ```\n    interval(1000, MyObservable) instanceof MyObservable // true\n  ```\n\n  By default, creators will return an instance of the global Observable.\n\n  The helper function `addCreators` is used to add creators to the Observable constructor as part of the library's root method. If you wish to cherrypick creators you may do so:\n\n  ```\n  import { addCreators, interval, fromEvent } from 'observable-operators'\n\n  addCreators(Observable, [interval, fromEvent])\n  ```\n\n## Available Methods\n\n### Creators\n* [defer](https://nmuldavin.github.io/ObservableOperators/#defer)\n* [error](https://nmuldavin.github.io/ObservableOperators/#error)\n* [fromEvent](https://nmuldavin.github.io/ObservableOperators/#fromevent)\n* [fromPromise](https://nmuldavin.github.io/ObservableOperators/#frompromise)\n* [interval](https://nmuldavin.github.io/ObservableOperators/#interval)\n\n### Operators\n* [catchError](https://nmuldavin.github.io/ObservableOperators/#catcherror)\n* [concat](https://nmuldavin.github.io/ObservableOperators/#concat)\n* [debounce](https://nmuldavin.github.io/ObservableOperators/#debounce)\n* [delay](https://nmuldavin.github.io/ObservableOperators/#delay)\n* [filter](https://nmuldavin.github.io/ObservableOperators/#filter)\n* [flatMap](https://nmuldavin.github.io/ObservableOperators/#flatmap)\n* [forEach](https://nmuldavin.github.io/ObservableOperators/#foreach)\n* [map](https://nmuldavin.github.io/ObservableOperators/#map)\n* [merge](https://nmuldavin.github.io/ObservableOperators/#merge)\n* [reduce](https://nmuldavin.github.io/ObservableOperators/#reduce)\n* [scan](https://nmuldavin.github.io/ObservableOperators/#scan)\n* [skip](https://nmuldavin.github.io/ObservableOperators/#skip)\n* [skipLast](https://nmuldavin.github.io/ObservableOperators/#skiplast)\n* [skipUntil](https://nmuldavin.github.io/ObservableOperators/#skipuntil)\n* [startWith](https://nmuldavin.github.io/ObservableOperators/#startwith)\n* [take](https://nmuldavin.github.io/ObservableOperators/#take)\n* [takeLast](https://nmuldavin.github.io/ObservableOperators/#takelast)\n* [takeUntil](https://nmuldavin.github.io/ObservableOperators/#takeuntil)\n* [throttle](https://nmuldavin.github.io/ObservableOperators/#throttle)\n* [toArray](https://nmuldavin.github.io/ObservableOperators/#toarray)\n* [transform](https://nmuldavin.github.io/ObservableOperators/#transform)\n\n## Motivation\n\nThere are great existing reactive observable libraries out there already such as [most.js](https://github.com/cujojs/most) and [RxJS](https://github.com/Reactive-Extensions/RxJS), but none of them that are built from the bottom up on top of the [ECMAScript Observable](https://github.com/tc39/proposal-observables) proposal that will (hopefully) be part of the language. This is that library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmuldavin%2Fobservableoperators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmuldavin%2Fobservableoperators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmuldavin%2Fobservableoperators/lists"}