{"id":16318605,"url":"https://github.com/vic/promised","last_synced_at":"2026-02-14T13:03:46.353Z","repository":{"id":4410537,"uuid":"5548069","full_name":"vic/promised","owner":"vic","description":"Convert back and forth from javascript Promises to Callbacks","archived":false,"fork":false,"pushed_at":"2012-08-25T11:24:40.000Z","size":148,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-13T18:18:27.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://vic.github.com/promised","language":null,"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/vic.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":"2012-08-25T02:58:40.000Z","updated_at":"2014-07-07T12:16:17.000Z","dependencies_parsed_at":"2022-09-17T17:00:35.002Z","dependency_job_id":null,"html_url":"https://github.com/vic/promised","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vic/promised","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fpromised","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fpromised/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fpromised/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fpromised/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vic","download_url":"https://codeload.github.com/vic/promised/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fpromised/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278172153,"owners_count":25942282,"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","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10T22:24:05.483Z","updated_at":"2025-10-03T13:35:50.122Z","avatar_url":"https://github.com/vic.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Promised #.\n\nConvert back and forth from javascript Promises to Callbacks\n\nThis library works on both node and browser.\nCurrently it supports jQuery and Q promises.\n\n[jQuery]: [http://api.jquery.com/category/deferred-object]\n[Q]: [http://documentup.com/kriskowal/q/]\n\n## Usage ##\n\n```javascript\nvar P = require('promised') // or window.promised in browsers\n\nvar promisedQ = P.Q( Q )      // Use Promised with Q deferreds\nvar promisedJ = P.$( jQuery ) // Use Promised with JQuery deferreds\n\n// Or you can give P two functions:\n//\n// deferrer: takes a single argument and creates a deferred object\n//           with it or returns it if already a referred.\n//\n// promiser: takes a deferred object and returns a promise for it\n//\n\nvar promisedCustom = P( defferer, promiser )\n\n```\n\n## API ##\n\nIn the following signatures `callback\u003ce,s\u003e` means a function that\ntakes two arguments, one for error and the second for success. And\n`callback\u003cv\u003e` is a function that takes a single value; in node\nAPI these kind of callbacks are used for predicates, functions that\neither invoke the callback with true or false, that's why each of\nthe following functions has a `p.` version which works with this\nkind of predicate callbacks.\n\n### Deferred generator to Callback receiver ###\n\n`P(function, receiver, args...)` -\u003e `function(args..., callback\u003ce,s\u003e)`\n\n`P.p(function, receiver, args...)` -\u003e `function(args..., callback\u003cv\u003e)`\n\nThis transformation takes a function that will return a _deferred_ and\nwill transform it into a function that expects any number of arguments\nand a _callback_ as the last one.\n\n```\nP(jQuery.ajax, jQuery)\n\n// is equivalent to\nfunction(args..., callback) {\n  var deferred = jQuery.ajax(args...)\n    , promise = deferred.promise()\n  promise.then(callbackSuccess, callbackError)\n}\n```\n\nFunctions returned by `P` can be curried by using it's `curry` method.\nThis way you can add arguments to the function without yet invoking it.\n\n`_.curry(args...)` -\u003e `function(args..., callback\u003ce,s\u003e)`\n\n### Forward a Promise to Callback arguments ###\n\n`P.fwd(promise, callback\u003ce, s\u003e)`\n\n`P.p.fwd(promise, callback\u003cv\u003e)`\n\nWhen the given _promise_ is resolved/rejected, the _callback_ is called\naccordingly.\n\n\n### Turn a Deferred into a Callback ###\n\n`P.bwd(deferred)` -\u003e `function(error, success)`\n\n`P.p.bwd(deferred)` -\u003e `function(value)`\n\nWhen the returned _callback_ is given an error argument, the\n_deferred_ will be rejected, otherwise it will be resolved.\n\n### Turn a Promise into a Function that takes a callback and resolves ###\n\n`P.get(promise)` -\u003e `function(callback\u003ce,s\u003e){ resolve(s)/reject(e) }`\n`P.p.get(promise)` -\u003e `function(callback\u003cv\u003e){ promise.resolve(v) }`\n\nIf given multiple _promise_s, `.get` will return an array of functions.\n\n### Turn a Deferred into a Function (callback) that resolves/rejects ###\n\n`P.set(deferred)` -\u003e `function(error, success) { resolve(success)/reject(error) }`\n`P.p.set(deferred)` -\u003e `function(value) { resolve(value) }`\n\nIf `p.set` is given multiple _deferred_s each of them will be resolved\nto the corresponding argument the _callback_ is called with.\nIf `.set` is given multiple _deferred_s all of them will be\nresolved/rejected to the same value.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvic%2Fpromised","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvic%2Fpromised","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvic%2Fpromised/lists"}