UnitJS/README.md

50 lines
1.6 KiB
Markdown
Raw Normal View History

2020-05-17 22:19:21 +02:00
# UnitJS
2022-08-09 19:59:48 +02:00
UnitJS is a tiny Javascript framework to write web applications. It provides
four essential modules to deal with asynchronous functions (technically, it's a
monad obtained by currifying the CPS functions of Javascript like
`setTimeout`), value caching, DOM manipulation and basic functional needs like
composition or object projections.
2020-05-17 22:19:21 +02:00
2022-08-09 19:59:48 +02:00
## How to use it in your project
2020-05-17 22:19:21 +02:00
2022-08-09 19:59:48 +02:00
### As a [`SJW`](https://git.marvid.fr/Tissevert/SJW) package.
2020-05-17 22:19:21 +02:00
2022-08-09 19:59:48 +02:00
#### With [`guix`](https://guix.gnu.org/)
2020-05-17 22:19:21 +02:00
2022-08-09 19:59:48 +02:00
The easiest way to use it in your web projects is to simply [package them with
`guix`](https://git.marvid.fr/Tissevert/SJW#how-not-to-install).
2020-05-17 22:19:21 +02:00
2022-08-09 19:59:48 +02:00
#### Otherwise
2020-05-17 22:19:21 +02:00
2022-08-09 19:59:48 +02:00
You can follow [these
instructions](https://git.marvid.fr/Tissevert/SJW#when-guix-is-not-an-option)
to use it without `guix`.
2020-05-17 22:19:21 +02:00
2022-08-09 19:59:48 +02:00
### Without `SJW`
2020-05-17 22:19:21 +02:00
2022-08-09 19:59:48 +02:00
If you don't want to or can't use SJW, it's still possible to use UnitJS by
generating a single script that can then be loaded from your web page like this
:
2020-05-17 22:19:21 +02:00
```
<script src="/path/to/unit.js"></script>
```
2022-08-09 19:59:48 +02:00
The file `unit.js` can be easily generated with `make`, which actually just
calls the `unit.js.tpl` script. Note that you can still generate custom
«partial» versions of `unit.js` if you don't use all of it by overriding the
`SRC` variable of the `Makefile` like so :
2020-05-17 22:19:21 +02:00
```
make SRC="src/UnitJS/Dom.js src/UnitJS/Cache.js"
```
2022-08-09 19:59:48 +02:00
or by manually calling `./unit.js.tpl` with the files you want, like the
`Makefile` does.
When used that way, the `UnitJS` library will be available to your Javascript
code as a global variable `unitJS` containing each of the modules (`Async`,
`Dom`, etc.) as an attribute.