@vect/vector-select
Advanced tools
Comparing version 0.1.10 to 0.1.12
@@ -5,2 +5,4 @@ 'use strict'; | ||
var vectorUpdate = require('@vect/vector-update'); | ||
const select = (vec, indexes, hi) => { | ||
@@ -15,2 +17,19 @@ hi = hi || indexes.length; | ||
/** | ||
* Divide input array by an array of indexes, | ||
* The indexes should be integer array sorted by ascending. | ||
* Return selected array and rest array. | ||
* 'Pick' array is new array, and the 'rest' points to the input array. | ||
* @param {*[]} vec | ||
* @param {number[]} indexes - integer array sorted ascending | ||
* @param {number} [hi] - length of indexes | ||
* @returns {{pick: *[], rest: *[]}} - rest points to altered original array, pick is an new array. | ||
*/ | ||
const divide = (vec, indexes, hi) => (hi = hi || indexes.length, { | ||
pick: vectorUpdate.partition(vec, indexes, hi).splice(indexes[0], hi), | ||
rest: vec | ||
}); | ||
exports.divide = divide; | ||
exports.select = select; |
@@ -0,1 +1,3 @@ | ||
import { partition } from '@vect/vector-update'; | ||
const select = (vec, indexes, hi) => { | ||
@@ -10,2 +12,18 @@ hi = hi || indexes.length; | ||
export { select }; | ||
/** | ||
* Divide input array by an array of indexes, | ||
* The indexes should be integer array sorted by ascending. | ||
* Return selected array and rest array. | ||
* 'Pick' array is new array, and the 'rest' points to the input array. | ||
* @param {*[]} vec | ||
* @param {number[]} indexes - integer array sorted ascending | ||
* @param {number} [hi] - length of indexes | ||
* @returns {{pick: *[], rest: *[]}} - rest points to altered original array, pick is an new array. | ||
*/ | ||
const divide = (vec, indexes, hi) => (hi = hi || indexes.length, { | ||
pick: partition(vec, indexes, hi).splice(indexes[0], hi), | ||
rest: vec | ||
}); | ||
export { divide, select }; |
{ | ||
"name": "@vect/vector-select", | ||
"version": "0.1.10", | ||
"version": "0.1.12", | ||
"description": "A math util library", | ||
@@ -17,2 +17,5 @@ "main": "dist/index.cjs.js", | ||
}, | ||
"dependencies": { | ||
"@vect/vector-update": "^0.1.12" | ||
}, | ||
"repository": { | ||
@@ -32,3 +35,4 @@ "type": "git", | ||
}, | ||
"homepage": "https://github.com/hoyeungw/vect#readme" | ||
"homepage": "https://github.com/hoyeungw/vect#readme", | ||
"gitHead": "e91bc62c84e8e587d8e10d3b4a0fdba87ad69aeb" | ||
} |
5171
47
1
+ Added@vect/vector-update@^0.1.12
+ Added@vect/swap@0.1.15(transitive)
+ Added@vect/vector-update@0.1.15(transitive)