@javascript-utilities/guarded-set-interval
v0.0.2
Published
Set interval wrapper with re-entry guard
Downloads
1
Maintainers
Readme
Guarded Set Interval
Set interval wrapper with re-entry guard, I.E. if a callback takes longer than defined interval it'll skip execution for a tick or few.
- :arrow_up: Top of Document
- :building_construction: Requirements
- :zap: Quick Start
- 藺 Usage
- Notes
- :chart_with_upwards_trend: Contributing
- :card_index: Attribution
- :balance_scale: Licensing
Requirements
NodeJS dependencies may be installed via NPM...
npm install @javascript-utilities/guarded-set-interval
Quick Start
Clone this project...
Linux/MacOS
mkdir -vp ~/git/hub/javascript-utilities
cd ~/git/hub/javascript-utilities
git clone [email protected]:javascript-utilities/guarded-set-interval.git
Usage
import { Guarded_Set_Interval } from '@javascript-utilities/guarded-set-interval';
const shared_state = { callback_count: 0 };
const callback = {
next: (...args) => {
console.log('callback args:', args);
shared_state.count++;
if (shared_state.count > 3) {
return { done: true, value: shared_state.count };
}
return { done: false, value: shared_state.count };
}
};
const interval = new Guarded_Set_Interval({
callback,
args: ['foo', 'bar'],
milliseconds: 1000,
verbose: true,
});
interval.start();
// ... Do other stuff...
interval.stop();
Notes
This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.
Contributing
Options for contributing to guarded-set-interval and javascript-utilities
Forking
:warning: Creating fork(s), submitting contribution(s), publishing derivative work(s), etc. based on this repository will form an agreement to be bound by the use-cased based licensing sub-sections.
I.E. if you choose to contribute to or use this project, you acknowledge and accept these usage based licensing terms will apply to any such works too.
Start making a Fork of this repository to an account that you have write permissions for.
- Add remote for fork URL. The URL syntax is
[email protected]:<NAME>/<REPO>.git
...
cd ~/git/hub/javascript-utilities/guarded-set-interval
git remote add fork [email protected]:<NAME>/guarded-set-interval.git
- Commit your changes and push to your fork, eg. to fix an issue...
cd ~/git/hub/javascript-utilities/guarded-set-interval
git commit -F- <<'EOF'
:bug: Fixes #42 Issue
**Edits**
- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF
git push fork main
Note, the
-u
option may be used to setfork
as the default remote, eg.git push -u fork main
however, this will also default thefork
remote for pulling from too! Meaning that pulling updates fromorigin
must be done explicitly, eg.git pull origin main
- Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is
https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>
Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.
Sponsor
Thanks for even considering it!
Via Liberapay you may on a repeating basis.
Regardless of if you're able to financially support projects such as guarded-set-interval that javascript-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.
Attribution
License
This project is licensed based on use-case
Commercial and/or proprietary use
If a project is either commercial or (||
) proprietary, then please
contact the author for pricing and licensing options to make use of code and/or
features from this repository.
Non-commercial and FOSS use
If a project is both non-commercial and (&&
) published with a license
compatible with AGPL-3.0, then it may utilize code from this repository under
the following terms.
Set interval wrapper with re-entry guard
Copyright (C) 2024 S0AndS0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For further details review full length version of AGPL-3.0 License.