Skip to content

Instantly share code, notes, and snippets.

View fliptv97's full-sized avatar

Philip Kazakov fliptv97

View GitHub Profile
customElements.define(
"vwo-marquee",
class extends HTMLElement {
static observedAttributes = ["eyebrow", "title", "description"];
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = this.layout;
@fliptv97
fliptv97 / get.js
Last active November 5, 2024 22:43
const isObject = value => typeof value === "object" && value !== null;
// #region recursive
const getR = (obj, path, defaultValue) => {
const pathParts = path.split(".");
if (!isObject(obj) && !Array.isArray(obj)) return defaultValue;
if (typeof path !== "string" || path.length <= 0 || !Object.hasOwn(obj, pathParts[0])) {
return defaultValue;
}
function fromNullable(value) {
return value === undefined || value === null ? Nothing() : Just(value);
}
function Nothing() {
return {
map: Nothing,
chain: Nothing,
};
}
interface IObserver<T> {
(value: T): void;
}
class Observable<T> {
#value: T;
#observers: Set<IObserver<T>>;
static of<T>(initialValue: T) {
return new Observable(initialValue);
interface TNode<T> {
value: T;
children: TNode<T>[];
}
class Node_<T> {
#value: T;
#children: Node_<T>[] = [];
static fromObject<T>(template_object: TNode<T>) {