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/ |
Upload File : |
'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 define = (obj, name, value) => Reflect.defineProperty(obj, name, { value }); let cache = null; /** * NpmApi constructor. Create an instance to work with maintainer and repository information. * * ```js * let npm = new NpmApi(); * ``` * @name NpmApi * @api public */ class NpmApi { constructor(options = {}) { this.options = { ...options }; this.reset(); define(this, 'List', List); define(this, 'View', View); define(this, 'Repo', Repo); define(this, 'Maintainer', Maintainer); } reset() { cache = new Map(); cache.set('lists', new Map()); cache.set('views', new Map()); cache.set('repos', new Map()); cache.set('maintainers', new Map()); } use(fn) { fn.call(this, this, this.options); } /** * Create a new instance of `View` or get an existing instance to work * with npm couchdb views. * * ```js * var view = npm.view('byUser'); * ``` * * @param {String} `name` Name of the couchdb view to work with. * @return {Object} `View` instance * @name .view * @api public */ view(name) { let views = cache.get('views'); if (views.has(name)) { return views.get(name); } let view = new View(name); views.set(name, view); return view; } /** * Create a new instance of `List` or get an existing instance to work * with npm couchdb list. * * ```js * var list = npm.list('sortCount', 'byUser'); * ``` * * @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 * @name .list * @api public */ list(name, view) { let lists = cache.get('lists'); let viewName = view; if (typeof view === 'object') { viewName = view.name; } let key = `${viewName}.${name}`; if (lists.has(key)) { return lists.get(key); } if (typeof view === 'string') { view = this.view(view); } let list = new List(name, view); lists.set(key, list); return list; } /** * Create an instance of a `repo` to work with. * * ```js * var repo = npm.repo('micromatch'); * ``` * * @param {String} `name` Name of the repo as it's published to npm. * @return {Object} Instance of a `Repo` model to work with. * @name .repo * @api public */ repo(name) { let repos = cache.get('repos'); if (repos.has(name)) { return repos.get(name); } let repo = new Repo(name); repos.set(name, repo); return repo; } /** * Create an instance of a `maintainer` to work with. * * ```js * var maintainer = npm.maintainer('doowb'); * ``` * * @param {String} `name` Npm username of the maintainer. * @return {Object} Instance of a `Maintainer` model to work with. * @name .maintainer * @api public */ maintainer(name) { let maintainers = cache.get('maintainers'); if (maintainers.has(name)) { return maintainers.get(name); } let maintainer = new Maintainer(name); maintainers.set(name, maintainer); return maintainer; } } /** * Exposes `NpmApi` */ module.exports = NpmApi;