@clonegod/ttd-core 2.1.12 → 2.1.13

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.
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './token';
11
11
  export * from './trade';
12
12
  export * from './chains';
13
13
  export * from './ws';
14
+ export * from './util';
14
15
  export declare const FAILED = "FAILED";
15
16
  export declare const SUCCESS = "SUCCESS";
16
17
  export declare const NOT_FOUND = "NOT_FOUND";
package/dist/index.js CHANGED
@@ -91,6 +91,7 @@ __exportStar(require("./token"), exports);
91
91
  __exportStar(require("./trade"), exports);
92
92
  __exportStar(require("./chains"), exports);
93
93
  __exportStar(require("./ws"), exports);
94
+ __exportStar(require("./util"), exports);
94
95
  const short = require('short-uuid');
95
96
  const exec = require('util').promisify(require('child_process').exec);
96
97
  exports.FAILED = 'FAILED';
@@ -0,0 +1 @@
1
+ export declare function appendLogWithPeriodicReset(dir: string, filename: string, line: string, hours: number): Promise<void>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.appendLogWithPeriodicReset = appendLogWithPeriodicReset;
13
+ const fs_1 = require("fs");
14
+ let lastResetAtMap = {};
15
+ function appendLogWithPeriodicReset(dir, filename, line, hours) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ var _a;
18
+ const now = Date.now();
19
+ const intervalMs = hours * 60 * 60 * 1000;
20
+ if (!(0, fs_1.existsSync)(dir)) {
21
+ (0, fs_1.mkdirSync)(dir, { recursive: true });
22
+ }
23
+ const filePath = `${dir}/${filename}`;
24
+ const lastResetAt = (_a = lastResetAtMap[filePath]) !== null && _a !== void 0 ? _a : 0;
25
+ if (now - lastResetAt > intervalMs) {
26
+ (0, fs_1.writeFileSync)(filePath, "", "utf8");
27
+ lastResetAtMap[filePath] = now;
28
+ }
29
+ (0, fs_1.appendFileSync)(filePath, line + "\n", "utf8");
30
+ });
31
+ }
@@ -0,0 +1 @@
1
+ export * from './fileutil';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./fileutil"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "2.1.12",
3
+ "version": "2.1.13",
4
4
  "description": "Common types and utilities for trading systems - use `npm run push` to publish",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",