@@ -33,6 +33,12 @@ identToJs (Ident name) | nameIsJsReserved name = "$$" ++ name
33identToJs (Ident name) = concatMap identCharToString name
33identToJs (Ident name) = concatMap identCharToString name
34identToJs (Op op) = concatMap identCharToString op
34identToJs (Op op) = concatMap identCharToString op
37+-- Test if a string is a valid JS identifier without escaping.
39+identNeedsEscaping :: String -> Bool
40+identNeedsEscaping s = s /= identToJs (Ident s)
37-- Attempts to find a human-readable name for a symbol, if none has been specified returns the
43-- Attempts to find a human-readable name for a symbol, if none has been specified returns the
38-- ordinal value.
44-- ordinal value.
@@ -130,11 +136,5 @@ nameIsJsReserved name =
131 , "yield" ]
137 , "yield" ]
134−-- Test if a string is a valid JS identifier.
136−isIdent :: String -> Bool
137−isIdent s = identToJs (Ident s) == s
139moduleNameToJs :: ModuleName -> String
139moduleNameToJs :: ModuleName -> String
140moduleNameToJs (ModuleName pns) = intercalate "_" (runProperName `map` pns)
140moduleNameToJs (ModuleName pns) = intercalate "_" (runProperName `map` pns)