Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielrufino/folport
📁 Imports all the modules from a folder
https://github.com/gabrielrufino/folport
javascript node
Last synced: 7 days ago
JSON representation
📁 Imports all the modules from a folder
- Host: GitHub
- URL: https://github.com/gabrielrufino/folport
- Owner: gabrielrufino
- License: unlicense
- Created: 2023-03-01T00:45:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-29T18:57:44.000Z (17 days ago)
- Last Synced: 2024-10-29T20:45:51.698Z (17 days ago)
- Topics: javascript, node
- Language: JavaScript
- Homepage:
- Size: 295 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Folport banner](./assets/folport.png)
# Folport
Folport allows you to import all modules from a folder in a single step, organizing them in a clean and accessible way.
### Getting Started
To install, run this command:
```bash
npm install folport
```### Important: Setting `"type": "module"`
Since Folport uses ES Modules (import/export syntax), you need to specify `"type": "module"` in your `package.json` file. This setting is essential to ensure Node.js interprets your code correctly as ES Modules.
```json
{
"name": "your-project-name",
"version": "1.0.0",
"type": "module",
"dependencies": {
"folport": "^1.0.0"
}
}
```### Example
Suppose we have the following folder structure:
```
+-- math
| +-- add.js
| +-- subtract.js
| +-- multiply.js
| +-- divide.js
+-- index.js
```#### index.js
```js
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';import folport from 'folport';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);async function main() {
const math = await folport(join(__dirname, 'math'))console.log(math.add(1, 2)) // 3
console.log(math.subtract(8, 4)) // 4
console.log(math.multiply(6, 7)) // 42
console.log(math.divide(20, 10)) // 2
}main()
```---
**Black Tech by [Gabriel Rufino](https://github.com/gabrielrufino) 🖤**