mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
chore: Fix magic number
Co-authored-by: Reda Al Sulais <u.yokozuna@gmail.com>
This commit is contained in:
parent
1a8743ec11
commit
068a74adeb
@ -6,6 +6,8 @@ import { populateCommonDb } from '../common/populateCommonDb.js';
|
|||||||
import { db } from './db.js';
|
import { db } from './db.js';
|
||||||
import type { Block, Row } from './types.js';
|
import type { Block, Row } from './types.js';
|
||||||
|
|
||||||
|
const maxPacketSize = 10_000;
|
||||||
|
|
||||||
const populate = (ast: Packet) => {
|
const populate = (ast: Packet) => {
|
||||||
populateCommonDb(ast, db);
|
populateCommonDb(ast, db);
|
||||||
let lastByte = -1;
|
let lastByte = -1;
|
||||||
@ -16,7 +18,7 @@ const populate = (ast: Packet) => {
|
|||||||
if (end && end < start) {
|
if (end && end < start) {
|
||||||
throw new Error(`Packet block ${start} - ${end} is invalid. End must be greater than start.`);
|
throw new Error(`Packet block ${start} - ${end} is invalid. End must be greater than start.`);
|
||||||
}
|
}
|
||||||
if (start != lastByte + 1) {
|
if (start !== lastByte + 1) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Packet block ${start} - ${end ?? start} is not contiguous. It should start from ${
|
`Packet block ${start} - ${end ?? start} is not contiguous. It should start from ${
|
||||||
lastByte + 1
|
lastByte + 1
|
||||||
@ -26,7 +28,7 @@ const populate = (ast: Packet) => {
|
|||||||
lastByte = end ?? start;
|
lastByte = end ?? start;
|
||||||
log.debug(`Packet block ${start} - ${lastByte} with label ${label}`);
|
log.debug(`Packet block ${start} - ${lastByte} with label ${label}`);
|
||||||
|
|
||||||
while (word.length <= bitsPerRow + 1 && db.getPacket().length < 10_000) {
|
while (word.length <= bitsPerRow + 1 && db.getPacket().length < maxPacketSize) {
|
||||||
const [block, nextBlock] = getNextFittingBlock({ start, end, label }, row, bitsPerRow);
|
const [block, nextBlock] = getNextFittingBlock({ start, end, label }, row, bitsPerRow);
|
||||||
word.push(block);
|
word.push(block);
|
||||||
if (block.end + 1 === row * bitsPerRow) {
|
if (block.end + 1 === row * bitsPerRow) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user