@spare/vettro
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -6,12 +6,7 @@ 'use strict'; | ||
var util = require('@spare/util'); | ||
var vector = require('@vect/vector'); | ||
var hatsuMatrix = require('hatsu-matrix'); | ||
var vectorMargin = require('@vect/vector-margin'); | ||
// Matrigin | ||
// Vettro | ||
// Mattro | ||
class Vectogin { | ||
constructor(ar, head, tail, dash) { | ||
this.ar = ar; | ||
constructor(vec, head, tail, dash) { | ||
this.vec = vec; | ||
this.head = head; | ||
@@ -22,31 +17,19 @@ this.tail = tail; | ||
reboot(ar) { | ||
return this.ar = ar, this; | ||
} | ||
clone(ar) { | ||
return new Vectogin(ar, this.head, this.tail, this.dash); | ||
} | ||
static build(ar, h = 0, t = 0) { | ||
var _ar; | ||
let d = true, | ||
l; | ||
if (!(l = (_ar = ar) === null || _ar === void 0 ? void 0 : _ar.length)) [ar, h, t, d] = [[], 0, 0, false]; | ||
if (!ar || !(l = ar.length)) [ar, h, t, d] = [[], 0, 0, false]; | ||
if (!h && !t || h >= l) [h, t, d] = [l, 0, false]; | ||
return new Vectogin(vector.copyMargin(ar, h, t, l), h, t, d); | ||
return new Vectogin(vectorMargin.marginCopy(ar, h, t, l), h, t, d); | ||
} | ||
map(fn, mutate = false) { | ||
return mutate ? this.reboot(this.ar.map(fn)) : this.clone(this.ar.map(fn)); | ||
const { | ||
vec, | ||
head, | ||
tail | ||
} = this; | ||
return mutate ? this.reboot(vectorMargin.marginMutate(vec, fn, head, tail)) : this.clone(vectorMargin.marginMapper(vec, fn, head, tail)); | ||
} | ||
/** | ||
* | ||
* @param {function} [fn] | ||
* @param {boolean} [mutate] | ||
* @return { Vectogin } | ||
*/ | ||
stringify(fn, mutate = true) { | ||
@@ -56,14 +39,23 @@ return this.map(fn ? _ => String(fn(_)) : util.totx, mutate); | ||
toList(el) { | ||
toVector(el) { | ||
const { | ||
ar, | ||
vec, | ||
head, | ||
tail | ||
} = this, | ||
diff = ar.length - (head + tail), | ||
list = ar.slice(); | ||
this.dash && el ? list.splice(head, diff, el) : list.splice(head, diff); | ||
return list; | ||
dif = vec.length - (head + tail), | ||
ar = vec.slice(); | ||
this.dash && el ? ar.splice(head, dif, el) : ar.splice(head, dif); | ||
return ar; | ||
} | ||
reboot(ar) { | ||
if (ar) this.vec = ar; | ||
return this; | ||
} | ||
clone(ar) { | ||
return new Vectogin(ar, this.head, this.tail, this.dash); | ||
} | ||
} | ||
@@ -74,7 +66,8 @@ | ||
* @param {*[]} arr | ||
* @param {function(*):string} [abstract] | ||
* @param {number} [head] | ||
* @param {number} [tail] | ||
* @param {{[max]:string,[min]:string,[na]:string}} [visual] | ||
* @return {{text:*[], raw:*[], dye:*[]}} | ||
* @param {function(*):string} [abstract] | ||
* @param {*} hr | ||
* @param {boolean} [pad] | ||
* @return {{raw:*[],text:*[]}} | ||
*/ | ||
@@ -86,18 +79,8 @@ | ||
abstract, | ||
visual | ||
hr = '...' | ||
} = {}) => { | ||
var _visual, _visual2; | ||
visual = (_visual = visual, util.isVisual(_visual)); | ||
let vn = Vectogin.build(arr, head, tail), | ||
raw = vn.toList('...'), | ||
dye = (_visual2 = visual, util.isVisual(_visual2)) ? hatsuMatrix.Visual.vector(raw, { ...visual, | ||
retFn: true, | ||
mutate: false | ||
}) : null, | ||
text = vn.stringify(abstract).toList('...'); | ||
let vn = Vectogin.build(arr, head, tail); | ||
return { | ||
text, | ||
raw, | ||
dye | ||
raw: vn.toVector(hr), | ||
text: vn.stringify(abstract).toVector(hr) | ||
}; | ||
@@ -104,0 +87,0 @@ }; |
@@ -1,12 +0,7 @@ | ||
import { totx, isVisual } from '@spare/util'; | ||
import { copyMargin } from '@vect/vector'; | ||
import { Visual } from 'hatsu-matrix'; | ||
import { totx } from '@spare/util'; | ||
import { marginCopy, marginMutate, marginMapper } from '@vect/vector-margin'; | ||
// Matrigin | ||
// Vettro | ||
// Mattro | ||
class Vectogin { | ||
constructor(ar, head, tail, dash) { | ||
this.ar = ar; | ||
constructor(vec, head, tail, dash) { | ||
this.vec = vec; | ||
this.head = head; | ||
@@ -17,31 +12,19 @@ this.tail = tail; | ||
reboot(ar) { | ||
return this.ar = ar, this; | ||
} | ||
clone(ar) { | ||
return new Vectogin(ar, this.head, this.tail, this.dash); | ||
} | ||
static build(ar, h = 0, t = 0) { | ||
var _ar; | ||
let d = true, | ||
l; | ||
if (!(l = (_ar = ar) === null || _ar === void 0 ? void 0 : _ar.length)) [ar, h, t, d] = [[], 0, 0, false]; | ||
if (!ar || !(l = ar.length)) [ar, h, t, d] = [[], 0, 0, false]; | ||
if (!h && !t || h >= l) [h, t, d] = [l, 0, false]; | ||
return new Vectogin(copyMargin(ar, h, t, l), h, t, d); | ||
return new Vectogin(marginCopy(ar, h, t, l), h, t, d); | ||
} | ||
map(fn, mutate = false) { | ||
return mutate ? this.reboot(this.ar.map(fn)) : this.clone(this.ar.map(fn)); | ||
const { | ||
vec, | ||
head, | ||
tail | ||
} = this; | ||
return mutate ? this.reboot(marginMutate(vec, fn, head, tail)) : this.clone(marginMapper(vec, fn, head, tail)); | ||
} | ||
/** | ||
* | ||
* @param {function} [fn] | ||
* @param {boolean} [mutate] | ||
* @return { Vectogin } | ||
*/ | ||
stringify(fn, mutate = true) { | ||
@@ -51,14 +34,23 @@ return this.map(fn ? _ => String(fn(_)) : totx, mutate); | ||
toList(el) { | ||
toVector(el) { | ||
const { | ||
ar, | ||
vec, | ||
head, | ||
tail | ||
} = this, | ||
diff = ar.length - (head + tail), | ||
list = ar.slice(); | ||
this.dash && el ? list.splice(head, diff, el) : list.splice(head, diff); | ||
return list; | ||
dif = vec.length - (head + tail), | ||
ar = vec.slice(); | ||
this.dash && el ? ar.splice(head, dif, el) : ar.splice(head, dif); | ||
return ar; | ||
} | ||
reboot(ar) { | ||
if (ar) this.vec = ar; | ||
return this; | ||
} | ||
clone(ar) { | ||
return new Vectogin(ar, this.head, this.tail, this.dash); | ||
} | ||
} | ||
@@ -69,7 +61,8 @@ | ||
* @param {*[]} arr | ||
* @param {function(*):string} [abstract] | ||
* @param {number} [head] | ||
* @param {number} [tail] | ||
* @param {{[max]:string,[min]:string,[na]:string}} [visual] | ||
* @return {{text:*[], raw:*[], dye:*[]}} | ||
* @param {function(*):string} [abstract] | ||
* @param {*} hr | ||
* @param {boolean} [pad] | ||
* @return {{raw:*[],text:*[]}} | ||
*/ | ||
@@ -81,18 +74,8 @@ | ||
abstract, | ||
visual | ||
hr = '...' | ||
} = {}) => { | ||
var _visual, _visual2; | ||
visual = (_visual = visual, isVisual(_visual)); | ||
let vn = Vectogin.build(arr, head, tail), | ||
raw = vn.toList('...'), | ||
dye = (_visual2 = visual, isVisual(_visual2)) ? Visual.vector(raw, { ...visual, | ||
retFn: true, | ||
mutate: false | ||
}) : null, | ||
text = vn.stringify(abstract).toList('...'); | ||
let vn = Vectogin.build(arr, head, tail); | ||
return { | ||
text, | ||
raw, | ||
dye | ||
raw: vn.toVector(hr), | ||
text: vn.stringify(abstract).toVector(hr) | ||
}; | ||
@@ -99,0 +82,0 @@ }; |
{ | ||
"name": "@spare/vettro", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A debugging tool", | ||
@@ -15,10 +15,7 @@ "main": "dist/index.cjs.js", | ||
"pub": "npm publish", | ||
"test": "node -r @babel/register test/test.index.js" | ||
"test": "node -r @babel/register test/vectogin.test.js" | ||
}, | ||
"dependencies": { | ||
"@spare/string": "^0.0.5", | ||
"@spare/util": "^0.0.5", | ||
"@vect/vector": "^0.0.4", | ||
"hatsu-matrix": "^0.0.21", | ||
"veho": "^0.2.23" | ||
"@spare/util": "^0.0.6", | ||
"@vect/vector-margin": "^0.0.17" | ||
}, | ||
@@ -41,3 +38,3 @@ "repository": { | ||
"homepage": "https://github.com/hoyeungw/spare#readme", | ||
"gitHead": "7895b3e77293b1eecd777df0d79d9fc4506b722d" | ||
"gitHead": "026b65cd7566cd2bda3e7eaa0bcb03c97671bebf" | ||
} |
2
6909
141
+ Added@vect/vector-margin@^0.0.17
+ Added@aryth/comparer@0.0.8(transitive)
+ Added@spare/lange@0.0.6(transitive)
+ Added@spare/util@0.0.6(transitive)
+ Added@vect/column-getter@0.0.17(transitive)
+ Added@vect/columns-mapper@0.0.17(transitive)
+ Added@vect/matrix@0.0.17(transitive)
+ Added@vect/matrix-indicator@0.0.17(transitive)
+ Added@vect/matrix-init@0.0.17(transitive)
+ Added@vect/matrix-mapper@0.0.17(transitive)
+ Added@vect/matrix-margin@0.0.17(transitive)
+ Added@vect/matrix-quantifier@0.0.17(transitive)
+ Added@vect/matrix-size@0.0.17(transitive)
+ Added@vect/matrix-transpose@0.0.17(transitive)
+ Added@vect/matrix-zipper@0.0.17(transitive)
+ Added@vect/vector@0.0.17(transitive)
+ Added@vect/vector-indicator@0.0.17(transitive)
+ Added@vect/vector-mapper@0.0.17(transitive)
+ Added@vect/vector-margin@0.0.17(transitive)
+ Added@vect/vector-zipper@0.0.17(transitive)
- Removed@spare/string@^0.0.5
- Removed@vect/vector@^0.0.4
- Removedhatsu-matrix@^0.0.21
- Removedveho@^0.2.23
- Removed@spare/lange@0.0.5(transitive)
- Removed@spare/string@0.0.5(transitive)
- Removed@spare/util@0.0.5(transitive)
- Removed@vect/vector@0.0.4(transitive)
- Removed@vect/vector-mapper@0.0.4(transitive)
- Removedborel@0.1.41(transitive)
- Removedfarbe@0.0.20(transitive)
- Removedhatsu@0.0.20(transitive)
- Removedhatsu-matrix@0.0.21(transitive)
- Removedkalorie@0.0.3(transitive)
- Removedpalett@0.0.21(transitive)
- Removedpalett-presets@0.0.21(transitive)
- Removedtypen@0.2.3(transitive)
- Removedveho@0.2.24(transitive)
Updated@spare/util@^0.0.6