This commit is contained in:
Evan You 2014-07-09 10:58:53 -04:00
parent b5bfc59a70
commit 55bfa2f2e7
1 changed files with 17 additions and 0 deletions

View File

@ -34,4 +34,21 @@ exports.isObject = function (obj) {
exports.isArray = function (obj) {
return Array.isArray(obj)
}
/**
* Define a readonly, in-enumerable property
*
* @param {Object} obj
* @param {String} key
* @param {*} val
*/
exports.define = function (obj, key, val) {
Object.defineProperty(obj, key, {
value: val,
enumerable: false,
writable: false,
configurable: true
})
}