Projektstart

This commit is contained in:
2026-01-22 15:49:12 +01:00
parent 7212eb6f7a
commit 57e5f652f8
10637 changed files with 2598792 additions and 64 deletions

21
backend/node_modules/obliterator/LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017-2021 Guillaume Plique (Yomguithereal)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

415
backend/node_modules/obliterator/README.md generated vendored Normal file
View File

@@ -0,0 +1,415 @@
[![Build Status](https://github.com/Yomguithereal/obliterator/workflows/Tests/badge.svg)](https://github.com/Yomguithereal/obliterator/actions)
# Obliterator
Obliterator is a dead simple JavaScript/TypeScript library providing miscellaneous higher-order iterator/iterable functions such as combining two or more iterators into a single one.
Note that when possible, `obliterator` also consider sequences such as arrays, strings etc. as valid iterables (although they are not proper ES6 iterables values), for convenience.
# Installation
```
npm install --save obliterator
```
Note that `obliterator` comes along with its TypeScript declarations.
# Usage
## Summary
_Classes_
- [Iterator](#iterator)
_Functions_
- [chain](#chain)
- [combinations](#combinations)
- [consume](#consume)
- [every](#every)
- [filter](#filter)
- [find](#find)
- [forEach](#foreach)
- [forEachWithNullKeys](#foreachwithnullkeys)
- [includes](#includes)
- [iter](#iter)
- [map](#map)
- [match](#match)
- [permutations](#permutations)
- [powerSet](#powerSet)
- [some](#some)
- [split](#split)
- [take](#take)
## Iterator
A handy Iterator class easily usable with ES2015's `for ... of` loop constructs & spread operator.
```js
import Iterator from 'obliterator/iterator';
// Or
import {Iterator} from 'obliterator';
const iterator = new Iterator(function () {
// Define what the `next` function does
return {done: false, value: 34};
});
// Checking that the given value is an iterator (native or else)
Iterator.is(value);
// Creating an empty iterator
const emptyIterator = Iterator.empty();
// Creating a simple iterator from a single value
const simpleIterator = Iterator.of(34);
// Creating a simple iterator from multiple values
const multipleIterator = Iterator.of(1, 2, 3);
```
## chain
Variadic function chaining all the given iterable-like values.
```js
import chain from 'obliterator/chain';
// Or
import {chain} from 'obliterator';
const set1 = new Set('a');
const set2 = new Set('bc');
const chained = chain(set1.values(), set2);
chained.next();
>>> {done: false, value: 'a'}
chained.next();
>>> {done: false, value: 'b'}
```
## combinations
Returns an iterator of combinations of the given array and of the given size.
Note that for performance reasons, the yielded combination is always the same object.
```js
import combinations from 'obliterator/combinations';
// Or
import {combinations} from 'obliterator';
const iterator = combinations(['A', 'B', 'C', 'D'], 2);
iterator.next().value;
>>> ['A', 'B']
iterator.next().value;
>>> ['A', 'C']
```
## consume
Function consuming the given iterator fully or for n steps.
```js
import consume from 'obliterator/consume';
// Or
import {consume} from 'obliterator';
const set = new Set([1, 2, 3]);
// Consuming the whole iterator
let iterator = set.values();
consume(iterator);
iterator.next().done >>> true;
// Consuming n steps
let iterator = set.values();
consume(iterator, 2);
iterator.next().value >>> 3;
```
## every
Function returning whether all items of an iterable-like match the given predicate function.
```js
import every from 'obliterator/every';
// Or
import {every} from 'obliterator';
every([2, 4, 6], n => n % 2 === 0);
>>> true
every([1, 2, 3], n => n % 2 === 0);
>>> false
```
## filter
Function returning an iterator filtering another one's values using the given predicate function.
```js
import filter from 'obliterator/filter';
// Or
import {filter} from 'obliterator';
const set = new Set([1, 2, 3, 4, 5]);
const even = x => x % 2 === 0;
const iterator = filter(set.values(), even);
iterator.next().value >>> 2;
iterator.next().value >>> 4;
```
## find
Function returning the next item matching given predicate function in an iterable-like.
```js
import find from 'obliterator/find';
// Or
import {find} from 'obliterator';
const set = new Set([1, 2, 3, 4, 5]);
const even = x => x % 2 === 0;
const values = set.values();
find(values, even);
>>> 2
find(values, even);
>>> 4
find(values, even);
>>> undefined
```
## forEach
Function able to iterate over almost any JavaScript iterable value using a callback.
Supported values range from arrays, typed arrays, sets, maps, objects, strings, arguments, iterators, arbitrary iterables etc.
```js
import forEach from 'obliterator/foreach';
// Or
import {forEach} from 'obliterator';
const set = new Set(['apple', 'banana']);
forEach(set.values(), (value, i) => {
console.log(i, value);
});
// Iterating over a string
forEach('abc', (char, i) => ...);
// Iterating over a map
forEach(map, (value, key) => ...);
```
## forEachWithNullKeys
Variant of [forEach](#foreach) one can use to iterate over mixed values but with the twist that iterables without proper keys (lists, sets etc.), will yield `null` instead of an index key.
Supported values range from arrays, typed arrays, sets, maps, objects, strings, arguments, iterators, arbitrary iterables etc.
```js
import {forEachWithNullKeys} from 'obliterator/foreach';
const set = new Set(['apple', 'banana']);
forEach(set, (value, key) => {
console.log(key, value);
});
>>> null, 'apple'
>>> null, 'banana'
```
## includes
Function returning whether the given value can be found in given iterable-like.
```js
import {includes} from 'obliterator';
// Or
import includes from 'obliterator/includes';
includes([1, 2, 3], 3);
>>> true;
includes('test', 'a');
>>> false;
```
## iter
Function casting any iterable-like value to a proper iterator. Will throw an error if the given value cannot be cast as an iterator.
```js
import {iter} from 'obliterator';
// Or
import iter from 'obliterator/iter';
iter('test');
iter(new Set([1, 2, 3]));
// This will throw:
iter(null);
```
## map
Function returning an iterator mapping another one's values using the given function.
```js
import map from 'obliterator/map';
// Or
import {map} from 'obliterator';
const set = new Set([1, 2, 3, 4, 5]);
const triple = x => x * 3;
const iterator = map(set.values(), triple);
iterator.next().value >>> 3;
iterator.next().value >>> 6;
```
## match
Function returning an iterator over the matches of a given regex applied to the target string.
```js
import match from 'obliterator/match';
// Or
import {match} from 'obliterator';
const iterator = match(/t/, 'test');
iterator.next().value.index >>> 0;
iterator.next().value.index >>> 3;
```
## permutations
Returns an iterator of permutations of the given array and of the given size.
Note that for performance reasons, the yielded permutation is always the same object.
```js
import permutations from 'obliterator/permutations';
// Or
import {permutations} from 'obliterator';
let iterator = permutations([1, 2, 3]);
iterator.next().value
>>> [1, 2, 3]
iterator.next().value
>>> [1, 3, 2]
iterator = permutations(['A', 'B', 'C', 'D'], 2);
iterator.next().value;
>>> ['A', 'B']
iterator.next().value;
>>> ['A', 'C']
```
## powerSet
Returns an iterator of sets composing the power set of the given array.
```js
import powerSet from 'obliterator/power-set';
// Or
import {powerSet} from 'obliterator';
const iterator = powerSet(['A', 'B', 'C']);
iterator.next().value;
>>> []
iterator.next().value;
>>> ['A']
```
## some
Returns whether the given iterable-like has some item matching the given predicate function.
```js
import some from 'obliterator/some';
// Or
import {some} from 'obliterator';
some(new Set([1, 2, 3]), n => n % 2 === 0);
>>> true
some('test', c => c === 'a');
>>> false
```
## split
Returns an iterator over the splits of the target string, according to the given RegExp pattern.
```js
import split from 'obliterator/split';
// Or
import {split} from 'obliterator';
const iterator = split(/;/g, 'hello;world;super');
iterator.next().value;
>>> 'hello'
iterator.next().value;
>>> 'world'
```
## take
Function taking values from given iterator and returning them in an array.
```js
import take from 'obliterator/take';
// Or
import {take} from 'obliterator';
const set = new Set([1, 2, 3]);
// To take n values from the iterator
take(set.values(), 2);
>>> [1, 2]
// To convert the full iterator into an array
take(set.values());
>>> [1, 2, 3]
```
# Contribution
Contributions are obviously welcome. Please be sure to lint the code & add the relevant unit tests before submitting any PR.
```
git clone git@github.com:Yomguithereal/obliterator.git
cd obliterator
npm install
# To lint the code
npm run lint
# To run the unit tests
npm test
```
# License
[MIT](LICENSE.txt)

5
backend/node_modules/obliterator/chain.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import type {IntoInterator} from './types';
export default function chain<T>(
...iterables: IntoInterator<T>[]
): IterableIterator<T>;

46
backend/node_modules/obliterator/chain.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
/**
* Obliterator Chain Function
* ===========================
*
* Variadic function combining the given iterables.
*/
var Iterator = require('./iterator.js');
var iter = require('./iter.js');
/**
* Chain.
*
* @param {...Iterator} iterables - Target iterables.
* @return {Iterator}
*/
module.exports = function chain() {
var iterables = arguments;
var current = null;
var i = -1;
/* eslint-disable no-constant-condition */
return new Iterator(function next() {
var step = null;
do {
if (current === null) {
i++;
if (i >= iterables.length) return {done: true};
current = iter(iterables[i]);
}
step = current.next();
if (step.done === true) {
current = null;
continue;
}
break;
} while (true);
return step;
});
};

4
backend/node_modules/obliterator/combinations.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export default function combinations<T>(
array: Array<T>,
r: number
): IterableIterator<Array<T>>;

76
backend/node_modules/obliterator/combinations.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
/**
* Obliterator Combinations Function
* ==================================
*
* Iterator returning combinations of the given array.
*/
var Iterator = require('./iterator.js');
/**
* Helper mapping indices to items.
*/
function indicesToItems(target, items, indices, r) {
for (var i = 0; i < r; i++) target[i] = items[indices[i]];
}
/**
* Combinations.
*
* @param {array} array - Target array.
* @param {number} r - Size of the subsequences.
* @return {Iterator}
*/
module.exports = function combinations(array, r) {
if (!Array.isArray(array))
throw new Error(
'obliterator/combinations: first argument should be an array.'
);
var n = array.length;
if (typeof r !== 'number')
throw new Error(
'obliterator/combinations: second argument should be omitted or a number.'
);
if (r > n)
throw new Error(
'obliterator/combinations: the size of the subsequences should not exceed the length of the array.'
);
if (r === n) return Iterator.of(array.slice());
var indices = new Array(r),
subsequence = new Array(r),
first = true,
i;
for (i = 0; i < r; i++) indices[i] = i;
return new Iterator(function next() {
if (first) {
first = false;
indicesToItems(subsequence, array, indices, r);
return {value: subsequence, done: false};
}
if (indices[r - 1]++ < n - 1) {
indicesToItems(subsequence, array, indices, r);
return {value: subsequence, done: false};
}
i = r - 2;
while (i >= 0 && indices[i] >= n - (r - i)) --i;
if (i < 0) return {done: true};
indices[i]++;
while (++i < r) indices[i] = indices[i - 1] + 1;
indicesToItems(subsequence, array, indices, r);
return {value: subsequence, done: false};
});
};

1
backend/node_modules/obliterator/consume.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export default function consume<T>(iterator: Iterator<T>, steps?: number): void;

29
backend/node_modules/obliterator/consume.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/* eslint no-constant-condition: 0 */
/**
* Obliterator Consume Function
* =============================
*
* Function consuming the given iterator for n or every steps.
*/
/**
* Consume.
*
* @param {Iterator} iterator - Target iterator.
* @param {number} [steps] - Optional steps.
*/
module.exports = function consume(iterator, steps) {
var step,
l = arguments.length > 1 ? steps : Infinity,
i = 0;
while (true) {
if (i === l) return;
step = iterator.next();
if (step.done) return;
i++;
}
};

8
backend/node_modules/obliterator/every.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type {IntoInterator} from './types';
type PredicateFunction<T> = (item: T) => boolean;
export default function every<T>(
target: IntoInterator<T>,
predicate: PredicateFunction<T>
): boolean;

27
backend/node_modules/obliterator/every.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
* Obliterator Every Function
* ==========================
*
* Function taking an iterable and a predicate and returning whether all
* its items match the given predicate.
*/
var iter = require('./iter.js');
/**
* Every.
*
* @param {Iterable} iterable - Target iterable.
* @param {function} predicate - Predicate function.
* @return {boolean}
*/
module.exports = function every(iterable, predicate) {
var iterator = iter(iterable);
var step;
while (((step = iterator.next()), !step.done)) {
if (!predicate(step.value)) return false;
}
return true;
};

8
backend/node_modules/obliterator/filter.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type {IntoInterator} from './types';
type PredicateFunction<T> = (item: T) => boolean;
export default function filter<T>(
target: IntoInterator<T>,
predicate: PredicateFunction<T>
): IterableIterator<T>;

28
backend/node_modules/obliterator/filter.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/**
* Obliterator Filter Function
* ===========================
*
* Function returning a iterator filtering the given iterator.
*/
var Iterator = require('./iterator.js');
var iter = require('./iter.js');
/**
* Filter.
*
* @param {Iterable} target - Target iterable.
* @param {function} predicate - Predicate function.
* @return {Iterator}
*/
module.exports = function filter(target, predicate) {
var iterator = iter(target);
var step;
return new Iterator(function () {
do {
step = iterator.next();
} while (!step.done && !predicate(step.value));
return step;
});
};

8
backend/node_modules/obliterator/find.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type {IntoInterator} from './types';
type PredicateFunction<T> = (item: T) => boolean;
export default function find<T>(
target: IntoInterator<T>,
predicate: PredicateFunction<T>
): T | undefined;

27
backend/node_modules/obliterator/find.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
* Obliterator Find Function
* ==========================
*
* Function taking an iterable and a predicate and returning the first item
* matching the given predicate.
*/
var iter = require('./iter.js');
/**
* Find.
*
* @param {Iterable} iterable - Target iterable.
* @param {function} predicate - Predicate function.
* @return {boolean}
*/
module.exports = function find(iterable, predicate) {
var iterator = iter(iterable);
var step;
while (((step = iterator.next()), !step.done)) {
if (predicate(step.value)) return step.value;
}
return;
};

View File

@@ -0,0 +1,29 @@
import type {Sequence} from './types';
interface ForEachTrait<K, V> {
forEach(callback: (value: V, key: K, self: this) => void): void;
}
interface PlainObject<T> {
[key: string]: T;
}
export default function forEachWithNullKeys<V>(
iterable: Set<V>,
callback: (value: V, key: null) => void
): void;
export default function forEachWithNullKeys<K, V>(
iterable: ForEachTrait<K, V>,
callback: (value: V, key: K) => void
): void;
export default function forEachWithNullKeys<T>(
iterable: Iterator<T> | Iterable<T> | Sequence<T>,
callback: (item: T, key: null) => void
): void;
export default function forEachWithNullKeys<T>(
object: PlainObject<T>,
callback: (value: T, key: string) => void
): void;

View File

@@ -0,0 +1,93 @@
/**
* Obliterator ForEachWithNullKeys Function
* =========================================
*
* Helper function used to easily iterate over mixed values.
*/
var support = require('./support.js');
var ARRAY_BUFFER_SUPPORT = support.ARRAY_BUFFER_SUPPORT;
var SYMBOL_SUPPORT = support.SYMBOL_SUPPORT;
/**
* Same function as the `forEach` but will yield `null` when the target
* does not have keys.
*
* @param {any} iterable - Iterable value.
* @param {function} callback - Callback function.
*/
module.exports = function forEachWithNullKeys(iterable, callback) {
var iterator, k, i, l, s;
if (!iterable)
throw new Error('obliterator/forEachWithNullKeys: invalid iterable.');
if (typeof callback !== 'function')
throw new Error('obliterator/forEachWithNullKeys: expecting a callback.');
// The target is an array or a string or function arguments
if (
Array.isArray(iterable) ||
(ARRAY_BUFFER_SUPPORT && ArrayBuffer.isView(iterable)) ||
typeof iterable === 'string' ||
iterable.toString() === '[object Arguments]'
) {
for (i = 0, l = iterable.length; i < l; i++) callback(iterable[i], null);
return;
}
// The target is a Set
if (iterable instanceof Set) {
iterable.forEach(function (value) {
callback(value, null);
});
return;
}
// The target is a Map
if (iterable instanceof Map) {
iterable.forEach(function (value, key) {
callback(value, key);
});
return;
}
// The target is iterable
if (
SYMBOL_SUPPORT &&
Symbol.iterator in iterable &&
typeof iterable.next !== 'function'
) {
iterable = iterable[Symbol.iterator]();
}
// The target is an iterator
if (typeof iterable.next === 'function') {
iterator = iterable;
i = 0;
while (((s = iterator.next()), s.done !== true)) {
callback(s.value, null);
i++;
}
return;
}
// The target has a #.forEach method
// NOTE: there is now a JS builtin `Iterator` class having a #.forEach method.
// This is why this branch cannot happen earlier.
if (typeof iterable.forEach === 'function') {
iterable.forEach(callback);
return;
}
// The target is a plain object
for (k in iterable) {
if (iterable.hasOwnProperty(k)) {
callback(iterable[k], k);
}
}
return;
};

24
backend/node_modules/obliterator/foreach.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import type {Sequence} from './types';
interface ForEachTrait<K, V> {
forEach(callback: (value: V, key: K, self: this) => void): void;
}
interface PlainObject<T> {
[key: string]: T;
}
export default function forEach<K, V>(
iterable: ForEachTrait<K, V>,
callback: (value: V, key: K) => void
): void;
export default function forEach<T>(
iterable: Iterator<T> | Iterable<T> | Sequence<T>,
callback: (item: T, index: number) => void
): void;
export default function forEach<T>(
object: PlainObject<T>,
callback: (value: T, key: string) => void
): void;

73
backend/node_modules/obliterator/foreach.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
/**
* Obliterator ForEach Function
* =============================
*
* Helper function used to easily iterate over mixed values.
*/
var support = require('./support.js');
var ARRAY_BUFFER_SUPPORT = support.ARRAY_BUFFER_SUPPORT;
var SYMBOL_SUPPORT = support.SYMBOL_SUPPORT;
/**
* Function able to iterate over almost any iterable JS value.
*
* @param {any} iterable - Iterable value.
* @param {function} callback - Callback function.
*/
module.exports = function forEach(iterable, callback) {
var iterator, k, i, l, s;
if (!iterable) throw new Error('obliterator/forEach: invalid iterable.');
if (typeof callback !== 'function')
throw new Error('obliterator/forEach: expecting a callback.');
// The target is an array or a string or function arguments
if (
Array.isArray(iterable) ||
(ARRAY_BUFFER_SUPPORT && ArrayBuffer.isView(iterable)) ||
typeof iterable === 'string' ||
iterable.toString() === '[object Arguments]'
) {
for (i = 0, l = iterable.length; i < l; i++) callback(iterable[i], i);
return;
}
// The target has a #.forEach method
if (typeof iterable.forEach === 'function') {
iterable.forEach(callback);
return;
}
// The target is iterable
if (
SYMBOL_SUPPORT &&
Symbol.iterator in iterable &&
typeof iterable.next !== 'function'
) {
iterable = iterable[Symbol.iterator]();
}
// The target is an iterator
if (typeof iterable.next === 'function') {
iterator = iterable;
i = 0;
while (((s = iterator.next()), s.done !== true)) {
callback(s.value, i);
i++;
}
return;
}
// The target is a plain object
for (k in iterable) {
if (iterable.hasOwnProperty(k)) {
callback(iterable[k], k);
}
}
return;
};

6
backend/node_modules/obliterator/includes.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import type {IntoInterator} from './types';
export default function includes<T>(
target: IntoInterator<T>,
value: T
): boolean;

27
backend/node_modules/obliterator/includes.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
* Obliterator Includes Function
* ==============================
*
* Function taking an iterable and returning whether the given item can be
* found in it.
*/
var iter = require('./iter.js');
/**
* Includes.
*
* @param {Iterable} iterable - Target iterable.
* @param {function} value - Searched value.
* @return {boolean}
*/
module.exports = function includes(iterable, value) {
var iterator = iter(iterable);
var step;
while (((step = iterator.next()), !step.done)) {
if (step.value === value) return true;
}
return false;
};

20
backend/node_modules/obliterator/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
export {default as Iterator} from './iterator';
export {default as iter} from './iter';
export {default as chain} from './chain';
export {default as combinations} from './combinations';
export {default as consume} from './consume';
export {default as every} from './every';
export {default as filter} from './filter';
export {default as find} from './find';
export {default as forEach} from './foreach';
export {default as forEachWithNullKeys} from './foreach-with-null-keys';
export {default as includes} from './includes';
export {default as map} from './map';
export {default as match} from './match';
export {default as permutations} from './permutations';
export {default as powerSet} from './power-set';
export {default as range} from './range';
export {default as some} from './some';
export {default as split} from './split';
export {default as take} from './take';
export {default as takeInto} from './take-into';

26
backend/node_modules/obliterator/index.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/**
* Obliterator Library Endpoint
* =============================
*
* Exporting the library's functions.
*/
exports.Iterator = require('./iterator.js');
exports.iter = require('./iter.js');
exports.chain = require('./chain.js');
exports.combinations = require('./combinations.js');
exports.consume = require('./consume.js');
exports.every = require('./every.js');
exports.filter = require('./filter.js');
exports.find = require('./find.js');
exports.forEach = require('./foreach.js');
exports.forEachWithNullKeys = require('./foreach-with-null-keys.js');
exports.includes = require('./includes.js');
exports.map = require('./map.js');
exports.match = require('./match.js');
exports.permutations = require('./permutations.js');
exports.powerSet = require('./power-set.js');
exports.range = require('./range.js');
exports.some = require('./some.js');
exports.split = require('./split.js');
exports.take = require('./take.js');
exports.takeInto = require('./take-into.js');

1
backend/node_modules/obliterator/iter.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export default function iter<T>(target: unknown): Iterator<T>;

46
backend/node_modules/obliterator/iter.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
/**
* Obliterator Iter Function
* ==========================
*
* Function coercing values to an iterator. It can be quite useful when needing
* to handle iterables and iterators the same way.
*/
var Iterator = require('./iterator.js');
var support = require('./support.js');
var ARRAY_BUFFER_SUPPORT = support.ARRAY_BUFFER_SUPPORT;
var SYMBOL_SUPPORT = support.SYMBOL_SUPPORT;
function iterOrNull(target) {
// Indexed sequence
if (
typeof target === 'string' ||
Array.isArray(target) ||
(ARRAY_BUFFER_SUPPORT && ArrayBuffer.isView(target))
)
return Iterator.fromSequence(target);
// Invalid value
if (typeof target !== 'object' || target === null) return null;
// Iterable
if (SYMBOL_SUPPORT && typeof target[Symbol.iterator] === 'function')
return target[Symbol.iterator]();
// Iterator duck-typing
if (typeof target.next === 'function') return target;
// Invalid object
return null;
}
module.exports = function iter(target) {
var iterator = iterOrNull(target);
if (!iterator)
throw new Error(
'obliterator: target is not iterable nor a valid iterator.'
);
return iterator;
};

18
backend/node_modules/obliterator/iterator.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import type {Sequence} from './types';
type NextFunction<V> = () => IteratorResult<V>;
export default class ObliteratorIterator<V> implements IterableIterator<V> {
// Constructor
constructor(next: NextFunction<V>);
// Well-known methods
next(): IteratorResult<V>;
[Symbol.iterator](): IterableIterator<V>;
// Static methods
static of<T>(...args: T[]): ObliteratorIterator<T>;
static empty<T>(): ObliteratorIterator<T>;
static is(value: any): boolean;
static fromSequence<T>(sequence: Sequence<T>): ObliteratorIterator<T>;
}

96
backend/node_modules/obliterator/iterator.js generated vendored Normal file
View File

@@ -0,0 +1,96 @@
/**
* Obliterator Iterator Class
* ===========================
*
* Simple class representing the library's iterators.
*/
/**
* Iterator class.
*
* @constructor
* @param {function} next - Next function.
*/
function Iterator(next) {
if (typeof next !== 'function')
throw new Error('obliterator/iterator: expecting a function!');
this.next = next;
}
/**
* If symbols are supported, we add `next` to `Symbol.iterator`.
*/
if (typeof Symbol !== 'undefined')
Iterator.prototype[Symbol.iterator] = function () {
return this;
};
/**
* Returning an iterator of the given values.
*
* @param {any...} values - Values.
* @return {Iterator}
*/
Iterator.of = function () {
var args = arguments,
l = args.length,
i = 0;
return new Iterator(function () {
if (i >= l) return {done: true};
return {done: false, value: args[i++]};
});
};
/**
* Returning an empty iterator.
*
* @return {Iterator}
*/
Iterator.empty = function () {
var iterator = new Iterator(function () {
return {done: true};
});
return iterator;
};
/**
* Returning an iterator over the given indexed sequence.
*
* @param {string|Array} sequence - Target sequence.
* @return {Iterator}
*/
Iterator.fromSequence = function (sequence) {
var i = 0,
l = sequence.length;
return new Iterator(function () {
if (i >= l) return {done: true};
return {done: false, value: sequence[i++]};
});
};
/**
* Returning whether the given value is an iterator.
*
* @param {any} value - Value.
* @return {boolean}
*/
Iterator.is = function (value) {
if (value instanceof Iterator) return true;
return (
typeof value === 'object' &&
value !== null &&
typeof value.next === 'function'
);
};
/**
* Exporting.
*/
module.exports = Iterator;

8
backend/node_modules/obliterator/map.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type {IntoInterator} from './types';
type MapFunction<S, T> = (item: S) => T;
export default function map<S, T>(
target: IntoInterator<S>,
predicate: MapFunction<S, T>
): IterableIterator<T>;

29
backend/node_modules/obliterator/map.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/**
* Obliterator Map Function
* ===========================
*
* Function returning a iterator mapping the given iterator's values.
*/
var Iterator = require('./iterator.js');
var iter = require('./iter.js');
/**
* Map.
*
* @param {Iterator} target - Target iterable.
* @param {function} mapper - Map function.
* @return {Iterator}
*/
module.exports = function map(target, mapper) {
var iterator = iter(target);
return new Iterator(function next() {
var step = iterator.next();
if (step.done) return step;
return {
value: mapper(step.value)
};
});
};

4
backend/node_modules/obliterator/match.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export default function match(
pattern: RegExp,
string: string
): IterableIterator<string>;

43
backend/node_modules/obliterator/match.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
/**
* Obliterator Match Function
* ===========================
*
* Function returning an iterator over the matches of the given regex on the
* target string.
*/
var Iterator = require('./iterator.js');
/**
* Match.
*
* @param {RegExp} pattern - Regular expression to use.
* @param {string} string - Target string.
* @return {Iterator}
*/
module.exports = function match(pattern, string) {
var executed = false;
if (!(pattern instanceof RegExp))
throw new Error(
'obliterator/match: invalid pattern. Expecting a regular expression.'
);
if (typeof string !== 'string')
throw new Error('obliterator/match: invalid target. Expecting a string.');
return new Iterator(function () {
if (executed && !pattern.global) {
pattern.lastIndex = 0;
return {done: true};
}
executed = true;
var m = pattern.exec(string);
if (m) return {value: m};
pattern.lastIndex = 0;
return {done: true};
});
};

46
backend/node_modules/obliterator/package.json generated vendored Normal file
View File

@@ -0,0 +1,46 @@
{
"name": "obliterator",
"version": "2.0.5",
"description": "Higher order iterator library for JavaScript/TypeScript.",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"lint": "eslint *.js",
"prepublishOnly": "npm run lint && npm test",
"prettier": "prettier --write '*.js' '*.ts'",
"test": "mocha test.js && npm run test:types",
"test:types": "tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yomguithereal/obliterator.git"
},
"keywords": [
"iterator"
],
"author": {
"name": "Guillaume Plique",
"url": "http://github.com/Yomguithereal"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/yomguithereal/obliterator/issues"
},
"homepage": "https://github.com/yomguithereal/obliterator#readme",
"devDependencies": {
"@yomguithereal/eslint-config": "^4.4.0",
"@yomguithereal/prettier-config": "^1.2.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"mocha": "^9.2.2",
"prettier": "^2.6.2",
"typescript": "^4.6.3"
},
"eslintConfig": {
"extends": [
"@yomguithereal/eslint-config",
"eslint-config-prettier"
]
},
"prettier": "@yomguithereal/prettier-config"
}

4
backend/node_modules/obliterator/permutations.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export default function permutations<T>(
array: Array<T>,
r: number
): IterableIterator<Array<T>>;

94
backend/node_modules/obliterator/permutations.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
/**
* Obliterator Permutations Function
* ==================================
*
* Iterator returning permutations of the given array.
*/
var Iterator = require('./iterator.js');
/**
* Helper mapping indices to items.
*/
function indicesToItems(target, items, indices, r) {
for (var i = 0; i < r; i++) target[i] = items[indices[i]];
}
/**
* Permutations.
*
* @param {array} array - Target array.
* @param {number} r - Size of the subsequences.
* @return {Iterator}
*/
module.exports = function permutations(array, r) {
if (!Array.isArray(array))
throw new Error(
'obliterator/permutations: first argument should be an array.'
);
var n = array.length;
if (arguments.length < 2) r = n;
if (typeof r !== 'number')
throw new Error(
'obliterator/permutations: second argument should be omitted or a number.'
);
if (r > n)
throw new Error(
'obliterator/permutations: the size of the subsequences should not exceed the length of the array.'
);
var indices = new Uint32Array(n),
subsequence = new Array(r),
cycles = new Uint32Array(r),
first = true,
i;
for (i = 0; i < n; i++) {
indices[i] = i;
if (i < r) cycles[i] = n - i;
}
i = r;
return new Iterator(function next() {
if (first) {
first = false;
indicesToItems(subsequence, array, indices, r);
return {value: subsequence, done: false};
}
var tmp, j;
i--;
if (i < 0) return {done: true};
cycles[i]--;
if (cycles[i] === 0) {
tmp = indices[i];
for (j = i; j < n - 1; j++) indices[j] = indices[j + 1];
indices[n - 1] = tmp;
cycles[i] = n - i;
return next();
} else {
j = cycles[i];
tmp = indices[i];
indices[i] = indices[n - j];
indices[n - j] = tmp;
i = r;
indicesToItems(subsequence, array, indices, r);
return {value: subsequence, done: false};
}
});
};

3
backend/node_modules/obliterator/power-set.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function powerSet<T>(
array: Array<T>
): IterableIterator<Array<T>>;

27
backend/node_modules/obliterator/power-set.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
* Obliterator Power Set Function
* ===============================
*
* Iterator returning the power set of the given array.
*/
var Iterator = require('./iterator.js'),
combinations = require('./combinations.js'),
chain = require('./chain.js');
/**
* Power set.
*
* @param {array} array - Target array.
* @return {Iterator}
*/
module.exports = function powerSet(array) {
var n = array.length;
var iterators = new Array(n + 1);
iterators[0] = Iterator.of([]);
for (var i = 1; i < n + 1; i++) iterators[i] = combinations(array, i);
return chain.apply(null, iterators);
};

10
backend/node_modules/obliterator/range.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
export default function range(end: number): IterableIterator<number>;
export default function range(
start: number,
end: number
): IterableIterator<number>;
export default function range(
start: number,
end: number,
step: number
): IterableIterator<number>;

44
backend/node_modules/obliterator/range.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
/**
* Obliterator Range Function
* ===========================
*
* Function returning a range iterator.
*/
var Iterator = require('./iterator.js');
/**
* Range.
*
* @param {number} start - Start.
* @param {number} end - End.
* @param {number} step - Step.
* @return {Iterator}
*/
module.exports = function range(start, end, step) {
if (arguments.length === 1) {
end = start;
start = 0;
}
if (arguments.length < 3) step = 1;
var i = start;
var iterator = new Iterator(function () {
if (i < end) {
var value = i;
i += step;
return {value: value, done: false};
}
return {done: true};
});
iterator.start = start;
iterator.end = end;
iterator.step = step;
return iterator;
};

8
backend/node_modules/obliterator/some.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type {IntoInterator} from './types';
type PredicateFunction<T> = (item: T) => boolean;
export default function some<T>(
target: IntoInterator<T>,
predicate: PredicateFunction<T>
): boolean;

27
backend/node_modules/obliterator/some.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/**
* Obliterator Some Function
* ==========================
*
* Function taking an iterable and a predicate and returning whether a
* matching item can be found.
*/
var iter = require('./iter.js');
/**
* Some.
*
* @param {Iterable} iterable - Target iterable.
* @param {function} predicate - Predicate function.
* @return {boolean}
*/
module.exports = function some(iterable, predicate) {
var iterator = iter(iterable);
var step;
while (((step = iterator.next()), !step.done)) {
if (predicate(step.value)) return true;
}
return false;
};

4
backend/node_modules/obliterator/split.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export default function split(
pattern: RegExp,
string: string
): IterableIterator<string>;

68
backend/node_modules/obliterator/split.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
/**
* Obliterator Split Function
* ===========================
*
* Function returning an iterator over the pieces of a regex split.
*/
var Iterator = require('./iterator.js');
/**
* Function used to make the given pattern global.
*
* @param {RegExp} pattern - Regular expression to make global.
* @return {RegExp}
*/
function makeGlobal(pattern) {
var flags = 'g';
if (pattern.multiline) flags += 'm';
if (pattern.ignoreCase) flags += 'i';
if (pattern.sticky) flags += 'y';
if (pattern.unicode) flags += 'u';
return new RegExp(pattern.source, flags);
}
/**
* Split.
*
* @param {RegExp} pattern - Regular expression to use.
* @param {string} string - Target string.
* @return {Iterator}
*/
module.exports = function split(pattern, string) {
if (!(pattern instanceof RegExp))
throw new Error(
'obliterator/split: invalid pattern. Expecting a regular expression.'
);
if (typeof string !== 'string')
throw new Error('obliterator/split: invalid target. Expecting a string.');
// NOTE: cloning the pattern has a performance cost but side effects for not
// doing so might be worse.
pattern = makeGlobal(pattern);
var consumed = false,
current = 0;
return new Iterator(function () {
if (consumed) return {done: true};
var match = pattern.exec(string),
value,
length;
if (match) {
length = match.index + match[0].length;
value = string.slice(current, match.index);
current = length;
} else {
consumed = true;
value = string.slice(current);
}
return {value: value, done: false};
});
};

2
backend/node_modules/obliterator/support.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
exports.ARRAY_BUFFER_SUPPORT = typeof ArrayBuffer !== 'undefined';
exports.SYMBOL_SUPPORT = typeof Symbol !== 'undefined';

9
backend/node_modules/obliterator/take-into.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import type {IntoInterator} from './types';
// Requires a resolution of https://github.com/microsoft/TypeScript/issues/1213
// export default function takeInto<C<~>, T>(ArrayClass: new <T>(n: number) => C<T>, iterator: Iterator<T>, n: number): C<T>;
export default function takeInto<T>(
ArrayClass: new <T>(arrayLength: number) => T[],
iterator: IntoInterator<T>,
n: number
): T[];

39
backend/node_modules/obliterator/take-into.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/* eslint no-constant-condition: 0 */
/**
* Obliterator Take Into Function
* ===============================
*
* Same as the take function but enables the user to select an array class
* in which to insert the retrieved values.
*/
var iter = require('./iter.js');
/**
* Take Into.
*
* @param {function} ArrayClass - Array class to use.
* @param {Iterable} iterable - Target iterable.
* @param {number} n - Number of items to take.
* @return {array}
*/
module.exports = function takeInto(ArrayClass, iterable, n) {
var array = new ArrayClass(n),
step,
i = 0;
var iterator = iter(iterable);
while (true) {
if (i === n) return array;
step = iterator.next();
if (step.done) {
if (i !== n) return array.slice(0, i);
return array;
}
array[i++] = step.value;
}
};

6
backend/node_modules/obliterator/take.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import type {IntoInterator} from './types';
export default function take<T>(
iterator: IntoInterator<T>,
n: number
): Array<T>;

39
backend/node_modules/obliterator/take.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
/* eslint no-constant-condition: 0 */
/**
* Obliterator Take Function
* ==========================
*
* Function taking n or every value of the given iterator and returns them
* into an array.
*/
var iter = require('./iter.js');
/**
* Take.
*
* @param {Iterable} iterable - Target iterable.
* @param {number} [n] - Optional number of items to take.
* @return {array}
*/
module.exports = function take(iterable, n) {
var l = arguments.length > 1 ? n : Infinity,
array = l !== Infinity ? new Array(l) : [],
step,
i = 0;
var iterator = iter(iterable);
while (true) {
if (i === l) return array;
step = iterator.next();
if (step.done) {
if (i !== n) array.length = i;
return array;
}
array[i++] = step.value;
}
};

18
backend/node_modules/obliterator/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
export interface Sequence<T> {
length: number;
slice(from: number, to?: number): Sequence<T>;
[index: number]: T;
}
export interface Mapping<K, V> {
has(key: K): boolean;
get(key: K): V | undefined;
forEach(callback: (value: V, key: K) => void): void;
}
export type AnyMapping<K, V> = K extends keyof any
? Record<K, V> | Mapping<K, V>
: Mapping<K, V>;
export type IntoInterator<T> = Iterable<T> | Iterator<T> | Sequence<T>;
export type IntoEntriesIterator<K, V> = IntoInterator<[K, V]>;