Comparing version 1.0.0 to 1.0.1
62
index.js
'use strict'; | ||
// selected so (BASE - 1) * 0x100000000 + 0xffffffff is a safe integer | ||
const BASE = 1000000; | ||
var BASE = 1000000; | ||
const readInt8 = buffer => { | ||
let high = buffer.readInt32BE(0); | ||
let low = buffer.readUInt32BE(4); | ||
let sign = ''; | ||
function readInt8(buffer) { | ||
var high = buffer.readInt32BE(0); | ||
var low = buffer.readUInt32BE(4); | ||
var sign = ''; | ||
@@ -17,11 +17,17 @@ if (high < 0) { | ||
let result = ''; | ||
var result = ''; | ||
var carry; | ||
var t; | ||
var digits; | ||
var pad; | ||
var l; | ||
var i; | ||
{ | ||
const carry = high % BASE; | ||
carry = high % BASE; | ||
high = high / BASE >>> 0; | ||
const t = 0x100000000 * carry + low; | ||
t = 0x100000000 * carry + low; | ||
low = t / BASE >>> 0; | ||
const digits = '' + (t - BASE * low); | ||
digits = '' + (t - BASE * low); | ||
@@ -32,6 +38,6 @@ if (low === 0 && high === 0) { | ||
let pad = ''; | ||
const l = 6 - digits.length; | ||
pad = ''; | ||
l = 6 - digits.length; | ||
for (let i = 0; i < l; i++) { | ||
for (i = 0; i < l; i++) { | ||
pad += '0'; | ||
@@ -44,8 +50,8 @@ } | ||
{ | ||
const carry = high % BASE; | ||
carry = high % BASE; | ||
high = high / BASE >>> 0; | ||
const t = 0x100000000 * carry + low; | ||
t = 0x100000000 * carry + low; | ||
low = t / BASE >>> 0; | ||
const digits = '' + (t - BASE * low); | ||
digits = '' + (t - BASE * low); | ||
@@ -56,6 +62,6 @@ if (low === 0 && high === 0) { | ||
let pad = ''; | ||
const l = 6 - digits.length; | ||
pad = ''; | ||
l = 6 - digits.length; | ||
for (let i = 0; i < l; i++) { | ||
for (i = 0; i < l; i++) { | ||
pad += '0'; | ||
@@ -68,8 +74,8 @@ } | ||
{ | ||
const carry = high % BASE; | ||
carry = high % BASE; | ||
high = high / BASE >>> 0; | ||
const t = 0x100000000 * carry + low; | ||
t = 0x100000000 * carry + low; | ||
low = t / BASE >>> 0; | ||
const digits = '' + (t - BASE * low); | ||
digits = '' + (t - BASE * low); | ||
@@ -80,6 +86,6 @@ if (low === 0 && high === 0) { | ||
let pad = ''; | ||
const l = 6 - digits.length; | ||
pad = ''; | ||
l = 6 - digits.length; | ||
for (let i = 0; i < l; i++) { | ||
for (i = 0; i < l; i++) { | ||
pad += '0'; | ||
@@ -92,10 +98,10 @@ } | ||
{ | ||
const carry = high % BASE; | ||
const t = 0x100000000 * carry + low; | ||
const digits = '' + t % BASE; | ||
carry = high % BASE; | ||
t = 0x100000000 * carry + low; | ||
digits = '' + t % BASE; | ||
return sign + digits + result; | ||
} | ||
}; | ||
} | ||
module.exports = readInt8; |
{ | ||
"name": "pg-int8", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "64-bit big-endian signed integer-to-string conversion", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/charmander/pg-int8/issues", |
@@ -0,1 +1,3 @@ | ||
[![Build status][ci image]][ci] | ||
64-bit big-endian signed integer-to-string conversion designed for [pg][]. | ||
@@ -12,1 +14,4 @@ | ||
[pg]: https://github.com/brianc/node-postgres | ||
[ci]: https://travis-ci.org/charmander/pg-int8 | ||
[ci image]: https://api.travis-ci.org/charmander/pg-int8.svg |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3186
75
17