1 | # funfix-core
|
2 |
|
3 | <a href="https://funfix.org">
|
4 | <img src="https://funfix.org/public/logo/funfix-512.png" width="200" align="right" style="float:right; display: block; width:200px;" />
|
5 | </a>
|
6 |
|
7 | [![Join chat](https://badges.gitter.im/funfix/funfix.svg)](https://gitter.im/funfix/funfix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
8 | [![npm](https://img.shields.io/npm/v/funfix-core.svg)](https://www.npmjs.com/package/funfix-core)
|
9 |
|
10 | Sub-project of **[Funfix](https://funfix.org)**, exposing primitive
|
11 | interfaces and data types that need to be universally available,
|
12 | belonging into a standard library.
|
13 |
|
14 | ## Documentation
|
15 |
|
16 | Links:
|
17 |
|
18 | - [Homepage](https://funfix.org)
|
19 | - **[JSDoc documentation](https://funfix.org/api/core/)**
|
20 |
|
21 | ## Usage
|
22 |
|
23 | You can depend on the whole `funfix` library, by adding it to
|
24 | `package.json`:
|
25 |
|
26 | ```bash
|
27 | npm install --save funfix
|
28 | ```
|
29 |
|
30 | In this case imports are like:
|
31 |
|
32 | ```typescript
|
33 | import { Option } from "funfix"
|
34 | ```
|
35 |
|
36 | Or for finer grained dependency management, the project can depend
|
37 | only on `funfix-core`:
|
38 |
|
39 | ```bash
|
40 | npm install --save funfix-core
|
41 | ```
|
42 |
|
43 | In this case imports are like:
|
44 |
|
45 | ```typescript
|
46 | import { Option } from "funfix-core"
|
47 | ```
|
48 |
|
49 | Usage sample:
|
50 |
|
51 | ```typescript
|
52 | import { Try, Option, Either } from "funfix"
|
53 |
|
54 | const opt1 = Option.of("hello")
|
55 | const opt2 = Try.of(() => "world").toOption()
|
56 |
|
57 | const greeting =
|
58 | Option.map2(opt1, opt2, (a, b) => a + " " + b)
|
59 |
|
60 | console.log(greeting.getOrElse("Ooops!"))
|
61 | ```
|
62 |
|
63 | ### Modules: UMD and ES 2015
|
64 |
|
65 | The library has been compiled using
|
66 | [UMD (Universal Module Definition)](https://github.com/umdjs/umd),
|
67 | so it should work with [CommonJS](http://requirejs.org/docs/commonjs.html)
|
68 | and [AMD](http://requirejs.org/docs/whyamd.html).
|
69 |
|
70 | But it also provides a `module` definition in `package.json`, thus
|
71 | providing compatibility with
|
72 | [ECMAScript 2015 modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import), for usage when used with a modern JS engine,
|
73 | or when bundling with a tool chain that understands ES2015 modules,
|
74 | like [Rollup](https://rollupjs.org/) or [Webpack](https://webpack.js.org/).
|
75 |
|
76 | ## License
|
77 |
|
78 | Licensed under the Apache License, Version 2.0.
|