Sha256: f9f35c4f77d2ea864253d30183c2c1343a018e885c8c4ede5f848f865b73c2a7

Contents?: true

Size: 738 Bytes

Versions: 6

Compression:

Stored size: 738 Bytes

Contents

import { get } from "@rails/request.js";

export async function getHTML(url: string): Promise<string> {
  const response = await get(url, { headers: { "X-Shimmer": "true" } });
  if (response.ok) {
    return await response.response.text();
  }
  return "";
}

export const loaded: Promise<void> = new Promise((res) => {
  document.addEventListener("DOMContentLoaded", () => {
    res();
  });
});

export async function nextFrame(): Promise<void> {
  return new Promise((res) => {
    setTimeout(res, 10);
  });
}

export function createElement(
  parent: HTMLElement,
  className: string
): HTMLDivElement {
  const element = document.createElement("div");
  element.className = className;
  parent.append(element);
  return element;
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shimmer-0.0.10 src/util.ts
shimmer-0.0.9 src/util.ts
shimmer-0.0.8 src/util.ts
shimmer-0.0.7 src/util.ts
shimmer-0.0.6 src/util.ts
shimmer-0.0.5 src/util.ts