source: node_modules/ip-address/dist/v6/helpers.js@ 81bc7da

finki-main main
Last change on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[81bc7da]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.spanAllZeroes = spanAllZeroes;
4exports.spanAll = spanAll;
5exports.spanLeadingZeroes = spanLeadingZeroes;
6exports.simpleGroup = simpleGroup;
7/**
8 * @returns {String} the string with all zeroes contained in a <span>
9 */
10function spanAllZeroes(s) {
11 return s.replace(/(0+)/g, '<span class="zero">$1</span>');
12}
13/**
14 * @returns {String} the string with each character contained in a <span>
15 */
16function spanAll(s, offset = 0) {
17 const letters = s.split('');
18 return letters
19 .map((n, i) => `<span class="digit value-${n} position-${i + offset}">${spanAllZeroes(n)}</span>`)
20 .join('');
21}
22function spanLeadingZeroesSimple(group) {
23 return group.replace(/^(0+)/, '<span class="zero">$1</span>');
24}
25/**
26 * @returns {String} the string with leading zeroes contained in a <span>
27 */
28function spanLeadingZeroes(address) {
29 const groups = address.split(':');
30 return groups.map((g) => spanLeadingZeroesSimple(g)).join(':');
31}
32/**
33 * Groups an address
34 * @returns {String} a grouped address
35 */
36function simpleGroup(addressString, offset = 0) {
37 const groups = addressString.split(':');
38 return groups.map((g, i) => {
39 if (/group-v4/.test(g)) {
40 return g;
41 }
42 return `<span class="hover-group group-${i + offset}">${spanLeadingZeroesSimple(g)}</span>`;
43 });
44}
45//# sourceMappingURL=helpers.js.map
Note: See TracBrowser for help on using the repository browser.