Skip to content

Commit

Permalink
jsdoc improvment + explicit path
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmywarting committed Nov 13, 2021
1 parent 54ed799 commit 1605b5d
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion examples/get-maintainer-repos.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const NpmApi = require('../');
const NpmApi = require('../index.js');
const npm = new NpmApi();

run()
Expand Down
2 changes: 1 addition & 1 deletion examples/get-repo-downloads.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const NpmApi = require('../');
const NpmApi = require('../index.js');
const npm = new NpmApi();

run()
Expand Down
2 changes: 1 addition & 1 deletion examples/view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const NpmApi = require('../');
const NpmApi = require('../index.js');
const npm = new NpmApi();

run()
Expand Down
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const List = require('./lib/list');
const View = require('./lib/view');
const Repo = require('./lib/models/repo');
const Maintainer = require('./lib/models/maintainer');
const List = require('./lib/list.js');
const View = require('./lib/view.js');
const Repo = require('./lib/models/repo.js');
const Maintainer = require('./lib/models/maintainer.js');

const define = (obj, name, value) => Reflect.defineProperty(obj, name, { value });
let cache = null;
Expand Down Expand Up @@ -50,7 +50,7 @@ class NpmApi {
* ```
*
* @param {String} `name` Name of the couchdb view to work with.
* @return {Object} `View` instance
* @return {View} `View` instance
* @name .view
* @api public
*/
Expand All @@ -76,7 +76,7 @@ class NpmApi {
*
* @param {String} `name` Name of the couchdb list to work with.
* @param {String|Object} `view` Name or instance of a `view` to work with.
* @return {Object} `List` instance
* @return {List} `List` instance
* @name .list
* @api public
*/
Expand Down Expand Up @@ -110,7 +110,7 @@ class NpmApi {
* ```
*
* @param {String} `name` Name of the repo as it's published to npm.
* @return {Object} Instance of a `Repo` model to work with.
* @return {Repo} Instance of a `Repo` model to work with.
* @name .repo
* @api public
*/
Expand All @@ -134,18 +134,18 @@ class NpmApi {
* ```
*
* @param {String} `name` Npm username of the maintainer.
* @return {Object} Instance of a `Maintainer` model to work with.
* @return {Maintainer} Instance of a `Maintainer` model to work with.
* @name .maintainer
* @api public
*/

maintainer(name) {
let maintainers = cache.get('maintainers');
const maintainers = cache.get('maintainers');
if (maintainers.has(name)) {
return maintainers.get(name);
}

let maintainer = new Maintainer(name);
const maintainer = new Maintainer(name);
maintainers.set(name, maintainer);
return maintainer;
}
Expand Down
10 changes: 6 additions & 4 deletions lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

const url = require('url');
const fetch = require('node-fetch');
const utils = require('./utils');
const config = require('./config');
const utils = require('./utils.js');
const config = require('./config.js');

/** @typedef {import('./view.js')} View */

/**
* List constructor. Create an instance of a list associated with a couchdb list in the npm registry.
Expand All @@ -13,8 +15,8 @@ const config = require('./config');
* ```
*
* @param {String} `name` Name of couchdb list to use.
* @param {Object} `view` Instance of a View to use with the list.
* @returns {Object} instance of `List`
* @param {View} `view` Instance of a View to use with the list.
* @returns {List} instance of `List`
* @name List
* @api public
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/models/base.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const List = require('../list');
const View = require('../view');
const Registry = require('../registry');
const List = require('../list.js');
const View = require('../view.js');
const Registry = require('../registry.js');

const define = (obj, name, value) => Reflect.defineProperty(obj, name, { value });

Expand Down
6 changes: 3 additions & 3 deletions lib/models/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const Base = require('./base');
const utils = require('../utils');
const config = require('../config');
const Base = require('./base.js');
const utils = require('../utils.js');
const config = require('../config.js');

/**
* Maintainer constructor. Create an instance of an npm maintainer by maintainer name.
Expand Down
4 changes: 2 additions & 2 deletions lib/models/repo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const Base = require('./base');
const downloads = require('../plugins/downloads');
const Base = require('./base.js');
const downloads = require('../plugins/downloads.js');

/**
* Repo constructor. Create an instance of an npm repo by repo name.
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/downloads.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const utils = require('../utils');
const utils = require('../utils.js');
const define = (obj, name, value) => Reflect.defineProperty(obj, name, { value });

module.exports = (options = {}) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/registry.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const fetch = require('node-fetch');
const utils = require('./utils');
const config = require('./config');
const utils = require('./utils.js');
const config = require('./config.js');

/**
* Registry constructor. Create an instance of a registry for querying registry.npmjs.org directly.
Expand Down
8 changes: 4 additions & 4 deletions lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

const url = require('url');
const fetch = require('node-fetch');
const utils = require('./utils');
const config = require('./config');
const utils = require('./utils.js');
const config = require('./config.js');

/**
* View constructor. Create an instance of a view associated with a couchdb view in the npm registry.
Expand Down Expand Up @@ -92,8 +92,8 @@ class View {
if (!response.ok) {
throw new Error(response.statusText);
}
response.body.pipe(stream)
}).catch(e => stream.emit('error', e))
response.body.pipe(stream);
}).catch(e => stream.emit('error', e));
return stream;
}

Expand Down

0 comments on commit 1605b5d

Please sign in to comment.