Sha256: 3f1da533aaefc502b316f0db2321797e958f6f3c08c25bc6ac0e4c54ff0120c2

Contents?: true

Size: 1.51 KB

Versions: 29

Compression:

Stored size: 1.51 KB

Contents

"use strict";

var isValue         = require("type/value/is")
  , isPlainFunction = require("type/plain-function/is")
  , assign          = require("es5-ext/object/assign")
  , normalizeOpts   = require("es5-ext/object/normalize-options")
  , contains        = require("es5-ext/string/#/contains");

var d = (module.exports = function (dscr, value/*, options*/) {
	var c, e, w, options, desc;
	if (arguments.length < 2 || typeof dscr !== "string") {
		options = value;
		value = dscr;
		dscr = null;
	} else {
		options = arguments[2];
	}
	if (isValue(dscr)) {
		c = contains.call(dscr, "c");
		e = contains.call(dscr, "e");
		w = contains.call(dscr, "w");
	} else {
		c = w = true;
		e = false;
	}

	desc = { value: value, configurable: c, enumerable: e, writable: w };
	return !options ? desc : assign(normalizeOpts(options), desc);
});

d.gs = function (dscr, get, set/*, options*/) {
	var c, e, options, desc;
	if (typeof dscr !== "string") {
		options = set;
		set = get;
		get = dscr;
		dscr = null;
	} else {
		options = arguments[3];
	}
	if (!isValue(get)) {
		get = undefined;
	} else if (!isPlainFunction(get)) {
		options = get;
		get = set = undefined;
	} else if (!isValue(set)) {
		set = undefined;
	} else if (!isPlainFunction(set)) {
		options = set;
		set = undefined;
	}
	if (isValue(dscr)) {
		c = contains.call(dscr, "c");
		e = contains.call(dscr, "e");
	} else {
		c = true;
		e = false;
	}

	desc = { get: get, set: set, configurable: c, enumerable: e };
	return !options ? desc : assign(normalizeOpts(options), desc);
};

Version data entries

29 entries across 29 versions & 2 rubygems

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