mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-12 07:06:07 +00:00
Add binding for String.prototype.toLowerCase
This commit is contained in:
parent
bfffd58683
commit
58560f1408
@ -1065,6 +1065,13 @@ extern "C" {
|
|||||||
#[wasm_bindgen(method, js_class = "String")]
|
#[wasm_bindgen(method, js_class = "String")]
|
||||||
pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
|
pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
|
||||||
|
|
||||||
|
/// The toLowerCase() method returns the calling string value
|
||||||
|
/// converted to lower case.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase
|
||||||
|
#[wasm_bindgen(method, js_class = "String", js_name = toLowerCase)]
|
||||||
|
pub fn to_lower_case(this: &JsString) -> JsString;
|
||||||
|
|
||||||
/// The toString() method returns a string representing the specified object.
|
/// The toString() method returns a string representing the specified object.
|
||||||
///
|
///
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString
|
||||||
|
@ -396,6 +396,32 @@ fn substr() {
|
|||||||
.test()
|
.test()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn to_lower_case() {
|
||||||
|
project()
|
||||||
|
.file("src/lib.rs", r#"
|
||||||
|
#![feature(proc_macro, wasm_custom_section)]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
use wasm_bindgen::js;
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn string_to_lower_case(this: &js::JsString) -> js::JsString {
|
||||||
|
this.to_lower_case()
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.file("test.ts", r#"
|
||||||
|
import * as assert from "assert";
|
||||||
|
import * as wasm from "./out";
|
||||||
|
|
||||||
|
export function test() {
|
||||||
|
assert.equal(wasm.string_to_lower_case("Mozilla"), "mozilla");
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.test()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_string() {
|
fn to_string() {
|
||||||
project()
|
project()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user