{"_id":"@se-oss/deasync","_rev":"2-e4cc315dd8515d4f308d285c20180106","name":"@se-oss/deasync","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@se-oss/deasync","version":"1.0.0","keywords":["deasync","async","synchronous","addon","blocking","callbacks","nodejs"],"author":{"url":"https://github.com/shahradelahi","name":"Shahrad Elahi","email":"shahrad@litehex.com"},"license":"MIT","_id":"@se-oss/deasync@1.0.0","maintainers":[{"name":"shahradelahi","email":"shahrad@litehex.com"}],"homepage":"https://github.com/shahradelahi/deasync","bugs":{"url":"https://github.com/shahradelahi/deasync/issues"},"dist":{"shasum":"25e8d9129a68bb0117d05b7a60766daeec9ef4c2","tarball":"https://registry.npmjs.org/@se-oss/deasync/-/deasync-1.0.0.tgz","fileCount":3,"integrity":"sha512-1eaNOe3t5t9OLPUulSxkkqYBwiop5HrepktJzE0LXe/ZzrKf1ArBiDGPfbqb5OiMwwvYjikbe+cdiRJUPPp6vA==","signatures":[{"sig":"MEQCIGHwmMSf2VE9BlP7605NXpd44PiXUojD2urThidl0M5AAiAUT6g8hpE+/U7F8Es3l/aexajlvDebZpLRj+mKmAouSQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@se-oss%2fdeasync@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":6397},"main":"dist/index.js","napi":{"name":"deasync","triples":{"additional":["aarch64-apple-darwin","aarch64-unknown-linux-gnu","aarch64-unknown-linux-musl","aarch64-pc-windows-msvc","x86_64-unknown-linux-musl"]}},"pnpm":{"overrides":{"rollup":"npm:@rollup/wasm-node"}},"types":"dist/index.d.ts","engines":{"node":">= 10"},"gitHead":"c884d7281d4680d90ab1c79d86907ab50c515bb3","scripts":{"test":"vitest --run","build":"tsup","format":"prettier --write . --ignore-path .gitignore","version":"napi version","bindings":"pnpm bindings:debug --release","artifacts":"napi artifacts","universal":"napi universal","format:check":"prettier --check . --ignore-path .gitignore","bindings:debug":"napi build --platform --dts bindings.d.ts --js bindings.js","prepublishOnly":"napi prepublish -t npm --skip-gh-release"},"_npmUser":{"name":"shahradelahi","email":"shahrad@litehex.com"},"prettier":"@shahrad/prettier-config","repository":{"url":"git+https://github.com/shahradelahi/deasync.git","type":"git"},"_npmVersion":"10.8.2","description":"Native Node.js addon for synchronous async calls.","directories":{},"_nodeVersion":"20.18.3","dependencies":{"type-fest":"^4.36.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@9.15.6","devDependencies":{"tsup":"^8.4.0","vitest":"^3.0.7","prettier":"^3.5.2","typescript":"^5.8.2","@types/node":"^22.13.8","@napi-rs/cli":"^2.18.4","@sindresorhus/tsconfig":"^7.0.0","@shahrad/prettier-config":"^1.2.1"},"optionalDependencies":{"@se-oss/deasync-darwin-x64":"1.0.0","@se-oss/deasync-darwin-arm64":"1.0.0","@se-oss/deasync-linux-x64-gnu":"1.0.0","@se-oss/deasync-linux-x64-musl":"1.0.0","@se-oss/deasync-win32-x64-msvc":"1.0.0","@se-oss/deasync-linux-arm64-gnu":"1.0.0","@se-oss/deasync-linux-arm64-musl":"1.0.0","@se-oss/deasync-win32-arm64-msvc":"1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/deasync_1.0.0_1741127456680_0.7725652946619335","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@se-oss/deasync","version":"1.0.1","description":"Native Node.js addon for synchronous async calls.","keywords":["deasync","async","synchronous","addon","blocking","callbacks","nodejs"],"homepage":"https://github.com/shahradelahi/deasync","repository":{"type":"git","url":"git+https://github.com/shahradelahi/deasync.git"},"license":"MIT","author":{"name":"Shahrad Elahi","email":"shahrad@litehex.com","url":"https://github.com/shahradelahi"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"artifacts":"napi artifacts","bindings":"pnpm bindings:debug --release","bindings:debug":"napi build --platform --dts bindings.d.ts --js bindings.js","build":"tsup","format":"prettier --write . --ignore-path .gitignore","format:check":"prettier --check . --ignore-path .gitignore","prepublishOnly":"napi prepublish -t npm --skip-gh-release","test":"vitest --run","universal":"napi universal","version":"napi version"},"prettier":"@shahrad/prettier-config","dependencies":{"type-fest":"^4.37.0"},"devDependencies":{"@napi-rs/cli":"^2.18.4","@shahrad/prettier-config":"^1.2.1","@sindresorhus/tsconfig":"^7.0.0","@types/node":"^22.13.10","prettier":"^3.5.3","tsup":"^8.4.0","typescript":"^5.8.2","vitest":"^3.0.8"},"optionalDependencies":{"@se-oss/deasync-win32-x64-msvc":"1.0.1","@se-oss/deasync-darwin-x64":"1.0.1","@se-oss/deasync-linux-x64-gnu":"1.0.1","@se-oss/deasync-darwin-arm64":"1.0.1","@se-oss/deasync-linux-arm64-gnu":"1.0.1","@se-oss/deasync-linux-arm64-musl":"1.0.1","@se-oss/deasync-win32-arm64-msvc":"1.0.1","@se-oss/deasync-linux-x64-musl":"1.0.1"},"packageManager":"pnpm@9.15.9","engines":{"node":">= 10"},"publishConfig":{"access":"public"},"pnpm":{"overrides":{"rollup":"npm:@rollup/wasm-node"}},"napi":{"name":"deasync","triples":{"additional":["aarch64-apple-darwin","aarch64-unknown-linux-gnu","aarch64-unknown-linux-musl","aarch64-pc-windows-msvc","x86_64-unknown-linux-musl"]}},"_id":"@se-oss/deasync@1.0.1","gitHead":"fd8b0f4d54cf15200eb10ee23a644614adf29cc5","bugs":{"url":"https://github.com/shahradelahi/deasync/issues"},"_nodeVersion":"20.18.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Ha7P/xCNxOuH72BNdLRWs4TT8rsMMrERnHtfKWBeTWu+UFW9OBTrRgfZJOlbAAQFR0l4Q30cpAn8CuR7PXWcPg==","shasum":"18301ef127366e2bda5f2ebb10670dde16d8e326","tarball":"https://registry.npmjs.org/@se-oss/deasync/-/deasync-1.0.1.tgz","fileCount":7,"unpackedSize":21663,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@se-oss%2fdeasync@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDg3OwTSFRnjvc5taYsUXVnvsMWZrg2nLUBx8jZq5uX2AiEA+UVH04rjyj6w9U2/jECQIf9Hzdhv1k5FDbJ1/TExn4Y="}]},"_npmUser":{"name":"shahradelahi","email":"shahrad@litehex.com"},"directories":{},"maintainers":[{"name":"shahradelahi","email":"shahrad@litehex.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/deasync_1.0.1_1741724296439_0.08251284347739962"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-04T22:30:56.576Z","modified":"2025-03-11T20:18:17.320Z","1.0.0":"2025-03-04T22:30:56.855Z","1.0.1":"2025-03-11T20:18:16.613Z"},"bugs":{"url":"https://github.com/shahradelahi/deasync/issues"},"author":{"name":"Shahrad Elahi","email":"shahrad@litehex.com","url":"https://github.com/shahradelahi"},"license":"MIT","homepage":"https://github.com/shahradelahi/deasync","keywords":["deasync","async","synchronous","addon","blocking","callbacks","nodejs"],"repository":{"type":"git","url":"git+https://github.com/shahradelahi/deasync.git"},"description":"Native Node.js addon for synchronous async calls.","maintainers":[{"name":"shahradelahi","email":"shahrad@litehex.com"}],"readme":"# @se-oss/deasync\n\n[![CI](https://github.com/shahradelahi/deasync/actions/workflows/CI.yml/badge.svg)](https://github.com/shahradelahi/deasync/actions/workflows/CI.yml)\n[![NPM Version](https://img.shields.io/npm/v/@se-oss/deasync.svg)](https://www.npmjs.com/package/@se-oss/deasync)\n[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](/LICENSE)\n[![Install Size](https://packagephobia.com/badge?p=@se-oss/deasync)](https://packagephobia.com/result?p=@se-oss/deasync)\n\n_@se-oss/deasync_ is a Node.js addon that enables synchronous execution of asynchronous functions by blocking the event loop. The core of project is written in Rust for performance and reliability.\n\n---\n\n- [Installation](#-installation)\n- [Usage](#-usage)\n- [Documentation](#-documentation)\n- [Contributing](#-contributing)\n- [Credits](#-credits)\n- [License](#license)\n\n## 📦 Installation\n\n```bash\nnpm install @se-oss/deasync\n```\n\n## 📖 Usage\n\n#### Wrapping an Asynchronous Function\n\n`deasync` converts an asynchronous function with the conventional callback pattern `function(p1, ...pn, callback(error, result))` into a synchronous function. It returns the result and throws an error if one occurs.\n\n```typescript\nimport { deasync } from '@se-oss/deasync';\n\nfunction asyncFunction(input: string, callback: (err: any, result: string) => void) {\n  setTimeout(() => {\n    callback(null, `Hello, ${input}!`);\n  }, 1000);\n}\n\nconst syncFunction = deasync(asyncFunction);\nconsole.log(syncFunction(\"World\")); // Blocks for 1 second, then prints \"Hello, World!\"\n```\n\n#### Blocking Execution with `loopWhile`\n\nUse `loopWhile(predicateFunc)` to block execution while the given predicate function returns `true`.\n\n```typescript\nimport { sleep } from '@se-oss/deasync';\nlet done = false;\n\nsetTimeout(() => {\n  done = true;\n}, 1000);\n\nloopWhile(() => !done);\n\n// The task is now complete\n```\n\n#### Sleeping for a Fixed Duration\n\nThe sleep function blocks the current thread for the specified number of milliseconds. It behaves similarly to the [`Atomic.wait()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait) API.\n\n```typescript\nimport { sleep } from '@se-oss/deasync';\n\nconsole.log(Date.now(), 'Hello');\nsleep(1000);\nconsole.log(Date.now(), 'World!');\n```\n\n## 📚 Documentation\n\nFor all configuration options, please see [the API docs](https://www.jsdocs.io/package/@se-oss/deasync).\n\n## 🤝 Contributing\n\nWant to contribute? Awesome! To show your support is to star the project, or to raise issues on [GitHub](https://github.com/shahradelahi/deasync)\n\nThanks again for your support, it is much appreciated! 🙏\n\n## 🙌 Credits\n\nThis project is inspired by [deasync](https://github.com/abbr/deasync), originally created by [Vladimir Kurchatkin](https://github.com/vkurchatkin) and later maintained by [@abbr](https://github.com/abbr).\n\n## License\n\n[MIT](/LICENSE) © [Shahrad Elahi](https://github.com/shahradelahi) and [contributors](https://github.com/shahradelahi/deasync/graphs/contributors).\n","readmeFilename":"README.md"}