@analys/table-divide
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -5,35 +5,37 @@ 'use strict'; | ||
var enumMutabilities = require('@analys/enum-mutabilities'); | ||
var columnsSelect = require('@vect/columns-select'); | ||
var vectorSelect = require('@vect/vector-select'); | ||
var vectorMapper = require('@vect/vector-mapper'); | ||
var tableInit = require('@analys/table-init'); | ||
/** | ||
* @param {Object<str,function(*):boolean>} filterObject | ||
* @return {{includes:Table,excludes:Table}} - mutated 'this' {head, rows} | ||
* Divide a table by fields | ||
* @param {*[]} fields | ||
* @return {{ pick:TableObject, rest:TableObject }} - mutated 'this' {head, rows} | ||
*/ | ||
const tableDivide = function ({ | ||
includes, | ||
excludes | ||
}) { | ||
/** @type {Table} */ | ||
let body = this; | ||
const tableDivide = function (fields) { | ||
var _this, _this2; | ||
if (includes && includes.length) { | ||
const [regenerated, body] = [body.spliceColumns(includes, enumMutabilities.IMMUTABLE), body.select(includes, enumMutabilities.MUTABLE)]; | ||
return { | ||
includes: body, | ||
excludes: regenerated | ||
}; | ||
} | ||
/** @type {Table|TableObject} */ | ||
const rs = (_this = this, tableInit.slice(_this)); | ||
/** @type {Table|TableObject} */ | ||
if (excludes && includes.length) { | ||
const [regenerated, body] = [body.select(excludes, enumMutabilities.IMMUTABLE), body.spliceColumns(excludes, enumMutabilities.MUTABLE)]; | ||
return { | ||
includes: regenerated, | ||
excludes: body | ||
}; | ||
} | ||
const pk = (_this2 = this, tableInit.slice(_this2)); | ||
const { | ||
head, | ||
rows | ||
} = this; | ||
const indexes = vectorMapper.mapper(fields, label => head.indexOf(label)); | ||
({ | ||
pick: pk.head, | ||
rest: rs.head | ||
} = vectorSelect.divide(head, indexes)); | ||
({ | ||
pick: pk.rows, | ||
rest: rs.rows | ||
} = columnsSelect.divide(rows, indexes)); | ||
return { | ||
includes: body, | ||
excludes: body | ||
pick: pk, | ||
rest: rs | ||
}; | ||
@@ -40,0 +42,0 @@ }; |
@@ -1,34 +0,36 @@ | ||
import { IMMUTABLE, MUTABLE } from '@analys/enum-mutabilities'; | ||
import { divide as divide$1 } from '@vect/columns-select'; | ||
import { divide } from '@vect/vector-select'; | ||
import { mapper } from '@vect/vector-mapper'; | ||
import { slice } from '@analys/table-init'; | ||
/** | ||
* @param {Object<str,function(*):boolean>} filterObject | ||
* @return {{includes:Table,excludes:Table}} - mutated 'this' {head, rows} | ||
* Divide a table by fields | ||
* @param {*[]} fields | ||
* @return {{ pick:TableObject, rest:TableObject }} - mutated 'this' {head, rows} | ||
*/ | ||
const tableDivide = function ({ | ||
includes, | ||
excludes | ||
}) { | ||
/** @type {Table} */ | ||
let body = this; | ||
const tableDivide = function (fields) { | ||
var _this, _this2; | ||
if (includes && includes.length) { | ||
const [regenerated, body] = [body.spliceColumns(includes, IMMUTABLE), body.select(includes, MUTABLE)]; | ||
return { | ||
includes: body, | ||
excludes: regenerated | ||
}; | ||
} | ||
/** @type {Table|TableObject} */ | ||
const rs = (_this = this, slice(_this)); | ||
/** @type {Table|TableObject} */ | ||
if (excludes && includes.length) { | ||
const [regenerated, body] = [body.select(excludes, IMMUTABLE), body.spliceColumns(excludes, MUTABLE)]; | ||
return { | ||
includes: regenerated, | ||
excludes: body | ||
}; | ||
} | ||
const pk = (_this2 = this, slice(_this2)); | ||
const { | ||
head, | ||
rows | ||
} = this; | ||
const indexes = mapper(fields, label => head.indexOf(label)); | ||
({ | ||
pick: pk.head, | ||
rest: rs.head | ||
} = divide(head, indexes)); | ||
({ | ||
pick: pk.rows, | ||
rest: rs.rows | ||
} = divide$1(rows, indexes)); | ||
return { | ||
includes: body, | ||
excludes: body | ||
pick: pk, | ||
rest: rs | ||
}; | ||
@@ -35,0 +37,0 @@ }; |
{ | ||
"name": "@analys/table-divide", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "A cross-table-divide analytics tool", | ||
@@ -18,3 +18,7 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"@analys/enum-mutabilities": "^0.0.12" | ||
"@analys/enum-mutabilities": "^0.0.13", | ||
"@analys/table-init": "^0.0.13", | ||
"@vect/columns-select": "^0.1.12", | ||
"@vect/vector-mapper": "^0.1.12", | ||
"@vect/vector-select": "^0.1.12" | ||
}, | ||
@@ -41,3 +45,3 @@ "repository": { | ||
"homepage": "https://github.com/hoyeungw/analys#readme", | ||
"gitHead": "2b74be88f325ad83497a1a1d5305914f089a2688" | ||
"gitHead": "2d47d8c77ab23f890ff0b9e3b6608f0d98a3989f" | ||
} |
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
5638
70
5
+ Added@analys/table-init@^0.0.13
+ Added@vect/columns-select@^0.1.12
+ Added@vect/vector-mapper@^0.1.12
+ Added@vect/vector-select@^0.1.12
+ Added@analys/enum-mutabilities@0.0.13(transitive)
+ Added@analys/table-init@0.0.13(transitive)
+ Added@aryth/comparer@0.0.13(transitive)
+ Added@aryth/rand@0.0.13(transitive)
+ Added@vect/column-getter@0.1.16(transitive)
+ Added@vect/column-mapper@0.1.18(transitive)
+ Added@vect/columns-select@0.1.18(transitive)
+ Added@vect/swap@0.1.15(transitive)
+ Added@vect/vector-mapper@0.1.16(transitive)
+ Added@vect/vector-select@0.1.17(transitive)
+ Added@vect/vector-update@0.1.15(transitive)
+ Addedtypen@0.2.3(transitive)
+ Addedveho@0.2.24(transitive)
- Removed@analys/enum-mutabilities@0.0.12(transitive)