aboutsummaryrefslogtreecommitdiff
path: root/src/matcher
diff options
context:
space:
mode:
authorjw2552018-04-19 16:35:01 +0100
committerjw2552018-04-19 16:35:01 +0100
commit29d4c4ba25828fb26d2d8ce8f3bfb5ecc7da7b57 (patch)
tree54f1a49adcad01a8c960e4fe22d97b9b633ef5b9 /src/matcher
parentReverting the ExtractAndStitchChunks to use Bufferbased method instead of VIPS (diff)
parentAdd CORS support (diff)
downloadmedicine-29d4c4ba25828fb26d2d8ce8f3bfb5ecc7da7b57.tar.gz
medicine-29d4c4ba25828fb26d2d8ce8f3bfb5ecc7da7b57.zip

Merge branch ‘trh/gets’ into cjd24/conversion

Diffstat (limited to 'src/matcher')
-rw-r--r--src/matcher/index.ts1
-rw-r--r--src/matcher/options.ts13
2 files changed, 13 insertions, 1 deletions
diff --git a/src/matcher/index.ts b/src/matcher/index.ts
index 99cc18c..0806907 100644
--- a/src/matcher/index.ts
+++ b/src/matcher/index.ts
@@ -10,6 +10,7 @@ export {
export {
Atom,
+ isPresent as anything,
isNumber as number,
isString as string,
isBoolean as boolean,
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