@mishguru/interpolate
Advanced tools
Comparing version 0.0.9 to 0.1.0
@@ -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": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
147125
6
90
1
22
1