Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@steelbreeze/landscape

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@steelbreeze/landscape - npm Package Compare versions

Comparing version 3.7.0 to 3.7.1

docs/api/v3/.nojekyll

2

docs/dist/landscape.min.js

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

var landscape;(()=>{"use strict";var e={};(()=>{var s=e;Object.defineProperty(s,"__esModule",{value:!0}),s.merge=s.table=void 0,s.table=(e,s,t,r,c=Math.max)=>a(e.map((e=>e.map((e=>e.length?o(e,t):[l("empty")])))),s,r,c);const a=(e,s,a,o)=>{const r=s.x.map(((s,l)=>a?o(...e.map((e=>e[l].length))):1)),c=e.map((e=>a?1:o(...e.map((e=>e.length)))));return t(e,c,((e,a,o,c)=>t(e,r,((e,s,l)=>({...e[Math.floor(e.length*(o+l)/(s*a))]})),s.y[c].map((e=>l(`axis y ${e.key}`,e.value))))),s.x[0].map(((e,a)=>t(s.x,r,(e=>l(`axis x ${e[a].key}`,e[a].value)),s.y[0].map((()=>l("axis xy")))))))};s.merge=(e,s,a)=>{let l;r(e,((o,t)=>{r(o,((r,p)=>{a&&t&&(l=e[t-1][p])&&c(l,r)&&l.cols===r.cols?(l.rows+=r.rows,o.splice(p,1)):s&&p&&(l=o[p-1])&&c(l,r)&&l.rows===r.rows&&(l.cols+=r.cols,o.splice(p,1))}))}))};const l=(e,s="",a="")=>({key:a,value:s,style:e,rows:1,cols:1}),o=(e,s)=>{const a=[];for(const l of e){const e=s(l);a.some((s=>c(s,e)))||a.push({...e,rows:1,cols:1})}return a},t=(e,s,a,l)=>(e.forEach(((e,o)=>{for(let t=s[o],r=0;r<t;++r)l.push(a(e,t,r,o))})),l),r=(e,s)=>{for(let a=e.length;a--;)s(e[a],a)},c=(e,s)=>e.value===s.value&&e.style===s.style})(),landscape=e})();
var landscape;(()=>{"use strict";var e={};(()=>{var l=e;Object.defineProperty(l,"__esModule",{value:!0}),l.merge=l.table=void 0,l.table=(e,l,s,r,n=Math.max)=>{const c=t(e,s),p=l.x.map(((e,l)=>r?n(...c.map((e=>e[l].length))):1));return o(c,c.map((e=>r?1:n(...e.map((e=>e.length))))),l.x[0].map(((e,t)=>o(l.x,p,l.y[0].map((()=>a("axis xy"))),(e=>a(`axis x ${e[t].key}`,e[t].value))))),((e,t,s,r)=>o(e,p,l.y[r].map((e=>a(`axis y ${e.key}`,e.value))),((e,l,a)=>({...e[Math.floor(e.length*(s+a)/(l*t))]})))))},l.merge=(e,l,t)=>{let s;for(let a=e.length;a--;){const o=e[a];for(let n=o.length;n--;){const c=o[n];t&&a&&(s=e[a-1][n])&&r(s,c,"cols")?(s.rows+=c.rows,o.splice(n,1)):l&&n&&(s=o[n-1])&&r(s,c,"rows")&&(s.cols+=c.cols,o.splice(n,1))}}};const t=(e,l)=>e.map((e=>e.map((e=>e.length?s(e,l):[a("empty")])))),s=(e,l)=>{const t=[];for(const s of e){const e=l(s);t.some((l=>r(l,e)))||t.push({...e,rows:1,cols:1})}return t},a=(e,l="",t="")=>({key:t,value:l,style:e,rows:1,cols:1}),o=(e,l,t,s)=>{for(let a=e.length,o=0;o<a;++o)for(let a=l[o],r=0;r<a;++r)t.push(s(e[o],a,r,o));return t},r=(e,l,t)=>e.value===l.value&&e.style===l.style&&(!t||e[t]===l[t])})(),landscape=e})();

@@ -12,31 +12,23 @@ "use strict";

*/
const table = (cube, axes, getElement, onX, method = Math.max) =>
// convert the source data to cells and remove resulting duplicates; create the resultant table
expand(cube.map(row => row.map(table => table.length ? cells(table, getElement) : [cell('empty')])), axes, onX, method);
exports.table = table;
/**
* Expands a cube of cells into a table, creating mutiple rows or columns where a cell in a cube has multiple values.
* @hidden
*/
const expand = (cells, axes, onX, method) => {
// calcuate the x and y splits required
const table = (cube, axes, getElement, onX, method = Math.max) => {
// transform the cube of rows into a cube of cells
const cells = transform(cube, getElement);
// calcuate the x splits required (y splits inlined below)
const xSplits = axes.x.map((_, iX) => onX ? method(...cells.map(row => row[iX].length)) : 1);
const ySplits = cells.map(row => onX ? 1 : method(...row.map(table => table.length)));
// iterate and expand the y axis based on the split data
return reduce(cells, ySplits, (row, ySplit, ysi, iY) =>
// generate the whole table
return expand(cells, cells.map(row => onX ? 1 : method(...row.map(table => table.length))),
// generate x axis header rows
axes.x[0].map((_, iC) => expand(axes.x, xSplits,
// generate the x/y header
axes.y[0].map(() => cell('axis xy')),
// generate the x axis cells
(x) => cell(`axis x ${x[iC].key}`, x[iC].value))),
// iterate and expand the x axis based on the split data
reduce(row, xSplits, (cell, xSplit, xsi) =>
(row, ySplit, ysi, iY) => expand(row, xSplits,
// generate the y axis row header cells
axes.y[iY].map(criterion => cell(`axis y ${criterion.key}`, criterion.value)),
// generate the cube cells
({ ...cell[Math.floor(cell.length * (ysi + xsi) / (xSplit * ySplit))] }),
// generate the y axis row header cells
axes.y[iY].map(criterion => cell(`axis y ${criterion.key}`, criterion.value))),
// generate the x axis column header rows
axes.x[0].map((_, iC) =>
// iterate and expand the x axis
reduce(axes.x, xSplits, x =>
// generate the x axis cells
cell(`axis x ${x[iC].key}`, x[iC].value),
// generate the x/y header
axes.y[0].map(() => cell('axis xy')))));
(cell, xSplit, xsi) => ({ ...cell[Math.floor(cell.length * (ysi + xsi) / (xSplit * ySplit))] })));
};
exports.table = table;
/**

@@ -50,23 +42,25 @@ * Merge adjacent cells in a split table on the y and/or x axes.

let next;
forEachRev(cells, (row, iY) => {
forEachRev(row, (cell, iX) => {
if (onY && iY && (next = cells[iY - 1][iX]) && equals(next, cell) && next.cols === cell.cols) {
for (let iY = cells.length; iY--;) {
const row = cells[iY];
for (let iX = row.length; iX--;) {
const cell = row[iX];
if (onY && iY && (next = cells[iY - 1][iX]) && equals(next, cell, 'cols')) {
next.rows += cell.rows;
row.splice(iX, 1);
}
else if (onX && iX && (next = row[iX - 1]) && equals(next, cell) && next.rows === cell.rows) {
else if (onX && iX && (next = row[iX - 1]) && equals(next, cell, 'rows')) {
next.cols += cell.cols;
row.splice(iX, 1);
}
});
});
}
}
};
exports.merge = merge;
/**
* Creates a cell within a table.
* Transform a cube of rows into a cube of cells.
* @hidden
*/
const cell = (style, value = '', key = '') => ({ key, value, style, rows: 1, cols: 1 });
const transform = (cube, getElement) => cube.map(row => row.map(table => table.length ? cells(table, getElement) : [cell('empty')]));
/**
* Convert a table of rows into a table of cells.
* Transform an array of rows into an array of cells.
* @hidden

@@ -85,26 +79,22 @@ */

/**
* Creates a cell within a table.
* @hidden
*/
const cell = (style, value = '', key = '') => ({ key, value, style, rows: 1, cols: 1 });
/**
* Expands an array using, splitting values into multiple based on a set of corresponding splits then maps the data to a desired structure.
* @hidden
*/
const reduce = (values, splits, callbackfn, seed) => {
values.forEach((value, iValue) => {
const expand = (values, splits, seed, callbackfn) => {
for (let length = values.length, iValue = 0; iValue < length; ++iValue) {
for (let split = splits[iValue], iSplit = 0; iSplit < split; ++iSplit) {
seed.push(callbackfn(value, split, iSplit, iValue));
seed.push(callbackfn(values[iValue], split, iSplit, iValue));
}
});
}
return seed;
};
/**
* A reverse for loop
* @param hidden
*/
const forEachRev = (values, callbackfn) => {
for (let index = values.length; index--;) {
callbackfn(values[index], index);
}
};
/**
* Compare two Elements for equality
* Compare two Elements for equality, using value, style and optionally, one other property.
* @hidden
*/
const equals = (a, b) => a.value === b.value && a.style === b.style;
const equals = (a, b, key) => a.value === b.value && a.style === b.style && (!key || a[key] === b[key]);

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

var landscape;(()=>{"use strict";var e={};(()=>{var s=e;Object.defineProperty(s,"__esModule",{value:!0}),s.merge=s.table=void 0,s.table=(e,s,t,r,c=Math.max)=>a(e.map((e=>e.map((e=>e.length?o(e,t):[l("empty")])))),s,r,c);const a=(e,s,a,o)=>{const r=s.x.map(((s,l)=>a?o(...e.map((e=>e[l].length))):1)),c=e.map((e=>a?1:o(...e.map((e=>e.length)))));return t(e,c,((e,a,o,c)=>t(e,r,((e,s,l)=>({...e[Math.floor(e.length*(o+l)/(s*a))]})),s.y[c].map((e=>l(`axis y ${e.key}`,e.value))))),s.x[0].map(((e,a)=>t(s.x,r,(e=>l(`axis x ${e[a].key}`,e[a].value)),s.y[0].map((()=>l("axis xy")))))))};s.merge=(e,s,a)=>{let l;r(e,((o,t)=>{r(o,((r,p)=>{a&&t&&(l=e[t-1][p])&&c(l,r)&&l.cols===r.cols?(l.rows+=r.rows,o.splice(p,1)):s&&p&&(l=o[p-1])&&c(l,r)&&l.rows===r.rows&&(l.cols+=r.cols,o.splice(p,1))}))}))};const l=(e,s="",a="")=>({key:a,value:s,style:e,rows:1,cols:1}),o=(e,s)=>{const a=[];for(const l of e){const e=s(l);a.some((s=>c(s,e)))||a.push({...e,rows:1,cols:1})}return a},t=(e,s,a,l)=>(e.forEach(((e,o)=>{for(let t=s[o],r=0;r<t;++r)l.push(a(e,t,r,o))})),l),r=(e,s)=>{for(let a=e.length;a--;)s(e[a],a)},c=(e,s)=>e.value===s.value&&e.style===s.style})(),landscape=e})();
var landscape;(()=>{"use strict";var e={};(()=>{var l=e;Object.defineProperty(l,"__esModule",{value:!0}),l.merge=l.table=void 0,l.table=(e,l,s,r,n=Math.max)=>{const c=t(e,s),p=l.x.map(((e,l)=>r?n(...c.map((e=>e[l].length))):1));return o(c,c.map((e=>r?1:n(...e.map((e=>e.length))))),l.x[0].map(((e,t)=>o(l.x,p,l.y[0].map((()=>a("axis xy"))),(e=>a(`axis x ${e[t].key}`,e[t].value))))),((e,t,s,r)=>o(e,p,l.y[r].map((e=>a(`axis y ${e.key}`,e.value))),((e,l,a)=>({...e[Math.floor(e.length*(s+a)/(l*t))]})))))},l.merge=(e,l,t)=>{let s;for(let a=e.length;a--;){const o=e[a];for(let n=o.length;n--;){const c=o[n];t&&a&&(s=e[a-1][n])&&r(s,c,"cols")?(s.rows+=c.rows,o.splice(n,1)):l&&n&&(s=o[n-1])&&r(s,c,"rows")&&(s.cols+=c.cols,o.splice(n,1))}}};const t=(e,l)=>e.map((e=>e.map((e=>e.length?s(e,l):[a("empty")])))),s=(e,l)=>{const t=[];for(const s of e){const e=l(s);t.some((l=>r(l,e)))||t.push({...e,rows:1,cols:1})}return t},a=(e,l="",t="")=>({key:t,value:l,style:e,rows:1,cols:1}),o=(e,l,t,s)=>{for(let a=e.length,o=0;o<a;++o)for(let a=l[o],r=0;r<a;++r)t.push(s(e[o],a,r,o));return t},r=(e,l,t)=>e.value===l.value&&e.style===l.style&&(!t||e[t]===l[t])})(),landscape=e})();
{
"name": "@steelbreeze/landscape",
"version": "3.7.0",
"version": "3.7.1",
"description": "Landscape map viewpoint visualisation",

@@ -19,3 +19,3 @@ "main": "lib/node/index.js",

"@steelbreeze/types": "^1.0.0-rc.5",
"typedoc": "^0.20.36",
"typedoc": "^0.22.11",
"typescript": "^4.2.4",

@@ -26,4 +26,3 @@ "webpack-cli": "^4.7.0"

"build": "tsc -p . && webpack && cp ./lib/web/*.js ./docs/dist/",
"document": "typedoc",
"test": "echo \"Error: no test specified\" && exit 1"
"document": "typedoc"
},

@@ -30,0 +29,0 @@ "repository": {

@@ -68,2 +68,2 @@ # landscape

Copyright (c) 2020-22 David Mesquita-Morris.
Copyright (c) 2022 David Mesquita-Morris.

@@ -30,39 +30,28 @@ import { Function, FunctionVA, Pair } from '@steelbreeze/types';

*/
export const table = <TRow>(cube: Cube<TRow>, axes: Axes<TRow>, getElement: Function<TRow, Element>, onX: boolean, method: FunctionVA<number, number> = Math.max): Array<Array<Cell>> =>
// convert the source data to cells and remove resulting duplicates; create the resultant table
expand(cube.map(row => row.map(table => table.length ? cells(table, getElement) : [cell('empty')])), axes, onX, method);
export const table = <TRow>(cube: Cube<TRow>, axes: Axes<TRow>, getElement: Function<TRow, Element>, onX: boolean, method: FunctionVA<number, number> = Math.max): Array<Array<Cell>> => {
// transform the cube of rows into a cube of cells
const cells = transform(cube, getElement);
/**
* Expands a cube of cells into a table, creating mutiple rows or columns where a cell in a cube has multiple values.
* @hidden
*/
const expand = <TRow>(cells: Cube<Cell>, axes: Axes<TRow>, onX: boolean, method: FunctionVA<number, number>): Array<Array<Cell>> => {
// calcuate the x and y splits required
const xSplits = axes.x.map((_, iX) => onX ? method(...cells.map(row => row[iX].length)) : 1);
const ySplits = cells.map(row => onX ? 1 : method(...row.map(table => table.length)));
// calcuate the x splits required (y splits inlined below)
const xSplits: Array<number> = axes.x.map((_, iX) => onX ? method(...cells.map(row => row[iX].length)) : 1);
// iterate and expand the y axis based on the split data
return reduce(cells, ySplits, (row, ySplit, ysi, iY) =>
// generate the whole table
return expand(cells, cells.map(row => onX ? 1 : method(...row.map(table => table.length))),
// generate x axis header rows
axes.x[0].map((_, iC) => expand(axes.x, xSplits,
// generate the x/y header
axes.y[0].map(() => cell('axis xy')),
// generate the x axis cells
(x) => cell(`axis x ${x[iC].key}`, x[iC].value)
)),
// iterate and expand the x axis based on the split data
reduce(row, xSplits, (cell, xSplit, xsi) =>
(row, ySplit, ysi, iY) => expand(row, xSplits,
// generate the y axis row header cells
axes.y[iY].map(criterion => cell(`axis y ${criterion.key}`, criterion.value)),
// generate the cube cells
({ ...cell[Math.floor(cell.length * (ysi + xsi) / (xSplit * ySplit))] }),
// generate the y axis row header cells
axes.y[iY].map(criterion => cell(`axis y ${criterion.key}`, criterion.value))),
// generate the x axis column header rows
axes.x[0].map((_, iC) =>
// iterate and expand the x axis
reduce(axes.x, xSplits, x =>
// generate the x axis cells
cell(`axis x ${x[iC].key}`, x[iC].value),
// generate the x/y header
axes.y[0].map(() => cell('axis xy')))
));
(cell, xSplit, xsi) => ({ ...cell[Math.floor(cell.length * (ysi + xsi) / (xSplit * ySplit))] })
)
);
}

@@ -79,24 +68,28 @@

forEachRev(cells, (row, iY) => {
forEachRev(row, (cell, iX) => {
if (onY && iY && (next = cells[iY - 1][iX]) && equals(next, cell) && next.cols === cell.cols) {
for (let iY = cells.length; iY--;) {
const row = cells[iY];
for (let iX = row.length; iX--;) {
const cell = row[iX];
if (onY && iY && (next = cells[iY - 1][iX]) && equals(next, cell, 'cols')) {
next.rows += cell.rows;
row.splice(iX, 1);
} else if (onX && iX && (next = row[iX - 1]) && equals(next, cell) && next.rows === cell.rows) {
} else if (onX && iX && (next = row[iX - 1]) && equals(next, cell, 'rows')) {
next.cols += cell.cols;
row.splice(iX, 1);
}
});
});
}
}
}
/**
* Creates a cell within a table.
* Transform a cube of rows into a cube of cells.
* @hidden
*/
const cell = (style: string, value: string = '', key = ''): Cell => ({ key, value, style, rows: 1, cols: 1 });
const transform = <TRow>(cube: Cube<TRow>, getElement: Function<TRow, Element>): Cube<Cell> =>
cube.map(row => row.map(table => table.length ? cells(table, getElement) : [cell('empty')]));
/**
* Convert a table of rows into a table of cells.
* Transform an array of rows into an array of cells.
* @hidden

@@ -107,7 +100,7 @@ */

for (const row of table) {
for(const row of table) {
const element = getElement(row);
if (!result.some(cell => equals(cell, element))) {
result.push({...element, rows: 1, cols: 1});
result.push({ ...element, rows: 1, cols: 1 });
}

@@ -120,11 +113,17 @@ }

/**
* Creates a cell within a table.
* @hidden
*/
const cell = (style: string, value: string = '', key = ''): Cell => ({ key, value, style, rows: 1, cols: 1 });
/**
* Expands an array using, splitting values into multiple based on a set of corresponding splits then maps the data to a desired structure.
* @hidden
*/
const reduce = <TSource, TResult>(values: TSource[], splits: number[], callbackfn: (value: TSource, split: number, iSplit: number, iValue: number) => TResult, seed: TResult[]): TResult[] => {
values.forEach((value, iValue) => {
const expand = <TSource, TResult>(values: TSource[], splits: number[], seed: TResult[], callbackfn: (value: TSource, split: number, iSplit: number, iValue: number) => TResult): TResult[] => {
for (let length = values.length, iValue = 0; iValue < length; ++iValue) {
for (let split = splits[iValue], iSplit = 0; iSplit < split; ++iSplit) {
seed.push(callbackfn(value, split, iSplit, iValue));
seed.push(callbackfn(values[iValue], split, iSplit, iValue));
}
});
}

@@ -135,15 +134,6 @@ return seed;

/**
* A reverse for loop
* @param hidden
*/
const forEachRev = <TValue>(values: Array<TValue>, callbackfn: (value: TValue, index: number) => void): void => {
for (let index = values.length; index--;) {
callbackfn(values[index], index);
}
}
/**
* Compare two Elements for equality
* Compare two Elements for equality, using value, style and optionally, one other property.
* @hidden
*/
const equals = (a: Element, b: Element): boolean => a.value === b.value && a.style === b.style;
const equals = <TElement extends Element>(a: TElement, b: TElement, key?: keyof TElement): boolean =>
a.value === b.value && a.style === b.style && (!key || a[key] === b[key]);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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