Compare commits

..

2 Commits

Author SHA1 Message Date
ccd5b80d67 4.0.17 2020-07-14 10:55:49 +00:00
298904e17e fix(core): update 2020-07-14 10:55:48 +00:00
4 changed files with 13 additions and 7 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/lik",
"version": "4.0.16",
"version": "4.0.17",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/lik",
"version": "4.0.16",
"version": "4.0.17",
"private": false,
"description": "light little helpers for node",
"main": "dist_ts/index.js",

View File

@ -2,12 +2,13 @@ import * as plugins from './lik.plugins';
import { InterestMap, IInterestComparisonFunc } from './lik.interestmap';
export interface IInterestOptions {
export interface IInterestOptions<DTInterestFullfillment> {
markLostAfterDefault: number;
defaultFullfillment?: DTInterestFullfillment;
}
export class Interest<DTInterestId, DTInterestFullfillment> {
public options: IInterestOptions;
public options: IInterestOptions<DTInterestFullfillment>;
private interestMapRef: InterestMap<DTInterestId, DTInterestFullfillment>;
public originalInterest: DTInterestId;
@ -48,7 +49,7 @@ export class Interest<DTInterestId, DTInterestFullfillment> {
interestMapArg: InterestMap<DTInterestId, DTInterestFullfillment>,
interestArg: DTInterestId,
comparisonFuncArg: IInterestComparisonFunc<DTInterestId>,
optionsArg?: IInterestOptions
optionsArg?: IInterestOptions<DTInterestFullfillment>
) {
this.interestMapRef = interestMapArg;
this.originalInterest = interestArg;
@ -72,6 +73,9 @@ export class Interest<DTInterestId, DTInterestFullfillment> {
*/
public destroy() {
this.interestMapRef.removeInterest(this);
if (!this.isFullfilled && this.options.defaultFullfillment) {
this.fullfillInterest(this.options.defaultFullfillment);
}
}
/**

View File

@ -34,7 +34,8 @@ export class InterestMap<DTInterestId, DTInterestFullfillment> {
* @param objectArg
*/
public async addInterest(
objectArg: DTInterestId
objectArg: DTInterestId,
defaultFullfillmentArg?: DTInterestFullfillment
): Promise<Interest<DTInterestId, DTInterestFullfillment>> {
const comparisonString = this.comparisonFunc(objectArg);
let returnInterest: Interest<DTInterestId, DTInterestFullfillment>;
@ -43,7 +44,8 @@ export class InterestMap<DTInterestId, DTInterestFullfillment> {
objectArg,
this.comparisonFunc,
{
markLostAfterDefault: this.options.markLostAfterDefault
markLostAfterDefault: this.options.markLostAfterDefault,
defaultFullfillment: defaultFullfillmentArg
}
);
let interestExists = false;