{"id":15497378,"url":"https://github.com/heapwolf/asde","last_synced_at":"2025-07-18T05:37:36.738Z","repository":{"id":57184707,"uuid":"94688964","full_name":"heapwolf/asde","owner":"heapwolf","description":"A low level module for destructuring asynchronous values.","archived":false,"fork":false,"pushed_at":"2017-06-24T22:51:25.000Z","size":5,"stargazers_count":50,"open_issues_count":0,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T19:11:15.274Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heapwolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-18T13:28:19.000Z","updated_at":"2024-02-28T18:55:34.000Z","dependencies_parsed_at":"2022-09-14T09:01:07.955Z","dependency_job_id":null,"html_url":"https://github.com/heapwolf/asde","commit_stats":null,"previous_names":["0x00a/asde"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fasde","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fasde/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fasde/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fasde/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heapwolf","download_url":"https://codeload.github.com/heapwolf/asde/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250330534,"owners_count":21412993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T08:33:17.063Z","updated_at":"2025-04-22T21:45:20.915Z","avatar_url":"https://github.com/heapwolf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SYNOPSIS\nA low level module for destructuring asynchronous values.\n\n# MOTIVATION\nUse `async/await` on regular callback APIs, return `[error||null, ...values]`.\n\n# DESCRIPTION\n`asde` is a low level module that wraps a node-style function call in a promise\nso that it can be used with `async/await`. The promise always resolves with an\narray of values (error first). The values can then be identified using\na `destructuring assignment`, providing both the error and values in the same\nchannel without expectation of a try/catch block.\n\n# USAGE\nHere are some notes on how async functions work with the await keyword.\n\n### ASYNC\n`async` functions help solve `promise hell`. They provide a synchronous-looking\nway to receive asynchronous values.\n\n```js\nasync function main () {\n  // the await keyword is only available inside async functions.\n\n  // async functions are \"shallow\"! await is not available\n  // to any nested, non-async functions in the scope.\n\n  // an exception in an async function body\n  // will throw an unhandled promise rejection.\n\n  // try/catch blocks can be used to handle rejections.\n}\n```\n\n### AWAIT\nThe `await` keyword waits until a promise resolves or rejects.\n\n```js\nconst b = new Promise((resolve, reject) =\u003e {\n  setTimeout(() =\u003e resolve('b'), 16)\n})\n\nasync function main () {\n  try {\n    console.log('a')\n    console.log(await b)\n    console.log('c')\n  } catch (ex) {\n    console.log(ex)\n  }\n}\n\nmain()\n```\n\nIf you don't catch, the `rejection` will \"bubble up\" until it finds a promise\nthat can handle it. If one isn't found, Node.js (and some browsers) provide a\ncatch-all event called `unhandledRejection` (similar to `uncaughtException`).\n\n# USAGE\n`asde` will return a function that takes the same arguments as the original\nfunction, but does not require a `callback`. The new function should be called\nwith the `await` keyword from within a `async` function.\n\n```js\nconst asde = require('asde')\nconst fs = require('fs')\n\nconst stat = asde(fs.stat)\n\nasync function main () {\n  const [errStat, value] = await stat('./file')\n\n  if (errStat) {\n    return console.error(errStat)\n  }\n\n  console.log(value)\n}\n\nmain()\n```\n\n# INSTALL\n\n```js\nnpm install asde\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Fasde","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheapwolf%2Fasde","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Fasde/lists"}