refactor: drop bluebird dependency (#3279)
parent
3c8ad50005
commit
293ca70077
|
@ -53,7 +53,6 @@
|
|||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.13.0",
|
||||
"@panter/vue-i18next": "^0.15.2",
|
||||
"bluebird": "^3.7.2",
|
||||
"bonjour": "^3.5.0",
|
||||
"crypto-es": "^1.2.7",
|
||||
"d3": "^7.8.2",
|
||||
|
|
|
@ -111,8 +111,9 @@ cli.initialize = function (callback) {
|
|||
self.history.add(outString.trim());
|
||||
|
||||
const outputArray = outString.split("\n");
|
||||
return Promise.reduce(outputArray, function(delay, line, index) {
|
||||
return new Promise(function (resolve) {
|
||||
return outputArray.reduce((p, line, index) =>
|
||||
p.then((delay) =>
|
||||
new Promise((resolve) => {
|
||||
GUI.timeout_add('CLI_send_slowly', function () {
|
||||
let processingDelay = self.lineDelayMs;
|
||||
line = line.trim();
|
||||
|
@ -127,8 +128,10 @@ cli.initialize = function (callback) {
|
|||
resolve(processingDelay);
|
||||
});
|
||||
}, delay);
|
||||
});
|
||||
}, 0);
|
||||
}),
|
||||
),
|
||||
Promise.resolve(0),
|
||||
);
|
||||
}
|
||||
|
||||
$('#content').load("./tabs/cli.html", function () {
|
||||
|
|
|
@ -254,10 +254,18 @@ FONT.msp = {
|
|||
};
|
||||
|
||||
FONT.upload = function($progress) {
|
||||
return Promise.mapSeries(FONT.data.characters, function(data, i) {
|
||||
return FONT.data.characters
|
||||
.reduce(
|
||||
(p, x, i) =>
|
||||
p.then(() => {
|
||||
$progress.val((i / FONT.data.characters.length) * 100);
|
||||
return MSP.promise(MSPCodes.MSP_OSD_CHAR_WRITE, FONT.msp.encode(i));
|
||||
})
|
||||
return MSP.promise(
|
||||
MSPCodes.MSP_OSD_CHAR_WRITE,
|
||||
FONT.msp.encode(i),
|
||||
);
|
||||
}),
|
||||
Promise.resolve(),
|
||||
)
|
||||
.then(function() {
|
||||
|
||||
console.log(`Uploaded all ${FONT.data.characters.length} characters`);
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
<script type="text/javascript" src="./node_modules/jquery-ui-npm/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="./js/libraries/jquery.nouislider.all.min.js"></script>
|
||||
<script type="text/javascript" src="./js/libraries/jquery.flightindicators.js"></script>
|
||||
<script type="text/javascript" src="./node_modules/bluebird/js/browser/bluebird.min.js"></script>
|
||||
<script type="text/javascript" src="./node_modules/jquery-textcomplete/dist/jquery.textcomplete.min.js"></script>
|
||||
<script type="text/javascript" src="./node_modules/jquery-touchswipe/jquery.touchSwipe.min.js"></script>
|
||||
<script type="text/javascript" src="./node_modules/select2/dist/js/select2.min.js"></script>
|
||||
|
|
|
@ -88,8 +88,9 @@ export default class CliEngine
|
|||
this._reportSendCommandsProgress(0);
|
||||
const totalCommandsCount = strings.length;
|
||||
|
||||
return Promise.reduce(strings, (delay, line, index) => {
|
||||
return new Promise((resolve) => {
|
||||
return strings.reduce(strings, (p, line, index) =>
|
||||
p.then((delay) =>
|
||||
new Promise((resolve) => {
|
||||
GUI.timeout_add('CLI_send_slowly', () => {
|
||||
let processingDelay = this.lineDelayMs;
|
||||
line = line.trim();
|
||||
|
@ -104,13 +105,15 @@ export default class CliEngine
|
|||
line = this.getCliCommand(line, this.cliBuffer);
|
||||
}
|
||||
|
||||
this.sendLine(line, ()=>{ /* empty on-send callback */ }, () => {
|
||||
this.sendLine(line, () => { /* empty on-send callback */ }, () => {
|
||||
resolve(processingDelay);
|
||||
this._reportSendCommandsProgress(100.0 * index / totalCommandsCount);
|
||||
});
|
||||
}, delay);
|
||||
});
|
||||
}, 0).then(() => {
|
||||
}),
|
||||
),
|
||||
Promise.resolve(0),
|
||||
).then(() => {
|
||||
this._reportSendCommandsProgress(100);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ export default class PresetsRepoIndexed {
|
|||
return this._executeIncludeOnce(strings)
|
||||
.then(resultStrings => this._executeIncludeNested(resultStrings));
|
||||
} else {
|
||||
return new Promise.resolve(strings);
|
||||
return Promise.resolve(strings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import "bluebird";
|
||||
import { JSDOM } from "jsdom";
|
||||
import $ from "jquery";
|
||||
import { vi } from "vitest";
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Promise } from "bluebird";
|
||||
import {
|
||||
describe,
|
||||
it,
|
||||
|
@ -88,7 +87,7 @@ describe("cli", () => {
|
|||
cli.cliBuffer = "se";
|
||||
cli.read({
|
||||
data: toArrayBuffer(
|
||||
"\r\x1B[Kserialpassthrough\tservo\r\n# ser"
|
||||
"\r\x1B[Kserialpassthrough\tservo\r\n# ser",
|
||||
),
|
||||
});
|
||||
// Ambigous auto-complete from firmware is preceded with an \r carriage return
|
||||
|
@ -153,11 +152,7 @@ describe("cli", () => {
|
|||
send: () => {},
|
||||
};
|
||||
});
|
||||
vi.spyOn(Promise, "reduce").mockImplementation((items, cb) => {
|
||||
items.forEach((line, idx) => cb(0, line, idx));
|
||||
});
|
||||
|
||||
vi.spyOn(Promise, "Promise").mockResolvedValue(0);
|
||||
vi.spyOn(GUI, "timeout_add").mockImplementation((name, cb) => {
|
||||
cb();
|
||||
});
|
||||
|
@ -222,7 +217,7 @@ describe("cli", () => {
|
|||
|
||||
expect(cli.send).toHaveBeenCalledOnce();
|
||||
expect(cli.send).toHaveBeenCalledWith(
|
||||
`${backspaceCode.repeat(3)}\t`
|
||||
`${backspaceCode.repeat(3)}\t`,
|
||||
);
|
||||
done();
|
||||
});
|
||||
|
@ -266,7 +261,7 @@ describe("cli", () => {
|
|||
|
||||
expect(cli.send).toHaveBeenCalledOnce();
|
||||
expect(cli.send).toHaveBeenCalledWith(
|
||||
`${backspaceCode.repeat(3)}\n`
|
||||
`${backspaceCode.repeat(3)}\n`,
|
||||
);
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -4282,7 +4282,7 @@ bl@^4.0.3:
|
|||
inherits "^2.0.4"
|
||||
readable-stream "^3.4.0"
|
||||
|
||||
bluebird@^3.1.1, bluebird@^3.3.5, bluebird@^3.5.5, bluebird@^3.7.2:
|
||||
bluebird@^3.1.1, bluebird@^3.3.5, bluebird@^3.5.5:
|
||||
version "3.7.2"
|
||||
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
|
||||
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
|
||||
|
|
Loading…
Reference in New Issue