{"id":25072379,"url":"https://github.com/lanfei/deferred-lib","last_synced_at":"2025-03-31T17:26:27.866Z","repository":{"id":19880839,"uuid":"23145006","full_name":"Lanfei/deferred-lib","owner":"Lanfei","description":"A lightweight implementation of Deferred/Promise.","archived":false,"fork":false,"pushed_at":"2016-07-19T08:23:20.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T18:01:46.287Z","etag":null,"topics":["deffered","promise"],"latest_commit_sha":null,"homepage":"https://nodei.co/npm/deferred-lib","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/Lanfei.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-08-20T10:35:00.000Z","updated_at":"2019-01-26T12:39:11.000Z","dependencies_parsed_at":"2022-09-07T10:41:13.895Z","dependency_job_id":null,"html_url":"https://github.com/Lanfei/deferred-lib","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/Lanfei%2Fdeferred-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lanfei%2Fdeferred-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lanfei%2Fdeferred-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lanfei%2Fdeferred-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lanfei","download_url":"https://codeload.github.com/Lanfei/deferred-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246507244,"owners_count":20788784,"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":["deffered","promise"],"created_at":"2025-02-06T22:19:32.305Z","updated_at":"2025-03-31T17:26:27.840Z","avatar_url":"https://github.com/Lanfei.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deferred\n\nA lightweight implementation of Deferred/Promise.\n\n[![NPM](https://nodei.co/npm/deferred-lib.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/deferred-lib)\n\n## Installation\n\n### Node\n\n```bash\n$ npm install deferred-lib\n```\n\n### Browser\n\n```html\n\u003cscript src=\"js/deferred.min.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n```js\n// Usage 1\n// Declare the deferred instance and use it.\nfunction countdown1() {\n\tvar deferred = new Deferred();\n\tvar i = 5;\n\tvar timer = setInterval(function () {\n\t\tdeferred.notify(i);\n\t\tif (i-- === 0) {\n\t\t\tdeferred.resolve('Hi');\n\t\t\tclearInterval(timer);\n\t\t}\n\t}, 300);\n\treturn deferred.promise();\n}\n\ncountdown1().progress(function (step) {\n\tconsole.log('countdown1', step);\n}).done(function () {\n\tconsole.log('countdown1 done');\n});\n\n\n// Usage 2\n// Use `Deferred(fn)` and get the deferred instance with `this` context.\nfunction countdown2() {\n\tvar self = this;\n\tvar i = 5;\n\tvar timer = setInterval(function () {\n\t\tself.notify(i);\n\t\tif (i-- === 0) {\n\t\t\tself.resolve('Hi');\n\t\t\tclearInterval(timer);\n\t\t}\n\t}, 300);\n}\n\nDeferred(countdown2).progress(function (step) {\n\tconsole.log('countdown2', step);\n}).done(function () {\n\tconsole.log('countdown2 done');\n});\n```\n\n**See `examples` directory for more usages.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanfei%2Fdeferred-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flanfei%2Fdeferred-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanfei%2Fdeferred-lib/lists"}