@rocketh/verifier 0.10.1

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.
@@ -0,0 +1,72 @@
1
+ // taken from package match-all
2
+ export function matchAll(s: string, r: RegExp) {
3
+ return {
4
+ input: s,
5
+ regex: r,
6
+
7
+ /**
8
+ * next
9
+ * Get the next match in single group match.
10
+ *
11
+ * @name next
12
+ * @function
13
+ * @return {String|null} The matched snippet.
14
+ */
15
+ next() {
16
+ let c = this.nextRaw();
17
+ if (c) {
18
+ for (let i = 1; i < c.length; i++) {
19
+ if (c[i]) {
20
+ return c[i];
21
+ }
22
+ }
23
+ }
24
+ return null;
25
+ },
26
+
27
+ /**
28
+ * nextRaw
29
+ * Get the next match in raw regex output. Usefull to get another group match.
30
+ *
31
+ * @name nextRaw
32
+ * @function
33
+ * @returns {Array|null} The matched snippet
34
+ */
35
+ nextRaw() {
36
+ let c = this.regex.exec(this.input);
37
+ return c;
38
+ },
39
+
40
+ /**
41
+ * toArray
42
+ * Get all the matches.
43
+ *
44
+ * @name toArray
45
+ * @function
46
+ * @return {Array} The matched snippets.
47
+ */
48
+ toArray() {
49
+ let res = [],
50
+ c = null;
51
+
52
+ while ((c = this.next())) {
53
+ res.push(c);
54
+ }
55
+
56
+ return res;
57
+ },
58
+
59
+ /**
60
+ * reset
61
+ * Reset the index.
62
+ *
63
+ * @name reset
64
+ * @function
65
+ * @param {Number} i The new index (default: `0`).
66
+ * @return {Number} The new index.
67
+ */
68
+ reset(i: number = 0) {
69
+ return (this.regex.lastIndex = i);
70
+ },
71
+ };
72
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "moduleResolution": "Node",
4
+ "lib": ["ES2020", "dom"],
5
+ "target": "ES2020",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "resolveJsonModule": true,
13
+ "module": "ES6"
14
+ }
15
+ }