Files
headroom/frontend/node_modules/fast-check/lib/esm/stream/Stream.js
Santhosh Janardhanan de2d83092e feat: Reinitialize frontend with SvelteKit and TypeScript
- Delete old Vite+Svelte frontend
- Initialize new SvelteKit project with TypeScript
- Configure Tailwind CSS v4 + DaisyUI
- Implement JWT authentication with auto-refresh
- Create login page with form validation (Zod)
- Add protected route guards
- Update Docker configuration for single-stage build
- Add E2E tests with Playwright (6/11 passing)
- Fix Svelte 5 reactivity with $state() runes

Known issues:
- 5 E2E tests failing (timing/async issues)
- Token refresh implementation needs debugging
- Validation error display timing
2026-02-17 16:19:59 -05:00

87 lines
2.0 KiB
JavaScript

import { filterHelper, flatMapHelper, joinHelper, mapHelper, nilHelper, takeNHelper, takeWhileHelper, } from './StreamHelpers.js';
const safeSymbolIterator = Symbol.iterator;
export class Stream {
static nil() {
return new Stream(nilHelper());
}
static of(...elements) {
return new Stream(elements[safeSymbolIterator]());
}
constructor(g) {
this.g = g;
}
next() {
return this.g.next();
}
[Symbol.iterator]() {
return this.g;
}
map(f) {
return new Stream(mapHelper(this.g, f));
}
flatMap(f) {
return new Stream(flatMapHelper(this.g, f));
}
dropWhile(f) {
let foundEligible = false;
function* helper(v) {
if (foundEligible || !f(v)) {
foundEligible = true;
yield v;
}
}
return this.flatMap(helper);
}
drop(n) {
if (n <= 0) {
return this;
}
let idx = 0;
function helper() {
return idx++ < n;
}
return this.dropWhile(helper);
}
takeWhile(f) {
return new Stream(takeWhileHelper(this.g, f));
}
take(n) {
return new Stream(takeNHelper(this.g, n));
}
filter(f) {
return new Stream(filterHelper(this.g, f));
}
every(f) {
for (const v of this.g) {
if (!f(v)) {
return false;
}
}
return true;
}
has(f) {
for (const v of this.g) {
if (f(v)) {
return [true, v];
}
}
return [false, null];
}
join(...others) {
return new Stream(joinHelper(this.g, others));
}
getNthOrLast(nth) {
let remaining = nth;
let last = null;
for (const v of this.g) {
if (remaining-- === 0)
return v;
last = v;
}
return last;
}
}
export function stream(g) {
return new Stream(g);
}