1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-11 01:58:05 -05:00

chore(ext/webstorage): custom arity (#14201)

This commit is contained in:
Divy Srivastava 2022-04-04 15:07:26 +05:30 committed by David Sherret
parent 5b234ca270
commit 4fffc0af19
2 changed files with 4 additions and 14 deletions

View file

@ -55,10 +55,7 @@
context: "Argument 2", context: "Argument 2",
}); });
core.opSync("op_webstorage_set", { core.opSync("op_webstorage_set", key, value, this[_persistent]);
keyName: key,
keyValue: value,
}, this[_persistent]);
} }
getItem(key) { getItem(key) {

View file

@ -10,7 +10,6 @@ use deno_core::OpState;
use rusqlite::params; use rusqlite::params;
use rusqlite::Connection; use rusqlite::Connection;
use rusqlite::OptionalExtension; use rusqlite::OptionalExtension;
use serde::Deserialize;
use std::fmt; use std::fmt;
use std::path::PathBuf; use std::path::PathBuf;
@ -135,17 +134,11 @@ pub fn op_webstorage_key(
Ok(key) Ok(key)
} }
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetArgs {
key_name: String,
key_value: String,
}
#[op] #[op]
pub fn op_webstorage_set( pub fn op_webstorage_set(
state: &mut OpState, state: &mut OpState,
args: SetArgs, key: String,
value: String,
persistent: bool, persistent: bool,
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
let conn = get_webstorage(state, persistent)?; let conn = get_webstorage(state, persistent)?;
@ -165,7 +158,7 @@ pub fn op_webstorage_set(
let mut stmt = conn let mut stmt = conn
.prepare_cached("INSERT OR REPLACE INTO data (key, value) VALUES (?, ?)")?; .prepare_cached("INSERT OR REPLACE INTO data (key, value) VALUES (?, ?)")?;
stmt.execute(params![args.key_name, args.key_value])?; stmt.execute(params![key, value])?;
Ok(()) Ok(())
} }