Sha256: 6a4250b4aa6fc1a5bcd9496a22eb622bad6d385462f9dcfa3f4a86c35892adfb

Contents?: true

Size: 1.2 KB

Versions: 20

Compression:

Stored size: 1.2 KB

Contents

'use strict';

var copy             = require('es5-ext/object/copy')
  , normalizeOptions = require('es5-ext/object/normalize-options')
  , ensureCallable   = require('es5-ext/object/valid-callable')
  , map              = require('es5-ext/object/map')
  , callable         = require('es5-ext/object/valid-callable')
  , validValue       = require('es5-ext/object/valid-value')

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

define = function (name, desc, options) {
	var value = validValue(desc) && callable(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 (options.resolveContext != null) ensureCallable(options.resolveContext);
	return map(props, function (desc, name) { return define(name, desc, options); });
};

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
govuk_publishing_components-16.29.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.28.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.27.1 node_modules/d/auto-bind.js
govuk_publishing_components-16.27.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.26.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.25.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.24.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.23.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.22.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.21.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.20.1 node_modules/d/auto-bind.js
govuk_publishing_components-16.20.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.19.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.18.0 node_modules/d/auto-bind.js
govuk_publishing_components-16.17.0 node_modules/d/auto-bind.js
optimacms-0.4.3 spec/dummy/node_modules/d/auto-bind.js
optimacms-0.4.2 spec/dummy/node_modules/d/auto-bind.js
cortex-0.1.3 spec/dummy/node_modules/d/auto-bind.js
guard-sass-lint-0.1.2 node_modules/d/auto-bind.js
guard-sass-lint-0.1.1 node_modules/d/auto-bind.js