UNPKG

@itsmworkbench/utils

Version:

The usual utility functions

25 lines (24 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dropFirstSegments = exports.extractPathFromDescription = void 0; function extractPathFromDescription(input) { // Regular expression to match the pattern .focus?(...) and capture the inner content const regex = /\.focus\?\(([^)]+)\)/g; let match; const parts = []; // Use a loop to find all matches and push the captured groups into the parts array while ((match = regex.exec(input)) !== null) { parts.push(match[1]); } // Join the captured parts with a dot and return the result return parts.join('.'); } exports.extractPathFromDescription = extractPathFromDescription; function dropFirstSegments(input, n) { // Split the input string into segments based on the dot const segments = input.split('.'); // Drop the first n segments and join the remaining segments with a dot const result = segments.slice(n).join('.'); return result; } exports.dropFirstSegments = dropFirstSegments;