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

@mishguru/interpolate

Package Overview
Dependencies
Maintainers
10
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mishguru/interpolate - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

dist/index.js.flow

50

dist/index.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {

});
exports.interpolateSumX = exports.interpolatePoints = exports.interpolate = undefined;
exports.default = exports.interpolateSumX = exports.interpolatePoints = exports.interpolate = void 0;
var _ramda = require('ramda');
var _ramda = require("ramda");
const interpolateSumX = points => interpolatePoints(points, true);
exports.interpolateSumX = interpolateSumX;
const interpolatePoints = (points, annotate = false) => {

@@ -22,5 +24,10 @@ if (points.length === 1) {

const meanY = findMeanY(points);
const annotatedPoints = annotate ? (0, _ramda.reduce)(annotatePoint, { annotatedPoints: [], currentX: 0 }, points).annotatedPoints : points;
const { left, right } = findSuitablePair(meanY, annotatedPoints);
const annotatedPoints = annotate ? (0, _ramda.reduce)(annotatePoint, {
annotatedPoints: [],
currentX: 0
}, points).annotatedPoints : points;
const {
left,
right
} = findSuitablePair(meanY, annotatedPoints);
const leftY = left.y;

@@ -38,10 +45,13 @@ const rightY = right.y;

const fraction = (meanY - leftY) / (rightY - leftY);
return interpolate(left, right, fraction);
};
exports.interpolatePoints = interpolatePoints;
const findMeanY = (0, _ramda.compose)(_ramda.mean, (0, _ramda.map)(p => p.y));
const annotatePoint = (acc, point) => {
const { annotatedPoints, currentX } = acc;
const {
annotatedPoints,
currentX
} = acc;
const updatedX = currentX + point.x;

@@ -58,3 +68,6 @@ return {

const makeLeft = (0, _ramda.assoc)('left', point);
const { left, right } = acc;
const {
left,
right
} = acc;

@@ -82,15 +95,22 @@ if (left && right) {

const max = Math.max(a, b);
return testNumber >= min && testNumber <= max;
};
const interpolate = ({ x: x1, y: y1 }, { x: x2, y: y2 }, fraction) => {
const interpolate = ({
x: x1,
y: y1
}, {
x: x2,
y: y2
}, fraction) => {
const x = x1 + (x2 - x1) * fraction;
const y = y1 + (y2 - y1) * fraction;
return { x, y };
return {
x,
y
};
};
exports.interpolate = interpolate;
exports.interpolatePoints = interpolatePoints;
exports.interpolateSumX = interpolateSumX;
exports.default = interpolatePoints;
var _default = interpolatePoints;
exports.default = _default;
{
"name": "@mishguru/interpolate",
"version": "0.0.9",
"version": "0.1.0",
"description": "Estimates where data should lie by interpolating through a list of points",

@@ -12,31 +12,2 @@ "main": "dist/index.js",

},
"babel": {
"presets": [
[
"env",
{
"targets": {
"node": "current"
}
}
]
],
"plugins": [
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
]
],
"ignore": [
"**/*.spec.js"
]
},
"ava": {
"require": [
"babel-register"
],
"babel": "inherit"
},
"repository": {

@@ -53,3 +24,3 @@ "type": "git",

"devDependencies": {
"@mishguru/package": "^1.1.1"
"@mishguru/package": "^4.1.0"
},

@@ -56,0 +27,0 @@ "dependencies": {

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