@plumier/reflect
Advanced tools
Comparing version 1.1.2-canary.4 to 1.1.2
@@ -6,2 +6,16 @@ # Change Log | ||
## [1.1.2](https://github.com/plumier/plumier/compare/v1.1.1...v1.1.2) (2023-01-20) | ||
### Bug Fixes | ||
* **reflect:** Fix inefficient regular expression issue ([#1044](https://github.com/plumier/plumier/issues/1044)) ([ce733c1](https://github.com/plumier/plumier/commit/ce733c15a079fd3e9261a162f51be5a2920ae0fb)) | ||
* **reflect:** Fix introspect property which accessed private field ([#1038](https://github.com/plumier/plumier/issues/1038)) ([db6a615](https://github.com/plumier/plumier/commit/db6a6158c334d6883a46f5c0369f3a3dc1a523ae)) | ||
* **reflect:** Fix issue where primitive data type inspected as Function instead of Class ([#1035](https://github.com/plumier/plumier/issues/1035)) ([c9bc774](https://github.com/plumier/plumier/commit/c9bc7742f7f3f4e910fb3f097a1f5d5780ae2442)) | ||
* **reflect:** Fix unable to reflect function property inside object ([#1037](https://github.com/plumier/plumier/issues/1037)) ([1e6f54e](https://github.com/plumier/plumier/commit/1e6f54e893c16778115750d2f3683464958b7977)) | ||
## [1.1.1](https://github.com/plumier/plumier/compare/v1.1.0...v1.1.1) (2023-01-03) | ||
@@ -8,0 +22,0 @@ |
@@ -65,12 +65,9 @@ "use strict"; | ||
// regex search for | ||
if (functionOnly && code.search(/^(async\b\s*)?function\s*\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\)\s*{/gm) > -1) | ||
// /^(async\s+)?(function)\s*([a-zA-Z0-9_$]*)\s*\(([^)]*)\)\s*\{([^}]*)\}/ | ||
if (functionOnly && code.search(/^(async\s+)?(function)\s*\(([^)]*)\)\s*\{([^}]*)\}/gm) > -1) | ||
return code.replace("function", "function _"); | ||
// in case inline function | ||
// const obj = { fn(par1) {} } | ||
if (functionOnly && code.search(/^([A-z0-9]+)\s*\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\)\s*(?!=>){/gm) > -1) | ||
return `function ${code}`; | ||
// in case inline async function | ||
// const obj = { async fn(par1) {} } | ||
if (functionOnly && code.search(/^async\s*([A-z0-9]+)\s*\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\)/gm) > -1) | ||
return code.replace("async", "async function"); | ||
if (functionOnly && code.search(/^(async\s+)?([a-zA-Z0-9_$]*)\s*\(([^)]*)\)\s*(?!=>)\s*\{([^}]*)\}/gm) > -1) | ||
return code.startsWith("async") ? code.replace("async", "async function") : `function ${code}`; | ||
// for the rest code, sometime its contain [native code], just remove it | ||
@@ -194,7 +191,4 @@ return code.replace("[native code]", ""); | ||
} | ||
function isFunction(owner, member) { | ||
const descriptor = Object.getOwnPropertyDescriptor(owner, member); | ||
return typeof (descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) === "function"; | ||
} | ||
function parseProperties(owner) { | ||
const isFunction = (owner, member) => { var _a; return typeof ((_a = Object.getOwnPropertyDescriptor(owner, member)) === null || _a === void 0 ? void 0 : _a.value) === "function"; }; | ||
const result = []; | ||
@@ -201,0 +195,0 @@ const members = getClassMembers(owner); |
{ | ||
"name": "@plumier/reflect", | ||
"version": "1.1.2-canary.4+b569e4e", | ||
"version": "1.1.2", | ||
"description": "Plumier reflection module", | ||
@@ -42,3 +42,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "b569e4e6adfd0d70121164156ec60b78051d3b08" | ||
"gitHead": "cfda714b6f9048e66d3d7a5a1f0a51310bfc9902" | ||
} |
@@ -1,13 +0,12 @@ | ||
# Reflect: A TypeScript Reflection Library | ||
# Reflect: A JavScript/TypeScript Reflection Library | ||
An introspection (reflection) library, extracts JavaScript/TypeScript type into an object graph containing object preferences and metadata | ||
A reflection library, extracts JavaScript/TypeScript object into an object graph containing object preferences and applied metadata information | ||
## Companies Using Reflect | ||
[![HP Inc](https://avatars.githubusercontent.com/u/9728779?s=200)](https://github.com/HPInc) | ||
[<img src="https://user-images.githubusercontent.com/1106884/210295963-95ed9685-af85-475f-954f-fa24af9aab61.png" width="200" />](https://github.com/HPInc) | ||
## Example Usage | ||
## Example | ||
```typescript | ||
@@ -27,6 +26,6 @@ import reflect from "@plumier/reflect" | ||
const metadata = reflect(MyAwesomeClass) | ||
const obj = reflect(MyAwesomeClass) | ||
``` | ||
Result of `metadata` variable above is like below | ||
Result of `obj` variable above is like below | ||
@@ -91,3 +90,3 @@ ```javascript | ||
- [x] Supported inspect parameter with complex default value | ||
- [x] (TypeScript only) Inspect decorators | ||
- [x] (TypeScript only) Inspect metadata using decorators | ||
- [x] (TypeScript only) Inspect parameter properties | ||
@@ -98,3 +97,2 @@ - [x] (TypeScript only) Inspect type information | ||
## TypeScript Requirement | ||
@@ -132,3 +130,3 @@ To be able to inspect type information its required to enable configuration below in `tsconfig.json` | ||
const metadata = reflect(Awesome) | ||
const obj = reflect(Awesome) | ||
``` | ||
@@ -146,3 +144,3 @@ | ||
const metadata = reflect(Awesome) | ||
const obj = reflect(Awesome) | ||
``` | ||
@@ -160,3 +158,3 @@ | ||
const metadata = reflect(Awesome) | ||
const obj = reflect(Awesome) | ||
``` | ||
@@ -176,3 +174,3 @@ Above code showing that we able to get type information of parameters of the constructor, by applying decorator on the class level. | ||
const metadata = reflect(Awesome) | ||
const obj = reflect(Awesome) | ||
``` | ||
@@ -194,3 +192,3 @@ | ||
const metadata = reflect(Awesome) | ||
const obj = reflect(Awesome) | ||
``` | ||
@@ -214,3 +212,3 @@ | ||
const metadata = reflect(Awesome) | ||
const obj = reflect(Awesome) | ||
``` | ||
@@ -231,3 +229,3 @@ | ||
const metadata = reflect(Awesome) | ||
const obj = reflect(Awesome) | ||
``` | ||
@@ -234,0 +232,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
83743
1
0
1495
358