Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

most-subject

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

most-subject - npm Package Compare versions

Comparing version 5.3.0 to 6.0.0

.config/tsconfig.commonjs.json

2

.vscode/settings.json
{
"typescript.tsdk": "./node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib"
}

@@ -0,3 +1,38 @@

<a name="6.0.0"></a>
# [6.0.0](https://github.com/mostjs-community/subject/compare/v1.0.0...v6.0.0) (2017-10-17)
<a name="1.0.0"></a>
# [1.0.0](https://github.com/mostjs-community/subject/compare/v5.3.0...v1.0.0) (2017-10-17)
### Bug Fixes
* fix Subject type ([cc52fbb](https://github.com/mostjs-community/subject/commit/cc52fbb))
### Features
* add Subject<A, B> type ([a9fc693](https://github.com/mostjs-community/subject/commit/a9fc693))
* default to id function ([d175d90](https://github.com/mostjs-community/subject/commit/d175d90))
* integrate proxy behavior ([300dd24](https://github.com/mostjs-community/subject/commit/300dd24))
* restrict the return type to streams ([a6d1c37](https://github.com/mostjs-community/subject/commit/a6d1c37))
* start fresh ([7f4f669](https://github.com/mostjs-community/subject/commit/7f4f669))
* upgrade compatibility for [@most](https://github.com/most)/core ([82eaa8f](https://github.com/mostjs-community/subject/commit/82eaa8f))
<a name="5.3.0"></a>
# [5.3.0](https://github.com/mostjs-community/subject/compare/v5.2.0...v5.3.0) (2016-12-11)
### Bug Fixes
* **tsconfig:** build es2015 modules to es5 source code ([5f1b94f](https://github.com/mostjs-community/subject/commit/5f1b94f))
<a name="5.2.0"></a>
# [5.2.0](https://github.com/mostjs-community/most-subject/compare/v5.1.0...v5.2.0) (2016-11-12)
# [5.2.0](https://github.com/mostjs-community/subject/compare/v5.1.0...v5.2.0) (2016-11-12)

@@ -7,3 +42,3 @@

<a name="5.1.0"></a>
# [5.1.0](https://github.com/mostjs-community/most-subject/compare/v5.0.0...v5.1.0) (2016-11-10)
# [5.1.0](https://github.com/mostjs-community/subject/compare/v5.0.0...v5.1.0) (2016-11-10)

@@ -13,3 +48,3 @@

* **error:** fix type signature ([4534e42](https://github.com/mostjs-community/most-subject/commit/4534e42))
* **error:** fix type signature ([4534e42](https://github.com/mostjs-community/subject/commit/4534e42))

@@ -19,3 +54,3 @@

<a name="5.0.0"></a>
# [5.0.0](https://github.com/mostjs-community/most-subject/compare/v4.1.1...v5.0.0) (2016-11-09)
# [5.0.0](https://github.com/mostjs-community/subject/compare/v4.1.1...v5.0.0) (2016-11-09)

@@ -25,6 +60,6 @@

* **holdSubject:** Fix holdSubject to buffer without consumer ([332827b](https://github.com/mostjs-community/most-subject/commit/332827b))
* **next:** remove unused imports ([c608fe0](https://github.com/mostjs-community/most-subject/commit/c608fe0))
* **SubjectSource:** allow source to be run after being disposed ([9caae7c](https://github.com/mostjs-community/most-subject/commit/9caae7c))
* **test:** Isolate test-related babel config ([7e778c5](https://github.com/mostjs-community/most-subject/commit/7e778c5))
* **holdSubject:** Fix holdSubject to buffer without consumer ([332827b](https://github.com/mostjs-community/subject/commit/332827b))
* **next:** remove unused imports ([c608fe0](https://github.com/mostjs-community/subject/commit/c608fe0))
* **SubjectSource:** allow source to be run after being disposed ([9caae7c](https://github.com/mostjs-community/subject/commit/9caae7c))
* **test:** Isolate test-related babel config ([7e778c5](https://github.com/mostjs-community/subject/commit/7e778c5))

@@ -34,5 +69,5 @@

* **combinators:** improve typings ([9035acf](https://github.com/mostjs-community/most-subject/commit/9035acf))
* **exports:** export BasicSubjectSource and HoldSubjectSource ([aa06c61](https://github.com/mostjs-community/most-subject/commit/aa06c61))
* **most-subject:** Rewrite for better typings, tree-shakable, and async subjects. ([b3408fe](https://github.com/mostjs-community/most-subject/commit/b3408fe))
* **combinators:** improve typings ([9035acf](https://github.com/mostjs-community/subject/commit/9035acf))
* **exports:** export BasicSubjectSource and HoldSubjectSource ([aa06c61](https://github.com/mostjs-community/subject/commit/aa06c61))
* **most-subject:** Rewrite for better typings, tree-shakable, and async subjects. ([b3408fe](https://github.com/mostjs-community/subject/commit/b3408fe))

@@ -42,3 +77,3 @@

<a name="4.1.1"></a>
## [4.1.1](https://github.com/mostjs-community/most-subject/compare/v4.1.0...v4.1.1) (2016-05-29)
## [4.1.1](https://github.com/mostjs-community/subject/compare/v4.1.0...v4.1.1) (2016-05-29)

@@ -48,3 +83,3 @@

<a name="4.1.0"></a>
# [4.1.0](https://github.com/mostjs-community/most-subject/compare/v4.0.2...v4.1.0) (2016-05-29)
# [4.1.0](https://github.com/mostjs-community/subject/compare/v4.0.2...v4.1.0) (2016-05-29)

@@ -54,3 +89,3 @@

* **SubjectSource:** remove hard dep on [@most](https://github.com/most)/prelude ([af42d88](https://github.com/mostjs-community/most-subject/commit/af42d88))
* **SubjectSource:** remove hard dep on [@most](https://github.com/most)/prelude ([af42d88](https://github.com/mostjs-community/subject/commit/af42d88))

@@ -60,3 +95,3 @@

* **src:** rewrite in typescript ([1398833](https://github.com/mostjs-community/most-subject/commit/1398833))
* **src:** rewrite in typescript ([1398833](https://github.com/mostjs-community/subject/commit/1398833))

@@ -66,3 +101,3 @@

<a name="4.0.2"></a>
## [4.0.2](https://github.com/mostjs-community/most-subject/compare/v4.0.1...v4.0.2) (2016-05-17)
## [4.0.2](https://github.com/mostjs-community/subject/compare/v4.0.1...v4.0.2) (2016-05-17)

@@ -72,3 +107,3 @@

<a name="4.0.1"></a>
## [4.0.1](https://github.com/mostjs-community/most-subject/compare/v4.0.0...v4.0.1) (2016-05-17)
## [4.0.1](https://github.com/mostjs-community/subject/compare/v4.0.0...v4.0.1) (2016-05-17)

@@ -78,3 +113,3 @@

<a name="4.0.0"></a>
# [4.0.0](https://github.com/mostjs-community/most-subject/compare/v3.0.2...v4.0.0) (2016-05-16)
# [4.0.0](https://github.com/mostjs-community/subject/compare/v3.0.2...v4.0.0) (2016-05-16)

@@ -84,3 +119,3 @@

* rewrite to boost performance ([eccb337](https://github.com/mostjs-community/most-subject/commit/eccb337))
* rewrite to boost performance ([eccb337](https://github.com/mostjs-community/subject/commit/eccb337))

@@ -90,3 +125,3 @@

<a name="3.0.2"></a>
## [3.0.2](https://github.com/mostjs-community/most-subject/compare/v3.0.1...v3.0.2) (2016-03-24)
## [3.0.2](https://github.com/mostjs-community/subject/compare/v3.0.1...v3.0.2) (2016-03-24)

@@ -96,3 +131,3 @@

<a name="3.0.1"></a>
## [3.0.1](https://github.com/mostjs-community/most-subject/compare/1.0.0...v3.0.1) (2016-03-22)
## [3.0.1](https://github.com/mostjs-community/subject/compare/1.0.0...v3.0.1) (2016-03-22)

@@ -102,5 +137,5 @@

* close all issues ([1842e85](https://github.com/mostjs-community/most-subject/commit/1842e85)), closes [#1](https://github.com/mostjs-community/most-subject/issues/1) [#2](https://github.com/mostjs-community/most-subject/issues/2) [#3](https://github.com/mostjs-community/most-subject/issues/3) [#4](https://github.com/mostjs-community/most-subject/issues/4)
* reimplement replay and remove dep on [@most](https://github.com/most)/hold ([620b2c4](https://github.com/mostjs-community/most-subject/commit/620b2c4))
* rework api ([47e0eb6](https://github.com/mostjs-community/most-subject/commit/47e0eb6))
* close all issues ([1842e85](https://github.com/mostjs-community/subject/commit/1842e85)), closes [#1](https://github.com/mostjs-community/subject/issues/1) [#2](https://github.com/mostjs-community/subject/issues/2) [#3](https://github.com/mostjs-community/subject/issues/3) [#4](https://github.com/mostjs-community/subject/issues/4)
* reimplement replay and remove dep on [@most](https://github.com/most)/hold ([620b2c4](https://github.com/mostjs-community/subject/commit/620b2c4))
* rework api ([47e0eb6](https://github.com/mostjs-community/subject/commit/47e0eb6))

@@ -107,0 +142,0 @@

@@ -1,3 +0,10 @@

We'd highly appreciate your contribution to our source code to make this even better.
# Contributing
It would be greatly appreciated that when you make commits please use `npm run commit` instead of `git commit` to easily adhere to the commit message format in place.
First of all, thank you so much, we need your help.
## Contributing a fix or feature
1. Fork the repository
2. Switch to a new branch `git checkout -b [branchName]`
3. Produce your fix or feature
4. Submit a pull request for review
The MIT License (MIT)
Copyright (c) 2016 Tylor Steinberger
Copyright (c) 2017 Tylor Steinberger
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "most-subject",
"version": "5.3.0",
"description": "Subjects for most.js",
"main": "lib/commonjs/index.js",
"module": "lib/es2015/index.js",
"jsnext:main": "lib/es2015/index.js",
"typings": "lib/es2015/index.d.ts",
"scripts": {
"test:lint": "tslint src/**/*.ts src/*.ts",
"test:unit": "TS_NODE_PROJECT='test/tsconfig.json' mocha -r ts-node/register test/*.ts",
"test": "npm run test:lint && npm run test:unit",
"commit": "git-cz",
"changelog": "conventional-changelog --infile CHANGELOG.md --same-file --release-count 0 --preset angular",
"postchangelog": "git add CHANGELOG.md && git commit -m 'docs(CHANGELOG): append to changled' && git push origin master",
"build:es2015": "tsc -P tsconfig.json",
"build:commonjs": "tsc -P tsconfig-commonjs.json",
"build": "npm run build:es2015 && npm run build:commonjs",
"preversion": "npm run build",
"postversion": "git push origin master && git push origin --tags && npm publish && npm run changelog",
"release:minor": "npm version minor -m 'chore(package): v%s'",
"release:major": "npm version major -m 'chore(package): v%s'"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
},
"ghooks": {
"commit-msg": "node ./node_modules/.bin/validate-commit-msg"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/mostjs-community/most-subject.git"
},
"keywords": [
"most.js",
"subject"
],
"author": "Tylor Steinberger <tlsteinberger167@gmail.com> (github.com/TylorS)",
"description": "Subjects for @most/core",
"repository": "https://github.com/mostjs-community/subject",
"version": "6.0.0",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"typings": "lib/index.d.ts",
"jsnext:main": "lib.es2015/index.js",
"module": "lib.es2015/index.js",
"author": "Tylor Steinberger <tlsteinberger167@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/mostjs-community/most-subject/issues"
},
"homepage": "https://github.com/mostjs-community/most-subject#readme",
"devDependencies": {
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.46",
"commitizen": "^2.8.6",
"conventional-changelog": "^1.1.0",
"conventional-changelog-cli": "^1.2.0",
"cz-conventional-changelog": "^1.2.0",
"ghooks": "^1.3.2",
"mocha": "^3.1.2",
"ts-node": "^1.7.0",
"tslint": "^3.15.1",
"typescript": "^2.0.8",
"uglify-js": "^2.7.4",
"validate-commit-msg": "^2.8.2"
"@typed/test": "3.6.0",
"@types/node": "8.0.44",
"conventional-changelog-cli": "1.3.4",
"husky": "0.14.3",
"lint-staged": "4.2.3",
"prettier": "1.7.4",
"typescript": "2.5.2",
"validate-commit-message": "3.0.1"
},
"dependencies": {
"@most/multicast": "^1.2.4",
"@most/prelude": "^1.4.1",
"most": "^1.1.0"
"@most/core": "0.14.0",
"@most/prelude": "1.6.4",
"@most/types": "0.11.1"
},
"lint-staged": {
"*.ts": [
"prettier --write --print-width 80 --tab-width 2 --no-semi --single-quote --trailing-comma es5 --parser typescript",
"git add"
]
},
"scripts": {
"build": "yarn build:commonjs && yarn build:es2015",
"build:commonjs": "tsc -P .config/tsconfig.commonjs.json",
"build:es2015": "tsc -P .config/tsconfig.es2015.json",
"changelog": "conventional-changelog -i CHANGELOG.md -s -r 0 -p angular && git add CHANGELOG.md && git commit -m 'docs(CHANGELOG): amend changelog'",
"commitmsg": "validate-commit-msg",
"postversion": "yarn changelog && git push origin master --tags && npm publish --access=public",
"precommit": "lint-staged",
"preversion": "yarn test && yarn build",
"release:major": "npm version major -m 'chore(package): v%s'",
"release:minor": "npm version minor -m 'chore(package): v%s'",
"test:lint": "prettier --write --print-width 80 --tab-width 2 --no-semi --single-quote --trailing-comma es5 --parser typescript 'src/*.ts' 'src/**/*.ts'",
"test": "typed-test 'src/*.test.ts' 'src/**/*.test.ts'"
}
}

@@ -1,266 +0,114 @@

# Most Subject [![Build Status](https://travis-ci.org/mostjs-community/most-subject.svg?branch=master)](https://travis-ci.org/TylorS/most-subject) [![npm version](https://badge.fury.io/js/most-subject.svg)](https://badge.fury.io/js/most-subject)
# most-subject
Subject interfaces for [most](https://github.com/cujojs/most)
Subjects for [`@most/core`](https://github.com/mostjs/core)
## API Documentation
###### **Subject**
A Subject is a normal most.js
[Stream](https://github.com/cujojs/most/wiki/Concepts#streams), with 3 added methods,
which allow for imperative calls to events, errors, and completion. This library was
created out of need for them for [motorcycle.js](https://github.com/motorcyclejs) and
the need to create circular dependencies. The original author of most.js, and I,
would strongly urge you to find a way to create a custom Stream factory using
the standard most.js architectural patterns before deferring to this library.
We would love to help you in the [most.js gitter room](https://gitter.im/cujojs/most).
You're still here? Okay, so maybe you need to use a Subject for a good reason.
I'll define the interfaces that are used by this library. The notation here is that
which is used by TypeScript. For the types that are not defined here please see
[this](https://github.com/cujojs/most/wiki/Architecture) on the most.js Architecture.
```typescript
interface Subject<T> extends Stream<T> {
source: Source<T> & Sink<T>;
next (value: T): Subject<T>
error <Err extends Error> (err: Err): Subject<T>;
complete (value?: T): Subject<T>;
}
interface HoldSubject<T> extends Subject<T> {
source: HoldSubjectSource<T>;
next (value: T): HoldSubject<T>
error <Err extends Error> (err: Err): HoldSubject<T>;
complete (value?: T): HoldSubject<T>;
}
## Get it
```sh
yarn add most-subject
# or
npm install --save most-subject
```
Okay so here, we have the interfaces that define what a Subject *is*. It is a
Stream with a `source` property that satifies both the `Source` and `Sink` interfaces,
like that of `MulticastSource` from [`@most/multicast`](https://github.com/mostjs/multicast).
A Subject also has 3 methods `next`, `error`, and `complete`
to allow imperatively pushing values into the underlying stream.
## API Documentation
The reason for the distinction between a Subject and a HoldSubject are solely for
TypeScript users looking for the best typings they can get :smile:
#### create\<A\>(): Subject\<A, A\>
#### create\<A, B\>(f: (stream: Stream\<A\>) =\> Stream\<B\>): Subject\<A, B\>
Let us take a look at some of the functions provided by this library.
Returns an tuple containing a `AttachSink` and a `Stream`. `AttachSink` can be
used to imperatively control the events flowing through the `Stream` or
declaratively using `attach`. Optionally, a function can be applied to the Stream,
and the return value of that function will be returned as the second tuple value.
### Subjects
#### `async<T>(): Subject<T>`
This function here creates a Subject, which will produce its values asynchonously.
The asynchrony is important to note here. Most.js itself ensures that **no** events
can occur while it is being instantiated via `.observe()` and related operators that
"attach" listeners.
**Example**
<details>
<summary>See an example</summary>
```typescript
import { async, Subject } from 'most-subject';
import { create, event } from 'most-subject'
import { runEffects, propagateEventTask } from '@most/core'
import { newDefaultScheduler, currentTime } from '@most/scheduler'
const subject: Subject<number> = async<number>();
// Create a new `Scheduler` for use in our application.
// Usually, you will want to only have one Scheduler, and it should be shared
// across your application
const scheduler = newDefaultScheduler()
subject.observe(x => console.log(x)) // 1, 2, 3
// Create our sink and our stream.
// NOTE: stream is the resulting value of tap(console.log, stream).
const [ sink, stream ] = create(tap<number>(console.log))
subject.next(1);
subject
.next(2)
.next(3)
.complete();
// Pushes events into our stream.
const next = (n: number) => event(currentTime(scheduler), n, sink)
```
// Activate our stream.
runEffects(stream, scheduler)
#### `sync<T>(): Subject<T>`
This function here will create Subject that will emit its values synchronously.
This is provided to add backwards compatiblity with theoretical edge cases
applications may have been built on in previous versions.
```typescript
import { sync } from 'most-subject';
const subject = sync();
subject.observe(x => console.log(x)); // 1, 2, 3
subject.next(1);
subject.next(2).next(3);
// note this setTimeout will be required
// to ensure the previous events are ever emitted
setTimeout(() => subject.complete());
// Simulate asynchronous data fetching,
// and then push values into our stream.
Promise.resolve([ 1, 2, 3 ])
.then(data => data.forEach(next))
```
### Combinators
</details>
###### All combinators are curried.
#### attach\<A\>(attachSink: AttachSink\<A\>, stream: Stream\<A\>): Stream\<A\>
#### `hold<T> (bufferSize: number, subject: Subject<T>): HoldSubject<T>`
Create circular dependencies with additional logic to help avoid memory leaks.
This function will lift any subject, synchronous or asynchonous, into a HoldSubject.
A HoldSubject is just like a regular Subject, but it will remember values previously
emitted for any late subscribers. The number of values it will remember is based on the
bufferSize amount passed in as the first argument.
WARNING: There isn't any logic for breaking infinite loops.
```typescript
import { sync, hold } from 'most-subject';
<details>
<summary>See an example</summary>
const holdSubject = hold(1, sync());
holdSubject.next(1);
holdSubject.next(2);
holdSubject.observe(x => console.log(x)); // 2
setTimeout(() => holdSubject.complete());
```
#### `next<T> (value: T, subject: Subject<T>): Subject<T>`
This is a functional equivalent to `subject.next(value)`. It will push a value
into a Subject.
```typescript
import { next, async } from 'most-subject';
import { Stream } from '@most/types'
import { create, attach } from 'most-subject'
import { periodic, scan, take, runEffects } from '@most/core'
import { newDefaultScheduler } from '@most/scheduler'
const subject = async();
// Create a new Scheduler for use in our application.
// Usually, you will want to only have one Scheduler, and it should be shared
// across your application.
const scheduler = newDefaultScheduler()
subject.observe(x => console.log(x)); // 1, 1, 2
const [ sink, stream ] = create<number>()
subject.next(1);
// is equivalent to
next(1, subject);
// Listen to our stream.
// It will log 1, 2, and 3.
runEffects(tap(console.log, take(3, stream)), scheduler)
// curried by default
const nextTwo = next(2);
nextTwo(subject);
const origin = scan(x => x + 1, 0, periodic(100))
subject.complete();
attach(origin)
```
#### `error<T> (err: Error, subject: Subject<T>): Subject<T>`
</details>
This is a functional equivalent to `subject.error(Error)`. It will push an error
into a Subject.
#### event\<A\>(time: Time, value: A, sink: Sink\<A\>): void
```typescript
import { error, async } from 'most-subject';
A curried function for calling `Sink.event(time, value)`.
const subject = async();
#### error(time: Time, error: Error, sink: Sink\<any\>): void
subject.observe(x => console.log(x));
.catch(err => console.log(err.message))
A curried function for calling `Sink.error(time, error)`.
subject.error(new Error());
// is equivalent to
error(new Error, subject);
#### end(time: Time, sink: Sink\<any\>): void
// curried by default
const defaultError = error(new Error('default message'));
defaultError(subject);
A curried function for calling `Sink.end(time)`.
subject.complete();
```
#### Subject\<A, B\>
#### `complete<T> (value: T, subject: Subject<T>): Subject<T>`
This is a functional equivalent to `subject.complete(value)`. It will cause a
subject to complete with a particular value.
```typescript
import { complete, async } from 'most-subject';
import { Sink, Stream } from '@most/types'
const subject = asnyc();
subject.complete(1);
// is equivalent to
complete(1, subject);
const completeWith1 = complete(1);
completeWith1(subject);
export type Subject<A, B> = [AttachSink<A>, Stream<B>]
```
### "Upgrading" streams
#### AttachSink\<A\>
A new feature designed to help with manual stream debugging are 2 functions that
are able to "lift" most.js Streams into Subjects of your choice.
#### `asSync<T> (stream: Stream<T>): Subject<T>`
Lifts a stream into a synchronously emitting Subject.
```typescript
import { asSync, next } from 'most-subject';
import { Sink } from '@most/types'
const subject = asSync(someStream);
next(1, subject);
export AttachSink<A> extends Sink<A> {
attach(stream: Stream<A>): Stream<A>
}
```
#### `asAsync<T> (stream: Stream<T>): Subject<T>`
Lifts a stream into an asynchonously emitting Subject.
```typescript
import { asAsync, next } from 'most-subject';
const subject = asAsync(somStream);
next(1, subject);
```
### Classes
####`SyncSubject`
SyncSubject is the class instance created when using `sync()` or `asSync(stream)`.
It must be istantiated using the keyword `new` and takes a single parameter
`source` which must satisfy the interfaces `Sink` and `Source`.
```typescript
import { SyncSubject } from 'most-subject'
import { MulticastSource } from '@most/multicast';
import { never } from 'most';
// this is effectively what `sync()` creates
const subject = new SyncSubject(new MulticastSource(never().source));
```
#### `AsyncSubject`
AsyncSubject is the class instance created when using `async()` or `asAsync(stream)`.
It must be istantiated using the keyword `new` and takes a single parameter
`source` which must satisfy the interfaces `Sink` and `Source`.
```typescript
import { AsyncSubject } from 'most-subject'
import { MulticastSource } from '@most/multicast';
import { never } from 'most';
// this is effectively what `async()` creates
const subject = new AsyncSubject(new MulticastSource(never().source));
```
#### `HoldSubjectSource`
HoldSubjectSource is the `source` property type of a `HoldSubject`. It is a
special case that implements both `Sink` and `Source` interfaces, that also remembers
an arbitrary number of values.
It must be istantiated using the keyword `new` and takes a two parameters.
`source` which must satisfy the interface `Source` and `bufferSize` which is of
type Number and must be an integer greater than or equal to 1.
```typescript
import { HoldSubjectSource, SyncSubject } from 'most-subject';
import { never } from 'most';
const source = new HoldSubjectSource(never().source, 1);
// effectively what hold(1, sync()) creates
const subject = new SyncSubject(source);
```

@@ -1,4 +0,6 @@

export * from './interfaces';
export * from './sources';
export * from './subjects';
export * from './combinators';
export * from './attach'
export * from './create'
export * from './end'
export * from './error'
export * from './event'
export * from './types'
{
"compilerOptions": {
"declaration": true,
"lib": [
"dom",
"es5",
"es2015"
],
"target": "es5",
"moduleResolution": "node",
"module": "es2015",
"target": "es5",
"declaration": true,
"noImplicitAny": true,
"sourceMap": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"outDir": "lib/es2015"
"noUnusedLocals": true
},
"files": [
"src/index.ts"
"include": [
"src/**/*.ts"
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc