Sha256: 055c2d36c3f2ebca508caa70e945d793dcbb48b92799c4c05f49e5f3d44c35a2

Contents?: true

Size: 1.21 KB

Versions: 29

Compression:

Stored size: 1.21 KB

Contents

"use strict";

var isValue             = require("type/value/is")
  , ensureValue         = require("type/value/ensure")
  , ensurePlainFunction = require("type/plain-function/ensure")
  , copy                = require("es5-ext/object/copy")
  , normalizeOptions    = require("es5-ext/object/normalize-options")
  , map                 = require("es5-ext/object/map");

var bind = Function.prototype.bind
  , defineProperty = Object.defineProperty
  , hasOwnProperty = Object.prototype.hasOwnProperty
  , define;

define = function (name, desc, options) {
	var value = ensureValue(desc) && ensurePlainFunction(desc.value), dgs;
	dgs = copy(desc);
	delete dgs.writable;
	delete dgs.value;
	dgs.get = function () {
		if (!options.overwriteDefinition && hasOwnProperty.call(this, name)) return value;
		desc.value = bind.call(value, options.resolveContext ? options.resolveContext(this) : this);
		defineProperty(this, name, desc);
		return this[name];
	};
	return dgs;
};

module.exports = function (props/*, options*/) {
	var options = normalizeOptions(arguments[1]);
	if (isValue(options.resolveContext)) ensurePlainFunction(options.resolveContext);
	return map(props, function (desc, name) { return define(name, desc, options); });
};

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/d/auto-bind.js
govuk_publishing_components-18.0.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.21.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.20.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.19.1 node_modules/d/auto-bind.js
govuk_publishing_components-17.19.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.18.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.17.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.16.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.15.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.14.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.13.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.12.2 node_modules/d/auto-bind.js
govuk_publishing_components-17.12.1 node_modules/d/auto-bind.js
govuk_publishing_components-17.12.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.11.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.10.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.9.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.8.0 node_modules/d/auto-bind.js
govuk_publishing_components-17.7.0 node_modules/d/auto-bind.js