MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 19 lines 857 B view raw
1import { parse } from 'node:url'; 2 3function assert(condition, message) { 4 if (!condition) throw new Error(message); 5} 6 7const tcp = parse('tcp://localhost:4321'); 8assert(tcp, 'expected parse() to return a value for tcp:// URLs'); 9assert(tcp.protocol === 'tcp:', `expected tcp protocol, got ${tcp && tcp.protocol}`); 10assert(tcp.hostname === 'localhost', `expected localhost hostname, got ${tcp && tcp.hostname}`); 11assert(tcp.port === '4321', `expected 4321 port, got ${tcp && tcp.port}`); 12 13const unix = parse('unix:/tmp/ant-test.sock'); 14assert(unix, 'expected parse() to return a value for unix: URLs'); 15assert(unix.protocol === 'unix:', `expected unix protocol, got ${unix && unix.protocol}`); 16assert(unix.pathname === '/tmp/ant-test.sock', 17 `expected unix pathname, got ${unix && unix.pathname}`); 18 19console.log('node:url parse named export test passed');