@ultirequiem/six 0.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +24 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +33 -0
- package/license.md +21 -0
- package/package.json +42 -21
- package/readme.md +29 -15
- package/esm/mod.js +0 -11
- package/esm/package.json +0 -3
- package/license +0 -21
- package/types/mod.d.ts +0 -2
- package/umd/mod.js +0 -24
- package/umd/package.json +0 -3
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Limit the amount of times that setInterval will fire.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```javascript
|
|
6
|
+
* import { setIntervalX } from "@ultirequiem/six";
|
|
7
|
+
* import { randomNumber } from "@ultirequiem/random-number";
|
|
8
|
+
*
|
|
9
|
+
* const API_URL = "https://example.com/api/leap";
|
|
10
|
+
*
|
|
11
|
+
* async function checkAPIStatus() {
|
|
12
|
+
* const randomYear = randomNumber({ min: 2000, max: 10_000});
|
|
13
|
+
*
|
|
14
|
+
* const response = await fetch(`${API_URL}/${randomYear}`);
|
|
15
|
+
* const data = await response.json();
|
|
16
|
+
*
|
|
17
|
+
* console.log(`Is ${randomYear} a leap year? ${data.leapYear}.`);
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* setIntervalX(checkAPIStatus, 2000, 15);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function setIntervalX(handler: (...args: any[]) => any, timeout: number, repetitions: number, ...args: any[]): NodeJS.Timeout;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAChC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,GAAG,IAAI,EAAE,GAAG,EAAE,kBAaf"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/**
|
|
3
|
+
* Limit the amount of times that setInterval will fire.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```javascript
|
|
7
|
+
* import { setIntervalX } from "@ultirequiem/six";
|
|
8
|
+
* import { randomNumber } from "@ultirequiem/random-number";
|
|
9
|
+
*
|
|
10
|
+
* const API_URL = "https://example.com/api/leap";
|
|
11
|
+
*
|
|
12
|
+
* async function checkAPIStatus() {
|
|
13
|
+
* const randomYear = randomNumber({ min: 2000, max: 10_000});
|
|
14
|
+
*
|
|
15
|
+
* const response = await fetch(`${API_URL}/${randomYear}`);
|
|
16
|
+
* const data = await response.json();
|
|
17
|
+
*
|
|
18
|
+
* console.log(`Is ${randomYear} a leap year? ${data.leapYear}.`);
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* setIntervalX(checkAPIStatus, 2000, 15);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function setIntervalX(handler, timeout, repetitions, ...args) {
|
|
25
|
+
let x = 0;
|
|
26
|
+
const interval = setInterval(() => {
|
|
27
|
+
handler(...args);
|
|
28
|
+
if (++x === repetitions) {
|
|
29
|
+
clearInterval(interval);
|
|
30
|
+
}
|
|
31
|
+
}, timeout);
|
|
32
|
+
return interval;
|
|
33
|
+
}
|
package/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Eliaz Bobadilla <eliaz.bobadilla@gmail.com>
|
|
4
|
+
(https://ultirequiem.com)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
the Software without restriction, including without limitation the rights to
|
|
9
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
{
|
|
2
|
-
"module": "./esm/mod.js",
|
|
3
|
-
"main": "./umd/mod.js",
|
|
4
|
-
"types": "./types/mod.d.ts",
|
|
5
2
|
"name": "@ultirequiem/six",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/ultirequiem/six/issues"
|
|
14
|
-
},
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Limit the amount of times that setInterval will fire.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
15
8
|
"exports": {
|
|
16
9
|
".": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"types": "./types/mod.d.ts"
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"import": "./lib/index.js"
|
|
20
12
|
}
|
|
21
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"lib/**/*"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"time",
|
|
22
|
+
"setInterval"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"homepage": "https://ulti.js.org/six",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/UltiRequiem/six.git"
|
|
29
|
+
},
|
|
22
30
|
"scripts": {
|
|
23
|
-
"
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"lint": "eslint 'src/**/*.ts' && prettier --check 'src/**/*.ts'",
|
|
33
|
+
"fmt": "prettier --write 'src/**/*.ts'",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:coverage": "vitest run --coverage"
|
|
24
36
|
},
|
|
25
|
-
"dependencies": {},
|
|
26
37
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"
|
|
38
|
+
"@types/node": "^26.6.5",
|
|
39
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
40
|
+
"eslint": "^10.13.0",
|
|
41
|
+
"eslint-plugin-tsdoc": "^0.5.4",
|
|
42
|
+
"eslint-plugin-unicorn": "^78.0.0",
|
|
43
|
+
"prettier": "^3.9.10",
|
|
44
|
+
"typescript": "^6.0.3",
|
|
45
|
+
"typescript-eslint": "^8.72.0",
|
|
46
|
+
"vitest": "^5.0.5"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@ultirequiem/random-number": "^2.0.0",
|
|
50
|
+
"@ultirequiem/six": "^1.0.0"
|
|
30
51
|
},
|
|
31
|
-
"
|
|
52
|
+
"packageManager": "pnpm@12.6.0"
|
|
32
53
|
}
|
package/readme.md
CHANGED
|
@@ -1,35 +1,49 @@
|
|
|
1
1
|
# six
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@ultirequiem/six)
|
|
4
|
+
[](https://www.npmjs.com/package/@ultirequiem/six)
|
|
5
|
+
[](https://github.com/UltiRequiem/six/actions/workflows/ci.yaml)
|
|
6
|
+
[](https://codecov.io/gh/UltiRequiem/six)
|
|
7
|
+
|
|
3
8
|
> Set Interval X
|
|
4
9
|
|
|
5
10
|
Limit the amount of times that `setInterval` will fire.
|
|
6
11
|
|
|
12
|
+
> Made for
|
|
13
|
+
> [this StackOverflow Question](https://stackoverflow.com/questions/2956966) 😆
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @ultirequiem/six
|
|
19
|
+
```
|
|
20
|
+
|
|
7
21
|
## Usage
|
|
8
22
|
|
|
9
|
-
|
|
10
|
-
import setIntervalX from "https://deno.land/x/six/mod.ts";
|
|
11
|
-
import randomNumber from "https://deno.land/x/random_number/mod.ts";
|
|
23
|
+
ESM only, types included: the same import works in Node.js, Bun and browsers.
|
|
12
24
|
|
|
13
|
-
|
|
25
|
+
## Support
|
|
14
26
|
|
|
15
|
-
|
|
16
|
-
const startTime = performance.now();
|
|
27
|
+
Open an Issue, I will check it as soon as possible 👀
|
|
17
28
|
|
|
18
|
-
|
|
29
|
+
If you want to hurry me up a bit
|
|
30
|
+
[send me a tweet](https://twitter.com/intent/tweet?text=%40UltiRequiem%20) 😆
|
|
19
31
|
|
|
20
|
-
|
|
32
|
+
Don't forget to star the repo ⭐
|
|
21
33
|
|
|
22
|
-
|
|
34
|
+
## Versioning
|
|
23
35
|
|
|
24
|
-
|
|
36
|
+
We use [SemVer](http://semver.org) for versioning. For the versions available,
|
|
37
|
+
see the [tags](https://github.com/UltiRequiem/six/tags).
|
|
25
38
|
|
|
26
|
-
|
|
39
|
+
## Authors
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
[Eliaz Bobadilla (a.k.a UltiRequiem)](https://ultirequiem.com) - Creator and
|
|
42
|
+
Maintainer 💪
|
|
30
43
|
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
See also the full list of
|
|
45
|
+
[contributors](https://github.com/UltiRequiem/six/contributors) who participated
|
|
46
|
+
in this project.
|
|
33
47
|
|
|
34
48
|
## Licence
|
|
35
49
|
|
package/esm/mod.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// deno-lint-ignore-file no-explicit-any
|
|
2
|
-
export default function setIntervalX(callback, delay, repetitions, ...args) {
|
|
3
|
-
let x = 0;
|
|
4
|
-
const intervalID = setInterval(() => {
|
|
5
|
-
callback(...args);
|
|
6
|
-
if (++x === repetitions) {
|
|
7
|
-
clearInterval(intervalID);
|
|
8
|
-
}
|
|
9
|
-
}, delay);
|
|
10
|
-
return intervalID;
|
|
11
|
-
}
|
package/esm/package.json
DELETED
package/license
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Eliaz Bobadilla (a.k.a UltiRequiem)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/types/mod.d.ts
DELETED
package/umd/mod.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// deno-lint-ignore-file no-explicit-any
|
|
2
|
-
(function (factory) {
|
|
3
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
4
|
-
var v = factory(require, exports);
|
|
5
|
-
if (v !== undefined) module.exports = v;
|
|
6
|
-
}
|
|
7
|
-
else if (typeof define === "function" && define.amd) {
|
|
8
|
-
define(["require", "exports"], factory);
|
|
9
|
-
}
|
|
10
|
-
})(function (require, exports) {
|
|
11
|
-
"use strict";
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
function setIntervalX(callback, delay, repetitions, ...args) {
|
|
14
|
-
let x = 0;
|
|
15
|
-
const intervalID = setInterval(() => {
|
|
16
|
-
callback(...args);
|
|
17
|
-
if (++x === repetitions) {
|
|
18
|
-
clearInterval(intervalID);
|
|
19
|
-
}
|
|
20
|
-
}, delay);
|
|
21
|
-
return intervalID;
|
|
22
|
-
}
|
|
23
|
-
exports.default = setIntervalX;
|
|
24
|
-
});
|
package/umd/package.json
DELETED