UNPKG

@strong-roots-capital/bybit-api

Version:

TypeScript API for Bybit cryptocurrency exchange

43 lines 1.85 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.unsafeParse = void 0; var E = __importStar(require("fp-ts/Either")); var function_1 = require("fp-ts/function"); /** * Decode value with codec or `throw`. * * Note: you must swear to only call this function at the top-level scope, * i.e. it must run as soon as program execution begins. Otherwise * we risk throwing in the middle of program execution. */ function unsafeParse(codec, value) { var work = function (value) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return return (0, function_1.pipe)(codec.decode(value), E.getOrElseW(function () { throw new Error("ParseError: unable to decode " + value + " into type " + codec.name); })); }; // eslint-disable-next-line @typescript-eslint/no-unsafe-return return value === undefined ? work : work(value); } exports.unsafeParse = unsafeParse; //# sourceMappingURL=unsafe-parse.js.map