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

@aryth/bound-vector

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aryth/bound-vector - npm Package Compare versions

Comparing version 0.1.14 to 0.2.0

83

dist/index.cjs.js

@@ -7,2 +7,5 @@ 'use strict';

var enumCheckLevels = require('@typen/enum-check-levels');
var literal = require('@typen/literal');
var numLoose = require('@typen/num-loose');
var vectorMapper = require('@vect/vector-mapper');

@@ -57,3 +60,83 @@ const iniNumEntry = (ar, lo, hi, {

const stringValue = word => {
let l = word === null || word === void 0 ? void 0 : word.length;
if (!l) {
return NaN;
}
if (l >= 4) {
return ((word.charCodeAt(0) & 0x7f) << 21) + ((word.charCodeAt(1) & 0x7f) << 14) + ((word.charCodeAt(2) & 0x7f) << 7) + (word.charCodeAt(3) & 0x7f);
}
if (l === 3) {
return ((word.charCodeAt(0) & 0x7f) << 21) + (word.charCodeAt(1) & 0x7f) << 14 + ((word.charCodeAt(2) & 0x7f) << 7);
}
if (l === 2) {
return ((word.charCodeAt(0) & 0x7f) << 21) + (word.charCodeAt(1) & 0x7f) << 14;
}
if (l === 1) {
return (word.charCodeAt(0) & 0x7f) << 21;
}
};
const oneself = x => x;
const duobound = (words, x = {
filter: numLoose.isNumeric,
mapper: oneself
}, y = {
filter: literal.isLiteral,
mapper: stringValue
}) => {
const l = words === null || words === void 0 ? void 0 : words.length;
let vecX = undefined,
vecY = undefined;
const {
filter: filterX,
mapper: mapperX
} = x;
const {
filter: filterY,
mapper: mapperY
} = y;
vectorMapper.iterate(words, (v, i) => {
var _vecX, _vecY;
if (filterX(v) && ((_vecX = vecX) !== null && _vecX !== void 0 ? _vecX : vecX = Array(l))) {
var _vecX$max;
v = mapperX(v);
if (v > ((_vecX$max = vecX.max) !== null && _vecX$max !== void 0 ? _vecX$max : vecX.max = vecX.min = v)) {
vecX.max = v;
} else if (v < vecX.min) {
vecX.min = v;
}
return vecX[i] = v;
}
if (filterY(v) && ((_vecY = vecY) !== null && _vecY !== void 0 ? _vecY : vecY = Array(l))) {
var _vecY$max;
v = mapperY(v);
if (v > ((_vecY$max = vecY.max) !== null && _vecY$max !== void 0 ? _vecY$max : vecY.max = vecY.min = v)) {
vecY.max = v;
} else if (v < vecY.min) {
vecY.min = v;
}
return vecY[i] = v;
}
return NaN;
}, l);
return [vecX, vecY];
};
exports.bound = bound;
exports.duobound = duobound;
exports.leap = leap;

84

dist/index.esm.js
import { IsNum, boundOutput, ToNum } from '@aryth/util-bound';
import { LOOSE } from '@typen/enum-check-levels';
import { isLiteral } from '@typen/literal';
import { isNumeric } from '@typen/num-loose';
import { iterate } from '@vect/vector-mapper';

@@ -52,2 +55,81 @@ const iniNumEntry = (ar, lo, hi, {

export { bound, leap };
const stringValue = word => {
let l = word === null || word === void 0 ? void 0 : word.length;
if (!l) {
return NaN;
}
if (l >= 4) {
return ((word.charCodeAt(0) & 0x7f) << 21) + ((word.charCodeAt(1) & 0x7f) << 14) + ((word.charCodeAt(2) & 0x7f) << 7) + (word.charCodeAt(3) & 0x7f);
}
if (l === 3) {
return ((word.charCodeAt(0) & 0x7f) << 21) + (word.charCodeAt(1) & 0x7f) << 14 + ((word.charCodeAt(2) & 0x7f) << 7);
}
if (l === 2) {
return ((word.charCodeAt(0) & 0x7f) << 21) + (word.charCodeAt(1) & 0x7f) << 14;
}
if (l === 1) {
return (word.charCodeAt(0) & 0x7f) << 21;
}
};
const oneself = x => x;
const duobound = (words, x = {
filter: isNumeric,
mapper: oneself
}, y = {
filter: isLiteral,
mapper: stringValue
}) => {
const l = words === null || words === void 0 ? void 0 : words.length;
let vecX = undefined,
vecY = undefined;
const {
filter: filterX,
mapper: mapperX
} = x;
const {
filter: filterY,
mapper: mapperY
} = y;
iterate(words, (v, i) => {
var _vecX, _vecY;
if (filterX(v) && ((_vecX = vecX) !== null && _vecX !== void 0 ? _vecX : vecX = Array(l))) {
var _vecX$max;
v = mapperX(v);
if (v > ((_vecX$max = vecX.max) !== null && _vecX$max !== void 0 ? _vecX$max : vecX.max = vecX.min = v)) {
vecX.max = v;
} else if (v < vecX.min) {
vecX.min = v;
}
return vecX[i] = v;
}
if (filterY(v) && ((_vecY = vecY) !== null && _vecY !== void 0 ? _vecY : vecY = Array(l))) {
var _vecY$max;
v = mapperY(v);
if (v > ((_vecY$max = vecY.max) !== null && _vecY$max !== void 0 ? _vecY$max : vecY.max = vecY.min = v)) {
vecY.max = v;
} else if (v < vecY.min) {
vecY.min = v;
}
return vecY[i] = v;
}
return NaN;
}, l);
return [vecX, vecY];
};
export { bound, duobound, leap };

11

package.json
{
"name": "@aryth/bound-vector",
"version": "0.1.14",
"version": "0.2.0",
"description": "A math util library",

@@ -18,4 +18,7 @@ "main": "dist/index.cjs.js",

"dependencies": {
"@aryth/util-bound": "^0.1.14",
"@typen/enum-check-levels": "^0.1.4"
"@aryth/util-bound": "^0.2.0",
"@typen/enum-check-levels": "^0.1.4",
"@typen/literal": "^0.1.4",
"@typen/num-loose": "^0.1.4",
"@vect/vector-mapper": "^0.2.4"
},

@@ -37,3 +40,3 @@ "repository": {

"homepage": "https://github.com/hoyeungw/aryth#readme",
"gitHead": "041ece9db15cfbf1589ba56429d5dbdec39754dc"
"gitHead": "80791a9032dc6e352eb5385d83d1b24ff85ba04d"
}
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