index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. var __importDefault = (this && this.__importDefault) || function (mod) {
  17. return (mod && mod.__esModule) ? mod : { "default": mod };
  18. };
  19. Object.defineProperty(exports, "__esModule", { value: true });
  20. exports.autoDetect = autoDetect;
  21. /* eslint-disable @typescript-eslint/no-var-requires */
  22. const debug_1 = __importDefault(require("debug"));
  23. const darwin_1 = require("./darwin");
  24. const linux_1 = require("./linux");
  25. const win32_1 = require("./win32");
  26. const debug = (0, debug_1.default)('serialport/bindings-cpp');
  27. __exportStar(require("@serialport/bindings-interface"), exports);
  28. __exportStar(require("./darwin"), exports);
  29. __exportStar(require("./linux"), exports);
  30. __exportStar(require("./win32"), exports);
  31. __exportStar(require("./errors"), exports);
  32. /**
  33. * This is an auto detected binding for your current platform
  34. */
  35. function autoDetect() {
  36. switch (process.platform) {
  37. case 'win32':
  38. debug('loading WindowsBinding');
  39. return win32_1.WindowsBinding;
  40. case 'darwin':
  41. debug('loading DarwinBinding');
  42. return darwin_1.DarwinBinding;
  43. default:
  44. debug('loading LinuxBinding');
  45. return linux_1.LinuxBinding;
  46. }
  47. }