Ejemplo n.º 1
0
        internal static IDynamic ToArray(IEnvironment environment, IArgs args)
        {
            var array    = ((IConstructable)environment.ArrayConstructor).Construct(environment, environment.EmptyArgs);
            var builder  = environment.CreateObjectBuilder(array).SetAttributes(true, true, true);
            var iterator = new Iterator(environment, args[0]);

            uint index = 0;

            while (iterator.Next())
            {
                builder.AppendDataProperty(index.ToString(), iterator.Current);
                index++;
            }

            array.Put("length", environment.CreateNumber(index), true);

            return(array);
        }
Ejemplo n.º 2
0
        internal static IDynamic ToArray(IEnvironment environment, IArgs args)
        {
            var array = ((IConstructable)environment.ArrayConstructor).Construct(environment, environment.EmptyArgs);
            var builder = environment.CreateObjectBuilder(array).SetAttributes(true, true, true);
            var iterator = new Iterator(environment, args[0]);

            uint index = 0;
            while (iterator.Next())
            {
                builder.AppendDataProperty(index.ToString(), iterator.Current);
                index++;
            }

            array.Put("length", environment.CreateNumber(index), true);

            return array;
        }