superui_boa_engine 0.2.2

Fork of boa_engine (boa 0.21.1) vendored for superui so the boa_parser stack-growth patch is publishable; also carries a relaxed icu_normalizer pin. See docs/fork-patches.md. Upstream: https://github.com/boa-dev/boa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use icu_plurals::PluralRuleType;

use crate::{Context, JsNativeError, JsResult, JsValue, builtins::options::OptionType};

impl OptionType for PluralRuleType {
    fn from_value(value: JsValue, context: &mut Context) -> JsResult<Self> {
        match value.to_string(context)?.to_std_string_escaped().as_str() {
            "cardinal" => Ok(Self::Cardinal),
            "ordinal" => Ok(Self::Ordinal),
            _ => Err(JsNativeError::range()
                .with_message("provided string was not `cardinal` or `ordinal`")
                .into()),
        }
    }
}