Bookmark this: tool.io/parse/matrix/source-code
Numeric Matrix Parser Source Code
Browse the implementation files for Numeric Matrix Parser.tool.ts typescript
import {
parseNumericMatrix,
type NumericMatrix
} from '@tool.io/tools/parse/matrix';
export { parseNumericMatrix, type NumericMatrix };
export const normalizeMatrix = (input: unknown): string => {
const matrix = parseNumericMatrix(input);
return matrix === null ? '' : JSON.stringify(matrix);
};
export const Tool: TypeTool = {
name: 'Numeric Matrix Parser',
slug: 'parse/matrix',
intro:
'Parse a rectangular numeric matrix from JSON or rows of comma- or space-separated values.',
tool: normalizeMatrix,
i: [
{
example: '1, 2, 3\n4, 5, 6',
label: 'Matrix',
placeholder: 'Enter matrix rows',
render: 'textarea',
type: 'text'
}
],
o: [
{
example:
'{"columns":3,"kind":"matrix/number","rows":2,"values":[[1,2,3],[4,5,6]],"version":1}',
label: 'Parsed Matrix',
placeholder: 'Parsed matrix will appear here...',
render: 'textarea',
type: 'text'
}
]
};
export default Tool;
Description
Browse the implementation files for Numeric Matrix Parser.