Skip to content

Saber2pr/mod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mod

a module style for js.

do you know monad? :)

<script src="https://saber2pr.top/mod/mod.min.js"></script>

API

function mod<T>(creator: () => Promise<T>): Promise<T>
function mod<T>(
  creator: (join: (dep: string) => Promise<any>) => Promise<T>
): Promise<T>
  1. define a module:
// ./add.js
mod(() => {
  const add = (a, b) => a + b
  return add
})
  1. import a module
// ./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

About

a module style for js.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published