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

block-sequence-mongo

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

block-sequence-mongo - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

4

CHANGELOG.md
# Change Log
## [1.1.0]
### Changed
- Erroring when sequence exceeds Number.MAX_SAFE_INT
## [1.0.2]

@@ -4,0 +8,0 @@ ### Changed

35

index.js

@@ -5,5 +5,7 @@ var debug = require('debug')('block-sequence:mongo')

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

@@ -31,7 +33,10 @@ if (!config.url) return cb(new Error('url is required'))

if (err) return cb(err)
cb(null, _.chain({})
.defaultsDeep(result.value)
.omit(['_id'])
.value()
)
deserialize(result.value, function(err, sequence) {
if (err) return cb(err)
cb(null, _.chain({})
.defaultsDeep(sequence)
.omit(['_id'])
.value()
)
})
}

@@ -53,8 +58,10 @@ )

if (err) return cb(err)
var sequence = result.value
cb(null, _.chain({ next: sequence.value - size + 1, remaining: size })
.defaultsDeep(sequence)
.omit(['_id', 'value'])
.value()
)
deserialize(result.value, function(err, sequence) {
if (err) return cb(err)
cb(null, _.chain({ next: sequence.value - size + 1, remaining: size })
.defaultsDeep(sequence)
.omit(['_id', 'value'])
.value()
)
})
}

@@ -71,2 +78,8 @@ )

function deserialize(sequence, cb) {
var value = bigInt(sequence.value)
if (value.greater(Number.MAX_SAFE_INTEGER)) return cb(new Error('Sequence value exceeds Number.MAX_SAFE_INTEGER'))
cb(null, sequence)
}
function close(cb) {

@@ -73,0 +86,0 @@ db.close(cb)

{
"name": "block-sequence-mongo",
"version": "1.0.2",
"version": "1.1.0",
"description": "A mongo implementation of block-sequence",

@@ -24,3 +24,3 @@ "main": "index.js",

"devDependencies": {
"block-sequence-compliance-tests": "^1.2.0",
"block-sequence-compliance-tests": "^2.0.1",
"codeclimate-test-reporter": "^0.4.0",

@@ -36,2 +36,3 @@ "eslint": "^3.12.2",

"async": "^2.1.4",
"big-integer": "^1.6.17",
"debug": "^2.6.0",

@@ -38,0 +39,0 @@ "lodash": "^4.17.4",

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