ramda#equals TypeScript Examples

The following examples show how to use ramda#equals. 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: validate.ts    From reskript with MIT License 6 votes vote down vote up
checkFeatureMatrixSchema = (features: FeatureMatrix): void => {
    const featurePairs = Object.entries(features);
    // 计算每一个feature的结构是不是一样,如果有结构不一样的,则直接报错退出
    const baseSchema = getSchema(featurePairs[0][1]);
    const conflicts = featurePairs.slice(1).reduce(
        (errors, [key, value]) => {
            const currentSchema = getSchema(value);

            if (!equals(baseSchema, currentSchema)) {
                return [...errors, key];
            }

            return errors;
        },
        [] as string[]
    );

    if (conflicts.length > 0) {
        logger.error(`Build target ${conflicts.join(' & ')} have incompatible feature schema`);
        process.exit(21);
    }
}
Example #2
Source File: tenant.controller.ts    From radiopanel with GNU General Public License v3.0 6 votes vote down vote up
@Patch('/:tenantUuid')
	@Permissions('settings/update')
	@AuditLog('settings/update')
	@ApiOkResponse({ type: Tenant })
	public async patch(@Body() updatedTenant: any): Promise<Tenant> {
		const existingTenant = await this.tenantService.findOne();

		return this.tenantService.update(existingTenant.uuid, omit(['users', 'features'])({
			...existingTenant,
			...updatedTenant,
			settings: {
				...existingTenant.settings,
				...reject(equals('hidden'))({
					...updatedTenant.settings,
					something: "hidden"
				})
			},
			updatedAt: new Date(),
		}) as any);
	}
Example #3
Source File: proxy.ts    From the-fake-backend with ISC License 6 votes vote down vote up
/**
   * Get the routes with overridden proxy.
   *
   * @return Overridden proxy routes
   */
  getOverriddenProxyRoutes() {
    const current = this.getCurrent();

    return this.routeManager
      .getAll()
      .filter(
        both(
          propSatisfies(complement(equals(undefined)), 'proxy'),
          pathSatisfies(complement(equals(current?.name)), ['proxy', 'name'])
        )
      );
  }
Example #4
Source File: L5-typecheck.ts    From interpreters with MIT License 5 votes vote down vote up
checkEqualType = (te1: TExp, te2: TExp, exp: Exp): Result<true> =>
  equals(te1, te2) ? makeOk(true) :
  bind(unparseTExp(te1), (te1: string) =>
    bind(unparseTExp(te2), (te2: string) =>
        bind(unparse(exp), (exp: string) => 
            makeFailure<true>(`Incompatible types: ${te1} and ${te2} in ${exp}`))))
Example #5
Source File: useBookmark.ts    From back-home-safe with GNU General Public License v3.0 5 votes vote down vote up
[UseBookmarkLocationProvider, useBookmarkLocation] = constate(
  () => {
    const { currentTime } = useTime();
    const {
      value: { savedLocations },
      setValue,
    } = useData();

    const removeBookmarkLocation = useCallback(
      (id: string) => {
        setValue((prev) => ({
          ...prev,
          savedLocations: reject(
            ({ id: itemId }) => itemId === id,
            prev.savedLocations
          ),
        }));
      },
      [setValue]
    );

    const createBookmarkLocation = useCallback(
      (record: Omit<SavedLocation, "createdAt">) => {
        setValue((prev) => ({
          ...prev,
          savedLocations: [
            {
              ...trimData(record),
              createdAt: currentTime.toISOString(),
              id: uuid(),
            },
            ...prev.savedLocations,
          ],
        }));
      },
      [setValue, currentTime]
    );

    const getBookmarkLocationId = useCallback(
      (record: Omit<SavedLocation, "createdAt">) => {
        const trimmedData = trimData(record);

        const result = find((item) => {
          const trimmedItem = trimData(item);
          return equals(trimmedData, trimmedItem);
        }, savedLocations);

        if (!result) return null;

        return result.id;
      },
      [savedLocations]
    );

    return {
      bookmarkLocation: savedLocations,
      removeBookmarkLocation,
      createBookmarkLocation,
      getBookmarkLocationId,
    };
  }
)
Example #6
Source File: useNextQuestion.tsx    From nosgestesclimat-site with MIT License 5 votes vote down vote up
questionDifference = (rule1 = '', rule2 = '') =>
	1 /
	(1 +
		pipe(
			zipWith(equals),
			takeWhile(Boolean),
			length
		)(rule1.split(' . '), rule2.split(' . ')))
Example #7
Source File: overrides.ts    From the-fake-backend with ISC License 5 votes vote down vote up
function findSelectedMethodOverride(method: Method) {
  return method.overrides?.find(propSatisfies(equals(true), 'selected'));
}