{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/promises/issues/25","repository_url":"https://api.github.com/repos/nodejs/promises","labels_url":"https://api.github.com/repos/nodejs/promises/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/promises/issues/25/comments","events_url":"https://api.github.com/repos/nodejs/promises/issues/25/events","html_url":"https://github.com/nodejs/promises/issues/25","id":134353454,"number":25,"title":"Promise API: Accept Promises for Argument Values","user":{"login":"chrisdickinson","id":37303,"avatar_url":"https://avatars.githubusercontent.com/u/37303?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisdickinson","html_url":"https://github.com/chrisdickinson","followers_url":"https://api.github.com/users/chrisdickinson/followers","following_url":"https://api.github.com/users/chrisdickinson/following{/other_user}","gists_url":"https://api.github.com/users/chrisdickinson/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisdickinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisdickinson/subscriptions","organizations_url":"https://api.github.com/users/chrisdickinson/orgs","repos_url":"https://api.github.com/users/chrisdickinson/repos","events_url":"https://api.github.com/users/chrisdickinson/events{/privacy}","received_events_url":"https://api.github.com/users/chrisdickinson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/promises/labels/async-await","name":"async-await","color":"bfd4f2"},{"url":"https://api.github.com/repos/nodejs/promises/labels/blocks-landing-pr","name":"blocks-landing-pr","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-17T17:57:35Z","updated_at":"2016-02-17T18:18:36Z","closed_at":null,"body":"Something I've found useful [in my own code](https://medium.com/@isntitvacant/observations-on-promises-2b08a0d0c27), at least, is to allow any promise-returning function to accept promises as argument parameters. In situations like the following:\r\n\r\n```js\r\nconst getFD = fs.openPromise(filename, 'w')\r\nconst writeFile = getFD.then(fd => {\r\n  return fs.writeFilePromise(fd, 'data')\r\n})\r\nconst closeFD = writeFile.then(() => getFD).then(fd => {\r\n  return fs.closePromise(fd)\r\n})\r\n```\r\n\r\nIt means we can rewrite like so:\r\n\r\n```js\r\nconst getFD = fs.openPromise(filename, 'w')\r\nconst writeFile = fs.writeFilePromise(getFD, 'data')\r\nconst closeFD = writeFile.then(() => fs.closePromise(getFD))\r\n```\r\n\r\nIf we're not going down the route of `--abort-on-sync-rejection`, it seems like this would be fairly trivial to implement. Is there interest in this?"},"comment":{"url":"https://api.github.com/repos/nodejs/promises/issues/comments/185332824","html_url":"https://github.com/nodejs/promises/issues/25#issuecomment-185332824","issue_url":"https://api.github.com/repos/nodejs/promises/issues/25","id":185332824,"user":{"login":"chrisdickinson","id":37303,"avatar_url":"https://avatars.githubusercontent.com/u/37303?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisdickinson","html_url":"https://github.com/chrisdickinson","followers_url":"https://api.github.com/users/chrisdickinson/followers","following_url":"https://api.github.com/users/chrisdickinson/following{/other_user}","gists_url":"https://api.github.com/users/chrisdickinson/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisdickinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisdickinson/subscriptions","organizations_url":"https://api.github.com/users/chrisdickinson/orgs","repos_url":"https://api.github.com/users/chrisdickinson/repos","events_url":"https://api.github.com/users/chrisdickinson/events{/privacy}","received_events_url":"https://api.github.com/users/chrisdickinson/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T18:18:36Z","updated_at":"2016-02-17T18:18:36Z","body":"@benjamingr Anecdotally, I'm asking for it (and use it a lot in the user-acl and license-api bits of the registry) :wink:\r\n\r\nDo TS/Flow users allow multiple types in a signature? It seems like `Promise<T> ↔︎ T` should be cast-able, but I haven't used their tools so I'm unsure if it's feasible."}}