Disable new linters which aren't compatible with this code module.
Upgrade github actions to fix caching issues.
Run go mod to bring in new styling.
Remove space on nolint declarations.
Apply all changes to whitespace as required to pass goimports linter.
Only trigger checks on pull_request which works for pulls from other
forks, where as push only works from the same repo.
Prevent loop statements with no body hanging forever
Co-authored-by: Stefano Fratini <stefano.fratini@nnnco.com.au>
Co-authored-by: tkpd-richard-putra <83326962+tkpd-richard-putra@users.noreply.github.com>
Adds basic non ascii support including substring, substr, slice functions,
which work with runes (prevent utf-8 length).
This includes adding runes compatible functions:
* indexOf
* lastIndexOf
Fix a panic in value export when an array has multiple types of arrays.
This takes into account the types of elements in sub arrays, slices, etc.
Fixes#279Fixes#377
Leverage github actions for tests and linting.
This includes fixing a bunch of issues highlighted by golangci
including:
* Dead code.
* Ineffectual assigns.
* Goto warnings.
* Nil return err.
* Reused literal strings.
* Test parameter order.
Also:
* Setup clog.
This change adds two types of tests:
1. First some regular Test* tests that functionally
ensure the test cases are correct.
2. A few Benchmark* tests that then allow us to
measure Otto's performance under various functional scenarios.
The basic tests are just sorting, but I'm planning over time
to bring in more advanced tests (like the CryptoAES) from
popular benchmarking suites (JetStream for instance.)
I intend to run profiler on these tests to find any
ottlenecks or low-hanging fruit that can help speed up
Otto for real-world use-cases.
Next up after this is to add some heavy underscorejs
benchmarks.
Responding to PR comments
* (#257) Change Walk/Visit to follow an explicit Enter/Exit pattern
* (#257) Convert walk example into test.
* (#257) restore walk/visitor example
* (#257) Fix godoc comment in the Visitor interface
... typo referred to `End` method instead of `Exit`
Background:
When methods are attached on a map type like so:
type Foo map[string]string
func (f Foo) Bar() {
fmt.Printf("Hello World");
}
vm := otto.New();
vm.Set("foo", Foo{});
vm.Run(`
foo.Bar();
`);
You get:
Error in Run: TypeError: 'Bar' is not a function
The Fix:
I looked into how/why the same works for arrays. After
all array properties are tested (such as length, and any integer-based members),
the code then looks for any methods attached to that type.
This change literally copies that code over into
maps.
This is very useful when working with the http.Request object which
has the http.Header type that is a map[string][]string, with a lot
of useful methods attached to it.
Added unit test to support/guard the change (and map had no test before)
Responded to PR comments