"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/d/auto-bind.js" (8 Mar 2017, 919 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 'use strict';
    2 
    3 var copy       = require('es5-ext/object/copy')
    4   , map        = require('es5-ext/object/map')
    5   , callable   = require('es5-ext/object/valid-callable')
    6   , validValue = require('es5-ext/object/valid-value')
    7 
    8   , bind = Function.prototype.bind, defineProperty = Object.defineProperty
    9   , hasOwnProperty = Object.prototype.hasOwnProperty
   10   , define;
   11 
   12 define = function (name, desc, bindTo) {
   13     var value = validValue(desc) && callable(desc.value), dgs;
   14     dgs = copy(desc);
   15     delete dgs.writable;
   16     delete dgs.value;
   17     dgs.get = function () {
   18         if (hasOwnProperty.call(this, name)) return value;
   19         desc.value = bind.call(value, (bindTo == null) ? this : this[bindTo]);
   20         defineProperty(this, name, desc);
   21         return this[name];
   22     };
   23     return dgs;
   24 };
   25 
   26 module.exports = function (props/*, bindTo*/) {
   27     var bindTo = arguments[1];
   28     return map(props, function (desc, name) {
   29         return define(name, desc, bindTo);
   30     });
   31 };