JavaScript::Any - evaluate some javascript using the best available Javascript implementation
use JavaScript::Any qw( jseval ); my $sum = jseval('1 + 2'); # 3
Or:
use JavaScript::Any; my $context = JavaScript::Any->new_context; $context->define( say => sub { print @_, "\n" } ); $context->eval('say(1 + 2)');
This module is a thin wrapper around JavaScript::V8, JavaScript::Duktape, and JE, allowing you to evaluate strings of Javascript code from Perl.
This is a very early alpha version. The API still needs documenting and cleaning up a lot.
In particular, the API for defining custom Javascript functions exposes differences between the alternative Javascript implementations. Future versions of JavaScript::Any will smooth some of these out.
This module can export one function. It is not exported by default.
jseval($str)
Evaluates the string of Javascript in a fresh context and returns the result.
For more advanced features, use the object-oriented interface.
JavaScript::Any->new_context(%opts)
Factory method returning an object which implements the JavaScript::Any::Context API.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=JavaScript-Any.
JavaScript::Any::Context.
JavaScript::V8, JavaScript::Duktape, JE.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2017 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install JavaScript::Any, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JavaScript::Any
CPAN shell
perl -MCPAN -e shell install JavaScript::Any
For more information on module installation, please visit the detailed CPAN module installation guide.