* Make a configuration property hidden so it doesn't appear when enumerating * elements of the object. * * * The property still exists and can be read from and written to, but it won't * show up in for ... in loops, Object.keys(), or JSON.stringify() type methods. *
(object, property, value)
| 119 | * @return {object} - The original object is returned - for chaining. |
| 120 | */ |
| 121 | static makeHidden(object, property, value) { |
| 122 | // If the new value isn't specified, just mark the property as hidden |
| 123 | if (typeof value === 'undefined') { |
| 124 | Object.defineProperty(object, property, { |
| 125 | enumerable: false, |
| 126 | configurable: true |
| 127 | }); |
| 128 | } else { |
| 129 | // Otherwise set the value and mark it as hidden |
| 130 | Object.defineProperty(object, property, { |
| 131 | value: value, |
| 132 | enumerable: false, |
| 133 | configurable: true |
| 134 | }); |
| 135 | } |
| 136 | |
| 137 | return object; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Make a javascript object immutable (assuring it cannot be changed from the current value) |
no outgoing calls
no test coverage detected