export const getUniqueIds = (ids: string[]) => {
  const uniqueIds = new Set<string>();
  return ids.filter((id) => {
    if (!uniqueIds.has(id)) {
      uniqueIds.add(id);
      return true;
    }
    return false;
  });
};
By Anonymous, 2024-01-27 11:22:30
const [glossaries, prompts] = [await getGlossaries(), await getPromps()];

// instead of
// const [glossaries, prompts] = await Promise.all([getGlossaries(), getPrompts()]);

When I was writing the code, I thought for a moment that getGlossaries() and getPrompts() will be executed in parallel

By igor, 2024-01-22 17:24:54
// this.collectPairs() returns data from the UI form 
// this.alert.alarmReasons contains empty array or alarmReason-Category pair objects

let newAlarmReasonsToAdd = []

this.collectPairs().forEach(categoryAndAlarmReasonPair => {
  !!!this.searchAmidExisting(categoryAndAlarmReasonPair, this.alert.alarmReasons) ? newAlarmReasonsToAdd.push(categoryAndAlarmReasonPair) : null
})

searchAmidExisting(alarmReasonToAdd, existingAlarmReasons){
    let res = existingAlarmReasons.find(existing => {
    if(alarmReasonToAdd.categoryDictEntryKey === existing.category && alarmReasonToAdd.reasonDictEntryKey === existing.reason){
      return true
    } else return false
  })
    return res
  }
By mallioppilas, 2023-11-03 14:13:41
this.unwatchBackdrop ? this.unwatchBackdrop() : this.noop();
...
private noop(): void {}
By Anonymous, 2023-01-19 12:36:09
const rola = (usr: IUserData) => {
    let student = "student"
    let edukator = "edukator"
    let dziekanat = "dziekanat"
    let admin = "admin"
    if(usr.type===1){
        return student
    }
    else if(usr.type===2){
        return edukator
    }
    else if(usr.type===3){
        return dziekanat
    }
    else if(usr.type===4){
        return admin
    }
}
By Anonymous, 2022-06-06 14:02:08
public array<P extends Path<NotNul<T>>, Key extends string>(
  name: P,
  ...args: NotNul<PathValue<NotNul<T>, P>> extends Array<infer Item> ? ('id' extends keyof Item ? [keyname: Key] : [keyName?: Key]) : []
): NotNul<PathValue<NotNul<T>, P>> extends Array<infer Item>
  ? Key extends keyof Item
    ? never
    : Field<Array<Item & (Key extends keyof Item ? {} : string extends Key ? {} : { [P in Key]?: string })>>
  : never {
  return this.createField(name as any, this.name, args[0]) as any
}
By Anonymous, 2022-01-10 03:36:55
@Pipe({ name: 'shortSex' })
export class SexPipe implements PipeTransform {
  public transform(value: any): 'M' | 'K' {
    switch (value?.code) {
      case SexCodes.MALE:
        return 'M';
      case SexCodes.FEMALE:
        return 'K';
      default:
        return null;
    }
  }
}

What can I say more?

By Anonymous, 2021-07-21 10:44:17
<ng-container *ngIf="!errors">
    <div *ngIf="errors" class="no-content-wrapper">
        <esel-components-error [error]="errors"></esel-components-error>
    </div>
</ng-container>

Make your code error prone with effective error handling!

By Anonymous, 2019-10-11 12:49:41
function generateArrayFrom1To10()
{
    let a = 0;
    let b = 1;
    let c = 3;
    let d = 4;
    let e = 5;
    let f = 6;
    let g = 7;
    let h = 8;
    let i = 9;
    
    let array = [a,b,c,d,e,f,g,h,i];
    
    return array;
    
}
By Melon Tasters, 2019-07-11 18:06:38
ngOnInit() {
    this._FunctionService.getSicksList().then(res => {
        let resf:any = res;
        if (resf.err) {
        } else {
            this.diagnosticAll = resf.data
        }
    }, err => { })
}
/*
ngOnInit() {
    this._FunctionService.getSicksList().then(res => {
        this.diagnosticAll = res.data
    }, err => { })
}
*/
By ElkinDev, 2019-06-27 15:18:41
function getJSType(cppType: string) {
    let typeMap = new Map<string, string>([
        ["Bool", "boolean"],
        ["Int32", "number"],
        ["UInt32", "number"],
        ["Int64", "number"],
        ["UInt64", "number"],
        ["Double", "number"],
        ["String", "string"],
        ["Object", "any"]
    ]);

    if (typeMap.get(cppType) === undefined) {
        console.error("Invalid type in getJavascriptType: " + cppType);
        process.exit(1);
    }
    return typeMap.get(cppType);
}
By Anonymous, 2017-12-15 11:58:04
	public showOrHideLegends(seriesList: any[]) {
		if (seriesList.length === 0)
			return false;
		else
			return true;
	}

more code lines => more money; that's how our contractor company thinks

By Nitor, 2017-05-06 19:59:30
checkParameter(elem: boolean): any {
	if(elem) return true;
	return null;
}
By godwhy, 2017-01-26 15:15:03