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); }
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; }