Coder Social home page Coder Social logo

index's Introduction

@most/index

Index and count events. More generally, pair events with any iterative value.

import { index, count } from '@most/index'
import { Stream, periodic } from '@most/core'

// 0 1 2 3 4 ...
const si: Stream<number> = index(periodic(1000))

// 1 2 3 4 5 ...
const sc: Stream<number> = count(periodic(1000))

Get it

npm install --save @most/index

API

count :: Stream a → Stream number

Count events.

// 1 2 3 ...
count(periodic(1000))

withCount :: Stream a → Stream [number, a]

Pair events with a 1-based count.

// [1, 'withCount'] [2, 'withCount'] [3, 'withCount'] ...
withCount(constant('withCount', periodic(1000)))

index :: Stream a → Stream number

Index events.

// 0 1 2 ...
index(periodic(1000))

withIndex :: Stream a → Stream [number, a]

Pair events with a 0-based index.

// [0, 'withIndex'] [1, 'withIndex'] [2, 'withIndex'] ...
withIndex(constant('withIndex', periodic(1000)))

withIndexStart :: number → Stream a → Stream [number, a]

Pair events with a start-based index.

// [100, 'withIndexStart'] [101, 'withIndexStart'] [102, 'withIndexStart'] ...
withIndexStart(100, constant('withIndexStart', periodic(1000)))

indexed :: (s → [i, s]) → s → Stream a → Stream [i, a]

Pair events with any iteratively computed index.

const stringIndex = (s: string) => (prev: string): [string, string] =>
  [prev, prev + s]

// ['', 'indexed'], ['a', 'indexed'], ['aa', 'indexed'], ['aaa', 'indexed']
indexed(stringIndex('a'), '', constant('indexed', periodic(1000)))

index's People

Stargazers

 avatar

Watchers

 avatar  avatar

index's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.