whitequark / whitequark/ipaddr.js
Using `subnetMatch` in TypeScript?
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 654
- Forks
- 104
- Avg merge
- 3h 18m
- Merged PRs (30d)
- 1
Description
Related to #94. The example given does not work for me:
const rangeList = {
documentationOnly: [ ipaddr.parse('2001:db8::'), 32 ],
tunnelProviders: [
[ ipaddr.parse('2001:470::'), 32 ], // he.net
[ ipaddr.parse('2001:5c0::'), 32 ] // freenet6
]
};
ipaddr.subnetMatch(ipaddr.parse('2001:470:8:66::1'), rangeList, 'unknown'); // => "tunnelProviders"
But.. This works:
const rangeList: {
documentationOnly: [ipaddr.IPv6|ipaddr.IPv4, number];
tunnelProviders: [ipaddr.IPv6|ipaddr.IPv4, number][];
} = {
documentationOnly: [ipaddr.parse('2001:db8::'), 32],
tunnelProviders: [
[ipaddr.parse('2001:470::'), 32], // he.net
[ipaddr.parse('2001:5c0::'), 32] // freenet6
]
};
ipaddr.subnetMatch(ipaddr.parse('2001:470:8:66::1'), rangeList, 'unknown'); // => "tunnelProviders"
I'm not really sure if this is the cleanest solution. Also, it isn't copy/pastable for those using JavaScript instead of TypeScript.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the subnetMatch example described here and the related issue #94, then inspect how the TypeScript types represent the range list. Done means the example works in TypeScript with an appropriate type explanation and remains copy/pastable for JavaScript users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100