main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
570 bytes
|
Line | |
---|
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 | // fallback old -> new set methods proposal arguments
|
---|
17 | module.exports = function (it) {
|
---|
18 | if (isSetLike(it)) return it;
|
---|
19 | return isIterable(it) ? new Set(it) : it;
|
---|
20 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.