New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

quansync

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quansync - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

2

LICENSE.md
MIT License
Copyright (c) 2025-PRESENT Anthony Fu <https://github.com/antfu>
Copyright (c) 2025-PRESENT Anthony Fu <https://github.com/antfu> and Kevin Deng <https://github.com/sxzz>

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "quansync",
"type": "module",
"version": "0.0.5",
"version": "0.0.6",
"description": "Create sync/async APIs with usable logic",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
"contributors": [
{
"name": "三咲智子 Kevin Deng",
"email": "sxzz@sxzz.moe"
}
],
"license": "MIT",
"funding": "https://github.com/sponsors/antfu",
"homepage": "https://github.com/antfu/quansync#readme",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/antfu"
},
{
"type": "individual",
"url": "https://github.com/sponsors/sxzz"
}
],
"homepage": "https://github.com/antfu-collective/quansync#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/antfu/quansync.git"
"url": "git+https://github.com/antfu-collective/quansync.git"
},
"bugs": "https://github.com/antfu/quansync/issues",
"bugs": "https://github.com/antfu-collective/quansync/issues",
"keywords": [

@@ -31,16 +46,15 @@ "async",

"devDependencies": {
"@antfu/eslint-config": "^4.1.1",
"@antfu/ni": "^23.3.1",
"@antfu/utils": "^8.1.0",
"@types/node": "^22.13.1",
"bumpp": "^10.0.2",
"eslint": "^9.20.0",
"@antfu/eslint-config": "^4.3.0",
"@types/node": "^22.13.5",
"bumpp": "^10.0.3",
"eslint": "^9.21.0",
"gensync": "1.0.0-beta.2",
"lint-staged": "^15.4.3",
"pnpm": "^10.2.1",
"mitata": "^1.0.34",
"simple-git-hooks": "^2.11.1",
"tsx": "^4.19.2",
"tsx": "^4.19.3",
"typescript": "^5.7.3",
"unbuild": "^3.3.1",
"vite": "^6.1.0",
"vitest": "^3.0.5"
"unbuild": "^3.5.0",
"vite": "^6.2.0",
"vitest": "^3.0.7"
},

@@ -59,2 +73,3 @@ "simple-git-hooks": {

"start": "tsx src/index.ts",
"benchmark": "node scripts/benchmark.js",
"test": "vitest",

@@ -61,0 +76,0 @@ "typecheck": "tsc --noEmit"

@@ -29,3 +29,3 @@ # quansync

// Create an quansync function by providing `sync` and `async` implementations
// Create a quansync function by providing `sync` and `async` implementations
const readFile = quansync({

@@ -36,3 +36,3 @@ sync: (path: string) => fs.readFileSync(path),

// Create an quansync function by providing a generator function
// Create a quansync function by providing a generator function
const myFunction = quansync(function* (filename) {

@@ -52,2 +52,54 @@ // Use `yield*` to call another quansync function

## Why
// TODO:
## How it works
// TODO:
## Benchmark
Run the following command to benchmark the performance of `quansync`:
```bash
pnpm run build && pnpm run benchmark
```
Benchmark results indicate that each `yield` incurs an overhead of
approximately 150 ns, comparable to that of `await sync()`. (On Apple M1 Max)
## Build-time Macro
If you don't like the `function*` and `yield*` syntax, we also provide a build-time macro via [unplugin-quansync](https://github.com/unplugin/unplugin-quansync#usage) allowing you use quansync with async/await syntax, while still able to get the sync version out of that.
Here is an example:
```ts
import fs from 'node:fs'
import { quansyncMacro } from 'quansync'
// Create a quansync function by providing `sync` and `async` implementations
const readFile = quansyncMacro({
sync: (path: string) => fs.readFileSync(path),
async: (path: string) => fs.promises.readFile(path),
})
// Create a quansync function by providing an **async** function
const myFunction = quansyncMacro(async (filename) => {
// Use `await` to call another quansync function
const code = await readFile(filename, 'utf8')
return `// some custom prefix\n${code}`
})
// Use it as a sync function
const result = myFunction.sync('./some-file.js')
// Use it as an async function
const asyncResult = await myFunction.async('./some-file.js')
```
For more details on usage, refer to [unplugin-quansync's docs](https://github.com/unplugin/unplugin-quansync#usage).
## Sponsors

@@ -61,5 +113,11 @@

<p align="center">
<a href="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg">
<img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>
</a>
</p>
## License
[MIT](./LICENSE) License © [Anthony Fu](https://github.com/antfu)
[MIT](./LICENSE) License © [Anthony Fu](https://github.com/antfu) and [Kevin Deng](https://github.com/sxzz)

@@ -66,0 +124,0 @@ <!-- Badges -->

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc