bebraw/setjs — pull request #1 by dfellis (2013-08-14 15:13:50+00:00)
Title: Adding true immutability to the library.

Hi,

I saw your comment about how this library is intended to be an immutable set but you can still alter the underlying structure (and break the immutability contract), so I decided to fix it with ``Object.defineProperty``. For example:

```js
damocles@tesla:~$ node
> var foo = {};
undefined
> Object.defineProperty(foo, 'bar', { get: function() { return 'bar'; } });
{}
> foo.bar
'bar'
> foo.bar = 'baz';
'baz'
> foo.bar
'bar'
> delete foo.bar
false
> foo.bar
'bar'
>
```

By defining only a getter, and using the default [`configurable = false`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#Description) value, the property cannot be altered or deleted from the object. The entire set may be deleted, however, so these properties can be garbage collected.