Skip to content
Astera Technology

Frame scans using the supplied terminator

Retain complete frames and an unfinished tail without guessing boundaries.

Download complete case notes and answer keys ↓

Set the decision and its input

The fictional capture grammar ends a frame with ENTER and expects a three-character code. A12 ENTER B34 ENTER supplies two frames. Concatenating all characters instead creates A12B34. One ENTER after that combined string supplies one oversized frame requiring review, not two proven scans.

Filled local test worksheet
CaseInput JSON
Base test{"keys":["A","1","2","ENTER","B","3","4","ENTER"]}
Download editable CSV ↓

Run the supplied comparison

The state machine closes frames only on the stated terminator. Frame admission is separate from catalogue lookup; these characters never create a stock movement.

Faulty and required outputs
PathOutput JSON
Faulty path{"frames":["A12B34"],"pending":"","requiresReview":false}
Required path{"frames":["A12","B34"],"pending":"","requiresReview":false}
Download editable CSV ↓
Complete local Node24.14.1 programme
import assert from 'node:assert/strict';

const run=function run(i,corrected=true){
    const frames=[];let pending='';for(const key of i.keys){if(key==='ENTER'){if(corrected){frames.push(pending);pending='';}}else pending+=key;}
    if(!corrected&&pending){frames.push(pending);pending='';}
    return {frames,pending,requiresReview:corrected&&(pending!==''||frames.some(f=>f.length!==3))};
  };
const cases=[{"input":{"keys":["A","1","2","ENTER","B","3","4","ENTER"]},"corrected":false,"expected":{"frames":["A12B34"],"pending":"","requiresReview":false}},{"input":{"keys":["A","1","2","ENTER","B","3","4","ENTER"]},"corrected":true,"expected":{"frames":["A12","B34"],"pending":"","requiresReview":false}},{"input":{"keys":["A","1","2","B","3","4","ENTER"]},"corrected":true,"expected":{"frames":["A12B34"],"pending":"","requiresReview":true}},{"input":{"keys":["A","1","2"]},"corrected":true,"expected":{"frames":[],"pending":"A12","requiresReview":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Download runnable example ↓

Choose from the boundary evidence

Unterminated A12 stays pending. A six-character frame is retained whole with review required.

  1. Collect the pending characters
  2. Close on the declared terminator
  3. Check frame length before lookup

Do not invent a terminator from a familiar code shape.

Editable boundary inputs and outputs
ConditionInput JSONExpected output JSON
one combined frame{"keys":["A","1","2","B","3","4","ENTER"]}{"frames":["A12B34"],"pending":"","requiresReview":true}
unterminated tail{"keys":["A","1","2"]}{"frames":[],"pending":"A12","requiresReview":true}
Download editable CSV ↓

Can the combined frame be split automatically into A12 and B34?

Show the worked answer

No. Only one terminator exists. Retain A12B34 as one unresolved frame and obtain the missing framing evidence.

Related resources