emmanueltouzery / prelude-ts

Functional programming, immutable collections and FP constructs for typescript and javascript
ISC License
377 stars 21 forks source link

constant #49

Closed ShalokShalom closed 3 years ago

ShalokShalom commented 3 years ago

Hi there :)

Is there any chance to get a real, serious constant binding, that does what it says?

So deep freeze combined with casual const.

Thanks a lot

Edit: Seems like readonly does the job.

emmanueltouzery commented 3 years ago

hello, i'm not sure what is wrong with const with prelude? seems the collections are immutable it should work?

> const vec1 = Vector.of(1,2,3)
undefined
> vec1 = Vector.of(2,3)
Uncaught TypeError: Assignment to constant variable.
> vec1.toArray()
[ 1, 2, 3 ]
> vec1.append(4).toArray()
[ 1, 2, 3, 4 ]
> vec1.toArray()
[ 1, 2, 3 ]