Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = defineProp;
- function defineProp(obj, str, fnc) {
- var arr = str.split(':'),
- name = arr.pop(),
- prop = arr.pop() || 'value',
- hex = (arr.pop() || '101').split(''),
- desc = { configurable: !!+hex[0], enumerable: !!+hex[1]};
- if('value' === prop && !!+hex[2])
- desc.writable = true;
- desc[prop] = fnc;
- Object.defineProperty(obj, name, desc)
- return obj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement