Options
All
  • Public
  • Public/Protected
  • All
Menu

获取npm包信息

新增于v0.0.21

脚本举例

  import { Npm } from '@tomato-js/api'
  const api = new Npm({
    name:'http-server',
    pages: 3
  })
  (async()=>{
    const info = await getSortedDependentsByStar({
      token:'Your github token'
    });
  // [
  //   {
  //     '@atomist/sdm-core':
  //       { forks: 3,
  //         stars: 6,
  //         watchers: 6,
  //         url: 'github.com/atomist/sdm-core'
  //       }
  //    }
  // ]
  })()
param

配置

param

包名称

param

请求页数

returns

依赖该包的npm包详细信息

Hierarchy

  • Npm

Index

Constructors

constructor

Properties

Private packageName

packageName: string

Private pages

pages: number

Methods

Private _sortInfos

  • _sortInfos(options: SortInfosOptions): {}[]

getDependentsInfo

  • getDependentsInfo(__namedParameters: { concurrency: number; token: string }): Promise<any>
  • 获取npm包依赖包列表完整信息

    新增于v0.0.21

    脚本举例

      import { Npm } from '@tomato-js/api'
      const api = new Npm({
        name:'http-server',
        pages: 3
      })
      (async()=>{
        const info = await getDependentsInfo({
          token:'Your github token'
        });
      // [
      //   {
      //     '@atomist/sdm-core':
      //       { forks: 3,
      //         stars: 6,
      //         watchers: 6,
      //         url: 'github.com/atomist/sdm-core'
      //       }
      //    }
      // ]
      })()
    

    Parameters

    • __namedParameters: { concurrency: number; token: string }
      • concurrency: number
      • token: string

    Returns Promise<any>

    依赖该包的npm包详细信息

getNpmDependents

  • getNpmDependents(__namedParameters: { concurrency: number }): Promise<string[]>
  • 获取npm包被依赖列表

    新增于v0.0.21

    脚本举例

      import { Npm } from '@tomato-js/api'
      const api = new Npm({
        name:'http-server',
        pages: 3
      })
      (async()=>{
        const data = await api.getNpmDependents();
      })()
      //['pack','pack2']

    Parameters

    • __namedParameters: { concurrency: number }
      • concurrency: number

    Returns Promise<string[]>

    依赖该包的队列

getNpmLatestVersion

  • getNpmLatestVersion(packageName: string): Promise<string>
  • 获取npm包最新版本

    新增于v0.0.21

    脚本举例

      import { Npm } from '@tomato-js/api'
      const api = new Npm({
        name:'http-server',
        pages: 3
      })
      (async()=>{
        const version = await api.getNpmRegistryInfo('http-server');
      })()
      //1.2.3

    Parameters

    • packageName: string

      包名称

    Returns Promise<string>

    包最新版本号

getNpmRegistryInfo

  • getNpmRegistryInfo(packageName: string): Promise<any>
  • 获取npm包完整信息

    新增于v0.0.21

    脚本举例

      import { Npm } from '@tomato-js/api'
      const api = new Npm({
        name:'http-server',
        pages: 3
      })
      (async()=>{
        const data = await api.getNpmRegistryInfo();
      })()

    Parameters

    • packageName: string

      包名称

    Returns Promise<any>

    包完整信息

getSortedDependentsByStar

  • getSortedDependentsByStar(__namedParameters: { concurrency: number; token: string }): Promise<{}[]>
  • 获取npm包依赖包按github的star排序

    新增于v0.0.21

    脚本举例

      import { Npm } from '@tomato-js/api'
      const api = new Npm({
        name:'http-server',
        pages: 3
      })
      (async()=>{
        const info = await getSortedDependentsByStar({
          token:'Your github token'
        });
      // [
      //   {
      //     '@atomist/sdm-core':
      //       { forks: 3,
      //         stars: 6,
      //         watchers: 6,
      //         url: 'github.com/atomist/sdm-core'
      //       }
      //    }
      // ]
      })()
    

    Parameters

    • __namedParameters: { concurrency: number; token: string }
      • concurrency: number
      • token: string

    Returns Promise<{}[]>

    依赖该包的npm包详细信息

Generated using TypeDoc