Skip to content

Inline nub helper, drop runtime dependency#54

Open
colinhacks wants to merge 1 commit into
freeall:masterfrom
colinhacks:inline-nub
Open

Inline nub helper, drop runtime dependency#54
colinhacks wants to merge 1 commit into
freeall:masterfrom
colinhacks:inline-nub

Conversation

@colinhacks
Copy link
Copy Markdown

nub is used in a single call site to dedupe the flat list of country names returned by countries(). Inlining a three-line ES5 equivalent lets us drop the runtime dependency without changing behavior or platform requirements.

The local helper uses Array.prototype.filter + Array.prototype.indexOf, both ES5, both already used elsewhere in index.js, so this introduces no new engine requirements.

Tests pass locally — cc.countries().length === 260 continues to hold, which is the assertion that exercises the deduplication path.

The nub module is used in a single call site to dedupe a flat array of
country name strings. Inlining an equivalent three-line ES5 helper lets
us drop the runtime dependency without changing behavior or platform
requirements.

Tests pass locally.
Copilot AI review requested due to automatic review settings May 18, 2026 19:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR removes the external nub dependency and replaces it with an inline implementation to deduplicate arrays.

Changes:

  • Dropped nub from package.json dependencies.
  • Replaced require('nub') with a local nub function in index.js.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
package.json Removes the nub dependency from runtime dependencies.
index.js Adds an inline array-deduplication helper to replace nub.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread index.js
var publishDate = require('./iso-4217-publish-date');

var nub = function(xs) {
return xs.filter(function(x, i) { return xs.indexOf(x) === i; });
Copy link
Copy Markdown
Author

@colinhacks colinhacks May 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation is equivalent to the implementation in the existing nub@0.0.0 package. I'd recommend against a solution that assumes the existence of Set so the code will continue working for any consumer running ES5.

Comment thread index.js
var data = require('./data');
var publishDate = require('./iso-4217-publish-date');

var nub = function(xs) {
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.

2 participants