Skip to content

Function: setToArray() ​

setToArray<T>(set): T[]

Convert a set into an array of its items, in their insertion order. The set is not modified.

Type Parameters ​

T ​

T = any

Parameters ​

set ​

Set<T>

The set to convert; an empty set gives an empty array.

Returns ​

T[]

A new array of the set's items.

Example ​

typescript
import {setToArray} from 'lakutata/utils'

console.log(setToArray(new Set(['b', 'a'])))
//['b', 'a']

Released under the MIT License.