Socket
Socket
Sign inDemoInstall

stockshark-util

Package Overview
Dependencies
7
Maintainers
1
Versions
434
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.426 to 1.0.427

2

package.json
{
"name": "stockshark-util",
"version": "1.0.426",
"version": "1.0.427",
"description": "util",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -5,22 +5,29 @@ // Calculates the percentage difference between two arrays.

module.exports = function (data1, data2) {
var result = []
module.exports = function (data1, data2, limit) {
var result = []
for (let i = 0; i < data1.length; i++) {
for (let i = 0; i < data1.length; i++) {
let d1 = data1[i]
let d2 = data2[i]
let d1 = data1[i]
let d2 = data2[i]
if (d1 == 0 || d2 == 0) {
result.push(null)
continue
}
if (d1 == 0 || d2 == 0) {
result.push(0)
continue
}
if (d1 == null || d2 == null) {
result.push(null)
continue
}
// let value = ((d1 / d2) - 1) * 100
let value = ((d2 - d1) / Math.abs(d1)) * 100
// let value = ((d1 / d2) - 1) * 100
let value = ((d2 - d1) / Math.abs(d1)) * 100
result.push(value)
}
if (value > 0 && value > limit) value = limit
if (value < 0 && value < -limit) value = -limit
return result
result.push(value)
}
return result
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc