{"id":21716704,"url":"https://github.com/postor/async-drop-late","last_synced_at":"2025-03-20T19:58:12.913Z","repository":{"id":57185533,"uuid":"144661323","full_name":"postor/async-drop-late","owner":"postor","description":null,"archived":false,"fork":false,"pushed_at":"2018-08-14T03:48:05.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-26T04:37:20.214Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postor.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":"2018-08-14T03:03:03.000Z","updated_at":"2018-08-14T03:48:06.000Z","dependencies_parsed_at":"2022-09-14T08:50:36.348Z","dependency_job_id":null,"html_url":"https://github.com/postor/async-drop-late","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/postor%2Fasync-drop-late","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postor%2Fasync-drop-late/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postor%2Fasync-drop-late/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postor%2Fasync-drop-late/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postor","download_url":"https://codeload.github.com/postor/async-drop-late/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244679630,"owners_count":20492447,"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-26T01:12:48.625Z","updated_at":"2025-03-20T19:58:12.891Z","avatar_url":"https://github.com/postor.png","language":"JavaScript","readme":"# async-drop-late\n\n有同学在多次ajax的时候遇到了较早的请求后到导致数据不一致的问题，最好的方案当然是数据包含版本，但这个实现就不依赖后端也能确保数据不会被迟到的ajax结果覆盖\n\nsometimes former ajax result may come late and over write the right data with outdated data, this package keeps the secquence, and reject when the former ajax comes late\n\n## usage\n\n```\nconst dropLate = require('async-drop-late')\n\n//first async, delay 2second, will resolve after second async and get dropped!\ndropLate(delay(1500,'first'))\n.then((v)=\u003econsole.log(`wrong!`,v))\n.catch((e)=\u003econsole.log(`first async get dropped!`,e))\n\ndropLate(delay(1000,'second'))\n.then((v)=\u003econsole.log(`second async done`,v))\n.catch((e)=\u003econsole.log(`wrong!`,e))\n\ndropLate(delay(2000,'third'))\n.then((v)=\u003econsole.log(`third async done`,v))\n.catch((e)=\u003econsole.log(`wrong!`,e))\n\n\n//different key won't mess up\ndropLate(delay(500,'fuorth'),'testkey')\n.then((v)=\u003econsole.log(`fuorth async with another key done`,v))\n.catch((e)=\u003econsole.log(`wrong!`,e))\n\n\nfunction delay(miliseconds,name){\n  return new Promise((resolve)=\u003e{\n    setTimeout(()=\u003eresolve(name),miliseconds)\n  })\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostor%2Fasync-drop-late","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostor%2Fasync-drop-late","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostor%2Fasync-drop-late/lists"}