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

array-order

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-order - npm Package Compare versions

Comparing version 0.9.1 to 1.0.0

pick.js

1

index.js
export {default as sort} from './sort.js'
export {default as rank} from './rank.js'
export {default as pick} from './pick.js'
export {default as heap} from './heap.js'
export {default as swap} from './swap.js'
export {default as shift} from './shift.js'

4

package.json
{
"name": "array-order",
"version": "0.9.1",
"version": "1.0.0",
"type": "module",

@@ -19,3 +19,3 @@ "main": "./index.js",

"scripts": {
"test": "node ./tst/heap && node ./tst/rank && node ./tst/sort"
"test": "node ./tst/heap && node ./tst/pick && node ./tst/sort"
},

@@ -22,0 +22,0 @@ "repository": {

@@ -1,13 +0,11 @@

export default function(seq, arr) {
var len = seq.length
for (var i=0; i<len; ++i) {
var j = seq[i]
while (j<i) j = seq[j]
if (i!==j) {
var t = arr[i]
arr[i] = arr[j]
arr[j] = t
}
}
return arr
export default function(ref, dir) {
var seq = [],
i = 0
while (i<ref.length) seq[i] = i++
seq.sort(
dir < 0 ? function(a,b) { return ref[b]-ref[a] }
: typeof dir === 'function' ? function(a,b) { return dir(ref[a], ref[b]) }
: function(a,b) { return ref[a]-ref[b] }
)
return seq
}

@@ -11,3 +11,4 @@ <!-- markdownlint-disable MD004 MD007 MD010 MD012 MD041 MD022 MD024 MD032 MD036 -->

* **sort** creates a sorter to sort multiple columns `(ref:Array [,compare]) => (a:Array) => a`
* **rank** performs reordering based on given ranks `(ranks:Array, a:Array) => a:Array`
* **rank** creates the sorting sequence an array `(a:Array, [,compare]) => rank:Array`
* **pick** performs reordering based on given ranks `(rank:Array, a:Array) => a:Array`
* **heap** creates a function that performs permutation, each one different `a:Array => () => a`

@@ -14,0 +15,0 @@

import rank from './rank.js'
import pick from './pick.js'
export default function(ref, dir) {
var seq = [],
i = 0
while (i<ref.length) seq[i] = i++
seq.sort(
dir < 0 ? function(a,b) { return ref[b]-ref[a] }
: typeof dir === 'function' ? function(a,b) { return dir(ref[a], ref[b]) }
: function(a,b) { return ref[a]-ref[b] }
)
return rank.bind(null,seq)
return pick.bind(null,rank(ref, dir))
}
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