1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00
Commit Graph

34 Commits

Author SHA1 Message Date
Steven Hartland
7009038f79
fix: linting errors (#441)
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.
2022-10-08 00:12:19 +01:00
Steven Hartland
9297a9abe4
feat: add github action tests and linting (#418)
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.
2021-09-27 16:19:28 +01:00
Steven Hartland
209b1fb8e8
Revert "feat: support null value returns for toValue (#325)" (#417)
This reverts commit 26cb6ccce6.
2021-09-27 12:00:52 +01:00
Ryan
26cb6ccce6
feat: support null value returns for toValue (#325)
Add nullValue as the return value for the nil case in toValue.

Co-authored-by: Ryan Macleod <ryan.macleod@cumul8.com>
2021-09-27 11:47:21 +01:00
Conrad Pankoff
9fa7c0c0f8 support converting to json.RawMessage 2019-12-15 13:36:24 +11:00
deoxxa
e335b9a887 implement TextUnmarshaller function parameter conversion 2018-05-06 18:12:42 +10:00
deoxxa
09c2169283 implement and test basic [object Object] -> struct conversion 2018-05-06 17:43:12 +10:00
deoxxa
e177400a34 fix a bug related to converting Value objects to specific interfaces 2018-05-06 14:28:05 +10:00
deoxxa
68a29f5e29 add test for issue #269 2017-10-11 17:07:14 +11:00
deoxxa
1fe0007dcb refactor native function parameter conversion
* add benchmarks and tests for native function calls
* improve conversion of various native function parameters
* add support for more types of native function parameters
* improve performance of most parameter types
2016-05-07 21:35:17 +10:00
Steven Hartland
af6c304c5a Merge pull request #107 from multiplay/call-params
Improve method call parameter processing
2015-12-01 13:14:24 +00:00
Steven Hartland
526e6b2be2 Merge pull request #106 from multiplay/float-precision
Prevent loss of float precision
2015-12-01 13:13:51 +00:00
Steven Hartland
e378501ad1 Merge pull request #108 from multiplay/array-types
Export arrays to common type if possible
2015-12-01 13:13:00 +00:00
Tim Cooper
d1b4d8ef0e Fix Go map iteration when looping over non-string keys 2015-03-01 16:44:54 -08:00
Steven Hartland
a30a6a7b53 Improve method call parameter processing
Add support for the final parameter to a variadic function to be a slice.

Add support for conversion of slice parameters.

Expand numeric conversion support to include all int and uint types as souce types. This allows the result of bitwise calculations (int32) to be passed in as parameters.
2015-02-19 11:45:35 +00:00
Steven Hartland
abcc601db6 Prevent loss of float precision
When automatically converting a float to int type ensure we don't loose any precision.
2015-02-19 11:33:21 +00:00
Steven Hartland
72d92c8e19 Export arrays to common type if possible
If there is a common type for all values in an array export to a slice of that type otherwise return a slice of interfaces.
2015-02-17 23:18:23 +00:00
Robert Krimen
c2346f4ada Merge pull request #103 from multiplay/multi-return
Support go multiple return values as an array
2015-02-15 16:28:43 -08:00
Steven Hartland
c25bb49761 Automatic numeric parameter conversion
Javascript uses int64 (literals) and float64 (default) representations for numbers so to allow easy use of go funcs apply automatic conversion for function parameters where it is safe to do so.
2015-02-12 15:48:45 +00:00
Steven Hartland
81b01b9fac Support go multiple return values as an array
Add support for go funcs which return multiple values by returning them as an array.

In the future this can be used along side destructuring assignment to provide a nice way to deal with multiple value returns e.g.
[val, err] = MyGoFunc()
2015-02-12 15:10:58 +00:00
Robert Krimen
6c7c425424 Fix toReflectValue to handle Struct, Map, Slice, etc.
This fixes #79
2014-06-04 18:08:42 -07:00
Robert Krimen
98be5e74da go vet
This fixes #76

I cheated on some of these.
2014-05-28 21:46:08 -07:00
Robert Krimen
ba678bc782 Use _runtime.toValue() instead of func toValue()
This fixes #72
2014-05-22 20:39:27 -07:00
Robert Krimen
470b8c3b73 terst
* Update to latest github.com/robertkrimen/terst
* Clean up testing
2014-04-25 22:48:25 -07:00
Robert Krimen
ad8a97c028 New parser
* Faster, more straightforward, etc.
* More advanced object literals (get ..., set ...)
* More tests using JavaScript from the wild (http://cdnjs.com/)
2014-04-10 20:42:25 -07:00
Daniel Cannon
07737f86b9 Add ability to call struct methods
This fixes #60

This is incompatible with go 1.0.3
2014-03-16 09:04:00 -07:00
Robert Krimen
6669f98a8e Improve type_go_* behavior 2013-05-31 22:50:51 -07:00
Robert Krimen
64182c96bd Handle Ptr properly in type_go_*
Though I'm not sure that &map..., or &[]..., makes sense.
2013-05-30 19:17:57 -07:00
Robert Krimen
f745b98f2b Handle struct, map, & array/slice in exportNative 2013-05-30 18:57:33 -07:00
Robert Krimen
58eefe5c3d Handle toReflectValue of interface{}
Fix #19
2013-05-29 22:45:01 -07:00
Robert Krimen
7e2b4f2063 Rewrite of property handling to be more robust and compliant
* No more _stash
* Now using a "virtual table" system via _objectClass
* Make Array.concat GoArray compatible (via .isArray())

Fix #16
2013-05-12 14:14:51 -07:00
Robert Krimen
9184233705 Bundle terst dependency (github.com/robertkrimen/terst) 2013-04-15 10:20:34 -07:00
Robert Krimen
15aadd333c Upgrade underscore to 1.4.4, including tests 2013-02-04 21:58:47 -08:00
Robert Krimen
a879744c20 Add Go <=> JavaScript type interaction
Via reflection for struct, map, and slice/array
Fix #10
2013-02-04 10:31:44 -08:00