aboutsummaryrefslogblamecommitdiffstats
path: root/src/util/identifier.rs
blob: 4887e021737f75cbc2de37df363c5d85dfa19416 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                               
//! Info on JavaScript identifiers.

use unicode_id::UnicodeID;

/// Check if a character can start a JS identifier.
pub fn id_start(char: char) -> bool {
    UnicodeID::is_id_start(char) || matches!(char, '$' | '_')
}

/// Check if a character can continue a JS (or JSX) identifier.
pub fn id_cont(char: char, jsx: bool) -> bool {
    UnicodeID::is_id_continue(char)
        || matches!(char, '\u{200c}' | '\u{200d}')
        || (jsx && char == '-')
}