Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Simple and straightforward solution to get the next logical record.
https://serhat-m.github.io/moveNext
npm i movenext
moveNext(opts)
import moveNext from "movenext"
opts
Object
data
{ [key: string]: unknown }[]
array of recordsdirection
'prev' | 'next'
determines the directionendBehaviour
'default' | 'jump'
behaviour after the last logical entryselector(entry) => unknown
callback for selecting the id reference
entry
{ [key: string]: unknown }
entry of data
selectedId
undefined | ...
current selected id@returns
new selected id
This example navigates through the data
Array, if the keyboard keys ArrowDown
or ArrowUp
are pressed. The selectedId
variable saves the current state.
import moveNext from "movenext"
const data = [
{ id: 1, title: "Dataset 1" },
{ id: 2, title: "Dataset 2" },
{ id: 3, title: "Dataset 3" },
]
let selectedId = undefined
document.addEventListener("keydown", (event) => {
const direction = event.key === "ArrowDown" ? "next" : event.key === "ArrowUp" ? "prev" : false
if (direction) {
selectedId = moveNext({
data,
direction,
endBehaviour: "default",
selector: (entry) => entry.id,
selectedId,
})
}
})
import moveNext from "movenext"
const [data, setData] = useState([
{ id: 1, title: "Dataset 1" },
{ id: 2, title: "Dataset 2" },
{ id: 3, title: "Dataset 3" },
])
const [selectedId, setSelectedId] = useState(undefined)
const keyDownHandler = useCallback(
(event) => {
const direction = event.key === "ArrowDown" ? "next" : event.key === "ArrowUp" ? "prev" : false
if (direction) {
setSelectedId((prevSelectedId) => {
return moveNext({
data,
direction,
endBehaviour: "default",
selector: (entry) => entry.id,
selectedId: prevSelectedId,
})
})
}
},
[data],
)
useEffect(() => {
document.addEventListener("keydown", keyDownHandler)
return () => {
document.removeEventListener("keydown", keyDownHandler)
}
}, [keyDownHandler])
The following types are available and can be used to define e. g. typed helper functions:
Direction = "prev" | "next"
EndBehaviour = "default" | "jump”
import type { Direction, EndBehaviour } from "movenext"
// Example 1
function updateData(direction: Direction, behaviour: EndBehaviour) {
...
}
// Example 2
const direction: Direction | false = event.key === "ArrowDown" ? "next" : event.key === "ArrowUp" ? "prev" : false
FAQs
Simple and straightforward solution to get the next logical record.
The npm package movenext receives a total of 5 weekly downloads. As such, movenext popularity was classified as not popular.
We found that movenext 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.