![]() |
![]()
| ![]() |
![]()
NAMELanguage::Expr::Compiler::js - Compile Language::Expr expression to JavaScript VERSIONThis document describes version 0.29 of Language::Expr::Compiler::js (from Perl distribution Language-Expr), released on 2016-07-03. SYNOPSISuse Language::Expr::Compiler::js; my $jsc = Language::Expr::Compiler::js->new; print $jsc->compile('map({$_**2}, [1, 2, 3])'); # prints: [1, 2, 3].map(function(_){ Math.pow(_, 2) }) # map Expr function to JS function/method/property $jsc->func_mapping->{ceil} = 'Math.ceil'; $jsc->func_mapping->{uc} = '.toUpperCase'; $jsc->func_mapping->{length} = ':length'; print $jsc->compile(q{uc("party like it's ") . ceil(1998.9)}); # prints: "party like it's ".toUpperCase() + Math.ceil(1998.9) DESCRIPTIONCompiles Language::Expr expression to JavaScript code. Some notes:
METHODScompile($expr) => $js_codeConvert Language::Expr expression into JavaScript code. Dies if there is syntax error in expression. HOMEPAGEPlease visit the project's homepage at <https://metacpan.org/release/Language-Expr>. SOURCESource repository is at <https://github.com/sharyanto/perl-Language-Expr>. BUGSPlease report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Language-Expr> When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. AUTHORperlancar <perlancar@cpan.org> COPYRIGHT AND LICENSEThis software is copyright (c) 2016 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|