Skip to content

Commit

Permalink
support numbers by default, bigints can be later
Browse files Browse the repository at this point in the history
  • Loading branch information
nudded committed Oct 28, 2024
1 parent 7575abe commit 503ed06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions expression-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ elem.oninput = function () {
error.innerHTML = "";
try {
expression = parseExpression(elem.value);
output.innerHTML = evaluateExpression(expression, "code", BigInt(1231254123), {
started_at: BigInt(123124123),
ended_at: BigInt(1241231241),
replicas: BigInt(8),
output.innerHTML = evaluateExpression(expression, "code", 1231254123, {
started_at: 123124123,
ended_at: 1241231241,
replicas: 8,
});
} catch (e) {
error.innerHTML = e;
Expand Down
6 changes: 3 additions & 3 deletions expression-js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn parse_expression(expression: String) -> Result<Expression, String> {
pub fn evaluate_expression(
expression: Expression,
code: String,
timestamp: u64,
timestamp: u32,
js_properties: &JsValue,
) -> Result<JsValue, JsValue> {
let mut properties = HashMap::new();
Expand All @@ -43,7 +43,7 @@ pub fn evaluate_expression(
let insert = if value.is_string() {
String::try_from(value)?
} else {
let n = u64::try_from(value)?;
let n = f64::try_from(value)?;
format!("{n}")
};

Expand All @@ -52,7 +52,7 @@ pub fn evaluate_expression(

let event = expression_core::Event {
code,
timestamp,
timestamp: timestamp.into(),
properties,
};

Expand Down

0 comments on commit 503ed06

Please sign in to comment.