Beta 7 with some repo names changed.

This commit is contained in:
Luis Fernando Molina committed 2020-11-15 13:05:19 +01:00
1 parent 0f7b40cca7
commit 963c19493a
3408 files changed
+462217 -15516

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
"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); });
};
+62
View File
@@ -0,0 +1,62 @@
"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);
};
+115
View File
@@ -0,0 +1,115 @@
"use strict";
var isPlainFunction = require("type/plain-function/is")
, ensureValue = require("type/value/ensure")
, isValue = require("type/value/is")
, map = require("es5-ext/object/map")
, contains = require("es5-ext/string/#/contains");
var call = Function.prototype.call
, defineProperty = Object.defineProperty
, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor
, getPrototypeOf = Object.getPrototypeOf
, hasOwnProperty = Object.prototype.hasOwnProperty
, cacheDesc = { configurable: false, enumerable: false, writable: false, value: null }
, define;
define = function (name, options) {
var value, dgs, cacheName, desc, writable = false, resolvable, flat;
options = Object(ensureValue(options));
cacheName = options.cacheName;
flat = options.flat;
if (!isValue(cacheName)) cacheName = name;
delete options.cacheName;
value = options.value;
resolvable = isPlainFunction(value);
delete options.value;
dgs = { configurable: Boolean(options.configurable), enumerable: Boolean(options.enumerable) };
if (name !== cacheName) {
dgs.get = function () {
if (hasOwnProperty.call(this, cacheName)) return this[cacheName];
cacheDesc.value = resolvable ? call.call(value, this, options) : value;
cacheDesc.writable = writable;
defineProperty(this, cacheName, cacheDesc);
cacheDesc.value = null;
if (desc) defineProperty(this, name, desc);
return this[cacheName];
};
} else if (!flat) {
dgs.get = function self() {
var ownDesc;
if (hasOwnProperty.call(this, name)) {
ownDesc = getOwnPropertyDescriptor(this, name);
// It happens in Safari, that getter is still called after property
// was defined with a value, following workarounds that
// While in IE11 it may happen that here ownDesc is undefined (go figure)
if (ownDesc) {
if (ownDesc.hasOwnProperty("value")) return ownDesc.value;
if (typeof ownDesc.get === "function" && ownDesc.get !== self) {
return ownDesc.get.call(this);
}
return value;
}
}
desc.value = resolvable ? call.call(value, this, options) : value;
defineProperty(this, name, desc);
desc.value = null;
return this[name];
};
} else {
dgs.get = function self() {
var base = this, ownDesc;
if (hasOwnProperty.call(this, name)) {
// It happens in Safari, that getter is still called after property
// was defined with a value, following workarounds that
ownDesc = getOwnPropertyDescriptor(this, name);
if (ownDesc.hasOwnProperty("value")) return ownDesc.value;
if (typeof ownDesc.get === "function" && ownDesc.get !== self) {
return ownDesc.get.call(this);
}
}
while (!hasOwnProperty.call(base, name)) base = getPrototypeOf(base);
desc.value = resolvable ? call.call(value, base, options) : value;
defineProperty(base, name, desc);
desc.value = null;
return base[name];
};
}
dgs.set = function (value) {
if (hasOwnProperty.call(this, name)) {
throw new TypeError("Cannot assign to lazy defined '" + name + "' property of " + this);
}
dgs.get.call(this);
this[cacheName] = value;
};
if (options.desc) {
desc = {
configurable: contains.call(options.desc, "c"),
enumerable: contains.call(options.desc, "e")
};
if (cacheName === name) {
desc.writable = contains.call(options.desc, "w");
desc.value = null;
} else {
writable = contains.call(options.desc, "w");
desc.get = dgs.get;
desc.set = dgs.set;
}
delete options.desc;
} else if (cacheName === name) {
desc = {
configurable: Boolean(options.configurable),
enumerable: Boolean(options.enumerable),
writable: Boolean(options.writable),
value: null
};
}
delete options.configurable;
delete options.enumerable;
delete options.writable;
return dgs;
};
module.exports = function (props) {
return map(props, function (desc, name) { return define(name, desc); });
};
+106
View File
@@ -0,0 +1,106 @@
{
"_from": "d@1",
"_id": "d@1.0.1",
"_inBundle": false,
"_integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
"_location": "/d",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "d@1",
"name": "d",
"escapedName": "d",
"rawSpec": "1",
"saveSpec": null,
"fetchSpec": "1"
},
"_requiredBy": [
"/es6-iterator",
"/es6-symbol"
],
"_resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
"_shasum": "8698095372d58dbee346ffd0c7093f99f8f9eb5a",
"_spec": "d@1",
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\BackendServers\\node_modules\\es6-iterator",
"author": {
"name": "Mariusz Nowak",
"email": "medyk@medikoo.com",
"url": "http://www.medikoo.com/"
},
"bugs": {
"url": "https://github.com/medikoo/d/issues"
},
"bundleDependencies": false,
"dependencies": {
"es5-ext": "^0.10.50",
"type": "^1.0.1"
},
"deprecated": false,
"description": "Property descriptor factory",
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-medikoo": "^2.3.0",
"git-list-updated": "^1.1.2",
"husky": "^2.4.1",
"lint-staged": "^8.2.1",
"prettier-elastic": "^1.18.2",
"tad": "^2.0.1"
},
"eslintConfig": {
"extends": "medikoo/es5",
"root": true
},
"homepage": "https://github.com/medikoo/d#readme",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"keywords": [
"descriptor",
"es",
"ecmascript",
"ecma",
"property",
"descriptors",
"meta",
"properties"
],
"license": "ISC",
"lint-staged": {
"*.js": [
"eslint"
],
"*.{css,html,js,json,md,yaml,yml}": [
"prettier -c"
]
},
"name": "d",
"prettier": {
"printWidth": 100,
"tabWidth": 4,
"overrides": [
{
"files": [
"*.md"
],
"options": {
"tabWidth": 2
}
}
]
},
"repository": {
"type": "git",
"url": "git://github.com/medikoo/d.git"
},
"scripts": {
"lint": "eslint --ignore-path=.gitignore .",
"lint-updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'",
"prettier-check-updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
"prettify": "prettier --write --ignore-path .gitignore '**/*.{css,html,js,json,md,yaml,yml}'",
"test": "node node_modules/tad/bin/tad"
},
"version": "1.0.1"
}
+11
View File
@@ -0,0 +1,11 @@
"use strict";
var d = require("../");
module.exports = function (t, a) {
var o = Object.defineProperties(
{}, t({ bar: d(function () { return this === o; }), bar2: d(function () { return this; }) })
);
a.deep([o.bar(), o.bar2()], [true, o]);
};
+209
View File
@@ -0,0 +1,209 @@
"use strict";
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
module.exports = function (t, a) {
var o, c, cg, cs, ce, ceg, ces, cew, cw, e, eg, es, ew, v, vg, vs, w, df, dfg, dfs;
o = Object.create(Object.prototype, {
c: t("c", (c = {})),
cgs: t.gs("c", (cg = function () {}), (cs = function () {})),
ce: t("ce", (ce = {})),
cegs: t.gs("ce", (ceg = function () {}), (ces = function () {})),
cew: t("cew", (cew = {})),
cw: t("cw", (cw = {})),
e: t("e", (e = {})),
egs: t.gs("e", (eg = function () {}), (es = function () {})),
ew: t("ew", (ew = {})),
v: t("", (v = {})),
vgs: t.gs("", (vg = function () {}), (vs = function () {})),
w: t("w", (w = {})),
df: t((df = {})),
dfgs: t.gs((dfg = function () {}), (dfs = function () {}))
});
return {
c: function (a) {
var d = getOwnPropertyDescriptor(o, "c");
a(d.value, c, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, true, "Configurable");
a(d.enumerable, false, "Enumerable");
a(d.writable, false, "Writable");
d = getOwnPropertyDescriptor(o, "cgs");
a(d.value, undefined, "GS Value");
a(d.get, cg, "GS Get");
a(d.set, cs, "GS Set");
a(d.configurable, true, "GS Configurable");
a(d.enumerable, false, "GS Enumerable");
a(d.writable, undefined, "GS Writable");
},
ce: function (a) {
var d = getOwnPropertyDescriptor(o, "ce");
a(d.value, ce, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, true, "Configurable");
a(d.enumerable, true, "Enumerable");
a(d.writable, false, "Writable");
d = getOwnPropertyDescriptor(o, "cegs");
a(d.value, undefined, "GS Value");
a(d.get, ceg, "GS Get");
a(d.set, ces, "GS Set");
a(d.configurable, true, "GS Configurable");
a(d.enumerable, true, "GS Enumerable");
a(d.writable, undefined, "GS Writable");
},
cew: function (a) {
var d = getOwnPropertyDescriptor(o, "cew");
a(d.value, cew, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, true, "Configurable");
a(d.enumerable, true, "Enumerable");
a(d.writable, true, "Writable");
},
cw: function (a) {
var d = getOwnPropertyDescriptor(o, "cw");
a(d.value, cw, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, true, "Configurable");
a(d.enumerable, false, "Enumerable");
a(d.writable, true, "Writable");
},
e: function (a) {
var d = getOwnPropertyDescriptor(o, "e");
a(d.value, e, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, false, "Configurable");
a(d.enumerable, true, "Enumerable");
a(d.writable, false, "Writable");
d = getOwnPropertyDescriptor(o, "egs");
a(d.value, undefined, "GS Value");
a(d.get, eg, "GS Get");
a(d.set, es, "GS Set");
a(d.configurable, false, "GS Configurable");
a(d.enumerable, true, "GS Enumerable");
a(d.writable, undefined, "GS Writable");
},
ew: function (a) {
var d = getOwnPropertyDescriptor(o, "ew");
a(d.value, ew, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, false, "Configurable");
a(d.enumerable, true, "Enumerable");
a(d.writable, true, "Writable");
},
v: function (a) {
var d = getOwnPropertyDescriptor(o, "v");
a(d.value, v, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, false, "Configurable");
a(d.enumerable, false, "Enumerable");
a(d.writable, false, "Writable");
d = getOwnPropertyDescriptor(o, "vgs");
a(d.value, undefined, "GS Value");
a(d.get, vg, "GS Get");
a(d.set, vs, "GS Set");
a(d.configurable, false, "GS Configurable");
a(d.enumerable, false, "GS Enumerable");
a(d.writable, undefined, "GS Writable");
},
w: function (a) {
var d = getOwnPropertyDescriptor(o, "w");
a(d.value, w, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, false, "Configurable");
a(d.enumerable, false, "Enumerable");
a(d.writable, true, "Writable");
},
d: function (a) {
var d = getOwnPropertyDescriptor(o, "df");
a(d.value, df, "Value");
a(d.get, undefined, "Get");
a(d.set, undefined, "Set");
a(d.configurable, true, "Configurable");
a(d.enumerable, false, "Enumerable");
a(d.writable, true, "Writable");
d = getOwnPropertyDescriptor(o, "dfgs");
a(d.value, undefined, "GS Value");
a(d.get, dfg, "GS Get");
a(d.set, dfs, "GS Set");
a(d.configurable, true, "GS Configurable");
a(d.enumerable, false, "GS Enumerable");
a(d.writable, undefined, "GS Writable");
},
Options: {
v: function (a) {
var x = {}, d = t(x, { foo: true });
a.deep(
d,
{ configurable: true, enumerable: false, writable: true, value: x, foo: true },
"No descriptor"
);
d = t("c", "foo", { marko: "elo" });
a.deep(
d,
{
configurable: true,
enumerable: false,
writable: false,
value: "foo",
marko: "elo"
},
"Descriptor"
);
},
gs: function (a) {
var gFn = function () {}, sFn = function () {}, d;
d = t.gs(gFn, sFn, { foo: true });
a.deep(
d, { configurable: true, enumerable: false, get: gFn, set: sFn, foo: true },
"No descriptor"
);
d = t.gs(null, sFn, { foo: true });
a.deep(
d,
{ configurable: true, enumerable: false, get: undefined, set: sFn, foo: true },
"No descriptor: Just set"
);
d = t.gs(gFn, { foo: true });
a.deep(
d,
{ configurable: true, enumerable: false, get: gFn, set: undefined, foo: true },
"No descriptor: Just get"
);
d = t.gs("e", gFn, sFn, { bar: true });
a.deep(
d, { configurable: false, enumerable: true, get: gFn, set: sFn, bar: true },
"Descriptor"
);
d = t.gs("e", null, sFn, { bar: true });
a.deep(
d,
{ configurable: false, enumerable: true, get: undefined, set: sFn, bar: true },
"Descriptor: Just set"
);
d = t.gs("e", gFn, { bar: true });
a.deep(
d,
{ configurable: false, enumerable: true, get: gFn, set: undefined, bar: true },
"Descriptor: Just get"
);
}
}
};
};
+97
View File
@@ -0,0 +1,97 @@
"use strict";
var d = require("../")
, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
module.exports = function (t, a) {
var Foo = function () {}, i = 1, o, o2, desc;
Object.defineProperties(
Foo.prototype,
t({
bar: d(function () { return ++i; }),
bar2: d(function () { return this.bar + 23; }),
bar3: d(function () { return this.bar2 + 34; }, { desc: "ew" }),
bar4: d(function () { return this.bar3 + 12; }, { cacheName: "_bar4_" }),
bar5: d(function () { return this.bar4 + 3; }, { cacheName: "_bar5_", desc: "e" })
})
);
desc = getOwnPropertyDescriptor(Foo.prototype, "bar");
a(desc.configurable, true, "Configurable: default");
a(desc.enumerable, false, "Enumerable: default");
o = new Foo();
a.deep([o.bar, o.bar2, o.bar3, o.bar4, o.bar5], [2, 25, 59, 71, 74], "Values");
a.deep(
getOwnPropertyDescriptor(o, "bar3"),
{ configurable: false, enumerable: true, writable: true, value: 59 }, "Desc"
);
a(o.hasOwnProperty("bar4"), false, "Cache not exposed");
desc = getOwnPropertyDescriptor(o, "bar5");
a.deep(
desc, { configurable: false, enumerable: true, get: desc.get, set: desc.set },
"Cache & Desc: desc"
);
o2 = Object.create(o);
o2.bar = 30;
o2.bar3 = 100;
a.deep(
[o2.bar, o2.bar2, o2.bar3, o2.bar4, o2.bar5], [30, 25, 100, 112, 115], "Extension Values"
);
Foo = function () {};
Object.defineProperties(
Foo.prototype,
t({
test: d("w", function () { return "raz"; }),
test2: d("", function () { return "raz"; }, { desc: "w" }),
test3: d("", function () { return "raz"; }, { cacheName: "__test3__", desc: "w" }),
test4: d("w", "bar")
})
);
o = new Foo();
o.test = "marko";
a.deep(
getOwnPropertyDescriptor(o, "test"),
{ configurable: false, enumerable: false, writable: true, value: "marko" }, "Set before get"
);
o.test2 = "marko2";
a.deep(
getOwnPropertyDescriptor(o, "test2"),
{ configurable: false, enumerable: false, writable: true, value: "marko2" },
"Set before get: Custom desc"
);
o.test3 = "marko3";
a.deep(
getOwnPropertyDescriptor(o, "__test3__"),
{ configurable: false, enumerable: false, writable: true, value: "marko3" },
"Set before get: Custom cache name"
);
a(o.test4, "bar", "Resolve by value");
a.h1("Flat");
Object.defineProperties(
Foo.prototype,
t({
flat: d(function () { return "foo"; }, { flat: true }),
flat2: d(function () { return "bar"; }, { flat: true })
})
);
a.h2("Instance");
a(o.flat, "foo", "Value");
a(o.hasOwnProperty("flat"), false, "Instance");
a(Foo.prototype.flat, "foo", "Prototype");
a.h2("Direct");
a(Foo.prototype.flat2, "bar");
a.h2("Reset direct");
Object.defineProperties(Foo.prototype, t({ testResetDirect: d(false) }));
a.throws(function () { Foo.prototype.testResetDirect = false; }, TypeError);
};