a2bei4-utils 1.0.9 → 1.0.10
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/a2bei4.utils.cjs.js +14 -0
- package/dist/a2bei4.utils.cjs.js.map +1 -1
- package/dist/a2bei4.utils.cjs.min.js +1 -1
- package/dist/a2bei4.utils.cjs.min.js.map +1 -1
- package/dist/a2bei4.utils.esm.js +14 -0
- package/dist/a2bei4.utils.esm.js.map +1 -1
- package/dist/a2bei4.utils.esm.min.js +1 -1
- package/dist/a2bei4.utils.esm.min.js.map +1 -1
- package/dist/a2bei4.utils.umd.js +14 -0
- package/dist/a2bei4.utils.umd.js.map +1 -1
- package/dist/a2bei4.utils.umd.min.js +1 -1
- package/dist/a2bei4.utils.umd.min.js.map +1 -1
- package/dist/timer.cjs +14 -0
- package/dist/timer.cjs.map +1 -1
- package/dist/timer.js +14 -0
- package/dist/timer.js.map +1 -1
- package/package.json +5 -5
- package/types/index.d.ts +5 -1
- package/types/timer.d.ts +4 -0
package/dist/a2bei4.utils.umd.js
CHANGED
|
@@ -1827,6 +1827,10 @@ registerProcessor('audio-stream-resampler-processor', AudioStreamResamplerProces
|
|
|
1827
1827
|
this._fn = fn;
|
|
1828
1828
|
this._ms = ms;
|
|
1829
1829
|
this._timerId = null;
|
|
1830
|
+
/**
|
|
1831
|
+
* @type {symbol | null}
|
|
1832
|
+
*/
|
|
1833
|
+
this._loopId = null;
|
|
1830
1834
|
}
|
|
1831
1835
|
|
|
1832
1836
|
/**
|
|
@@ -1835,8 +1839,17 @@ registerProcessor('audio-stream-resampler-processor', AudioStreamResamplerProces
|
|
|
1835
1839
|
*/
|
|
1836
1840
|
start() {
|
|
1837
1841
|
this.stop();
|
|
1842
|
+
|
|
1843
|
+
const curLoopId = Symbol();
|
|
1844
|
+
this._loopId = curLoopId;
|
|
1845
|
+
|
|
1838
1846
|
const loop = () => {
|
|
1847
|
+
if (this._loopId !== curLoopId) return;
|
|
1848
|
+
|
|
1839
1849
|
this._fn(); // 执行业务
|
|
1850
|
+
|
|
1851
|
+
if (this._loopId !== curLoopId) return;
|
|
1852
|
+
|
|
1840
1853
|
this._timerId = setTimeout(loop, this._ms);
|
|
1841
1854
|
};
|
|
1842
1855
|
loop(); // 立即执行第一次
|
|
@@ -1846,6 +1859,7 @@ registerProcessor('audio-stream-resampler-processor', AudioStreamResamplerProces
|
|
|
1846
1859
|
* 停止定时器。
|
|
1847
1860
|
*/
|
|
1848
1861
|
stop() {
|
|
1862
|
+
this._loopId = null;
|
|
1849
1863
|
if (this._timerId !== null) {
|
|
1850
1864
|
clearTimeout(this._timerId);
|
|
1851
1865
|
this._timerId = null;
|