@ultirequiem/six 1.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.
@@ -1,13 +1,12 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * Limit the amount of times that setInterval will fire.
4
3
  *
5
4
  * @example
6
5
  * ```javascript
7
- * import { setInterval } from "https://deno.land/x/six/mod.ts";
8
- * import { randomNumber } from "https://deno.land/x/random_number/mod.ts";
6
+ * import { setIntervalX } from "@ultirequiem/six";
7
+ * import { randomNumber } from "@ultirequiem/random-number";
9
8
  *
10
- * const API_URL = "https://leap.deno.dev";
9
+ * const API_URL = "https://example.com/api/leap";
11
10
  *
12
11
  * async function checkAPIStatus() {
13
12
  * const randomYear = randomNumber({ min: 2000, max: 10_000});
@@ -21,4 +20,5 @@
21
20
  * setIntervalX(checkAPIStatus, 2000, 15);
22
21
  * ```
23
22
  */
24
- export declare function setIntervalX(callback: (...args: any[]) => any, delay: number, repetitions: number, ...args: any[]): NodeJS.Timer;
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"}
@@ -1,13 +1,13 @@
1
- // deno-lint-ignore-file no-explicit-any
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  /**
3
3
  * Limit the amount of times that setInterval will fire.
4
4
  *
5
5
  * @example
6
6
  * ```javascript
7
- * import { setInterval } from "https://deno.land/x/six/mod.ts";
8
- * import { randomNumber } from "https://deno.land/x/random_number/mod.ts";
7
+ * import { setIntervalX } from "@ultirequiem/six";
8
+ * import { randomNumber } from "@ultirequiem/random-number";
9
9
  *
10
- * const API_URL = "https://leap.deno.dev";
10
+ * const API_URL = "https://example.com/api/leap";
11
11
  *
12
12
  * async function checkAPIStatus() {
13
13
  * const randomYear = randomNumber({ min: 2000, max: 10_000});
@@ -21,13 +21,13 @@
21
21
  * setIntervalX(checkAPIStatus, 2000, 15);
22
22
  * ```
23
23
  */
24
- export function setIntervalX(callback, delay, repetitions, ...args) {
24
+ export function setIntervalX(handler, timeout, repetitions, ...args) {
25
25
  let x = 0;
26
- const intervalID = setInterval(() => {
27
- callback(...args);
26
+ const interval = setInterval(() => {
27
+ handler(...args);
28
28
  if (++x === repetitions) {
29
- clearInterval(intervalID);
29
+ clearInterval(interval);
30
30
  }
31
- }, delay);
32
- return intervalID;
31
+ }, timeout);
32
+ return interval;
33
33
  }
package/package.json CHANGED
@@ -1,39 +1,53 @@
1
1
  {
2
- "module": "./esm/mod.js",
3
- "main": "./script/mod.js",
4
- "types": "./types/mod.d.ts",
5
2
  "name": "@ultirequiem/six",
3
+ "version": "2.0.0",
6
4
  "description": "Limit the amount of times that setInterval will fire.",
7
- "version": "1.0.0",
8
- "license": "MIT",
9
- "funding": {
10
- "type": "patreon",
11
- "url": "https://www.patreon.com/ultirequiem"
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "import": "./lib/index.js"
12
+ }
12
13
  },
13
- "repository": "github:ultirequiem/@ultirequiem/six",
14
- "homepage": "https://ulti.js.org/six",
15
- "bugs": {
16
- "url": "https://github.com/ultirequiem/@ultirequiem/six/issues",
17
- "email": "eliaz.bobadilladev@gmail.com"
14
+ "files": [
15
+ "lib/**/*"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20"
18
19
  },
19
20
  "keywords": [
20
21
  "time",
21
22
  "setInterval"
22
23
  ],
23
- "exports": {
24
- ".": {
25
- "import": "./esm/mod.js",
26
- "require": "./script/mod.js",
27
- "types": "./types/mod.d.ts"
28
- }
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
29
  },
30
30
  "scripts": {
31
- "test": "node test_runner.js"
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"
32
36
  },
33
- "dependencies": {},
34
37
  "devDependencies": {
35
- "@types/node": "16.11.26",
36
- "chalk": "4.1.2",
37
- "@deno/shim-deno": "~0.4.3"
38
- }
39
- }
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"
51
+ },
52
+ "packageManager": "pnpm@12.6.0"
53
+ }
package/readme.md ADDED
@@ -0,0 +1,50 @@
1
+ # six
2
+
3
+ [![npm](https://img.shields.io/npm/v/@ultirequiem/six?logo=npm&color=cb3837)](https://www.npmjs.com/package/@ultirequiem/six)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@ultirequiem/six?color=cb3837)](https://www.npmjs.com/package/@ultirequiem/six)
5
+ [![CI](https://github.com/UltiRequiem/six/actions/workflows/ci.yaml/badge.svg)](https://github.com/UltiRequiem/six/actions/workflows/ci.yaml)
6
+ [![codecov](https://codecov.io/gh/UltiRequiem/six/graph/badge.svg)](https://codecov.io/gh/UltiRequiem/six)
7
+
8
+ > Set Interval X
9
+
10
+ Limit the amount of times that `setInterval` will fire.
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
+
21
+ ## Usage
22
+
23
+ ESM only, types included: the same import works in Node.js, Bun and browsers.
24
+
25
+ ## Support
26
+
27
+ Open an Issue, I will check it as soon as possible 👀
28
+
29
+ If you want to hurry me up a bit
30
+ [send me a tweet](https://twitter.com/intent/tweet?text=%40UltiRequiem%20) 😆
31
+
32
+ Don't forget to star the repo ⭐
33
+
34
+ ## Versioning
35
+
36
+ We use [SemVer](http://semver.org) for versioning. For the versions available,
37
+ see the [tags](https://github.com/UltiRequiem/six/tags).
38
+
39
+ ## Authors
40
+
41
+ [Eliaz Bobadilla (a.k.a UltiRequiem)](https://ultirequiem.com) - Creator and
42
+ Maintainer 💪
43
+
44
+ See also the full list of
45
+ [contributors](https://github.com/UltiRequiem/six/contributors) who participated
46
+ in this project.
47
+
48
+ ## Licence
49
+
50
+ Released under the MIT Licence.
package/README.md DELETED
@@ -1,97 +0,0 @@
1
- # six
2
-
3
- [![CI](https://github.com/UltiRequiem/six/actions/workflows/ci.yaml/badge.svg)](https://github.com/UltiRequiem/six/actions/workflows/ci.yaml)
4
- [![codecov](https://codecov.io/gh/ultirequiem/six/branch/main/graph/badge.svg)](https://codecov.io/gh/ultirequiem/six)
5
- [![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/six/mod.ts)
6
-
7
- ![Custom badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fdep-count%2Fx%2Fsix%2Fmod.ts)
8
- ![Custom badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fupdates%2Fx%2Fsix%2Fmod.ts)
9
- [![Custom badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fsix%2Fmod.ts)](https://deno.land/x/six)
10
-
11
- > Set Interval X
12
-
13
- Limit the amount of times that `setInterval` will fire.
14
-
15
- > Made for
16
- > [this StackOverflow Question](https://stackoverflow.com/questions/2956966) 😆
17
-
18
- ## Usage
19
-
20
- ### [Deno 🚀](https://deno.land/x/six)
21
-
22
- ```javascript
23
- import { setInterval } from "https://deno.land/x/six/mod.ts";
24
- import { randomNumber } from "https://deno.land/x/random_number/mod.ts";
25
-
26
- const API_URL = "https://leap.deno.dev";
27
-
28
- async function checkAPIStatus() {
29
- const startTime = performance.now();
30
-
31
- const randomYear = randomNumber({ min: 2000, max: 10_000 });
32
-
33
- const response = await fetch(`${API_URL}/${randomYear}`);
34
-
35
- const data = await response.json();
36
-
37
- console.log(`Is ${randomYear} a leap year? ${data.leapYear}.`);
38
-
39
- const entTime = performance.now();
40
-
41
- console.log(`Request took ${(entTime - startTime) / 1000} seconds.`);
42
- }
43
-
44
- setIntervalX(checkAPIStatus, 2000, 15);
45
- ```
46
-
47
- ### [Node.js 🐢](https://www.npmjs.com/package/@ultirequiem/six)
48
-
49
- ```typescript
50
- import { setIntervalX } from "@ultirequiem/six";
51
- ```
52
-
53
- ### [Browser 🕸](https://developer.mozilla.org/en-US/docs/Glossary/Browser)
54
-
55
- You can use any [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) 🔥
56
-
57
- Eg. [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
58
- ▶ [SkyPack](https://cdn.skypack.dev/@ultirequiem/six) _/_
59
- [script tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) ▶
60
- [JSDelivr](https://cdn.jsdelivr.net/npm/@ultirequiem/six).
61
-
62
- The API is the same on all this platforms.
63
-
64
- ## API
65
-
66
- [Autogenerated Documentation](https://doc.deno.land/https://deno.land/x/six/mod.ts)
67
- 🚀
68
-
69
- ## Support
70
-
71
- Open an Issue, I will check it a soon as possible 👀
72
-
73
- If you want to hurry me up a bit
74
- [send me a tweet](https://twitter.com/intent/tweet?text=%40UltiRequiem%20) 😆
75
-
76
- Consider [supporting me on Patreon](https://patreon.com/UltiRequiem) if you like
77
- my work 🚀
78
-
79
- Don't forget to start the repo ⭐
80
-
81
- ## Versioning
82
-
83
- We use [SemVer](http://semver.org) for versioning. For the versions available,
84
- see the [tags](https://github.com/UltiRequiem/six/tags).
85
-
86
- ## Authors
87
-
88
- [Eliaz Bobadilla (a.k.a UltiRequiem)](https://ultirequiem.com) - Creator and
89
- Maintainer 💪
90
-
91
- See also the full list of
92
- [contributors](https://github.com/UltiRequiem/six/contributors) who participated
93
- in this project.
94
-
95
- ## Licence
96
-
97
- Released under the MIT Licence.
package/esm/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
package/script/mod.js DELETED
@@ -1,37 +0,0 @@
1
- "use strict";
2
- // deno-lint-ignore-file no-explicit-any
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.setIntervalX = void 0;
5
- /**
6
- * Limit the amount of times that setInterval will fire.
7
- *
8
- * @example
9
- * ```javascript
10
- * import { setInterval } from "https://deno.land/x/six/mod.ts";
11
- * import { randomNumber } from "https://deno.land/x/random_number/mod.ts";
12
- *
13
- * const API_URL = "https://leap.deno.dev";
14
- *
15
- * async function checkAPIStatus() {
16
- * const randomYear = randomNumber({ min: 2000, max: 10_000});
17
- *
18
- * const response = await fetch(`${API_URL}/${randomYear}`);
19
- * const data = await response.json();
20
- *
21
- * console.log(`Is ${randomYear} a leap year? ${data.leapYear}.`);
22
- * }
23
- *
24
- * setIntervalX(checkAPIStatus, 2000, 15);
25
- * ```
26
- */
27
- function setIntervalX(callback, delay, repetitions, ...args) {
28
- let x = 0;
29
- const intervalID = setInterval(() => {
30
- callback(...args);
31
- if (++x === repetitions) {
32
- clearInterval(intervalID);
33
- }
34
- }, delay);
35
- return intervalID;
36
- }
37
- exports.setIntervalX = setIntervalX;
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
File without changes