Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cidr-tools

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cidr-tools - npm Package Compare versions

Comparing version 6.0.1 to 6.1.0

14

index.js

@@ -25,14 +25,18 @@ import ipRegex from "ip-regex";

function doNormalize(cidr) {
function doNormalize(cidr, {compress = true} = {}) {
const {start, prefix, single, version} = parse(cidr);
if (!single) { // cidr
// set network address to first address
return `${normalizeIp(stringifyIp({number: start, version}))}/${prefix}`;
return `${normalizeIp(stringifyIp({number: start, version}), {compress})}/${prefix}`;
} else { // single ip
return normalizeIp(cidr);
return normalizeIp(cidr, {compress});
}
}
export function normalize(cidr) {
return Array.isArray(cidr) ? cidr.map(doNormalize) : doNormalize(cidr);
export function normalize(cidr, {compress = true} = {}) {
if (Array.isArray(cidr)) {
return cidr.map(entry => normalize(entry, {compress}));
} else {
return doNormalize(cidr, {compress});
}
}

@@ -39,0 +43,0 @@

{
"name": "cidr-tools",
"version": "6.0.1",
"version": "6.1.0",
"author": "silverwind <me@silverwind.io>",

@@ -22,3 +22,3 @@ "description": "Tools to work with IPv4 and IPv6 CIDR network lists",

"cidr-regex": "4.0.3",
"ip-bigint": "7.0.2",
"ip-bigint": "7.1.0",
"ip-regex": "5.0.0",

@@ -32,4 +32,4 @@ "string-natural-compare": "3.0.1"

"versions": "11.0.1",
"vitest": "0.31.3"
"vitest": "0.31.4"
}
}

@@ -63,8 +63,11 @@ # cidr-tools

### normalize(networks)
### normalize(networks, [opts])
- `networks` *String* or *Array*: One or more CIDR or IP address.
Returns a string or array (depending on input) with a normalized representation of IPs or CIDRs. Will not include a prefix on single IPs.
Returns a string or array (depending on input) with a normalized representation. Will not include a prefix on single IPs.
`opts`: Options `Object`
- `compress`: Whether to compress the IP. For IPv6, this means the "best representation" all-lowercase shortest possible form. Default: `true`.
© [silverwind](https://github.com/silverwind), distributed under BSD licence.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc