UNPKG

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