@aire-ux/aire-condensation
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -11,3 +11,3 @@ import TypeRegistry from "./type-registry"; | ||
move<T>(address: Address, target: Region): Pointer<T> | null; | ||
invoke<T, U>(address: Address, op: string, ...args: string[]): U | null; | ||
invoke<T, U>(address: Address | Pointer<T>, op: string, ...args: string[]): U | null; | ||
delete<T>(address: Address): T | null; | ||
@@ -14,0 +14,0 @@ addressOf<T>(t: T): Address | null; |
@@ -39,3 +39,3 @@ var __read = (this && this.__read) || function (o, n) { | ||
import RemoteRegistry from "./remote-registry"; | ||
import { allocate, Region } from "./types"; | ||
import { allocate, isPointer, Region } from "./types"; | ||
import { BooleanDeserializer, NumberDeserializer, StringDeserializer, TypeRegistrationDeserializer, } from "./deserializer"; | ||
@@ -94,3 +94,9 @@ /** | ||
} | ||
var v = this.locate(address); | ||
var v; | ||
if (isPointer(address)) { | ||
v = address; | ||
} | ||
else { | ||
v = this.locate(address); | ||
} | ||
if (!v) { | ||
@@ -97,0 +103,0 @@ throw new Error("Null pointer exception at ".concat(address, " while trying to invoke ").concat(op)); |
@@ -24,2 +24,7 @@ /** | ||
/** | ||
* guard allowing use of pointers as addresses | ||
* @param t the value to check | ||
*/ | ||
export declare function isPointer<T>(t: Pointer<T> | Address): boolean; | ||
/** | ||
* allocate a value into a pointer | ||
@@ -26,0 +31,0 @@ * @param value the value to allocate |
@@ -20,2 +20,9 @@ /** | ||
/** | ||
* guard allowing use of pointers as addresses | ||
* @param t the value to check | ||
*/ | ||
export function isPointer(t) { | ||
return t.address !== undefined; | ||
} | ||
/** | ||
* allocate a value into a pointer | ||
@@ -22,0 +29,0 @@ * @param value the value to allocate |
{ | ||
"name": "@aire-ux/aire-condensation", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Client-side serialization library for Aire-UX", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import TypeRegistry from "@condensation/type-registry"; | ||
import RemoteRegistry, { InvocationType } from "@condensation/remote-registry"; | ||
import { Address, allocate, Class, Pointer, Region } from "@condensation/types"; | ||
import { | ||
Address, | ||
allocate, | ||
Class, | ||
isPointer, | ||
Pointer, | ||
Region, | ||
} from "@condensation/types"; | ||
import { | ||
BooleanDeserializer, | ||
@@ -11,2 +18,3 @@ Deserializer, | ||
} from "@condensation/deserializer"; | ||
import { add } from "husky"; | ||
@@ -24,3 +32,7 @@ export type Format = "json"; | ||
invoke<T, U>(address: Address, op: string, ...args: string[]): U | null; | ||
invoke<T, U>( | ||
address: Address | Pointer<T>, | ||
op: string, | ||
...args: string[] | ||
): U | null; | ||
@@ -76,4 +88,13 @@ delete<T>(address: Address): T | null; | ||
invoke<T, U>(address: Address, op: string, ...args: string[]): U | null { | ||
const v = this.locate(address) as Pointer<T>; | ||
invoke<T, U>( | ||
address: Address | Pointer<T>, | ||
op: string, | ||
...args: string[] | ||
): U | null { | ||
let v: Pointer<T>; | ||
if (isPointer(address)) { | ||
v = address as Pointer<T>; | ||
} else { | ||
v = this.locate(address as Address) as Pointer<T>; | ||
} | ||
if (!v) { | ||
@@ -80,0 +101,0 @@ throw new Error( |
@@ -39,2 +39,10 @@ /** | ||
/** | ||
* guard allowing use of pointers as addresses | ||
* @param t the value to check | ||
*/ | ||
export function isPointer<T>(t: Pointer<T> | Address) { | ||
return (t as Pointer<T>).address !== undefined; | ||
} | ||
/** | ||
* allocate a value into a pointer | ||
@@ -41,0 +49,0 @@ * @param value the value to allocate |
@@ -182,1 +182,33 @@ import { Receive, Remotable } from "@condensation/remotable"; | ||
}); | ||
test("pointers should be invocable", () => { | ||
@RootElement | ||
class Person { | ||
@Property(String) | ||
name: string | undefined; | ||
} | ||
@Remotable | ||
class MxGraphManager { | ||
person: Person | undefined; | ||
public init(@Receive(Person) person: Person): void { | ||
this.person = person; | ||
} | ||
} | ||
const ctx = Condensation.newContext(), | ||
mgr = ctx.create<MxGraphManager>(MxGraphManager); | ||
ctx.invoke( | ||
mgr, | ||
"init", | ||
` | ||
{ | ||
"name": "Josiah" | ||
} | ||
` | ||
); | ||
expect(mgr.person?.name).toBe("Josiah"); | ||
}); |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
61034
47
1720
1
74