Comparing version 1.0.0 to 1.0.1
type Transformer<T, S> = { | ||
name: string; | ||
key: string; | ||
isApplicable(value: unknown): value is T; | ||
@@ -4,0 +5,0 @@ serialize(value: T): S; |
@@ -75,3 +75,4 @@ "use strict"; | ||
u: { | ||
name: "u", | ||
name: "Unknown", | ||
key: "u", | ||
isApplicable(value) { | ||
@@ -88,3 +89,4 @@ return value === void 0; | ||
i: { | ||
name: "i", | ||
name: "BigInt", | ||
key: "i", | ||
isApplicable(value) { | ||
@@ -101,3 +103,4 @@ return typeof value === "bigint"; | ||
b: { | ||
name: "b", | ||
name: "Buffer", | ||
key: "b", | ||
isApplicable(value) { | ||
@@ -114,3 +117,4 @@ return value instanceof import_buffer.Buffer; | ||
d: { | ||
name: "d", | ||
name: "Date", | ||
key: "d", | ||
isApplicable(value) { | ||
@@ -138,3 +142,3 @@ return value instanceof Date; | ||
return { | ||
[`${MAGIC}${transformer.name}`]: transformer.serialize(value) | ||
[`${MAGIC}${transformer.key}`]: transformer.serialize(value) | ||
}; | ||
@@ -179,3 +183,7 @@ } | ||
register(transformer) { | ||
__privateGet(this, _transformers)[transformer.name] = transformer; | ||
const existing = __privateGet(this, _transformers)[transformer.key]; | ||
if (existing) { | ||
throw new Error(`Transformer ${transformer.key} already registered for '${existing.name}'`); | ||
} | ||
__privateGet(this, _transformers)[transformer.key] = transformer; | ||
} | ||
@@ -192,8 +200,5 @@ stringify(data) { | ||
); | ||
if (value instanceof Date) { | ||
console.log(key, value, transformer); | ||
} | ||
if (transformer) { | ||
return { | ||
[`${MAGIC}${transformer.name}`]: transformer.serialize(value) | ||
[`${MAGIC}${transformer.key}`]: transformer.serialize(value) | ||
}; | ||
@@ -200,0 +205,0 @@ } |
{ | ||
"name": "xtrajson", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A JSON serialization tool", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
18404
478