MCPcopy
hub / github.com/jsdoc/jsdoc / constructor

Method constructor

lib/jsdoc/package.js:69–255  ·  view source on GitHub ↗

* @param {string} json - The contents of the `package.json` file.

(json)

Source from the content-addressed store, hash-verified

67 * @param {string} json - The contents of the `package.json` file.
68 */
69 constructor(json) {
70 let packageInfo;
71
72 /**
73 * The string identifier that is shared by all `Package` objects.
74 *
75 * @readonly
76 * @default
77 * @type {string}
78 */
79 this.kind = 'package';
80
81 try {
82 packageInfo = JSON.parse(stripBom.strip(json) || '{}');
83 }
84 catch (e) {
85 logger.error('Unable to parse the package file: %s', e.message);
86 packageInfo = {};
87 }
88
89 if (packageInfo.name) {
90 /**
91 * The package name.
92 *
93 * @type {string}
94 */
95 this.name = packageInfo.name;
96 }
97
98 /**
99 * The unique longname for this `Package` object.
100 *
101 * @type {string}
102 */
103 this.longname = `${this.kind}:${this.name}`;
104
105 if (packageInfo.author) {
106 /**
107 * The author of this package. Contains either a
108 * {@link module:jsdoc/package.Package~PersonInfo PersonInfo} object or a string with
109 * information about the author.
110 *
111 * @type {(module:jsdoc/package.Package~PersonInfo|string)}
112 * @since 3.3.0
113 */
114 this.author = packageInfo.author;
115 }
116
117 if (packageInfo.bugs) {
118 /**
119 * Information about where to report bugs in the project. May contain a URL, a string, or an
120 * object with more detailed information.
121 *
122 * @type {(string|module:jsdoc/package.Package~BugInfo)}
123 * @since 3.3.0
124 */
125 this.bugs = packageInfo.bugs;
126 }

Callers

nothing calls this directly

Calls 2

getLicensesFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected