UNPKG

parse-authors

Version:

Parse a string into an array of objects with `name`, `email` and `url` properties following npm conventions. Useful for the `authors` property in package.json or for parsing an AUTHORS file into an array of authors objects.

20 lines (16 loc) 438 B
/** * parse-authors <https://github.com/assemble/parse-authors> * * Copyright (c) 2014-2016 Jon Schlinkert, contributors. * Licensed under the MIT license. */ 'use strict'; var author = require('parse-author'); module.exports = function(authors) { if (typeof authors === 'string') { authors = authors.trim().split(/[\r\n]+/); } return authors.reduce(function(acc, str) { return acc.concat(author(str)); }, []); };