1 | 'use strict';
|
2 | var getBuiltIn = require('../internals/get-built-in');
|
3 | var isCallable = require('../internals/is-callable');
|
4 | var isIterable = require('../internals/is-iterable');
|
5 | var isObject = require('../internals/is-object');
|
6 |
|
7 | var Set = getBuiltIn('Set');
|
8 |
|
9 | var isSetLike = function (it) {
|
10 | return isObject(it)
|
11 | && typeof it.size == 'number'
|
12 | && isCallable(it.has)
|
13 | && isCallable(it.keys);
|
14 | };
|
15 |
|
16 |
|
17 | module.exports = function (it) {
|
18 | if (isSetLike(it)) return it;
|
19 | return isIterable(it) ? new Set(it) : it;
|
20 | };
|