Skip to content

Commit f314162

Browse files
committed
Adds lint rule for quotes
1 parent b681936 commit f314162

File tree

9 files changed

+54
-53
lines changed

9 files changed

+54
-53
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"semi": ["error", "always"],
1616
"lines-between-class-members": ["error", "always"],
1717
"tsdoc/syntax": "warn",
18-
"no-constant-condition": "off"
18+
"no-constant-condition": "off",
19+
"quotes": ["warn", "double"]
1920
},
2021
"ignorePatterns": [
2122
"rollup.config.js",

dist/bundle.browser.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
const createAdvancedAnalyserNode = async (context, options = {}) => {
1515
{
16-
const processorUrl = 'data:application/javascript;base64,' + processor;
16+
const processorUrl = "data:application/javascript;base64," + processor;
1717
await context.audioWorklet.addModule(processorUrl);
1818
const AdvancedAnalyserNode = (await Promise.resolve().then(function () { return advancedAnalyserNode; })).AdvancedAnalyserNode;
1919
const advancedAnalyser = new AdvancedAnalyserNode(context, {
@@ -91,7 +91,7 @@
9191

9292
const MAX_FFT_SIZE = 32768;
9393
const MIN_FFT_SIZE = 32;
94-
const PROCESSOR_NAME = 'AdvancedAnalyserProcessor';
94+
const PROCESSOR_NAME = "AdvancedAnalyserProcessor";
9595

9696
const validateFftSize = (value) => {
9797
if (value && (value & (value - 1)) !== 0) {
@@ -127,7 +127,7 @@
127127
if (!Object.values(WindowFunctionTypes).includes(value)) {
128128
throw new Error(`${value} is not a valid windowFunction. Possible window functions are ${Object.values(WindowFunctionTypes)
129129
.map((windowFunction) => `'${windowFunction}'`)
130-
.join(', ')}`);
130+
.join(", ")}`);
131131
}
132132
};
133133
const validateMaxAndMinDecibels = (minDecibels, maxDecibels) => {
@@ -137,7 +137,7 @@
137137
};
138138
const validateSmoothingTimeConstant = (value) => {
139139
if (value < 0 && value > 1) {
140-
throw new Error('smoothingTimeConstant value must be between 0 and 1');
140+
throw new Error("smoothingTimeConstant value must be between 0 and 1");
141141
}
142142
};
143143

@@ -306,9 +306,9 @@
306306
channelInterpretation: "speakers",
307307
});
308308
this.fftSize = fftSize;
309-
if (typeof samplesBetweenTransforms !== 'undefined')
309+
if (typeof samplesBetweenTransforms !== "undefined")
310310
this.samplesBetweenTransforms = samplesBetweenTransforms;
311-
if (typeof timeDomainSamplesCount !== 'undefined')
311+
if (typeof timeDomainSamplesCount !== "undefined")
312312
this.timeDomainSamplesCount = timeDomainSamplesCount;
313313
this.windowFunction = windowFunction;
314314
this.minDecibels = minDecibels;
@@ -328,19 +328,19 @@
328328
_onmessage(event) {
329329
switch (event.type) {
330330
case MessageTypes.frequencyDataAvailable: {
331-
this.dispatchEvent(new CustomEvent('frequencydata', { detail: new Float32Array(event.payload) }));
331+
this.dispatchEvent(new CustomEvent("frequencydata", { detail: new Float32Array(event.payload) }));
332332
break;
333333
}
334334
case MessageTypes.byteFrequencyDataAvailable: {
335-
this.dispatchEvent(new CustomEvent('bytefrequencydata', { detail: new Uint8Array(event.payload) }));
335+
this.dispatchEvent(new CustomEvent("bytefrequencydata", { detail: new Uint8Array(event.payload) }));
336336
break;
337337
}
338338
case MessageTypes.timeDomainDataAvailable: {
339-
this.dispatchEvent(new CustomEvent('timedomaindata', { detail: new Float32Array(event.payload) }));
339+
this.dispatchEvent(new CustomEvent("timedomaindata", { detail: new Float32Array(event.payload) }));
340340
break;
341341
}
342342
case MessageTypes.byteTimeDomainDataAvailable: {
343-
this.dispatchEvent(new CustomEvent('bytetimedomaindata', { detail: new Uint8Array(event.payload) }));
343+
this.dispatchEvent(new CustomEvent("bytetimedomaindata", { detail: new Uint8Array(event.payload) }));
344344
break;
345345
}
346346
case MessageTypes.requestedFloatFrequencyDataAvailable:
@@ -408,12 +408,12 @@
408408
}
409409
addEventListener(type, listener, options) {
410410
super.addEventListener(type, listener, options);
411-
if (type !== 'processorerror')
411+
if (type !== "processorerror")
412412
this._pushEventListener(type, listener);
413413
}
414414
removeEventListener(type, listener, options) {
415415
super.removeEventListener(type, listener, options);
416-
if (type !== 'processorerror')
416+
if (type !== "processorerror")
417417
this._removeEventListener(type, listener);
418418
}
419419
}

dist/src/processor/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import FFT from 'fft.js';
2-
import { EventListenerTypes, Message, WindowFunctionTypes } from '../types';
1+
import FFT from "fft.js";
2+
import { EventListenerTypes, Message, WindowFunctionTypes } from "../types";
33
export declare class AdvancedAnalyserProcessor extends AudioWorkletProcessor {
44
_samplesCount: number;
55
_count: number;

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ export const MAX_FFT_SIZE = 32768;
22
export const MIN_FFT_SIZE = 32;
33

44

5-
export const PROCESSOR_NAME = 'AdvancedAnalyserProcessor';
5+
export const PROCESSOR_NAME = "AdvancedAnalyserProcessor";

src/node/advanced-analyser-node.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ export class AdvancedAnalyserNode extends AudioWorkletNode {
232232
});
233233

234234
this.fftSize = fftSize;
235-
if (typeof samplesBetweenTransforms !== 'undefined') this.samplesBetweenTransforms = samplesBetweenTransforms;
236-
if (typeof timeDomainSamplesCount !== 'undefined') this.timeDomainSamplesCount = timeDomainSamplesCount;
235+
if (typeof samplesBetweenTransforms !== "undefined") this.samplesBetweenTransforms = samplesBetweenTransforms;
236+
if (typeof timeDomainSamplesCount !== "undefined") this.timeDomainSamplesCount = timeDomainSamplesCount;
237237
this.windowFunction = windowFunction;
238238
this.minDecibels = minDecibels;
239239
this.maxDecibels = maxDecibels;
@@ -257,19 +257,19 @@ export class AdvancedAnalyserNode extends AudioWorkletNode {
257257
private _onmessage(event: Message) {
258258
switch(event.type) {
259259
case MessageTypes.frequencyDataAvailable: {
260-
this.dispatchEvent(new CustomEvent<Float32Array>('frequencydata', { detail: new Float32Array(event.payload) }));
260+
this.dispatchEvent(new CustomEvent<Float32Array>("frequencydata", { detail: new Float32Array(event.payload) }));
261261
break;
262262
}
263263
case MessageTypes.byteFrequencyDataAvailable: {
264-
this.dispatchEvent(new CustomEvent<Uint8Array>('bytefrequencydata', { detail: new Uint8Array(event.payload) }));
264+
this.dispatchEvent(new CustomEvent<Uint8Array>("bytefrequencydata", { detail: new Uint8Array(event.payload) }));
265265
break;
266266
}
267267
case MessageTypes.timeDomainDataAvailable: {
268-
this.dispatchEvent(new CustomEvent<Float32Array>('timedomaindata', { detail: new Float32Array(event.payload) }));
268+
this.dispatchEvent(new CustomEvent<Float32Array>("timedomaindata", { detail: new Float32Array(event.payload) }));
269269
break;
270270
}
271271
case MessageTypes.byteTimeDomainDataAvailable: {
272-
this.dispatchEvent(new CustomEvent<Uint8Array>('bytetimedomaindata', { detail: new Uint8Array(event.payload) }));
272+
this.dispatchEvent(new CustomEvent<Uint8Array>("bytetimedomaindata", { detail: new Uint8Array(event.payload) }));
273273
break;
274274
}
275275
case MessageTypes.requestedFloatFrequencyDataAvailable:
@@ -355,37 +355,37 @@ export class AdvancedAnalyserNode extends AudioWorkletNode {
355355
* Listens to Time-domain data events. The interval between calls is defined the `timeDomainSamplesCount` property.
356356
* Returns a Uint8Array with the size defined by `timeDomainSamplesCount`, with the current time-domain data.
357357
*/
358-
addEventListener(type: 'bytetimedomaindata' , listener: Listener<Uint8Array>): void;
358+
addEventListener(type: "bytetimedomaindata" , listener: Listener<Uint8Array>): void;
359359

360360
/**
361361
* Listens to Frequency data events. The interval between calls is defined by the `samplesBetweenTransforms` property.
362362
* The data is represented in bytes
363363
* Returns a Uint8Array with half the `fftSize`, with the current frequency data.
364364
*/
365-
addEventListener(type: 'bytefrequencydata' , listener: Listener<Uint8Array>): void;
365+
addEventListener(type: "bytefrequencydata" , listener: Listener<Uint8Array>): void;
366366

367367
/**
368368
* Listens to Time-domain data events. The interval between calls is defined the `timeDomainSamplesCount` property.
369369
* Returns a Float32Array with the size defined by `timeDomainSamplesCount`, with the current time-domain data.
370370
*/
371-
addEventListener(type: 'timedomaindata', listener: Listener<Float32Array>): void;
371+
addEventListener(type: "timedomaindata", listener: Listener<Float32Array>): void;
372372

373373
/**
374374
* Listens to Frequency data events. The interval between calls is defined by the `samplesBetweenTransforms` property.
375375
* Returns a Float32Array with half the `fftSize`, with the current frequency data.
376376
*/
377-
addEventListener(type: 'frequencydata', listener: Listener<Float32Array>): void;
377+
addEventListener(type: "frequencydata", listener: Listener<Float32Array>): void;
378378

379379
addEventListener(type: "processorerror", listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void ;
380380

381381
addEventListener(type: "processorerror" | EventListenerTypes, listener: EventListenerOrEventListenerObject | Listener<Float32Array | Uint8Array>, options?: boolean | AddEventListenerOptions): void {
382382
super.addEventListener(type, listener as EventListenerOrEventListenerObject, options);
383-
if (type !== 'processorerror') this._pushEventListener(type, listener);
383+
if (type !== "processorerror") this._pushEventListener(type, listener);
384384
}
385385

386386
removeEventListener(type: "processorerror" | EventListenerTypes, listener: EventListenerOrEventListenerObject | Listener<ArrayBuffer>, options?: boolean | EventListenerOptions): void {
387387
super.removeEventListener(type, listener as EventListenerOrEventListenerObject, options);
388-
if (type !== 'processorerror') this._removeEventListener(type, listener);
388+
if (type !== "processorerror") this._removeEventListener(type, listener);
389389
}
390390
}
391391

src/node/create-advanced-analyser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
* The AudioWorkletProcessor is bundled first, and later imported here to be bundled as a base64 string,
44
* to avoid needing to be manually imported and loaded by this module's consumers
55
*/
6-
import processor from 'processor';
7-
import { AdvancedAnalyserNodeProperties } from '../types';
6+
import processor from "processor";
7+
import { AdvancedAnalyserNodeProperties } from "../types";
88

99
export const createAdvancedAnalyserNode = async (context: BaseAudioContext, options: AdvancedAnalyserNodeProperties = {}) => {
10-
if (IS_SERVER) {
10+
if (false) {
1111
throw new Error(`
1212
AudioWorkletNode does not exist in this environment:
1313
This typically happens if you try to run 'createAdvancedAnalyserNode' in the server
1414
`);
1515
} else {
16-
const processorUrl = 'data:application/javascript;base64,' + processor;
16+
const processorUrl = "data:application/javascript;base64," + processor;
1717
await context.audioWorklet.addModule(processorUrl);
18-
const AdvancedAnalyserNode = (await import('./advanced-analyser-node')).AdvancedAnalyserNode;
18+
const AdvancedAnalyserNode = (await import("./advanced-analyser-node")).AdvancedAnalyserNode;
1919
const advancedAnalyser = new AdvancedAnalyserNode(context, {
2020
...options,
2121
});

src/node/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './create-advanced-analyser';
2-
export { type AdvancedAnalyserNode} from './advanced-analyser-node';
1+
export * from "./create-advanced-analyser";
2+
export { type AdvancedAnalyserNode} from "./advanced-analyser-node";

src/node/validation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const validateWindowFunction = (value: WindowFunctionTypes) => {
4444
`${value} is not a valid windowFunction. Possible window functions are ${
4545
Object.values(WindowFunctionTypes)
4646
.map((windowFunction) => `'${windowFunction}'`)
47-
.join(', ')}`);
47+
.join(", ")}`);
4848
}
4949
};
5050

@@ -61,7 +61,7 @@ export const validateMaxAndMinDecibels = (minDecibels: number, maxDecibels: numb
6161
export const validateSmoothingTimeConstant = (value: number) => {
6262
if (value < 0 && value > 1) {
6363
throw new Error(
64-
'smoothingTimeConstant value must be between 0 and 1'
64+
"smoothingTimeConstant value must be between 0 and 1"
6565
);
6666
}
6767
};

src/types.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,49 +91,49 @@ export type Message =
9191

9292

9393
export enum ProcessorParameters {
94-
fftSize = 'fftSize',
95-
samplesBetweenTransforms = 'samplesBetweenTransforms',
96-
timeDomainSamplesCount = 'timeDomainSamplesCount',
97-
windowFunction = 'windowFunction',
98-
minDecibels = 'minDecibels',
99-
maxDecibels = 'maxDecibels',
100-
smoothingTimeConstant = 'smoothingTimeConstant',
94+
fftSize = "fftSize",
95+
samplesBetweenTransforms = "samplesBetweenTransforms",
96+
timeDomainSamplesCount = "timeDomainSamplesCount",
97+
windowFunction = "windowFunction",
98+
minDecibels = "minDecibels",
99+
maxDecibels = "maxDecibels",
100+
smoothingTimeConstant = "smoothingTimeConstant",
101101
}
102-
export type EventListenerTypes = 'frequencydata' | 'bytefrequencydata' | 'timedomaindata' | 'bytetimedomaindata'
102+
export type EventListenerTypes = "frequencydata" | "bytefrequencydata" | "timedomaindata" | "bytetimedomaindata"
103103

104104
export enum WindowFunctionTypes {
105105
/**
106106
* Retangular window - Doesn't change the signal
107107
*/
108-
rectangular = 'rectangular',
108+
rectangular = "rectangular",
109109
/**
110110
* [Blackmann window](https://en.wikipedia.org/wiki/Window_function#Blackman_window)
111111
*/
112-
blackman = 'blackman',
112+
blackman = "blackman",
113113
/**
114114
* [Nuttall window](https://en.wikipedia.org/wiki/Window_function#Nuttall_window,_continuous_first_derivative)
115115
*/
116-
nuttall = 'nuttall',
116+
nuttall = "nuttall",
117117
/**
118118
* [Blackman-Nutall window](https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Nuttall_window)
119119
*/
120-
blackmanNuttall = 'blackman-nuttall',
120+
blackmanNuttall = "blackman-nuttall",
121121
/**
122122
* [Blackman-Harris window](https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Harris_window)
123123
*/
124-
blackmanHarris = 'blackman-harris',
124+
blackmanHarris = "blackman-harris",
125125
/**
126126
* [Hann window](https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows)
127127
*/
128-
hann = 'hann',
128+
hann = "hann",
129129
/**
130130
* [Hamming window](https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows)
131131
*/
132-
hamming = 'hamming',
132+
hamming = "hamming",
133133
/**
134134
* Bartlett window
135135
*/
136-
bartlett = 'bartlett',
136+
bartlett = "bartlett",
137137
}
138138

139139
export type AdvancedAnalyserNodeProperties = {

0 commit comments

Comments
 (0)