@shaclmate/compiler 4.0.37 → 4.0.38

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.
@@ -1,12 +1,12 @@
1
1
  import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
2
  export const snippets_monkeyPatchObject = ({ syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}monkeyPatchObject`, code `\
3
3
  function ${syntheticNamePrefix}monkeyPatchObject<T extends object>(obj: T, methods: { toJson?: (obj: T) => object, ${syntheticNamePrefix}toString?: (obj: T) => string }): T {
4
- if (methods.toJson && !globalThis.Object.prototype.hasOwnProperty.call(obj, "toJSON")) {
4
+ if (methods.toJson && (!globalThis.Object.prototype.hasOwnProperty.call(obj, "toJSON") || typeof (obj as any).toJSON === "function")) {
5
5
  const toJsonMethod = methods.toJson;
6
6
  (obj as any).toJSON = function(this: T, _key: string) { return toJsonMethod(this); }
7
7
  }
8
8
 
9
- if (methods.${syntheticNamePrefix}toString && !globalThis.Object.prototype.hasOwnProperty.call(obj, "toString")) {
9
+ if (methods.${syntheticNamePrefix}toString && (!globalThis.Object.prototype.hasOwnProperty.call(obj, "toString") || typeof (obj as any).toJSON === "function")) {
10
10
  const toStringMethod = methods.${syntheticNamePrefix}toString;
11
11
  (obj as any).toString = function(this: T) { return toStringMethod(this); }
12
12
  }
@@ -133,14 +133,16 @@ function $identityValidationFunction(_schema, value) {
133
133
  const $literalFactory = new LiteralFactory({ dataFactory: dataFactory });
134
134
  function $monkeyPatchObject(obj, methods) {
135
135
  if (methods.toJson &&
136
- !globalThis.Object.prototype.hasOwnProperty.call(obj, "toJSON")) {
136
+ (!globalThis.Object.prototype.hasOwnProperty.call(obj, "toJSON") ||
137
+ typeof obj.toJSON === "function")) {
137
138
  const toJsonMethod = methods.toJson;
138
139
  obj.toJSON = function (_key) {
139
140
  return toJsonMethod(this);
140
141
  };
141
142
  }
142
143
  if (methods.$toString &&
143
- !globalThis.Object.prototype.hasOwnProperty.call(obj, "toString")) {
144
+ (!globalThis.Object.prototype.hasOwnProperty.call(obj, "toString") ||
145
+ typeof obj.toJSON === "function")) {
144
146
  const toStringMethod = methods.$toString;
145
147
  obj.toString = function () {
146
148
  return toStringMethod(this);
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "dependencies": {
3
- "@shaclmate/shacl-ast": "4.0.37",
3
+ "@shaclmate/shacl-ast": "4.0.38",
4
4
  "@rdfjs/dataset": "~2.0.2",
5
5
  "@rdfjs/prefix-map": "~0.1.2",
6
6
  "@rdfjs/term-map": "~2.0.2",
7
7
  "@rdfjs/term-set": "~2.0.3",
8
8
  "@rdfjs/types": "~2.0.1",
9
- "@rdfx/data-factory": "0.0.13",
10
- "@rdfx/literal": "0.0.13",
11
- "@rdfx/resource": "0.0.13",
12
- "@rdfx/string": "0.0.13",
9
+ "@rdfx/data-factory": "0.0.18",
10
+ "@rdfx/literal": "0.0.18",
11
+ "@rdfx/resource": "0.0.18",
12
+ "@rdfx/string": "0.0.18",
13
13
  "@sindresorhus/base62": "~0.1.0",
14
14
  "@tpluscode/rdf-ns-builders": "~4.3.0",
15
15
  "@types/rdfjs__dataset": "~2.0.7",
@@ -68,5 +68,5 @@
68
68
  },
69
69
  "type": "module",
70
70
  "types": "./dist/index.d.ts",
71
- "version": "4.0.37"
71
+ "version": "4.0.38"
72
72
  }