GitXplorerGitXplorer
a

dgelong

public
13 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
7f9812d065ba2792adb77e2d4460fb55edd2300c

make Option idempotent

aalexeyraspopov committed 8 years ago
Unverified
4f6c60cc8255aec5223d3f4c74af4371391c9ccd

remove old tests

aalexeyraspopov committed 8 years ago
Unverified
df6a2e43ad247ea95bdbc2ae637cb2bbad755ac8

update description and homepage

aalexeyraspopov committed 8 years ago
Unverified
8abe2c92ecd3c160394d0e388c533f5fd2259d83

return Nothing if a step has Nothing

aalexeyraspopov committed 8 years ago
Unverified
10ecda2f9960533c84d6384082a0b6bc6fa94ec1

get rid of iterator

aalexeyraspopov committed 8 years ago
Unverified
4f6c7a497f7fb7f15342e9c914247aaaff7a2ab3

update README

aalexeyraspopov committed 8 years ago

README

The README file for this repository.

Dgelong

Set of useful first-class structures which allow you to get rid of your developer's pain.

  • Flatten by default.
  • Minimal API sufrace area.
  • Immutable.
  • Lazy evaluation.
  • Full interoperability between all structures and JavaScript natives.

Install

npm install dgelong

Motivation

I don't want make another implementation that requires Ph.D in Math. The usage of monads should be as simple as functional composition f(g(a)). API should be close to native. So if we're talking about data structures, they should be produced in the same way as natives: by calling constructor function with or without new operator (I prefer the second approach).

Usage

import Dgelong from 'dgelong';

Or just use something specific, for example:

import { Option, Either } from 'dgelong';

Option

import { Just, Nothing } from 'dgelong';

function square(n) {
    return n * n;
}

function isEven(n) {
    return n % 2 ? Nothing() : Just(n);
}

new Just(5)
    .map(square) // returns Just(25)
    .map(isEven) // returns Nothing()
    .map(alert); // won't be executed

Either

import { Success, Failure } from 'dgelong/either';

function validateUserPassword(password) {
  if (password.length < 10) return Failure('Password is too short');
  if (!/[0-9]/g.test(password)) return Failure('Password should contain numbers');

  return Success(password);
}

validateUserPassword('boo')
  .map(savePassword, showError);