notion-utils
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -40,4 +40,13 @@ "use strict"; | ||
return formula.name === 'true'; | ||
case 'constant': | ||
return formula.value; | ||
case 'constant': { | ||
const value = formula.value; | ||
switch (formula.result_type) { | ||
case 'text': | ||
return value; | ||
case 'number': | ||
return parseFloat(value); | ||
default: | ||
return value; | ||
} | ||
} | ||
case 'property': | ||
@@ -128,4 +137,14 @@ const value = ctx.properties[formula.id]; | ||
case 'add': | ||
return (evalFormula(args[0], ctx) + | ||
evalFormula(args[1], ctx)); | ||
const v0 = evalFormula(args[0], ctx); | ||
const v1 = evalFormula(args[1], ctx); | ||
if (typeof v0 === 'number') { | ||
return v0 + +v1; | ||
} | ||
else if (typeof v0 === 'string') { | ||
return v0 + `${v1}`; | ||
} | ||
else { | ||
// TODO | ||
return v0; | ||
} | ||
case 'cbrt': | ||
@@ -132,0 +151,0 @@ return Math.cbrt(evalFormula(args[0], ctx)); |
{ | ||
"name": "notion-utils", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Useful utilities for working with Notion data. Isomorphic.", | ||
@@ -18,3 +18,3 @@ "repository": "saasify-sh/notion-kit", | ||
"date-fns": "^2.15.0", | ||
"notion-types": "^1.3.1" | ||
"notion-types": "^1.3.2" | ||
}, | ||
@@ -25,3 +25,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "e5532c42ec118797bb5c0e38e61b61dc2a32f567" | ||
"gitHead": "cb2f95c77ce41647604e57bdbc8913c9868f8388" | ||
} |
@@ -50,4 +50,13 @@ import * as types from 'notion-types' | ||
case 'constant': | ||
return formula.value | ||
case 'constant': { | ||
const value = formula.value | ||
switch (formula.result_type) { | ||
case 'text': | ||
return value | ||
case 'number': | ||
return parseFloat(value) | ||
default: | ||
return value | ||
} | ||
} | ||
@@ -164,7 +173,14 @@ case 'property': | ||
case 'add': | ||
return ( | ||
(evalFormula(args[0], ctx) as number) + | ||
(evalFormula(args[1], ctx) as number) | ||
) | ||
const v0 = evalFormula(args[0], ctx) | ||
const v1 = evalFormula(args[1], ctx) | ||
if (typeof v0 === 'number') { | ||
return v0 + +v1 | ||
} else if (typeof v0 === 'string') { | ||
return v0 + `${v1}` | ||
} else { | ||
// TODO | ||
return v0 | ||
} | ||
case 'cbrt': | ||
@@ -171,0 +187,0 @@ return Math.cbrt(evalFormula(args[0], ctx) as number) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8128
413901
129
Updatednotion-types@^1.3.2