https://github.com/loatheb/nedo
a commonJS hook to load modules from url at runtime.
https://github.com/loatheb/nedo
commonjs commonjs-modules nodejs
Last synced: about 1 year ago
JSON representation
a commonJS hook to load modules from url at runtime.
- Host: GitHub
- URL: https://github.com/loatheb/nedo
- Owner: loatheb
- License: mit
- Created: 2018-06-02T02:06:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-14T08:14:43.000Z (almost 8 years ago)
- Last Synced: 2025-03-18T16:14:18.237Z (about 1 year ago)
- Topics: commonjs, commonjs-modules, nodejs
- Language: JavaScript
- Homepage:
- Size: 93.8 KB
- Stars: 23
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README-CN.md
- License: LICENSE
Awesome Lists containing this project
README
# NEDO
Node 端 CommonJS 规范增强版,支持运行时从 url 和 ts 文件加载模块...
[](https://travis-ci.org/loatheb/nedo)
[](https://github.com/prettier/prettier)
[[English doc](https://github.com/loatheb/nedo/blob/master/README.md)]
[[中文文档](https://github.com/loatheb/nedo/blob/master/README-CN.md)]
### 示例
- 从 url 加载一个 CommonJS 模块
```js
const r = require("nedo");
const code = r(
"https://raw.githubusercontent.com/loatheb/nedo/master/__test/case/code.js"
);
console.log(code); // hello code.js
```
- 从 ts 文件加载一个 CommonJS 模块
```js
const r = require("nedo");
const code = r("./code.ts");
console.log(code); // hello code.ts
```
- 顶层 await
```js
// index.js
const r = require("nedo");
r("./code.js");
// code.js: 这里并不需要将 await 包裹在 async 函数中
await doSomeAsyncThings();
```
### 测试用例
可以 review [\_\_test/index.js](https://github.com/loatheb/nedo/blob/master/__test/index.js) 来获取更多关于使用的信息.

### 协议
MIT