npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@142vip/data-source

v0.0.1-alpha.4

Published

通用型数据源,支持多种数据库、API、CSV等形式的数据源管理

Downloads

34

Readme

@142vip/data-source

NPM version

TIPS:没数据源,可视化、数字孪生就是玩单机

介绍

@142vip/data-source模块可以用来连接多种数据源,支持从数据源快速获取数据

安装

# npm
npm install @142vip/data-source
# pnpm
pnpm i @142vip/data-source

简单使用

按照数据来源,将数据源分为CSV型、API型、SQL数据库型三种类型。

新增数据源

定义接口类型

export interface MyDataSourceOptions {
  // coding xxx
}

初始化连接器

import { DataSourceConnector } from '@142vip/data-source'

export class MyDataSource implements DataSourceConnector<MyDataSourceOptions> {
  /**
   * 获取连接数据
   */
  public async getConnectionData(options: MyDataSourceOptions): Promise<DataSourceParseResponse> {
    try {
      // coding xxx
    }
    catch (error) {
      return handlerDataSourceConnectError(VipPostgreSql.name, error)
    }
    finally {
      await pgClient?.end()
    }
  }
}

进一步拓展

基于DataSourceManager接口,封装parseDatatestConnectgetDataBaseNames等常用方法。

/**
 * 自定义数据源
 */
export class MyDataSource implements DataSourceManager {
  /**
   * 解析数据
   */
  public async parseData(): Promise<DataSourceParseResponse> {
    // coding xxx
  }

  /**
   * 测试连接
   */
  public testConnect(): Promise<DataSourceParseResponse> {
    // coding xxx
  }

  /**
   * 获取表名列表
   */
  public getDataBaseNames(): Promise<DataSourceParseResponse<string[]>> {
    // coding xxx
  }

  /**
   * 获取表名列表
   */
  public getTableNames(): Promise<DataSourceParseResponse<DataSourceTable[]>> {
    // coding xxx
  }

  /**
   * 获取表字段列表
   */
  public getTableColumns(tableName: string, schema?: string): Promise<DataSourceParseResponse<DataSourceColumn[]>> {
    // coding xxx
  }
}

参考

证书

MIT

Copyright (c) 2019-present, @142vip 储凡

仅供学习参考,商业使用请保留作者版权信息,作者不保证也不承担任何软件的使用风险。