@vect/vector
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -5,54 +5,32 @@ 'use strict'; | ||
var Mappers = require('@vect/vector-mapper'); | ||
var Zippers = require('@vect/vector-zipper'); | ||
var Mapper = require('@vect/vector-mapper'); | ||
var Margin = require('@vect/vector-margin'); | ||
var Zipper = require('@vect/vector-zipper'); | ||
/** | ||
* | ||
* @param {*[]} ar | ||
* @param {number} [l] - left margin length | ||
* @param {number} [r] - right margin length | ||
* @param {number} [w] - array length | ||
* @returns {*[]} | ||
*/ | ||
const copyMargin = (ar, l, r, w) => { | ||
const ve = Array(w = w || ar.length), | ||
s = w - r; | ||
const { | ||
mapper, | ||
mutate | ||
} = Mapper; | ||
const { | ||
marginCopy, | ||
marginMapper, | ||
marginMutate | ||
} = Margin; | ||
const { | ||
zipper, | ||
mutazip, | ||
Duozipper, | ||
Trizipper, | ||
Quazipper | ||
} = Zipper; | ||
for (--l; l >= 0; l--) ve[l] = ar[l]; | ||
for (--w; w >= s; w--) ve[w] = ar[w]; | ||
return ve; | ||
}; | ||
/** | ||
* | ||
* @param {*[]} ar | ||
* @param {function(*)|function(*,number)} fn | ||
* @param {number} [l] - left margin length | ||
* @param {number} [r] - right margin length | ||
* @param {number} [w] - array length | ||
* @returns {*[]} | ||
*/ | ||
const mapMargin = (ar, fn, l, r, w) => { | ||
const ve = Array(w = w || ar.length), | ||
s = w - r; | ||
for (--l; l >= 0; l--) ve[l] = fn(ar[l], l); | ||
for (--w; w >= s; w--) ve[w] = fn(ar[w], w); | ||
return ve; | ||
}; | ||
const mapper = Mappers.mapper; | ||
const mutate = Mappers.mutate; | ||
const zipper = Zippers.zipper; | ||
const mutazip = Zippers.mutazip; | ||
exports.copyMargin = copyMargin; | ||
exports.mapMargin = mapMargin; | ||
exports.Duozipper = Duozipper; | ||
exports.Quazipper = Quazipper; | ||
exports.Trizipper = Trizipper; | ||
exports.mapper = mapper; | ||
exports.marginCopy = marginCopy; | ||
exports.marginMapper = marginMapper; | ||
exports.marginMutate = marginMutate; | ||
exports.mutate = mutate; | ||
exports.mutazip = mutazip; | ||
exports.zipper = zipper; |
@@ -1,48 +0,22 @@ | ||
import { mapper as mapper$1, mutate as mutate$1 } from '@vect/vector-mapper'; | ||
import { zipper as zipper$1, mutazip as mutazip$1 } from '@vect/vector-zipper'; | ||
import * as Mapper from '@vect/vector-mapper'; | ||
import * as Margin from '@vect/vector-margin'; | ||
import * as Zipper from '@vect/vector-zipper'; | ||
/** | ||
* | ||
* @param {*[]} ar | ||
* @param {number} [l] - left margin length | ||
* @param {number} [r] - right margin length | ||
* @param {number} [w] - array length | ||
* @returns {*[]} | ||
*/ | ||
const copyMargin = (ar, l, r, w) => { | ||
const ve = Array(w = w || ar.length), | ||
s = w - r; | ||
const { | ||
mapper, | ||
mutate | ||
} = Mapper; | ||
const { | ||
marginCopy, | ||
marginMapper, | ||
marginMutate | ||
} = Margin; | ||
const { | ||
zipper, | ||
mutazip, | ||
Duozipper, | ||
Trizipper, | ||
Quazipper | ||
} = Zipper; | ||
for (--l; l >= 0; l--) ve[l] = ar[l]; | ||
for (--w; w >= s; w--) ve[w] = ar[w]; | ||
return ve; | ||
}; | ||
/** | ||
* | ||
* @param {*[]} ar | ||
* @param {function(*)|function(*,number)} fn | ||
* @param {number} [l] - left margin length | ||
* @param {number} [r] - right margin length | ||
* @param {number} [w] - array length | ||
* @returns {*[]} | ||
*/ | ||
const mapMargin = (ar, fn, l, r, w) => { | ||
const ve = Array(w = w || ar.length), | ||
s = w - r; | ||
for (--l; l >= 0; l--) ve[l] = fn(ar[l], l); | ||
for (--w; w >= s; w--) ve[w] = fn(ar[w], w); | ||
return ve; | ||
}; | ||
const mapper = mapper$1; | ||
const mutate = mutate$1; | ||
const zipper = zipper$1; | ||
const mutazip = mutazip$1; | ||
export { copyMargin, mapMargin, mapper, mutate, mutazip, zipper }; | ||
export { Duozipper, Quazipper, Trizipper, mapper, marginCopy, marginMapper, marginMutate, mutate, mutazip, zipper }; |
{ | ||
"name": "@vect/vector", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "Util for array", | ||
@@ -14,4 +14,5 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"@vect/vector-mapper": "^0.0.15", | ||
"@vect/vector-zipper": "^0.0.15" | ||
"@vect/vector-mapper": "^0.0.16", | ||
"@vect/vector-margin": "^0.0.16", | ||
"@vect/vector-zipper": "^0.0.16" | ||
}, | ||
@@ -36,3 +37,3 @@ "scripts": { | ||
"homepage": "https://github.com/hoyeungw/vect#readme", | ||
"gitHead": "afd16578bef3d0305e95b8427c2d4de53b6984de" | ||
"gitHead": "b51153c64209ba722c1479179d498461a030af8c" | ||
} |
4509
3
51
+ Added@vect/vector-margin@^0.0.16
+ Added@vect/vector-mapper@0.0.16(transitive)
+ Added@vect/vector-margin@0.0.16(transitive)
+ Added@vect/vector-zipper@0.0.16(transitive)
- Removed@vect/vector-mapper@0.0.15(transitive)
- Removed@vect/vector-zipper@0.0.15(transitive)
Updated@vect/vector-mapper@^0.0.16
Updated@vect/vector-zipper@^0.0.16