forked from ClearFoundry/ClearScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScriptObjectFlags.cs
More file actions
65 lines (57 loc) · 2.91 KB
/
JavaScriptObjectFlags.cs
File metadata and controls
65 lines (57 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
namespace Microsoft.ClearScript.JavaScript
{
/// <summary>
/// Defines JavaScript object attributes.
/// </summary>
[Flags]
public enum JavaScriptObjectFlags
{
/// <summary>
/// Indicates that no attributes are present.
/// </summary>
None = 0,
/// <summary>
/// Indicates that the object is an
/// <c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</see></c>,
/// <c><see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView">DataView</see></c>,
/// or
/// <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays">typed array</see> whose contents reside in shared memory.
/// </summary>
Shared = 0x00000001,
/// <summary>
/// Indicates that the object is an
/// <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function">async function</see>
/// or
/// <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols">async iterator</see>.
/// </summary>
Async = 0x00000002,
/// <summary>
/// Indicates that the object is a
/// <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#generator_functions">generator function</see>
/// or
/// <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*">async generator function</see>.
/// </summary>
Generator = 0x00000004,
/// <summary>
/// Indicates that the object is a
/// <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">promise</see>
/// that is not yet settled. If the object is a promise and this attribute is not present,
/// then the promise is fulfilled unless <c><see cref="Rejected"/></c> is present.
/// </summary>
Pending = 0x00000008,
/// <summary>
/// Indicates that the object is a rejected
/// <see href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">promise</see>.
/// This attribute has no meaning if <c><see cref="Pending"/></c> is present.
/// </summary>
Rejected = 0x00000010
}
internal static class JavaScriptObjectFlagsHelpers
{
public static bool HasAllFlags(this JavaScriptObjectFlags value, JavaScriptObjectFlags flags) => (value & flags) == flags;
public static bool HasAnyFlag(this JavaScriptObjectFlags value, JavaScriptObjectFlags flags) => (value & flags) != 0;
}
}