Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-rearrange

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-rearrange - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

24

index.js

@@ -13,3 +13,3 @@ 'use strict'

if (arr.length !== index.length * stride) {
if (arr.length !== n * stride) {
throw Error('Bad length of index array')

@@ -28,6 +28,10 @@ }

for (var start = 0; start < n; start++) {
let currId = start
let pickId = index[currId]
let currId, pickId = index[start]
if (start === pickId) continue
while (pickId !== start) {
currId = pickId
pickId = index[currId]
let v = arr[pickId]

@@ -38,6 +42,3 @@ arr[pickId] = arr[currId]

index[currId] = currId
currId = pickId
pickId = index[currId]
}
index[currId] = currId
}

@@ -48,6 +49,10 @@ }

for (var start = 0; start < n; start++) {
let currId = start
let pickId = index[currId]
let currId, pickId = index[start]
if (start === pickId) continue
while (pickId !== start) {
currId = pickId
pickId = index[currId]
for (var j = 0; j < stride; j++) {

@@ -60,6 +65,3 @@ var value = arr[pickId * stride + j];

index[currId] = currId
currId = pickId
pickId = index[currId]
}
index[currId] = currId

@@ -66,0 +68,0 @@ }

{
"name": "array-rearrange",
"version": "2.2.0",
"version": "2.2.1",
"description": "Rearrange array elements by index array",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -25,3 +25,12 @@ 'use strict'

console.time(1)
reorder(a, idx)
reorder(a, idx.slice())
console.timeEnd(1)
let _a = new Float64Array(a)
console.time(2)
let b = new Float64Array(N)
for (let i = 0; i < N; i++) {
b[i] = a[idx[i]]
}
_a.set(b)
console.timeEnd(2)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc