UNPKG

@nodesecure/contact

Version:

Utilities to extract/fetch data on NPM contacts (author, maintainers ..)

30 lines 1.13 kB
// Import Internal Dependencies import { UnlitContact } from "./UnlitContact.class.js"; export class ContactExtractor { highlighted = []; constructor(options) { const { highlight } = options; this.highlighted = structuredClone(highlight); } fromDependencies(dependencies) { const unlitContacts = this.highlighted .map((contact) => new UnlitContact(contact)); for (const [packageName, metadata] of Object.entries(dependencies)) { for (const unlit of unlitContacts) { const isMaintainer = extractMetadataContacts(metadata) .some((contact) => unlit.compareTo(contact)); if (isMaintainer) { unlit.dependencies.add(packageName); } } } return unlitContacts.flatMap((unlit) => (unlit.dependencies.size > 0 ? [unlit.illuminate()] : [])); } } function extractMetadataContacts(metadata) { return [ ...(metadata.author ? [metadata.author] : []), ...metadata.maintainers ]; } //# sourceMappingURL=ContactExtractor.class.js.map