protected override void ProcessItem(JsValue[] args, JsValue currentValue)
            {
                _index++;
                _addedCount++;
                var jsValue = ExtractValueFromIteratorInstance(currentValue);

                _instance.SetIndexValue((uint)_index, jsValue, updateLength: false);
            }
        public JsValue GetOwnPropertyNames(JsValue thisObject, JsValue[] arguments)
        {
            var oArg = arguments.At(0);
            var o    = oArg.TryCast <ObjectInstance>();

            if (ReferenceEquals(o, null))
            {
                ExceptionHelper.ThrowTypeError(Engine);
            }

            uint n = 0;

            ArrayInstance array         = null;
            var           ownProperties = o.GetOwnProperties().ToList();

            if (o is StringInstance)
            {
                var s      = o as StringInstance;
                var length = s.PrimitiveValue.Length;
                array = Engine.Array.ConstructFast((uint)(ownProperties.Count + length));
                for (var i = 0; i < length; i++)
                {
                    array.SetIndexValue(n, TypeConverter.ToString(i), updateLength: false);
                    n++;
                }
            }

            array = array ?? Engine.Array.ConstructFast((uint)ownProperties.Count);
            for (var i = 0; i < ownProperties.Count; i++)
            {
                var p = ownProperties[i];
                array.SetIndexValue(n, p.Key, false);
                n++;
            }

            array.SetLength(n);
            return(array);
        }
Exemple #3
0
 protected override void ProcessItem(JsValue[] args, JsValue currentValue)
 {
     _index++;
     _addedCount++;
     _instance.SetIndexValue((uint)_index, currentValue, updateLength: false);
 }