lodash#matches TypeScript Examples

The following examples show how to use lodash#matches. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: corner-cell.ts    From S2 with MIT License 6 votes vote down vote up
protected getIconPosition(): Point {
    const textCfg = this.textShapes?.[0]?.cfg.attrs;
    const { textBaseline, textAlign } = this.getTextStyle();
    const { size, margin } = this.getStyle().icon;

    const iconX =
      textCfg?.x +
      cond([
        [matches('center'), constant(this.actualTextWidth / 2)],
        [matches('right'), constant(0)],
        [stubTrue, constant(this.actualTextWidth)],
      ])(textAlign) +
      margin.left;

    const iconY = getVerticalPosition(
      this.getContentArea(),
      textBaseline,
      size,
    );

    return { x: iconX, y: iconY };
  }
Example #2
Source File: custom-matchers.ts    From js-client with MIT License 6 votes vote down vote up
myCustomMatchers: jasmine.CustomMatcherFactories = {
	toPartiallyEqual: () => ({
		compare: (actual: any, expected: any) => {
			const pass = matches(expected)(actual);
			const result: jasmine.CustomMatcherResult = { pass };

			if (pass == false) {
				const serialize = (v: any): string => JSON.stringify(v, null, '  ');
				result.message = `Expected:\n${serialize(actual)}\n\nTo partially equal:\n${serialize(expected)}`;
			}

			return result;
		},
	}),
}
Example #3
Source File: keep-data-range-test.spec.ts    From js-client with MIT License 5 votes vote down vote up
expectStatsFilter = async (stats$: Observable<SearchStats>, filter: SearchFilter): Promise<void> => {
	const matchesFilter = matches(filter);
	const statsP = firstValueFrom(stats$.pipe(skipWhile(x => matchesFilter(x.filter) === false)));

	await expectAsync(statsP)
		.withContext(`Expecting the filter to be ${JSON.stringify(filter)}`)
		.toBeResolved();
}