UNPKG

sim800

Version:

A modern and opiniated module for SIM800 GSM modems ( SIM800 / SIM800L ).

22 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.completedCommandSubscriberFactory = void 0; const completedCommandSubscriberFactory = (command, buffer, nextJob$, logger) => (pid) => { setTimeout(() => { var _a, _b; if (command.result) { (_a = logger === null || logger === void 0 ? void 0 : logger.verbose) === null || _a === void 0 ? void 0 : _a.call(logger, `Command "${command.command}" with PID ${pid} has completed with result "${command.result}"`); } // we can remove the command from the buffer const commandIndex = buffer.findIndex((c) => c.pid === pid); if (commandIndex > -1) { buffer.splice(commandIndex, 1); } if (buffer.length) { (_b = logger === null || logger === void 0 ? void 0 : logger.verbose) === null || _b === void 0 ? void 0 : _b.call(logger, `Executing next command "${buffer[0].command}" with PID ${buffer[0].pid}`); nextJob$.next(); } }, 0); }; exports.completedCommandSubscriberFactory = completedCommandSubscriberFactory; //# sourceMappingURL=completed-command-subscriber.js.map