Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/node_modules/npm-api/lib/models/ |
Upload File : |
'use strict'; const Base = require('./base'); const downloads = require('../plugins/downloads'); /** * Repo constructor. Create an instance of an npm repo by repo name. * * ```js * const repo = new Repo('micromatch'); * ``` * * @param {String} `name` Name of the npm repo to get information about. * @name Repo * @api public */ class Repo extends Base { constructor(name) { super(); this.name = name; this.use(downloads()); } /** * Get the repo's published package.json. * * ```js * repo.package() * .then(function(pkg) { * console.log(pkg); * }, function(err) { * console.error(err); * }); * ``` * @return {Promise} Returns the package.json object when promise resolves. * @name .package * @api public */ async package(version = 'latest') { let key = `pkg-${version}`; if (!this.cache.has(key)) { let registry = new this.Registry(); let results = await registry.get(this.name); let pkg = version === 'all' ? results : (results.versions[version] || results.versions[results['dist-tags'][version]]); this.cache.set(key, pkg); } return this.cache.get(key); } /** * Get the repo's published package.json value for the specified version. * * ```js * repo.version('0.2.0') * .then(function(pkg) { * console.log(pkg); * }, function(err) { * console.error(err); * }); * ``` * @param {String} `version` Specific version to retrieve. * @return {Promise} Returns the package.json object for the specified version when promise resolves. * @name .version * @api public */ async version(version) { let pkg = await this.package('all'); if (pkg['dist-tags'][version]) { version = pkg['dist-tags'][version]; } if (!pkg.versions[version]) { return {}; } return pkg.versions[version]; } /** * Get the repo's dependencies for the specified version. * * ```js * repo.dependencies() * .then(function(dependencies) { * console.log(dependencies); * }, function(err) { * console.error(err); * }); * ``` * @param {String} `version` Specific version to retrieve. Defaults to `latest`. * @return {Promise} Returns the dependencies object for the specified version when promise resolves. * @name .dependencies * @api public */ dependencies(version) { return this.prop('dependencies', version); } /** * Get the repo's devDependencies for the specified version. * * ```js * repo.devDependencies() * .then(function(devDependencies) { * console.log(devDependencies); * }, function(err) { * console.error(err); * }); * ``` * @param {String} `version` Specific version to retrieve. Defaults to `latest`. * @return {Promise} Returns the devDependencies object for the specified version when promise resolves. * @name .devDependencies * @api public */ devDependencies(version) { return this.prop('devDependencies', version); } /** * Get the specified property from the repo's package.json for the specified version. * * ```js * repo.prop('author') * .then(function(author) { * console.log(author); * }, function(err) { * console.error(err); * }); * ``` * @param {String} `prop` Name of the property to get. * @param {String} `version` Specific version to retrieve. Defaults to `latest`. * @return {Promise} Returns the property for the specified version when promise resolves. * @name .prop * @api public */ async prop(prop, version = 'latest') { let pkg = await this.version(version); return pkg[prop]; } } /** * Exposes `Repo` */ module.exports = Repo;