ramda#has TypeScript Examples

The following examples show how to use ramda#has. 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: useMigration.ts    From back-home-safe with GNU General Public License v3.0 6 votes vote down vote up
useMigration = () => {
  const [, , removePasswordHash] = useLocalStorage<string | null>(
    "password_hash",
    null
  );

  useEffect(() => {
    // Old version store password with SHA256, which can be brute-forced
    removePasswordHash();
  }, [removePasswordHash]);

  const { unlocked, setValue } = useData();

  // Old versions travel records has no unique id
  useEffect(() => {
    setValue((prev) => ({
      ...prev,
      travelRecords: prev.travelRecords.map((item) => {
        if (has("id", item)) return item;
        return { ...(item as TravelRecord), id: uuid() };
      }),
    }));
  }, [unlocked, setValue]);
}
Example #2
Source File: index.ts    From nouns-monorepo with GNU General Public License v3.0 6 votes vote down vote up
invalidBodyCheck = (body: string | undefined | null): false | ErrorReason => {
  if (!body || body.length === 0)
    return {
      error: 'empty_body',
      message: 'Request body is missing or empty',
    };
  if (!has('msg')) return errorBuilder('missing_msg', 'Request is missing msg');
  if (!has('sig')) return errorBuilder('missing_sig', 'Request is missing signature');
  if (!has('signer')) return errorBuilder('missing_signer', 'Request is missing signer');
  return false;
}