This repository has been archived by the owner on Dec 28, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathspec.emu
37 lines (36 loc) · 1.58 KB
/
spec.emu
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
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="./spec.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="./spec.js"></script>
<pre class="metadata">
title: Map.prototype.toJSON / Set.prototype.toJSON
stage: 0
contributors: David Bruant, Jordan Harband
</pre>
<emu-clause id="Map.prototype.toJSON">
<h1>Map.prototype.toJSON ( )</h1>
<p>This function provides an Array representation of an iterable object for use by <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify">JSON.stringify</a>.<p>
<p>When the *toJSON* method is called, the following steps are taken:</p>
<emu-alg>
1. Let _M_ be the *this* value.
1. Let _iterator_ be ? GetIterator(_M_)
1. Let _A_ be ! ArrayCreate(*0*).
1. Let _k_ be *0*.
1. Repeat
1. Let _Pk_ be ! ToString(_k_).
1. Let _next_ be ? IteratorStep(_iterator_).
1. If _next_ is *false*, then
1. Perform ? Set(_A_, "length", _k_, *true*).
1. Return _A_.
1. Let _nextValue_ be ? IteratorValue(_next_).
1. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _nextValue_).
1. If _defineStatus_ is an abrupt completion, return IteratorClose(_iterator_, _defineStatus_).
1. Increase _k_ by 1.
</emu-alg>
<emu-note>The *length* property of the *toJSON* method is *0*.</emu-note>
</emu-clause>
<emu-clause id="Set.prototype.toJSON">
<h1>Set.prototype.toJSON ( )</h1>
<p>The initial value of the *toJSON* property is the same function object as the initial value of the *Map.prototype.toJSON* property.</p>
</emu-clause>