necessary 13.0.9 → 13.0.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scratch.js +39 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "necessary",
3
3
  "author": "James Smith",
4
- "version": "13.0.9",
4
+ "version": "13.0.10",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/necessary",
7
7
  "description": "A collection of utility functions.",
package/scratch.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ function substring(string, start, end = Infinity) {
4
+ let index = 0;
5
+
6
+ const iterator = string[Symbol.iterator](),
7
+ characters = [];
8
+
9
+ let character = iterator.next();
10
+
11
+ while (!character.done) {
12
+ if (index === end) {
13
+ break;
14
+ }
15
+
16
+ if (index >= start) {
17
+ characters.push(character.value); ///
18
+ }
19
+
20
+ character = iterator.next();
21
+
22
+ index++
23
+ }
24
+
25
+ const substring = characters.join("");
26
+
27
+ return substring;
28
+ }
29
+
30
+ const then = Date.now()
31
+
32
+ for (let count = 0; count < 1000000; count++) {
33
+ substring("ℝℚℤℕ 0123456789 ℝℚℤℕℝℚℤℕ 0123456789 ℝℚℤℕℝℚℤℕ 0123456789 ℝℚℤℕ", 13, 16)
34
+ }
35
+
36
+ const now = Date.now();
37
+
38
+ console.log(now - then);
39
+