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

Add enumeration for Arguments (argumentsEnumerate)

This commit is contained in:
Robert Krimen 2013-06-02 16:21:49 -07:00
parent 1b469aefc1
commit 8b16ca18d8
2 changed files with 17 additions and 1 deletions

View File

@ -83,7 +83,7 @@ func init() {
objectHasOwnProperty,
argumentsDefineOwnProperty,
argumentsDelete,
objectEnumerate,
argumentsEnumerate,
}
_classGoStruct = &_objectClass{

View File

@ -1,5 +1,9 @@
package otto
import (
"strconv"
)
func (runtime *_runtime) newArgumentsObject(indexOfParameterName []string, environment _environment, length int) *_object {
self := runtime.newClassObject("Arguments")
@ -83,3 +87,15 @@ func argumentsDelete(self *_object, name string, throw bool) bool {
}
return objectDelete(self, name, throw)
}
func argumentsEnumerate(self *_object, all bool, each func(string)) {
{
object := self.value.(*_argumentsObject)
for index, value := range object.indexOfParameterName {
if value != "" {
each(strconv.FormatInt(int64(index), 10))
}
}
objectEnumerate(self, all, each)
}
}