@grind-t/tinkoff-invest-api 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/converters/index.ts
21
+ var converters_exports = {};
22
+ __export(converters_exports, {
23
+ tInvestMoney: () => tInvestMoney,
24
+ tInvestNumber: () => tInvestNumber,
25
+ tInvestQuotation: () => tInvestQuotation
26
+ });
27
+ module.exports = __toCommonJS(converters_exports);
28
+
29
+ // src/converters/t-invest-quotation.ts
30
+ function tInvestQuotation(value) {
31
+ const sign = value < 0 ? -1 : 1;
32
+ const absValue = Math.abs(value);
33
+ const units = Math.floor(absValue);
34
+ const nano = Math.round((absValue - units) * 1e9);
35
+ return {
36
+ $typeName: "tinkoff.public.invest.api.contract.v1.Quotation",
37
+ units: BigInt(sign * units),
38
+ nano: sign * nano
39
+ };
40
+ }
41
+
42
+ // src/converters/t-invest-money.ts
43
+ function tInvestMoney(value, currency) {
44
+ const { units, nano } = tInvestQuotation(value);
45
+ return {
46
+ $typeName: "tinkoff.public.invest.api.contract.v1.MoneyValue",
47
+ units,
48
+ nano,
49
+ currency
50
+ };
51
+ }
52
+
53
+ // src/converters/t-invest-number.ts
54
+ function tInvestNumber(value) {
55
+ return Number(value.units) + value.nano / 1e9;
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ tInvestMoney,
60
+ tInvestNumber,
61
+ tInvestQuotation
62
+ });
@@ -0,0 +1,3 @@
1
+ export { tInvestMoney } from '../_tsup-dts-rollup.cjs';
2
+ export { tInvestNumber } from '../_tsup-dts-rollup.cjs';
3
+ export { tInvestQuotation } from '../_tsup-dts-rollup.cjs';
@@ -0,0 +1,3 @@
1
+ export { tInvestMoney } from '../_tsup-dts-rollup.js';
2
+ export { tInvestNumber } from '../_tsup-dts-rollup.js';
3
+ export { tInvestQuotation } from '../_tsup-dts-rollup.js';
@@ -0,0 +1,33 @@
1
+ // src/converters/t-invest-quotation.ts
2
+ function tInvestQuotation(value) {
3
+ const sign = value < 0 ? -1 : 1;
4
+ const absValue = Math.abs(value);
5
+ const units = Math.floor(absValue);
6
+ const nano = Math.round((absValue - units) * 1e9);
7
+ return {
8
+ $typeName: "tinkoff.public.invest.api.contract.v1.Quotation",
9
+ units: BigInt(sign * units),
10
+ nano: sign * nano
11
+ };
12
+ }
13
+
14
+ // src/converters/t-invest-money.ts
15
+ function tInvestMoney(value, currency) {
16
+ const { units, nano } = tInvestQuotation(value);
17
+ return {
18
+ $typeName: "tinkoff.public.invest.api.contract.v1.MoneyValue",
19
+ units,
20
+ nano,
21
+ currency
22
+ };
23
+ }
24
+
25
+ // src/converters/t-invest-number.ts
26
+ function tInvestNumber(value) {
27
+ return Number(value.units) + value.nano / 1e9;
28
+ }
29
+ export {
30
+ tInvestMoney,
31
+ tInvestNumber,
32
+ tInvestQuotation
33
+ };