Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Jint.Tests.Test262/Test262Harness.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"async-iteration",
"Atomics",
"decorators",
"Error.isError",
"explicit-resource-management",
"import-defer",
"iterator-helpers",
Expand Down
21 changes: 20 additions & 1 deletion Jint/Native/Error/ErrorConstructor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Jint.Collections;
using Jint.Native.Object;
using Jint.Runtime;
using Jint.Runtime.Descriptors;
using Jint.Runtime.Interop;

namespace Jint.Native.Error;

Expand All @@ -25,14 +27,23 @@ internal ErrorConstructor(

internal ErrorPrototype PrototypeObject { get; }

protected override void Initialize()
{
var properties = new PropertyDictionary(3, checkExistingKeys: false)
{
["isError"] = new PropertyDescriptor(new PropertyDescriptor(new ClrFunction(Engine, "isError", IsError, 1), PropertyFlag.NonEnumerable)),
};
SetProperties(properties);
}

protected internal override JsValue Call(JsValue thisObject, JsValue[] arguments)
{
return Construct(arguments, this);
}

public ObjectInstance Construct(string? message = null)
{
return Construct(message != null ? new JsValue[]{ message } : System.Array.Empty<JsValue>(), this);
return Construct(message != null ? new JsValue[] { message } : System.Array.Empty<JsValue>(), this);
}

/// <summary>
Expand Down Expand Up @@ -83,4 +94,12 @@ public override ObjectInstance Construct(JsValue[] arguments, JsValue newTarget)
return callStack.BuildCallStackString(_engine, lastSyntaxNode.Location, currentFunction == this ? 1 : 0);
}
}

/// <summary>
/// https://tc39.es/proposal-is-error/
/// </summary>
private static JsValue IsError(JsValue? thisObj, JsValue[] arguments)
{
return arguments.At(0) is JsError;
}
}
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ and many more.

#### ECMAScript Stage 3 (no version yet)

- ✔ Float16Array (Requires NET 6 or higher)
- ✔ `Error.isError`
- ✔ `Float16Array` (Requires NET 6 or higher)
- ✔ Import attributes
- ✔ JSON modules
- ✔ Math.sumPrecise
- ✔ `Math.sumPrecise`
- ✔ `Promise.try`
- ✔ Set methods (`intersection`, `union`, `difference`, `symmetricDifference`, `isSubsetOf`, `isSupersetOf`, `isDisjointFrom`)
- ✔ ShadowRealm
- ✔ Uint8Array to/from base64
- ✔ `ShadowRealm`
- ✔ `Uint8Array` to/from base64

#### Other

Expand Down