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

@vect/vector-indicator

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vect/vector-indicator - npm Package Compare versions

Comparing version 0.1.2 to 0.1.6

109

dist/index.cjs.js

@@ -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;

109

dist/index.esm.js
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 };

8

package.json
{
"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 @@

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