@vect/object-select
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -5,4 +5,26 @@ 'use strict'; | ||
var rand = require('@aryth/rand'); | ||
var comparer = require('@aryth/comparer'); | ||
var vectorMapper = require('@vect/vector-mapper'); | ||
const leap = (o, start, gap) => { | ||
var _ref; | ||
const keys = (_ref = undefined === null || undefined === void 0 ? void 0 : undefined.keys) !== null && _ref !== void 0 ? _ref : Object.keys(o); | ||
const wd = keys.length, | ||
df = comparer.max(gap, wd), | ||
rs = {}; | ||
let lo = start ? comparer.min(start, wd - 1) : rand.rand(wd), | ||
hi = lo + df, | ||
i = lo, | ||
k; | ||
while (lo++ < hi) { | ||
rs[k = keys[i++]] = o[k]; | ||
if (i === wd) i = 0; | ||
} | ||
return rs; | ||
}; | ||
/** | ||
@@ -62,4 +84,5 @@ * | ||
exports.leap = leap; | ||
exports.lookupKeys = lookupKeys; | ||
exports.select = select; | ||
exports.selectValues = selectValues; |
@@ -0,3 +1,25 @@ | ||
import { rand } from '@aryth/rand'; | ||
import { max, min } from '@aryth/comparer'; | ||
import { iterate } from '@vect/vector-mapper'; | ||
const leap = (o, start, gap) => { | ||
var _ref; | ||
const keys = (_ref = undefined === null || undefined === void 0 ? void 0 : undefined.keys) !== null && _ref !== void 0 ? _ref : Object.keys(o); | ||
const wd = keys.length, | ||
df = max(gap, wd), | ||
rs = {}; | ||
let lo = start ? min(start, wd - 1) : rand(wd), | ||
hi = lo + df, | ||
i = lo, | ||
k; | ||
while (lo++ < hi) { | ||
rs[k = keys[i++]] = o[k]; | ||
if (i === wd) i = 0; | ||
} | ||
return rs; | ||
}; | ||
/** | ||
@@ -57,2 +79,2 @@ * | ||
export { lookupKeys, select, selectValues }; | ||
export { leap, lookupKeys, select, selectValues }; |
{ | ||
"name": "@vect/object-select", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Select from object/array", | ||
@@ -18,2 +18,5 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"@aryth/comparer": "^0.0.13", | ||
"@aryth/rand": "^0.0.13", | ||
"@vect/swap": "^0.1.12", | ||
"@vect/vector-mapper": "^0.1.12" | ||
@@ -36,3 +39,3 @@ }, | ||
"homepage": "https://github.com/hoyeungw/vect#readme", | ||
"gitHead": "e91bc62c84e8e587d8e10d3b4a0fdba87ad69aeb" | ||
"gitHead": "ae04b29d32f5867613804444771b84bd3308d06a" | ||
} |
7413
133
4
+ Added@aryth/comparer@^0.0.13
+ Added@aryth/rand@^0.0.13
+ Added@vect/swap@^0.1.12
+ Added@aryth/comparer@0.0.13(transitive)
+ Added@aryth/rand@0.0.13(transitive)
+ Added@vect/swap@0.1.15(transitive)