UNPKG

@exchanges/binance

Version:

Exchange provider for Binance API

30 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateXMBXUsedWeightAfterCall = exports.updateXMBXUsedWeight = void 0; const safe_parsing_1 = require("@berish/safe-parsing"); const clients_1 = require("../clients"); const info_1 = require("../info"); const resolveHeaders_1 = require("./resolveHeaders"); function updateXMBXUsedWeight(client, headers) { if (!client) throw new TypeError('updateXMBXUsedWeight client is empty'); if (!(client instanceof clients_1.BinanceClient)) throw new TypeError('updateXMBXUsedWeight client is not BinanceClient'); headers = (0, resolveHeaders_1.resolveHeaders)(headers, [info_1.CONST.X_MBX_USED_WEIGHT_HEADER], 'strict'); const weight = (0, safe_parsing_1.parse)(headers[0] && headers[0][1], safe_parsing_1.numberParser); client[info_1.CONST.SYMBOL_X_MBX_USED_WEIGHT] = weight || 0; } exports.updateXMBXUsedWeight = updateXMBXUsedWeight; function updateXMBXUsedWeightAfterCall(client) { return (response) => { const error = response && response.error; const data = response && response.data; const headers = response && response.headers; updateXMBXUsedWeight(client, headers); if (error) throw error; return data; }; } exports.updateXMBXUsedWeightAfterCall = updateXMBXUsedWeightAfterCall; //# sourceMappingURL=updateXMBXUsedWeight.js.map