Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
analog-array
Advanced tools
npm i analog-array
// any method:
import AnalogArray from "analog-array";
// or
const AnalogArray = require("analog-array");
// or
define(["analog-array"], function(AnalogArray){});
const AnalogArray = require("analog-array");
require.config({
packages: [{
name: 'analog-array',
location: 'node_modules/analog-array/dist/amd',
main: 'analog-array'
}]
});
// ...
define(["analog-array"], function(AnalogArray){});
<script src="dist/global/analog-array.js"></script>
<!-- or -->
<script src="dist/global/analog-array.min.js"></script>
<script>
const analogArray = new AnalogArray([10, 8, 999, 20000])
</script>
let analogArray = new AnalogArray([10, 8, 16])
Array.isArray(analogArray) // true
// overflow access returns highest or lowest available index respectively:
analogArray[999] // 16
analogArray[-0.5] // 10
// index values accessed like a normal array:
analogArray[1] // 8
let analogArray = new AnalogArray([10, 8, 16])
analogArray[0.5] // 9 (half way between index 0 and index 1)
analogArray[1.25] // 10 (1/4 past the value at index 1 towards the value at index 2)
analogArray[1.50] // 12 (1/2 past the value at index 1 towards the value at index 2)
analogArray[1.75] // 14 (3/4 past the value at index 1 towards the value at index 2)
analogArray[2.00] // 16 (the value at index 2)
analogArray = new AnalogArray([10, 8, 16], mySlideFn) // at init
analogArray.slide = mySlideFn // or later
Slide functions take 3 arguments, (from, to, amount)
from
is the value at the index Math.floor(splitIndex)
to
is the value at the index Math.floor(splitIndex) + 1
amount
is the scalar = splitIndex - fromIndex
, which will be a value in the range (0, 1)
(amounts 0 and 1 will access the array directly without sliding, otherwise the range would have been [0, 1])
Examples:
let floorIndexValuesOnly = (from, to, amount) => {
console.log(from, to, amount)
return from
}
analogArray = new AnalogArray([10, 8, 16])
analogArray[1.50] // 12
analogArray.slide = floorIndexValuesOnly
analogArray[1.50] // returns: 8, logs: 8 16 0.5
The values in the analogArray can be anything if you provide a way to slide between them.
These slide functions can be used directly outside of the implicit use in an AnalogArray instance if needed.
Accepts hex colors in the form "#RRGGBB". If "RRGGBB" is used (without "#") at Math.floor(splitIndex), the result will also omit "#".
let colorsAnalogArray = new AnalogArray(["#ff00ff", "888888", "#00ff00"], AnalogArray.slideColor)
colorsAnalogArray[0] // "#ff00ff"
colorsAnalogArray[0.5] // "#c444c4"
colorsAnalogArray[1] // "888888"
colorsAnalogArray[1.5] // "44c444"
colorsAnalogArray[2] // "#00ff00"
It will also slide hex colors in the form "#RRGGBBAA" and "RRGGBBAA" with similar results.
FAQs
AnalogArray by PropJokey - read values between array indexes
The npm package analog-array receives a total of 2 weekly downloads. As such, analog-array popularity was classified as not popular.
We found that analog-array 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.