mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
25 lines
450 B
JavaScript
25 lines
450 B
JavaScript
|
var objectKeys =
|
||
|
Object.keys ||
|
||
|
function (obj) {
|
||
|
var keys = [];
|
||
|
for (var key in obj) {
|
||
|
if ({}.hasOwnProperty.call(obj, key)) keys.push(key);
|
||
|
}
|
||
|
return keys;
|
||
|
};
|
||
|
|
||
|
function assign(obj, newKey, newValue) {
|
||
|
var keys = objectKeys(obj);
|
||
|
var copy = {};
|
||
|
|
||
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||
|
var key = keys[i];
|
||
|
copy[key] = obj[key];
|
||
|
}
|
||
|
|
||
|
copy[newKey] = newValue;
|
||
|
return copy;
|
||
|
}
|
||
|
|
||
|
module.exports = assign;
|