Skip to content

refactor: updated and refactored for esm using latest npm libraries #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

timint
Copy link

@timint timint commented Jul 12, 2025

Leaving this library better than I found it.

  • Refactored for ESM
  • Updated and solved vulnerable dependencies
  • Updated build tools to latest config standards
  • Polished and modernized code where needed
  • Updated all tests to conform with new code

Benchmark results BEFORE:

Started: lookup
tangerine.lookup POST with caching using Cloudflare x 81.31 ops/sec ±195.93% (76 runs sampled)
tangerine.lookup POST without caching using Cloudflare x 155 ops/sec ±3.50% (70 runs sampled)
tangerine.lookup GET with caching using Cloudflare x 229,002 ops/sec ±2.29% (80 runs sampled)
tangerine.lookup GET without caching using Cloudflare x 200 ops/sec ±1.01% (77 runs sampled)
dns.promises.lookup with caching using Cloudflare x 9,104,364 ops/sec ±2.17% (77 runs sampled)
dns.promises.lookup without caching using Cloudflare x 4,753 ops/sec ±5.24% (72 runs sampled)
Fastest without caching is: dns.promises.lookup without caching using Cloudflare

Started: resolve
tangerine.resolve POST with caching using Cloudflare x 566 ops/sec ±195.91% (76 runs sampled)
tangerine.resolve POST without caching using Cloudflare x 178 ops/sec ±1.25% (75 runs sampled)
tangerine.resolve GET with caching using Cloudflare x 1,246,098 ops/sec ±1.70% (82 runs sampled)
tangerine.resolve GET without caching using Cloudflare x 173 ops/sec ±1.08% (71 runs sampled)
tangerine.resolve POST with caching using Google x 1,251,376 ops/sec ±1.57% (78 runs sampled)
tangerine.resolve POST without caching using Google x 107 ops/sec ±1.17% (75 runs sampled)
tangerine.resolve GET with caching using Google x 1,255,991 ops/sec ±2.21% (77 runs sampled)
tangerine.resolve GET without caching using Google x 110 ops/sec ±1.94% (80 runs sampled)
resolver.resolve with caching using Cloudflare x 7,586,061 ops/sec ±2.98% (71 runs sampled)
resolver.resolve without caching using Cloudflare x 206 ops/sec ±1.93% (72 runs sampled)
Fastest without caching is: resolver.resolve without caching using Cloudflare

Started: reverse
tangerine.reverse GET with caching x 553 ops/sec ±195.53% (73 runs sampled)
tangerine.reverse GET without caching x 195 ops/sec ±1.58% (74 runs sampled)
resolver.reverse with caching x 7,890,730 ops/sec ±3.13% (72 runs sampled)
resolver.reverse without caching x 202 ops/sec ±1.57% (69 runs sampled)
dns.promises.reverse with caching x 8,517,471 ops/sec ±1.42% (75 runs sampled)
dns.promises.reverse without caching x 205 ops/sec ±1.38% (71 runs sampled)
Fastest without caching is: dns.promises.reverse without caching, resolver.reverse without caching

Benchmark results AFTER:

Started: lookup
tangerine.lookup POST with caching using Cloudflare x 584 ops/sec ±195.45% (73 runs sampled)
tangerine.lookup POST without caching using Cloudflare x 182 ops/sec ±1.79% (73 runs sampled)
tangerine.lookup GET with caching using Cloudflare x 224,403 ops/sec ±1.46% (83 runs sampled)
tangerine.lookup GET without caching using Cloudflare x 186 ops/sec ±1.28% (70 runs sampled)
dns.promises.lookup with caching using Cloudflare x 9,039,409 ops/sec ±4.04% (73 runs sampled)
dns.promises.lookup without caching using Cloudflare x 4,767 ops/sec ±5.99% (73 runs sampled)
Fastest without caching is: dns.promises.lookup without caching using Cloudflare

Started: resolve
tangerine.resolve POST with caching using Cloudflare x 664 ops/sec ±195.89% (79 runs sampled)
tangerine.resolve POST without caching using Cloudflare x 202 ops/sec ±1.88% (71 runs sampled)
tangerine.resolve GET with caching using Cloudflare x 1,226,500 ops/sec ±1.50% (79 runs sampled)
tangerine.resolve GET without caching using Cloudflare x 180 ops/sec ±1.35% (75 runs sampled)
tangerine.resolve POST with caching using Google x 1,212,057 ops/sec ±1.55% (81 runs sampled)
tangerine.resolve POST without caching using Google x 111 ops/sec ±1.98% (72 runs sampled)
tangerine.resolve GET with caching using Google x 1,197,579 ops/sec ±2.44% (78 runs sampled)
tangerine.resolve GET without caching using Google x 111 ops/sec ±0.62% (78 runs sampled)
resolver.resolve with caching using Cloudflare x 7,879,187 ops/sec ±2.90% (74 runs sampled)
resolver.resolve without caching using Cloudflare x 215 ops/sec ±1.42% (76 runs sampled)
Fastest without caching is: resolver.resolve without caching using Cloudflare

Started: reverse
tangerine.reverse GET with caching x 619 ops/sec ±195.69% (78 runs sampled)
tangerine.reverse GET without caching x 198 ops/sec ±1.17% (76 runs sampled)
resolver.reverse with caching x 8,534,229 ops/sec ±1.67% (77 runs sampled)
resolver.reverse without caching x 212 ops/sec ±1.40% (75 runs sampled)
dns.promises.reverse with caching x 8,404,110 ops/sec ±1.74% (76 runs sampled)
dns.promises.reverse without caching x 211 ops/sec ±1.22% (73 runs sampled)
Fastest without caching is: resolver.reverse without caching, dns.promises.reverse without caching

Copy link

socket-security bot commented Jul 12, 2025

index.js Outdated
Comment on lines 28 to 29
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

This comment was marked as abuse.

index.js Outdated
Comment on lines 71 to 76
// Dynamically import dohdec
let dohdec;
// eslint-disable-next-line unicorn/prefer-top-level-await
import('dohdec').then((obj) => {
dohdec = obj;
import('dohdec').then((object) => {
dohdec = object;
});

This comment was marked as abuse.

SukkaW

This comment was marked as abuse.

@titanism titanism closed this Aug 20, 2025
@titanism titanism reopened this Aug 20, 2025
@titanism
Copy link
Contributor

Agreed, we are CJS only here. Additionally I'm wondering why the staggering test benchmark differences. Doesn't seem accurate. What was the underlying package or change that brought the differences?

@timint timint requested a review from SukkaW August 20, 2025 23:55
@timint
Copy link
Author

timint commented Aug 21, 2025

Feel free to do what you want with it. I have no more use for it. I turned down paid assignments to play with this. And considering that my time invested, and sharing the work seemed to upset people here. I'm not interested in providing any more of my time.

you are creating shit loads of un-necessary format changes.

That's an absolute dick comment. Are you trying to be productive with that attitude? Go wash your mouth.

@timint
Copy link
Author

timint commented Aug 21, 2025

You gotta try something, and I don't think attitude is gonna get you far.
image

@titanism
Copy link
Contributor

I'm not sure who @SukkaW is but we've banned them. Apologies that other users gave negative comments to your positive PR. My only question was what was the source do you think for the benchmark differences. 😄

@timint
Copy link
Author

timint commented Aug 21, 2025

Thank you @titanism . I think you did the right thing and everyone a favour.

So, my time doing this was limited and I didn't upscale the amount of work I put in. I'm sharing the work as-is hoping it might save someone time. I don't mind if you wanna make some adjustments before adopting, it or just use bits and pieces. I see projects commonly moving towards ESM and I think libraries are future proof that way. But I agree they should be backwards compatible with CommonJS and that needs to be added to this PR.

The tests were both carried out from my local machine. One for the PR and one for 1.6.0. I would recommend anyone to run their own tests, multiple times to get some kind of average. What's key here is the results are unique to the machine running it.

The main reason I refactored this was due to the high amount of vulnerable and abandoned libraries it included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants