lodash#join TypeScript Examples

The following examples show how to use lodash#join. 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: utils.ts    From yforms with MIT License 7 votes vote down vote up
searchSelect = {
  allowClear: true,
  showSearch: true,
  optionFilterProp: 'children',
  filterOption: (input: string, option: any) => {
    const getValue = (dom: React.ReactNode): string => {
      const _value = get(dom, 'props.children');
      if (Array.isArray(_value)) {
        const d = map(_value, (item) => {
          if (isValidElement(item)) {
            return getValue(item);
          }
          return item;
        });
        return join(d, '');
      }
      if (isValidElement(_value)) {
        return getValue(_value);
      }
      return join(_value, '');
    };

    const str = getValue(option);
    return str.toLowerCase().indexOf(input.toLowerCase()) >= 0;
  },
}
Example #2
Source File: mnemonic.ts    From nautilus-wallet with MIT License 6 votes vote down vote up
function validator(words: []) {
  if (isEmpty(words)) {
    return false;
  }

  try {
    return validateMnemonic(join(words, " "));
  } catch (e) {
    return false;
  }
}
Example #3
Source File: error.abstract.ts    From relate with GNU General Public License v3.0 6 votes vote down vote up
constructor(message: string, actions: string[] = []) {
        super(
            /* eslint-disable indent */
            arrayHasItems(actions)
                ? `${message}.\n\nSuggested Action(s):\n${join(
                      map(actions, (action) => `- ${action}`),
                      '\n',
                  )}`
                : message,
            /* eslint-enable indent */
        );
    }
Example #4
Source File: validation-failure.error.ts    From relate with GNU General Public License v3.0 6 votes vote down vote up
constructor(message: string, errors: ValidationError[] = []) {
        super(
            `${message}:\n\n${join(
                map(
                    errors,
                    ({property, constraints}) =>
                        `- Property "${property}" failed the following constraints: ${join(values(constraints), ', ')}`,
                ),
                '\n',
            )}`,
        );
    }
Example #5
Source File: read-properties-file.ts    From relate with GNU General Public License v3.0 6 votes vote down vote up
export async function readPropertiesFile(path: string): Promise<PropertyEntries> {
    const conf = await readFile(path, 'utf8');
    const lines = map(split(conf, NEW_LINE), trim);

    return map(lines, (line): [string, string] => {
        const [key, ...rest] = split(line, PROPERTIES_SEPARATOR);

        return [key, join(rest, PROPERTIES_SEPARATOR)];
    });
}
Example #6
Source File: write-properties-file.ts    From relate with GNU General Public License v3.0 6 votes vote down vote up
export function writePropertiesFile(path: string, properties: PropertyEntries): Promise<void> {
    const asText = join(
        map(properties, ([key, val]) => {
            const nowhitespace = trim(val);

            return nowhitespace ? join([key, val], PROPERTIES_SEPARATOR) : key;
        }),
        NEW_LINE,
    );

    return writeFile(path, asText, 'utf8');
}
Example #7
Source File: list.monad.ts    From relate with GNU General Public License v3.0 5 votes vote down vote up
join(separator?: string | Str): Str {
        return Str.from(join([...this], separator ? `${separator}` : separator));
    }
Example #8
Source File: list.monad.ts    From relate with GNU General Public License v3.0 5 votes vote down vote up
toString() {
        return `[${this.join(', ')}]`;
    }