aboutsummaryrefslogtreecommitdiff
path: root/src/matcher/options.ts
diff options
context:
space:
mode:
authorcjd242018-04-19 20:48:19 +0100
committercjd242018-04-19 20:48:19 +0100
commit92e23d37f843e49eda01a4d0ea7ed8005efffdb2 (patch)
tree7c08678dfce9bf82eaa4f71f5e23182f8515d386 /src/matcher/options.ts
parentAdded a write of the base teir JSON object, made the images actually write to... (diff)
parentMerge branch 'trh/gets' into cjd24/conversion (diff)
downloadmedicine-92e23d37f843e49eda01a4d0ea7ed8005efffdb2.tar.gz
medicine-92e23d37f843e49eda01a4d0ea7ed8005efffdb2.zip

Merge branch ‘cjd24/conversion’ of https://gitlab.cs.st-andrews.ac.uk/cs3099group-be-4/project-code into cjd24/conversion

Diffstat (limited to 'src/matcher/options.ts')
-rw-r--r--src/matcher/options.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/matcher/options.ts b/src/matcher/options.ts
index 62e4985..967a6f9 100644
--- a/src/matcher/options.ts
+++ b/src/matcher/options.ts
@@ -15,13 +15,20 @@ export type Value =
const matchNoCurry:
(template: TemplateValue, value: Value | undefined) => boolean =
(template: TemplateValue, value: Value | undefined): boolean => {
+ console.log("matchNoCurry()")
+ console.log(template)
+ console.log(value)
if (types.atom(template)) {
+ console.log("atom")
return template === value;
} else if (types.function(template)) {
+ console.log("function")
return template(value);
} else if (types.atom(value) || value === undefined) {
+ console.log("atom2")
return false;
} else if (types.object(template)) {
+ console.log("object")
return Object.keys(template)
.every((key: string): boolean => {
const v: Value | undefined = value[key];
@@ -34,7 +41,11 @@ const matchNoCurry:
// tslint:disable-next-line:typedef
export const match = (template: TemplateValue, value?: Value) => {
+ console.log("match()")
+ console.log(template)
+ console.log(value)
if (value === undefined) {
+ console.log("is undefined")
return matchNoCurry.bind(null, template);
}
return matchNoCurry(template, value);
@@ -85,7 +96,7 @@ export const array = (template: TemplateValue, values?: Value[]) => {
const m: Checker = types.function(template)
? template
: match.bind(null, template);
- return values.every(m);
+ return values.every(m); //
};
// tslint:disable-next-line:typedef