Skip to content

Commit 6488e2d

Browse files
committed
2.4.0
1 parent 5249a85 commit 6488e2d

6 files changed

Lines changed: 53 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d
44

55
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
66

7+
#### [v2.4.0](https://github.com/bas080/sendscript/compare/v2.3.9...v2.4.0)
8+
9+
- Update tap to 4.5.4 [`5249a85`](https://github.com/bas080/sendscript/commit/5249a85a08b10485f0d64058fd2c8bcaae84edda)
10+
- Add fn and args support [`6110654`](https://github.com/bas080/sendscript/commit/6110654fa039d17cd9ba0e15f749756b615b5d09)
11+
- Move transport agnostic section to socket example [`3a92257`](https://github.com/bas080/sendscript/commit/3a9225787df16a0fd83293bfa14d91b74a46d070)
12+
713
#### [v2.3.9](https://github.com/bas080/sendscript/compare/v2.3.8...v2.3.9)
814

15+
> 14 April 2026
16+
917
- Remove schema description from reference and schema shape [`7126829`](https://github.com/bas080/sendscript/commit/7126829b5968588d7c9377ee643b88465f3fe16e)
1018

1119
#### [v2.3.8](https://github.com/bas080/sendscript/compare/v2.3.7...v2.3.8)

README.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Write JS code that you can run on servers, browsers or other clients.
2525
* [Server](#server)
2626
* [Client](#client)
2727
- [Repl](#repl)
28+
- [Functions](#functions)
2829
- [Promises](#promises)
2930
* [.then / .catch](#then--catch)
3031
* [await](#await)
@@ -114,17 +115,14 @@ core or around it. Things like supporting more complex (de)serializers, errors
114115
and maybe mixing client functions with sendscript programs. Contact me if I have
115116
piqued your interest.
116117

117-
***
118-
119-
SendScript leaves it up to you to choose HTTP, web-sockets or any other method
120-
of communication between servers and clients that best fits your needs.
121-
122118
## Reference
123119

124120
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
125121

126122
### defaultLeafParse
127123

124+
[parse.mjs:49-49](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/parse.mjs#L49-L49 "Source code on GitHub")
125+
128126
Default deserializer for leaf nodes.
129127

130128
#### Parameters
@@ -135,6 +133,8 @@ Returns **any**&#x20;
135133

136134
### Parse
137135

136+
[parse.mjs:68-215](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/parse.mjs#L68-L215 "Source code on GitHub")
137+
138138
#### Parameters
139139

140140
* `schema` **[Schema](#schema)**&#x20;
@@ -145,6 +145,8 @@ Returns **[parse](#parse)**&#x20;
145145

146146
### parse
147147

148+
[parse.mjs:78-214](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/parse.mjs#L78-L214 "Source code on GitHub")
149+
148150
Parses and executes a serialized program.
149151

150152
#### Parameters
@@ -155,6 +157,8 @@ Returns **(any | [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Ref
155157

156158
### References
157159

160+
[references.mjs:109-127](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/references.mjs#L109-L127 "Source code on GitHub")
161+
158162
Builds a nested API structure from a schema definition.
159163

160164
#### Parameters
@@ -170,12 +174,16 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
170174

171175
### SchemaNode
172176

177+
[schema.mjs:1-19](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/schema.mjs#L1-L6 "Source code on GitHub")
178+
173179
A single schema node.
174180

175181
Type: ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | \[[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [Schema](#schema)])
176182

177183
### Schema
178184

185+
[schema.mjs:1-19](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/schema.mjs#L8-L18 "Source code on GitHub")
186+
179187
A schema defines the structure of the runtime API tree.
180188

181189
* string → leaf node
@@ -187,6 +195,8 @@ Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global
187195

188196
### defaultLeafStringify
189197

198+
[stringify.mjs:37-47](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/stringify.mjs#L37-L47 "Source code on GitHub")
199+
190200
Default strict serializer for leaf values.
191201

192202
Rejects non-JSON-safe values.
@@ -199,6 +209,8 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
199209

200210
### Stringify
201211

212+
[stringify.mjs:56-157](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/stringify.mjs#L56-L157 "Source code on GitHub")
213+
202214
Creates a stringify function for SendScript AST structures.
203215

204216
#### Parameters
@@ -209,6 +221,8 @@ Returns **[stringify](#stringify)**&#x20;
209221

210222
### stringify
211223

224+
[stringify.mjs:64-156](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/stringify.mjs#L64-L156 "Source code on GitHub")
225+
212226
Serializes a program into a JSON string representation.
213227

214228
#### Parameters
@@ -219,6 +233,9 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
219233

220234
## Socket example
221235

236+
SendScript leaves it up to you to choose HTTP, web-sockets or any other method
237+
of communication between servers and clients that best fits your needs.
238+
222239
For this example we'll use [socket.io][socket.io].
223240

224241
### Module
@@ -325,6 +342,24 @@ run it by simply typing `sendscript` in their console.
325342
> Use the `DEBUG='*'` to enable all logs or `DEBUG='sendscript:*'` for
326343
> printingonly sendscript logs.
327344
345+
## Functions
346+
347+
SendScript as of `v2.4` supports functions to do basic templating. It does not
348+
support async functions and will throw an error when you define one.
349+
350+
Under the hood the function is called when it is being parsed. Make sure you
351+
understand what you are doing when mixing client and server functions.
352+
353+
```js
354+
map((a) => add(a, 1))([1, 2, 3]))
355+
```
356+
357+
It also supports nested functions.
358+
359+
```js
360+
map(call)(map((a) => () => add(a, 1))([1, 2, 3]))
361+
```
362+
328363
## Promises
329364

330365
### .then / .catch

example/typescript/docs/functions/add.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **add**(`a`, `b`): `number`
1010
11-
Defined in: [math.ts:1](https://github.com/bas080/sendscript/blob/7126829b5968588d7c9377ee643b88465f3fe16e/example/typescript/math.ts#L1)
11+
Defined in: [math.ts:1](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/example/typescript/math.ts#L1)
1212

1313
## Parameters
1414

example/typescript/docs/functions/square.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **square**(`a`): `number`
1010
11-
Defined in: [math.ts:2](https://github.com/bas080/sendscript/blob/7126829b5968588d7c9377ee643b88465f3fe16e/example/typescript/math.ts#L2)
11+
Defined in: [math.ts:2](https://github.com/bas080/sendscript/blob/5249a85a08b10485f0d64058fd2c8bcaae84edda/example/typescript/math.ts#L2)
1212

1313
## Parameters
1414

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sendscript",
3-
"version": "2.3.9",
3+
"version": "2.4.0",
44
"description": "Blur the line between server and client code.",
55
"module": true,
66
"main": "index.mjs",

0 commit comments

Comments
 (0)