How to use the @microsoft/fast-web-utilities.startsWith function in @microsoft/fast-web-utilities

To help you get started, we’ve selected a few @microsoft/fast-web-utilities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / fast-dna / packages / fast-components-react-base / src / listbox / listbox.tsx View on Github external
(child: React.ReactElement, index: number): boolean => {
                if (child.props[this.props.typeAheadPropertyKey] === undefined) {
                    return false;
                }
                if (
                    startsWith(
                        child.props[this.props.typeAheadPropertyKey].toLowerCase(),
                        this.typeAheadString
                    )
                ) {
                    matchIndex = index;
                    return true;
                }
            }
        );
github microsoft / fast-dna / packages / fast-components-react-msft / src / auto-suggest-option / auto-suggest-option.tsx View on Github external
private defaultDisplayFormatter = (
        displayString: string,
        searchString: string
    ): React.ReactNode => {
        if (
            !isNil(displayString) &&
            !isNil(searchString) &&
            startsWith(displayString.toLowerCase(), searchString.toLowerCase())
        ) {
            return (
                <span>
                    <b>{displayString.substring(0, searchString.length)}</b>
                    {displayString.substring(searchString.length, displayString.length)}
                </span>
            );
        }
        return displayString;
    };
}