UNPKG

2.16 kBMarkdownView Raw
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
10Sub-project of **[Funfix](https://funfix.org)**, exposing primitive
11interfaces and data types that need to be universally available,
12belonging into a standard library.
13
14## Documentation
15
16Links:
17
18- [Homepage](https://funfix.org)
19- **[JSDoc documentation](https://funfix.org/api/core/)**
20
21## Usage
22
23You can depend on the whole `funfix` library, by adding it to
24`package.json`:
25
26```bash
27npm install --save funfix
28```
29
30In this case imports are like:
31
32```typescript
33import { Option } from "funfix"
34```
35
36Or for finer grained dependency management, the project can depend
37only on `funfix-core`:
38
39```bash
40npm install --save funfix-core
41```
42
43In this case imports are like:
44
45```typescript
46import { Option } from "funfix-core"
47```
48
49Usage sample:
50
51```typescript
52import { Try, Option, Either } from "funfix"
53
54const opt1 = Option.of("hello")
55const opt2 = Try.of(() => "world").toOption()
56
57const greeting =
58 Option.map2(opt1, opt2, (a, b) => a + " " + b)
59
60console.log(greeting.getOrElse("Ooops!"))
61```
62
63### Modules: UMD and ES 2015
64
65The library has been compiled using
66[UMD (Universal Module Definition)](https://github.com/umdjs/umd),
67so it should work with [CommonJS](http://requirejs.org/docs/commonjs.html)
68and [AMD](http://requirejs.org/docs/whyamd.html).
69
70But it also provides a `module` definition in `package.json`, thus
71providing 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,
73or when bundling with a tool chain that understands ES2015 modules,
74like [Rollup](https://rollupjs.org/) or [Webpack](https://webpack.js.org/).
75
76## License
77
78Licensed under the Apache License, Version 2.0.