當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript npm-registry-client.get函數代碼示例

本文整理匯總了TypeScript中npm-registry-client.get函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript get函數的具體用法?TypeScript get怎麽用?TypeScript get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了get函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: concatMap

        concatMap(options => {
          const subject = new ReplaySubject<NpmRepositoryPackageJson>(1);

          const client = new RegistryClient({
            proxy: {
              http: options[0],
              https: options[1],
            },
          });
          client.log.level = 'silent';
          const params = {
            timeout: 30000,
          };

          client.get(
            fullUrl,
            params,
            (error: object, data: NpmRepositoryPackageJson) => {
            if (error) {
              subject.error(error);
            }

            subject.next(data);
            subject.complete();
          });

          maybeRequest = subject.asObservable();
          npmPackageJsonCache.set(fullUrl.toString(), maybeRequest);

          return maybeRequest;
        }),
開發者ID:iwe7,項目名稱:devkit,代碼行數:31,代碼來源:npm.ts

示例2: concatMap

        concatMap(options => {
          const [
            http,
            https,
            strictSsl,
            cafile,
            token,
            username,
            password,
            alwaysAuth,
          ] = options;

          const subject = new ReplaySubject<NpmRepositoryPackageJson>(1);

          const sslOptions = getNpmClientSslOptions(strictSsl, cafile);

          let auth;
          if (token) {
            auth = { token, alwaysAuth };
          } else if (username) {
            auth = { username, password, alwaysAuth };
          }

          const client = new RegistryClient({
            proxy: { http, https },
            ssl: sslOptions,
          });
          client.log.level = 'silent';
          const params = {
            timeout: 30000,
            auth,
          };

          client.get(
            fullUrl.toString(),
            params,
            (error: object, data: NpmRepositoryPackageJson) => {
            if (error) {
              subject.error(error);
            }

            subject.next(data);
            subject.complete();
          });

          maybeRequest = subject.asObservable();
          npmPackageJsonCache.set(fullUrl.toString(), maybeRequest);

          return maybeRequest;
        }),
開發者ID:fmalcher,項目名稱:angular-cli,代碼行數:50,代碼來源:npm.ts

示例3: concatMap

        concatMap(options => {
          const [
            http,
            https,
            strictSsl,
            cafile,
            token,
            authToken,
            username,
            password,
            email,
            alwaysAuth,
          ] = options;

          const subject = new ReplaySubject<NpmRepositoryPackageJson>(1);

          const sslOptions = getNpmClientSslOptions(strictSsl, cafile);

          const auth: {
            token?: string,
            alwaysAuth?: boolean;
            username?: string;
            password?: string;
            email?: string;
          } = {};

          if (alwaysAuth !== undefined) {
            auth.alwaysAuth = alwaysAuth === 'false' ? false : !!alwaysAuth;
          }

          if (email) {
            auth.email = email;
          }

          if (authToken) {
            auth.token = authToken;
          } else if (token) {
            try {
              // attempt to parse "username:password" from base64 token
              // to enable Artifactory / Nexus-like repositories support
              const delimiter = ':';
              const parsedToken = Buffer.from(token, 'base64').toString('ascii');
              const [extractedUsername, ...passwordArr] = parsedToken.split(delimiter);
              const extractedPassword = passwordArr.join(delimiter);

              if (extractedUsername && extractedPassword) {
                auth.username = extractedUsername;
                auth.password = extractedPassword;
              } else {
                throw new Error('Unable to extract username and password from _auth token');
              }
            } catch (ex) {
              auth.token = token;
            }
          } else if (username) {
            auth.username = username;
            auth.password = password;
          }

          const client = new RegistryClient({
            proxy: { http, https },
            ssl: sslOptions,
          });
          client.log.level = 'silent';
          const params = {
            timeout: 30000,
            auth,
          };

          client.get(
            fullUrl.toString(),
            params,
            (error: object, data: NpmRepositoryPackageJson) => {
            if (error) {
              subject.error(error);
            }

            subject.next(data);
            subject.complete();
          });

          maybeRequest = subject.asObservable();
          npmPackageJsonCache.set(fullUrl.toString(), maybeRequest);

          return maybeRequest;
        }),
開發者ID:baconwaffles,項目名稱:angular-cli,代碼行數:86,代碼來源:npm.ts

示例4: concatMap

        concatMap(options => {
          const [
            http,
            https,
            strictSsl,
            cafile,
            token,
            authToken,
            username,
            password,
            alwaysAuth,
          ] = options;

          const subject = new ReplaySubject<NpmRepositoryPackageJson>(1);

          const sslOptions = getNpmClientSslOptions(strictSsl, cafile);

          const auth: {
            token?: string,
            alwaysAuth?: boolean;
            username?: string;
            password?: string
          } = {};

          if (alwaysAuth !== undefined) {
            auth.alwaysAuth = alwaysAuth === 'false' ? false : !!alwaysAuth;
          }

          if (authToken) {
            auth.token = authToken;
          } else if (token) {
            auth.token = token;
          } else if (username) {
            auth.username = username;
            auth.password = password;
          }

          const client = new RegistryClient({
            proxy: { http, https },
            ssl: sslOptions,
          });
          client.log.level = 'silent';
          const params = {
            timeout: 30000,
            auth,
          };

          client.get(
            fullUrl.toString(),
            params,
            (error: object, data: NpmRepositoryPackageJson) => {
            if (error) {
              subject.error(error);
            }

            subject.next(data);
            subject.complete();
          });

          maybeRequest = subject.asObservable();
          npmPackageJsonCache.set(fullUrl.toString(), maybeRequest);

          return maybeRequest;
        }),
開發者ID:rexebin,項目名稱:angular-cli,代碼行數:64,代碼來源:npm.ts


注:本文中的npm-registry-client.get函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。