Skip to content

Commit 41f2485

Browse files
committed
Merge branch 'dev' of https://github.com/terminusdb/terminus-client into dev
2 parents 2189f33 + 533606e commit 41f2485

File tree

10 files changed

+449
-178
lines changed

10 files changed

+449
-178
lines changed

.eslintrc

Lines changed: 0 additions & 26 deletions
This file was deleted.

dist/terminus-client.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/terminus-client.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/framePattern.js

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,3 @@
1-
/**
2-
* FramePatternMatcher does pattern matching on frames
3-
* Does a given pattern match a given frame?
4-
*/
5-
const FramePatternMatcher = {}
6-
7-
/**
8-
* Runs an array of matching rules across a frame and calls the passed onmatch function on each match
9-
* The optional onmatch function is called with each hit and is passed the frame and the rule that hit it.
10-
* A list of the matched rules is returned.
11-
*
12-
*/
13-
FramePatternMatcher.testRules = function(rules, frame, onmatch){
14-
var matched_rules = [];
15-
if(rules && rules.length){
16-
for(var i = 0; i<rules.length; i++){
17-
var match = (!rules[i].rule.pattern || FramePatternMatcher.patternMatchesFrame(rules[i].rule.pattern, frame));
18-
if(match){
19-
matched_rules.push(rules[i]);
20-
if(onmatch && typeof onmatch == "function"){
21-
onmatch(frame, rules[i]);
22-
}
23-
}
24-
}
25-
}
26-
return matched_rules;
27-
}
28-
29-
/**
30-
* Determines whether a given pattern matches a given frame
31-
*/
32-
FramePatternMatcher.patternMatchesFrame = function(pattern, frame){
33-
if(typeof pattern == "object" && pattern.length){ //multiple patterns are ANDed
34-
for(var i = 0 ; i<pattern.length; i++){
35-
var fp = new FramePattern(pattern[i]);
36-
if(!fp.checkFrame(frame)) return false;
37-
}
38-
return true;
39-
}
40-
else {
41-
var fp = new FramePattern(pattern);
42-
return fp.checkFrame(frame);
43-
}
44-
}
45-
46-
471
/**
482
* A frame pattern can have the following variables
493
* renderer : object, property, data, * - matches a specific part of the frame
@@ -61,7 +15,7 @@ FramePatternMatcher.patternMatchesFrame = function(pattern, frame){
6115
* status: updated, error, new, ok,
6216
*/
6317

64-
FramePattern = function(pattern){
18+
function FramePattern(pattern){
6519
if(pattern){
6620
this.setPattern(pattern);
6721
}
@@ -301,6 +255,57 @@ FramePattern.prototype.getRendererType = function(frame){
301255
return false;
302256
}
303257

258+
259+
260+
261+
262+
/**
263+
* FramePatternMatcher does pattern matching on frames
264+
* Does a given pattern match a given frame?
265+
*/
266+
const FramePatternMatcher = {}
267+
268+
/**
269+
* Runs an array of matching rules across a frame and calls the passed onmatch function on each match
270+
* The optional onmatch function is called with each hit and is passed the frame and the rule that hit it.
271+
* A list of the matched rules is returned.
272+
*
273+
*/
274+
FramePatternMatcher.testRules = function(rules, frame, onmatch){
275+
var matched_rules = [];
276+
if(rules && rules.length){
277+
for(var i = 0; i<rules.length; i++){
278+
var match = (!rules[i].rule.pattern || FramePatternMatcher.patternMatchesFrame(rules[i].rule.pattern, frame));
279+
if(match){
280+
matched_rules.push(rules[i]);
281+
if(onmatch && typeof onmatch == "function"){
282+
onmatch(frame, rules[i]);
283+
}
284+
}
285+
}
286+
}
287+
return matched_rules;
288+
}
289+
290+
/**
291+
* Determines whether a given pattern matches a given frame
292+
*/
293+
FramePatternMatcher.patternMatchesFrame = function(pattern, frame){
294+
if(typeof pattern == "object" && pattern.length){ //multiple patterns are ANDed
295+
for(var i = 0 ; i<pattern.length; i++){
296+
var fp = new FramePattern(pattern[i]);
297+
if(!fp.checkFrame(frame)) return false;
298+
}
299+
return true;
300+
}
301+
else {
302+
var fp = new FramePattern(pattern);
303+
return fp.checkFrame(frame);
304+
}
305+
}
306+
307+
308+
304309
function FrameRule(){
305310
this.rule = { pattern: {} };
306311
return this;

0 commit comments

Comments
 (0)