willemmulder / Diont

Easy Service Discovery on Local Networks in 100% pure Javascript / Typescript
43 stars 6 forks source link

Typescript support? #5

Closed kennarddh closed 1 year ago

willemmulder commented 1 year ago

Good idea; feel free to create a PR and I'll merge it!

kennarddh commented 1 year ago

Should I rewrite the lib or create dts file?

willemmulder commented 1 year ago

I'd say that the best option would be to rewrite it in Typescript, then export the JS file and types to a /lib folder, and ensure that that is used when publishing to NPM. I just found this guide that has the same idea: https://itnext.io/step-by-step-building-and-publishing-an-npm-typescript-package-44fe7164964c. Would that work?

kennarddh commented 1 year ago

Ok. I'll try it.

kennarddh commented 1 year ago

What is the use of the toString function?

const socket = dgram.createSocket({
    type: 'udp4',
    reuseAddr: true,
    toString: function () {
        return 'udp4'
    },
})

Typescript throw error because toString doesn't exist in dgram.createSocket options

willemmulder commented 1 year ago

Wow, amazing work on the PR! I have time on friday to look at it, test it and hopefully merge it. Thanks so far; it's appreciated!

willemmulder commented 1 year ago

Quick update: it's going to be tomorrow. Too much going on today :-)

I'll let you know!

willemmulder commented 1 year ago

As mentioned on the PR: looks good; thanks for the effort and the nice optimizations/cleanups here and there! I'll publish in a minute.

willemmulder commented 1 year ago

Just published!