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

13 Commits

Author SHA1 Message Date
Steven Hartland
898a889ed4
fix: missing regexp capture panic (#477)
Fix RegExp panic when a capture doesn't match but the full expression
does.
2022-12-05 22:51:22 +00:00
Steven Hartland
026a1d9a9c
chore: lint and naming refactor (#475)
Enable more linters, address the issues and do a major naming refactor
to use golang lower camelCase identifiers for types, functions, methods
and variable names.

Also: 
* Clean up inline generation so it doesn't rely on temporary variables.
* Remove unused functions generated by inline.pl.
2022-12-04 21:49:38 +00:00
Steven Hartland
7de4257c77
fix: number locale support (#472)
Add support for Number.toLocaleString() which was previously just using
toString.

Default locale is: en-US

Fixes #285
2022-11-29 12:57:48 +00:00
Steven Hartland
eb72a6e703
fix: reduce current index type (#468)
While not specified in the ECMA specification the current index has been
typed as number by others, so match this instead of passing as string.

Fixes #177
2022-11-28 18:59:19 +00:00
Steven Hartland
ec2dc5ec24
fix: map export (#467)
When exporting a map check for values which are otto.Value and process
them. This is a one level export and no additional traversal is done.

Fixes #252
2022-11-28 17:21:20 +00:00
Steven Hartland
c745096260
fix: regexp substring matches (#466)
Set RegExp.input, RegExp.$_ and RegExp.$1 -> $9 substring matches on
successful match.

Fixes #317
2022-11-28 15:50:55 +00:00
Steven Hartland
3697ad1504
fix: stack panic truncation (#465)
Fix stack being truncated due to double conversion to _error.

Fixes #329
2022-11-28 14:07:27 +00:00
Steven Hartland
aeda017882
fix!: date underflow / overflow and utc (#464)
Use time.UnixMilli instead of UnixNano for time calculations to avoid
underflow / overflow issues.

BREAKING CHANGE: Use a GMT fixed time zone for UTC to mimic toUTCString
behaviour of Javascript which outputs in GMT not UTC.

Fixes #302
2022-11-28 13:00:51 +00:00
Steven Hartland
c4b94300e3
feat: support push to go slices (#460)
Add support for direct use of push to go slices without converting to
array using .slice().

Fixes #357

Also:
* Add classGoSlice and use it, to make it clear the type when debugging.
2022-11-27 23:09:00 +00:00
Steven Hartland
a3b51c68f2
chore: enable whitespace linter and fix errors (#456)
Enable the whitespace linter and fix the errors resulting from it.

Also:
* Remove unneeded golangci-lint config for disabled linters.
* Correct test number for panic in previous commit.
2022-11-26 13:33:09 +00:00
Steven Hartland
52d4954a54
fix: catch panic in try catch (#455)
Ensure that a panic is caught if thrown in a try catch block.

Fixes #382
2022-11-26 11:35:10 +00:00
Steven Hartland
08e7a8d472
fix: array writes (#454)
Fix array writes not being persisted by passing in writeable
reflect.Value when available instead of .Interface() which looses that
property.

Also:
* Use value.IsValid() instead of comparison with zero entry.
* Use propertyLength instead of literal.

Fixes #386
2022-11-26 02:57:29 +00:00
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