Skip to content

Instantly share code, notes, and snippets.

View flockast's full-sized avatar
🏓

konstantin flockast

🏓
View GitHub Profile
@flockast
flockast / interpolation.js
Created March 23, 2022 11:57
Linear Interpolation js
const linearInterpolation = (x1, y1, x2, y2, x) => y1 + (x - x1) * ((y2 - y1) / (x2 - x1))
@flockast
flockast / formatter.js
Created September 22, 2021 18:19
Replace wrapping symbols on tags
export const escape = (string) => string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
export const replaceSymbolOnTag = (str, symbol, tagName) => {
const regexp = new RegExp(`${escape(symbol)}(.*?)${escape(symbol)}`, 'gi')
return str.replace(regexp, `<${tagName}>$1</${tagName}>`)
}
export const replacer = (selectors = [], symbol = '#', tagName = 'span') => {
const $elements = []