sendscript 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- #### [v1.0.0](https://github.com/bas080/sendscript/compare/v0.1.4...v1.0.0)
7
+ #### [v1.0.1](https://github.com/bas080/sendscript/compare/v1.0.0...v1.0.1)
8
+
9
+ - Add async await section to readme [`7e56024`](https://github.com/bas080/sendscript/commit/7e560246e2a7b5b34f1de0ce5eb0df62897cc454)
10
+
11
+ ### [v1.0.0](https://github.com/bas080/sendscript/compare/v0.1.4...v1.0.0)
12
+
13
+ > 3 May 2025
8
14
 
9
15
  - Add support for async await [`e949184`](https://github.com/bas080/sendscript/commit/e949184ab31a3bfdf4c6181463dcdd7250aca3a8)
10
16
  - Update tap to latest version on 2024-03-17 [`1164994`](https://github.com/bas080/sendscript/commit/11649947737ffd152ac46d1db01946ad0c1261e7)
package/README.md CHANGED
@@ -13,6 +13,7 @@ Write JS code that you can run on servers, browsers or other clients.
13
13
  * [Module](#module)
14
14
  * [Server](#server)
15
15
  * [Client](#client)
16
+ - [Async/Await](#asyncawait)
16
17
  - [TypeScript](#typescript)
17
18
  - [Tests](#tests)
18
19
  - [Formatting](#formatting)
@@ -135,6 +136,25 @@ pkill sendscript
135
136
  Result: 100
136
137
  ```
137
138
 
139
+ ## Async/Await
140
+
141
+ SendScript supports async/await seamlessly within a single request. This avoids the performance pitfalls of waterfall-style messaging, which can be especially slow on high-latency networks.
142
+
143
+ While it's possible to chain promises manually or use utility functions, native async/await support makes your code more readable, modern, and easier to reason about — aligning SendScript with today’s JavaScript best practices.
144
+
145
+ ```js
146
+ const userId = 'user-123'
147
+ const program = {
148
+ unread: await fetchUnreadMessages(userId),
149
+ emptyTrash: await emptyTrash(userId),
150
+ archived: await archiveMessages(selectMessages({ old: true }))
151
+ }
152
+
153
+ const result = await send(program)
154
+ ```
155
+
156
+ This operation is done in a single round-trip. The result is an object with the defined properties and returned values.
157
+
138
158
  ## TypeScript
139
159
 
140
160
  There is a good use-case to write a module in TypeScript.
@@ -146,22 +166,15 @@ There is a good use-case to write a module in TypeScript.
146
166
  3. You can use the types of the module to coerce your client to adopt the
147
167
  module's type.
148
168
 
149
- ```bash
150
- # Create pretty docs for your module.
151
- npx typedoc my-module.ts
152
- ```
153
-
154
- Now we can use the `my-module.ts` file for the client API.
155
-
156
169
  ```ts
157
- import type * as MyModule from './my-module'
170
+ import type * as math from './example/math.ts'
158
171
 
159
- import sendScriptApi from 'sendscript/api.mjs'
172
+ import module from 'sendscript/module.mjs'
160
173
 
161
- export default sendScriptApi([
162
- fnOne,
163
- fnTwo,
164
- ], /* perform websocket request */) as typeof MyModule
174
+ export default module([
175
+ add,
176
+ squer,
177
+ ]) as typeof math
165
178
  ```
166
179
 
167
180
  > [!NOTE]
@@ -179,11 +192,11 @@ npm t -- report text-summary
179
192
  ```
180
193
  ```
181
194
 
182
- > sendscript@1.0.0 test
195
+ > sendscript@1.0.1 test
183
196
  > tap -R silent
184
197
 
185
198
 
186
- > sendscript@1.0.0 test
199
+ > sendscript@1.0.1 test
187
200
  > tap report text-summary
188
201
 
189
202
 
package/README.mz CHANGED
@@ -118,6 +118,25 @@ node ./example/client.socket.io.mjs
118
118
  pkill sendscript
119
119
  ```
120
120
 
121
+ ## Async/Await
122
+
123
+ SendScript supports async/await seamlessly within a single request. This avoids the performance pitfalls of waterfall-style messaging, which can be especially slow on high-latency networks.
124
+
125
+ While it's possible to chain promises manually or use utility functions, native async/await support makes your code more readable, modern, and easier to reason about — aligning SendScript with today’s JavaScript best practices.
126
+
127
+ ```js
128
+ const userId = 'user-123'
129
+ const program = {
130
+ unread: await fetchUnreadMessages(userId),
131
+ emptyTrash: await emptyTrash(userId),
132
+ archived: await archiveMessages(selectMessages({ old: true }))
133
+ }
134
+
135
+ const result = await send(program)
136
+ ```
137
+
138
+ This operation is done in a single round-trip. The result is an object with the defined properties and returned values.
139
+
121
140
  ## TypeScript
122
141
 
123
142
  There is a good use-case to write a module in TypeScript.
@@ -129,22 +148,15 @@ There is a good use-case to write a module in TypeScript.
129
148
  3. You can use the types of the module to coerce your client to adopt the
130
149
  module's type.
131
150
 
132
- ```bash
133
- # Create pretty docs for your module.
134
- npx typedoc my-module.ts
135
- ```
136
-
137
- Now we can use the `my-module.ts` file for the client API.
138
-
139
151
  ```ts
140
- import type * as MyModule from './my-module'
152
+ import type * as math from './example/math.ts'
141
153
 
142
- import sendScriptApi from 'sendscript/api.mjs'
154
+ import module from 'sendscript/module.mjs'
143
155
 
144
- export default sendScriptApi([
145
- fnOne,
146
- fnTwo,
147
- ], /* perform websocket request */) as typeof MyModule
156
+ export default module([
157
+ add,
158
+ squer,
159
+ ]) as typeof math
148
160
  ```
149
161
 
150
162
  > [!NOTE]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sendscript",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Blur the line between server and client code.",
5
5
  "module": true,
6
6
  "main": "index.mjs",