shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
formatPackageJson
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.package
This function simply take a package.json JSON formatted object and standardize some fields like the “author” one to be sure it is an object at the end, the “contributors” array the same way as the “author” one, etc… Here’s the list of processed actions:
- Transform the string version of the “author” field into an object with the properties “name”, “email” and “url”
- Transform the string version of the “contributors” field into an object with the properties “name”, “email” and “url”
Params
- json*-Object
The json to process
Return
- -Object
The standardized json
Example
import { formatPackageJson } from '@blackbyte/sugar/package';
formatPackageJson({
"author": "Olivier Bossel <olivier.bossel@gmail.com> (https://blackbyte.space)"
}); // => {
"author": {
"name": "Olivier Bossel",
"email": "olivier.bossel@gmail.com",
"url": "https://olivierbossel.com"
}
}Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space