Advertisement
Guest User

Untitled

a guest
Jul 9th, 2014
1,246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. define(function (require) {
  2.  
  3.     var LazyExpr = function(options) {
  4.         this.expr = options.expr;
  5.         this.context = options.context;
  6.     };
  7.  
  8.     var Lazy = function(expr, context) {
  9.  
  10.         return new LazyExpr({
  11.             expr: expr,
  12.             context: context
  13.         });
  14.  
  15.     };
  16.  
  17.     Object.defineProperty(LazyExpr.prototype, "value", {
  18.         configurable: true,
  19.         get: function () {
  20.             var self = this;
  21.  
  22.             return function() { return eval(self.expr);}.call(this.context);
  23.         }
  24.     });
  25.  
  26.     return Lazy;
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement