set.js 379 B

12345678910111213141516
  1. import { inspectList } from './helpers'
  2. // IE11 doesn't support `Array.from(set)`
  3. function arrayFromSet(set) {
  4. const values = []
  5. set.forEach(value => {
  6. values.push(value)
  7. })
  8. return values
  9. }
  10. export default function inspectSet(set, options) {
  11. if (set.size === 0) return 'Set{}'
  12. options.truncate -= 7
  13. return `Set{ ${inspectList(arrayFromSet(set), options)} }`
  14. }