fix(core): update

This commit is contained in:
2021-10-03 17:37:03 +02:00
parent de87e314c0
commit d4cea26fb5
15 changed files with 194 additions and 130 deletions

View File

@ -54,7 +54,7 @@ export class ArticleSearch {
weight: 1,
},
],
includeMatches: true
includeMatches: true,
});
this.readyDeferred.resolve();
} else {

View File

@ -3,7 +3,6 @@ import * as plugins from './smartfuzzy.plugins';
export class ObjectSorter<T> {
public objectDictionary: T[];
constructor(objectDictionaryArg: T[] = []) {
this.objectDictionary = objectDictionaryArg;
}
@ -16,11 +15,10 @@ export class ObjectSorter<T> {
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: objectKeysArg
keys: objectKeysArg,
};
const fuse = new plugins.fuseJs<T>(this.objectDictionary, fuseOptions);
const result = fuse.search(stringArg);
return result;
}
}
}

View File

@ -38,7 +38,7 @@ export class Smartfuzzy {
const fuseDictionary: { name: string }[] = [];
for (const wordArg of this.dictionary) {
fuseDictionary.push({
name: wordArg
name: wordArg,
});
}
const fuseOptions = {
@ -48,13 +48,13 @@ export class Smartfuzzy {
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: ['name']
keys: ['name'],
};
const fuse = new plugins.fuseJs(fuseDictionary, fuseOptions);
const fuzzyResult = fuse.search(stringArg);
let closestMatch: string = null;
if(fuzzyResult.length > 0) {
closestMatch = fuzzyResult[0].item.name
if (fuzzyResult.length > 0) {
closestMatch = fuzzyResult[0].item.name;
}
return closestMatch;
}

View File

@ -1,16 +1,12 @@
// @pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
export {
smartpromise
}
export { smartpromise };
// @tsclass scope
import * as tsclass from '@tsclass/tsclass';
export {
tsclass
}
export { tsclass };
// third party scope
import leven from 'leven';