@vect/column-mapper
Advanced tools
Comparing version 0.1.15 to 0.1.18
@@ -11,2 +11,39 @@ 'use strict'; | ||
function columnMapperDuplicate(mx, fn, l) { | ||
l = l || mx && mx.length; | ||
const mt = Array(l); | ||
for (let i = 0, r, { | ||
y | ||
} = this; i < l; i++) { | ||
mt[i] = r = mx[i].slice(); | ||
r[y] = fn(r[y], i); | ||
} | ||
return mt; | ||
} | ||
function columnMapper(mx, fn, l) { | ||
l = l || mx && mx.length; | ||
const vec = Array(l); | ||
for (let i = 0, { | ||
y | ||
} = this; i < l; i++) vec[i] = fn(mx[i][y], i); | ||
return vec; | ||
} | ||
/** | ||
* Return a mapper function that iterate through each element in column indexed by 'y'. | ||
* @param {number} y | ||
* @param {boolean=true} [duplicate] - true if duplicate original matrix form | ||
* @returns {function(*[][],function(*):*,[number]):*[][]} | ||
* @constructor | ||
*/ | ||
const ColumnMapper = (y, duplicate = true) => duplicate ? columnMapperDuplicate.bind({ | ||
y | ||
}) : columnMapper.bind({ | ||
y | ||
}); | ||
const mapper = (mx, y, fn, l) => columnMapper.call({ | ||
@@ -63,39 +100,2 @@ y | ||
function columnMapperDuplicate(mx, fn, l) { | ||
l = l || mx && mx.length; | ||
const mt = Array(l); | ||
for (let i = 0, r, { | ||
y | ||
} = this; i < l; i++) { | ||
mt[i] = r = mx[i].slice(); | ||
r[y] = fn(r[y], i); | ||
} | ||
return mt; | ||
} | ||
function columnMapper$1(mx, fn, l) { | ||
l = l || mx && mx.length; | ||
const vec = Array(l); | ||
for (let i = 0, { | ||
y | ||
} = this; i < l; i++) vec[i] = fn(mx[i][y], i); | ||
return vec; | ||
} | ||
/** | ||
* Return a mapper function that iterate through each element in column indexed by 'y'. | ||
* @param {number} y | ||
* @param {boolean=true} [duplicate] - true if duplicate original matrix form | ||
* @returns {function(*[][],function(*):*,[number]):*[][]} | ||
* @constructor | ||
*/ | ||
const ColumnMapper = (y, duplicate = true) => duplicate ? columnMapperDuplicate.bind({ | ||
y | ||
}) : columnMapper$1.bind({ | ||
y | ||
}); | ||
exports.ColumnIterate = ColumnIterate; | ||
@@ -102,0 +102,0 @@ exports.ColumnMapper = ColumnMapper; |
@@ -7,2 +7,39 @@ const iterate = function (mx, y, fn, l) { | ||
function columnMapperDuplicate(mx, fn, l) { | ||
l = l || mx && mx.length; | ||
const mt = Array(l); | ||
for (let i = 0, r, { | ||
y | ||
} = this; i < l; i++) { | ||
mt[i] = r = mx[i].slice(); | ||
r[y] = fn(r[y], i); | ||
} | ||
return mt; | ||
} | ||
function columnMapper(mx, fn, l) { | ||
l = l || mx && mx.length; | ||
const vec = Array(l); | ||
for (let i = 0, { | ||
y | ||
} = this; i < l; i++) vec[i] = fn(mx[i][y], i); | ||
return vec; | ||
} | ||
/** | ||
* Return a mapper function that iterate through each element in column indexed by 'y'. | ||
* @param {number} y | ||
* @param {boolean=true} [duplicate] - true if duplicate original matrix form | ||
* @returns {function(*[][],function(*):*,[number]):*[][]} | ||
* @constructor | ||
*/ | ||
const ColumnMapper = (y, duplicate = true) => duplicate ? columnMapperDuplicate.bind({ | ||
y | ||
}) : columnMapper.bind({ | ||
y | ||
}); | ||
const mapper = (mx, y, fn, l) => columnMapper.call({ | ||
@@ -59,39 +96,2 @@ y | ||
function columnMapperDuplicate(mx, fn, l) { | ||
l = l || mx && mx.length; | ||
const mt = Array(l); | ||
for (let i = 0, r, { | ||
y | ||
} = this; i < l; i++) { | ||
mt[i] = r = mx[i].slice(); | ||
r[y] = fn(r[y], i); | ||
} | ||
return mt; | ||
} | ||
function columnMapper$1(mx, fn, l) { | ||
l = l || mx && mx.length; | ||
const vec = Array(l); | ||
for (let i = 0, { | ||
y | ||
} = this; i < l; i++) vec[i] = fn(mx[i][y], i); | ||
return vec; | ||
} | ||
/** | ||
* Return a mapper function that iterate through each element in column indexed by 'y'. | ||
* @param {number} y | ||
* @param {boolean=true} [duplicate] - true if duplicate original matrix form | ||
* @returns {function(*[][],function(*):*,[number]):*[][]} | ||
* @constructor | ||
*/ | ||
const ColumnMapper = (y, duplicate = true) => duplicate ? columnMapperDuplicate.bind({ | ||
y | ||
}) : columnMapper$1.bind({ | ||
y | ||
}); | ||
export { ColumnIterate, ColumnMapper, ColumnMutate, iterate, mapper, mutate }; |
{ | ||
"name": "@vect/column-mapper", | ||
"version": "0.1.15", | ||
"version": "0.1.18", | ||
"description": "A debugging tool", | ||
@@ -33,3 +33,3 @@ "main": "dist/index.cjs.js", | ||
"homepage": "https://github.com/hoyeungw/vect#readme", | ||
"gitHead": "1b843fe2db07f22e9c8dd7ab2a2b28497c6a964c" | ||
"gitHead": "42f272eda481b27ce0a2365a3ef4612e6cfcb2aa" | ||
} |
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
7638