0.0.14 • Published 11 months ago

haskellian v0.0.14

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

Haskellian

The Functional Programming library you need

npm i haskellian
yarn add haskellian

Iter<A>

import { Iter } from 'haskellian/iter'

Iter.range(1e9)
  .filter(x => x % 2 === 0)
  .map(x => x * x)
  .batch(2)
  .take(2)
  .sync()
// [[0, 4], [16, 36]]

AsynIter<A>

import { AsynIter } from 'haskellia/asyn_iter'

AsynIter.of([0, 1, 2, 3, 4, 5, 6, 7, 8])
  .filter(x => x % 2 === 0)
  .map(x => x * x)
  .batch(2)
  .take(2)
  .sync()
// Promise<[[0, 4], [16, 36]]>

ManagedPromise<A>

import { managedPromise } from 'haskellian/promise'

const promise = managedPromise()
file.onload = () => promise.resolve()
await promise

ManagedAsync<A>

import { managedAsync } from 'haskellian/asyn_iter'

const messages = managedAsync()

ws.onmessage = e => {
  if (e.data === null)
    messages.end()
  else
    messages.push(e.data)
}

for await (const msg of messages) {
  // ...
}

Bunch of pure utilities

import { mod, clamp, urlJoin } from 'haskellian/util'

mod(-1, 4) // 3, instead of the unfortunate -1 % 4 = -1
clamp(0, x, 1) // something in [0, 1]

urlJoin('oh/', '/my/', '/dear/') // 'oh/my/dear/'
0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago

0.0.0

11 months ago