Skip to content

Instantly share code, notes, and snippets.

View peterwiebe's full-sized avatar
🌍
Working from Ponte Vedra Beach

Peter Wiebe peterwiebe

🌍
Working from Ponte Vedra Beach
  • PGA Tour
  • Jacksonville, FL
View GitHub Profile
@peterwiebe
peterwiebe / splitWithDelimiter.js
Last active September 3, 2021 19:37
JavaScript utility to split a string into array that includes the delimiter and can ignore case
/*
* Example splitWithDelimiter({query: 'the', suggestion: 'The quick brown fox jumps over the lazy dog.', shouldIgnoreCase: true})
* Evaluates to ['The', ' quick brown fox jumps over ', 'the', ' lazy dog.'];
*/
function splitWithDelimiter ({delimiter, target, shouldIgnoreCase}) {
const result = [];
const formattedTarget = shouldIgnoreCase ? target.toLowerCase() : target;
const formattedDelimiter = shouldIgnoreCase ? delimiter.toLowerCase() : delimiter;
const doesStartWithDelimiter = formattedTarget.startsWith(formattedDelimiter);
const doesEndWithDelimiter = formattedTarget.endsWith(formattedDelimiter);
@peterwiebe
peterwiebe / App.tsx
Created July 11, 2021 00:16
react-native-typewriter change direction
import * as React from 'react';
import TypeWriter from 'react-native-typewriter';
const App = () => {
const [isDeleting, setIsDeleting] = React.useState(false)
const handleAnimationEnd = () => {
setIsDeleting(true)
}