11// //////////////////////////////////////////////////////////////////////////////// //
22// MIT License
33//
4- // Copyright (c) 2018 Jan Küster
4+ // Copyright (c) 2018 - today Jan Küster
55//
66// Permission is hereby granted, free of charge, to any person obtaining a copy
77// of this software and associated documentation files (the "Software"), to deal
@@ -154,11 +154,12 @@ scope.Set.prototype.add =
154154 * @private
155155 */
156156function resolve ( obj , circ = new originals . constructor ( [ obj ] ) ) {
157- if ( typeof obj === 'undefined' ||
158- typeof obj === 'string' ||
159- typeof obj === 'number' ||
160- typeof obj === 'boolean' ||
161- obj === null ) {
157+ const type = typeof obj
158+
159+ if (
160+ [ 'undefined' , 'string' , 'number' , 'boolean' ] . includes ( type ) ||
161+ obj === null
162+ ) {
162163 return obj
163164 }
164165
@@ -167,15 +168,18 @@ function resolve (obj, circ = new originals.constructor([obj])) {
167168 obj = Array . from ( obj )
168169 }
169170
170- if ( typeof obj === 'function' ) {
171+ if ( type === 'function' ) {
171172 const fctObj = { fctStr : String ( obj ) . replace ( / \s + / g, '' ) } // function body to string
172173 // resolve all function properties / attached references
173- fctObj . refs = Object . getOwnPropertyNames ( obj ) . map ( key => originals . has . call ( circ , obj [ key ] ) ? 'circular' : resolve ( obj [ key ] , circ ) )
174+ fctObj . refs = Object
175+ . getOwnPropertyNames ( obj )
176+ . filter ( prop => prop !== 'name' )
177+ . map ( key => originals . has . call ( circ , obj [ key ] ) ? 'circular' : resolve ( obj [ key ] , circ ) )
174178 return fctObj
175179 }
176180
177181 const isArray = Array . isArray ( obj )
178- if ( typeof obj !== 'object' && ! isArray ) {
182+ if ( type !== 'object' && ! isArray ) {
179183 return obj
180184 }
181185
@@ -224,12 +228,14 @@ function resolve (obj, circ = new originals.constructor([obj])) {
224228 */
225229scope . Set . prototype . has = function has ( value ) {
226230 const valType = typeof value
231+
227232 if ( valType === 'string' || valType === 'number' || valType === 'boolean' ) {
228233 return originals . has . call ( this , value )
229234 }
230235
231236 const iterator = this . values ( )
232237 let element
238+
233239 while ( ( element = iterator . next ( ) . value ) !== undefined ) {
234240 const elType = typeof element
235241
@@ -258,9 +264,11 @@ scope.Set.prototype.has = function has (value) {
258264 // version of both and compare their strings.
259265 // - functions are string-ed and their properties are resolved
260266 // like objects
261- if ( ( elType === 'function' && valType === 'function' ) ||
267+ if (
268+ ( elType === 'function' && valType === 'function' ) ||
262269 ( ! setCompare && elType === 'object' && valType === 'object' ) ||
263- ( Array . isArray ( element ) && Array . isArray ( value ) ) ) {
270+ ( Array . isArray ( element ) && Array . isArray ( value ) )
271+ ) {
264272 const sortedElmnt = resolve ( element )
265273 const sortedValue = resolve ( value )
266274
0 commit comments