@vect/column-quantifier
Advanced tools
Comparing version 0.0.24 to 0.0.25
@@ -5,4 +5,2 @@ 'use strict'; | ||
var matrixSize = require('@vect/matrix-size'); | ||
/** | ||
@@ -13,13 +11,17 @@ * Return true if every element in a specified column of a matrix matches the input criteria. | ||
* @param {function(*,number?,number?):*} crit | ||
* @param {number} [h] | ||
* @param {number} [w] | ||
* @returns {boolean} | ||
*/ | ||
function columnEvery(mx, crit) { | ||
function columnEvery(mx, crit, h, w) { | ||
var _mx$; | ||
const { | ||
y | ||
} = this; | ||
const [ht, wd] = matrixSize.size(mx); | ||
if (!wd || y >= wd) return true; | ||
h = h || (mx === null || mx === void 0 ? void 0 : mx.length), w = w || h && ((_mx$ = mx[0]) === null || _mx$ === void 0 ? void 0 : _mx$.length); | ||
if (!w || y >= w) return true; | ||
for (let i = 0; i < ht; i++) if (!crit(mx[i][y], i)) return false; | ||
for (let i = 0; i < h; i++) if (!crit(mx[i][y], i)) return false; | ||
@@ -38,8 +40,10 @@ return true; | ||
* @param {function(*,number?,number?):*} crit | ||
* @param {number} [h] | ||
* @param {number} [w] | ||
* @returns {boolean} | ||
*/ | ||
const every = (mx, y, crit) => columnEvery.call({ | ||
const every = (mx, y, crit, h, w) => columnEvery.call({ | ||
y | ||
}, mx, crit); | ||
}, mx, crit, h, w); | ||
@@ -52,7 +56,9 @@ /** | ||
* @param {function(*,number?,number?):*} crit | ||
* @param {number} [h] | ||
* @param {number} [w] | ||
* @returns {boolean} | ||
*/ | ||
const some = (mx, y, crit) => columnSome.call({ | ||
const some = (mx, y, crit, h, w) => columnSome.call({ | ||
y | ||
}, mx, crit); | ||
}, mx, crit, h, w); | ||
@@ -64,13 +70,17 @@ /** | ||
* @param {function(*,number?,number?):*} crit | ||
* @param {number} [h] | ||
* @param {number} [w] | ||
* @returns {boolean} | ||
*/ | ||
function columnSome$1(mx, crit) { | ||
function columnSome$1(mx, crit, h, w) { | ||
var _mx$; | ||
const { | ||
y | ||
} = this; | ||
const [ht, wd] = matrixSize.size(mx); | ||
if (!wd || y >= wd) return false; | ||
h = h || (mx === null || mx === void 0 ? void 0 : mx.length), w = w || h && ((_mx$ = mx[0]) === null || _mx$ === void 0 ? void 0 : _mx$.length); | ||
if (!w || y >= w) return false; | ||
for (let i = 0; i < ht; i++) if (crit(mx[i][y], i)) return true; | ||
for (let i = 0; i < h; i++) if (crit(mx[i][y], i)) return true; | ||
@@ -77,0 +87,0 @@ return false; |
@@ -1,3 +0,1 @@ | ||
import { size } from '@vect/matrix-size'; | ||
/** | ||
@@ -8,13 +6,17 @@ * Return true if every element in a specified column of a matrix matches the input criteria. | ||
* @param {function(*,number?,number?):*} crit | ||
* @param {number} [h] | ||
* @param {number} [w] | ||
* @returns {boolean} | ||
*/ | ||
function columnEvery(mx, crit) { | ||
function columnEvery(mx, crit, h, w) { | ||
var _mx$; | ||
const { | ||
y | ||
} = this; | ||
const [ht, wd] = size(mx); | ||
if (!wd || y >= wd) return true; | ||
h = h || (mx === null || mx === void 0 ? void 0 : mx.length), w = w || h && ((_mx$ = mx[0]) === null || _mx$ === void 0 ? void 0 : _mx$.length); | ||
if (!w || y >= w) return true; | ||
for (let i = 0; i < ht; i++) if (!crit(mx[i][y], i)) return false; | ||
for (let i = 0; i < h; i++) if (!crit(mx[i][y], i)) return false; | ||
@@ -33,8 +35,10 @@ return true; | ||
* @param {function(*,number?,number?):*} crit | ||
* @param {number} [h] | ||
* @param {number} [w] | ||
* @returns {boolean} | ||
*/ | ||
const every = (mx, y, crit) => columnEvery.call({ | ||
const every = (mx, y, crit, h, w) => columnEvery.call({ | ||
y | ||
}, mx, crit); | ||
}, mx, crit, h, w); | ||
@@ -47,7 +51,9 @@ /** | ||
* @param {function(*,number?,number?):*} crit | ||
* @param {number} [h] | ||
* @param {number} [w] | ||
* @returns {boolean} | ||
*/ | ||
const some = (mx, y, crit) => columnSome.call({ | ||
const some = (mx, y, crit, h, w) => columnSome.call({ | ||
y | ||
}, mx, crit); | ||
}, mx, crit, h, w); | ||
@@ -59,13 +65,17 @@ /** | ||
* @param {function(*,number?,number?):*} crit | ||
* @param {number} [h] | ||
* @param {number} [w] | ||
* @returns {boolean} | ||
*/ | ||
function columnSome$1(mx, crit) { | ||
function columnSome$1(mx, crit, h, w) { | ||
var _mx$; | ||
const { | ||
y | ||
} = this; | ||
const [ht, wd] = size(mx); | ||
if (!wd || y >= wd) return false; | ||
h = h || (mx === null || mx === void 0 ? void 0 : mx.length), w = w || h && ((_mx$ = mx[0]) === null || _mx$ === void 0 ? void 0 : _mx$.length); | ||
if (!w || y >= w) return false; | ||
for (let i = 0; i < ht; i++) if (crit(mx[i][y], i)) return true; | ||
for (let i = 0; i < h; i++) if (crit(mx[i][y], i)) return true; | ||
@@ -72,0 +82,0 @@ return false; |
{ | ||
"name": "@vect/column-quantifier", | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"description": "Every and some for 2-array", | ||
@@ -21,5 +21,2 @@ "main": "dist/index.cjs.js", | ||
}, | ||
"dependencies": { | ||
"@vect/matrix-size": "^0.0.24" | ||
}, | ||
"keywords": [ | ||
@@ -39,3 +36,3 @@ "matrix", | ||
"homepage": "https://github.com/hoyeungw/vect#readme", | ||
"gitHead": "859849f307eddefac80bc064722d1816f2f930ad" | ||
"gitHead": "8c6ddf6bb50856583cdc81f29000f6303217f5da" | ||
} |
8613
0
147
- Removed@vect/matrix-size@^0.0.24
- Removed@vect/matrix-size@0.0.24(transitive)