{"id":15835134,"url":"https://github.com/kaelzhang/disposable-frames","last_synced_at":"2026-04-16T17:37:44.243Z","repository":{"id":57212971,"uuid":"168323359","full_name":"kaelzhang/disposable-frames","owner":"kaelzhang","description":"Disposable frame scheduler which abandons frames if CPU is high or the I/O event loop is blocking.","archived":false,"fork":false,"pushed_at":"2019-02-01T06:04:46.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-08T02:57:22.916Z","etag":null,"topics":["event-loop","nodejs","timer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kaelzhang.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","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":"2019-01-30T10:21:24.000Z","updated_at":"2019-02-01T06:04:53.000Z","dependencies_parsed_at":"2022-08-24T21:01:29.579Z","dependency_job_id":null,"html_url":"https://github.com/kaelzhang/disposable-frames","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/kaelzhang/disposable-frames","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fdisposable-frames","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fdisposable-frames/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fdisposable-frames/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fdisposable-frames/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaelzhang","download_url":"https://codeload.github.com/kaelzhang/disposable-frames/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fdisposable-frames/sbom","scorecard":{"id":547082,"data":{"date":"2025-08-11","repo":{"name":"github.com/kaelzhang/disposable-frames","commit":"be80164c7a5ed73b618a6cfe700b019dae716748"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}}]},"last_synced_at":"2025-08-20T09:48:58.387Z","repository_id":57212971,"created_at":"2025-08-20T09:48:58.387Z","updated_at":"2025-08-20T09:48:58.387Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275134617,"owners_count":25411563,"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","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["event-loop","nodejs","timer"],"created_at":"2024-10-05T14:20:52.419Z","updated_at":"2026-04-16T17:37:39.202Z","avatar_url":"https://github.com/kaelzhang.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/kaelzhang/disposable-frames.svg?branch=master)](https://travis-ci.org/kaelzhang/disposable-frames)\n[![Coverage](https://codecov.io/gh/kaelzhang/disposable-frames/branch/master/graph/badge.svg)](https://codecov.io/gh/kaelzhang/disposable-frames)\n\u003c!-- optional appveyor tst\n[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/kaelzhang/disposable-frames?branch=master\u0026svg=true)](https://ci.appveyor.com/project/kaelzhang/disposable-frames)\n--\u003e\n\u003c!-- optional npm version\n[![NPM version](https://badge.fury.io/js/disposable-frames.svg)](http://badge.fury.io/js/disposable-frames)\n--\u003e\n\u003c!-- optional npm downloads\n[![npm module downloads per month](http://img.shields.io/npm/dm/disposable-frames.svg)](https://www.npmjs.org/package/disposable-frames)\n--\u003e\n\u003c!-- optional dependency status\n[![Dependency Status](https://david-dm.org/kaelzhang/disposable-frames.svg)](https://david-dm.org/kaelzhang/disposable-frames)\n--\u003e\n\n# disposable-frames\n\nDisposable frame scheduler which abandons frames if CPU is high or the I/O event loop is blocking. `disposable-frames` is useful for web pages with heavy DOM manipulation.\n\n`disposable-frames` detects the usage of CPU approximately by monitoring the hehavior of `setTimeout(func, 0)`.\n\n## Install\n\n```sh\n$ npm i disposable-frames\n```\n\n## Usage\n\n```js\nimport {\n  setImmediate,\n  immediate\n} from 'disposable-frames'\n```\n\n## setImmediate(func: Function, options: Object): number | Immediate\n\n- **func** `Function` The function to call as `setTimeout(func, 0)`\n- **options.tolerance** `?number=0` The miniseconds within which since the `setImmediate` called that the `func` is allowed to execute. If `options.tolerance` is `0`, the default value, it indicates there is no restriction, which is silly because it is the only reason for this package to exist.\n- Returns\n  - [`Immediate`](https://nodejs.org/dist/latest-v11.x/docs/api/timers.html#timers_class_immediate) on node\n  - `number` the timer id on browsers\n\nSchedules the \"immediate\" execution of the `func` if the schedule doesn't take too long.\n\nIf we schedule a function `foo` with `options.tolerance` as `50`(ms), and in the real world, the I/O event loops take too long to respond, which causes that the `setImmediate` callback is supposed to be scheduled after 100ms from the beginning. And then the execution of `foo` will be abandoned according to `options.tolerance`.\n\n```js\nsetImmediate(func, {\n  tolerance: 10\n})\n```\n\n## immediate(func: Function, options: Object): Function\n\n- **func** `Function` The function to call as `setTimeout(func, 0)`\n- **options** `?Object`\n  - **tolerance** `?number=0`\n  - **maxWait** `?number=0` The maximum time `func` is allowed to be abandoned before it's invoked. In the other words, after every `maxWait` time, one execution of `func` is allowed despite of the limitation of `tolerance`. If `maxWait` is 0, the feature is disabled.\n  - **leading** `boolean=false` If `true`, the first execution is always allowed.\n\nWrap the `func` as a new function which schedules `func` as well as `setImmediate` does every time the wrapper function invokes.\n\n```js\nconst wrapped = immediate(func, {\n  maxWait: 500,\n  tolerance: 50\n})\n```\n\nSuppose that it takes precisely 100ms for `func` to execute every time then:\n\n```js\nwrapped()                   // will execute\nwrapped()                   // disposed\nwrapped()                   // disposed\nsetTimeout(wrapped, 200)    // will execute\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaelzhang%2Fdisposable-frames","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaelzhang%2Fdisposable-frames","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaelzhang%2Fdisposable-frames/lists"}