Comparing version 0.1.39 to 0.1.40
@@ -73,3 +73,3 @@ 'use strict'; | ||
const isNumLcher = (level = 0) => { | ||
const toNumChecker = (level = 0) => { | ||
switch (level) { | ||
@@ -87,3 +87,3 @@ case 0: | ||
}; | ||
const toNumLcher = (level = 0) => { | ||
const toNumerify = (level = 0) => { | ||
switch (level) { | ||
@@ -102,33 +102,22 @@ case 0: | ||
const locNumInAr = (arr, sta, end, { | ||
const firstNumInArray = (ar, lo, hi, { | ||
level = 0 | ||
} = {}) => { | ||
for (let el, isNum = isNumLcher(level); sta < end; sta++) { | ||
el = arr[sta]; | ||
if (isNum(el)) return [sta, el]; | ||
} | ||
for (let el, isNum = toNumChecker(level); lo < hi; lo++) if (isNum(el = ar[lo])) return [lo, el]; | ||
return [end, NaN]; | ||
return [hi, NaN]; | ||
}; | ||
const locNumInMx = (mx, ri, re, ci, ce, { | ||
const firstNumInMatrix = (mx, t, b, l, r, { | ||
level = 0 | ||
} = {}) => { | ||
for (let el, isNum = isNumLcher(level); ri < re; ri++) { | ||
for (ci = 0; ci < ce; ci++) { | ||
el = mx[ri][ci]; | ||
if (isNum(el)) return [ri, ci, el]; | ||
} | ||
} | ||
for (let el, isNum = toNumChecker(level); t < b; t++) for (l = 0; l < r; l++) if (isNum(el = mx[t][l])) return [t, l, el]; | ||
return [re, ce, NaN]; | ||
return [b, r, NaN]; | ||
}; | ||
const locNumInCol = (mx, ri, re, c, { | ||
const firstNumInColumn = (mx, t, b, c, { | ||
level = 0 | ||
} = {}) => { | ||
for (let el, isNum = isNumLcher(level); ri < re; ri++) { | ||
el = mx[ri][c]; | ||
if (isNum(el)) return [ri, el]; | ||
} | ||
for (let el, isNum = toNumChecker(level); t < b; t++) if (isNum(el = mx[t][c])) return [t, el]; | ||
return [re, NaN]; | ||
return [b, NaN]; | ||
}; | ||
@@ -177,3 +166,3 @@ | ||
if (!arr) return 0; | ||
const tr = toNumLcher(level); | ||
const tr = toNumerify(level); | ||
let { | ||
@@ -293,16 +282,16 @@ length: l | ||
if (!l) return toBound(NaN, NaN, dif); | ||
const t = toNumLcher(level); | ||
let [i, el] = locNumInAr(arr, 0, l, { | ||
const t = toNumerify(level); | ||
let [i, x] = firstNumInArray(arr, 0, l, { | ||
level | ||
}); | ||
let max = t(el), | ||
min = max; | ||
let min, | ||
max = min = t(x); | ||
for (--l; l > i; --l) { | ||
el = t(arr[l]); | ||
for (--l; l > i; l--) { | ||
x = t(arr[l]); | ||
if (el < min) { | ||
min = el; | ||
} else if (el > max) { | ||
max = el; | ||
if (x < min) { | ||
min = x; | ||
} else if (x > max) { | ||
max = x; | ||
} | ||
@@ -471,7 +460,8 @@ } | ||
} = {}) { | ||
var _level; | ||
let [h, w] = size(mx); | ||
if (!h || !w) return toBound(NaN, NaN, dif); | ||
const t = toNumLcher(level); | ||
let [i,, el] = locNumInMx(mx, 0, h, 0, w, { | ||
const t = (_level = level, toNumerify(_level)); | ||
let [i,, el] = firstNumInMatrix(mx, 0, h, 0, w, { | ||
level | ||
@@ -481,9 +471,9 @@ }), | ||
min = max, | ||
_a, | ||
_i; | ||
rowMax, | ||
rowMin; | ||
for (--h; h > i; --h) { | ||
for (--h; h >= i; h--) { | ||
({ | ||
max: _a, | ||
min: _i | ||
max: rowMax, | ||
min: rowMin | ||
} = Stat.bound(mx[h], { | ||
@@ -493,6 +483,6 @@ level | ||
if (_i < min) { | ||
min = _i; | ||
} else if (_a > max) { | ||
max = _a; | ||
if (rowMin < min) { | ||
min = rowMin; | ||
} else if (rowMax > max) { | ||
max = rowMax; | ||
} | ||
@@ -519,4 +509,4 @@ } | ||
if (!h || !w || y >= w) return toBound(NaN, NaN, dif); | ||
const t = toNumLcher(level); | ||
let [i, el] = locNumInCol(mx, 0, h, y, { | ||
const t = toNumerify(level); | ||
let [i, el] = firstNumInColumn(mx, 0, h, y, { | ||
level | ||
@@ -527,3 +517,3 @@ }), | ||
for (--h; h > i; --h) { | ||
for (--h; h >= i; h--) { | ||
el = t(mx[h][y]); | ||
@@ -530,0 +520,0 @@ |
@@ -69,3 +69,3 @@ import { Num, NumLoose } from 'typen'; | ||
const isNumLcher = (level = 0) => { | ||
const toNumChecker = (level = 0) => { | ||
switch (level) { | ||
@@ -83,3 +83,3 @@ case 0: | ||
}; | ||
const toNumLcher = (level = 0) => { | ||
const toNumerify = (level = 0) => { | ||
switch (level) { | ||
@@ -98,33 +98,22 @@ case 0: | ||
const locNumInAr = (arr, sta, end, { | ||
const firstNumInArray = (ar, lo, hi, { | ||
level = 0 | ||
} = {}) => { | ||
for (let el, isNum = isNumLcher(level); sta < end; sta++) { | ||
el = arr[sta]; | ||
if (isNum(el)) return [sta, el]; | ||
} | ||
for (let el, isNum = toNumChecker(level); lo < hi; lo++) if (isNum(el = ar[lo])) return [lo, el]; | ||
return [end, NaN]; | ||
return [hi, NaN]; | ||
}; | ||
const locNumInMx = (mx, ri, re, ci, ce, { | ||
const firstNumInMatrix = (mx, t, b, l, r, { | ||
level = 0 | ||
} = {}) => { | ||
for (let el, isNum = isNumLcher(level); ri < re; ri++) { | ||
for (ci = 0; ci < ce; ci++) { | ||
el = mx[ri][ci]; | ||
if (isNum(el)) return [ri, ci, el]; | ||
} | ||
} | ||
for (let el, isNum = toNumChecker(level); t < b; t++) for (l = 0; l < r; l++) if (isNum(el = mx[t][l])) return [t, l, el]; | ||
return [re, ce, NaN]; | ||
return [b, r, NaN]; | ||
}; | ||
const locNumInCol = (mx, ri, re, c, { | ||
const firstNumInColumn = (mx, t, b, c, { | ||
level = 0 | ||
} = {}) => { | ||
for (let el, isNum = isNumLcher(level); ri < re; ri++) { | ||
el = mx[ri][c]; | ||
if (isNum(el)) return [ri, el]; | ||
} | ||
for (let el, isNum = toNumChecker(level); t < b; t++) if (isNum(el = mx[t][c])) return [t, el]; | ||
return [re, NaN]; | ||
return [b, NaN]; | ||
}; | ||
@@ -173,3 +162,3 @@ | ||
if (!arr) return 0; | ||
const tr = toNumLcher(level); | ||
const tr = toNumerify(level); | ||
let { | ||
@@ -289,16 +278,16 @@ length: l | ||
if (!l) return toBound(NaN, NaN, dif); | ||
const t = toNumLcher(level); | ||
let [i, el] = locNumInAr(arr, 0, l, { | ||
const t = toNumerify(level); | ||
let [i, x] = firstNumInArray(arr, 0, l, { | ||
level | ||
}); | ||
let max = t(el), | ||
min = max; | ||
let min, | ||
max = min = t(x); | ||
for (--l; l > i; --l) { | ||
el = t(arr[l]); | ||
for (--l; l > i; l--) { | ||
x = t(arr[l]); | ||
if (el < min) { | ||
min = el; | ||
} else if (el > max) { | ||
max = el; | ||
if (x < min) { | ||
min = x; | ||
} else if (x > max) { | ||
max = x; | ||
} | ||
@@ -467,7 +456,8 @@ } | ||
} = {}) { | ||
var _level; | ||
let [h, w] = size(mx); | ||
if (!h || !w) return toBound(NaN, NaN, dif); | ||
const t = toNumLcher(level); | ||
let [i,, el] = locNumInMx(mx, 0, h, 0, w, { | ||
const t = (_level = level, toNumerify(_level)); | ||
let [i,, el] = firstNumInMatrix(mx, 0, h, 0, w, { | ||
level | ||
@@ -477,9 +467,9 @@ }), | ||
min = max, | ||
_a, | ||
_i; | ||
rowMax, | ||
rowMin; | ||
for (--h; h > i; --h) { | ||
for (--h; h >= i; h--) { | ||
({ | ||
max: _a, | ||
min: _i | ||
max: rowMax, | ||
min: rowMin | ||
} = Stat.bound(mx[h], { | ||
@@ -489,6 +479,6 @@ level | ||
if (_i < min) { | ||
min = _i; | ||
} else if (_a > max) { | ||
max = _a; | ||
if (rowMin < min) { | ||
min = rowMin; | ||
} else if (rowMax > max) { | ||
max = rowMax; | ||
} | ||
@@ -515,4 +505,4 @@ } | ||
if (!h || !w || y >= w) return toBound(NaN, NaN, dif); | ||
const t = toNumLcher(level); | ||
let [i, el] = locNumInCol(mx, 0, h, y, { | ||
const t = toNumerify(level); | ||
let [i, el] = firstNumInColumn(mx, 0, h, y, { | ||
level | ||
@@ -523,3 +513,3 @@ }), | ||
for (--h; h > i; --h) { | ||
for (--h; h >= i; h--) { | ||
el = t(mx[h][y]); | ||
@@ -526,0 +516,0 @@ |
{ | ||
"name": "borel", | ||
"version": "0.1.39", | ||
"version": "0.1.40", | ||
"description": "A light and simple math library", | ||
@@ -40,3 +40,3 @@ "main": "dist/index.cjs.js", | ||
"homepage": "https://github.com/hoyeungw/borel#readme", | ||
"gitHead": "99014cbc3e13062a4341ff6fcb010e107a1fd858" | ||
"gitHead": "9569518da3f3c993a1ffc8937aacc8bbdfeabe32" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30229
1080