@thi.ng/dsp 4.6.16 → 4.6.18
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/CHANGELOG.md +1 -1
- package/README.md +1 -1
- package/add.js +24 -38
- package/addg.js +4 -19
- package/adsr.js +148 -156
- package/agen.js +17 -21
- package/allpass.js +37 -38
- package/alt.js +26 -22
- package/anti-alias.js +8 -37
- package/api.js +0 -1
- package/aproc.js +24 -30
- package/biquad.js +188 -184
- package/bounce.js +15 -16
- package/complex.js +4 -1
- package/const.js +12 -13
- package/convert.js +18 -64
- package/cosine.js +43 -48
- package/curve.js +12 -41
- package/dcblock.js +9 -10
- package/delay.js +100 -111
- package/feedback-delay.js +23 -30
- package/fft.js +188 -334
- package/filter-delay.js +23 -27
- package/filter-response.js +22 -33
- package/foldback.js +26 -35
- package/impulse-train.js +35 -37
- package/impulse.js +27 -42
- package/integrator.js +27 -32
- package/internal/ensure.js +4 -1
- package/internal/take.js +8 -5
- package/iterable.js +32 -43
- package/line.js +10 -25
- package/madd.js +25 -40
- package/mapg.js +77 -69
- package/merge.js +18 -20
- package/mix.js +20 -16
- package/mul.js +24 -38
- package/multiplex.js +15 -11
- package/onepole.js +41 -42
- package/osc-additive.js +25 -53
- package/osc-cos.js +4 -1
- package/osc-dsf.js +15 -52
- package/osc-mix.js +6 -20
- package/osc-parabolic.js +4 -13
- package/osc-rect.js +6 -8
- package/osc-saw.js +4 -1
- package/osc-sin.js +4 -1
- package/osc-tri.js +4 -1
- package/osc-wavetable.js +12 -9
- package/osc.js +40 -74
- package/package.json +13 -10
- package/pan.js +23 -29
- package/pink-noise.js +35 -57
- package/pipe.js +6 -4
- package/power.js +40 -96
- package/product.js +5 -4
- package/reciprocal.js +20 -22
- package/ref.js +24 -20
- package/serial.js +59 -60
- package/sincos.js +45 -61
- package/sum.js +5 -4
- package/svf.js +74 -78
- package/sweep.js +4 -27
- package/waveshaper.js +41 -60
- package/white-noise.js +17 -23
- package/window.js +67 -52
package/foldback.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
import { foldback as _foldback } from "@thi.ng/math/interval";
|
|
2
2
|
import { AProc } from "./aproc.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
threshold() {
|
|
27
|
-
return this._thresh;
|
|
28
|
-
}
|
|
29
|
-
setThreshold(t) {
|
|
30
|
-
this._thresh = t;
|
|
31
|
-
}
|
|
32
|
-
amp() {
|
|
33
|
-
return this._amp;
|
|
34
|
-
}
|
|
35
|
-
setAmp(a) {
|
|
36
|
-
this._amp = a;
|
|
37
|
-
}
|
|
3
|
+
const foldback = (thresh, amp) => new Foldback(thresh, amp);
|
|
4
|
+
class Foldback extends AProc {
|
|
5
|
+
constructor(_thresh = 1, _amp = 1 / _thresh) {
|
|
6
|
+
super(0);
|
|
7
|
+
this._thresh = _thresh;
|
|
8
|
+
this._amp = _amp;
|
|
9
|
+
}
|
|
10
|
+
next(x) {
|
|
11
|
+
return this._val = _foldback(this._thresh, x) * this._amp;
|
|
12
|
+
}
|
|
13
|
+
threshold() {
|
|
14
|
+
return this._thresh;
|
|
15
|
+
}
|
|
16
|
+
setThreshold(t) {
|
|
17
|
+
this._thresh = t;
|
|
18
|
+
}
|
|
19
|
+
amp() {
|
|
20
|
+
return this._amp;
|
|
21
|
+
}
|
|
22
|
+
setAmp(a) {
|
|
23
|
+
this._amp = a;
|
|
24
|
+
}
|
|
38
25
|
}
|
|
26
|
+
export {
|
|
27
|
+
Foldback,
|
|
28
|
+
foldback
|
|
29
|
+
};
|
package/impulse-train.js
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import { AGen } from "./agen.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
next() {
|
|
34
|
-
return (this._val =
|
|
35
|
-
++this._pos >= this._period
|
|
36
|
-
? ((this._pos = 0), this._on)
|
|
37
|
-
: this._off);
|
|
38
|
-
}
|
|
2
|
+
const impulseTrain = (period, start) => new ImpulseTrain(1, 0, period, start);
|
|
3
|
+
const impulseTrainT = (on, off, period, start) => new ImpulseTrain(on, off, period, start);
|
|
4
|
+
const impulseTrainB = (period, start) => new ImpulseTrain(true, false, period, start);
|
|
5
|
+
class ImpulseTrain extends AGen {
|
|
6
|
+
constructor(_on, _off, _period, _pos = 0) {
|
|
7
|
+
super(_off);
|
|
8
|
+
this._on = _on;
|
|
9
|
+
this._off = _off;
|
|
10
|
+
this._period = _period;
|
|
11
|
+
this._pos = _pos;
|
|
12
|
+
this._startpos = --this._pos;
|
|
13
|
+
}
|
|
14
|
+
_startpos;
|
|
15
|
+
copy() {
|
|
16
|
+
return new ImpulseTrain(
|
|
17
|
+
this._on,
|
|
18
|
+
this._off,
|
|
19
|
+
this._period,
|
|
20
|
+
this._startpos + 1
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
reset() {
|
|
24
|
+
this._val = this._off;
|
|
25
|
+
this._pos = this._startpos;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
next() {
|
|
29
|
+
return this._val = ++this._pos >= this._period ? (this._pos = 0, this._on) : this._off;
|
|
30
|
+
}
|
|
39
31
|
}
|
|
32
|
+
export {
|
|
33
|
+
ImpulseTrain,
|
|
34
|
+
impulseTrain,
|
|
35
|
+
impulseTrainB,
|
|
36
|
+
impulseTrainT
|
|
37
|
+
};
|
package/impulse.js
CHANGED
|
@@ -1,44 +1,29 @@
|
|
|
1
1
|
import { AGen } from "./agen.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export const impulseB = (start = true) => new Impulse(start, !start);
|
|
24
|
-
export class Impulse extends AGen {
|
|
25
|
-
_on;
|
|
26
|
-
_off;
|
|
27
|
-
constructor(_on, _off) {
|
|
28
|
-
super(_on);
|
|
29
|
-
this._on = _on;
|
|
30
|
-
this._off = _off;
|
|
31
|
-
}
|
|
32
|
-
copy() {
|
|
33
|
-
return new Impulse(this._on, this._off);
|
|
34
|
-
}
|
|
35
|
-
reset() {
|
|
36
|
-
this._val = this._on;
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
next() {
|
|
40
|
-
const x = this._val;
|
|
41
|
-
this._val = this._off;
|
|
42
|
-
return x;
|
|
43
|
-
}
|
|
2
|
+
const impulse = (on = 1) => new Impulse(on, 0);
|
|
3
|
+
const impulseT = (on, off) => new Impulse(on, off);
|
|
4
|
+
const impulseB = (start = true) => new Impulse(start, !start);
|
|
5
|
+
class Impulse extends AGen {
|
|
6
|
+
constructor(_on, _off) {
|
|
7
|
+
super(_on);
|
|
8
|
+
this._on = _on;
|
|
9
|
+
this._off = _off;
|
|
10
|
+
}
|
|
11
|
+
copy() {
|
|
12
|
+
return new Impulse(this._on, this._off);
|
|
13
|
+
}
|
|
14
|
+
reset() {
|
|
15
|
+
this._val = this._on;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
next() {
|
|
19
|
+
const x = this._val;
|
|
20
|
+
this._val = this._off;
|
|
21
|
+
return x;
|
|
22
|
+
}
|
|
44
23
|
}
|
|
24
|
+
export {
|
|
25
|
+
Impulse,
|
|
26
|
+
impulse,
|
|
27
|
+
impulseB,
|
|
28
|
+
impulseT
|
|
29
|
+
};
|
package/integrator.js
CHANGED
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
import { AProc } from "./aproc.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
next(x) {
|
|
26
|
-
return (this._val = this._val * this._coeff + x);
|
|
27
|
-
}
|
|
28
|
-
coeff() {
|
|
29
|
-
return this._coeff;
|
|
30
|
-
}
|
|
31
|
-
setCoeff(c) {
|
|
32
|
-
this._coeff = c;
|
|
33
|
-
}
|
|
2
|
+
const integrator = (coeff, start) => new Integrator(coeff, start);
|
|
3
|
+
class Integrator extends AProc {
|
|
4
|
+
constructor(_coeff = 1, _start = 0) {
|
|
5
|
+
super(_start);
|
|
6
|
+
this._coeff = _coeff;
|
|
7
|
+
this._start = _start;
|
|
8
|
+
}
|
|
9
|
+
copy() {
|
|
10
|
+
return new Integrator(this._coeff, this._start);
|
|
11
|
+
}
|
|
12
|
+
reset() {
|
|
13
|
+
this._val = this._start;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
next(x) {
|
|
17
|
+
return this._val = this._val * this._coeff + x;
|
|
18
|
+
}
|
|
19
|
+
coeff() {
|
|
20
|
+
return this._coeff;
|
|
21
|
+
}
|
|
22
|
+
setCoeff(c) {
|
|
23
|
+
this._coeff = c;
|
|
24
|
+
}
|
|
34
25
|
}
|
|
26
|
+
export {
|
|
27
|
+
Integrator,
|
|
28
|
+
integrator
|
|
29
|
+
};
|
package/internal/ensure.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { isNumber } from "@thi.ng/checks/is-number";
|
|
2
2
|
import { Const } from "../const.js";
|
|
3
|
-
|
|
3
|
+
const __ensureGenN = (x, clamp) => isNumber(x) ? new Const(clamp(x)) : x;
|
|
4
|
+
export {
|
|
5
|
+
__ensureGenN
|
|
6
|
+
};
|
package/internal/take.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const __take = (src, num, out = [], idx = 0) => {
|
|
2
|
+
for (; num-- > 0; ) {
|
|
3
|
+
out[idx++] = src.next();
|
|
4
|
+
}
|
|
5
|
+
return out;
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
__take
|
|
6
9
|
};
|
package/iterable.js
CHANGED
|
@@ -1,46 +1,35 @@
|
|
|
1
1
|
import { __take } from "./internal/take.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
_iter
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return this._val;
|
|
26
|
-
}
|
|
27
|
-
*[Symbol.iterator]() {
|
|
28
|
-
while (true)
|
|
29
|
-
yield this.next();
|
|
30
|
-
}
|
|
31
|
-
next() {
|
|
32
|
-
if (this._iter) {
|
|
33
|
-
const res = this._iter.next();
|
|
34
|
-
if (!res.done) {
|
|
35
|
-
this._val = res.value;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this._iter = null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return this._val;
|
|
42
|
-
}
|
|
43
|
-
take(num, out = [], idx = 0) {
|
|
44
|
-
return __take(this, num, out, idx);
|
|
2
|
+
const iterable = (src, initial) => new $Iterable(src, initial);
|
|
3
|
+
class $Iterable {
|
|
4
|
+
_iter;
|
|
5
|
+
_val;
|
|
6
|
+
constructor(src, initial) {
|
|
7
|
+
this._iter = src[Symbol.iterator]();
|
|
8
|
+
this._val = initial;
|
|
9
|
+
}
|
|
10
|
+
deref() {
|
|
11
|
+
return this._val;
|
|
12
|
+
}
|
|
13
|
+
*[Symbol.iterator]() {
|
|
14
|
+
while (true)
|
|
15
|
+
yield this.next();
|
|
16
|
+
}
|
|
17
|
+
next() {
|
|
18
|
+
if (this._iter) {
|
|
19
|
+
const res = this._iter.next();
|
|
20
|
+
if (!res.done) {
|
|
21
|
+
this._val = res.value;
|
|
22
|
+
} else {
|
|
23
|
+
this._iter = null;
|
|
24
|
+
}
|
|
45
25
|
}
|
|
26
|
+
return this._val;
|
|
27
|
+
}
|
|
28
|
+
take(num, out = [], idx = 0) {
|
|
29
|
+
return __take(this, num, out, idx);
|
|
30
|
+
}
|
|
46
31
|
}
|
|
32
|
+
export {
|
|
33
|
+
$Iterable,
|
|
34
|
+
iterable
|
|
35
|
+
};
|
package/line.js
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
import { Add } from "./add.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* line(0, 1, 5).take(7)
|
|
15
|
-
* // [ 0, 0.2, 0.4, 0.6, 0.8, 1, 1.2 ]
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @param start - start value
|
|
19
|
-
* @param end - end value
|
|
20
|
-
* @param num - num steps (default: 10)
|
|
21
|
-
* @param skipFirst - true to skip start value (default: false)
|
|
22
|
-
* @param clampEnd - true to clamp curve at end value (default: false)
|
|
23
|
-
*/
|
|
24
|
-
export const line = (start = 0, end = 1, num = 10, skipFirst = false, clampEnd = false) => {
|
|
25
|
-
const dt = (end - start) / num;
|
|
26
|
-
return new Add(dt, skipFirst ? start + dt : start, clampEnd ? end : undefined);
|
|
2
|
+
const line = (start = 0, end = 1, num = 10, skipFirst = false, clampEnd = false) => {
|
|
3
|
+
const dt = (end - start) / num;
|
|
4
|
+
return new Add(
|
|
5
|
+
dt,
|
|
6
|
+
skipFirst ? start + dt : start,
|
|
7
|
+
clampEnd ? end : void 0
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
line
|
|
27
12
|
};
|
package/madd.js
CHANGED
|
@@ -1,42 +1,27 @@
|
|
|
1
1
|
import { AGen } from "./agen.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_offset;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this._clamp = _clamp;
|
|
24
|
-
this.reset();
|
|
25
|
-
}
|
|
26
|
-
copy() {
|
|
27
|
-
return new MAdd(this._factor, this._start, this._offset, this._clamp);
|
|
28
|
-
}
|
|
29
|
-
reset() {
|
|
30
|
-
this._val = (this._start - this._offset) / this._factor;
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
next() {
|
|
34
|
-
let v = this._val * this._factor + this._offset;
|
|
35
|
-
return (this._val =
|
|
36
|
-
this._clamp !== undefined
|
|
37
|
-
? this._start < this._clamp
|
|
38
|
-
? Math.min(v, this._clamp)
|
|
39
|
-
: Math.max(v, this._clamp)
|
|
40
|
-
: v);
|
|
41
|
-
}
|
|
2
|
+
const madd = (factor, start, offset, clamp) => new MAdd(factor, start, offset, clamp);
|
|
3
|
+
class MAdd extends AGen {
|
|
4
|
+
constructor(_factor = 1, _start = 1, _offset = 0, _clamp) {
|
|
5
|
+
super(0);
|
|
6
|
+
this._factor = _factor;
|
|
7
|
+
this._start = _start;
|
|
8
|
+
this._offset = _offset;
|
|
9
|
+
this._clamp = _clamp;
|
|
10
|
+
this.reset();
|
|
11
|
+
}
|
|
12
|
+
copy() {
|
|
13
|
+
return new MAdd(this._factor, this._start, this._offset, this._clamp);
|
|
14
|
+
}
|
|
15
|
+
reset() {
|
|
16
|
+
this._val = (this._start - this._offset) / this._factor;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
next() {
|
|
20
|
+
let v = this._val * this._factor + this._offset;
|
|
21
|
+
return this._val = this._clamp !== void 0 ? this._start < this._clamp ? Math.min(v, this._clamp) : Math.max(v, this._clamp) : v;
|
|
22
|
+
}
|
|
42
23
|
}
|
|
24
|
+
export {
|
|
25
|
+
MAdd,
|
|
26
|
+
madd
|
|
27
|
+
};
|
package/mapg.js
CHANGED
|
@@ -1,76 +1,84 @@
|
|
|
1
1
|
import { illegalArity } from "@thi.ng/errors/illegal-arity";
|
|
2
2
|
import { AGen } from "./agen.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
function mapG(op, ...args) {
|
|
4
|
+
switch (args.length) {
|
|
5
|
+
case 2:
|
|
6
|
+
return new MapG1(op, args[0], args[1]);
|
|
7
|
+
case 3:
|
|
8
|
+
return new MapG2(op, args[0], args[1], args[2]);
|
|
9
|
+
case 4:
|
|
10
|
+
return new MapG3(op, args[0], args[1], args[2], args[3]);
|
|
11
|
+
case 5:
|
|
12
|
+
return new MapG4(op, args[0], args[1], args[2], args[3], args[4]);
|
|
13
|
+
default:
|
|
14
|
+
illegalArity(args.length);
|
|
15
|
+
}
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return (this._val = this._op(this._a.next(), this._val));
|
|
27
|
-
}
|
|
17
|
+
class MapG1 extends AGen {
|
|
18
|
+
constructor(_op, _a, init) {
|
|
19
|
+
super(init);
|
|
20
|
+
this._op = _op;
|
|
21
|
+
this._a = _a;
|
|
22
|
+
}
|
|
23
|
+
next() {
|
|
24
|
+
return this._val = this._op(this._a.next(), this._val);
|
|
25
|
+
}
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
class MapG2 extends AGen {
|
|
28
|
+
constructor(_op, _a, _b, init) {
|
|
29
|
+
super(init);
|
|
30
|
+
this._op = _op;
|
|
31
|
+
this._a = _a;
|
|
32
|
+
this._b = _b;
|
|
33
|
+
}
|
|
34
|
+
next() {
|
|
35
|
+
return this._val = this._op(
|
|
36
|
+
this._a.next(),
|
|
37
|
+
this._b.next(),
|
|
38
|
+
this._val
|
|
39
|
+
);
|
|
40
|
+
}
|
|
42
41
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
class MapG3 extends AGen {
|
|
43
|
+
constructor(_op, _a, _b, _c, init) {
|
|
44
|
+
super(init);
|
|
45
|
+
this._op = _op;
|
|
46
|
+
this._a = _a;
|
|
47
|
+
this._b = _b;
|
|
48
|
+
this._c = _c;
|
|
49
|
+
}
|
|
50
|
+
next() {
|
|
51
|
+
return this._val = this._op(
|
|
52
|
+
this._a.next(),
|
|
53
|
+
this._b.next(),
|
|
54
|
+
this._c.next(),
|
|
55
|
+
this._val
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
class MapG4 extends AGen {
|
|
60
|
+
constructor(_op, _a, _b, _c, _d, init) {
|
|
61
|
+
super(init);
|
|
62
|
+
this._op = _op;
|
|
63
|
+
this._a = _a;
|
|
64
|
+
this._b = _b;
|
|
65
|
+
this._c = _c;
|
|
66
|
+
this._d = _d;
|
|
67
|
+
}
|
|
68
|
+
next() {
|
|
69
|
+
return this._val = this._op(
|
|
70
|
+
this._a.next(),
|
|
71
|
+
this._b.next(),
|
|
72
|
+
this._c.next(),
|
|
73
|
+
this._d.next(),
|
|
74
|
+
this._val
|
|
75
|
+
);
|
|
76
|
+
}
|
|
76
77
|
}
|
|
78
|
+
export {
|
|
79
|
+
MapG1,
|
|
80
|
+
MapG2,
|
|
81
|
+
MapG3,
|
|
82
|
+
MapG4,
|
|
83
|
+
mapG
|
|
84
|
+
};
|