
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
sort-array-for-drag-and-drop
Advanced tools
Simple array sort logics to use when implements drag and drop
Simple array sort logics to use when implements drag and drop
npm install sort-array-for-drag-and-drop
moveElement
const {moveElement} = require('sort-array-for-drag-and-drop');
const array = [
'A',
'B',
'C',
];
console.log(moveElement(array, 0, 2)); // -> ['B', 'A', 'C'] (Insert `array[0]` before `array[2]`)
console.log(moveElement(array, 0, 1)); // -> ['A', 'B', 'C'] (Insert `array[0]` before `array[1]`, not moved)
console.log(moveElement(array, 0, 0)); // -> ['A', 'B', 'C'] (Not moved)
console.log(moveElement(array, 0, 3)); // -> ['B', 'C', 'A'] (In the case of an index that is exceeded, it inserts to the end)
console.log(moveElement(array, 2, 0)); // -> ['C', 'A', 'B'] (Insert `array[2]` before `array[0]`)
console.log(moveElement(array, 2, 1)); // -> ['A', 'C', 'B'] (Insert `array[2]` before `array[1]`)
moveElementByValue
const {moveElementByValue} = require('sort-array-for-drag-and-drop');
// The values must be unique
const array = [
'A',
'B',
'C',
];
console.log(moveElementByValue(array, 'A', 'C')); // -> ['B', 'A', 'C'] (Insert 'A' before 'C')
console.log(moveElementByValue(array, 'A', 'C', true)); // -> ['B', 'C', 'A'] (Insert 'A' after 'C')
console.log(moveElementByValue(array, 'D', 'C')); // -> Error! ('D' is not included)
moveElementBy
const {moveElementBy} = require('sort-array-for-drag-and-drop');
// The values must be unique
const a = {value: 'a'};
const b = {value: 'b'};
const c = {value: 'c'};
const array = [a, b, c];
// return to compare with values
function getValue(elem) {
return elem.value;
}
console.log(moveElementBy(array, getValue, 'A', 'C')); // -> [B, A, C] (Insert A before C)
console.log(moveElementBy(array, getValue, 'A', 'C', true)); // -> [B, C, A] (Insert A after C)
console.log(moveElementBy(array, getValue, 'D', 'C')); // -> Error! (D is not included)
FAQs
Simple array sort logics to use when implements drag and drop
The npm package sort-array-for-drag-and-drop receives a total of 323 weekly downloads. As such, sort-array-for-drag-and-drop popularity was classified as not popular.
We found that sort-array-for-drag-and-drop 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.