import _ from 'lodash' ; export type DiscoveredUrlProcessor = typeof discoveredUrlProcessor ; export function discoveredUrlProcessor ( discoveredUrls , deepScanDiscoveryLimit , knownUrls ? ) { if ( _ . isNil ( discoveredUrls ) ) { return [ ] ; } let processedUrls = discoveredUrls ; if ( ! _ . isNil ( knownUrls ) ) { processedUrls = removeUrlsFromList ( discoveredUrls , knownUrls ) ; } return limitNumUrls ( processedUrls , getUrlLimit ( deepScanDiscoveryLimit , knownUrls ) ) ; } function removeUrlsFromList ( urlList , removeUrls ) { return _ . pullAll ( urlList , removeUrls ) ; } function limitNumUrls ( urlList , numUrls ) { return _ . take ( urlList , numUrls ) ; } function getUrlLimit ( deepScanDiscoveryLimit , knownUrls ? ) { const numKnownPages = _ . isNil ( knownUrls ) ? 0 : knownUrls . length ; return Math . max ( deepScanDiscoveryLimit - numKnownPages , 0 ) ; }