Simplified and enhanced util.freeze()
parent
4c74f2a1f2
commit
f47fcf4f46
12
lib/util.js
12
lib/util.js
|
@ -62,17 +62,13 @@ var can_define_prop = ( function()
|
||||||
*
|
*
|
||||||
* @return {Object} object passed to function
|
* @return {Object} object passed to function
|
||||||
*/
|
*/
|
||||||
exports.freeze = function( obj )
|
exports.freeze = ( typeof Object.freeze === 'function' )
|
||||||
{
|
? Object.freeze
|
||||||
// if freezing is not supported (ES5), do nothing
|
: function( obj )
|
||||||
if ( Object.freeze === undefined )
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
Object.freeze( obj );
|
|
||||||
return obj;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue