{"id":16330019,"url":"https://github.com/luin/dotq","last_synced_at":"2025-07-06T13:38:10.041Z","repository":{"id":10409444,"uuid":"12565626","full_name":"luin/dotQ","owner":"luin","description":"Yet another Q.","archived":false,"fork":false,"pushed_at":"2013-09-05T05:00:11.000Z","size":116,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-09T13:47:55.656Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-03T14:14:50.000Z","updated_at":"2019-01-13T05:17:17.000Z","dependencies_parsed_at":"2022-09-07T14:10:10.210Z","dependency_job_id":null,"html_url":"https://github.com/luin/dotQ","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luin/dotQ","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2FdotQ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2FdotQ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2FdotQ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2FdotQ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luin","download_url":"https://codeload.github.com/luin/dotQ/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luin%2FdotQ/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260944853,"owners_count":23086899,"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-10T23:18:11.884Z","updated_at":"2025-07-06T13:38:09.987Z","avatar_url":"https://github.com/luin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotQ\nYet another [Q](https://github.com/kriskowal/q).\n\n[![Build Status](https://travis-ci.org/luin/dotQ.png?branch=master)](https://travis-ci.org/luin/dotQ)\n\n## Introduce\nThe following code shows a pretty common case of deeply nested callbacks in JavaScript. It doesn't take a genius to figure out that these nested callbacks will eventually become a bit of a headache:\n\n    step1(function (value1) {\n      step2(value1, function(value2) {\n        step3(value2, function(value3) {\n          step4(value3, function(value4) {\n            // Do something with value4\n          });\n        });\n      });\n    });\n\nWith the dotQ library, you can flatten the pyramid.\n\n    require('dotq');\n\n    step1.promise()\n      .then(function(value1) {\n        return step2.promise(value1);\n      })\n      .then(function(value2) {\n        return step3.promise(value2);\n      })\n      .then(function(value3) {\n        return step4.promise(value3);\n      })\n      .then(function(value4) {\n        // Do something with value4\n      });\n\n## Install\n    npm install dotq\n\n## Difference between dotQ and Q\ndotQ is based on Q. dotQ extends the `Function` object with a `promise` method in order to convert the Node.js style callbacks(`function(err, result)`) into Q Promises.\n\nWhat's more, the style of dotQ works better with the [express-promise](https://github.com/luin/express-promise) library.\n\n## Shortcuts\n\n### map / reduce / filter / some / every\ndotQ also extends the Q Promise with some useful methods of Array object. For example:\n\n    function anAsyncFunction(number, callback) {\n      callback(null, [number, number + 1, number + 2]);\n    }\n\n    anAsyncFunction.promise(3)\n      .map(function(n) {\n        return n + 10;\n      })\n      .then(function(result) {\n        console.log(result); // [ 13, 14, 15 ]\n      });\n\n\n## How to use\nIn node.js, Each file loaded shares the same primordial objects like Object, Array, etc,\nso you can just require dotQ once in your initialization, after which you can use dotQ everywhere.\n\n## OMG IT EXTENDS FUNCTION???!?!@\nhttps://github.com/visionmedia/should.js/#omg-it-extends-object\n\nhttp://sugarjs.com/native\n\n## License\nThe MIT License (MIT)\n\nCopyright (c) 2013 Zihua Li\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluin%2Fdotq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluin%2Fdotq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluin%2Fdotq/lists"}