https://github.com/falkz/portl
0 configuration backend, for serving js functions and generators
https://github.com/falkz/portl
Last synced: 29 days ago
JSON representation
0 configuration backend, for serving js functions and generators
- Host: GitHub
- URL: https://github.com/falkz/portl
- Owner: FalkZ
- Created: 2020-02-18T14:27:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-24T13:53:32.000Z (over 6 years ago)
- Last Synced: 2025-01-10T23:27:31.421Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://deno.land/x/portl/
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# portl
0 configuration backend, for serving js functions and generators
## Usage
1. Create a file that exports the functions you want to expose.
```javascript
// serve.js
export const fn = (input) => input + " postfix";
export const it = async function*(mul) {
const arr = [1, 2, 3];
while (arr.length) {
yield new Promise((resolve) => {
setTimeout(() => resolve(mul * arr.shift()), 1000);
});
}
};
```
2. Run the server script with the file `./serve.js` as argument
```bash
deno --allow-net --allow-read https://deno.land/x/portl/portl-server.js ./serve.js
```
3. Import the client script and call the functions
```js
import portl from "https://gitcdn.xyz/repo/FalkZ/portl/master/portl-client.js";
portl.fn('from client').then(console.log)
// => from client postfix
portl.it(3).subscribe(console.log)
// => 3
// => 6
// => 9
```