@vect/vector-indicator
Advanced tools
Comparing version 0.1.2 to 0.1.6
@@ -6,2 +6,3 @@ 'use strict'; | ||
var comparer = require('@aryth/comparer'); | ||
var enums = require('@typen/enums'); | ||
@@ -22,5 +23,113 @@ const max = function (vec) { | ||
const indicatorByInitVal = function (vec, l) { | ||
l = l || vec.length; | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = this; | ||
let lo = 0, | ||
body = init !== null && init !== void 0 ? init : (lo++, vec[0]); | ||
for (let i = lo, fn = pile.bind(body); i < l; i++) fn(vec[i], i); | ||
return pick ? pick(body, l) : body; | ||
}; | ||
const indicatorByInitFun = function (vec, l) { | ||
l = l || vec.length; | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = this; | ||
let body = init(vec, l); | ||
for (let i = 0, fn = pile.bind(body); i < l; i++) fn(vec[i], i); | ||
return pick ? pick(body, l) : body; | ||
}; | ||
/** | ||
* | ||
* @param {*|Function|function(*[],number?):*} init - create a container to hold pileByInitVal | ||
* @param {Function|function(*,number?):*} pile - method to add current value to container when iterating | ||
* @param {Function|function(*,number?):*} pick - method to pick pileByInitVal value from the container | ||
* @returns {Function|function(*[],number?):*} | ||
* @constructor | ||
*/ | ||
const Indicator = ({ | ||
init, | ||
pile, | ||
pick | ||
}) => typeof init === enums.FUN ? indicatorByInitFun.bind({ | ||
init, | ||
pile, | ||
pick | ||
}) : indicatorByInitVal.bind({ | ||
init, | ||
pile, | ||
pick | ||
}); | ||
const pileByInitVal = function (vec, l) { | ||
l = l || vec.length; | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = this; | ||
let lo = 0, | ||
p = init !== null && init !== void 0 ? init : (lo++, vec[0]); | ||
for (let i = lo; i < l; i++) p = pile(p, vec[i], i); | ||
return pick ? pick(p, l) : p; | ||
}; | ||
const pileByInitFun = function (vec, l) { | ||
l = l || vec.length; | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = this; | ||
let p = init(vec, l); | ||
for (let i = 0; i < l; i++) p = pile(p, vec[i], i); | ||
return pick ? pick(p, l) : p; | ||
}; | ||
/** | ||
* | ||
* @param {Object|Function} config | ||
* @param {*|Function|function(*[],number?):*} [config.init] - create a container to hold pileByInitVal | ||
* @param {Function|function(*,number?):*} [config.pile] - method to add current value to container when iterating | ||
* @param {Function|function(*,number?):*} [config.pick] - method to pick pileByInitVal value from the container | ||
* @returns {Function|function(*[],number?):*} | ||
*/ | ||
const Piler = config => { | ||
if (typeof config === enums.FUN) return pileByInitVal.bind({ | ||
pile: config | ||
}); | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = config; | ||
return typeof init === enums.FUN ? pileByInitFun.bind({ | ||
init, | ||
pile, | ||
pick | ||
}) : pileByInitVal.bind({ | ||
init, | ||
pile, | ||
pick | ||
}); | ||
}; | ||
exports.Indicator = Indicator; | ||
exports.Max = Max; | ||
exports.Min = Min; | ||
exports.Piler = Piler; | ||
exports.maxBy = maxBy; | ||
exports.minBy = minBy; |
import { max as max$1, min as min$1 } from '@aryth/comparer'; | ||
import { FUN } from '@typen/enums'; | ||
@@ -17,2 +18,108 @@ const max = function (vec) { | ||
export { Max, Min, maxBy, minBy }; | ||
const indicatorByInitVal = function (vec, l) { | ||
l = l || vec.length; | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = this; | ||
let lo = 0, | ||
body = init !== null && init !== void 0 ? init : (lo++, vec[0]); | ||
for (let i = lo, fn = pile.bind(body); i < l; i++) fn(vec[i], i); | ||
return pick ? pick(body, l) : body; | ||
}; | ||
const indicatorByInitFun = function (vec, l) { | ||
l = l || vec.length; | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = this; | ||
let body = init(vec, l); | ||
for (let i = 0, fn = pile.bind(body); i < l; i++) fn(vec[i], i); | ||
return pick ? pick(body, l) : body; | ||
}; | ||
/** | ||
* | ||
* @param {*|Function|function(*[],number?):*} init - create a container to hold pileByInitVal | ||
* @param {Function|function(*,number?):*} pile - method to add current value to container when iterating | ||
* @param {Function|function(*,number?):*} pick - method to pick pileByInitVal value from the container | ||
* @returns {Function|function(*[],number?):*} | ||
* @constructor | ||
*/ | ||
const Indicator = ({ | ||
init, | ||
pile, | ||
pick | ||
}) => typeof init === FUN ? indicatorByInitFun.bind({ | ||
init, | ||
pile, | ||
pick | ||
}) : indicatorByInitVal.bind({ | ||
init, | ||
pile, | ||
pick | ||
}); | ||
const pileByInitVal = function (vec, l) { | ||
l = l || vec.length; | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = this; | ||
let lo = 0, | ||
p = init !== null && init !== void 0 ? init : (lo++, vec[0]); | ||
for (let i = lo; i < l; i++) p = pile(p, vec[i], i); | ||
return pick ? pick(p, l) : p; | ||
}; | ||
const pileByInitFun = function (vec, l) { | ||
l = l || vec.length; | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = this; | ||
let p = init(vec, l); | ||
for (let i = 0; i < l; i++) p = pile(p, vec[i], i); | ||
return pick ? pick(p, l) : p; | ||
}; | ||
/** | ||
* | ||
* @param {Object|Function} config | ||
* @param {*|Function|function(*[],number?):*} [config.init] - create a container to hold pileByInitVal | ||
* @param {Function|function(*,number?):*} [config.pile] - method to add current value to container when iterating | ||
* @param {Function|function(*,number?):*} [config.pick] - method to pick pileByInitVal value from the container | ||
* @returns {Function|function(*[],number?):*} | ||
*/ | ||
const Piler = config => { | ||
if (typeof config === FUN) return pileByInitVal.bind({ | ||
pile: config | ||
}); | ||
const { | ||
init, | ||
pile, | ||
pick | ||
} = config; | ||
return typeof init === FUN ? pileByInitFun.bind({ | ||
init, | ||
pile, | ||
pick | ||
}) : pileByInitVal.bind({ | ||
init, | ||
pile, | ||
pick | ||
}); | ||
}; | ||
export { Indicator, Max, Min, Piler, maxBy, minBy }; |
{ | ||
"name": "@vect/vector-indicator", | ||
"version": "0.1.2", | ||
"version": "0.1.6", | ||
"description": "Indicators for vector", | ||
@@ -22,3 +22,5 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"@aryth/comparer": "^0.0.10" | ||
"@aryth/comparer": "^0.0.10", | ||
"@typen/enums": "^0.0.1", | ||
"@valjoux/strategies": "^0.0.5" | ||
}, | ||
@@ -39,3 +41,3 @@ "keywords": [ | ||
"homepage": "https://github.com/hoyeungw/vect#readme", | ||
"gitHead": "79d90ea9bee956a1eff326a7a798535b114d09fb" | ||
"gitHead": "d20974768659c1574cbc5c71076ac3092ffa484f" | ||
} |
@@ -1,2 +0,2 @@ | ||
# @vect/vector-indicator | ||
# @vect/vector-maxIndicator | ||
@@ -13,8 +13,8 @@ [![npm version][badge-npm-version]][url-npm] | ||
[//]: <> (Shields) | ||
[badge-npm-version]: https://flat.badgen.net/npm/v/@vect/vector-indicator | ||
[badge-npm-download-monthly]: https://flat.badgen.net/npm/dm/@vect/vector-indicator | ||
[badge-npm-download-total]:https://flat.badgen.net/npm/dt/@vect/vector-indicator | ||
[badge-npm-dependents]: https://flat.badgen.net/npm/dependents/@vect/vector-indicator | ||
[badge-npm-license]: https://flat.badgen.net/npm/license/@vect/vector-indicator | ||
[badge-pp-install-size]: https://flat.badgen.net/packagephobia/install/@vect/vector-indicator | ||
[badge-npm-version]: https://flat.badgen.net/npm/v/@vect/vector-maxIndicator | ||
[badge-npm-download-monthly]: https://flat.badgen.net/npm/dm/@vect/vector-maxIndicator | ||
[badge-npm-download-total]:https://flat.badgen.net/npm/dt/@vect/vector-maxIndicator | ||
[badge-npm-dependents]: https://flat.badgen.net/npm/dependents/@vect/vector-maxIndicator | ||
[badge-npm-license]: https://flat.badgen.net/npm/license/@vect/vector-maxIndicator | ||
[badge-pp-install-size]: https://flat.badgen.net/packagephobia/install/@vect/vector-maxIndicator | ||
[badge-github-last-commit]: https://flat.badgen.net/github/last-commit/hoyeungw/vect | ||
@@ -24,4 +24,4 @@ [badge-github-commit-count]: https://flat.badgen.net/github/commits/hoyeungw/vect | ||
[//]: <> (Link) | ||
[url-npm]: https://npmjs.org/package/@vect/vector-indicator | ||
[url-pp]: https://packagephobia.now.sh/result?p=@vect/vector-indicator | ||
[url-npm]: https://npmjs.org/package/@vect/vector-maxIndicator | ||
[url-pp]: https://packagephobia.now.sh/result?p=@vect/vector-maxIndicator | ||
[url-github]: https://github.com/hoyeungw/vect | ||
@@ -42,3 +42,3 @@ | ||
```console | ||
$ npm install @vect/vector-indicator | ||
$ npm install @vect/vector-maxIndicator | ||
``` | ||
@@ -45,0 +45,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10240
225
3
1
+ Added@typen/enums@^0.0.1
+ Added@valjoux/strategies@^0.0.5
+ Added@aryth/bound-vector@0.0.10(transitive)
+ Added@aryth/comparer@0.0.9(transitive)
+ Added@aryth/math@0.0.10(transitive)
+ Added@aryth/rank@0.0.10(transitive)
+ Added@aryth/rank-column@0.0.10(transitive)
+ Added@aryth/rank-matrix@0.0.10(transitive)
+ Added@aryth/rank-vector@0.0.10(transitive)
+ Added@aryth/util-bound@0.0.10(transitive)
+ Added@palett/cards@0.0.12(transitive)
+ Added@palett/convert@0.0.12(transitive)
+ Added@palett/dye@0.0.12(transitive)
+ Added@palett/fluo-vector@0.0.12(transitive)
+ Added@palett/presets@0.0.12(transitive)
+ Added@palett/util-ansi@0.0.12(transitive)
+ Added@palett/util-fluo@0.0.12(transitive)
+ Added@typen/enums@0.0.1(transitive)
+ Added@valjoux/convert@0.0.5(transitive)
+ Added@valjoux/eta@0.0.5(transitive)
+ Added@valjoux/format-date@0.0.5(transitive)
+ Added@valjoux/format-date-time@0.0.5(transitive)
+ Added@valjoux/format-time@0.0.5(transitive)
+ Added@valjoux/strategies@0.0.5(transitive)
+ Added@valjoux/timestamp@0.0.5(transitive)
+ Added@valjoux/util-bitwise@0.0.5(transitive)
+ Added@vect/column@0.0.25(transitive)
+ Added@vect/column-getter@0.0.250.1.16(transitive)
+ Added@vect/column-indicator@0.0.25(transitive)
+ Added@vect/column-mapper@0.0.25(transitive)
+ Added@vect/column-quantifier@0.0.25(transitive)
+ Added@vect/column-zipper@0.0.25(transitive)
+ Added@vect/columns-mapper@0.1.16(transitive)
+ Added@vect/matrix-init@0.0.250.1.15(transitive)
+ Added@vect/matrix-mapper@0.0.25(transitive)
+ Added@vect/matrix-size@0.0.25(transitive)
+ Added@vect/vector@0.0.27(transitive)
+ Added@vect/vector-indicator@0.0.27(transitive)
+ Added@vect/vector-init@0.0.27(transitive)
+ Added@vect/vector-mapper@0.0.250.0.270.1.16(transitive)
+ Added@vect/vector-margin@0.0.27(transitive)
+ Added@vect/vector-select@0.0.27(transitive)
+ Added@vect/vector-update@0.0.27(transitive)
+ Added@vect/vector-zipper@0.0.27(transitive)
+ Addedaryth@0.0.5(transitive)
+ Addedpalett@0.0.21(transitive)
+ Addedpalett-presets@0.0.21(transitive)
+ Addedtypen@0.1.11(transitive)