New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@operational/frame

Package Overview
Dependencies
Maintainers
6
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@operational/frame - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

lib/DataFrame.js.map

82

lib/DataFrame.js

@@ -1,26 +0,4 @@

"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var PivotFrame_1 = require("./PivotFrame");
var DataFrame = /** @class */ (function () {
function DataFrame(schema, data) {
import { PivotFrame } from "./PivotFrame";
export class DataFrame {
constructor(schema, data) {
this.schema = schema;

@@ -30,3 +8,3 @@ this.data = data;

}
DataFrame.prototype.stats = function () {
stats() {
return {

@@ -36,43 +14,37 @@ columns: this.schema.length,

};
};
DataFrame.prototype.cell = function (rowIndex, columnIndex) {
}
cell(rowIndex, columnIndex) {
return this.data[rowIndex][columnIndex];
};
DataFrame.prototype.getCursor = function (column) {
}
getCursor(column) {
if (!this.cursorCache.has(column)) {
var index_1 = this.schema.findIndex(function (x) { return x.name === column; });
if (index_1 === -1) {
throw new Error("Unknown column: " + column);
const index = this.schema.findIndex(x => x.name === column);
if (index === -1) {
throw new Error(`Unknown column: ${column}`);
}
var cursor = (function (row) { return row[index_1]; });
const cursor = ((row) => row[index]);
cursor.column = column;
cursor.index = index_1;
cursor.index = index;
this.cursorCache.set(column, cursor);
}
return this.cursorCache.get(column);
};
DataFrame.prototype.mapRows = function (callback) {
}
mapRows(callback) {
return this.data.map(callback);
};
DataFrame.prototype.forEach = function (columns, cb) {
var _this = this;
}
forEach(columns, cb) {
if (!Array.isArray(columns)) {
columns = [columns];
}
var columnsIndex = columns.map(function (column) { return _this.schema.findIndex(function (x) { return x.name === column; }); });
if (columnsIndex.some(function (x) { return x < 0; })) {
throw new Error("Unknown column in " + columns);
const columnsIndex = columns.map(column => this.schema.findIndex(x => x.name === column));
if (columnsIndex.some(x => x < 0)) {
throw new Error(`Unknown column in ${columns}`);
}
this.data.forEach(function (dataRow) { return cb.apply(void 0, __spread(columnsIndex.map(function (columnIndex) { return dataRow[columnIndex]; }))); });
};
DataFrame.prototype.pivot = function (prop) {
this.data.forEach(dataRow => cb(...columnsIndex.map(columnIndex => dataRow[columnIndex])));
}
pivot(prop) {
// check if the input params are valid
if (prop.rows.length === 0 && prop.columns.length === 0) {
throw new Error("Please provide at least one row or column");
}
return new PivotFrame_1.PivotFrame(this.schema, this.data, prop);
};
return DataFrame;
}());
exports.DataFrame = DataFrame;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRGF0YUZyYW1lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL0RhdGFGcmFtZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkNBQTBDO0FBRzFDO0lBTUUsbUJBQVksTUFBb0IsRUFBRSxJQUFpQjtRQUNqRCxJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztRQUNyQixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztRQUNqQixJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksR0FBRyxFQUFFLENBQUM7SUFDL0IsQ0FBQztJQUVNLHlCQUFLLEdBQVo7UUFDRSxPQUFPO1lBQ0wsT0FBTyxFQUFFLEl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3RDLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLEtBQUssQ0FBQyxJQUFJLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxLQUFLLENBQUMsRUFBRTtZQUN2RCxNQUFNLElBQUksS0FBSyxDQUFDLDJDQUEyQyxDQUFDLENBQUM7U0FDOUQ7UUFDRCxPQUFPLElBQUksdUJBQVUsQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUM7SUFDdEQsQ0FBQztJQUNILGdCQUFDO0FBQUQsQ0FBQyxBQTVERCxJQTREQztBQTVEWSw4QkFBUyJ9
return new PivotFrame(this.schema, this.data, prop);
}
}
//# sourceMappingURL=DataFrame.js.map

@@ -1,25 +0,3 @@

"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var FragmentFrame = /** @class */ (function () {
function FragmentFrame(schema, data, index) {
export class FragmentFrame {
constructor(schema, data, index) {
this.schema = schema;

@@ -29,25 +7,23 @@ this.data = data;

}
FragmentFrame.prototype.mapRows = function (callback) {
var _this = this;
return this.index.map(function (i, j) { return callback(_this.data[i], j); });
};
FragmentFrame.prototype.forEach = function (columns, cb) {
var _this = this;
mapRows(callback) {
return this.index.map((i, j) => callback(this.data[i], j));
}
forEach(columns, cb) {
if (!Array.isArray(columns)) {
columns = [columns];
}
var columnsIndex = columns.map(function (column) { return _this.schema.findIndex(function (x) { return x.name === column; }); });
if (columnsIndex.some(function (x) { return x < 0; })) {
throw new Error("Unknown column in " + columns);
const columnsIndex = columns.map(column => this.schema.findIndex(x => x.name === column));
if (columnsIndex.some(x => x < 0)) {
throw new Error(`Unknown column in ${columns}`);
}
this.index.forEach(function (i) { return cb.apply(void 0, __spread(columnsIndex.map(function (columnIndex) { return _this.data[i][columnIndex]; }))); });
};
this.index.forEach(i => cb(...columnsIndex.map(columnIndex => this.data[i][columnIndex])));
}
// we need this function for table display
FragmentFrame.prototype.peak = function (column) {
var columnIndex = this.schema.findIndex(function (x) { return x.name === column; });
peak(column) {
const columnIndex = this.schema.findIndex(x => x.name === column);
if (columnIndex < 0) {
throw new Error("Unknown column " + column);
throw new Error(`Unknown column ${column}`);
}
if (this.index.length > 1) {
throw new Error("Only frame with exactly one row are good for peak");
throw new Error(`Only frame with exactly one row are good for peak`);
}

@@ -59,6 +35,4 @@ if (this.index.length === 0) {

return this.data[this.index[0]][columnIndex];
};
return FragmentFrame;
}());
exports.FragmentFrame = FragmentFrame;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRnJhZ21lbnRGcmFtZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9GcmFnbWVudEZyYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFQTtJQUtFLHVCQUFZLE1BQW9CLEVBQUUsSUFBaUIsRUFBRSxLQUFlO1FBQ2xFLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1FBQ3JCLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFDO0lBQ3JCLENBQUM7SUFFTSwrQkFBTyxHQUFkLFVBQWtCLFFBQTBDO1FBQTVELGlCQUVDO1FBREMsT0FBTyxJQUFJLENBQUM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QUFDO0lBQzdGLENBQUM7SUFFRCwwQ0FBMEM7SUFDbkMsNEJBQUksR0FBWCxVQUFZLE1BQVk7UUFDdEIsSUFBTSxXQUFXLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUMsVUFBQSxDQUFDLElBQUksT0FBQSxDQUFDLENBQUMsSUFBSSxLQUFLLE1BQU0sRUFBakIsQ0FBaUIsQ0FBQyxDQUFDO1FBQ2xFLElBQUksV0FBVyxHQUFHLENBQUMsRUFBRTtZQUNuQixNQUFNLElBQUksS0FBSyxDQUFDLG9CQUFrQixNQUFRLENBQUMsQ0FBQztTQUM3QztRQUNELElBQUksSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEdBQUcsQ0FBQyxFQUFFO1lBQ3pCLE1BQU0sSUFBSSxLQUFLLENBQUMsbURBQW1ELENBQUMsQ0FBQztTQUN0RTtRQUNELElBQUksSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEtBQUssQ0FBQyxFQUFFO1lBQzNCLHVEQUF1RDtZQUN2RCxPQUFPLElBQUksQ0FBQztTQUNiO1FBRUQsT0FBTyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUMsQ0FBQztJQUMvQyxDQUFDO0lBQ0gsb0JBQUM7QUFBRCxDQUFDLEFBNUNELElBNENDO0FBNUNZLHNDQUFhIn0=
}
}
//# sourceMappingURL=FragmentFrame.js.map

@@ -1,15 +0,6 @@

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./stats"));
var DataFrame_1 = require("./DataFrame");
exports.DataFrame = DataFrame_1.DataFrame;
var PivotFrame_1 = require("./PivotFrame");
exports.PivotFrame = PivotFrame_1.PivotFrame;
var PivotFramePreindexed_1 = require("./PivotFramePreindexed");
exports.PivotFramePreindexed = PivotFramePreindexed_1.PivotFramePreindexed;
var FragmentFrame_1 = require("./FragmentFrame");
exports.FragmentFrame = FragmentFrame_1.FragmentFrame;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFFQSw2QkFBd0I7QUFDeEIseUNBQXdDO0FBQS9CLGdDQUFBLFNBQVMsQ0FBQTtBQUNsQiwyQ0FBMEM7QUFBakMsa0NBQUEsVUFBVSxDQUFBO0FBQ25CLCtEQUE4RDtBQUFyRCxzREFBQSxvQkFBb0IsQ0FBQTtBQUM3QixpREFBZ0Q7QUFBdkMsd0NBQUEsYUFBYSxDQUFBIn0=
export * from "./stats";
export { DataFrame } from "./DataFrame";
export { PivotFrame } from "./PivotFrame";
export { PivotFramePreindexed } from "./PivotFramePreindexed";
export { FragmentFrame } from "./FragmentFrame";
//# sourceMappingURL=index.js.map

@@ -12,2 +12,3 @@ import { FragmentFrame } from "./FragmentFrame";

protected rowIndex: number[][];
protected frameWithoutPivoting: FragmentFrame<Name>;
private readonly rowCache;

@@ -29,4 +30,5 @@ private readonly columnCache;

cell(rowIdentifier: number, columnIdentifier: number): FragmentFrame<Name>;
private getFrameWithoutPivoting;
private buildIndex;
}
//# sourceMappingURL=PivotFrame.d.ts.map

@@ -1,13 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FragmentFrame_1 = require("./FragmentFrame");
var intersect = function () {
var arr = [];
for (var _i = 0; _i < arguments.length; _i++) {
arr[_i] = arguments[_i];
}
return arr.reduce(function (prev, curr) { return prev.filter(function (x) { return curr.includes(x); }); });
};
var PivotFrame = /** @class */ (function () {
function PivotFrame(schema, data, prop) {
import { FragmentFrame } from "./FragmentFrame";
const intersect = (...arr) => arr.reduce((prev, curr) => prev.filter(x => curr.includes(x)));
export class PivotFrame {
constructor(schema, data, prop) {
this.schema = schema;

@@ -22,73 +14,81 @@ this.data = data;

*/
PivotFrame.prototype.getPivotRows = function () {
getPivotRows() {
return this.prop.rows;
};
}
/**
* columns by which frame was pivoted e.g. columns from frame.pivot({ rows, columns })
*/
PivotFrame.prototype.getPivotColumns = function () {
getPivotColumns() {
return this.prop.columns;
};
PivotFrame.prototype.rowHeaders = function () {
}
rowHeaders() {
this.buildIndex();
return this.rowHeadersInternal;
};
PivotFrame.prototype.columnHeaders = function () {
}
columnHeaders() {
this.buildIndex();
return this.columnHeadersInternal;
};
PivotFrame.prototype.row = function (rowIdentifier) {
}
row(rowIdentifier) {
if (this.prop.rows.length === 0)
return this.getFrameWithoutPivoting();
this.buildIndex();
var row = this.rowIndex[rowIdentifier];
const row = this.rowIndex[rowIdentifier];
if (row === undefined) {
throw new Error("Can't find row #" + rowIdentifier);
throw new Error(`Can't find row #${rowIdentifier}`);
}
if (!this.rowCache.has(rowIdentifier)) {
this.rowCache.set(rowIdentifier, new FragmentFrame_1.FragmentFrame(this.schema, this.data, row));
this.rowCache.set(rowIdentifier, new FragmentFrame(this.schema, this.data, row));
}
return this.rowCache.get(rowIdentifier);
};
PivotFrame.prototype.column = function (columnIdentifier) {
}
column(columnIdentifier) {
if (this.prop.columns.length === 0)
return this.getFrameWithoutPivoting();
this.buildIndex();
var column = this.columnIndex[columnIdentifier];
const column = this.columnIndex[columnIdentifier];
if (column === undefined) {
throw new Error("Can't find column #" + columnIdentifier);
throw new Error(`Can't find column #${columnIdentifier}`);
}
if (!this.columnCache.has(columnIdentifier)) {
this.columnCache.set(columnIdentifier, new FragmentFrame_1.FragmentFrame(this.schema, this.data, column));
this.columnCache.set(columnIdentifier, new FragmentFrame(this.schema, this.data, column));
}
return this.columnCache.get(columnIdentifier);
};
PivotFrame.prototype.cell = function (rowIdentifier, columnIdentifier) {
}
cell(rowIdentifier, columnIdentifier) {
if (this.prop.rows.length === 0 && this.prop.columns.length === 0) {
return this.getFrameWithoutPivoting();
}
else if (this.prop.rows.length === 0) {
return this.column(columnIdentifier);
}
else if (this.prop.columns.length === 0) {
return this.row(rowIdentifier);
}
this.buildIndex();
if (this.prop.rows.length === 0) {
var index = this.columnIndex[columnIdentifier][rowIdentifier];
return new FragmentFrame_1.FragmentFrame(this.schema, this.data, index !== undefined ? [index] : []);
const row = this.rowIndex[rowIdentifier];
const column = this.columnIndex[columnIdentifier];
const cell = intersect(row, column);
return new FragmentFrame(this.schema, this.data, cell);
}
// This is very specific case when we need PivotFrame, but without pivoting itself.
// We need it to show the grid with "pivoting" only by measures.
// In this case `row`, `column` and `cell` methods will return the same result containing the whole data set
getFrameWithoutPivoting() {
if (!this.frameWithoutPivoting) {
this.frameWithoutPivoting = new FragmentFrame(this.schema, this.data, this.data.map((_, i) => i));
}
if (this.prop.columns.length === 0) {
var index = this.rowIndex[rowIdentifier][columnIdentifier];
return new FragmentFrame_1.FragmentFrame(this.schema, this.data, index !== undefined ? [index] : []);
}
var row = this.rowIndex[rowIdentifier];
var column = this.columnIndex[columnIdentifier];
var cell = intersect(row, column);
return new FragmentFrame_1.FragmentFrame(this.schema, this.data, cell);
};
PivotFrame.prototype.buildIndex = function () {
return this.frameWithoutPivoting;
}
buildIndex() {
if (this.columnIndex && this.rowIndex) {
return;
}
var nameToIndex = this.schema.reduce(function (acc, columnDefinition, index) {
const nameToIndex = this.schema.reduce((acc, columnDefinition, index) => {
acc[columnDefinition.name] = index;
return acc;
}, {});
const lastInRow = this.prop.rows.length - 1;
const pivotByRows = this.prop.rows.map(dimension => nameToIndex[dimension]);
/**
* We need those only for case when we pivot by one direction
* e.g. when `this.prop.columns.length === 0` or `this.prop.rows.length === 0`
*/
var maxColumnDepth = 0;
var maxRowDepth = 0;
var lastInRow = this.prop.rows.length - 1;
var pivotByRows = this.prop.rows.map(function (dimension) { return nameToIndex[dimension]; });
/**
* tree structure implemented as nested records

@@ -102,3 +102,3 @@ * {[valueFromRowA]: {[valueFromRowB]: {...: [<numbers of rows in this.data with valueFromRowA, valueFromRowB ...>] }}}

*/
var rowTreeIndex = {};
const rowTreeIndex = {};
/**

@@ -109,3 +109,3 @@ * matrix structure implemented as array of arrays

*/
var rowHeaders = [];
const rowHeaders = [];
/**

@@ -116,16 +116,16 @@ * matrix structure implemented as array of arrays

*/
var rowIndex = [];
var lastInColumn = this.prop.columns.length - 1;
var pivotByColumns = this.prop.columns.map(function (dimension) { return nameToIndex[dimension]; });
const rowIndex = [];
const lastInColumn = this.prop.columns.length - 1;
const pivotByColumns = this.prop.columns.map(dimension => nameToIndex[dimension]);
// see rowTreeIndex
var columnTreeIndex = {};
const columnTreeIndex = {};
// see rowHeaders
var columnHeaders = [];
const columnHeaders = [];
// see rowIndex
var columnIndex = [];
this.data.forEach(function (dataRow, rowNumber) {
var rowHeader = [];
var previousRow = rowTreeIndex;
pivotByRows.forEach(function (dimensionIndex, i) {
var dimensionValue = dataRow[dimensionIndex];
const columnIndex = [];
this.data.forEach((dataRow, rowNumber) => {
const rowHeader = [];
let previousRow = rowTreeIndex;
pivotByRows.forEach((dimensionIndex, i) => {
const dimensionValue = dataRow[dimensionIndex];
rowHeader.push(dimensionValue);

@@ -143,10 +143,9 @@ if (previousRow[dimensionValue] === undefined) {

previousRow[dimensionValue].push(rowNumber);
maxRowDepth = Math.max(previousRow[dimensionValue].length, maxRowDepth);
}
previousRow = previousRow[dimensionValue];
});
var columnHeader = [];
var previousColumn = columnTreeIndex;
pivotByColumns.forEach(function (dimensionIndex, i) {
var dimensionValue = dataRow[dimensionIndex];
const columnHeader = [];
let previousColumn = columnTreeIndex;
pivotByColumns.forEach((dimensionIndex, i) => {
const dimensionValue = dataRow[dimensionIndex];
columnHeader.push(dimensionValue);

@@ -164,3 +163,2 @@ if (previousColumn[dimensionValue] === undefined) {

previousColumn[dimensionValue].push(rowNumber);
maxColumnDepth = Math.max(previousColumn[dimensionValue].length, maxColumnDepth);
}

@@ -170,12 +168,8 @@ previousColumn = previousColumn[dimensionValue];

});
this.columnHeadersInternal =
this.prop.columns.length === 0 ? Array.from({ length: maxRowDepth }).map(function (_) { return []; }) : columnHeaders;
this.rowHeadersInternal =
this.prop.rows.length === 0 ? Array.from({ length: maxColumnDepth }).map(function (_) { return []; }) : rowHeaders;
this.columnHeadersInternal = columnHeaders;
this.rowHeadersInternal = rowHeaders;
this.columnIndex = columnIndex;
this.rowIndex = rowIndex;
};
return PivotFrame;
}());
exports.PivotFrame = PivotFrame;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUGl2b3RGcmFtZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9QaXZvdEZyYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsaURBQWdEO0FBR2hELElBQU0sU0FBUyxHQUFHO0lBQUksYUFBYTtTQUFiLFVBQWEsRUFBYixxQkFBYSxFQUFiLElBQWE7UUFBYix3QkFBYTs7SUFBVSxPQUFBLEdBQUcsQ0FBQyxNQUFNLENBQUMsVUFBQyxJQUFJLEVBQUUsSUFBSSxJQUFLLE9BQUEsSUFBSSxDQUFDLE1BQU0sQ0FBQyxVQUFBLENBQUMsSUFBSSxPQUFBLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLEVBQWhCLENBQWdCLENBQUMsRUFBbEMsQ0FBa0MsQ0FBQztBQUE5RCxDQUE4RCxDQUFDO0FBSzVHO0lBY0Usb0JBQVksTUFBb0IsRUFBRSxJQUFpQixFQUFFLElBQTRCO1FBQy9FLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1FBQ3JCLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ2pCLElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxHQUFHLEVBQStCLENBQUM7UUFDdkQsS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BQztRQUNMLENBQUMsQ0FBQyxDQUFDO1FBRUgsSUFBSSxDQUFDLHFCQUFxQjtZQUN4QixJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLEVBQUUsTUFBTSxFQUFFLFdBQVcsRUFBRSxDQUFDLENBQUMsR0FBRyxDQUFDLFVBQUEsQ0FBQyxJQUFJLE9BQUEsRUFBRSxFQUFGLENBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxhQUFhLENBQUM7UUFDcEcsSUFBSSxDQUFDLGtCQUFrQjtZQUNyQixJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLEVBQUUsTUFBTSxFQUFFLGNBQWMsRUFBRSxDQUFDLENBQUMsR0FBRyxDQUFDLFVBQUEsQ0FBQyxJQUFJLE9BQUEsRUFBRSxFQUFGLENBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxVQUFVLENBQUM7UUFFakcsSUFBSSxDQUFDLFdBQVcsR0FBRyxXQUFXLENBQUM7UUFDL0IsSUFBSSxDQUFDLFFBQVEsR0FBRyxRQUFRLENBQUM7SUFDM0IsQ0FBQztJQUNILGlCQUFDO0FBQUQsQ0FBQyxBQXBNRCxJQW9NQztBQXBNWSxnQ0FBVSJ9
}
}
//# sourceMappingURL=PivotFrame.js.map

@@ -1,26 +0,2 @@

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var PivotFrame_1 = require("./PivotFrame");
import { PivotFrame } from "./PivotFrame";
/**

@@ -33,17 +9,12 @@ * This class exposes internal implementation of PivotFrame,

*/
var PivotFramePreindexed = /** @class */ (function (_super) {
__extends(PivotFramePreindexed, _super);
function PivotFramePreindexed(schema, data, prop) {
var _this = this;
var rowHeadersInternal = prop.rowHeadersInternal, columnHeadersInternal = prop.columnHeadersInternal, columnIndex = prop.columnIndex, rowIndex = prop.rowIndex, rest = __rest(prop, ["rowHeadersInternal", "columnHeadersInternal", "columnIndex", "rowIndex"]);
_this = _super.call(this, schema, data, rest) || this;
_this.rowHeadersInternal = rowHeadersInternal;
_this.columnHeadersInternal = columnHeadersInternal;
_this.columnIndex = columnIndex;
_this.rowIndex = rowIndex;
return _this;
export class PivotFramePreindexed extends PivotFrame {
constructor(schema, data, prop) {
const { rowHeadersInternal, columnHeadersInternal, columnIndex, rowIndex, ...rest } = prop;
super(schema, data, rest);
this.rowHeadersInternal = rowHeadersInternal;
this.columnHeadersInternal = columnHeadersInternal;
this.columnIndex = columnIndex;
this.rowIndex = rowIndex;
}
return PivotFramePreindexed;
}(PivotFrame_1.PivotFrame));
exports.PivotFramePreindexed = PivotFramePreindexed;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUGl2b3RGcmFtZVByZWluZGV4ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvUGl2b3RGcmFtZVByZWluZGV4ZWQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkNBQTBEO0FBRzFEOzs7Ozs7R0FNRztBQUNIO0lBQXdFLHdDQUFnQjtJQUN0Riw4QkFDRSxNQUFvQixFQUNwQixJQUFpQixFQUNqQixJQUtDO1FBUkgsaUJBZ0JDO1FBTlMsSUFBQSw0Q0FBa0IsRUFBRSxrREFBcUIsRUFBRSw4QkFBVyxFQUFFLHdCQUFRLEVBQUUsK0ZBQU8sQ0FBVTtRQUMzRixRQUFBLGtCQUFNLE1BQU0sRUFBRSxJQUFJLEVBQUUsSUFBSSxDQUFDLFNBQUM7UUFDMUIsS0FBSSxDQUFDLGtCQUFrQixHQUFHLGtCQUFrQixDQUFDO1FBQzdDLEtBQUksQ0FBQyxxQkFBcUIsR0FBRyxxQkFBcUIsQ0FBQztRQUNuRCxLQUFJLENBQUMsV0FBVyxHQUFHLFdBQVcsQ0FBQztRQUMvQixLQUFJLENBQUMsUUFBUSxHQUFHLFFBQVEsQ0FBQzs7SUFDM0IsQ0FBQztJQUNILDJCQUFDO0FBQUQsQ0FBQyxBQWxCRCxDQUF3RSx1QkFBVSxHQWtCakY7QUFsQlksb0RBQW9CIn0=
}
//# sourceMappingURL=PivotFramePreindexed.js.map

@@ -1,2 +0,1 @@

"use strict";
/**

@@ -10,26 +9,5 @@ * There was attempt to optimize state for frame,

*/
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var weakMemoize = function (func) {
var cache = new WeakMap();
return function (a) {
const weakMemoize = (func) => {
const cache = new WeakMap();
return (a) => {
if (!cache.has(a)) {

@@ -41,24 +19,18 @@ cache.set(a, func(a));

};
var zip = function (a, b) {
return a.reduce(function (acc, x, i) {
acc[x] = b[i];
return acc;
}, {});
};
const zip = (a, b) => a.reduce((acc, x, i) => {
acc[x] = b[i];
return acc;
}, {});
// For numerical data for now we get min, max. We can get mean, deviation distribution as well
var getQuantitiveStats = weakMemoize(function (frame) {
var quantitiveColumns = frame.schema.filter(function (column) { return column.type === "number"; }).map(function (column) { return column.name; });
var max = [];
var min = [];
frame.forEach(quantitiveColumns, function () {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
const getQuantitiveStats = weakMemoize(frame => {
const quantitiveColumns = frame.schema.filter(column => column.type === "number").map(column => column.name);
let max = [];
let min = [];
frame.forEach(quantitiveColumns, (...values) => {
if (max.length === 0) {
max = __spread(values);
min = __spread(values);
max = [...values];
min = [...values];
}
else {
values.forEach(function (value, i) {
values.forEach((value, i) => {
max[i] = Math.max(value, max[i]);

@@ -74,11 +46,7 @@ min[i] = Math.min(value, min[i]);

});
var getCategoricalStats = weakMemoize(function (frame) {
var categoricalColumns = frame.schema.filter(function (column) { return column.type === "string"; }).map(function (column) { return column.name; });
var unique = categoricalColumns.map(function () { return new Set(); });
frame.forEach(categoricalColumns, function () {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
values.forEach(function (value, i) {
const getCategoricalStats = weakMemoize(frame => {
const categoricalColumns = frame.schema.filter(column => column.type === "string").map(column => column.name);
const unique = categoricalColumns.map(() => new Set());
frame.forEach(categoricalColumns, (...values) => {
values.forEach((value, i) => {
unique[i].add(value);

@@ -88,11 +56,11 @@ });

return {
unique: zip(categoricalColumns, unique.map(function (x) { return __spread(x); })),
unique: zip(categoricalColumns, unique.map(x => [...x])),
};
});
exports.uniqueValues = function (frame, column) {
export const uniqueValues = (frame, column) => {
return getCategoricalStats(frame).unique[column];
};
exports.maxValue = function (frame, column) {
export const maxValue = (frame, column) => {
return getQuantitiveStats(frame).max[column];
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvc3RhdHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7O0dBT0c7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFJSCxJQUFNLFdBQVcsR0FBRyxVQUFzQixJQUFpQjtJQUN6RCxJQUFNLEtBQUssR0FBRyxJQUFJLE9BQU8sRUFBRSxDQUFDO0lBQzVCLE9BQU8sVUFBQyxDQUFJO1FBQ1YsSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLEVBQUU7WUFDakIsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7U0FDdkI7UUFDRCxPQUFPLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFNLENBQUM7SUFDM0IsQ0FBQyxDQUFDO0FBQ0osQ0FBQyxDQUFDO0FBRUYsSUFBTSxHQUFHLEdBQUcsVUFBc0IsQ0FBTSxFQUFFLENBQU07SUFDOUMsT0FBQSxDQUFDLENBQUMsTUFBTSxDQUNOLFVBQUMsR0FBRyxFQUFFLENBQUMsRUFBRSxDQUFDO1FBQ1IsR0FBRyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNkLE9BQU8sR0FBRyxDQUFDO0lBQ2IsQ0FBQyxFQUNELEVBQWtCLENBQ25CO0FBTkQsQ0FNQyxDQUFDO0FBTUosOEZBQThGO0FBQzlGLElBQU0sa0JBQWtCLEdBQXVCLFdBQVcsQ0FBQyxVQU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0FBQztBQUVVLFFBQUEsWUFBWSxHQUFHLFVBQXNCLEtBQTRCLEVBQUUsTUFBWTtJQUMxRixPQUFPLG1CQUFtQixDQUFDLEtBQUssQ0FBQyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUNuRCxDQUFDLENBQUM7QUFFVyxRQUFBLFFBQVEsR0FBRyxVQUFzQixLQUE0QixFQUFFLE1BQVk7SUFDdEYsT0FBTyxrQkFBa0IsQ0FBQyxLQUFLLENBQUMsQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDL0MsQ0FBQyxDQUFDIn0=
//# sourceMappingURL=stats.js.map

@@ -1,3 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
//# sourceMappingURL=types.js.map
{
"name": "@operational/frame",
"version": "0.0.2",
"version": "0.1.0",
"description": "Contiamo DataFrame.",

@@ -17,7 +17,8 @@ "main": "./lib/index.js",

"scripts": {
"start": "tsc -w",
"start": "tsc -w --preserveWatchOutput",
"test": "echo 'Run this command instead: cd ../.. && yarn test' && exit 1",
"build": "tsc",
"clean": "rimraf tsconfig.tsbuildinfo lib dist"
"clean": "rimraf tsconfig.tsbuildinfo lib dist",
"prepare": "tsc"
}
}
# Operational Frame [![Build Status](https://travis-ci.com/contiamo/operational-visualizations.svg?branch=master)](https://travis-ci.com/contiamo/operational-visualizations) [![Netlify Status](https://api.netlify.com/api/v1/badges/37ca92a3-60e8-428e-a7ff-91666b59b4a8/deploy-status)](https://app.netlify.com/sites/operational-visualizations/deploys)
## Installation
```
yarn add @operational/frame
```
## Usage
Frame represents multidimensional data. It is similar to SQL table or CSV file or Pandas DataFrame or n-dimensional space described by Cartesian coordinates (x,y,z...).

@@ -4,0 +12,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc