2module Generate.JavaScript.Helpers where
4import qualified AST.Helpers as Help
5import Language.ECMAScript3.Syntax
7dolarize :: String -> String
8dolarize x = map (\c -> if c == '.' then '$' else c) x
10split :: String -> [String]
14 case break (=='.') str of
15 (x,_:rest) | Help.isOp x -> vars ++ [x ++ '.' : rest]
16 | otherwise -> go (vars ++ [x]) rest
22ref :: String -> Expression ()
23ref name = VarRef () (var name)
25prop name = PropId () (var name)
26f <| x = CallExpr () f [x]
27ret e = ReturnStmt () (Just e)
28args ==> e = FuncExpr () Nothing (map var args) [ ret e ]
29function args stmts = FuncExpr () Nothing (map var args) stmts
33dotSep :: [String] -> Expression ()
36 x:xs -> foldl (DotRef ()) (ref x) (map var xs)
37 [] -> error "dotSep must be called on a non-empty list of variables"
41equal a b = InfixExpr () OpStrictEq a b
43 InfixExpr () OpLAnd (typeof "object" x) (InfixExpr () OpInstanceof x (ref tipe))
44typeof tipe x = equal (PrefixExpr () PrefixTypeof x) (string tipe)
45member field x = InfixExpr () OpIn (string field) x
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list