postgres-interval
Advanced tools
Comparing version 4.0.1 to 4.0.2
39
index.js
@@ -160,30 +160,23 @@ 'use strict' | ||
function parseMillisecond (interval) { | ||
const previousPosition = position.value | ||
const currentValue = readNextNum(interval) | ||
const valueStringLength = position.value - previousPosition | ||
if (currentValue < 10) { | ||
return currentValue * 100 | ||
switch (valueStringLength) { | ||
case 1: | ||
return currentValue * 100 | ||
case 2: | ||
return currentValue * 10 | ||
case 3: | ||
return currentValue | ||
case 4: | ||
return currentValue / 10 | ||
case 5: | ||
return currentValue / 100 | ||
case 6: | ||
return currentValue / 1000 | ||
} | ||
if (currentValue < 100) { | ||
return currentValue * 10 | ||
} | ||
if (currentValue < 1000) { | ||
return currentValue | ||
} | ||
if (currentValue < 10000) { | ||
return currentValue / 10 | ||
} | ||
if (currentValue < 100000) { | ||
return currentValue / 100 | ||
} | ||
if (currentValue < 1000000) { | ||
return currentValue / 1000 | ||
} | ||
// slow path | ||
const remainder = currentValue.toString().length - 3 | ||
const remainder = valueStringLength - 3 | ||
return currentValue / Math.pow(10, remainder) | ||
@@ -190,0 +183,0 @@ } |
{ | ||
"name": "postgres-interval", | ||
"main": "index.js", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Parse Postgres interval columns", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12007
0
290