From e077b93d77d42f805ceb7a58cdc3c42255c0a30b Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Thu, 1 Oct 2020 20:33:15 +1000 Subject: refactor: add concept of 'legacy' compiler to enable non-breaking refactoring (#7762) --- cli/tsc.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'cli/tsc.rs') diff --git a/cli/tsc.rs b/cli/tsc.rs index 9b944125f..f1e49167a 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -942,6 +942,11 @@ impl TsCompiler { } } +#[derive(Debug, Deserialize)] +struct CreateHashArgs { + data: String, +} + fn execute_in_tsc( global_state: Arc, req: String, @@ -975,6 +980,14 @@ fn execute_in_tsc( Ok(json!({})) }), ); + js_runtime.register_op( + "op_create_hash", + json_op_sync(move |_s, args, _bufs| { + let v: CreateHashArgs = serde_json::from_value(args)?; + let hash = crate::checksum::gen(&[v.data.as_bytes()]); + Ok(json!({ "hash": hash })) + }), + ); } let bootstrap_script = format!( -- cgit v1.2.3