daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Sep 12th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Extending Javascript objects with CoffeeScript
  2. Object::extend = (objects...) ->
  3.     @[key] = value for key, value of object for object in objects
  4.    
  5. Object::extend = (objects...) ->
  6.     for object in objects
  7.         for key, value of object
  8.             @[key] = value
  9.    
  10. var __slice = [].slice;
  11.  
  12. Object.prototype.extend = function() {
  13.   var key, object, objects, value, _i, _len, _results;
  14.   objects = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  15.   _results = [];
  16.   for (_i = 0, _len = objects.length; _i < _len; _i++) {
  17.     object = objects[_i];
  18.     _results.push((function() {
  19.       var _results1;
  20.       _results1 = [];
  21.       for (key in object) {
  22.         value = object[key];
  23.         _results1.push(this[key] = value);
  24.       }
  25.       return _results1;
  26.     }).call(this));
  27.   }
  28.   return _results;
  29. };
  30.    
  31. Object.prototype.extend = function() {
  32.   var key, object, objects, value, _i, _len;
  33.   objects = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  34.   for (_i = 0, _len = objects.length; _i < _len; _i++) {
  35.     object = objects[_i];
  36.     (function() {
  37.       for (key in object) {
  38.         value = object[key];
  39.         this[key] = value;
  40.       }
  41.     }).call(this);
  42.   }
  43. };
  44.    
  45. Object::extend = (objects...) ->
  46.     for object in objects
  47.         for key, value of object
  48.             @[key] = value
  49.     return
  50.    
  51. var __slice = [].slice;
  52.  
  53. Object.prototype.extend = function() {
  54.   var key, object, objects, value, _i, _len;
  55.   objects = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  56.   for (_i = 0, _len = objects.length; _i < _len; _i++) {
  57.     object = objects[_i];
  58.     for (key in object) {
  59.       value = object[key];
  60.       this[key] = value;
  61.     }
  62.   }
  63. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top