UNPKG

node-thermal-printer

Version:

Print on Epson, Star, Tranca, Daruma, Brother and Custom thermal printers with Node.js

22 lines (18 loc) 605 B
function getInterface (uri, options, driver) { const networkRegex = /^tcp:\/\/([^/:]+)(?::(\d+))?\/?$/i; const printerRegex = /^printer:([^/]+)(?:\/([\w-]*))?$/i; const net = networkRegex.exec(uri); const printer = printerRegex.exec(uri); if (typeof uri === 'object') { return uri; } if (net) { const Network = require('./network'); return new Network(net[1], net[2], options); } if (printer) { const Printer = require('./printer'); return new Printer(printer[1], driver); } const File = require('./file'); return new File(uri); } module.exports = getInterface;