Closed lewisje closed 8 years ago
This was an early design decision (https://github.com/rtfeldman/seamless-immutable/issues/5) - is there a use case where the current behavior is causing a problem?
I didn't notice that closed issue, and I don't actually use the library; I just read the source and remembered how some tutorials on memoization implement it with properties on the functions themselves.
I just browsed through the code and saw that it considers
val
to be mutable if and only ifnull !== val
andtypeof val === 'object'
; however, functions can be mutated, much like an ordinary object (their internal[[Call]]
properties are immutable, but ordinary properties can still be added, changed, or removed), and I think thattypeof val === 'function'
should also work, or in sum:I am also aware of the non-standard typeof value
'unknown'
but I believe that only exists in oldIE, whereObject.defineProperty
only works on DOM nodes if it exists at all, and those "unknown" type objects are already immutable IIRC.