@zthun/helpful-reflection 9.6.0 → 9.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +15 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -60
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -5,81 +5,36 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const helpfulFn = require('@zthun/helpful-fn');
|
|
6
6
|
const noConflict = require('reflect-metadata/no-conflict');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
if (key in obj) {
|
|
10
|
-
Object.defineProperty(obj, key, {
|
|
11
|
-
value: value,
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true
|
|
15
|
-
});
|
|
16
|
-
} else {
|
|
17
|
-
obj[key] = value;
|
|
18
|
-
}
|
|
19
|
-
return obj;
|
|
20
|
-
}
|
|
21
|
-
function _object_spread(target) {
|
|
22
|
-
for(var i = 1; i < arguments.length; i++){
|
|
23
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
24
|
-
var ownKeys = Object.keys(source);
|
|
25
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
26
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
27
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
ownKeys.forEach(function(key) {
|
|
31
|
-
_define_property(target, key, source[key]);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
}
|
|
36
|
-
function ownKeys(object, enumerableOnly) {
|
|
37
|
-
var keys = Object.keys(object);
|
|
38
|
-
if (Object.getOwnPropertySymbols) {
|
|
39
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
-
keys.push.apply(keys, symbols);
|
|
41
|
-
}
|
|
42
|
-
return keys;
|
|
43
|
-
}
|
|
44
|
-
function _object_spread_props(target, source) {
|
|
45
|
-
source = source != null ? source : {};
|
|
46
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
47
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
48
|
-
} else {
|
|
49
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
50
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return target;
|
|
54
|
-
}
|
|
55
|
-
function _type_of(obj) {
|
|
56
|
-
"@swc/helpers - typeof";
|
|
57
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
58
|
-
}
|
|
59
|
-
var Key = "zthunworks:tags";
|
|
8
|
+
const Key = "zthunworks:tags";
|
|
60
9
|
function ZTag(by) {
|
|
61
|
-
return
|
|
10
|
+
return (target, property)=>{
|
|
62
11
|
if (property == null) {
|
|
63
12
|
// Class.
|
|
64
|
-
|
|
65
|
-
noConflict.defineMetadata(Key,
|
|
13
|
+
const current = helpfulFn.firstDefined({}, noConflict.getMetadata(Key, target));
|
|
14
|
+
noConflict.defineMetadata(Key, {
|
|
15
|
+
...current,
|
|
16
|
+
[by]: true
|
|
17
|
+
}, target);
|
|
66
18
|
} else {
|
|
67
19
|
// Member.
|
|
68
|
-
|
|
69
|
-
noConflict.defineMetadata(Key,
|
|
20
|
+
const current = helpfulFn.firstDefined({}, noConflict.getMetadata(Key, target, property));
|
|
21
|
+
noConflict.defineMetadata(Key, {
|
|
22
|
+
...current,
|
|
23
|
+
[by]: true
|
|
24
|
+
}, target, property);
|
|
70
25
|
}
|
|
71
26
|
};
|
|
72
27
|
}
|
|
73
28
|
function isTagged(by, target, property) {
|
|
74
|
-
|
|
29
|
+
const candidates = [
|
|
75
30
|
"function",
|
|
76
31
|
"object"
|
|
77
32
|
];
|
|
78
|
-
|
|
33
|
+
const type = typeof target;
|
|
79
34
|
if (target == null || !candidates.includes(type)) {
|
|
80
35
|
return false;
|
|
81
36
|
}
|
|
82
|
-
|
|
37
|
+
const tags = property ? noConflict.getMetadata(Key, target, property) : noConflict.getMetadata(Key, target);
|
|
83
38
|
return Object.prototype.hasOwnProperty.call(helpfulFn.firstDefined({}, tags), by);
|
|
84
39
|
}
|
|
85
40
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/tag/tag.ts"],"sourcesContent":["import { firstDefined } from \"@zthun/helpful-fn\";\nimport { defineMetadata, getMetadata } from \"reflect-metadata/no-conflict\";\n\nconst Key = \"zthunworks:tags\";\n\nexport function ZTag(\n by: string,\n): MethodDecorator & ClassDecorator & PropertyDecorator {\n return (target: any, property?: string | symbol) => {\n if (property == null) {\n // Class.\n const current = firstDefined({}, getMetadata(Key, target));\n defineMetadata(Key, { ...current, [by]: true }, target);\n } else {\n // Member.\n const current = firstDefined({}, getMetadata(Key, target, property));\n defineMetadata(Key, { ...current, [by]: true }, target, property);\n }\n };\n}\n\nexport function isTagged(\n by: string,\n target: any,\n property?: string | symbol,\n): boolean {\n const candidates = [\"function\", \"object\"];\n const type = typeof target;\n\n if (target == null || !candidates.includes(type)) {\n return false;\n }\n\n const tags = property\n ? getMetadata(Key, target, property)\n : getMetadata(Key, target);\n\n return Object.prototype.hasOwnProperty.call(firstDefined({}, tags), by);\n}\n"],"names":["Key","ZTag","by","target","property","current","firstDefined","getMetadata","defineMetadata","isTagged","candidates","type","includes","tags","Object","prototype","hasOwnProperty","call"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/tag/tag.ts"],"sourcesContent":["import { firstDefined } from \"@zthun/helpful-fn\";\nimport { defineMetadata, getMetadata } from \"reflect-metadata/no-conflict\";\n\nconst Key = \"zthunworks:tags\";\n\nexport function ZTag(\n by: string,\n): MethodDecorator & ClassDecorator & PropertyDecorator {\n return (target: any, property?: string | symbol) => {\n if (property == null) {\n // Class.\n const current = firstDefined({}, getMetadata(Key, target));\n defineMetadata(Key, { ...current, [by]: true }, target);\n } else {\n // Member.\n const current = firstDefined({}, getMetadata(Key, target, property));\n defineMetadata(Key, { ...current, [by]: true }, target, property);\n }\n };\n}\n\nexport function isTagged(\n by: string,\n target: any,\n property?: string | symbol,\n): boolean {\n const candidates = [\"function\", \"object\"];\n const type = typeof target;\n\n if (target == null || !candidates.includes(type)) {\n return false;\n }\n\n const tags = property\n ? getMetadata(Key, target, property)\n : getMetadata(Key, target);\n\n return Object.prototype.hasOwnProperty.call(firstDefined({}, tags), by);\n}\n"],"names":["Key","ZTag","by","target","property","current","firstDefined","getMetadata","defineMetadata","isTagged","candidates","type","includes","tags","Object","prototype","hasOwnProperty","call"],"mappings":";;;;;;;AAGA,MAAMA,GAAAA,GAAM,iBAAA;AAEL,SAASC,KACdC,EAAU,EAAA;AAEV,IAAA,OAAO,CAACC,MAAAA,EAAaC,QAAAA,GAAAA;AACnB,QAAA,IAAIA,YAAY,IAAA,EAAM;;AAEpB,YAAA,MAAMC,OAAAA,GAAUC,sBAAAA,CAAa,EAAC,EAAGC,uBAAYP,GAAAA,EAAKG,MAAAA,CAAAA,CAAAA;AAClDK,YAAAA,yBAAAA,CAAeR,GAAAA,EAAK;AAAE,gBAAA,GAAGK,OAAO;AAAE,gBAAA,CAACH,KAAK;aAAK,EAAGC,MAAAA,CAAAA;QAClD,CAAA,MAAO;;AAEL,YAAA,MAAME,UAAUC,sBAAAA,CAAa,EAAC,EAAGC,sBAAAA,CAAYP,KAAKG,MAAAA,EAAQC,QAAAA,CAAAA,CAAAA;AAC1DI,YAAAA,yBAAAA,CAAeR,GAAAA,EAAK;AAAE,gBAAA,GAAGK,OAAO;AAAE,gBAAA,CAACH,KAAK;AAAK,aAAA,EAAGC,MAAAA,EAAQC,QAAAA,CAAAA;AAC1D,QAAA;AACF,IAAA,CAAA;AACF;AAEO,SAASK,QAAAA,CACdP,EAAU,EACVC,MAAW,EACXC,QAA0B,EAAA;AAE1B,IAAA,MAAMM,UAAAA,GAAa;AAAC,QAAA,UAAA;AAAY,QAAA;AAAS,KAAA;AACzC,IAAA,MAAMC,OAAO,OAAOR,MAAAA;AAEpB,IAAA,IAAIA,UAAU,IAAA,IAAQ,CAACO,UAAAA,CAAWE,QAAQ,CAACD,IAAAA,CAAAA,EAAO;QAChD,OAAO,KAAA;AACT,IAAA;AAEA,IAAA,MAAME,OAAOT,QAAAA,GACTG,sBAAAA,CAAYP,KAAKG,MAAAA,EAAQC,QAAAA,CAAAA,GACzBG,uBAAYP,GAAAA,EAAKG,MAAAA,CAAAA;IAErB,OAAOW,MAAAA,CAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,sBAAAA,CAAa,EAAC,EAAGO,IAAAA,CAAAA,EAAOX,EAAAA,CAAAA;AACtE;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,81 +1,36 @@
|
|
|
1
1
|
import { firstDefined } from '@zthun/helpful-fn';
|
|
2
2
|
import { getMetadata, defineMetadata } from 'reflect-metadata/no-conflict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
if (key in obj) {
|
|
6
|
-
Object.defineProperty(obj, key, {
|
|
7
|
-
value: value,
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true
|
|
11
|
-
});
|
|
12
|
-
} else {
|
|
13
|
-
obj[key] = value;
|
|
14
|
-
}
|
|
15
|
-
return obj;
|
|
16
|
-
}
|
|
17
|
-
function _object_spread(target) {
|
|
18
|
-
for(var i = 1; i < arguments.length; i++){
|
|
19
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
20
|
-
var ownKeys = Object.keys(source);
|
|
21
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
22
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
23
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
ownKeys.forEach(function(key) {
|
|
27
|
-
_define_property(target, key, source[key]);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
}
|
|
32
|
-
function ownKeys(object, enumerableOnly) {
|
|
33
|
-
var keys = Object.keys(object);
|
|
34
|
-
if (Object.getOwnPropertySymbols) {
|
|
35
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
36
|
-
keys.push.apply(keys, symbols);
|
|
37
|
-
}
|
|
38
|
-
return keys;
|
|
39
|
-
}
|
|
40
|
-
function _object_spread_props(target, source) {
|
|
41
|
-
source = source != null ? source : {};
|
|
42
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
43
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
44
|
-
} else {
|
|
45
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
46
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return target;
|
|
50
|
-
}
|
|
51
|
-
function _type_of(obj) {
|
|
52
|
-
"@swc/helpers - typeof";
|
|
53
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
54
|
-
}
|
|
55
|
-
var Key = "zthunworks:tags";
|
|
4
|
+
const Key = "zthunworks:tags";
|
|
56
5
|
function ZTag(by) {
|
|
57
|
-
return
|
|
6
|
+
return (target, property)=>{
|
|
58
7
|
if (property == null) {
|
|
59
8
|
// Class.
|
|
60
|
-
|
|
61
|
-
defineMetadata(Key,
|
|
9
|
+
const current = firstDefined({}, getMetadata(Key, target));
|
|
10
|
+
defineMetadata(Key, {
|
|
11
|
+
...current,
|
|
12
|
+
[by]: true
|
|
13
|
+
}, target);
|
|
62
14
|
} else {
|
|
63
15
|
// Member.
|
|
64
|
-
|
|
65
|
-
defineMetadata(Key,
|
|
16
|
+
const current = firstDefined({}, getMetadata(Key, target, property));
|
|
17
|
+
defineMetadata(Key, {
|
|
18
|
+
...current,
|
|
19
|
+
[by]: true
|
|
20
|
+
}, target, property);
|
|
66
21
|
}
|
|
67
22
|
};
|
|
68
23
|
}
|
|
69
24
|
function isTagged(by, target, property) {
|
|
70
|
-
|
|
25
|
+
const candidates = [
|
|
71
26
|
"function",
|
|
72
27
|
"object"
|
|
73
28
|
];
|
|
74
|
-
|
|
29
|
+
const type = typeof target;
|
|
75
30
|
if (target == null || !candidates.includes(type)) {
|
|
76
31
|
return false;
|
|
77
32
|
}
|
|
78
|
-
|
|
33
|
+
const tags = property ? getMetadata(Key, target, property) : getMetadata(Key, target);
|
|
79
34
|
return Object.prototype.hasOwnProperty.call(firstDefined({}, tags), by);
|
|
80
35
|
}
|
|
81
36
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/tag/tag.ts"],"sourcesContent":["import { firstDefined } from \"@zthun/helpful-fn\";\nimport { defineMetadata, getMetadata } from \"reflect-metadata/no-conflict\";\n\nconst Key = \"zthunworks:tags\";\n\nexport function ZTag(\n by: string,\n): MethodDecorator & ClassDecorator & PropertyDecorator {\n return (target: any, property?: string | symbol) => {\n if (property == null) {\n // Class.\n const current = firstDefined({}, getMetadata(Key, target));\n defineMetadata(Key, { ...current, [by]: true }, target);\n } else {\n // Member.\n const current = firstDefined({}, getMetadata(Key, target, property));\n defineMetadata(Key, { ...current, [by]: true }, target, property);\n }\n };\n}\n\nexport function isTagged(\n by: string,\n target: any,\n property?: string | symbol,\n): boolean {\n const candidates = [\"function\", \"object\"];\n const type = typeof target;\n\n if (target == null || !candidates.includes(type)) {\n return false;\n }\n\n const tags = property\n ? getMetadata(Key, target, property)\n : getMetadata(Key, target);\n\n return Object.prototype.hasOwnProperty.call(firstDefined({}, tags), by);\n}\n"],"names":["Key","ZTag","by","target","property","current","firstDefined","getMetadata","defineMetadata","isTagged","candidates","type","includes","tags","Object","prototype","hasOwnProperty","call"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/tag/tag.ts"],"sourcesContent":["import { firstDefined } from \"@zthun/helpful-fn\";\nimport { defineMetadata, getMetadata } from \"reflect-metadata/no-conflict\";\n\nconst Key = \"zthunworks:tags\";\n\nexport function ZTag(\n by: string,\n): MethodDecorator & ClassDecorator & PropertyDecorator {\n return (target: any, property?: string | symbol) => {\n if (property == null) {\n // Class.\n const current = firstDefined({}, getMetadata(Key, target));\n defineMetadata(Key, { ...current, [by]: true }, target);\n } else {\n // Member.\n const current = firstDefined({}, getMetadata(Key, target, property));\n defineMetadata(Key, { ...current, [by]: true }, target, property);\n }\n };\n}\n\nexport function isTagged(\n by: string,\n target: any,\n property?: string | symbol,\n): boolean {\n const candidates = [\"function\", \"object\"];\n const type = typeof target;\n\n if (target == null || !candidates.includes(type)) {\n return false;\n }\n\n const tags = property\n ? getMetadata(Key, target, property)\n : getMetadata(Key, target);\n\n return Object.prototype.hasOwnProperty.call(firstDefined({}, tags), by);\n}\n"],"names":["Key","ZTag","by","target","property","current","firstDefined","getMetadata","defineMetadata","isTagged","candidates","type","includes","tags","Object","prototype","hasOwnProperty","call"],"mappings":";;;AAGA,MAAMA,GAAAA,GAAM,iBAAA;AAEL,SAASC,KACdC,EAAU,EAAA;AAEV,IAAA,OAAO,CAACC,MAAAA,EAAaC,QAAAA,GAAAA;AACnB,QAAA,IAAIA,YAAY,IAAA,EAAM;;AAEpB,YAAA,MAAMC,OAAAA,GAAUC,YAAAA,CAAa,EAAC,EAAGC,YAAYP,GAAAA,EAAKG,MAAAA,CAAAA,CAAAA;AAClDK,YAAAA,cAAAA,CAAeR,GAAAA,EAAK;AAAE,gBAAA,GAAGK,OAAO;AAAE,gBAAA,CAACH,KAAK;aAAK,EAAGC,MAAAA,CAAAA;QAClD,CAAA,MAAO;;AAEL,YAAA,MAAME,UAAUC,YAAAA,CAAa,EAAC,EAAGC,WAAAA,CAAYP,KAAKG,MAAAA,EAAQC,QAAAA,CAAAA,CAAAA;AAC1DI,YAAAA,cAAAA,CAAeR,GAAAA,EAAK;AAAE,gBAAA,GAAGK,OAAO;AAAE,gBAAA,CAACH,KAAK;AAAK,aAAA,EAAGC,MAAAA,EAAQC,QAAAA,CAAAA;AAC1D,QAAA;AACF,IAAA,CAAA;AACF;AAEO,SAASK,QAAAA,CACdP,EAAU,EACVC,MAAW,EACXC,QAA0B,EAAA;AAE1B,IAAA,MAAMM,UAAAA,GAAa;AAAC,QAAA,UAAA;AAAY,QAAA;AAAS,KAAA;AACzC,IAAA,MAAMC,OAAO,OAAOR,MAAAA;AAEpB,IAAA,IAAIA,UAAU,IAAA,IAAQ,CAACO,UAAAA,CAAWE,QAAQ,CAACD,IAAAA,CAAAA,EAAO;QAChD,OAAO,KAAA;AACT,IAAA;AAEA,IAAA,MAAME,OAAOT,QAAAA,GACTG,WAAAA,CAAYP,KAAKG,MAAAA,EAAQC,QAAAA,CAAAA,GACzBG,YAAYP,GAAAA,EAAKG,MAAAA,CAAAA;IAErB,OAAOW,MAAAA,CAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,YAAAA,CAAa,EAAC,EAAGO,IAAAA,CAAAA,EAAOX,EAAAA,CAAAA;AACtE;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zthun/helpful-reflection",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
4
4
|
"description": "Helpful decorators built around reflect-metadata.",
|
|
5
5
|
"author": "Anthony Bonta",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@zthun/helpful-fn": "^9.
|
|
28
|
+
"@zthun/helpful-fn": "^9.8.0",
|
|
29
29
|
"reflect-metadata": "^0.2.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@zthun/janitor-build-config": "^19.
|
|
32
|
+
"@zthun/janitor-build-config": "^19.4.1",
|
|
33
33
|
"typescript": "~5.9.3",
|
|
34
|
-
"vite": "^7.1.
|
|
35
|
-
"vitest": "^
|
|
34
|
+
"vite": "^7.1.11",
|
|
35
|
+
"vitest": "^4.0.1"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"sideEffects": false,
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "8eedf4b987cf59c0a12f1f0cd537d057414f924c"
|
|
42
42
|
}
|