@anzenjs/json
Advanced tools
Comparing version 0.0.3 to 0.0.4-0.0.4-alpha.2.0
@@ -1,7 +0,7 @@ | ||
import { Schema } from '@anzenjs/core'; | ||
import { SchemaLike } from '@anzenjs/core'; | ||
import { ICodec } from '@anzenjs/extra'; | ||
import { JsonValue } from './types'; | ||
export declare class JsonCodec implements ICodec<JsonValue, JsonValue> { | ||
encode(schema: Schema): (value: unknown) => JsonValue; | ||
decode(schema: Schema): (value: JsonValue) => any; | ||
encode(schemaLike: SchemaLike): (value: unknown) => JsonValue; | ||
decode(schemaLike: SchemaLike): (value: JsonValue) => any; | ||
private encodeObject; | ||
@@ -8,0 +8,0 @@ private decodeObject; |
@@ -6,3 +6,4 @@ "use strict"; | ||
class JsonCodec { | ||
encode(schema) { | ||
encode(schemaLike) { | ||
const schema = core_1.resolveSchema(schemaLike); | ||
return (value) => { | ||
@@ -31,3 +32,4 @@ switch (schema.type) { | ||
} | ||
decode(schema) { | ||
decode(schemaLike) { | ||
const schema = core_1.resolveSchema(schemaLike); | ||
return (value) => { | ||
@@ -34,0 +36,0 @@ switch (schema.type) { |
{ | ||
"name": "@anzenjs/json", | ||
"version": "0.0.3", | ||
"version": "0.0.4-0.0.4-alpha.2.0", | ||
"main": "dist/src/index.js", | ||
@@ -18,3 +18,3 @@ "types": "dist/src/index.d.ts", | ||
}, | ||
"gitHead": "d30d062cf97b6d41cbe401b886aca6106111600e" | ||
"gitHead": "2737e87c8a7c778de9c4adc7c705c6aa9cbec6c5" | ||
} |
@@ -7,3 +7,5 @@ import { | ||
Resolve, | ||
resolveSchema, | ||
Schema, | ||
SchemaLike, | ||
SchemaType, | ||
@@ -16,3 +18,5 @@ } from '@anzenjs/core' | ||
export class JsonCodec implements ICodec<JsonValue, JsonValue> { | ||
public encode(schema: Schema) { | ||
public encode(schemaLike: SchemaLike) { | ||
const schema = resolveSchema(schemaLike) | ||
return (value: Resolve<Schema>): JsonValue => { | ||
@@ -53,3 +57,5 @@ switch (schema.type) { | ||
public decode(schema: Schema) { | ||
public decode(schemaLike: SchemaLike) { | ||
const schema = resolveSchema(schemaLike) | ||
return (value: JsonValue): any => { | ||
@@ -56,0 +62,0 @@ switch (schema.type) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
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
21219
375
1