You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

sendscript

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sendscript - npm Package Compare versions

Comparing version

to
1.0.1

8

CHANGELOG.md

@@ -7,4 +7,10 @@ ### Changelog

#### [v1.0.0](https://github.com/bas080/sendscript/compare/v0.1.4...v1.0.0)
#### [v1.0.1](https://github.com/bas080/sendscript/compare/v1.0.0...v1.0.1)
- Add async await section to readme [`7e56024`](https://github.com/bas080/sendscript/commit/7e560246e2a7b5b34f1de0ce5eb0df62897cc454)
### [v1.0.0](https://github.com/bas080/sendscript/compare/v0.1.4...v1.0.0)
> 3 May 2025
- Add support for async await [`e949184`](https://github.com/bas080/sendscript/commit/e949184ab31a3bfdf4c6181463dcdd7250aca3a8)

@@ -11,0 +17,0 @@ - Update tap to latest version on 2024-03-17 [`1164994`](https://github.com/bas080/sendscript/commit/11649947737ffd152ac46d1db01946ad0c1261e7)

2

package.json
{
"name": "sendscript",
"version": "1.0.0",
"version": "1.0.1",
"description": "Blur the line between server and client code.",

@@ -5,0 +5,0 @@ "module": true,

@@ -16,2 +16,3 @@ # SendScript

* [Client](#client)
- [Async/Await](#asyncawait)
- [TypeScript](#typescript)

@@ -139,2 +140,21 @@ - [Tests](#tests)

## Async/Await
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.
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.
```js
const userId = 'user-123'
const program = {
unread: await fetchUnreadMessages(userId),
emptyTrash: await emptyTrash(userId),
archived: await archiveMessages(selectMessages({ old: true }))
}
const result = await send(program)
```
This operation is done in a single round-trip. The result is an object with the defined properties and returned values.
## TypeScript

@@ -151,18 +171,11 @@

```bash
# Create pretty docs for your module.
npx typedoc my-module.ts
```
Now we can use the `my-module.ts` file for the client API.
```ts
import type * as MyModule from './my-module'
import type * as math from './example/math.ts'
import sendScriptApi from 'sendscript/api.mjs'
import module from 'sendscript/module.mjs'
export default sendScriptApi([
fnOne,
fnTwo,
], /* perform websocket request */) as typeof MyModule
export default module([
add,
squer,
]) as typeof math
```

@@ -185,7 +198,7 @@

> sendscript@1.0.0 test
> sendscript@1.0.1 test
> tap -R silent
> sendscript@1.0.0 test
> sendscript@1.0.1 test
> tap report text-summary

@@ -192,0 +205,0 @@

Sorry, the diff of this file is not supported yet