{"id":24520463,"url":"https://github.com/substrate-system/after","last_synced_at":"2025-08-24T09:20:31.804Z","repository":{"id":269392588,"uuid":"907181293","full_name":"substrate-system/after","owner":"substrate-system","description":"Resolve a promise after n calls","archived":false,"fork":false,"pushed_at":"2025-03-22T05:46:23.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T11:03:17.222Z","etag":null,"topics":["after","promise"],"latest_commit_sha":null,"homepage":"https://substrate-system.github.io/after/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/substrate-system.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-23T02:41:16.000Z","updated_at":"2025-03-22T05:46:21.000Z","dependencies_parsed_at":"2024-12-23T09:18:01.872Z","dependency_job_id":"d303e11b-3bff-4032-853f-c1e3e1c681ed","html_url":"https://github.com/substrate-system/after","commit_stats":null,"previous_names":["substrate-system/after"],"tags_count":4,"template":false,"template_full_name":"nichoth/template-ts-browser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fafter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fafter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fafter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fafter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/substrate-system","download_url":"https://codeload.github.com/substrate-system/after/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868768,"owners_count":21174757,"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":["after","promise"],"created_at":"2025-01-22T02:37:05.894Z","updated_at":"2025-04-14T11:03:56.298Z","avatar_url":"https://github.com/substrate-system.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# after\n![tests](https://github.com/substrate-system/after/actions/workflows/nodejs.yml/badge.svg)\n[![types](https://img.shields.io/npm/types/@substrate-system/after?style=flat-square)](README.md)\n[![module](https://img.shields.io/badge/module-ESM%2FCJS-blue?style=flat-square)](README.md)\n[![semantic versioning](https://img.shields.io/badge/semver-2.0.0-blue?logo=semver\u0026style=flat-square)](https://semver.org/)\n[![Common Changelog](https://nichoth.github.io/badge/common-changelog.svg)](./CHANGELOG.md)\n[![install size](https://flat.badgen.net/packagephobia/install/@substrate-system/after)](https://packagephobia.com/result?p=@substrate-system/after)\n[![dependencies](https://img.shields.io/badge/dependencies-zero-brightgreen.svg?style=flat-square)](package.json)\n[![license](https://img.shields.io/badge/license-Polyform_Non_Commercial-26bc71?style=flat-square)](LICENSE)\n\nLike [`after`](https://github.com/Raynos/after), but for the world of promises. Resolve a promise after some number of calls.\n\nThis depends on an environment with [Proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy).\n\n\u003cdetails\u003e\u003csummary\u003e\u003ch2\u003eContents\u003c/h2\u003e\u003c/summary\u003e\n\n\u003c!-- toc --\u003e\n\n- [install](#install)\n- [Module Format](#module-format)\n  * [ESM](#esm)\n  * [Common JS](#common-js)\n  * [pre-built JS](#pre-built-js)\n- [Example](#example)\n  * [async](#async)\n\n\u003c!-- tocstop --\u003e\n\n\u003c/details\u003e\n\n## install\n\n```sh\nnpm i -S @substrate-system/after\n```\n\n## Module Format\n\nThis exposes ESM and common JS via [package.json `exports` field](https://nodejs.org/api/packages.html#exports).\n\n### ESM\n```js\nimport { after } from '@substrate-system/after'\n```\n\n### Common JS\n```js\nconst after = require('@substrate-system/after')\n```\n\n### pre-built JS\nThis package exposes minified JS files too. Copy them to a location that is\naccessible to your web server, then link to them in HTML.\n\n#### copy\n```sh\ncp ./node_modules/@substrate-system/after/dist/index.min.js ./public/after.min.js\n```\n\n#### HTML\n```html\n\u003cscript type=\"module\" src=\"./after.min.js\"\u003e\u003c/script\u003e\n```\n\n## Example\nResolve a promise after three function calls.\n\nThe value returned, `next`, is a function and also a promise. Call it when you want to increment the count.\n\n```js\nimport { after } from '@substrate-system/after'\n\nconst next = after(3)\n\n// 1\nsetTimeout(() =\u003e next(), 10)\n\n// 2\nsetTimeout(() =\u003e next(), 20)\n\n// 3\nsetTimeout(() =\u003e next(), 30)\n\n// 4 -- this does nothing\nsetTimeout(() =\u003e next(), 40)\n\nnext.then(() =\u003e {\n    console.log('30ms later...')\n})\n```\n\n### async\n\n```js\nconst next = after(3)\n\nsetTimeout(() =\u003e next, 100)\nsetTimeout(() =\u003e next, 200)\nsetTimeout(() =\u003e next, 300)\n\nconst time = Number(new Date())\n\nawait next  // wait for 3 calls -- 300ms\n\nconst afterTime = Number(new Date())\nconst diff = afterTime - time\n\nconsole.log(diff \u003e= 300)  // true\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubstrate-system%2Fafter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubstrate-system%2Fafter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubstrate-system%2Fafter/lists"}