Skip to content

Commit

Permalink
feat(): rewrite to boost performance
Browse files Browse the repository at this point in the history
  • Loading branch information
TylorS committed May 16, 2016
1 parent c9beaac commit eccb337
Show file tree
Hide file tree
Showing 38 changed files with 2,573 additions and 858 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"presets": [
"es2015"
],
"plugins": [
"syntax-flow",
"transform-flow-strip-types"
]
}
12 changes: 2 additions & 10 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{
"parser": "babel-eslint",
"extends": "eslint-config-cycle",
"env": {
"browser": true,
"node": true
},
"rules": {
"no-class/no-class": 0,
"quotes": 0
}
"extends": "@most/eslint-config-most",
"parser": "babel-eslint"
}
8 changes: 8 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[ignore]

[include]

[libs]

[options]
suppress_comment= \\(.\\|\n\\)*\\flow-ignore-next-line
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
sudo: true
node_js:
- "6"
- "5"
- "4"
env:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Tylor Steinberger
Copyright (c) 2016 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
Expand Down
79 changes: 3 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,7 @@
# Most Subject [![Build Status](https://travis-ci.org/TylorS/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)

Subject and Subject-like interface to Most.js
Subject interface for [most](https://github.com/cujojs/most)

# API
## API Documentation

## holdSubject(bufferSize = 1[, initialValue])

[src/index.js:25-31](https://github.com/tylors/most-subject/tree/master/src/index.js#L25-L31 "Source code on GitHub")

Creates a subject that replays past events that a new observer may have missed.

**Parameters**

- `bufferSize` **integer** [= 1] - how many values to keep buffered.
Must be an integer 1 or greater.
- `initialValue` **any** an initialValue to start with

**Examples**

```javascript
import {holdSubject} from 'most-subject'

// will keep 4 items buffered with an initialValue of 1
const {observer, stream} = holdSubject(4, 1)

observer.next(2)
observer.next(3)
observer.next(4)

stream.observe(x => console.log(x)) // 1 , 2 , 3, 4 , 5

observer.next(5)
observer.complete()
```

Returns [**Subject**](#subject-1)

## subject()

[src/index.js:21-23](https://github.com/tylors/most-subject/tree/master/src/index.js#L21-L23 "Source code on GitHub")

Creates a basic Subject

**Examples**

```javascript
import {subject} from 'most-subject'

const {observer, stream} = subject()

stream.observe(x => console.log(x)) // 1 , 2 , 3

observer.next(1)
observer.next(2)
observer.next(3)
observer.complete()
```

Returns [**Subject**](#subject-1)

## Subject

A Subject is simply an object with the following properties

**Properties**

- `observer` [**Observer**](#observer)
- `stream` **most.Stream** A most.js Stream instance

## Observer

An Observer

**Properties**

- `next` **Function<any>** pushes a new value to the underlying Stream
- `error` **Function<Error>** pushes a new Error to and ends
the underlying Stream
- `complete` **Function<Any>** ends the underlying Stream
To find the API documentation follow [this link](https://tylors.github.io/most-subject/docs)!
Loading

0 comments on commit eccb337

Please sign in to comment.