{"id":19560630,"url":"https://github.com/zoubin/when-ready","last_synced_at":"2025-02-26T08:41:39.450Z","repository":{"id":143928886,"uuid":"47385518","full_name":"zoubin/when-ready","owner":"zoubin","description":"Increasing delays dynamically","archived":false,"fork":false,"pushed_at":"2015-12-04T10:26:42.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T17:05:45.393Z","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/zoubin.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":"2015-12-04T06:19:52.000Z","updated_at":"2016-05-07T12:46:25.000Z","dependencies_parsed_at":"2023-03-21T12:00:34.957Z","dependency_job_id":null,"html_url":"https://github.com/zoubin/when-ready","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fwhen-ready","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fwhen-ready/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fwhen-ready/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Fwhen-ready/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoubin","download_url":"https://codeload.github.com/zoubin/when-ready/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240822615,"owners_count":19863302,"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-11-11T05:08:19.072Z","updated_at":"2025-02-26T08:41:39.271Z","avatar_url":"https://github.com/zoubin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# when-ready\n[![version](https://img.shields.io/npm/v/when-ready.svg)](https://www.npmjs.org/package/when-ready)\n[![status](https://travis-ci.org/zoubin/when-ready.svg?branch=master)](https://travis-ci.org/zoubin/when-ready)\n[![coverage](https://img.shields.io/coveralls/zoubin/when-ready.svg)](https://coveralls.io/github/zoubin/when-ready)\n[![dependencies](https://david-dm.org/zoubin/when-ready.svg)](https://david-dm.org/zoubin/when-ready)\n[![devDependencies](https://david-dm.org/zoubin/when-ready/dev-status.svg)](https://david-dm.org/zoubin/when-ready#info=devDependencies)\n\nSugar way to manage your pendings.\n\n## Example\n\n```javascript\nvar Ready = require('..')\n\nfunction Concat() {\n  this.ready = Ready()\n}\n\nConcat.prototype.add = function(file) {\n  this['addType' + (rand() % 2 + 1)](file)\n}\n\nConcat.prototype.addType1 = function(file) {\n  var self = this\n\n  this.ready.delay(\n    new Promise(function (resolve) {\n      setTimeout(function() {\n        self.push('{' + file.slice(-1) + '}')\n        resolve()\n      }, rand())\n    })\n  )\n}\n\nConcat.prototype.addType2 = function(file) {\n  var cb = this.ready.delay()\n\n  var self = this\n  setTimeout(function() {\n    self.push('[' + file.slice(-1) + ']')\n    cb()\n  }, rand())\n}\n\nConcat.prototype.push = function(source) {\n  console.log(source.toUpperCase())\n}\n\nConcat.prototype.end = function() {\n  var self = this\n  this.ready.then(function () {\n    self.push('\\n# end #')\n  })\n}\n\nfunction rand() {\n  return Math.ceil(Math.random() * 100)\n}\n\nvar concat = new Concat()\n\nconcat.add('./a')\nconcat.add('./b')\nconcat.add('./c')\nconcat.end()\n\n// [B]\n// {C}\n// [A]\n// \n// # END #\n\n\n```\n\n## class Ready()\nInstances are `thenable` objects.\n\n### .then(onFulfilled, onRejected)\n\n### .catch(onRejected)\n\n### .delay(n)\n\nIf `n` is `Number`, it specifies the amount of time to be delayed.\n\nIf `n` is `Promise`, it delays until the promise resolves or rejects.\n\nOtherwise, it delays until the returned callback is called.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Fwhen-ready","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoubin%2Fwhen-ready","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Fwhen-ready/lists"}