npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ttech-pub/invest-core

v1.61.0

Published

T-Tech Invest Core package with domain logic

Readme

@ttech-pub/invest-core

Общие примитивы SDK: десятичная арифметика, базовые ошибки, кеш и утилиты ErrorHub. Пакет не ходит в сеть и не содержит клиентов API — его подтягивают остальные пакеты набора.

Документация проекта: https://opensource.tbank.ru/invest/invest-js

Установка

npm install @ttech-pub/invest-core

Decimal

Денежные величины T-Invest API приходят как пара units/nano. Decimal принимает их напрямую или строкой и считает без потерь на big.js.

import { Decimal } from '@ttech-pub/invest-core';

const price = new Decimal({ units: 250, nano: 500000000 }); // 250.5
const qty = new Decimal('4');

price.multiply(qty).toString(); // '1002'
price.toPrimitives(); // { units: 250, nano: 500000000 }

Арифметика: add, subtract, multiply, divide, abs. Сравнение: isZero, isPositive, isNegative, isEqualTo, isGreaterThan, isLessThan, isGreaterThanOrEqual, isLessThanOrEqual. Статические: Decimal.min, Decimal.max. Вывод: toString, toPrimitives.

Ошибки: InputParamsNotValidDecimalError (пустой или некорректный вход), DivisionByZeroDecimalError, CannotConvertToPrimitivesDecimalError, UnknownDecimalError.

Ошибки

BaseError — абстрактный базовый класс всех ошибок SDK: обязательное поле code, необязательные cause, metadata, correlationId и toJSON() для сериализации в логи. ValidationError — готовая реализация для невалидного ввода.

Кеш

LocalTTLCacheProvider — реализация CacheProvider поверх @isaacs/ttlcache. Именно её использует кеш инструментов в gRPC-клиентах.

import { LocalTTLCacheProvider } from '@ttech-pub/invest-core';

const cache = new LocalTTLCacheProvider({ defaultTtl: 30 * 60 * 1000, keyPrefix: 'instruments' });

await cache.set('BBG004730N88', share);
await cache.get('BBG004730N88');
cache.getStats(); // { hits, misses, size, hitRate }

CacheOptions:

| Параметр | Тип | По умолчанию | Значение | | ------------ | -------- | ------------ | ----------------------------------------------------- | | defaultTtl | number | 60000 | Время жизни записи, мс | | maxSize | number | 1000 | Максимум записей; при переполнении вытесняются старые | | keyPrefix | string | '' | Префикс ключа, отделяется двоеточием |

LocalTTLCacheOptions дополнительно пробрасывает в @isaacs/ttlcache поля updateAgeOnGet, checkAgeOnGet (по умолчанию true), updateAgeOnHas, checkAgeOnHas (по умолчанию true), noUpdateTTL, noDisposeOnSet и dispose.

Интерфейс CacheProvider: get, set, has, delete, clear, cleanup, getStats.

ErrorHub

Вспомогательные функции диагностики stream-соединений: маскирование чувствительных данных и сбор контекста. Их вызывают gRPC-клиенты — напрямую из приложения они обычно не нужны. Как включать и отключать диагностику, описано в README проекта.