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

745 Commits

Author SHA1 Message Date
Steven Hartland
b6f2991c96
chore: clean up issue tests (#453)
Move all issue tests into issue_test.go and use common naming
convention.
2022-11-26 00:44:36 +00:00
Steven Hartland
041379fef3
fix: field pointers in fieldIndexByName (#452)
Allow pointers to structs in fieldIndexByName.

Also:
* Use reflect.Type.Elem() vs reflect.ValueOf(t).Elem().Type().
* Format bug_test.go to fix lint failure.
2022-11-25 22:13:15 +00:00
Alessandro Rinaldi
37f2928676
fix: support struct pointers (#370)
Fix panic when handling a pointer to a struct.

Fixes #369
2022-11-25 21:48:16 +00:00
Steven Hartland
4c4631625a
fix: string lengths (#450)
Fix string lengths for strings containing code points which require a
Surrogate pair encoding in utf16.

Fixes #388
2022-11-25 21:35:14 +00:00
Steven Hartland
9163a3ee27
ci: enable golangci-lint cache (#451)
Remove skip-cache: true and restore skip-pkg-cache: true and
skip-build-cache: true so that we still cache golangci-lint results
which skip-cache: true disables.
2022-11-25 21:34:48 +00:00
Steven Hartland
e311ec4305
fix: field index on interface (#449)
Don't look on interface types for field names, as it causes a
panic.

Fixes #390
2022-11-25 18:40:32 +00:00
Steven Hartland
ba066df8fc
ci: use setup-go caching (#448)
Use setup-go caching instead of manually rolled version.

Also:
* Bump golangci-lint to 1.50.1.
* Add go 1.19 to test / lint matrix.
* Bump timeout to 6 mins.
2022-11-25 15:00:07 +00:00
Steven Hartland
93072360ee
ci: add goreleaser (#447)
Add goreleaser to enable the easy creation of otto releases.
2022-11-25 13:29:41 +00:00
Erik Nordmark
511d75fba9
chore: update logex (#442)
Update github.com/chzyer/logex to v1.2.1 which has an explicit
LICENSE file to prevent package without alarming compliance
tools.

Signed-off-by: eriknordmark <erik@zededa.com>
2022-10-25 14:53:07 +01:00
Jens Alfke
09fc211e5a
feat: implement MarshalJSON for Value and Object (#437)
Value and Object now conform to the json.Marshaler interface and produce the
correct JSON when passed (directly or indirectly) to json.Marshal().

Before, both types would marshal as "{}" because they're structs with no public
fields.

This fixes some nasty problems marshaling object trees that mix Go and JS
collections. This can happen when you pass a Go collection into a JS function,
which modifies it adding JS values; and then back in Go you marshal the
collection to JSON. Before this commit the JS values would marshal to "{}".
(The new unit test TestNestedJSONMarshaling demonstrates this.)

Fixes #262
2022-10-11 18:56:42 +01:00
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
Richard Putra
201ab5b34f
fix: timeout on empty loop (#440)
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>
2022-10-06 12:45:23 +01:00
shahinv
b87d35c0b8
fix: remove unnecessary len (#424)
Remove extra len call on target variable
2021-10-24 18:01:58 +01:00
amartin
5b0d97091c
feat: basic non ascii support (#423)
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
2021-10-19 18:51:42 +01:00
andig
4eacda02dd
fix: uint<0 comparisons (#421)
Remove impossible conditions for uint comparisons.
2021-10-08 09:47:15 +01:00
Douglas Thrift
12a6322603
fix: export when an array has multiple types (#387)
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 #279
Fixes #377
2021-10-04 14:44:30 +01:00
Steven Hartland
f9375a2569
fix: golang style (#420)
Fix golang style which was broken by github suggestions spacing.
2021-09-27 23:22:13 +01:00
Boris Kostenko
6d2823e7c9
fix: array sort (#267)
Fix array sort issue using toIntSign compare function 

Fixes #266
2021-09-27 22:59:40 +01:00
Steven Hartland
8d2eaa7768
test: add test for issue #186 (#419)
Add a test which exercises issue #186

Also:
* Quote types in "can't convert from %q to %q" errors.
2021-09-27 21:35:16 +01:00
Iskander (Alex) Sharipov
ca9b4f9067
fix: replace single case type switches with if (#322)
Replace single case type switches with if statement.

Found using https://go-critic.github.io/overview.html#singleCaseSwitch-ref
2021-09-27 16:47:34 +01:00
Iskander (Alex) Sharipov
818f7465f8
fix(underscore): remove unneeded wrapping lambda (#320)
Use func value instead of wrapping lambda

Found using https://go-critic.github.io/overview.html#unlambda-ref
2021-09-27 16:34:54 +01:00
Iskander (Alex) Sharipov
43d26482c3
fix: remove unnecessary dereference (#321)
Removed unneeded dereference in builtinJSON_stringifyWalk:
Found using https://go-critic.github.io/overview.html#underef-ref
2021-09-27 16:32:26 +01:00
Iskander (Alex) Sharipov
edceeed7a9
fix: remove commented-out code (#323)
Remove old commented out code that was found using:
https://go-critic.github.io/overview.html#commentedOutCode-ref
2021-09-27 16:31:07 +01:00
Iskander (Alex) Sharipov
d34fc6f56d
fix: scope.reset, set length to 0 (#324)
Fix scope.reset to correctly clear output, while maintaining
the slice size.
2021-09-27 16:30:05 +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
Jongmin Kim
67c8da69a8
fix: test timeout on slow machines (#340)
Fix test timeout on slow machines by extend testing timeout
to 20 secs.

Fixes: #337

Signed-off-by: Jongmin Kim <jmkim@pukyong.ac.kr>
2021-09-27 11:38:29 +01:00
ilyapashuk
08d7b51940
feat: add go.mod support (#376)
Add support for go mod
2021-09-27 11:13:58 +01:00
Robert-André Mauchin
dee429e322
fix: go vet 1.15 warnings (#385)
Convert int to string using rune()

See https://github.com/golang/go/issues/32479

Fix #384.

Signed-off-by: Robert-André Mauchin <zebob.m@gmail.com>
2021-09-27 11:11:52 +01:00
Luka Zakrajšek
373ff54384
fix: Incorrect groups offsets if lastIndex is set (#393) 2021-06-14 19:17:06 +01:00
Conrad Pankoff
ef014fd054 improve error messages when converting values 2020-09-23 08:17:31 +10:00
Conrad Pankoff
c382bd3c16 fix field accesses on anonymous embedded structs 2019-12-20 10:40:10 +11:00
Conrad Pankoff
37f8e9a246 support Number.isNaN 2019-12-17 17:34:20 +11:00
Conrad Pankoff
9fa7c0c0f8 support converting to json.RawMessage 2019-12-15 13:36:24 +11:00
Conrad Pankoff
b839e7b8bb support methods on go array values 2019-12-15 13:18:22 +11:00
Conrad Pankoff
3ef5863438 allow conversion from [u]int* to float 2019-12-15 13:18:22 +11:00
Conrad Pankoff
0f57984957 use consistent field access rules across read/write and argument conversion 2019-12-15 13:18:22 +11:00
ia
15f95af6e7 all: gofmt (#307)
Run standard gofmt command on project root.

- go version go1.10.3 darwin/amd64

Signed-off-by: ia <isaac.ardis@gmail.com>
2018-06-17 14:11:54 +01:00
deoxxa
03d472dc43 extend convertCallParameter passthrough behaviour to _goArrayObject 2018-05-06 18:43:58 +10: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
carterjones
6c383dd335 fix whitespace issues (#297) 2018-03-05 04:20:45 +00:00
Steven Hartland
58e9cfdd5d
Revert "Update sourcemaps to v2 (#293)" (#296)
This reverts commit 67b2826a26.
2018-03-03 15:22:00 +00:00
Eric Reis Figueiredo
67b2826a26 Update sourcemaps to v2 (#293)
Update sourcemaps to gopkg.in/sourcemap.v2 in order to avoid possible golang error discussed in #291
2018-03-03 10:15:14 +00:00
Tao Wen
3b44b4dcb6 fix idx of throw and if (#286)
* fix idx of throw and if

* add test to cover if/throw statement idx
2017-11-30 10:32:05 +00:00
deoxxa
68a29f5e29 add test for issue #269 2017-10-11 17:07:14 +11:00
Conrad Pankoff
c284572e9b Merge pull request #275 from deoxxa/implement-function-caller
implement Function.caller
2017-10-03 09:47:08 +11:00
deoxxa
eb255cd1e9 implemet Function.caller 2017-10-03 09:46:37 +11:00