https://github.com/saber2pr/mod
a module style for js.
https://github.com/saber2pr/mod
module-system
Last synced: 8 months ago
JSON representation
a module style for js.
- Host: GitHub
- URL: https://github.com/saber2pr/mod
- Owner: Saber2pr
- License: mit
- Created: 2019-12-16T15:01:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-19T05:05:07.000Z (about 6 years ago)
- Last Synced: 2025-01-02T14:44:43.475Z (about 1 year ago)
- Topics: module-system
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# mod
a module style for js.
> do you know monad? :)
```html
```
# API
```ts
function mod(creator: () => Promise): Promise
function mod(
creator: (join: (dep: string) => Promise) => Promise
): Promise
```
1. define a module:
```js
// ./add.js
mod(() => {
const add = (a, b) => a + b
return add
})
```
2. import a module
```js
// ./main.js
mod(async require => {
// import module
const add = await require("./add.js")
console.log(add(1, 2))
})
```
> It looks like the do-block in haskell?
# License
MIT
> Author: saber2pr