Skip to content

Commit

Permalink
Pattern Match Cleanup (#9)
Browse files Browse the repository at this point in the history
simplify pattern matches with ..
  • Loading branch information
JonasGruenwald authored Jun 23, 2024
1 parent 45b8645 commit 945f131
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/chrobot.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ pub fn as_value(
decoder,
) {
case result {
Ok(runtime.RemoteObject(_, _, _, Some(value), _, _, _)) -> {
Ok(runtime.RemoteObject(value: Some(value), ..)) -> {
decoder(value)
|> result.replace_error(chrome.ProtocolError)
}
Expand Down Expand Up @@ -661,7 +661,7 @@ pub fn select_all(on page: Page, matching selector: String) {
let selector_code = "window.document.querySelectorAll(\"" <> selector <> "\")"
let result = eval(page, selector_code)
case result {
Ok(runtime.RemoteObject(_, _, _, _, _, _, Some(remote_object_id))) -> {
Ok(runtime.RemoteObject(object_id: Some(remote_object_id), ..)) -> {
use result_properties <- result.try(runtime.get_properties(
page_caller(page),
remote_object_id,
Expand Down Expand Up @@ -689,16 +689,11 @@ pub fn select_all(on page: Page, matching selector: String) {
list.filter_map(property_descriptors, fn(prop_descriptor) {
case prop_descriptor {
runtime.PropertyDescriptor(
_,
Some(runtime.RemoteObject(_, _, _, _, _, _, Some(object_id))),
_,
_,
_,
_,
_,
_,
_,
_,
value: Some(runtime.RemoteObject(
object_id: Some(object_id),
..,
)),
..,
) -> {
Ok(object_id)
}
Expand Down Expand Up @@ -896,7 +891,7 @@ fn handle_eval_response(eval_response) {

fn handle_object_id_response(response) {
case response {
Ok(runtime.RemoteObject(_, _, _, _, _, _, Some(remote_object_id))) -> {
Ok(runtime.RemoteObject(object_id: Some(remote_object_id), ..)) -> {
Ok(remote_object_id)
}
Ok(_) -> {
Expand Down Expand Up @@ -985,7 +980,10 @@ pub fn call_custom_function_on(
))
}
runtime.CallFunctionOnResponse(
runtime.RemoteObject(_, _, _, Some(value), _, _, _),
runtime.RemoteObject(
value: Some(value),
..,
),
None,
) -> {
value_decoder(value)
Expand Down

0 comments on commit 945f131

Please sign in to comment.