New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ml-arrayxy-uniquex

Package Overview
Dependencies
Maintainers
7
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-arrayxy-uniquex - npm Package Compare versions

Comparing version 0.0.2 to 0.2.4

CHANGELOG.md

21

package.json
{
"name": "ml-arrayxy-uniquex",
"version": "0.0.2",
"version": "0.2.4",
"description": "Function to sum the y values if the x values are equals. The x array has to be ordered.",
"main": "./src/index.js",
"main": "lib/index.js",
"module": "src/index.js",
"files": [
"lib",
"src"

@@ -17,3 +19,3 @@ ],

"type": "git",
"url": "https://github.com/mljs/arrayxy-uniquex.git"
"url": "https://github.com/mljs/array-xy.git"
},

@@ -30,14 +32,7 @@ "keywords": [

"bugs": {
"url": "https://github.com/mljs/arrayxy-uniquex/issues"
"url": "https://github.com/mljs/array-xy/issues"
},
"tonicExampleFilename": "./tonic.js",
"homepage": "https://github.com/mljs/arrayxy-uniquex#readme",
"devDependencies": {
"eslint": "^3.4.0",
"eslint-config-cheminfo": "^1.1.2",
"eslint-plugin-no-only-tests": "^1.1.0",
"mocha": "^3.0.2",
"mocha-better-spec-reporter": "^3.0.2",
"should": "^11.1.0"
}
"homepage": "https://github.com/mljs/array-sy/#readme",
"gitHead": "34f9f1559ca636dde9f676ddac73b4aee0dcbefa"
}

@@ -1,34 +0,34 @@

'use strict';
/**
* In place modification of the 2 arrays to make X unique and sum the Y if X has the same value
* @param xs
* @param ys
* @param {object} [points={}] : Object of points contains property x (an array) and y (an array)
* @return points
*/
function uniqueX(xs, ys) {
if (xs.length < 2) return;
export default function uniqueX(points = {}) {
const { x, y } = points;
if (x.length < 2) return;
if (x.length !== y.length) {
throw new Error('The X and Y arrays mush have the same length');
}
var current = xs[0];
var counter = 0;
let current = x[0];
let counter = 0;
for (var i = 1; i < xs.length; i++) {
if (current !== xs[i]) {
counter++;
current = xs[i];
xs[counter] = xs[i];
if (i !== counter) {
ys[counter] = 0;
}
}
if (i !== counter) {
ys[counter] += ys[i];
}
for (let i = 1; i < x.length; i++) {
if (current !== x[i]) {
counter++;
current = x[i];
x[counter] = x[i];
if (i !== counter) {
y[counter] = 0;
}
}
if (i !== counter) {
y[counter] += y[i];
}
}
xs.length = counter + 1;
ys.length = counter + 1;
x.length = counter + 1;
y.length = counter + 1;
}
module.exports = uniqueX;
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