Saving glyphs
This commit is contained in:
parent
2e05df8035
commit
f426573f96
3 changed files with 78 additions and 9 deletions
|
|
@ -62,6 +62,7 @@ export const _rt = {
|
|||
: { _tag: 'None' },
|
||||
len: (xs: any[] | string) => xs.length,
|
||||
// str: (x: any) => String(x),
|
||||
int: (x: any) => typeof x === 'number' ? Math.floor(x) : parseInt(x, 10) || 0,
|
||||
show: (value: any): string => {
|
||||
if (value === null || value === undefined) return "None";
|
||||
if (typeof value === 'string') return value;
|
||||
|
|
@ -126,8 +127,12 @@ export const _rt = {
|
|||
store[name] = pathOrValue;
|
||||
} else {
|
||||
const path = pathOrValue as string[];
|
||||
if (store[name] === undefined) store[name] = {};
|
||||
let obj = store[name];
|
||||
for (let i = 0; i < path.length - 1; i++) {
|
||||
if (obj[path[i]] === undefined || obj[path[i]] === null) {
|
||||
obj[path[i]] = {};
|
||||
}
|
||||
obj = obj[path[i]];
|
||||
}
|
||||
obj[path[path.length - 1]] = maybeValue;
|
||||
|
|
@ -327,7 +332,8 @@ function valueToAst(value: any): AST {
|
|||
}
|
||||
|
||||
export function syncToAst(name: string) {
|
||||
if (definitions.has(name)) {
|
||||
// if (definitions.has(name)) {
|
||||
if (name in store) {
|
||||
definitions.set(name, valueToAst(store[name]));
|
||||
const source = prettyPrint({ kind: 'definition', name, body: definitions.get(name)! });
|
||||
appendChangeLog(name, source);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue