@ultirequiem/six 0.0.0 → 1.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/LICENSE 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/README.md ADDED
@@ -0,0 +1,97 @@
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/mod.js CHANGED
@@ -1,5 +1,27 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- export default function setIntervalX(callback, delay, repetitions, ...args) {
2
+ /**
3
+ * Limit the amount of times that setInterval will fire.
4
+ *
5
+ * @example
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";
9
+ *
10
+ * const API_URL = "https://leap.deno.dev";
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(callback, delay, repetitions, ...args) {
3
25
  let x = 0;
4
26
  const intervalID = setInterval(() => {
5
27
  callback(...args);
package/package.json CHANGED
@@ -1,21 +1,29 @@
1
1
  {
2
2
  "module": "./esm/mod.js",
3
- "main": "./umd/mod.js",
3
+ "main": "./script/mod.js",
4
4
  "types": "./types/mod.d.ts",
5
5
  "name": "@ultirequiem/six",
6
- "description": "Limit the amount of times that setInterval will fire",
6
+ "description": "Limit the amount of times that setInterval will fire.",
7
+ "version": "1.0.0",
7
8
  "license": "MIT",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/ultirequiem/six.git"
9
+ "funding": {
10
+ "type": "patreon",
11
+ "url": "https://www.patreon.com/ultirequiem"
11
12
  },
13
+ "repository": "github:ultirequiem/@ultirequiem/six",
14
+ "homepage": "https://ulti.js.org/six",
12
15
  "bugs": {
13
- "url": "https://github.com/ultirequiem/six/issues"
16
+ "url": "https://github.com/ultirequiem/@ultirequiem/six/issues",
17
+ "email": "eliaz.bobadilladev@gmail.com"
14
18
  },
19
+ "keywords": [
20
+ "time",
21
+ "setInterval"
22
+ ],
15
23
  "exports": {
16
24
  ".": {
17
25
  "import": "./esm/mod.js",
18
- "require": "./umd/mod.js",
26
+ "require": "./script/mod.js",
19
27
  "types": "./types/mod.d.ts"
20
28
  }
21
29
  },
@@ -24,9 +32,8 @@
24
32
  },
25
33
  "dependencies": {},
26
34
  "devDependencies": {
27
- "@deno/shim-deno": "~0.1.1",
28
- "@types/node": "16.11.1",
29
- "chalk": "4.1.2"
30
- },
31
- "version": "0.0.0"
32
- }
35
+ "@types/node": "16.11.26",
36
+ "chalk": "4.1.2",
37
+ "@deno/shim-deno": "~0.4.3"
38
+ }
39
+ }
package/script/mod.js ADDED
@@ -0,0 +1,37 @@
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;
File without changes
package/types/mod.d.ts CHANGED
@@ -1,2 +1,24 @@
1
1
  /// <reference types="node" />
2
- export default function setIntervalX(callback: (...args: any[]) => any, delay: number, repetitions: number, ...args: any[]): NodeJS.Timer;
2
+ /**
3
+ * Limit the amount of times that setInterval will fire.
4
+ *
5
+ * @example
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";
9
+ *
10
+ * const API_URL = "https://leap.deno.dev";
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 declare function setIntervalX(callback: (...args: any[]) => any, delay: number, repetitions: number, ...args: any[]): NodeJS.Timer;
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/readme.md DELETED
@@ -1,36 +0,0 @@
1
- # six
2
-
3
- > Set Interval X
4
-
5
- Limit the amount of times that `setInterval` will fire.
6
-
7
- ## Usage
8
-
9
- ```typescript
10
- import setIntervalX 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-year.ultirequiem.repl.co";
14
-
15
- async function checkAPIStatus() {
16
- const startTime = performance.now();
17
-
18
- const randomYear = randomNumber({ min: 2000, max: 10_000, integer: true });
19
-
20
- const response = await fetch(`${API_URL}/${randomYear}`);
21
-
22
- const data = await response.json();
23
-
24
- console.log(`Is ${randomYear} a leap year? ${data.leapYear}.`);
25
-
26
- const entTime = performance.now();
27
-
28
- console.log(`Request took ${(entTime - startTime) / 1000} seconds.`);
29
- }
30
-
31
- setIntervalX(checkAPIStatus, 2000, 15);
32
- ```
33
-
34
- ## Licence
35
-
36
- Released under the MIT Licence.
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
- });