
Security News
GitHub Actions Supply Chain Attack Puts Thousands of Projects at Risk
A compromised GitHub Action exposed secrets in CI/CD logs, putting thousands of projects at risk and forcing developers to urgently secure their workflows.
polylinear-scale
Advanced tools
Create piecewise linear scales à la d3:
Although continuous scales typically have two values each in their domain and range, specifying more than two values produces a piecewise scale.
For many more features, see d3-scale.
For an even simpler version that does not support multiple piecewise scales, see simple-linear-scale.
As a Node.js module:
$ yarn add polylinear-scale
# or
$ npm install polylinear-scale
CDN version:
<!-- Minified -->
<script src="https://unpkg.com/polylinear-scale/dist/polylinear-scale.min.js"></script>
<!-- Un-minified -->
<script src="https://unpkg.com/polylinear-scale/dist/polylinear-scale.js"></script>
domain (Array)
: The input domain (default is [0, 1]
).range (Array)
: The output range (default is [0, 1]
).clamp (Boolean)
: Enable or disable clamping (default is false
).(Function)
: The resulting scaling function.const polylinearScale = require('polylinear-scale')
// Create a linear scale
const linear = polylinearScale([0, 1], [0, 100])
console.log(linear(0.5)) // 50
// Create a polylinear scale
const polylinear = polylinearScale([0, 100, 300], [0, 50, 100])
console.log(polylinear(10)) // 5
console.log(polylinear(-10)) // -5
// Clamp results to the given range
const clamped = polylinearScale([-10, 0, 10], [-5, 2, 10], true)
console.log(clamped(11)) // 10
Uses JavaScript Standard Style.
# test
$ npm run test
FAQs
Create piecewise linear scales à la d3
The npm package polylinear-scale receives a total of 337 weekly downloads. As such, polylinear-scale popularity was classified as not popular.
We found that polylinear-scale demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A compromised GitHub Action exposed secrets in CI/CD logs, putting thousands of projects at risk and forcing developers to urgently secure their workflows.
Research
Security News
A malicious Maven package typosquatting a popular library is secretly stealing OAuth credentials on the 15th of each month, putting Java developers at risk.
Security News
Socket and Seal Security collaborate to fix a critical npm overrides bug, resolving a three-year security issue in the JavaScript ecosystem's most popular package manager.