How to use fuzzy.test:
GitHub: EMIIA/www.emiia.ru
5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082
// Return all elements of `array` that have a fuzzy // match against `pattern`. fuzzy.simpleFilter = function(pattern, array) { return array.filter(function(string) { return fuzzy.test(pattern, string); }); }; // Does `pattern` fuzzy match `string`?
How to use fuzzy.match:
GitHub: EMIIA/www.emiia.ru
5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088
}); }; // Does `pattern` fuzzy match `string`? fuzzy.test = function(pattern, string) { return fuzzy.match(pattern, string) !== null; }; // If `pattern` matches `string`, wrap each matching character // in `opts.pre` and `opts.post`. If no match, return null
How to use fuzzy.filter:
359 360 361 362 363 364 365 366 367 368
let split = path.normalize(file).split(path.sep).slice(0, 2); let mockupPath = split.join('/'); let errorMsg = 'Invalid link in JSON at property /' + this.path.join('/') + ' with value ' + this.node + '. No such file exists in mockup at path.'; let invalidPath = this.node.replace('/redfish/v1/', mockupPath).split('/'); let files = Object.keys(linkToFile); let possible = fuzzy.filter(path.join(...invalidPath), files).map(x => path2Redfish(x.string, true)); if(possible.length) { errorMsg += `\nPerhaps you meant one of:\n${possible.join('\n')}`; } assert.fail(errorMsg);
28
66
45
See more examples