Добавлена ДБ

This commit is contained in:
Georgiy Syralev
2025-09-15 18:10:26 +03:00
parent 253ad8c19b
commit c954b5268e
5824 changed files with 1107594 additions and 19141 deletions

View File

@@ -0,0 +1,20 @@
class LazyIterableIterator {
constructor(producer) {
this.producer = producer;
}
[Symbol.iterator]() {
if (this.it === undefined) {
this.it = this.producer();
}
return this.it;
}
next() {
if (this.it === undefined) {
this.it = this.producer();
}
return this.it.next();
}
}
export function makeLazy(producer) {
return new LazyIterableIterator(producer);
}

86
node_modules/fast-check/lib/esm/stream/Stream.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
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);
}

View File

@@ -0,0 +1,55 @@
class Nil {
[Symbol.iterator]() {
return this;
}
next(value) {
return { value, done: true };
}
}
Nil.nil = new Nil();
export function nilHelper() {
return Nil.nil;
}
export function* mapHelper(g, f) {
for (const v of g) {
yield f(v);
}
}
export function* flatMapHelper(g, f) {
for (const v of g) {
yield* f(v);
}
}
export function* filterHelper(g, f) {
for (const v of g) {
if (f(v)) {
yield v;
}
}
}
export function* takeNHelper(g, n) {
for (let i = 0; i < n; ++i) {
const cur = g.next();
if (cur.done) {
break;
}
yield cur.value;
}
}
export function* takeWhileHelper(g, f) {
let cur = g.next();
while (!cur.done && f(cur.value)) {
yield cur.value;
cur = g.next();
}
}
export function* joinHelper(g, others) {
for (let cur = g.next(); !cur.done; cur = g.next()) {
yield cur.value;
}
for (const s of others) {
for (let cur = s.next(); !cur.done; cur = s.next()) {
yield cur.value;
}
}
}