New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parse-author

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-author - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

41

index.js
/*!
* parse-author <https://github.com/jonschlinkert/parse-author>
*
* Copyright (c) 2014-2016, Jon Schlinkert.
* Licensed under the MIT License.
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
*/

@@ -10,2 +10,4 @@

var regex = require('author-regex');
module.exports = function(str) {

@@ -15,10 +17,29 @@ if (typeof str !== 'string') {

}
var name = str.match(/^([^\(<]+)/);
var url = str.match(/\(([^\)]+)\)/);
var email = str.match(/<([^>]+)>/);
var obj = {};
if (name && name[1].trim()) obj.name = name[1].trim();
if (email && email[1].trim()) obj.email = email[1].trim();
if (url && url[1].trim()) obj.url = url[1].trim();
return obj;
if (!str || !/\w/.test(str)) {
return {};
}
var match = [].concat.apply([], regex().exec(str));
var author = {};
if (match[1]) {
author.name = match[1];
}
for (var i = 2; i < match.length; i++) {
var val = match[i];
if (i % 2 === 0 && val && match[i + 1]) {
if (val.charAt(0) === '<') {
author.email = match[i + 1];
i++;
} else if (val.charAt(0) === '(') {
author.url = match[i + 1];
i++;
}
}
}
return author;
};
{
"name": "parse-author",
"description": "Parse a string into an object 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.",
"version": "1.0.0",
"description": "Parse an author, contributor, maintainer or other 'person' string into an object with name, email and url properties following npm conventions.",
"version": "2.0.0",
"homepage": "https://github.com/jonschlinkert/parse-author",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"contributors": [
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)",
"Sean Lang <slang800@gmail.com> (http://slang.cx)",
"Tim Oram <mitmaro@gmail.com> (http://www.mitmaro.ca)"
],
"repository": "jonschlinkert/parse-author",

@@ -22,5 +27,7 @@ "bugs": {

},
"dependencies": {
"author-regex": "^1.0.0"
},
"devDependencies": {
"gulp-format-md": "^0.1.7",
"mocha": "^2.4.5"
"mocha": "^3.2.0"
},

@@ -30,2 +37,3 @@ "keywords": [

"authors",
"contributor",
"exec",

@@ -48,12 +56,15 @@ "expression",

"verb": {
"run": true,
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"reflinks": [
"verb"
],
"related": {
"list": [
"author-regex",
"parse-authors",
"author-regex",
"stringify-author",

@@ -63,14 +74,9 @@ "stringify-authors"

},
"toc": {
"render": false
},
"run": true,
"layout": "default",
"reflinks": [
"verb"
],
"lint": {
"reflinks": true
},
"tasks": [
"readme"
]
}
}
}

@@ -1,4 +0,4 @@

# parse-author [![NPM version](https://img.shields.io/npm/v/parse-author.svg?style=flat)](https://www.npmjs.com/package/parse-author) [![NPM downloads](https://img.shields.io/npm/dm/parse-author.svg?style=flat)](https://npmjs.org/package/parse-author) [![Build Status](https://img.shields.io/travis/jonschlinkert/parse-author.svg?style=flat)](https://travis-ci.org/jonschlinkert/parse-author)
# parse-author [![NPM version](https://img.shields.io/npm/v/parse-author.svg?style=flat)](https://www.npmjs.com/package/parse-author) [![NPM monthly downloads](https://img.shields.io/npm/dm/parse-author.svg?style=flat)](https://npmjs.org/package/parse-author) [![NPM total downloads](https://img.shields.io/npm/dt/parse-author.svg?style=flat)](https://npmjs.org/package/parse-author) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/parse-author.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/parse-author)
Parse a string into an object 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.
> Parse a string into an object 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.

@@ -10,3 +10,3 @@ ## Install

```sh
$ npm install parse-author --save
$ npm install --save parse-author
```

@@ -17,54 +17,88 @@

```js
var authors = require('parse-author');
var parse = require('parse-author');
```
authors('Jon Schlinkert <jon.schlinkert@sellside.com> (https://github.com/jonschlinkert)');
//=> {name: 'Jon Schlinkert', email: 'jon.schlinkert@sellside.com', url: 'https://github.com/jonschlinkert'}
## Supported formats
Works with a flexible range of formats, any of the properties can be used or missing:
```
Name
Name <email> (url)
Name <email>(url)
Name<email> (url)
Name<email>(url)
Name (url) <email>
Name (url)<email>
Name(url) <email>
Name(url)<email>
Name (url)
Name(url)
Name <email>
Name<email>
<email> (url)
<email>(url)
(url) <email>
(url)<email>
<email>
(url)
```
Any of the properties can be used or missing:
## Examples
```js
authors('')
//=> {}
var author = parse('Jon Schlinkert <jon.schlinkert@sellside.com> (https://github.com/jonschlinkert)');
console.log(author);
//=> {name: 'Jon Schlinkert', email: 'jon.schlinkert@sellside.com', url: 'https://github.com/jonschlinkert'}
authors('Jon Schlinkert (https://github.com/jonschlinkert)');
console.log(parse('Jon Schlinkert (https://github.com/jonschlinkert)'));
//=> {name: 'Jon Schlinkert', url: 'https://github.com/jonschlinkert'}
console.log(parse('Jon Schlinkert <jon.schlinkert@sellside.com>'));
//=> {name: 'Jon Schlinkert', email: 'jon.schlinkert@sellside.com'}
console.log(parse(''));
//=> {}
```
## Related projects
## About
You might also be interested in these projects:
### Related projects
* [author-regex](https://www.npmjs.com/package/author-regex): Regular expression for parsing an `author` string into an object following npm conventions. | [homepage](https://github.com/jonschlinkert/author-regex)
* [parse-authors](https://www.npmjs.com/package/parse-authors): Parse a string into an array of objects with `name`, `email` and `url` properties following… [more](https://www.npmjs.com/package/parse-authors) | [homepage](https://github.com/jonschlinkert/parse-authors)
* [stringify-author](https://www.npmjs.com/package/stringify-author): Stringify an authors object to `name <email> (url)`. | [homepage](https://github.com/jonschlinkert/stringify-author)
* [stringify-authors](https://www.npmjs.com/package/stringify-authors): Converts an author object or array of author objects into an array of strings. Useful… [more](https://www.npmjs.com/package/stringify-authors) | [homepage](https://github.com/jonschlinkert/stringify-authors)
* [author-regex](https://www.npmjs.com/package/author-regex): Regular expression for parsing an `author` string into an object following npm conventions. | [homepage](https://github.com/jonschlinkert/author-regex "Regular expression for parsing an `author` string into an object following npm conventions.")
* [parse-authors](https://www.npmjs.com/package/parse-authors): Parse a string into an array of objects with `name`, `email` and `url` properties following… [more](https://github.com/jonschlinkert/parse-authors) | [homepage](https://github.com/jonschlinkert/parse-authors "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.")
* [stringify-author](https://www.npmjs.com/package/stringify-author): Stringify an authors object to `name <email> (url)`. | [homepage](https://github.com/jonschlinkert/stringify-author "Stringify an authors object to `name <email> (url)`.")
* [stringify-authors](https://www.npmjs.com/package/stringify-authors): Converts an author object or array of author objects into an array of strings. Useful… [more](https://github.com/jonschlinkert/stringify-authors) | [homepage](https://github.com/jonschlinkert/stringify-authors "Converts an author object or array of author objects into an array of strings. Useful for adding authors, maintainers or contributors to documentation, package.json or a readme.")
## Contributing
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/parse-author/issues/new).
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
## Building docs
### Contributors
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
| **Commits** | **Contributor** |
| --- | --- |
| 14 | [slang800](https://github.com/slang800) |
| 12 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [MitMaro](https://github.com/MitMaro) |
```sh
$ npm install verb && npm run docs
```
### Building docs
Or, if [verb](https://github.com/verbose/verb) is installed globally:
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ verb
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
## Running tests
### Running tests
Install dev dependencies:
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install -d && npm test
$ npm install && npm test
```
## Author
### Author

@@ -74,11 +108,11 @@ **Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
## License
### License
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/parse-author/blob/master/LICENSE).
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 13, 2016._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 08, 2017._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc