UNPKG

@ldrick/trade-indicators

Version:
16 lines (15 loc) 502 B
import { Big } from 'big.js'; import { either as E } from 'fp-ts/lib'; import { NotPositiveIntegerError } from '../errors/NotPositiveIntegerError.js'; /** * Safely convert `number` to `Big`. * * @internal */ export const toBig = (value) => E.tryCatch(() => new Big(value), (e) => E.toError(e)); /** * Validate positive Integer. * * @internal */ export const validatePositiveInteger = (period) => period > 0 && Number.isInteger(period) ? E.right(period) : E.left(new NotPositiveIntegerError());