tone 15.5.56 → 15.5.57

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.
@@ -99,5 +99,23 @@ describe("PatternGenerator", () => {
99
99
  currentIndex = nextIndex;
100
100
  }
101
101
  });
102
+
103
+ it("never randomly walks outside of the range of values", () => {
104
+ [1, 2, 3, 4].forEach((numValues) => {
105
+ const pattern = PatternGenerator(numValues, "randomWalk");
106
+ for (let i = 0; i < 100; i++) {
107
+ expect(pattern.next().value)
108
+ .to.be.at.least(0)
109
+ .and.at.most(numValues - 1);
110
+ }
111
+ });
112
+ });
113
+
114
+ it("randomly walks in place when there is only one value", () => {
115
+ const pattern = PatternGenerator(1, "randomWalk");
116
+ expect(getArrayValues(pattern, 10)).to.deep.equal([
117
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
118
+ ]);
119
+ });
102
120
  });
103
121
  });
@@ -138,6 +138,11 @@ function* randomWalk(numValues: number): IterableIterator<number> {
138
138
  // randomly choose a starting index
139
139
  let index = Math.floor(Math.random() * numValues);
140
140
  while (true) {
141
+ // with a single value there is nowhere to step to
142
+ if (numValues === 1) {
143
+ yield index;
144
+ continue;
145
+ }
141
146
  if (index === 0) {
142
147
  index++; // at bottom, so force upward step
143
148
  } else if (index === numValues - 1) {
package/Tone/version.ts CHANGED
@@ -1 +1 @@
1
- export const version: string = "15.5.56";
1
+ export const version: string = "15.5.57";