Giter Club home page Giter Club logo

five-minutes-demo's Introduction

five-minutes-demo

CircleCI

Typed functional programming in TypeScript in five minutes.

Features

  • fp-ts
  • Domain-driven design with io-ts.
  • pipe, Option, Either, TaskEither etc.
  • Browser/server validation.

Getting Started

  • clone repo
  • yarn to install
  • yarn dev to run

Tips

Imports

import { pipe } from 'fp-ts/lib/pipeable';
import * as t from 'io-ts';
import * as IO from 'fp-ts/lib/IO';
import * as O from 'fp-ts/lib/Option';
import * as T from 'fp-ts/lib/Task';

Tree Shaking

By default, when importing from lib (import { pipe } from 'fp-ts/lib/pipeable'), it takes the whole pipeable module with all its dependencies, 1.1 kB gzipped in case of pipe, because it takes also Either (look for 'Either' in compiled code).

Tree shaking works only with es6 modules. We can import { pipe } from 'fp-ts/es6/pipeable', and then only the pipe function is imported, which is great, but to make it work with Next.js, we have to use next-transpile-modules transpileModules: ['fp-ts'],.

As for io-ts, it uses fp-ts/lib import so it can not be tree shaked, but that's fine, because it uses only Either module which is pretty small. The whole io-ts lib itself has only 4.2 kB gzipped. As I see it, we can save some kBs with tree shaking but fp-ts itself is already pretty small, so it makes sense only for micro optimizations. So recommended usage is driven by DX (developer experience), import * as makes API discoverable.

five-minutes-demo's People

Contributors

steida avatar

Watchers

 avatar

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.