Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

block-sequence-postgres

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

block-sequence-postgres - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

_config.yml

7

index.js

@@ -8,5 +8,8 @@ var debug = require('debug')('block-sequence:postgres')

var path = require('path')
var bigInt = require('big-integer')
module.exports = function init(config, cb) {
if (typeof Promise === 'undefined') global.Promise = require('promise-polyfill')
if (Number.MAX_SAFE_INTEGER === undefined) Number.MAX_SAFE_INTEGER = 9007199254740991
if (arguments.length === 1) return init({}, arguments[0])

@@ -80,3 +83,5 @@ if (!config.url) return cb(new Error('url is required'))

// Because value is a BIGINT which could execeed Number.MAX_SAFE_INTEGER postgres returns a string.
cb(err, { name: record.name, value: parseInt(record.value, 10), metadata: metadata })
var value = bigInt(record.value)
if (value.greater(Number.MAX_SAFE_INTEGER)) return cb(new Error('Sequence value exceeds Number.MAX_SAFE_INTEGER'))
cb(err, { name: record.name, value: value.toJSNumber(), metadata: metadata })
})

@@ -83,0 +88,0 @@ }

32

package.json
{
"name": "block-sequence-postgres",
"version": "0.1.1",
"version": "1.0.0",
"description": "A Postgres implementation of block-sequence",
"main": "index.js",
"scripts": {
"test": "node tests/compliance.tests.js | tap-spec",
"test": "node test/compliance.tests.js | tap-spec",
"lint": "eslint .",
"istanbul": "istanbul cover --report html --report lcov tape -- test/compliance.tests.js",
"codeclimate": "codeclimate-test-reporter < coverage/lcov.info",
"prepush": "npm run lint && npm test",
"docker": "docker run --detach --publish 5432:5432 --name bs-postgres postgres"
"docker": "docker run --detach --publish 5432:5432 --name postgres kiasaki/alpine-postgres"
},

@@ -23,14 +25,18 @@ "keywords": [

"devDependencies": {
"block-sequence-compliance-tests": "0.1.0",
"eslint": "^0.24.1",
"eslint-config-imperative": "0.0.6",
"eslint-plugin-imperative": "0.0.2",
"husky": "^0.11.4",
"block-sequence-compliance-tests": "^2.0.1",
"codeclimate-test-reporter": "^0.4.0",
"eslint": "^3.12.2",
"eslint-config-imperative": "^1.0.0",
"eslint-plugin-imperative": "^1.0.0",
"husky": "^0.13.0",
"istanbul": "^0.4.5",
"tap-spec": "^4.1.1"
},
"dependencies": {
"async": "^2.0.0-rc.3",
"debug": "^2.2.0",
"lodash": "^4.11.1",
"pg": "^4.5.5",
"async": "^2.1.4",
"big-integer": "^1.6.17",
"debug": "^2.6.0",
"lodash": "^4.17.4",
"pg": "^6.1.2",
"promise-polyfill": "^6.0.2",
"safe-json-parse": "^4.0.0"

@@ -48,3 +54,3 @@ },

},
"homepage": "https://github.com/guidesmiths/block-sequence-postgres#readme"
"homepage": "https://guidesmiths.github.io/block-sequence-postgres/"
}
# block-sequence-postgres
A PostgreSQL implementation of [block-sequence](https://www.npmjs.com/package/block-sequence).
[![NPM version](https://img.shields.io/npm/v/block-sequence-postgres.svg?style=flat-square)](https://www.npmjs.com/package/block-sequence-postgres)
[![NPM downloads](https://img.shields.io/npm/dm/block-sequence-postgres.svg?style=flat-square)](https://www.npmjs.com/package/block-sequence-postgres)
[![Build Status](https://img.shields.io/travis/guidesmiths/block-sequence-postgres/master.svg)](https://travis-ci.org/guidesmiths/block-sequence-postgres)
[![Code Climate](https://codeclimate.com/github/guidesmiths/block-sequence-postgres/badges/gpa.svg)](https://codeclimate.com/github/guidesmiths/block-sequence-postgres)
[![Test Coverage](https://codeclimate.com/github/guidesmiths/block-sequence-postgres/badges/coverage.svg)](https://codeclimate.com/github/guidesmiths/block-sequence-postgres/coverage)
[![Code Style](https://img.shields.io/badge/code%20style-imperative-brightgreen.svg)](https://github.com/guidesmiths/eslint-config-imperative)
[![Dependency Status](https://david-dm.org/guidesmiths/block-sequence-postgres.svg)](https://david-dm.org/guidesmiths/block-sequence-postgres)
[![devDependencies Status](https://david-dm.org/guidesmiths/block-sequence-postgres/dev-status.svg)](https://david-dm.org/guidesmiths/block-sequence-postgres?type=dev)
## Usage
```js
var BlockArray = require('block-sequence').BlockArray
var init = require('block-sequence-postgres')
const BlockArray = require('block-sequence').BlockArray
const init = require('block-sequence-postgres')
// Initialise the PostgreSQL Block Sequence Driver
init({ url: 'postgres://username:password@localhost/bs_test' }, function(err, driver) {
init({ url: 'postgres://username:password@localhost/bs_test' }, (err, driver) => {
if (err) throw err
// Ensure the sequence exists
driver.ensure({ name: 'my-sequence' }, function(err, sequence) {
driver.ensure({ name: 'my-sequence' }, (err, sequence) => {
if (err) throw err
// Create a block array containing 1000 ids per block (defaults to 2 blocks)
var idGenerator = new BlockArray({ block: { driver: driver, size: 1000 } })
const idGenerator = new BlockArray({ block: { sequence: sequence, driver: driver, size: 1000 } })
// Grab the next id
idGenerator.next(function(err, id) {
idGenerator.next((err, id) => {
if (err) throw err

@@ -28,5 +37,4 @@ console.log(id)

```
See https://www.npmjs.com/package/pg for all connection parameters
See [pg](https://www.npmjs.com/package/pg) for all connection parameters

Sorry, the diff of this file is not supported yet

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