@vect/vector-margin
Advanced tools
Comparing version
@@ -7,3 +7,3 @@ 'use strict'; | ||
* | ||
* @param {*[]} ar | ||
* @param {*[]} vec | ||
* @param {number} [h] - head margin length | ||
@@ -14,9 +14,9 @@ * @param {number} [t] - tail margin length | ||
*/ | ||
const marginCopy = (ar, h, t, l) => { | ||
const ve = Array(l = l || ar.length), | ||
const marginCopy = (vec, h, t, l) => { | ||
const ve = Array(l = l || vec.length), | ||
s = l - t; | ||
for (--h; h >= 0; h--) ve[h] = ar[h]; | ||
for (--h; h >= 0; h--) ve[h] = vec[h]; | ||
for (--l; l >= s; l--) ve[l] = ar[l]; | ||
for (--l; l >= s; l--) ve[l] = vec[l]; | ||
@@ -28,3 +28,3 @@ return ve; | ||
* | ||
* @param {*[]} ar | ||
* @param {*[]} vec | ||
* @param {function(*)|function(*,number)} fn | ||
@@ -36,9 +36,9 @@ * @param {number} [h] - head margin length | ||
*/ | ||
const marginMapper = (ar, fn, h, t, l) => { | ||
const ve = Array(l = l || ar.length), | ||
const marginMapper = (vec, fn, h, t, l) => { | ||
const ve = Array(l = l || vec.length), | ||
s = l - t; | ||
for (--h; h >= 0; h--) ve[h] = fn(ar[h], h); | ||
for (--h; h >= 0; h--) ve[h] = fn(vec[h], h); | ||
for (--l; l >= s; l--) ve[l] = fn(ar[l], l); | ||
for (--l; l >= s; l--) ve[l] = fn(vec[l], l); | ||
@@ -50,3 +50,3 @@ return ve; | ||
* | ||
* @param {*[]} ar | ||
* @param {*[]} vec | ||
* @param {function(*)|function(*,number)} fn | ||
@@ -58,11 +58,11 @@ * @param {number} [h] - head margin length | ||
*/ | ||
const marginMutate = (ar, fn, h, t, l) => { | ||
l = l || ar.length; | ||
const marginMutate = (vec, fn, h, t, l) => { | ||
l = l || vec.length; | ||
const s = l - t; | ||
for (--h; h >= 0; h--) ar[h] = fn(ar[h], h); | ||
for (--h; h >= 0; h--) vec[h] = fn(vec[h], h); | ||
for (--l; l >= s; l--) ar[l] = fn(ar[l], l); | ||
for (--l; l >= s; l--) vec[l] = fn(vec[l], l); | ||
return ar; | ||
return vec; | ||
}; | ||
@@ -69,0 +69,0 @@ |
/** | ||
* | ||
* @param {*[]} ar | ||
* @param {*[]} vec | ||
* @param {number} [h] - head margin length | ||
@@ -9,9 +9,9 @@ * @param {number} [t] - tail margin length | ||
*/ | ||
const marginCopy = (ar, h, t, l) => { | ||
const ve = Array(l = l || ar.length), | ||
const marginCopy = (vec, h, t, l) => { | ||
const ve = Array(l = l || vec.length), | ||
s = l - t; | ||
for (--h; h >= 0; h--) ve[h] = ar[h]; | ||
for (--h; h >= 0; h--) ve[h] = vec[h]; | ||
for (--l; l >= s; l--) ve[l] = ar[l]; | ||
for (--l; l >= s; l--) ve[l] = vec[l]; | ||
@@ -23,3 +23,3 @@ return ve; | ||
* | ||
* @param {*[]} ar | ||
* @param {*[]} vec | ||
* @param {function(*)|function(*,number)} fn | ||
@@ -31,9 +31,9 @@ * @param {number} [h] - head margin length | ||
*/ | ||
const marginMapper = (ar, fn, h, t, l) => { | ||
const ve = Array(l = l || ar.length), | ||
const marginMapper = (vec, fn, h, t, l) => { | ||
const ve = Array(l = l || vec.length), | ||
s = l - t; | ||
for (--h; h >= 0; h--) ve[h] = fn(ar[h], h); | ||
for (--h; h >= 0; h--) ve[h] = fn(vec[h], h); | ||
for (--l; l >= s; l--) ve[l] = fn(ar[l], l); | ||
for (--l; l >= s; l--) ve[l] = fn(vec[l], l); | ||
@@ -45,3 +45,3 @@ return ve; | ||
* | ||
* @param {*[]} ar | ||
* @param {*[]} vec | ||
* @param {function(*)|function(*,number)} fn | ||
@@ -53,13 +53,13 @@ * @param {number} [h] - head margin length | ||
*/ | ||
const marginMutate = (ar, fn, h, t, l) => { | ||
l = l || ar.length; | ||
const marginMutate = (vec, fn, h, t, l) => { | ||
l = l || vec.length; | ||
const s = l - t; | ||
for (--h; h >= 0; h--) ar[h] = fn(ar[h], h); | ||
for (--h; h >= 0; h--) vec[h] = fn(vec[h], h); | ||
for (--l; l >= s; l--) ar[l] = fn(ar[l], l); | ||
for (--l; l >= s; l--) vec[l] = fn(vec[l], l); | ||
return ar; | ||
return vec; | ||
}; | ||
export { marginCopy, marginMapper, marginMutate }; |
{ | ||
"name": "@vect/vector-margin", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": "Util for array", | ||
@@ -31,3 +31,3 @@ "main": "dist/index.cjs.js", | ||
"homepage": "https://github.com/hoyeungw/vect#readme", | ||
"gitHead": "7b33acbf8f6796f6da550020296bfe592a86af72" | ||
"gitHead": "d1911a29fc0916f90c791b9a763bf1bec11c4eb1" | ||
} |
6030
0.6%