@isopodlabs/utilities 1.5.6 → 1.5.8
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/dist/bits.d.ts +39 -10
- package/dist/bits.js +15 -3
- package/package.json +1 -1
- package/dist/regex.d.ts +0 -103
- package/dist/regex.js +0 -1044
- package/dist/regexp.d.ts +0 -90
- package/dist/regexp.js +0 -659
- package/dist/utils.d.ts +0 -28
- package/dist/utils.js +0 -98
package/dist/bits.d.ts
CHANGED
|
@@ -7,7 +7,33 @@ export declare function countSet(x: bigint | number): number;
|
|
|
7
7
|
export declare function highestClear(x: number | bigint): number;
|
|
8
8
|
export declare function lowestClear(x: number | bigint): number;
|
|
9
9
|
export declare function countClear(x: bigint | number): number;
|
|
10
|
-
export
|
|
10
|
+
export interface immutableBitSet {
|
|
11
|
+
countSet(): number;
|
|
12
|
+
complement(): this;
|
|
13
|
+
intersect(other: this): this;
|
|
14
|
+
union(other: this): this;
|
|
15
|
+
xor(other: this): this;
|
|
16
|
+
contains(other: this): boolean;
|
|
17
|
+
test(a: number): boolean;
|
|
18
|
+
next(a: number, set: boolean): number;
|
|
19
|
+
where(set: boolean, from?: number): {
|
|
20
|
+
[Symbol.iterator](): Generator<number>;
|
|
21
|
+
};
|
|
22
|
+
ranges(): {
|
|
23
|
+
[Symbol.iterator](): Generator<number[]>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface BitSet extends immutableBitSet {
|
|
27
|
+
set(a: number): void;
|
|
28
|
+
clear(a: number): void;
|
|
29
|
+
setRange(a: number, b: number): this;
|
|
30
|
+
clearRange(a: number, b: number): this;
|
|
31
|
+
selfComplement(): this;
|
|
32
|
+
selfIntersect(other: this): this;
|
|
33
|
+
selfUnion(other: this): this;
|
|
34
|
+
selfXor(other: this): this;
|
|
35
|
+
}
|
|
36
|
+
export declare class ImmutableSparseBits implements immutableBitSet {
|
|
11
37
|
protected bits: number[];
|
|
12
38
|
protected undef: number;
|
|
13
39
|
static whereGenerator(bits: number[], undef: number, set: boolean, from?: number): Generator<number>;
|
|
@@ -24,7 +50,8 @@ export declare class ImmutableSparseBits {
|
|
|
24
50
|
xor(other: ImmutableSparseBits): this;
|
|
25
51
|
clean(): this;
|
|
26
52
|
contains(other: ImmutableSparseBits): boolean;
|
|
27
|
-
|
|
53
|
+
test(a: number): boolean;
|
|
54
|
+
countSet(): number;
|
|
28
55
|
next(a: number, set?: boolean): number;
|
|
29
56
|
toDense(): DenseBits;
|
|
30
57
|
where(set: boolean, from?: number): {
|
|
@@ -35,7 +62,7 @@ export declare class ImmutableSparseBits {
|
|
|
35
62
|
};
|
|
36
63
|
[Symbol.iterator](): Generator<number>;
|
|
37
64
|
}
|
|
38
|
-
export declare class SparseBits extends ImmutableSparseBits {
|
|
65
|
+
export declare class SparseBits extends ImmutableSparseBits implements BitSet {
|
|
39
66
|
private setMask;
|
|
40
67
|
private clearMask;
|
|
41
68
|
selfComplement(): this;
|
|
@@ -44,20 +71,22 @@ export declare class SparseBits extends ImmutableSparseBits {
|
|
|
44
71
|
selfXor(other: SparseBits): this;
|
|
45
72
|
set(a: number): void;
|
|
46
73
|
clear(a: number): void;
|
|
47
|
-
|
|
74
|
+
test(a: number): boolean;
|
|
48
75
|
setRange(a: number, b: number): this;
|
|
49
76
|
clearRange(a: number, b: number): this;
|
|
50
77
|
}
|
|
51
|
-
export declare class ImmutableDenseBits {
|
|
78
|
+
export declare class ImmutableDenseBits implements immutableBitSet {
|
|
52
79
|
protected bits: bigint;
|
|
53
80
|
constructor(bits?: bigint);
|
|
54
81
|
protected create(bits?: bigint): this;
|
|
55
82
|
complement(): this;
|
|
56
|
-
intersect(other:
|
|
57
|
-
union(other:
|
|
58
|
-
xor(other:
|
|
59
|
-
|
|
83
|
+
intersect(other: ImmutableDenseBits): this;
|
|
84
|
+
union(other: ImmutableDenseBits): this;
|
|
85
|
+
xor(other: ImmutableDenseBits): this;
|
|
86
|
+
test(a: number): boolean;
|
|
87
|
+
contains(other: this): boolean;
|
|
60
88
|
next(a: number, set?: boolean): number;
|
|
89
|
+
countSet(): number;
|
|
61
90
|
get length(): number;
|
|
62
91
|
where(set: boolean, from?: number): {
|
|
63
92
|
[Symbol.iterator](): Generator<number>;
|
|
@@ -68,7 +97,7 @@ export declare class ImmutableDenseBits {
|
|
|
68
97
|
[Symbol.iterator](): Generator<number>;
|
|
69
98
|
toSparse(): SparseBits;
|
|
70
99
|
}
|
|
71
|
-
export declare class DenseBits extends ImmutableDenseBits {
|
|
100
|
+
export declare class DenseBits extends ImmutableDenseBits implements BitSet {
|
|
72
101
|
private setMask;
|
|
73
102
|
private clearMask;
|
|
74
103
|
selfComplement(): this;
|
package/dist/bits.js
CHANGED
|
@@ -278,9 +278,15 @@ class ImmutableSparseBits {
|
|
|
278
278
|
}
|
|
279
279
|
return true;
|
|
280
280
|
}
|
|
281
|
-
|
|
281
|
+
test(a) {
|
|
282
282
|
return !!((this.bits[a >> 5] ?? this.undef) & (1 << (a & 0x1f)));
|
|
283
283
|
}
|
|
284
|
+
countSet() {
|
|
285
|
+
let count = 0;
|
|
286
|
+
for (const i in this.bits)
|
|
287
|
+
count += countSet32(this.bits[i]);
|
|
288
|
+
return count;
|
|
289
|
+
}
|
|
284
290
|
next(a, set = true) {
|
|
285
291
|
++a;
|
|
286
292
|
const xor = this.undef;
|
|
@@ -429,7 +435,7 @@ class SparseBits extends ImmutableSparseBits {
|
|
|
429
435
|
clear(a) {
|
|
430
436
|
this.clearMask(a >> 5, 1 << (a & 0x1f));
|
|
431
437
|
}
|
|
432
|
-
|
|
438
|
+
test(a) {
|
|
433
439
|
const i = a >> 5;
|
|
434
440
|
return !!((this.bits[i] ?? this.undef) & (1 << (a & 0x1f)));
|
|
435
441
|
}
|
|
@@ -497,14 +503,20 @@ class ImmutableDenseBits {
|
|
|
497
503
|
xor(other) {
|
|
498
504
|
return this.create(this.bits ^ other.bits);
|
|
499
505
|
}
|
|
500
|
-
|
|
506
|
+
test(a) {
|
|
501
507
|
return !!(this.bits & (1n << BigInt(a)));
|
|
502
508
|
}
|
|
509
|
+
contains(other) {
|
|
510
|
+
return (this.bits & other.bits) === other.bits;
|
|
511
|
+
}
|
|
503
512
|
next(a, set = true) {
|
|
504
513
|
let s = this.bits >> BigInt(a + 1);
|
|
505
514
|
s = set ? s & -s : (s + 1n) & ~s;
|
|
506
515
|
return s ? a + highestSet(s) : -1;
|
|
507
516
|
}
|
|
517
|
+
countSet() {
|
|
518
|
+
return countSet(this.bits);
|
|
519
|
+
}
|
|
508
520
|
get length() {
|
|
509
521
|
return highestSet(this.bits);
|
|
510
522
|
}
|
package/package.json
CHANGED
package/dist/regex.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { SparseBits } from "./bits";
|
|
2
|
-
export declare class characterClass extends SparseBits {
|
|
3
|
-
type: 'class';
|
|
4
|
-
test(char: string): boolean;
|
|
5
|
-
mutable(): MutablecharacterClass;
|
|
6
|
-
isNegated(): boolean;
|
|
7
|
-
toString(): string;
|
|
8
|
-
}
|
|
9
|
-
declare class MutablecharacterClass extends characterClass {
|
|
10
|
-
setChar(char: string): void;
|
|
11
|
-
setString(c: string): this;
|
|
12
|
-
clearString(c: string): this;
|
|
13
|
-
}
|
|
14
|
-
export declare function range(from: string, to: string): MutablecharacterClass;
|
|
15
|
-
export declare function chars(chars: string): MutablecharacterClass;
|
|
16
|
-
export declare function union(...classes: characterClass[]): MutablecharacterClass;
|
|
17
|
-
export declare const any: characterClass;
|
|
18
|
-
export declare const digit: characterClass;
|
|
19
|
-
export declare const lower: characterClass;
|
|
20
|
-
export declare const upper: characterClass;
|
|
21
|
-
export declare const alpha: characterClass;
|
|
22
|
-
export declare const alnum: characterClass;
|
|
23
|
-
export declare const word: characterClass;
|
|
24
|
-
export declare const whitespace: characterClass;
|
|
25
|
-
export declare const hex: characterClass;
|
|
26
|
-
export declare const octal: characterClass;
|
|
27
|
-
export declare function text(c: string): string;
|
|
28
|
-
export declare function concatenation(parts: part[]): part[] | part;
|
|
29
|
-
interface alternation {
|
|
30
|
-
type: 'alt';
|
|
31
|
-
parts: part[];
|
|
32
|
-
}
|
|
33
|
-
export declare function alternation(parts: part[]): alternation | part;
|
|
34
|
-
type noncaptureOptions = 'ahead' | 'behind' | 'neg_ahead' | 'neg_behind' | 'atomic' | {
|
|
35
|
-
i?: boolean;
|
|
36
|
-
m?: boolean;
|
|
37
|
-
s?: boolean;
|
|
38
|
-
};
|
|
39
|
-
interface noncapture {
|
|
40
|
-
type: 'noncapture';
|
|
41
|
-
part: part;
|
|
42
|
-
options?: noncaptureOptions;
|
|
43
|
-
}
|
|
44
|
-
export declare function noncapture(part: part, options?: noncaptureOptions): noncapture;
|
|
45
|
-
export declare function lookAhead(part: part): noncapture;
|
|
46
|
-
export declare function negLookAhead(part: part): noncapture;
|
|
47
|
-
export declare function lookBehind(part: part): noncapture;
|
|
48
|
-
export declare function negLookBehind(part: part): noncapture;
|
|
49
|
-
interface capture {
|
|
50
|
-
type: 'capture';
|
|
51
|
-
name?: string;
|
|
52
|
-
part: part;
|
|
53
|
-
}
|
|
54
|
-
export declare function capture(part: part, name?: string): capture;
|
|
55
|
-
type quantifiedMod = 'greedy' | 'lazy' | 'possessive';
|
|
56
|
-
interface quantified {
|
|
57
|
-
type: 'quantified';
|
|
58
|
-
part: part;
|
|
59
|
-
min: number;
|
|
60
|
-
max: number;
|
|
61
|
-
mod: quantifiedMod;
|
|
62
|
-
}
|
|
63
|
-
export declare function repeatFrom(part: part, min: number, max?: number, mod?: quantifiedMod): quantified;
|
|
64
|
-
export declare function repeat(part: part, n: number, mod?: quantifiedMod): quantified;
|
|
65
|
-
export declare function zeroOrMore(part: part, mod?: quantifiedMod): quantified;
|
|
66
|
-
export declare function oneOrMore(part: part, mod?: quantifiedMod): quantified;
|
|
67
|
-
export declare function optional(part: part, mod?: quantifiedMod): quantified;
|
|
68
|
-
interface boundary {
|
|
69
|
-
type: 'wordbound' | 'nowordbound' | 'inputboundstart' | 'inputboundend';
|
|
70
|
-
}
|
|
71
|
-
export declare function boundary(type: boundary['type']): boundary;
|
|
72
|
-
export declare const wordBoundary: boundary;
|
|
73
|
-
export declare const nonWordBoundary: boundary;
|
|
74
|
-
export declare const startAnchor: boundary;
|
|
75
|
-
export declare const endAnchor: boundary;
|
|
76
|
-
interface reference {
|
|
77
|
-
type: 'reference';
|
|
78
|
-
value: number | string;
|
|
79
|
-
}
|
|
80
|
-
export declare function reference(value: number | string): reference;
|
|
81
|
-
export declare function anchored(part: part): part;
|
|
82
|
-
interface unicode {
|
|
83
|
-
type: 'unicode' | 'notunicode';
|
|
84
|
-
property: string;
|
|
85
|
-
}
|
|
86
|
-
type _part = alternation | noncapture | capture | characterClass | unicode | quantified | boundary | reference;
|
|
87
|
-
type part = string | part[] | _part;
|
|
88
|
-
export declare function parse(re: string, unicode?: boolean, extended?: boolean): part;
|
|
89
|
-
export declare function toRegExpString(part: part): string;
|
|
90
|
-
export declare function toRegExp(part: part, flags?: string): RegExp;
|
|
91
|
-
export declare function optimize(part: part): part;
|
|
92
|
-
interface DFAState {
|
|
93
|
-
nfaStates: Set<number>;
|
|
94
|
-
transitions: Map<string, DFAState>;
|
|
95
|
-
isAccepting: boolean;
|
|
96
|
-
}
|
|
97
|
-
export declare function runDFA(dfa: DFAState, str: string): boolean;
|
|
98
|
-
export declare function regexToDFA(part: part): DFAState;
|
|
99
|
-
export declare function parseGlob(glob: string): string;
|
|
100
|
-
export declare function anchoredRe(re: string): RegExp;
|
|
101
|
-
export declare function globToRe(glob: string): RegExp;
|
|
102
|
-
export declare function globToReMulti(globs: string[]): RegExp;
|
|
103
|
-
export {};
|