{"id":22092234,"url":"https://github.com/pirxpilot/guard","last_synced_at":"2025-03-23T23:45:35.683Z","repository":{"id":5978859,"uuid":"7200925","full_name":"pirxpilot/guard","owner":"pirxpilot","description":"Trivial guard: triggers callback when internal counter reaches 0.","archived":false,"fork":false,"pushed_at":"2022-06-05T07:52:58.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-29T06:53:04.454Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/pirxpilot.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-17T07:20:27.000Z","updated_at":"2017-02-23T08:44:18.000Z","dependencies_parsed_at":"2022-07-21T13:49:07.702Z","dependency_job_id":null,"html_url":"https://github.com/pirxpilot/guard","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirxpilot%2Fguard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirxpilot%2Fguard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirxpilot%2Fguard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pirxpilot%2Fguard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pirxpilot","download_url":"https://codeload.github.com/pirxpilot/guard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245186927,"owners_count":20574554,"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-12-01T03:08:47.919Z","updated_at":"2025-03-23T23:45:35.661Z","avatar_url":"https://github.com/pirxpilot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://secure.travis-ci.org/code42day/guard.png)](http://travis-ci.org/code42day/guard)\n[![NPM version](https://badge.fury.io/js/guard.png)](http://badge.fury.io/js/guard)\n\n# guard \n\nTrivial guard: triggers callback when internal counter reaches 0.\n\n## API\n\nCreate ```guard``` passing callback function. Call ```on()``` and ```off()``` to increase and\ndecrease internal counter.\n\n    g = guard(function() {\n      console.log('Done...')\n    });\n    g.on();\n    g.on();\n    g.off();\n    g.off(); // prints 'Done...'\n\nYou can initialize the counter when creating a new guard.\n\n    g = guard(function() {\n      console.log('Done...')\n    }, 2);\n    g.on();\n    // call off 3 times\n    g.off();\n    g.off();\n    g.off(); // prints 'Done...'\n\n\nIn addition to `done` callback you can setup callbacks when counter reaches a certain value during\n`on` or `off`\n\n    g = guard()\n      .onCallback(100, function() {\n        // called when internal counter is 100 after increment\n      })\n      .offCallback(10, function() {\n        // called when internal counter is 10 after decrement\n      });\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirxpilot%2Fguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpirxpilot%2Fguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpirxpilot%2Fguard/lists"}