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

Create sync/async APIs with usable logic

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
48K
Maintainers
0
Weekly downloads
 
Created
Source

quansync

npm version npm downloads bundle JSDocs License

Create sync/async APIs with usable logic.

Quantum + Sync - "Superposition" between sync and async.

  • Typesafe
  • ESM, modern JavaScript
  • Zero dependencies

Heavily inspired by genasync by @loganfsmyth.

Usage

pnpm i quansync
import fs from 'node:fs'
import { quansync } from 'quansync'

// Create an quansync function by providing `sync` and `async` implementations
const readFile = quansync({
  sync: (path: string) => fs.readFileSync(path),
  async: (path: string) => fs.promises.readFile(path),
})

// Create an quansync function by providing a generator function
const myFunction = quansync(function* (filename) {
  // Use `yield*` to call another quansync function
  const code = yield * 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')

Sponsors

License

MIT License © Anthony Fu

Keywords

FAQs

Package last updated on 24 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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