fix: minor fixes

This commit is contained in:
Daniel Ledda
2022-05-28 19:41:32 +02:00
parent 875fa7e5da
commit 201a4b8c70
3 changed files with 5 additions and 5 deletions

View File

@@ -13,7 +13,7 @@ export interface ICapsule<T extends Captable = Captable> {
}
export function isCapsule(maybeCapsule: any): maybeCapsule is ICapsule {
return typeof maybeCapsule.val !== "undefined"
return maybeCapsule && typeof maybeCapsule.val !== "undefined"
&& typeof maybeCapsule.watch === "function"
&& typeof maybeCapsule.toString === "function";
}
@@ -42,8 +42,8 @@ export default class Capsule<T extends Captable = Captable> implements ICapsule
this.isString = typeof val === "string";
}
static new<T extends Captable>(val: T | Capsule<T>): Capsule<T> {
if (val instanceof Capsule) {
static new<T extends Captable>(val: T | ICapsule<T>): ICapsule<T> {
if (isCapsule(val)) {
return val;
} else {
return new Capsule<T>(val);

View File

@@ -1,4 +1,4 @@
import ISubscriber, {LEvent} from "./Subscriber";
import { ISubscriber, LEvent } from "./Subscriber";
class PublisherSubscription<EventType extends LEvent> implements ISubscription {
private subscriber: ISubscriber<EventType>;

View File

@@ -1,6 +1,6 @@
{
"name": "@djledda/ladder",
"version": "1.0.1",
"version": "1.0.2",
"description": "other libraries provide you with a whole framework - this is just a ladder",
"author": "Daniel Ledda <dan.j.ledda@gmail.com>",
"license": "MIT",