{"id":20962990,"url":"https://github.com/doesdev/ricks-bricks","last_synced_at":"2026-04-24T17:31:53.196Z","repository":{"id":66222235,"uuid":"134503025","full_name":"doesdev/ricks-bricks","owner":"doesdev","description":"Execute cb if called X times within X ms and hasn't been run in X ms","archived":false,"fork":false,"pushed_at":"2025-05-21T17:55:31.000Z","size":1075,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T02:53:48.407Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doesdev.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-05-23T02:41:05.000Z","updated_at":"2025-05-21T17:55:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"907a3eba-ba2a-4bf0-ba94-67e5659412d0","html_url":"https://github.com/doesdev/ricks-bricks","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"334b8beb367b8fdf0a8cfadbdd3027df62d635fa"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/doesdev/ricks-bricks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fricks-bricks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fricks-bricks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fricks-bricks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fricks-bricks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doesdev","download_url":"https://codeload.github.com/doesdev/ricks-bricks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fricks-bricks/sbom","scorecard":{"id":349611,"data":{"date":"2025-08-11","repo":{"name":"github.com/doesdev/ricks-bricks","commit":"3a45ed579ee65617f58d5d60e400483904a77045"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"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":"Maintained","score":0,"reason":"1 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":"Code-Review","score":0,"reason":"Found 0/4 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":"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":"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":"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":"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":"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":"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":"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-18T08:00:57.702Z","repository_id":66222235,"created_at":"2025-08-18T08:00:57.702Z","updated_at":"2025-08-18T08:00:57.702Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32234529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: 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":[],"created_at":"2024-11-19T02:39:46.026Z","updated_at":"2026-04-24T17:31:53.172Z","avatar_url":"https://github.com/doesdev.png","language":"JavaScript","readme":"# ricks-bricks [![NPM version](https://badge.fury.io/js/ricks-bricks.svg)](https://npmjs.org/package/ricks-bricks)   [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)   [![Dependency Status](https://dependencyci.com/github/doesdev/ricks-bricks/badge)](https://dependencyci.com/github/doesdev/ricks-bricks)\n\n\u003e Run if happened X times within X ms and hasn't been run in X ms\n\n## What is it this?\n\nSimply put it's yet another throttling utility. Specifically, I made to restart\na server process if ECONNREFUSED is encountered by the reverse proxy beyond the\nthreshold. It has plenty of other potential uses, but more than anything I\nwanted the logic isolated and reusable. So here it is in module form.\n\n## Double you tea eff is that name 'bout brah?\n\nRun if happened X times within X seconds(ms, actually) and hasn't been run in X seconds(ms)   \n-\u003e rihxtwxsahbrixs   \n-\u003e rix-twix-sabrixs   \n-\u003e ricks-bricks   \n\n## Install\n\n```sh\n$ npm install --save ricks-bricks\n```\n\n## Usage\n\n#### Only execute callback if called with same signature count \u003e= threshold\n```js\nconst rb = require('ricks-bricks')\nconst someCb = () =\u003e console.log('oak yeah')\n\n// set the threshold\nconst rbOpts = { threshold: 3 }\n\n// call with sig 2 times, 1 less than threshold\nrb('sig', someCb, rbOpts)\nrb('sig', someCb, rbOpts)\n// call with differentSig once, doesn't trigger callback\nrb('differentSig', someCb, rbOpts)\n// call with sig a third time, now meets threshold, executes callback\nrb('sig', someCb, rbOpts)\n```\n\n#### Only execute callback if (...) within specified timeframe\n```js\nconst rb = require('ricks-bricks')\nconst ms = require('pico-ms')\nconst someCb = () =\u003e console.log('oak yeah')\nconst delay = async (d) =\u003e {\n  await new Promise((resolve, reject) =\u003e setTimeout(resolve, d))\n}\n\n// this time also we also set resetAfter\nconst rbOpts = { threshold: 3, resetAfter: ms('5sec') }\n\nasync function main () {\n// call with sig 2 times, 1 less than threshold\n  rb('sig', someCb, rbOpts)\n  rb('sig', someCb, rbOpts)\n  // wait 7 seconds\n  await delay(ms('7sec'))\n  // call with sig 3rd time, outside resetAfter, doesn't trigger callback\n  rb('sig', someCb, rbOpts)\n  // now call again once, shouldn't meet threshold\n  rb('sig', someCb, rbOpts)\n  // now call again, should meet threshold and call\n  rb('sig', someCb, rbOpts)\n}\nmain()\n```\n\n#### Only execute callback if (...) throttling calls for X ms\n```js\nconst rb = require('ricks-bricks')\nconst ms = require('pico-ms')\nconst someCb = () =\u003e console.log('oak yeah')\nconst delay = async (d) =\u003e {\n  await new Promise((resolve, reject) =\u003e setTimeout(resolve, d))\n}\n\n// this time also we also set throttle\nconst rbOpts = { threshold: 3, throttle: ms('5sec') }\n\nasync function main () {\n  // call with sig 3 times, should execute callback\n  rb('sig', someCb, rbOpts)\n  rb('sig', someCb, rbOpts)\n  rb('sig', someCb, rbOpts)\n  // call a 4th time and 5th time, it should not execute, end count should be 1\n  rb('sig', someCb, rbOpts)\n  rb('sig', someCb, rbOpts)\n  // wait 7 seconds\n  await delay(ms('7sec'))\n  // call again, should effectively be the 2nd call as far as count is concerned\n  rb('sig', someCb, rbOpts)\n  // and we call one last time, this should be 3 and trigger cb\n  rb('sig', someCb, rbOpts)\n}\nmain()\n```\n\n## API\n\n#### `rb(signature, callback, options)`\n- **signature** *(String - required)*\n  - Identifier to track\n- **callback** *(Function - required)*\n  - Function to execute when conditions met\n- **options** *(Object - optional)*\n  - **threshold** *(Number - optional)*\n    - How many times rb is called for signature before we execute callback\n  - **throttle** *(Number - milliseconds - optional)*\n    - Once callback is executed don't track until this many ms have passed\n  - **resetAfter** *(Number - milliseconds - optional)*\n    - Reset tracking once this many ms have passed since previous call\n\n#### `rb.cleanupInterval = ms`\n- **ms** *(Number - milliseconds - optional [defaults to 30000 (30secs)])*\n  - Clear stale objects from tracking object every `ms` millseconds\n\n## License\n\nMIT © [Andrew Carpenter](https://github.com/doesdev)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoesdev%2Fricks-bricks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoesdev%2Fricks-bricks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoesdev%2Fricks-bricks/lists"}