Skip to content

Commit 01b5c9c

Browse files
committed
Fixed remaining eslint warnings
1 parent c08e01c commit 01b5c9c

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

lib/builders/webaudio.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function createFromAudio(options, callback) {
4545
}
4646
else {
4747
throw new TypeError(
48+
// eslint-disable-next-line
4849
"WaveformData.createFromAudio(): Pass either an AudioContext and ArrayBuffer, or an AudioBuffer object"
4950
);
5051
}

lib/core.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ WaveformData.prototype = {
4646
});
4747

4848
if (Adapter === null) {
49-
throw new TypeError("WaveformData.create(): Could not detect a WaveformData adapter from the input");
49+
throw new TypeError(
50+
"WaveformData.create(): Could not detect a WaveformData adapter from the input"
51+
);
5052
}
5153

5254
return Adapter;
@@ -69,11 +71,15 @@ WaveformData.prototype = {
6971
var is_partial_resampling = Boolean(options.input_index) || Boolean(options.output_index);
7072

7173
if (options.input_index != null && (options.input_index < 0)) {
72-
throw new RangeError("WaveformData.resample(): input_index should be a positive integer value");
74+
throw new RangeError(
75+
"WaveformData.resample(): input_index should be a positive integer value"
76+
);
7377
}
7478

7579
if (options.output_index != null && (options.output_index < 0)) {
76-
throw new RangeError("WaveformData.resample(): output_index should be a positive integer value");
80+
throw new RangeError(
81+
"WaveformData.resample(): output_index should be a positive integer value"
82+
);
7783
}
7884

7985
if (options.width != null && (options.width <= 0)) {
@@ -93,7 +99,9 @@ WaveformData.prototype = {
9399
options.scale === null ||
94100
options.input_index === null ||
95101
options.output_index === null) {
96-
throw new Error("WaveformData.resample(): Missing width, scale, input_index, or output_index option");
102+
throw new Error(
103+
"WaveformData.resample(): Missing width, scale, input_index, or output_index option"
104+
);
97105
}
98106
}
99107

@@ -134,7 +142,9 @@ WaveformData.prototype = {
134142
var max_value = 127;
135143

136144
if (samples_per_pixel < scale) {
137-
throw new Error("WaveformData.resample(): Zoom level " + samples_per_pixel + " too low, minimum: " + scale);
145+
throw new Error(
146+
"WaveformData.resample(): Zoom level " + samples_per_pixel + " too low, minimum: " + scale
147+
);
138148
}
139149

140150
var where, prev_where, stop, value, last_input_index;

test/unit/core.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ describe("WaveformData", function() {
415415
});
416416

417417
describe(".resample()", function() {
418-
it("should throw an error if attempting to resample to a width larger than the waveform length", function() {
418+
it("should throw an error if the given width is larger than the waveform length", function() {
419419
expect(function() {
420420
instance.resample({ width: 11 });
421421
}).to.throw(Error);
@@ -455,12 +455,12 @@ describe("WaveformData", function() {
455455

456456
// if we double the scale, it should fit in half the previous size (which means 5px)
457457
describe("full resample by scale", function() {
458-
it("should downsize the number of data by 2 if we request a half-size scaled resampled waveform", function() {
458+
it("should return a waveform with half the number of points", function() {
459459
expect(instance.resample({ scale: 1024 }))
460460
.to.have.lengthOf(expectations.resampled_length);
461461
});
462462

463-
it("should downsize the duration by 2 if we request a half-size scaled resampled waveform", function() {
463+
it("should return a waveform with half the duration", function() {
464464
expect(instance.resample({ scale: 1024 }))
465465
.to.have.property("duration", expectations.duration);
466466
});
@@ -515,7 +515,7 @@ describe("WaveformData", function() {
515515
jsonWaveform = new WaveformData(fixtures.getJSONData({ channels: 2 }));
516516
});
517517

518-
it("should return a new WaveformData object with the concatenated result from binary data", function() {
518+
it("should return a new object with the concatenated result from binary data", function() {
519519
var result = binaryWaveform.concat(binaryWaveform);
520520

521521
expect(result.channels).to.equal(2);
@@ -525,7 +525,7 @@ describe("WaveformData", function() {
525525
.to.deep.equal([0, -10, 0, -5, -5, 0, 0, 0, 0, -2, 0, -10, 0, -5, -5, 0, 0, 0, 0, -2]);
526526
});
527527

528-
it("should return a new WaveformData object with the concatenated result from json data", function() {
528+
it("should return a new object with the concatenated result from json data", function() {
529529
var result = jsonWaveform.concat(jsonWaveform);
530530

531531
expect(result.channels).to.equal(2);
@@ -580,7 +580,7 @@ describe("WaveformData", function() {
580580
expect(instance.at_time(1)).to.equal(93);
581581
});
582582

583-
it("should be able to convert between pixel indexes and times without losing precision", function() {
583+
it("should convert between pixel indexes and times without losing precision", function() {
584584
expect(instance.at_time(instance.time(0))).to.equal(0);
585585
expect(instance.at_time(instance.time(14))).to.equal(14);
586586
expect(instance.at_time(instance.time(93))).to.equal(93);
@@ -592,11 +592,11 @@ describe("WaveformData", function() {
592592
expect(instance.time(0)).to.equal(0);
593593
});
594594

595-
it("should return a time of 0.0015999999999999999 seconds for a given pixel index of 0.15", function() {
595+
it("should return the time in seconds for a given pixel index of 0.15", function() {
596596
expect(instance.time(0.15)).to.equal(0.0015999999999999999); // 0.15 * 512 / 48000
597597
});
598598

599-
it("should return a time of 0.010666666666666666 seconds for a given pixel index of 1", function() {
599+
it("should return the time in seconds for a given pixel index of 1", function() {
600600
expect(instance.time(1)).to.equal(0.010666666666666666); // 1 * 512 / 48000
601601
});
602602
});
@@ -629,7 +629,12 @@ describe("WaveformData", function() {
629629
});
630630

631631
it("should allow a WaveformData instance to be stringified as JSON", function() {
632-
expect(JSON.stringify(instance)).to.equal('{"version":2,"channels":2,"sample_rate":48000,"samples_per_pixel":512,"bits":8,"length":10,"data":[0,0,0,0,-10,10,-8,8,0,0,-2,2,-5,7,-6,3,-5,7,-6,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-2,2,-3,3]}');
632+
expect(JSON.stringify(instance)).to.equal(
633+
"{\"version\":2,\"channels\":2,\"sample_rate\":48000," +
634+
"\"samples_per_pixel\":512,\"bits\":8,\"length\":10," +
635+
"\"data\":[0,0,0,0,-10,10,-8,8,0,0,-2,2,-5,7,-6,3," +
636+
"-5,7,-6,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-2,2,-3,3]}"
637+
);
633638
});
634639
});
635640
});

0 commit comments

Comments
 (0)