-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Omondi
committed
Mar 20, 2024
1 parent
b0ac754
commit 47be78f
Showing
7 changed files
with
120 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
import { UntypedNode } from "./untypedNode"; | ||
|
||
/** Defines an interface for defining an untyped boolean. */ | ||
export interface UntypedBoolean extends UntypedNode { | ||
/** | ||
* Gets the value of the UntypedNode as a boolean value. | ||
*/ | ||
getValue(): boolean; | ||
} | ||
|
||
/** | ||
* Type guard to assert that an UntypedNode instance is an UntypedBoolean. | ||
* @param node The UntypedNode to check. | ||
* @return boolean indicating if the node is an UntypedBoolean. | ||
*/ | ||
export function isUntypedBoolean(node: UntypedNode): node is UntypedBoolean { | ||
const proposedNode = node as UntypedBoolean; | ||
return proposedNode && typeof proposedNode.value === "boolean"; | ||
} | ||
|
||
/** | ||
* Factory to create an UntypedBoolean from a boolean. | ||
* @param value The boolean value to create from. | ||
* @return The created UntypedBoolean. | ||
*/ | ||
export function createUntypedBoolean(value: boolean): UntypedBoolean { | ||
return { | ||
value: value, | ||
getValue: () => value as boolean, | ||
getValue: () => value as boolean, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
import { UntypedNode } from "./untypedNode"; | ||
|
||
/** Defines the interface for defining an untyped null value. */ | ||
export interface UntypedNull extends UntypedNode { | ||
/** | ||
* Gets the value of the UntypedNode as null. | ||
*/ | ||
getValue(): null; | ||
} | ||
|
||
/** | ||
* Type guard to assert that an object instance is an UntypedNull. | ||
* @param node The object to check. | ||
* @return boolean indicating if the node is an UntypedNull. | ||
*/ | ||
export function isUntypedNull(node: UntypedNode): node is UntypedNull { | ||
return node.value === null; | ||
} | ||
|
||
/** | ||
* Factory to create an UntypedNull from a boolean. | ||
* @return The created UntypedNull. | ||
*/ | ||
export function createUntypedNull(): UntypedNull { | ||
return { | ||
value: null, | ||
getValue: () => null, | ||
getValue: () => null, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
import { UntypedNode } from "./untypedNode"; | ||
|
||
/** Defines the interface for defining an untyped number value. */ | ||
export interface UntypedNumber extends UntypedNode { | ||
/** | ||
* Gets the value of the UntypedNode as a number. | ||
*/ | ||
getValue(): number; | ||
} | ||
|
||
/** | ||
* Type guard to assert that an object instance is an UntypedNumber. | ||
* @param node The object to check. | ||
* @return boolean indicating if the node is an UntypedNumber. | ||
*/ | ||
export function isUntypedNumber(node: UntypedNode): node is UntypedNumber { | ||
const proposedNode = node as UntypedNumber; | ||
return proposedNode && typeof proposedNode.value === "number"; | ||
} | ||
|
||
/** | ||
* Factory to create an UntypedNumber from a number. | ||
* @param value The number value to create from. | ||
* @return The created UntypedNumber. | ||
*/ | ||
export function createUntypedNumber(value: number): UntypedNumber { | ||
return { | ||
value: value, | ||
getValue: () => value as number, | ||
getValue: () => value as number, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
import { UntypedNode } from "./untypedNode"; | ||
|
||
/** Defines the interface for defining an untyped string value. */ | ||
export interface UntypedString extends UntypedNode { | ||
/** | ||
* Gets the value of the UntypedNode as a Record<string, UntypedNode>. | ||
*/ | ||
getValue(): string; | ||
} | ||
|
||
/** | ||
* Type guard to assert that an object instance is an UntypedString. | ||
* @param node The object to check. | ||
* @return boolean indicating if the node is an UntypedString. | ||
*/ | ||
export function isUntypedString(node: UntypedNode): node is UntypedString { | ||
const proposedNode = node as UntypedString; | ||
return proposedNode && typeof proposedNode.value === "string"; | ||
} | ||
|
||
/** | ||
* Factory to create an UntypedString from a string. | ||
* @param value The string value to create from. | ||
* @return The created UntypedString. | ||
*/ | ||
export function createUntypedString(value: string): UntypedString { | ||
return { | ||
value: value, | ||
getValue: () => value as string, | ||
getValue: () => value as string, | ||
}; | ||
} | ||
} |