All files / src index.ts

44.44% Statements 12/27
16.67% Branches 1/6
100% Functions 5/5
37.5% Lines 9/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 408x     8x         8x 8x                     8x 8x                         8x 8x     49x  
import { TonClient } from "@ton-client-ts/core";
 
let binaryLibraryFile: string;
switch (process.platform) {
  case 'linux':
    binaryLibraryFile = 'tonclient-linux.node';
    break;
  case 'darwin':
    binaryLibraryFile = 'tonclient-mac.node';
    break;
  case 'win32':
    binaryLibraryFile = 'tonclient-win.node';
    break;
  default:
    console.error(`Unsupported platform '${process.platform}'!`);
    binaryLibraryFile = 'unsupported';
    break;
}
 
let library: typeof TonClient;
try {
  library = require(`./${binaryLibraryFile}`);
} catch (error) {
  const fs = require("fs");
  const os = require("os");
  const path = require("path");
  let addonPath = path.resolve(__dirname, binaryLibraryFile);
  if (fs.existsSync(addonPath)) {
    throw error;
  }
  addonPath = path.resolve(os.homedir(), binaryLibraryFile);
  library = require(addonPath);
}
 
(async () => {
  TonClient.loadBinaryLibrary((): Promise<any> => new Promise((res) => res(library)));
})();
 
export { TonClient };