/usr/local/lib/node_modules/pm2/node_modules/ip-address/src/v6
NameSizeModeActions
constants.ts23790644editdlrm
helpers.ts14640644editdlrm
regular-expressions.ts25290644editdlrm
Edit: /usr/local/lib/node_modules/pm2/node_modules/ip-address/src/v6/helpers.ts (1464B)
import { sprintf } from 'sprintf-js'; /** * @returns {String} the string with all zeroes contained in a */ export function spanAllZeroes(s: string): string { return s.replace(/(0+)/g, '$1'); } /** * @returns {String} the string with each character contained in a */ export function spanAll(s: string, offset: number = 0): string { const letters = s.split(''); return letters .map( (n, i) => sprintf( '%s', n, i + offset, spanAllZeroes(n) ) // XXX Use #base-2 .value-0 instead? ) .join(''); } function spanLeadingZeroesSimple(group: string): string { return group.replace(/^(0+)/, '$1'); } /** * @returns {String} the string with leading zeroes contained in a */ export function spanLeadingZeroes(address: string): string { const groups = address.split(':'); return groups.map((g) => spanLeadingZeroesSimple(g)).join(':'); } /** * Groups an address * @returns {String} a grouped address */ export function simpleGroup(addressString: string, offset: number = 0): string[] { const groups = addressString.split(':'); return groups.map((g, i) => { if (/group-v4/.test(g)) { return g; } return sprintf( '%s', i + offset, spanLeadingZeroesSimple(g) ); }); }