Configure allowed partial types using the Allow object
mainThe Allow object is an Enum used to control which types of data can be returned in a partial state. You pass these constants to the parse function using a bitwise OR (|).
If a type is not included in the allow bitmask, the parser will only include that value in the result once it is fully completed. For example, if you only allow OBJ but not STR, an incomplete string inside an object will cause that key to be omitted entirely until the string is closed.
import { parse, OBJ, STR } from "partial-json";
// Without STR, the key is omitted because the value is incomplete
const result1 = parse('{"key": "v', OBJ);
console.log(result1); // Outputs: {}
// With STR, the partial value is captured
const result2 = parse('{"key": "v', STR | OBJ);
console.log(result2); // Outputs: { key: 'v' }