-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathperson.js
More file actions
27 lines (21 loc) · 699 Bytes
/
Copy pathperson.js
File metadata and controls
27 lines (21 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const utils = require('../utils');
const merge = require('../merge');
/**
* Stringify a person object, or array of person objects, such as
* `maintainer`, `collaborator`, `contributor`, and `author`.
*
* @param {Object|Array|String} `val` If an object is passed, it will be converted to a string. If an array of objects is passed, it will be converted to an array of strings.
* @return {String}
* @api public
*/
module.exports = function person(val, key, config, schema) {
merge(config, schema);
if (Array.isArray(val)) {
val = val.map(str => person(str, key, config, schema));
}
if (utils.isObject(val)) {
val = utils.stringify(val);
}
return val;
};