@aire-ux/aire-condensation
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "@aire-ux/aire-condensation", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Client-side serialization library for Aire-UX", | ||
@@ -81,4 +81,3 @@ "main": "dist/index.js", | ||
"reflect-metadata": "^0.1.13" | ||
}, | ||
"gitHead": "f0913bd1095bb927a69d28347b3482ba34fa0a8c" | ||
} | ||
} |
@@ -174,9 +174,8 @@ import TypeRegistry from "@condensation/type-registry"; | ||
return ctorArgs.map((def, idx) => { | ||
const doc = args[idx], | ||
jsonValue = JSON.parse(doc); | ||
const doc = args[idx]; | ||
if (def.type !== Dynamic) { | ||
const deserializer = Condensation.deserializerFor(def.type); | ||
return deserializer.read(jsonValue); | ||
return deserializer.read(deserializer.primitive ? doc : JSON.parse(doc)); | ||
} else { | ||
return jsonValue; | ||
return JSON.parse(doc); | ||
} | ||
@@ -183,0 +182,0 @@ }); |
@@ -7,2 +7,3 @@ import "reflect-metadata"; | ||
export interface Deserializer<T> { | ||
primitive: boolean; | ||
read(object: any): T; | ||
@@ -12,2 +13,3 @@ } | ||
export class StringDeserializer implements Deserializer<string> { | ||
primitive = true; | ||
read(object: any): string { | ||
@@ -19,2 +21,3 @@ return object as string; | ||
export class BooleanDeserializer implements Deserializer<boolean> { | ||
primitive = true; | ||
read(object: any): boolean { | ||
@@ -26,2 +29,3 @@ return object as boolean; | ||
export class NumberDeserializer implements Deserializer<number> { | ||
primitive = true; | ||
read(object: any): number { | ||
@@ -33,2 +37,3 @@ return object as number; | ||
export class TypeRegistrationDeserializer<T> implements Deserializer<T> { | ||
primitive = false; | ||
constructor( | ||
@@ -35,0 +40,0 @@ readonly type: Class<T>, |
import { Condensation, Context } from "@condensation/condensation"; | ||
import { Property, RootElement } from "@condensation/root-element"; | ||
import { Receive, Remotable } from "@condensation/remotable"; | ||
import {Receive, Remotable, Remote} from "@condensation/remotable"; | ||
import { allocate, Region } from "@condensation/types"; | ||
@@ -55,2 +55,48 @@ | ||
test('objects should be able to receive escaped string primitives', () => { | ||
@Remotable | ||
class RemotePerson { | ||
firstName: string | undefined; | ||
@Remote | ||
setFirstName(@Receive(String) name: string) : void { | ||
this.firstName = name; | ||
} | ||
} | ||
const value = context.create<RemotePerson>( | ||
RemotePerson | ||
); | ||
context.invoke(value, 'setFirstName', "Josiah"); | ||
expect(value.firstName).toBe("Josiah"); | ||
}); | ||
test('objects should be able to receive string primitives', () => { | ||
@Remotable | ||
class RemotePerson { | ||
firstName: string | undefined; | ||
@Remote | ||
setFirstName(@Receive(String) name: string) : void { | ||
this.firstName = name; | ||
} | ||
} | ||
const value = context.create<RemotePerson>( | ||
RemotePerson | ||
); | ||
context.invoke(value, 'setFirstName', "Josiah"); | ||
expect(value.firstName).toBe("Josiah"); | ||
}); | ||
test("objects should be invocable by their handles", () => { | ||
@@ -57,0 +103,0 @@ @RootElement |
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
65794
23
1952