@zthun/helpful-reflection 9.1.0 → 9.4.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 +80 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +77 -20
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/tag/tag.spec.d.ts +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,26 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const helpfulFn = require('@zthun/helpful-fn');
|
|
6
|
+
const noConflict = require('reflect-metadata/no-conflict');
|
|
7
|
+
|
|
8
|
+
function _define_property(obj, key, value) {
|
|
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));
|
|
11
48
|
} else {
|
|
12
|
-
|
|
13
|
-
|
|
49
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
50
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
51
|
+
});
|
|
14
52
|
}
|
|
15
|
-
|
|
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";
|
|
60
|
+
function ZTag(by) {
|
|
61
|
+
return function(target, property) {
|
|
62
|
+
if (property == null) {
|
|
63
|
+
// Class.
|
|
64
|
+
var current = helpfulFn.firstDefined({}, noConflict.getMetadata(Key, target));
|
|
65
|
+
noConflict.defineMetadata(Key, _object_spread_props(_object_spread({}, current), _define_property({}, by, true)), target);
|
|
66
|
+
} else {
|
|
67
|
+
// Member.
|
|
68
|
+
var current1 = helpfulFn.firstDefined({}, noConflict.getMetadata(Key, target, property));
|
|
69
|
+
noConflict.defineMetadata(Key, _object_spread_props(_object_spread({}, current1), _define_property({}, by, true)), target, property);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
16
72
|
}
|
|
17
73
|
function isTagged(by, target, property) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
74
|
+
var candidates = [
|
|
75
|
+
"function",
|
|
76
|
+
"object"
|
|
77
|
+
];
|
|
78
|
+
var type = typeof target === "undefined" ? "undefined" : _type_of(target);
|
|
79
|
+
if (target == null || !candidates.includes(type)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
var tags = property ? noConflict.getMetadata(Key, target, property) : noConflict.getMetadata(Key, target);
|
|
83
|
+
return Object.prototype.hasOwnProperty.call(helpfulFn.firstDefined({}, tags), by);
|
|
23
84
|
}
|
|
85
|
+
|
|
24
86
|
exports.ZTag = ZTag;
|
|
25
87
|
exports.isTagged = isTagged;
|
|
26
88
|
//# sourceMappingURL=index.cjs.map
|
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
|
|
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,IAAMA,GAAM,GAAA,iBAAA;AAEL,SAASC,KACdC,EAAU,EAAA;AAEV,IAAA,OAAO,SAACC,MAAaC,EAAAA,QAAAA,EAAAA;AACnB,QAAA,IAAIA,YAAY,IAAM,EAAA;;AAEpB,YAAA,IAAMC,OAAUC,GAAAA,sBAAAA,CAAa,EAAC,EAAGC,uBAAYP,GAAKG,EAAAA,MAAAA,CAAAA,CAAAA;AAClDK,YAAAA,yBAAAA,CAAeR,GAAK,EAAA,oBAAA,CAAA,cAAA,CAAA,EAAA,EAAKK,OAAS,CAAA,EAAA,gBAAA,CAAA,EAAA,EAACH,IAAK,IAAQC,CAAAA,CAAAA,EAAAA,MAAAA,CAAAA;SAC3C,MAAA;;AAEL,YAAA,IAAME,WAAUC,sBAAa,CAAA,EAAIC,EAAAA,sBAAAA,CAAYP,KAAKG,MAAQC,EAAAA,QAAAA,CAAAA,CAAAA;AAC1DI,YAAAA,yBAAAA,CAAeR,KAAK,oBAAKK,CAAAA,cAAAA,CAAAA,EAAAA,EAAAA,QAAAA,CAAAA,EAAS,gBAACH,CAAAA,EAAAA,EAAAA,EAAAA,EAAK,QAAQC,MAAQC,EAAAA,QAAAA,CAAAA;AAC1D;AACF,KAAA;AACF;AAEO,SAASK,QACdP,CAAAA,EAAU,EACVC,MAAW,EACXC,QAA0B,EAAA;AAE1B,IAAA,IAAMM,UAAa,GAAA;AAAC,QAAA,UAAA;AAAY,QAAA;AAAS,KAAA;IACzC,IAAMC,IAAAA,GAAO,OAAOR,MAAAA,KAAAA,WAAAA,GAAAA,WAAAA,GAAP,QAAOA,CAAAA,MAAAA,CAAAA;AAEpB,IAAA,IAAIA,UAAU,IAAQ,IAAA,CAACO,UAAWE,CAAAA,QAAQ,CAACD,IAAO,CAAA,EAAA;QAChD,OAAO,KAAA;AACT;AAEA,IAAA,IAAME,OAAOT,QACTG,GAAAA,sBAAAA,CAAYP,KAAKG,MAAQC,EAAAA,QAAAA,CAAAA,GACzBG,uBAAYP,GAAKG,EAAAA,MAAAA,CAAAA;IAErB,OAAOW,MAAAA,CAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACX,sBAAAA,CAAa,EAAC,EAAGO,IAAOX,CAAAA,EAAAA,EAAAA,CAAAA;AACtE;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,83 @@
|
|
|
1
|
-
import { firstDefined } from
|
|
2
|
-
import { getMetadata, defineMetadata } from
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { firstDefined } from '@zthun/helpful-fn';
|
|
2
|
+
import { getMetadata, defineMetadata } from 'reflect-metadata/no-conflict';
|
|
3
|
+
|
|
4
|
+
function _define_property(obj, key, value) {
|
|
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));
|
|
9
44
|
} else {
|
|
10
|
-
|
|
11
|
-
|
|
45
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
46
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
47
|
+
});
|
|
12
48
|
}
|
|
13
|
-
|
|
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";
|
|
56
|
+
function ZTag(by) {
|
|
57
|
+
return function(target, property) {
|
|
58
|
+
if (property == null) {
|
|
59
|
+
// Class.
|
|
60
|
+
var current = firstDefined({}, getMetadata(Key, target));
|
|
61
|
+
defineMetadata(Key, _object_spread_props(_object_spread({}, current), _define_property({}, by, true)), target);
|
|
62
|
+
} else {
|
|
63
|
+
// Member.
|
|
64
|
+
var current1 = firstDefined({}, getMetadata(Key, target, property));
|
|
65
|
+
defineMetadata(Key, _object_spread_props(_object_spread({}, current1), _define_property({}, by, true)), target, property);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
14
68
|
}
|
|
15
69
|
function isTagged(by, target, property) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
70
|
+
var candidates = [
|
|
71
|
+
"function",
|
|
72
|
+
"object"
|
|
73
|
+
];
|
|
74
|
+
var type = typeof target === "undefined" ? "undefined" : _type_of(target);
|
|
75
|
+
if (target == null || !candidates.includes(type)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
var tags = property ? getMetadata(Key, target, property) : getMetadata(Key, target);
|
|
79
|
+
return Object.prototype.hasOwnProperty.call(firstDefined({}, tags), by);
|
|
21
80
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
isTagged
|
|
25
|
-
};
|
|
81
|
+
|
|
82
|
+
export { ZTag, isTagged };
|
|
26
83
|
//# sourceMappingURL=index.js.map
|
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
|
|
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,IAAMA,GAAM,GAAA,iBAAA;AAEL,SAASC,KACdC,EAAU,EAAA;AAEV,IAAA,OAAO,SAACC,MAAaC,EAAAA,QAAAA,EAAAA;AACnB,QAAA,IAAIA,YAAY,IAAM,EAAA;;AAEpB,YAAA,IAAMC,OAAUC,GAAAA,YAAAA,CAAa,EAAC,EAAGC,YAAYP,GAAKG,EAAAA,MAAAA,CAAAA,CAAAA;AAClDK,YAAAA,cAAAA,CAAeR,GAAK,EAAA,oBAAA,CAAA,c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around reflect-metadata.",
|
|
5
5
|
"author": "Anthony Bonta",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@zthun/helpful-fn": "^9.
|
|
28
|
+
"@zthun/helpful-fn": "^9.4.0",
|
|
29
29
|
"reflect-metadata": "^0.2.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@zthun/janitor-build-config": "^19.2.
|
|
32
|
+
"@zthun/janitor-build-config": "^19.2.4",
|
|
33
33
|
"typescript": "~5.8.3",
|
|
34
34
|
"vite": "^6.3.5",
|
|
35
35
|
"vitest": "^3.2.4"
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"sideEffects": false,
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "c1bb7a55601ee10c0ef0973fc3824db06849f459"
|
|
42
42
|
}
|
package/dist/tag/tag.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|