index.js 568 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. /**
  3. * Xpipe - class consisting of only static methods
  4. * @class
  5. */
  6. class Xpipe {
  7. /**
  8. * Return a cross-platform IPC path
  9. * @return {string}
  10. */
  11. static eq(path) {
  12. const prefix = Xpipe.prefix;
  13. if (prefix.endsWith('/') && path.startsWith('/')) {
  14. return prefix + path.substr(1);
  15. }
  16. return prefix + path;
  17. }
  18. /**
  19. * Returns the prefix on Windows and empty string otherwise
  20. * @return {string}
  21. */
  22. static get prefix() {
  23. return process.platform === 'win32' ? '//./pipe/' : '';
  24. }
  25. }
  26. module.exports = Xpipe;