{"id":16588480,"url":"https://github.com/oliverjash/nodeify-function","last_synced_at":"2025-03-06T11:23:21.953Z","repository":{"id":23716724,"uuid":"27089441","full_name":"OliverJAsh/nodeify-function","owner":"OliverJAsh","description":"Q helper for nodeifying a promise returning function.","archived":false,"fork":false,"pushed_at":"2015-01-08T15:44:34.000Z","size":168,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-16T22:12:39.380Z","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/OliverJAsh.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":"2014-11-24T18:44:14.000Z","updated_at":"2015-01-08T15:44:34.000Z","dependencies_parsed_at":"2022-08-22T04:30:51.286Z","dependency_job_id":null,"html_url":"https://github.com/OliverJAsh/nodeify-function","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverJAsh%2Fnodeify-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverJAsh%2Fnodeify-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverJAsh%2Fnodeify-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverJAsh%2Fnodeify-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OliverJAsh","download_url":"https://codeload.github.com/OliverJAsh/nodeify-function/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242198088,"owners_count":20087948,"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-11T22:56:47.921Z","updated_at":"2025-03-06T11:23:21.933Z","avatar_url":"https://github.com/OliverJAsh.png","language":"JavaScript","readme":"# nodeify-function\n\nQ helper for nodeifying a promise returning function.\n\nThis method is useful for creating dual promise/callback APIs, i.e. APIs that\nreturn promises but also accept Node.js-style callbacks. [Q provides a helper\nfor nodeifying promises:\n`promise.nodeify(callback)`](https://github.com/kriskowal/q/wiki/API-Reference#promisenodeifycallback).\nThis function is the inverse: rather than nodeifying the promise, we can simply\nnodeify the function containing the promise. For example:\n\n``` js\nvar createUser = function (userName, userData) {\n    return database.ensureUserNameNotTaken(userName)\n        .then(function () {\n            return database.saveUserData(userName, userData);\n        });\n}\n\ncreateUser('Bob', { age: 42 })\n    .then(function (result) {\n        // …\n    }, function (error) {\n        // …\n    });\n\n// Without `nodeifyFunction`\n\nvar createUserNodeified = function (userName, userData, callback) {\n    createUser(userName, userData)\n        .nodeify(callback);\n};\n\n// With `nodeifyFunction`: a Q helper that abstracts the above into a\n// higher-order function\n\nvar nodeifyFunction = require('nodeify-function');\n\nvar createUserNodeified = nodeifyFunction(createUser);\n\ncreateUserNodified('Bob', { age: 42 }, function (error, result) {\n    // …\n});\n```\n\n## Installation\n\n```\nnpm install nodeify-function\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliverjash%2Fnodeify-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foliverjash%2Fnodeify-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliverjash%2Fnodeify-function/lists"}