Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow BigInts as IndexedDB keys #231

Closed
wants to merge 1 commit into from
Closed
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
72 changes: 55 additions & 17 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ Complain About: accidental-2119 yes
spec:html; type:dfn; for:/; text:task queue
</pre>

<pre class='biblio'>
{
"BIGINT": {
"href": "https://tc39.github.io/proposal-bigint/",
"title": "BigInt Specification",
"publisher": "TC39",
"status": "Stage 3 proposal"
}
}
</pre>

<pre class=anchors>
spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
urlPrefix: dom.html
Expand Down Expand Up @@ -63,6 +74,9 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
type: dfn
text: sequence<DOMString>; url: idl-sequence
text: sequence<any>; url: idl-sequence
spec: bigint; urlPrefix: https://tc39.github.io/proposal-bigint/
type: dfn
text: BigInt; url: #sec-ecmascript-language-types-bigint-type
</pre>

<style>
Expand Down Expand Up @@ -604,6 +618,7 @@ database, each [=object-store/record=] is organized according to its

A [=/key=] has an associated <dfn>type</dfn> which is one of:
<i>number</i>,
<i>bigint</i>,
<i>date</i>,
<i>string</i>,
<i>binary</i>,
Expand All @@ -622,6 +637,7 @@ be either:
an {{unrestricted double}} if type is <i>number</i> or <i>date</i>,
a {{DOMString}} if type is <i>string</i>,
a list of {{octet}}s if type is <i>binary</i>,
an integer if the type is <i>bigint</i>,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is a little fudge--the other types have meanings that are more well-defined in terms of Infra or WebIDL, but there isn't a BigInt WebIDL type yet.

or a list of other [=/keys=] if type is <i>array</i>.

</div>
Expand All @@ -642,6 +658,7 @@ following the steps to [=convert a value to a key=].
* [=Array=] objects, where every item is defined, is itself a valid
key, and does not directly or indirectly contain itself. This
includes empty arrays. Arrays can contain other arrays.
* [=BigInt=] primitive values.

Attempting to convert other ECMAScript values to a [=/key=]
will fail.
Expand All @@ -660,37 +677,45 @@ To <dfn>compare two keys</dfn> |a| and |b|, run these steps:
2. Let |tb| be the [=key/type=] of |b|.

3. If |ta| is <i>array</i> and |tb| is <i>binary</i>, <i>string</i>,
<i>date</i> or <i>number</i>, return 1.
<i>date</i>, <i>number</i> or <i>bigint</i>, return 1.

4. If |tb| is <i>array</i> and |ta| is <i>binary</i>, <i>string</i>,
<i>date</i> or <i>number</i>, return -1.
<i>date</i>, <i>number</i> or <i>bigint</i>, return -1.

5. If |ta| is <i>binary</i> and |tb| is <i>string</i>, <i>date</i>,
<i>number</i> or <i>bigint</i>, return 1.

6. If |tb| is <i>binary</i> and |ta| is <i>string</i>, <i>date</i>,
<i>number</i> or <i>bigint</i>, return -1.

5. If |ta| is <i>binary</i> and |tb| is <i>string</i>, <i>date</i> or
<i>number</i>, return 1.
7. If |ta| is <i>string</i> and |tb| is <i>date</i>, <i>number</i>
or <i>bigint</i>, return 1.

6. If |tb| is <i>binary</i> and |ta| is <i>string</i>, <i>date</i> or
<i>number</i>, return -1.
8. If |tb| is <i>string</i> and |ta| is <i>date</i>, <i>number</i>,
or <i>bigint</i>, return -1.

7. If |ta| is <i>string</i> and |tb| is <i>date</i> or <i>number</i>,
9. If |ta| is <i>date</i> and |tb| is <i>number</i> or <i>bigint</i>,
return 1.
8. If |tb| is <i>string</i> and |ta| is <i>date</i> or <i>number</i>,

10. If |tb| is <i>date</i> and |ta| is <i>number</i> or <i>bigint</i>,
return -1.

9. If |ta| is <i>date</i> and |tb| is <i>number</i>, return 1.
11. If |ta| is <i>bigint</i> and |tb| is <i>number</i>, return 1.

10. If |tb| is <i>date</i> and |ta| is <i>number</i>, return -1.
12. If |tb| is <i>bigint</i> and |ta| is <i>number</i>, return -1.

11. Assert: |ta| and |tb| are equal.
13. Assert: |ta| and |tb| are equal.

12. Let |va| be the [=key/value=] of |a|.
14. Let |va| be the [=key/value=] of |a|.

13. Let |vb| be the [=key/value=] of |b|.
15. Let |vb| be the [=key/value=] of |b|.

14. Switch on |ta|:
16. Switch on |ta|:

<dl class=switch>
<dt><i>number</i></dt>
<dt><i>date</i></dt>
<dt><i>bigint</i></dt>
<dd>
1. If |va| is greater than |vb|, then return 1.
2. If |va| is less than |vb|, then return -1.
Expand Down Expand Up @@ -763,7 +788,8 @@ of running the steps to [=compare two keys=] with |a| and |b| is 0.
<aside class=note>
As a result of the above rules, negative infinity is the lowest
possible value for a [=/key=].
<i>Number</i> keys are less than <i>date</i> keys.
<i>Number</i> keys are less than <i>bigint</i> keys.
<i>BigInt</i> keys are less than <i>date</i> keys.
<i>Date</i> keys are less than <i>string</i> keys.
<i>String</i> keys are less than <i>binary</i> keys.
<i>Binary</i> keys are less than <i>array</i> keys.
Expand Down Expand Up @@ -1617,8 +1643,8 @@ be updated.
Only specified keys of [=key/type=] <i>number</i> can affect the
[=key generator/current number=] of the key generator. Keys of [=key/type=]
<i>date</i>, <i>array</i> (regardless of the other keys they
contain), <i>binary</i>, or <i>string</i> (regardless of whether
they could be parsed as numbers) have no effect on the [=key generator/current
contain), <i>binary</i>, <i>string</i> (regardless of whether
they could be parsed as numbers), or <i>bigint</i> have no effect on the [=key generator/current
number=] of the key generator. Keys of [=key/type=]
<i>number</i> with [=key/value=] less than 1 do not affect the
[=key generator/current number=] since they are always lower than the
Expand Down Expand Up @@ -6635,6 +6661,9 @@ steps take one argument, |key|, and return an ECMAScript value.
<dt><i>number</i></dt>
<dd>Return an ECMAScript Number value equal to |value|</dd>

<dt><i>bigint</i></dt>
<dd>Return an ECMAScript [=BigInt=] value equal to |value|</dd>

<dt><i>string</i></dt>
<dd>Return an ECMAScript String value equal to |value|</dd>

Expand Down Expand Up @@ -6714,6 +6743,15 @@ steps may throw an exception.

</dd>

<!-- BigInt -->
<dt>If [=/Type=](|input|) is BigInt</dt>
<dd>
1. Return a new [=/key=] with
[=key/type=] <i>bigint</i> and [=key/value=]
|input|.

</dd>

<!-- Date -->
<dt>If |input| is a [=Date=] (has a \[[DateValue]] internal slot)</dt>
<dd>
Expand Down