UNPKG

@exchanges/binance

Version:

Exchange provider for Binance API

38 lines 2.3 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.compositeIndexSymbolInformationStreams = void 0; const apiCall_1 = require("../../../apiCall"); const safe_parsing_1 = require("@berish/safe-parsing"); function compositeIndexSymbolInformationStreams(client, symbol, callback) { if (!symbol) throw new TypeError('compositeIndexSymbolInformationStreams symbol is empty'); if (typeof symbol !== 'string') throw new TypeError('compositeIndexSymbolInformationStreams symbol is not string'); const parseCallback = callback && ((data, error) => { if (error) return callback(void 0, error); const response = (0, safe_parsing_1.parse)(data, (_a) => { var { e, E, s, p, c } = _a, other = __rest(_a, ["e", "E", "s", "p", "c"]); return (Object.assign({ eventTime: (0, safe_parsing_1.parse)(E, safe_parsing_1.dateParser), symbol: s, price: (0, safe_parsing_1.parse)(p, safe_parsing_1.numberParser), composition: (0, safe_parsing_1.parseArray)(c, (_a) => { var { b, w, W } = _a, other = __rest(_a, ["b", "w", "W"]); return (Object.assign({ baseAsset: b, weightInQuantity: (0, safe_parsing_1.parse)(w, safe_parsing_1.numberParser), weightInPercentage: (0, safe_parsing_1.parse)(W, safe_parsing_1.numberParser) }, other)); }) }, other)); }); return callback(response); }); return (0, apiCall_1.apiCall)({ host: 'usdtM', path: `${symbol.toLowerCase()}@compositeIndex`, securityType: 'SOCKET', client }, parseCallback); } exports.compositeIndexSymbolInformationStreams = compositeIndexSymbolInformationStreams; //# sourceMappingURL=compositeIndexSymbolInformationStreams.js.map