Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

to-set-like.js 570B

1234567891011121314151617181920
  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. var Set = getBuiltIn('Set');
  7. var isSetLike = function (it) {
  8. return isObject(it)
  9. && typeof it.size == 'number'
  10. && isCallable(it.has)
  11. && isCallable(it.keys);
  12. };
  13. // fallback old -> new set methods proposal arguments
  14. module.exports = function (it) {
  15. if (isSetLike(it)) return it;
  16. return isIterable(it) ? new Set(it) : it;
  17. };