refactor: extract coerce and stressorToString into util.js
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
import { coerce } from './util.js';
|
||||
|
||||
const LINE_RE = /^(\d{2}) (\S+(?:\.\S+)*) ?(.*)/;
|
||||
const DEBUG_RE = /^\d{2} # DEBUG/;
|
||||
|
||||
|
||||
export function coerce(s) {
|
||||
if (s === 'True' || s === 'Y' || s === 'on' || s === 'true') return true;
|
||||
if (s === 'False' || s === 'N' || s === 'off' || s === 'false') return false;
|
||||
if (s === '') return s;
|
||||
const n = Number(s);
|
||||
if (!isNaN(n)) return n;
|
||||
return s;
|
||||
}
|
||||
|
||||
export function parseAstLog(text) {
|
||||
const root = { slot: 'root', parentSlot: null, depth: -1, positionals: [], props: {}, children: [] };
|
||||
const stack = [root];
|
||||
|
||||
Reference in New Issue
Block a user