Inline nub helper, drop runtime dependency#54
Open
colinhacks wants to merge 1 commit into
Open
Conversation
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.
There was a problem hiding this comment.
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
nubfrompackage.jsondependencies. - Replaced
require('nub')with a localnubfunction inindex.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.
| var publishDate = require('./iso-4217-publish-date'); | ||
|
|
||
| var nub = function(xs) { | ||
| return xs.filter(function(x, i) { return xs.indexOf(x) === i; }); |
Author
There was a problem hiding this comment.
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.
| var data = require('./data'); | ||
| var publishDate = require('./iso-4217-publish-date'); | ||
|
|
||
| var nub = function(xs) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nubis used in a single call site to dedupe the flat list of country names returned bycountries(). 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 inindex.js, so this introduces no new engine requirements.Tests pass locally —
cc.countries().length === 260continues to hold, which is the assertion that exercises the deduplication path.