Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/data/material/components/table/ReactVirtualizedTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import { TableVirtuoso } from 'react-virtuoso';

// Deterministic pseudo random number. See https://stackoverflow.com/a/47593316
function mulberry32(a) {
return () => {
/* eslint-disable */
let t = (a += 0x6d2b79f5);
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
/* eslint-enable */
};
}

const sample = [
['Frozen yoghurt', 159, 6.0, 24, 4.0],
['Ice cream sandwich', 237, 9.0, 37, 4.3],
Expand Down Expand Up @@ -52,8 +64,9 @@ const columns = [
},
];

const random = mulberry32(1);
const rows = Array.from({ length: 200 }, (_, index) => {
const randomSelection = sample[Math.floor(Math.random() * sample.length)];
const randomSelection = sample[Math.floor(random() * sample.length)];
return createData(index, ...randomSelection);
});

Expand Down
15 changes: 14 additions & 1 deletion docs/data/material/components/table/ReactVirtualizedTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import { TableVirtuoso, TableComponents } from 'react-virtuoso';

// Deterministic pseudo random number. See https://stackoverflow.com/a/47593316
function mulberry32(a: number): () => number {
return () => {
/* eslint-disable */
let t = (a += 0x6d2b79f5);
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
/* eslint-enable */
};
}

interface Data {
calories: number;
carbs: number;
Expand Down Expand Up @@ -77,8 +89,9 @@ const columns: ColumnData[] = [
},
];

const random = mulberry32(1);
const rows: Data[] = Array.from({ length: 200 }, (_, index) => {
const randomSelection = sample[Math.floor(Math.random() * sample.length)];
const randomSelection = sample[Math.floor(random() * sample.length)];
return createData(index, ...randomSelection);
});

Expand Down
Loading