New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

postgres-range

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postgres-range

Range data type parser and serializer for PostgreSQL

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4M
increased by5.4%
Maintainers
1
Weekly downloads
 
Created

What is postgres-range?

The postgres-range npm package is designed to parse and serialize PostgreSQL range types. It supports various operations on range data, such as checking if a range contains a value, if one range contains another, if ranges overlap, and more. This package is particularly useful when working with PostgreSQL databases in Node.js applications that require manipulation or interpretation of range data.

What are postgres-range's main functionalities?

Parsing range strings

This feature allows for the parsing of PostgreSQL range strings into Range objects. The example demonstrates parsing an integer range string.

"const { Range } = require('postgres-range');
const intRange = Range.parse('[1,5)');
console.log(intRange);"

Checking if a range contains a value

This feature enables checking whether a given value is contained within a range. The example shows how to check if the number 3 is within the range [1,5), which returns true, and if the number 5 is within the same range, which returns false.

"const { Range } = require('postgres-range');
const intRange = new Range(1, 5);
console.log(intRange.contains(3)); // true
console.log(intRange.contains(5)); // false"

Serializing range objects to strings

This feature allows for the serialization of Range objects back into PostgreSQL range strings. The example demonstrates serializing a Range object representing the range [1,5).

"const { Range } = require('postgres-range');
const intRange = new Range(1, 5, '[)');
console.log(intRange.toString()); // '[1,5)'"

Other packages similar to postgres-range

FAQs

Package last updated on 29 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc