Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds 'core/last' emitting the last event. Useful for reduce/fold too. #673

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
name: Install Local JavaScript Dependencies
command: |
nvm use default
npm install
npm install --legacy-peer-deps

# Store a cache of local JavaScript modules.
- save_cache:
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
name: Install Local JavaScript Dependencies
command: |
nvm use node
npm install
npm install --legacy-peer-deps

# Store a cache of local JavaScript modules.
- save_cache:
Expand All @@ -132,13 +132,13 @@ workflows:
jobs:
- Test-LTS
# filters:
# # Define rules to allow/block exeution of specific branches.
# # Define rules to allow/block execution of specific branches.
# branches:
# only:
# - master
- Test-Latest
# filters:
# # Define rules to allow/block exeution of specific branches.
# # Define rules to allow/block execution of specific branches.
# branches:
# only:
# - master
22 changes: 22 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,28 @@ Discard the first *n* events from ``stream``. ::

If ``stream`` contains fewer than *n* events, the returned :ref:`Stream` will be empty.

.. _last:

last
````

.. code-block:: haskell

last :: Stream a -> Stream a

Emits the last event from ``stream`` and then ends. ::

stream: -a-b-c|
last(stream): -----c|

``fold`` (aka ``reduce``) a ``stream``:

.. code-block:: javascript

import { compose } from '@most/prelude'
// Like reduce for Array
fold = (reducer, seed) => compose(last, scan(reducer, seed))

.. _takeWhile:

takeWhile
Expand Down
Loading