clarity-pattern-parser
Advanced tools
Comparing version 3.0.8 to 3.0.9
@@ -1435,9 +1435,4 @@ (function (global, factory) { | ||
let options = (_d = this.rootPattern) === null || _d === void 0 ? void 0 : _d.getTokens(); | ||
const parts = this.text.split(" ").filter((part) => { | ||
return part.length > 0; | ||
}); | ||
options = options === null || options === void 0 ? void 0 : options.filter((option) => { | ||
return parts.some((part) => { | ||
return option.indexOf(part) > -1; | ||
}); | ||
return option.indexOf(this.text) > -1; | ||
}); | ||
@@ -1448,6 +1443,17 @@ if ((options === null || options === void 0 ? void 0 : options.length) === 0) { | ||
} | ||
const values = options === null || options === void 0 ? void 0 : options.map((option) => { | ||
const parts = option.split(this.text); | ||
return parts[1]; | ||
}); | ||
this.tokens = { | ||
startIndex: 0, | ||
values: options || [], | ||
values: values || [], | ||
}; | ||
this.matchedText = this.text; | ||
this.match = { | ||
text: this.text, | ||
startIndex: 0, | ||
endIndex: this.text.length - 1, | ||
}; | ||
this.error = null; | ||
return; | ||
@@ -1454,0 +1460,0 @@ } |
@@ -1429,9 +1429,4 @@ class Node { | ||
let options = (_d = this.rootPattern) === null || _d === void 0 ? void 0 : _d.getTokens(); | ||
const parts = this.text.split(" ").filter((part) => { | ||
return part.length > 0; | ||
}); | ||
options = options === null || options === void 0 ? void 0 : options.filter((option) => { | ||
return parts.some((part) => { | ||
return option.indexOf(part) > -1; | ||
}); | ||
return option.indexOf(this.text) > -1; | ||
}); | ||
@@ -1442,6 +1437,17 @@ if ((options === null || options === void 0 ? void 0 : options.length) === 0) { | ||
} | ||
const values = options === null || options === void 0 ? void 0 : options.map((option) => { | ||
const parts = option.split(this.text); | ||
return parts[1]; | ||
}); | ||
this.tokens = { | ||
startIndex: 0, | ||
values: options || [], | ||
values: values || [], | ||
}; | ||
this.matchedText = this.text; | ||
this.match = { | ||
text: this.text, | ||
startIndex: 0, | ||
endIndex: this.text.length - 1, | ||
}; | ||
this.error = null; | ||
return; | ||
@@ -1448,0 +1454,0 @@ } |
@@ -1433,9 +1433,4 @@ 'use strict'; | ||
let options = (_d = this.rootPattern) === null || _d === void 0 ? void 0 : _d.getTokens(); | ||
const parts = this.text.split(" ").filter((part) => { | ||
return part.length > 0; | ||
}); | ||
options = options === null || options === void 0 ? void 0 : options.filter((option) => { | ||
return parts.some((part) => { | ||
return option.indexOf(part) > -1; | ||
}); | ||
return option.indexOf(this.text) > -1; | ||
}); | ||
@@ -1446,6 +1441,17 @@ if ((options === null || options === void 0 ? void 0 : options.length) === 0) { | ||
} | ||
const values = options === null || options === void 0 ? void 0 : options.map((option) => { | ||
const parts = option.split(this.text); | ||
return parts[1]; | ||
}); | ||
this.tokens = { | ||
startIndex: 0, | ||
values: options || [], | ||
values: values || [], | ||
}; | ||
this.matchedText = this.text; | ||
this.match = { | ||
text: this.text, | ||
startIndex: 0, | ||
endIndex: this.text.length - 1, | ||
}; | ||
this.error = null; | ||
return; | ||
@@ -1452,0 +1458,0 @@ } |
{ | ||
"name": "clarity-pattern-parser", | ||
"version": "3.0.8", | ||
"version": "3.0.9", | ||
"description": "Parsing Library for Typescript and Javascript.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -16,2 +16,3 @@ import RecursivePattern from "../../patterns/RecursivePattern"; | ||
import boolean from "./boolean"; | ||
import Cursor from "../../Cursor"; | ||
@@ -18,0 +19,0 @@ const openCurlyBracket = new Literal("open-curly-bracket", "{"); |
@@ -83,2 +83,17 @@ /** @jest-environment node */ | ||
test("Partial Half Match On First Token", () => { | ||
const text = "Pa"; | ||
const textInspector = new TextSuggester(); | ||
const inspection = textInspector.suggest(text, sentence); | ||
expect(inspection.match?.startIndex).toBe(0); | ||
expect(inspection.match?.endIndex).toBe(1); | ||
expect(inspection.match?.text).toBe("Pa"); | ||
expect(inspection.options.values.length).toBe(1); | ||
expect(inspection.options.values[0]).toBe("t"); | ||
expect(inspection.isComplete).toBe(false); | ||
expect(inspection.error).toBe(null); | ||
}); | ||
test("Empty String", () => { | ||
@@ -85,0 +100,0 @@ const text = ""; |
@@ -185,10 +185,5 @@ import Node from "./ast/Node"; | ||
let options = this.rootPattern?.getTokens(); | ||
const parts = this.text.split(" ").filter((part: any) => { | ||
return part.length > 0; | ||
}); | ||
options = options?.filter((option: any) => { | ||
return parts.some((part: any) => { | ||
return option.indexOf(part) > -1; | ||
}); | ||
return option.indexOf(this.text) > -1; | ||
}); | ||
@@ -201,7 +196,20 @@ | ||
const values = options?.map((option) => { | ||
const parts = option.split(this.text); | ||
return parts[1]; | ||
}); | ||
this.tokens = { | ||
startIndex: 0, | ||
values: options || [], | ||
values: values || [], | ||
}; | ||
this.matchedText = this.text; | ||
this.match = { | ||
text: this.text, | ||
startIndex: 0, | ||
endIndex: this.text.length - 1, | ||
}; | ||
this.error = null; | ||
return; | ||
@@ -208,0 +216,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
816330
164
12265