{"id":13454452,"url":"https://github.com/lpinca/valvelet","last_synced_at":"2026-03-06T13:04:17.984Z","repository":{"id":57390560,"uuid":"60295546","full_name":"lpinca/valvelet","owner":"lpinca","description":"Limit the execution rate of a function","archived":false,"fork":false,"pushed_at":"2023-11-29T21:00:44.000Z","size":17,"stargazers_count":38,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-04T12:53:38.417Z","etag":null,"topics":["promise","rate-limiting","throttle"],"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/lpinca.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,"governance":null}},"created_at":"2016-06-02T20:36:08.000Z","updated_at":"2022-12-26T10:03:53.000Z","dependencies_parsed_at":"2023-11-29T22:23:24.375Z","dependency_job_id":"07d77d8b-c6d6-4bbf-b750-eb8a54959c0e","html_url":"https://github.com/lpinca/valvelet","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.030303030303030276","last_synced_commit":"578afc0a097f3cbf913d6109c788d8546a7efbe5"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/lpinca/valvelet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpinca%2Fvalvelet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpinca%2Fvalvelet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpinca%2Fvalvelet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpinca%2Fvalvelet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lpinca","download_url":"https://codeload.github.com/lpinca/valvelet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lpinca%2Fvalvelet/sbom","scorecard":{"id":600542,"data":{"date":"2025-08-11","repo":{"name":"github.com/lpinca/valvelet","commit":"685b042b743fa41f38ab0bffd80624a26df407ec"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"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":"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":"Code-Review","score":0,"reason":"Found 0/30 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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/lpinca/valvelet/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/lpinca/valvelet/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/lpinca/valvelet/ci.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:24","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"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":"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":"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":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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"}},{"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"}}]},"last_synced_at":"2025-08-21T00:18:09.362Z","repository_id":57390560,"created_at":"2025-08-21T00:18:09.362Z","updated_at":"2025-08-21T00:18:09.362Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30178286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T12:39:21.703Z","status":"ssl_error","status_checked_at":"2026-03-06T12:36:09.819Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["promise","rate-limiting","throttle"],"created_at":"2024-07-31T08:00:54.192Z","updated_at":"2026-03-06T13:04:17.457Z","avatar_url":"https://github.com/lpinca.png","language":"JavaScript","funding_links":[],"categories":["Packages","包","Repository","Control flow"],"sub_categories":["Control flow","流程控制","控制流"],"readme":"# valvelet\n\n[![Version npm][npm-valvelet-badge]][npm-valvelet]\n[![Build Status][ci-valvelet-badge]][ci-valvelet]\n[![Coverage Status][coverage-valvelet-badge]][coverage-valvelet]\n\nThis is a small utility to limit the execution rate of a function. It is useful\nfor scenarios such as REST APIs consumption where the amount of requests per\nunit of time should not exceed a given threshold.\n\nThis module is very similar to\n[`node-function-rate-limit`][function-rate-limit]. The difference is that\n`valvelet` works seamlessly with promise-returning functions.\n\n## Install\n\n```\nnpm install --save valvelet\n```\n\n## API\n\nThe module exports a single function that takes four arguments.\n\n### `valvelet(fn, limit, interval[, size])`\n\nReturns a function which should be called instead of `fn`.\n\n#### Arguments\n\n- `fn` - The function to rate limit calls to.\n- `limit` - The maximum number of allowed calls per `interval`.\n- `interval` - The timespan where `limit` is calculated.\n- `size` - The maximum size of the internal queue. Defaults to 2^32 - 1 which is\n  the maximum array size in JavaScript.\n\n#### Return value\n\nA function that returns a promise which resolves to the value returned by the\noriginal `fn` function. When the internal queue is at capacity the returned\npromise is rejected.\n\n#### Example\n\n```js\nconst valvelet = require('valvelet');\n\nconst get = valvelet(\n  function request(i) {\n    return Promise.resolve(`${i} - ${new Date().toISOString()}`);\n  },\n  2,\n  1000\n);\n\nfunction log(data) {\n  console.log(data);\n}\n\nfor (let i = 0; i \u003c 10; i++) {\n  get(i).then(log);\n}\n\n/*\n0 - 2016-06-02T20:07:33.843Z\n1 - 2016-06-02T20:07:33.844Z\n2 - 2016-06-02T20:07:34.846Z\n3 - 2016-06-02T20:07:34.846Z\n4 - 2016-06-02T20:07:35.846Z\n5 - 2016-06-02T20:07:35.846Z\n6 - 2016-06-02T20:07:36.848Z\n7 - 2016-06-02T20:07:36.848Z\n8 - 2016-06-02T20:07:37.851Z\n9 - 2016-06-02T20:07:37.851Z\n*/\n```\n\n## Disclaimers\n\nThis module is not a complete solution if you are trying to throttle your\nrequests to a remote API, but have multiple Node.js processes on the same or\nmultiple hosts, since the state is not shared between the services. That case\ncan be addressed by allowing each process to send up to only a fraction of the\ntotal limit. Ex: If you have 4 processes, let each process send up to $limit/4.\n\n## License\n\n[MIT](LICENSE)\n\n[npm-valvelet-badge]: https://img.shields.io/npm/v/valvelet.svg\n[npm-valvelet]: https://www.npmjs.com/package/valvelet\n[ci-valvelet-badge]:\n  https://img.shields.io/github/actions/workflow/status/lpinca/valvelet/ci.yml?branch=master\u0026label=CI\n[ci-valvelet]:\n  https://github.com/lpinca/valvelet/actions?query=workflow%3ACI+branch%3Amaster\n[coverage-valvelet-badge]:\n  https://img.shields.io/coveralls/lpinca/valvelet/master.svg\n[coverage-valvelet]: https://coveralls.io/r/lpinca/valvelet?branch=master\n[function-rate-limit]: https://github.com/wankdanker/node-function-rate-limit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpinca%2Fvalvelet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flpinca%2Fvalvelet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flpinca%2Fvalvelet/lists"}