Stage 1 Draft / May 21, 2017

Set and Map .of and .from

1CollectionCreate ( C, source [ , mapfn [ , thisArg ] ] )

The abstract operation CollectionCreate with arguments C, source, mapfn and thisArg performs the following steps:

  1. If IsConstructor(C) is false, throw a TypeError exception.
  2. If mapfn is undefined, let mapping be false.
  3. Else,
    1. If IsCallable(mapfn) is false, throw a TypeError exception.
    2. Let mapping be true.
  4. If source is either undefined or null,
    1. Return ? Construct(C, « »).
  5. Let A be ArrayCreate(0).
  6. Let iter be ? GetIterator(source).
  7. Let n be 0.
  8. Repeat,
    1. Let next be ? IteratorStep(iter).
    2. If next is false, return ? Construct(C, « A »).
    3. Let nextItem be ? IteratorValue(next).
    4. If mapping is true, then
      1. Let value be Call(mapfn, thisArg, « nextItem, n »).
      2. If value is an abrupt completion, return ? IteratorClose(iter, value).
    5. Else, let value be nextItem.
    6. Let status be CreateDataProperty(A, ! ToString(n), value).
    7. If status is an abrupt completion, return ? IteratorClose(iter, status).
    8. Increment n by 1.

2Map.of ( ...items )

When the of method is called with any number of arguments, the following steps are taken:

  1. Let items be the List of arguments passed to this function.
  2. Let iterator be CreateListIterator(items).
  3. Let C be the this value.
  4. Return ? CollectionCreate(C, iterator).

3Set.of ( ...items )

When the of method is called with any number of arguments, the following steps are taken:

  1. Let items be the List of arguments passed to this function.
  2. Let iterator be CreateListIterator(items).
  3. Let C be the this value.
  4. Return ? CollectionCreate(C, iterator).

4WeakMap.of ( ...items )

When the of method is called with any number of arguments, the following steps are taken:

  1. Let items be the List of arguments passed to this function.
  2. Let iterator be CreateListIterator(items).
  3. Let C be the this value.
  4. Return ? CollectionCreate(C, iterator).

5WeakSet.of ( ...items )

When the of method is called with any number of arguments, the following steps are taken:

  1. Let items be the List of arguments passed to this function.
  2. Let iterator be CreateListIterator(items).
  3. Let C be the this value.
  4. Return ? CollectionCreate(C, iterator).

6Map.from ( source [ , mapFn [ , thisArg ] ] )

When the from method is called with argument source, and optional arguments mapfn and thisArg, the following steps are taken:

  1. Let C be the this value.
  2. Return ? CollectionCreate(C, source, mapFn, thisArg).

7Set.from ( source [ , mapFn [ , thisArg ] ] )

When the from method is called with argument source, and optional arguments mapfn and thisArg, the following steps are taken:

  1. Let C be the this value.
  2. Return ? CollectionCreate(C, source, mapFn, thisArg).

8WeakMap.from ( source [ , mapFn [ , thisArg ] ] )

When the from method is called with argument source, and optional arguments mapfn and thisArg, the following steps are taken:

  1. Let C be the this value.
  2. Return ? CollectionCreate(C, source, mapFn, thisArg).

9WeakSet.from ( source [ , mapFn [ , thisArg ] ] )

When the from method is called with argument source, and optional arguments mapfn and thisArg, the following steps are taken:

  1. Let C be the this value.
  2. Return ? CollectionCreate(C, source, mapFn, thisArg).

ACopyright & Software License

Copyright Notice

© 2017 Allen Wirfs-Brock,Leonardo Balter

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT http://www.ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.