sendscript
Advanced tools
Comparing version
{ | ||
"name": "sendscript", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Blur the line between server and client code.", | ||
@@ -5,0 +5,0 @@ "module": true, |
@@ -6,7 +6,9 @@ # SendScript | ||
[](https://www.npmjs.com/package/sendscript) | ||
[](#tests) | ||
[](https://standardjs.com) | ||
[](./LICENSE) | ||
[](./LICENSE.txt) | ||
> SendScript leaves it up to you to choose HTTP, web-sockets or any other method of | ||
> communication between servers and clients that best fits your needs. | ||
> SendScript leaves it up to you to choose HTTP, web-sockets or any other | ||
> method of communication between servers and clients that best fits your | ||
> needs. | ||
@@ -25,3 +27,3 @@ ## Socket example | ||
We write a simple module that only has an add function | ||
We write a simple module. | ||
@@ -32,2 +34,3 @@ ```js | ||
export const add = (a, b) => a + b | ||
export const square = a => a * a | ||
``` | ||
@@ -37,3 +40,3 @@ | ||
Here a simple module for running a socket.io server that runs SendScript programs. | ||
Here a socket.io server that runs SendScript programs. | ||
@@ -73,3 +76,3 @@ ```js | ||
import socketClient from 'socket.io-client' | ||
import dsl from '../dsl.mjs' | ||
import api from '../api.mjs' | ||
@@ -89,6 +92,6 @@ const port = process.env.PORT || 3000 | ||
const { add } = dsl(['add'], exec) | ||
const { add, square } = api(['add', 'square'], exec) | ||
console.log( | ||
await add(1, add(add(2, 3), 4)) | ||
await square(add(1, add(add(2, 3), 4))) | ||
) | ||
@@ -111,3 +114,3 @@ | ||
``` | ||
10 | ||
100 | ||
``` | ||
@@ -117,4 +120,4 @@ | ||
SendScript is essentially a way to serialize a program to then send over the wire | ||
and execute it somewhere else. | ||
SendScript is essentially a way to serialize a program to then send over the | ||
wire and execute it somewhere else. | ||
@@ -124,5 +127,5 @@ We only have two modules. One that helps you write programs that can be sent | ||
### `sendscript/dsl.mjs` | ||
### `sendscript/api.mjs` | ||
The dsl module exports a function that takes two arguments. | ||
The api module exports a function that takes two arguments. | ||
@@ -134,9 +137,9 @@ 1. The schema, which represents the values that are available. | ||
It returns an object that contains functions which are defined in the schema. | ||
These functions are a JavaScript DSL for writing programs that can be sent to | ||
These functions are a JavaScript API for writing programs that can be sent to | ||
a server. | ||
```js | ||
import dsl from './dsl.mjs' | ||
import api from './api.mjs' | ||
const { add, subtract } = dsl( | ||
const { add, subtract } = api( | ||
['add', 'subtract'], | ||
@@ -157,3 +160,3 @@ serializableProgram => sendSomewhereToBeExecuted(serializableProgram) | ||
This DSL is composable and wrappable. | ||
This API is composable and wrappable. | ||
@@ -175,4 +178,4 @@ ### `sendscript/exec.mjs` | ||
You could use SendScript without knowing the details of how the LISP works. It is an | ||
implementation detail and might change over time. | ||
You could use SendScript without knowing the details of how the LISP works. It | ||
is an implementation detail and might change over time. | ||
@@ -188,23 +191,24 @@ ## Tests | ||
> sendscript@0.0.0 test | ||
> sendscript@0.0.1 test | ||
> tap *.test.mjs --no-cov -R classic | ||
api.test.mjs .......................................... 5/5 | ||
curry.test.mjs ........................................ 4/4 | ||
dsl.test.mjs .......................................... 5/5 | ||
exec.test.mjs ....................................... 15/15 | ||
total ............................................... 24/24 | ||
exec.test.mjs ....................................... 16/16 | ||
total ............................................... 25/25 | ||
24 passing (400.194ms) | ||
25 passing (406.01ms) | ||
ok | ||
-----------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
-----------|---------|----------|---------|---------|------------------- | ||
All files | 100 | 100 | 100 | 100 | | ||
curry.mjs | 100 | 100 | 100 | 100 | | ||
debug.mjs | 100 | 100 | 100 | 100 | | ||
dsl.mjs | 100 | 100 | 100 | 100 | | ||
error.mjs | 100 | 100 | 100 | 100 | | ||
exec.mjs | 100 | 100 | 100 | 100 | | ||
-----------|---------|----------|---------|---------|------------------- | ||
------------------|---------|----------|---------|---------|------------------- | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ||
------------------|---------|----------|---------|---------|------------------- | ||
All files | 100 | 100 | 100 | 100 | | ||
api.mjs | 100 | 100 | 100 | 100 | | ||
curry.mjs | 100 | 100 | 100 | 100 | | ||
debug.mjs | 100 | 100 | 100 | 100 | | ||
error.mjs | 100 | 100 | 100 | 100 | | ||
exec.mjs | 100 | 100 | 100 | 100 | | ||
promise-only.mjs | 100 | 100 | 100 | 100 | | ||
------------------|---------|----------|---------|---------|------------------- | ||
``` | ||
@@ -211,0 +215,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
22405
8.16%17
13.33%296
6.09%228
1.79%