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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nv-pg-decode-data-buf

v1.0.4

Published

本库提供了解析PostgreSQL二进制格式的各种数据类型的功能,包括基本类型、一维数组和多维数组。 目的是避免在后端传输过程中不必要的 JSON 序列化/反序列化

Readme

PostgreSQL 二进制数据解析库

本库提供了解析PostgreSQL二进制格式的各种数据类型的功能,包括基本类型、一维数组和多维数组。 目的是避免在后端传输过程中不必要的 JSON 序列化/反序列化

此库供前端使用

// 后端需要配合libpg 的c++绑定 // 后端入参 resultFormat = 1 => binary
// length 后端可以直接从libpq返回中获取 1
//
// 后端传给前端 type@oid length@int32, Buffer字节 // 前端自己解析 //

多维数组支持

所有的 xxx_ary 函数已经内置支持多维数组解析。PostgreSQL在二进制表示中存储了数组的维度信息,我们的解析器会相应地重构出多维数组结构。

使用示例

// 解析一个二维int4数组
const result = int4_ary(dataView, offset, length);

// 假设原始数据是一个2x3的数组[[1,2,3],[4,5,6]]
console.log(result); // 输出: [[1,2,3],[4,5,6]]

// 访问第二行第三列的元素
console.log(result[1][2]); // 输出: 6

支持的多维数组类型

库支持所有PostgreSQL数据类型的多维数组,包括但不限于:

  • 数值类型: int2_ary, int4_ary, int8_ary, float4_ary, float8_ary, numeric_ary
  • 文本类型: char_n_ary, str_like_ary (包括text和varchar ,varchar(n),xml)
  • 二进制类型: bytea_ary, bit_n_ary
  • 日期时间类型:date_ary, time_ary, timestamp_ary
  • JSON类型: json_ary, jsonb_ary
  • 网络类型: inet_ary, cidr_ary, macaddr_ary
  • 几何类型: point_ary, line_ary, polygon_ary ....等
  • 范围类型: int4range_ary, daterange_ary ....等

无需额外的函数,这些函数已经能够正确处理任意维度的数组。

API

    {
      _array: [Function (anonymous)] { reshapeArray: [Function: reshapeArray] },
      _range: [Function (anonymous)],
      bytea: [Function: bytea],
      bytea_ary: [Function: bytea_ary],
      bit_n: [Function: bit_n],
      bit_n_ary: [Function: bit_n_ary],
      char_n: [Function: char_n],
      char_n_ary: [Function: char_n_ary],
      str_like: [Function: str_like],
      str_like_ary: [Function: str_like_ary],
      jsonb: [Function: jsonb],
      jsonb_ary: [Function: jsonb_ary],
      json: [Function: json],
      json_ary: [Function: json_ary],
      xml: [Function: xml],
      xml_ary: [Function: xml_ary],
      bool: [Function: bool],
      bool_ary: [Function: bool_ary],
      int2: [Function: int2],
      int2_ary: [Function: int2_ary],
      int4: [Function: int4],
      int4_ary: [Function: int4_ary],
      int8: [Function: int8],
      int8_ary: [Function: int8_ary],
      float4: [Function: float4],
      float4_ary: [Function: float4_ary],
      float8: [Function: float8],
      float8_ary: [Function: float8_ary],
      numeric: [Function: numeric],
      numeric_ary: [Function: numeric_ary],
      date: [Function: date],
      date_ary: [Function: date_ary],
      time: [Function: time],
      time_ary: [Function: time_ary],
      timetz: [Function: timetz],
      timetz_ary: [Function: timetz_ary],
      timestamp: [Function: timestamp],
      timestamp_ary: [Function: timestamp_ary],
      interval: [Function: interval],
      interval_ary: [Function: interval_ary],
      uuid: [Function: uuid],
      uuid_ary: [Function: uuid_ary],
      inet: [Function: inet],
      inet_ary: [Function: inet_ary],
      cidr: [Function: cidr],
      cidr_ary: [Function: cidr_ary],
      macaddr: [Function: macaddr],
      macaddr_ary: [Function: macaddr_ary],
      money: [Function: money],
      money_ary: [Function: money_ary],
      enums: [Function: enums],
      enums_ary: [Function: enums_ary],
      point: [Function: point],
      point_ary: [Function: point_ary],
      line: [Function: line],
      line_ary: [Function: line_ary],
      lseg: [Function: lseg],
      lseg_ary: [Function: lseg_ary],
      path: [Function: path],
      path_ary: [Function: path_ary],
      polygon: [Function: polygon],
      polygon_ary: [Function: polygon_ary],
      circle: [Function: circle],
      circle_ary: [Function: circle_ary],
      int4range: [Function: int4range],
      int4range_ary: [Function: int4range_ary],
      int8range: [Function: int8range],
      int8range_ary: [Function: int8range_ary],
      numrange: [Function: numrange],
      numrange_ary: [Function: numrange_ary],
      tsrange: [Function: tsrange],
      tsrange_ary: [Function: tsrange_ary],
      daterange: [Function: daterange],
      daterange_ary: [Function: daterange_ary],
      tsvector: [Function: tsvector],
      tsvector_ary: [Function: tsvector_ary],
      tsquery: [Function: tsquery],
      tsquery_ary: [Function: tsquery_ary]
    }