Skip to content

Commit

Permalink
Added .at
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Nov 3, 2024
1 parent 1b94626 commit 3622ad4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion YantraJS.Core/Core/Array/JSArrayPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ public partial class JSArray

}

[JSPrototypeMethod][JSExport("at", Length = 1)]
public static JSValue At(in Arguments a)
{
var index = a[0];
var @this = a.This;
var length = a.Length;
var i = index.IntegerValue;
if (i < 0)
{
if (i < -length)
{
return JSUndefined.Value;
}
i += length;
}
if (i >= length)
{
return JSUndefined.Value;
}
return @this.GetOwnProperty((uint)i);
}

[JSPrototypeMethod][JSExport("concat", Length = 1)]
public static JSValue Concat(in Arguments a)
{
Expand Down Expand Up @@ -297,7 +319,7 @@ public static JSValue FlatMap(in Arguments a)
return result;
}

private static void FlattenTo(JSArray result, JSValue @this, JSValue callback, JSValue thisArg, int depth)
private static void FlattenTo(JSArray result, JSValue @this, JSValue callback, JSValue thisArg, int depth)
{


Expand Down

0 comments on commit 3622ad4

Please sign in to comment.