Valerii Vasin (valerii) wrote in changelog,
Valerii Vasin
valerii
changelog

[livejournal] r23507: LJSUP-14178: Add ability to customize ne...

Committer: vvasin
LJSUP-14178: Add ability to customize new friends feed. Provide LJ.Object.pick method.
U   trunk/htdocs/js/basic.js
Modified: trunk/htdocs/js/basic.js
===================================================================
--- trunk/htdocs/js/basic.js	2012-12-25 08:59:01 UTC (rev 23506)
+++ trunk/htdocs/js/basic.js	2012-12-26 11:14:41 UTC (rev 23507)
@@ -1686,7 +1686,27 @@
 	}
 };
 
+LJ.define('LJ.Object');
 /**
+ * Return a copy of the object only containing the whitelisted properties.
+ * @param {Object} obj Object source
+ * @param {String} keys* Keys which should be picked from source object
+ * @return {Object} Copy of source object that contains only whitelisted keys
+ */
+LJ.Object.pick = function(obj) {
+    var copy = {},
+    	keys = Array.prototype.concat.apply( [], Array.prototype.slice.call(arguments, 1) );
+
+    keys.forEach(function (key) {
+    	if (key in obj) {
+    		copy[key] = obj[key];
+    	}
+    });
+
+    return copy;
+};
+
+/**
  * Object responsible for statistic integration
  * @param  {jQuery} $ jQuery
  * @return {Object}   Methods for statistic interation

Tags: invis89, js, livejournal, vvasin
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments