{"_id":"@buildkitchen/maybe_promise","_rev":"2-d8cb0e115a82762417b2662bc10b00f6","name":"@buildkitchen/maybe_promise","dist-tags":{"latest":"0.0.6"},"versions":{"0.0.5":{"name":"@buildkitchen/maybe_promise","version":"0.0.5","keywords":["promise","async","await"],"author":{"name":"Kwasi Mensah","email":"kwasi.mensah@gmail.com"},"license":"MIT","_id":"@buildkitchen/maybe_promise@0.0.5","maintainers":[{"name":"kmensah23","email":"kwasi.mensah@gmail.com"}],"homepage":"https://codeberg.org/buildkitchen/maybe_promise","bugs":{"url":"https://codeberg.org/buildkitchen/maybe_promise"},"dist":{"shasum":"11198c00901b68829cbffe4a236135687b05dbf8","tarball":"https://registry.npmjs.org/@buildkitchen/maybe_promise/-/maybe_promise-0.0.5.tgz","fileCount":6,"integrity":"sha512-Y1bw9uv64hmov+OycV2FpO/+H5r+iBTl/a/E3t9dt6II3HIDNqcjhJGQP0kfLxCvmSitRNR6ZgRtCAUwET2U8Q==","signatures":[{"sig":"MEQCIFeCgwXZuYTqZf2376AhJHyNNK9oDaLnpscTCLhdRbAzAiAed1FWnWZTomRma78vb26qU9Nyzz1IvvfkHAQgyDIUKg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52517},"types":"./index.d.ts","private":false,"_npmUser":{"name":"kmensah23","email":"kwasi.mensah@gmail.com"},"_npmVersion":"11.12.1","description":"Promise type that resolve synchronously when possible.","directories":{},"_nodeVersion":"24.15.0","dependencies":{},"_hasShrinkwrap":false,"bundleDependencies":[],"_npmOperationalInternal":{"tmp":"tmp/maybe_promise_0.0.5_1785427848196_0.24054519902714122","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"description":"Promise type that resolve synchronously when possible.","homepage":"https://codeberg.org/buildkitchen/maybe_promise","bugs":{"url":"https://codeberg.org/buildkitchen/maybe_promise"},"license":"MIT","author":{"name":"Kwasi Mensah","email":"kwasi.mensah@gmail.com"},"keywords":["promise","async","await"],"name":"@buildkitchen/maybe_promise","private":false,"version":"0.0.6","dependencies":{},"types":"./index.d.ts","_id":"@buildkitchen/maybe_promise@0.0.6","bundleDependencies":[],"_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-Vq13nEf640DycWm367Bmbr5/SEca7gbr6mQpa1yknx0s9izM6SHjWZGCJignLWHNnJLMzGSCOy7oH1Ng0z9Y6g==","shasum":"386b68ce208a14c1cc37c021088ad1da78c43da5","tarball":"https://registry.npmjs.org/@buildkitchen/maybe_promise/-/maybe_promise-0.0.6.tgz","fileCount":6,"unpackedSize":52517,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEsWjGmTf6caJ25CO2FmK/yKxCqtLIU0JiWEV5FvzsgiAiAKXUUBLPno0V/WO+yKsTG20LQOEGEIiS15jKBN2ATmcQ=="}]},"_npmUser":{"name":"kmensah23","email":"kwasi.mensah@gmail.com"},"directories":{},"maintainers":[{"name":"kmensah23","email":"kwasi.mensah@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/maybe_promise_0.0.6_1785428140735_0.9596770607040619"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-30T16:10:48.034Z","modified":"2026-07-30T16:15:41.056Z","0.0.5":"2026-07-30T16:10:48.338Z","0.0.6":"2026-07-30T16:15:40.893Z"},"bugs":{"url":"https://codeberg.org/buildkitchen/maybe_promise"},"author":{"name":"Kwasi Mensah","email":"kwasi.mensah@gmail.com"},"license":"MIT","homepage":"https://codeberg.org/buildkitchen/maybe_promise","keywords":["promise","async","await"],"description":"Promise type that resolve synchronously when possible.","maintainers":[{"name":"kmensah23","email":"kwasi.mensah@gmail.com"}],"readme":"# 📦 @buildkitchen/maybe_promise\n\nA lightweight promise implementation that resolves synchronously for resolved values.\n\n## Installation\n\nInstall the package via your preferred package manager:\n\n```bash\nnpm install @buildkitchen/maybe_promise\n```\n\nOr using yarn/pnpm:\n\n```bash\nyarn add @buildkitchen/maybe_promise\npnpm add @buildkitchen/maybe_promise\n```\n\n## Usage\n\nThis is a promise implementation that is mostly conforming with the A+ test suite. The main differences are resolution order.\n\n```javascript\nimport { MaybePromise } from \"@buildkitchen/maybe_promise\";\n\nMaybePromise.resolve(5).then(() => console.log(\"promise is resolved\"));\nconsole.log(\"hello world\");\n```\n\nWith standard promises `\"hello world\"` would print first. But with MaybePromsie `\"promise is resolved\"` will print first.\n\nThis is useful when paired with caching async work i.e. you have work that is asynchronous but you don't want later cache hits to have to wait a microtask cycle for the event loop to resolve.\n\nInspired by [this post](https://bluepnume.medium.com/intentionally-unleashing-zalgo-with-promises-ab3f63ead2fd)\n\n## API Reference\n\nThis uses the same API as [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with one added function\n\n### `MaybePromise.batch<T>(promises: Iterable<PromiseLike<T>>)`\n\nA combination of `MaybePromise.allSettled` and `MaybePromise.all` when you don't want the fail-fast behavior of `MaybePromise.all` i.e. you want to make sure all connected promises have succeeded or failed before signalling completion. It can make error-handling much easier to follow.\n\n## Contributing\n\nWe're not actively soliticing contributions but please let us know of any bugs/issues you find in this code and we'll try to resolve them in a timely manner.\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n","readmeFilename":"README.md"}