}
+ {...props}
+ />
+))(({ theme }) => ({
+ "& .MuiFilledInput-root": {
+ overflow: "hidden",
+ borderRadius: 4,
+ backgroundColor: "#577ba840",
+ border: "1px solid",
+ borderColor: "#577ba840",
+ transition: theme.transitions.create([
+ "border-color",
+ "background-color",
+ "box-shadow",
+ ]),
+ "&:hover": {
+ backgroundColor: "#577ba840",
+ },
+ "&.Mui-focused": {
+ backgroundColor: "#AFCOD5",
+ borderColor: "#577ba840",
+ color: "info",
+ },
+ },
+}));
const SearchSidebar = (props: SearchSidebarProps) => {
const { listComponent: ListComponent, id, height } = props;
const [searchQuery, setSearchQuery] = useState("");
const intl = useIntl();
return (
-
-
+ {/* {
fullWidth
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
+ /> */}
+ setSearchQuery(e.target.value)}
+ value={searchQuery}
+ fullWidth
+ label={intl.formatMessage({
+ id: "search",
+ defaultMessage: "Search",
+ })}
+ color="info"
+ type="search"
/>
diff --git a/typescript/Frontend/src/components/Users/AddUser.tsx b/typescript/Frontend/src/components/Users/AddUser.tsx
index dffae42d1..cf4094d2e 100644
--- a/typescript/Frontend/src/components/Users/AddUser.tsx
+++ b/typescript/Frontend/src/components/Users/AddUser.tsx
@@ -1,4 +1,4 @@
-import { Dialog, DialogTitle, IconButton, DialogContent } from "@mui/material";
+import { Dialog, DialogTitle, IconButton, DialogContent, colors } from "@mui/material";
import { useState } from "react";
import { FormattedMessage, useIntl } from "react-intl";
import axiosConfig from "../../config/axiosConfig";
@@ -24,7 +24,7 @@ const AddUser = () => {
<>
setOpen(true)}
>
diff --git a/typescript/Frontend/src/components/Users/User.tsx b/typescript/Frontend/src/components/Users/User.tsx
index 7c6e3ee8d..3af824b3d 100644
--- a/typescript/Frontend/src/components/Users/User.tsx
+++ b/typescript/Frontend/src/components/Users/User.tsx
@@ -42,7 +42,22 @@ const Detail = (props: I_DetailProps) => {
if (values && values.id && values.id.toString() === id) {
return (
-
+
);
@@ -51,7 +66,7 @@ const Detail = (props: I_DetailProps) => {
-
+
);
} else if (error) {
diff --git a/typescript/Frontend/src/components/Users/UserForm.tsx b/typescript/Frontend/src/components/Users/UserForm.tsx
index d7ab9f5ec..7c1105f97 100644
--- a/typescript/Frontend/src/components/Users/UserForm.tsx
+++ b/typescript/Frontend/src/components/Users/UserForm.tsx
@@ -88,7 +88,7 @@ const UserForm = (props: I_UserFormProps) => {
disabled={readOnly}
/>
- {loading && }
+ {loading && }
{currentUser.hasWriteAccess && (
diff --git a/typescript/Frontend/src/components/Users/UserList.tsx b/typescript/Frontend/src/components/Users/UserList.tsx
index 8f4be25ec..17c4f9804 100644
--- a/typescript/Frontend/src/components/Users/UserList.tsx
+++ b/typescript/Frontend/src/components/Users/UserList.tsx
@@ -60,6 +60,20 @@ const UserList = (props: UserListProps) => {
>
diff --git a/typescript/Frontend/src/components/Users/UserTabs.tsx b/typescript/Frontend/src/components/Users/UserTabs.tsx
index d3d6f6ff1..16d84292c 100644
--- a/typescript/Frontend/src/components/Users/UserTabs.tsx
+++ b/typescript/Frontend/src/components/Users/UserTabs.tsx
@@ -3,7 +3,11 @@ import { Link } from "react-router-dom";
import routes from "../../routes.json";
import useRouteMatch from "../../hooks/useRouteMatch";
import { useIntl } from "react-intl";
-import { AntTabs, StyledTab } from "../../util/installation.util";
+import {
+ AntTabs,
+ StyledTab,
+ StyledTabBlue,
+} from "../../util/installation.util";
const UserTabs = () => {
const routeMatch = useRouteMatch([routes.users + routes.user + ":id"]);
@@ -21,7 +25,7 @@ const UserTabs = () => {
defaultMessage: "user tabs",
})}
>
- {
{getCurrentUser().hasWriteAccess && }
-
+
diff --git a/typescript/Frontend/src/index.css b/typescript/Frontend/src/index.css
index ec2585e8c..037bdfc79 100644
--- a/typescript/Frontend/src/index.css
+++ b/typescript/Frontend/src/index.css
@@ -11,3 +11,8 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
+body {
+
+ background-color: #F2F4F8;
+
+ }
\ No newline at end of file
diff --git a/typescript/Frontend/src/index.tsx b/typescript/Frontend/src/index.tsx
index 262364be0..044ccdf63 100644
--- a/typescript/Frontend/src/index.tsx
+++ b/typescript/Frontend/src/index.tsx
@@ -12,14 +12,21 @@ const root = ReactDOM.createRoot(
const theme = createTheme({
palette: {
- primary: {
- main: "#F59100",
- },
text: {
- primary: "#000000",
+ primary: "#2b3e54",
secondary: "#000000",
disabled: "#000000",
},
+ secondary: {
+ main: "#90A7C5",
+ dark: "#CCD6E4",
+ },
+ info: {
+ main: "#2b3e54",
+ },
+ warning: {
+ main: "#90a7c5",
+ },
},
typography: {
fontFamily: `"Ubuntu", sans-serif`,
@@ -28,13 +35,11 @@ const theme = createTheme({
});
root.render(
-
-
-
-
-
-
-
+
+
+
+
+
);
// If you want to start measuring performance in your app, pass a function
diff --git a/typescript/Frontend/src/resources/innovenergy_Logo_onOrange-2.png(1).png b/typescript/Frontend/src/resources/innovenergy_Logo_onOrange-2.png(1).png
new file mode 100644
index 000000000..57ee2dc8e
Binary files /dev/null and b/typescript/Frontend/src/resources/innovenergy_Logo_onOrange-2.png(1).png differ
diff --git a/typescript/Frontend/src/resources/innovenergy_Logo_onOrange-2.png.png b/typescript/Frontend/src/resources/innovenergy_Logo_onOrange-2.png.png
new file mode 100644
index 000000000..386f16e40
Binary files /dev/null and b/typescript/Frontend/src/resources/innovenergy_Logo_onOrange-2.png.png differ
diff --git a/typescript/Frontend/src/util/installation.util.tsx b/typescript/Frontend/src/util/installation.util.tsx
index 648393443..2f3c5d13b 100644
--- a/typescript/Frontend/src/util/installation.util.tsx
+++ b/typescript/Frontend/src/util/installation.util.tsx
@@ -3,30 +3,115 @@ import { styled, Tab, Tabs } from "@mui/material";
export const StyledTab = styled((props: any) => (
))(({ theme }) => ({
+ bottom: -1,
textTransform: "uppercase",
fontWeight: theme.typography.fontWeightRegular,
fontSize: theme.typography.pxToRem(14),
marginRight: theme.spacing(1),
background: "0 0",
border: "1px solid transparent",
- borderTopLeftRadius: "0.25rem",
- borderTopRightRadius: "0.25rem",
+ borderTopLeftRadius: "0.3rem",
+ borderTopRightRadius: "0.3rem",
padding: ".5rem 1rem",
textDecoration: "none",
transition: `color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out`,
"&.Mui-selected": {
color: "#000000",
- backgroundColor: "#fff",
- borderColor: "#bdbdbd #bdbdbd #fff",
- marginBottom: "-3px",
+ backgroundColor: "#F2F4F8",
+ borderColor: "#90A7c5 #90A7c5 #F2F4F8",
+ marginTop: "1px",
+ bottom: -1,
},
"&.Mui-focusVisible": {
backgroundColor: "rgba(100, 95, 228, 0.32)",
},
}));
-export const AntTabs = styled(Tabs)({
- borderBottom: "1px solid #bdbdbd",
+export const StyledTabBlue = styled((props: any) => (
+
+))(({ theme }) => ({
+ bottom: -1,
+ textTransform: "uppercase",
+ fontWeight: theme.typography.fontWeightRegular,
+ fontSize: theme.typography.pxToRem(14),
+ marginRight: theme.spacing(1),
+ background: "0 0",
+ border: "1px solid transparent",
+ borderBottom: "0px",
+ borderTopLeftRadius: "0.3rem",
+ borderTopRightRadius: "0.3rem",
+ padding: ".5rem 1rem",
+ textDecoration: "none",
+ transition: `color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out`,
+ "&.Mui-selected": {
+ bottom: -1,
+ color: "#000000",
+ backgroundColor: "#CCD6E4",
+ borderColor: "#90A7c5 #90A7c5 #CCD6E4",
+ marginTop: "1px",
+ },
+ "&.Mui-focusVisible": {
+ backgroundColor: "rgba(100, 95, 228, 0.32)",
+ },
+}));
+
+export const StyledTabBig = styled((props: any) => (
+
+))(({ theme }) => ({
+ bottom: -2,
+
+ textTransform: "uppercase",
+ fontWeight: theme.typography.fontWeightRegular,
+ fontSize: theme.typography.pxToRem(14),
+ marginRight: theme.spacing(1),
+ background: "0 0",
+ border: "2px solid transparent",
+ borderTopLeftRadius: "0.3rem",
+ borderTopRightRadius: "0.3rem",
+ padding: ".5rem 1rem",
+ textDecoration: "none",
+ transition: `color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out`,
+ "&.Mui-selected": {
+ color: "#000000",
+ backgroundColor: "#F2F4F8",
+ borderColor: "#90A7c5 #90A7c5 #F2F4F8",
+ marginTop: "1px",
+ bottom: -2,
+ },
+ "&.Mui-focusVisible": {
+ backgroundColor: "rgba(100, 95, 228, 0.32)",
+ },
+}));
+
+export const StyledTabWhite = styled((props: any) => (
+
+))(({ theme }) => ({
+ bottom: -1,
+ textTransform: "uppercase",
+ fontWeight: theme.typography.fontWeightRegular,
+ fontSize: theme.typography.pxToRem(14),
+ marginRight: theme.spacing(1),
+ background: "0 0",
+ border: "1px solid transparent",
+ borderTopLeftRadius: "0.3rem",
+ borderTopRightRadius: "0.3rem",
+ padding: ".5rem 1rem",
+ textDecoration: "none",
+ transition: `color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out`,
+ "&.Mui-selected": {
+ color: "#000000",
+ backgroundColor: "White",
+ borderColor: "#90A7c5 #90A7c5 White",
+ marginTop: "1px",
+ bottom: -1,
+ },
+ "&.Mui-focusVisible": {
+ backgroundColor: "rgba(100, 95, 228, 0.32)",
+ },
+}));
+
+export const AntTabsBig = styled(Tabs)({
+ borderBottom: "2px solid #90A7c5",
overflow: "visible!important",
"& div.MuiTabs-scroller": {
overflow: "visible!important",
@@ -34,7 +119,28 @@ export const AntTabs = styled(Tabs)({
"&.Mui-selected": {
color: "#000000",
backgroundColor: "red",
- borderColor: `#bdbdbd #bdbdbd #fff`,
+ borderColor: `#90A7c5 #90A7c5 #fff`,
+ },
+ "& .MuiTabs-indicator": {
+ display: "flex",
+ justifyContent: "center",
+ backgroundColor: "transparent",
+ },
+ "&.MuiTabs-root": {
+ width: "100%",
+ },
+});
+
+export const AntTabs = styled(Tabs)({
+ borderBottom: "1px solid #90A7c5",
+ overflow: "visible!important",
+ "& div.MuiTabs-scroller": {
+ overflow: "visible!important",
+ },
+ "&.Mui-selected": {
+ color: "#000000",
+ backgroundColor: "red",
+ borderColor: `#90A7c5 #90A7c5 #fff`,
},
"& .MuiTabs-indicator": {
display: "flex",
diff --git a/typescript/Web/dist/server.js.map b/typescript/Web/dist/server.js.map
new file mode 100644
index 000000000..8779047ad
--- /dev/null
+++ b/typescript/Web/dist/server.js.map
@@ -0,0 +1,7 @@
+{
+ "version": 3,
+ "sources": ["../node_modules/linq-to-typescript/esm/types/index.js", "../node_modules/linq-to-typescript/esm/shared/ArgumentOutOfRangeException.js", "../node_modules/linq-to-typescript/esm/shared/EqualityComparer.js", "../node_modules/linq-to-typescript/esm/shared/ErrorString.js", "../node_modules/linq-to-typescript/esm/shared/InvalidOperationException.js", "../node_modules/linq-to-typescript/esm/shared/NumberComparer.js", "../node_modules/linq-to-typescript/esm/shared/StrictEqualityComparer.js", "../node_modules/linq-to-typescript/esm/shared/StringifyComparer.js", "../node_modules/linq-to-typescript/esm/shared/index.js", "../node_modules/linq-to-typescript/esm/sync/ArrayEnumerable.js", "../node_modules/linq-to-typescript/esm/async/BasicAsyncEnumerable.js", "../node_modules/linq-to-typescript/esm/parallel/BasicParallelEnumerable.js", "../node_modules/linq-to-typescript/esm/sync/BasicEnumerable.js", "../node_modules/linq-to-typescript/esm/initializer/bindArray.js", "../node_modules/linq-to-typescript/esm/initializer/bindArrayEnumerable.js", "../node_modules/linq-to-typescript/esm/sync/_private/aggregate.js", "../node_modules/linq-to-typescript/esm/sync/_private/all.js", "../node_modules/linq-to-typescript/esm/sync/_private/allAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/any.js", "../node_modules/linq-to-typescript/esm/sync/_private/anyAsync.js", "../node_modules/linq-to-typescript/esm/async/static/fromAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/asAsync.js", "../node_modules/linq-to-typescript/esm/parallel/static/fromParallel.js", "../node_modules/linq-to-typescript/esm/sync/_private/asParallel.js", "../node_modules/linq-to-typescript/esm/sync/_private/average.js", "../node_modules/linq-to-typescript/esm/sync/_private/averageAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/chunk.js", "../node_modules/linq-to-typescript/esm/sync/_private/concatenate.js", "../node_modules/linq-to-typescript/esm/sync/_private/contains.js", "../node_modules/linq-to-typescript/esm/sync/_private/containsAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/count.js", "../node_modules/linq-to-typescript/esm/sync/_private/countAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/defaultIfEmpty.js", "../node_modules/linq-to-typescript/esm/sync/_private/distinct.js", "../node_modules/linq-to-typescript/esm/sync/_private/distinctAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/each.js", "../node_modules/linq-to-typescript/esm/sync/_private/eachAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/elementAt.js", "../node_modules/linq-to-typescript/esm/sync/_private/elementAtOrDefault.js", "../node_modules/linq-to-typescript/esm/sync/_private/except.js", "../node_modules/linq-to-typescript/esm/sync/_private/exceptAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/first.js", "../node_modules/linq-to-typescript/esm/sync/_private/firstAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/firstOrDefault.js", "../node_modules/linq-to-typescript/esm/sync/_private/firstOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/sync/Grouping.js", "../node_modules/linq-to-typescript/esm/sync/_private/groupByShared.js", "../node_modules/linq-to-typescript/esm/sync/_private/groupBy.js", "../node_modules/linq-to-typescript/esm/sync/_private/groupByAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/groupByWithSel.js", "../node_modules/linq-to-typescript/esm/sync/_private/groupJoin.js", "../node_modules/linq-to-typescript/esm/sync/_private/groupJoinAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/intersect.js", "../node_modules/linq-to-typescript/esm/sync/_private/intersectAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/join.js", "../node_modules/linq-to-typescript/esm/sync/_private/last.js", "../node_modules/linq-to-typescript/esm/sync/_private/lastAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/lastOrDefault.js", "../node_modules/linq-to-typescript/esm/sync/_private/lastOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/max.js", "../node_modules/linq-to-typescript/esm/sync/_private/maxAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/min.js", "../node_modules/linq-to-typescript/esm/sync/_private/minAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/ofType.js", "../node_modules/linq-to-typescript/esm/async/_ordered/asAsyncKeyMap.js", "../node_modules/linq-to-typescript/esm/async/_ordered/asAsyncSortedKeyValues.js", "../node_modules/linq-to-typescript/esm/async/_ordered/asAsyncKeyMapSync.js", "../node_modules/linq-to-typescript/esm/async/_ordered/asAsyncSortedKeyValuesSync.js", "../node_modules/linq-to-typescript/esm/async/_ordered/asKeyMap.js", "../node_modules/linq-to-typescript/esm/async/_ordered/asSortedKeyValues.js", "../node_modules/linq-to-typescript/esm/async/_ordered/asKeyMapSync.js", "../node_modules/linq-to-typescript/esm/async/_ordered/asSortedKeyValuesSync.js", "../node_modules/linq-to-typescript/esm/async/OrderedAsyncEnumerable.js", "../node_modules/linq-to-typescript/esm/sync/_ordered/asKeyMap.js", "../node_modules/linq-to-typescript/esm/sync/_ordered/asSortedKeyValues.js", "../node_modules/linq-to-typescript/esm/sync/_ordered/asKeyMapAsync.js", "../node_modules/linq-to-typescript/esm/sync/_ordered/asSortedKeyValuesAsync.js", "../node_modules/linq-to-typescript/esm/sync/OrderedEnumerable.js", "../node_modules/linq-to-typescript/esm/sync/_private/orderBy.js", "../node_modules/linq-to-typescript/esm/sync/_private/orderByAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/orderByDescending.js", "../node_modules/linq-to-typescript/esm/sync/_private/orderByDescendingAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/partition.js", "../node_modules/linq-to-typescript/esm/sync/_private/partitionAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/reverse.js", "../node_modules/linq-to-typescript/esm/sync/_private/select.js", "../node_modules/linq-to-typescript/esm/sync/_private/selectAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/selectMany.js", "../node_modules/linq-to-typescript/esm/sync/_private/selectManyAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/sequenceEquals.js", "../node_modules/linq-to-typescript/esm/sync/_private/sequenceEqualsAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/single.js", "../node_modules/linq-to-typescript/esm/sync/_private/singleAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/singleOrDefault.js", "../node_modules/linq-to-typescript/esm/sync/_private/singleOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/skip.js", "../node_modules/linq-to-typescript/esm/sync/_private/skipWhile.js", "../node_modules/linq-to-typescript/esm/sync/_private/skipWhileAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/sum.js", "../node_modules/linq-to-typescript/esm/sync/_private/sumAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/take.js", "../node_modules/linq-to-typescript/esm/sync/_private/takeWhile.js", "../node_modules/linq-to-typescript/esm/sync/_private/takeWhileAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/toArray.js", "../node_modules/linq-to-typescript/esm/sync/_private/toMap.js", "../node_modules/linq-to-typescript/esm/sync/_private/toMapAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/toObject.js", "../node_modules/linq-to-typescript/esm/sync/_private/toObjectAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/toSet.js", "../node_modules/linq-to-typescript/esm/sync/_private/union.js", "../node_modules/linq-to-typescript/esm/sync/_private/unionAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/where.js", "../node_modules/linq-to-typescript/esm/sync/_private/whereAsync.js", "../node_modules/linq-to-typescript/esm/sync/_private/zip.js", "../node_modules/linq-to-typescript/esm/sync/_private/zipAsync.js", "../node_modules/linq-to-typescript/esm/initializer/bindLinq.js", "../node_modules/linq-to-typescript/esm/async/_private/aggregate.js", "../node_modules/linq-to-typescript/esm/async/_private/all.js", "../node_modules/linq-to-typescript/esm/async/_private/allAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/any.js", "../node_modules/linq-to-typescript/esm/async/_private/anyAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/asParallel.js", "../node_modules/linq-to-typescript/esm/async/_private/average.js", "../node_modules/linq-to-typescript/esm/async/_private/averageAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/chunk.js", "../node_modules/linq-to-typescript/esm/async/_private/concatenate.js", "../node_modules/linq-to-typescript/esm/async/_private/contains.js", "../node_modules/linq-to-typescript/esm/async/_private/containsAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/count.js", "../node_modules/linq-to-typescript/esm/async/_private/countAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/defaultIfEmpty.js", "../node_modules/linq-to-typescript/esm/async/_private/distinct.js", "../node_modules/linq-to-typescript/esm/async/_private/distinctAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/each.js", "../node_modules/linq-to-typescript/esm/async/_private/eachAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/elementAt.js", "../node_modules/linq-to-typescript/esm/async/_private/elementAtOrDefault.js", "../node_modules/linq-to-typescript/esm/async/_private/except.js", "../node_modules/linq-to-typescript/esm/async/_private/exceptAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/first.js", "../node_modules/linq-to-typescript/esm/async/_private/firstAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/firstOrDefault.js", "../node_modules/linq-to-typescript/esm/async/_private/firstOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/groupBy.js", "../node_modules/linq-to-typescript/esm/async/_private/groupByAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/groupByWithSel.js", "../node_modules/linq-to-typescript/esm/async/_private/groupJoin.js", "../node_modules/linq-to-typescript/esm/async/_private/groupJoinAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/intersect.js", "../node_modules/linq-to-typescript/esm/async/_private/intersectAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/join.js", "../node_modules/linq-to-typescript/esm/async/_private/last.js", "../node_modules/linq-to-typescript/esm/async/_private/lastAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/lastOrDefault.js", "../node_modules/linq-to-typescript/esm/async/_private/lastOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/max.js", "../node_modules/linq-to-typescript/esm/async/_private/maxAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/min.js", "../node_modules/linq-to-typescript/esm/async/_private/minAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/ofType.js", "../node_modules/linq-to-typescript/esm/async/_private/orderBy.js", "../node_modules/linq-to-typescript/esm/async/_private/orderByAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/orderByDescending.js", "../node_modules/linq-to-typescript/esm/async/_private/orderByDescendingAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/partition.js", "../node_modules/linq-to-typescript/esm/async/_private/partitionAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/reverse.js", "../node_modules/linq-to-typescript/esm/async/_private/select.js", "../node_modules/linq-to-typescript/esm/async/_private/selectAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/selectMany.js", "../node_modules/linq-to-typescript/esm/async/_private/selectManyAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/sequenceEquals.js", "../node_modules/linq-to-typescript/esm/async/_private/sequenceEqualsAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/single.js", "../node_modules/linq-to-typescript/esm/async/_private/singleAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/singleOrDefault.js", "../node_modules/linq-to-typescript/esm/async/_private/singleOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/skip.js", "../node_modules/linq-to-typescript/esm/async/_private/skipWhile.js", "../node_modules/linq-to-typescript/esm/async/_private/skipWhileAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/sum.js", "../node_modules/linq-to-typescript/esm/async/_private/sumAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/take.js", "../node_modules/linq-to-typescript/esm/async/_private/takeWhile.js", "../node_modules/linq-to-typescript/esm/async/_private/takeWhileAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/toArray.js", "../node_modules/linq-to-typescript/esm/async/_private/toMap.js", "../node_modules/linq-to-typescript/esm/async/_private/toMapAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/toObject.js", "../node_modules/linq-to-typescript/esm/async/_private/toObjectAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/toSet.js", "../node_modules/linq-to-typescript/esm/async/_private/union.js", "../node_modules/linq-to-typescript/esm/async/_private/unionAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/where.js", "../node_modules/linq-to-typescript/esm/async/_private/whereAsync.js", "../node_modules/linq-to-typescript/esm/async/_private/zip.js", "../node_modules/linq-to-typescript/esm/async/_private/zipAsync.js", "../node_modules/linq-to-typescript/esm/initializer/bindLinqAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/aggregate.js", "../node_modules/linq-to-typescript/esm/parallel/_private/_nextIteration.js", "../node_modules/linq-to-typescript/esm/parallel/_private/all.js", "../node_modules/linq-to-typescript/esm/parallel/_private/_nextIterationAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/allAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/any.js", "../node_modules/linq-to-typescript/esm/parallel/_private/anyAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/asAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/_typeDataToArray.js", "../node_modules/linq-to-typescript/esm/parallel/_private/average.js", "../node_modules/linq-to-typescript/esm/parallel/_private/averageAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/chunk.js", "../node_modules/linq-to-typescript/esm/parallel/_private/concatenate.js", "../node_modules/linq-to-typescript/esm/parallel/_private/contains.js", "../node_modules/linq-to-typescript/esm/parallel/_private/containsAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/count.js", "../node_modules/linq-to-typescript/esm/parallel/_private/countAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/defaultIfEmpty.js", "../node_modules/linq-to-typescript/esm/parallel/_private/distinct.js", "../node_modules/linq-to-typescript/esm/parallel/_private/distinctAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/each.js", "../node_modules/linq-to-typescript/esm/parallel/_private/eachAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/elementAt.js", "../node_modules/linq-to-typescript/esm/parallel/_private/elementAtOrDefault.js", "../node_modules/linq-to-typescript/esm/parallel/_private/except.js", "../node_modules/linq-to-typescript/esm/parallel/_private/exceptAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/toArray.js", "../node_modules/linq-to-typescript/esm/parallel/_private/first.js", "../node_modules/linq-to-typescript/esm/parallel/_private/firstAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/firstOrDefault.js", "../node_modules/linq-to-typescript/esm/parallel/_private/firstOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/groupBy.js", "../node_modules/linq-to-typescript/esm/parallel/_private/groupByAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/groupByWithSel.js", "../node_modules/linq-to-typescript/esm/parallel/_private/groupJoin.js", "../node_modules/linq-to-typescript/esm/parallel/_private/groupJoinAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/intersect.js", "../node_modules/linq-to-typescript/esm/parallel/_private/intersectAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/join.js", "../node_modules/linq-to-typescript/esm/parallel/_private/last.js", "../node_modules/linq-to-typescript/esm/parallel/_private/lastAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/lastOrDefault.js", "../node_modules/linq-to-typescript/esm/parallel/_private/lastOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/max.js", "../node_modules/linq-to-typescript/esm/parallel/_private/maxAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/min.js", "../node_modules/linq-to-typescript/esm/parallel/_private/minAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/ofType.js", "../node_modules/linq-to-typescript/esm/parallel/_ordered/asAsyncKeyMap.js", "../node_modules/linq-to-typescript/esm/parallel/_ordered/asAsyncSortedKeyValues.js", "../node_modules/linq-to-typescript/esm/parallel/_ordered/asAsyncKeyMapSync.js", "../node_modules/linq-to-typescript/esm/parallel/_ordered/asAsyncSortedKeyValuesSync.js", "../node_modules/linq-to-typescript/esm/parallel/_ordered/asKeyMap.js", "../node_modules/linq-to-typescript/esm/parallel/_ordered/asSortedKeyValues.js", "../node_modules/linq-to-typescript/esm/parallel/_ordered/asKeyMapSync.js", "../node_modules/linq-to-typescript/esm/parallel/_ordered/asSortedKeyValuesSync.js", "../node_modules/linq-to-typescript/esm/parallel/OrderedParallelEnumerable.js", "../node_modules/linq-to-typescript/esm/parallel/_private/orderBy.js", "../node_modules/linq-to-typescript/esm/parallel/_private/orderByAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/orderByDescending.js", "../node_modules/linq-to-typescript/esm/parallel/_private/orderByDescendingAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/partition.js", "../node_modules/linq-to-typescript/esm/parallel/_private/partitionAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/reverse.js", "../node_modules/linq-to-typescript/esm/parallel/_private/_nextIterationWithIndex.js", "../node_modules/linq-to-typescript/esm/parallel/_private/select.js", "../node_modules/linq-to-typescript/esm/parallel/_private/_nextIterationWithIndexAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/selectAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/selectMany.js", "../node_modules/linq-to-typescript/esm/parallel/_private/selectManyAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/sequenceEquals.js", "../node_modules/linq-to-typescript/esm/parallel/_private/sequenceEqualsAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/single.js", "../node_modules/linq-to-typescript/esm/parallel/_private/singleAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/singleOrDefault.js", "../node_modules/linq-to-typescript/esm/parallel/_private/singleOrDefaultAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/skip.js", "../node_modules/linq-to-typescript/esm/parallel/_private/skipWhile.js", "../node_modules/linq-to-typescript/esm/parallel/_private/skipWhileAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/sum.js", "../node_modules/linq-to-typescript/esm/parallel/_private/sumAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/take.js", "../node_modules/linq-to-typescript/esm/parallel/_private/takeWhile.js", "../node_modules/linq-to-typescript/esm/parallel/_private/takeWhileAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/toMap.js", "../node_modules/linq-to-typescript/esm/parallel/_private/toMapAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/toObject.js", "../node_modules/linq-to-typescript/esm/parallel/_private/toObjectAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/toSet.js", "../node_modules/linq-to-typescript/esm/parallel/_private/union.js", "../node_modules/linq-to-typescript/esm/parallel/_private/unionAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/where.js", "../node_modules/linq-to-typescript/esm/parallel/_private/whereAsync.js", "../node_modules/linq-to-typescript/esm/parallel/_private/zip.js", "../node_modules/linq-to-typescript/esm/parallel/_private/zipAsync.js", "../node_modules/linq-to-typescript/esm/initializer/bindLinqParallel.js", "../node_modules/linq-to-typescript/esm/initializer/bindString.js", "../node_modules/linq-to-typescript/esm/initializer/initializeLinq.js", "../node_modules/linq-to-typescript/esm/initializer/initializer.js", "../node_modules/linq-to-typescript/esm/sync/static/empty.js", "../node_modules/linq-to-typescript/esm/sync/static/enumerateObject.js", "../node_modules/linq-to-typescript/esm/sync/static/flatten.js", "../node_modules/linq-to-typescript/esm/sync/static/from.js", "../node_modules/linq-to-typescript/esm/sync/static/range.js", "../node_modules/linq-to-typescript/esm/sync/static/repeat.js", "../node_modules/linq-to-typescript/esm/sync/static/index.js", "../node_modules/linq-to-typescript/esm/async/static/emptyAsync.js", "../node_modules/linq-to-typescript/esm/async/static/enumerateObjectAsync.js", "../node_modules/linq-to-typescript/esm/async/static/flattenAsync.js", "../node_modules/linq-to-typescript/esm/async/static/rangeAsync.js", "../node_modules/linq-to-typescript/esm/async/static/repeatAsync.js", "../node_modules/linq-to-typescript/esm/async/static/index.js", "../node_modules/linq-to-typescript/esm/parallel/static/emptyParallel.js", "../node_modules/linq-to-typescript/esm/parallel/static/flattenParallel.js", "../node_modules/linq-to-typescript/esm/parallel/static/rangeParallel.js", "../node_modules/linq-to-typescript/esm/parallel/static/repeatParallel.js", "../node_modules/linq-to-typescript/esm/parallel/static/index.js", "../node_modules/linq-to-typescript/esm/sync/isEnumerable.js", "../node_modules/linq-to-typescript/esm/parallel/isParallelEnumerable.js", "../node_modules/linq-to-typescript/esm/async/isAsyncEnumerable.js", "../node_modules/linq-to-typescript/esm/index.js", "../src/utils/linq.ts", "../node_modules/rxjs/src/internal/util/isFunction.ts", "../node_modules/rxjs/src/internal/util/createErrorClass.ts", "../node_modules/rxjs/src/internal/util/UnsubscriptionError.ts", "../node_modules/rxjs/src/internal/util/arrRemove.ts", "../node_modules/rxjs/src/internal/Subscription.ts", "../node_modules/rxjs/src/internal/config.ts", "../node_modules/rxjs/src/internal/scheduler/timeoutProvider.ts", "../node_modules/rxjs/src/internal/util/reportUnhandledError.ts", "../node_modules/rxjs/src/internal/util/noop.ts", "../node_modules/rxjs/src/internal/NotificationFactories.ts", "../node_modules/rxjs/src/internal/util/errorContext.ts", "../node_modules/rxjs/src/internal/Subscriber.ts", "../node_modules/rxjs/src/internal/symbol/observable.ts", "../node_modules/rxjs/src/internal/util/identity.ts", "../node_modules/rxjs/src/internal/util/pipe.ts", "../node_modules/rxjs/src/internal/Observable.ts", "../node_modules/rxjs/src/internal/util/lift.ts", "../node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts", "../node_modules/rxjs/src/internal/operators/refCount.ts", "../node_modules/rxjs/src/internal/observable/ConnectableObservable.ts", "../node_modules/rxjs/src/internal/scheduler/performanceTimestampProvider.ts", "../node_modules/rxjs/src/internal/scheduler/animationFrameProvider.ts", "../node_modules/rxjs/src/internal/observable/dom/animationFrames.ts", "../node_modules/rxjs/src/internal/util/ObjectUnsubscribedError.ts", "../node_modules/rxjs/src/internal/Subject.ts", "../node_modules/rxjs/src/internal/BehaviorSubject.ts", "../node_modules/rxjs/src/internal/scheduler/dateTimestampProvider.ts", "../node_modules/rxjs/src/internal/ReplaySubject.ts", "../node_modules/rxjs/src/internal/AsyncSubject.ts", "../node_modules/rxjs/src/internal/scheduler/Action.ts", "../node_modules/rxjs/src/internal/scheduler/intervalProvider.ts", "../node_modules/rxjs/src/internal/scheduler/AsyncAction.ts", "../node_modules/rxjs/src/internal/util/Immediate.ts", "../node_modules/rxjs/src/internal/scheduler/immediateProvider.ts", "../node_modules/rxjs/src/internal/scheduler/AsapAction.ts", "../node_modules/rxjs/src/internal/Scheduler.ts", "../node_modules/rxjs/src/internal/scheduler/AsyncScheduler.ts", "../node_modules/rxjs/src/internal/scheduler/AsapScheduler.ts", "../node_modules/rxjs/src/internal/scheduler/asap.ts", "../node_modules/rxjs/src/internal/scheduler/async.ts", "../node_modules/rxjs/src/internal/scheduler/QueueAction.ts", "../node_modules/rxjs/src/internal/scheduler/QueueScheduler.ts", "../node_modules/rxjs/src/internal/scheduler/queue.ts", "../node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts", "../node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts", "../node_modules/rxjs/src/internal/scheduler/animationFrame.ts", "../node_modules/rxjs/src/internal/scheduler/VirtualTimeScheduler.ts", "../node_modules/rxjs/src/internal/observable/empty.ts", "../node_modules/rxjs/src/internal/util/isScheduler.ts", "../node_modules/rxjs/src/internal/util/args.ts", "../node_modules/rxjs/src/internal/util/isArrayLike.ts", "../node_modules/rxjs/src/internal/util/isPromise.ts", "../node_modules/rxjs/src/internal/util/isInteropObservable.ts", "../node_modules/rxjs/src/internal/util/isAsyncIterable.ts", "../node_modules/rxjs/src/internal/util/throwUnobservableError.ts", "../node_modules/rxjs/src/internal/symbol/iterator.ts", "../node_modules/rxjs/src/internal/util/isIterable.ts", "../node_modules/rxjs/src/internal/util/isReadableStreamLike.ts", "../node_modules/rxjs/src/internal/observable/innerFrom.ts", "../node_modules/rxjs/src/internal/util/executeSchedule.ts", "../node_modules/rxjs/src/internal/operators/observeOn.ts", "../node_modules/rxjs/src/internal/operators/subscribeOn.ts", "../node_modules/rxjs/src/internal/scheduled/scheduleObservable.ts", "../node_modules/rxjs/src/internal/scheduled/schedulePromise.ts", "../node_modules/rxjs/src/internal/scheduled/scheduleArray.ts", "../node_modules/rxjs/src/internal/scheduled/scheduleIterable.ts", "../node_modules/rxjs/src/internal/scheduled/scheduleAsyncIterable.ts", "../node_modules/rxjs/src/internal/scheduled/scheduleReadableStreamLike.ts", "../node_modules/rxjs/src/internal/scheduled/scheduled.ts", "../node_modules/rxjs/src/internal/observable/from.ts", "../node_modules/rxjs/src/internal/observable/of.ts", "../node_modules/rxjs/src/internal/observable/throwError.ts", "../node_modules/rxjs/src/internal/Notification.ts", "../node_modules/rxjs/src/internal/util/isObservable.ts", "../node_modules/rxjs/src/internal/util/EmptyError.ts", "../node_modules/rxjs/src/internal/lastValueFrom.ts", "../node_modules/rxjs/src/internal/firstValueFrom.ts", "../node_modules/rxjs/src/internal/util/ArgumentOutOfRangeError.ts", "../node_modules/rxjs/src/internal/util/NotFoundError.ts", "../node_modules/rxjs/src/internal/util/SequenceError.ts", "../node_modules/rxjs/src/internal/util/isDate.ts", "../node_modules/rxjs/src/internal/operators/timeout.ts", "../node_modules/rxjs/src/internal/operators/map.ts", "../node_modules/rxjs/src/internal/util/mapOneOrManyArgs.ts", "../node_modules/rxjs/src/internal/observable/bindCallbackInternals.ts", "../node_modules/rxjs/src/internal/observable/bindCallback.ts", "../node_modules/rxjs/src/internal/observable/bindNodeCallback.ts", "../node_modules/rxjs/src/internal/util/argsArgArrayOrObject.ts", "../node_modules/rxjs/src/internal/util/createObject.ts", "../node_modules/rxjs/src/internal/observable/combineLatest.ts", "../node_modules/rxjs/src/internal/operators/mergeInternals.ts", "../node_modules/rxjs/src/internal/operators/mergeMap.ts", "../node_modules/rxjs/src/internal/operators/mergeAll.ts", "../node_modules/rxjs/src/internal/operators/concatAll.ts", "../node_modules/rxjs/src/internal/observable/concat.ts", "../node_modules/rxjs/src/internal/observable/defer.ts", "../node_modules/rxjs/src/internal/observable/connectable.ts", "../node_modules/rxjs/src/internal/observable/forkJoin.ts", "../node_modules/rxjs/src/internal/observable/fromEvent.ts", "../node_modules/rxjs/src/internal/observable/fromEventPattern.ts", "../node_modules/rxjs/src/internal/observable/generate.ts", "../node_modules/rxjs/src/internal/observable/iif.ts", "../node_modules/rxjs/src/internal/observable/timer.ts", "../node_modules/rxjs/src/internal/observable/interval.ts", "../node_modules/rxjs/src/internal/observable/merge.ts", "../node_modules/rxjs/src/internal/observable/never.ts", "../node_modules/rxjs/src/internal/util/argsOrArgArray.ts", "../node_modules/rxjs/src/internal/operators/onErrorResumeNext.ts", "../node_modules/rxjs/src/internal/observable/onErrorResumeNext.ts", "../node_modules/rxjs/src/internal/observable/pairs.ts", "../node_modules/rxjs/src/internal/util/not.ts", "../node_modules/rxjs/src/internal/operators/filter.ts", "../node_modules/rxjs/src/internal/observable/partition.ts", "../node_modules/rxjs/src/internal/observable/race.ts", "../node_modules/rxjs/src/internal/observable/range.ts", "../node_modules/rxjs/src/internal/observable/using.ts", "../node_modules/rxjs/src/internal/observable/zip.ts", "../node_modules/rxjs/dist/cjs/internal/types.js", "../node_modules/rxjs/src/internal/operators/audit.ts", "../node_modules/rxjs/src/internal/operators/auditTime.ts", "../node_modules/rxjs/src/internal/operators/buffer.ts", "../node_modules/rxjs/src/internal/operators/bufferCount.ts", "../node_modules/rxjs/src/internal/operators/bufferTime.ts", "../node_modules/rxjs/src/internal/operators/bufferToggle.ts", "../node_modules/rxjs/src/internal/operators/bufferWhen.ts", "../node_modules/rxjs/src/internal/operators/catchError.ts", "../node_modules/rxjs/src/internal/operators/scanInternals.ts", "../node_modules/rxjs/src/internal/operators/reduce.ts", "../node_modules/rxjs/src/internal/operators/toArray.ts", "../node_modules/rxjs/src/internal/operators/joinAllInternals.ts", "../node_modules/rxjs/src/internal/operators/combineLatestAll.ts", "../node_modules/rxjs/src/internal/operators/combineAll.ts", "../node_modules/rxjs/src/internal/operators/combineLatest.ts", "../node_modules/rxjs/src/internal/operators/combineLatestWith.ts", "../node_modules/rxjs/src/internal/operators/concatMap.ts", "../node_modules/rxjs/src/internal/operators/concatMapTo.ts", "../node_modules/rxjs/src/internal/operators/concat.ts", "../node_modules/rxjs/src/internal/operators/concatWith.ts", "../node_modules/rxjs/src/internal/observable/fromSubscribable.ts", "../node_modules/rxjs/src/internal/operators/connect.ts", "../node_modules/rxjs/src/internal/operators/count.ts", "../node_modules/rxjs/src/internal/operators/debounce.ts", "../node_modules/rxjs/src/internal/operators/debounceTime.ts", "../node_modules/rxjs/src/internal/operators/defaultIfEmpty.ts", "../node_modules/rxjs/src/internal/operators/take.ts", "../node_modules/rxjs/src/internal/operators/ignoreElements.ts", "../node_modules/rxjs/src/internal/operators/mapTo.ts", "../node_modules/rxjs/src/internal/operators/delayWhen.ts", "../node_modules/rxjs/src/internal/operators/delay.ts", "../node_modules/rxjs/src/internal/operators/dematerialize.ts", "../node_modules/rxjs/src/internal/operators/distinct.ts", "../node_modules/rxjs/src/internal/operators/distinctUntilChanged.ts", "../node_modules/rxjs/src/internal/operators/distinctUntilKeyChanged.ts", "../node_modules/rxjs/src/internal/operators/throwIfEmpty.ts", "../node_modules/rxjs/src/internal/operators/elementAt.ts", "../node_modules/rxjs/src/internal/operators/endWith.ts", "../node_modules/rxjs/src/internal/operators/every.ts", "../node_modules/rxjs/src/internal/operators/exhaustAll.ts", "../node_modules/rxjs/src/internal/operators/exhaust.ts", "../node_modules/rxjs/src/internal/operators/exhaustMap.ts", "../node_modules/rxjs/src/internal/operators/expand.ts", "../node_modules/rxjs/src/internal/operators/finalize.ts", "../node_modules/rxjs/src/internal/operators/find.ts", "../node_modules/rxjs/src/internal/operators/findIndex.ts", "../node_modules/rxjs/src/internal/operators/first.ts", "../node_modules/rxjs/src/internal/operators/groupBy.ts", "../node_modules/rxjs/src/internal/operators/isEmpty.ts", "../node_modules/rxjs/src/internal/operators/takeLast.ts", "../node_modules/rxjs/src/internal/operators/last.ts", "../node_modules/rxjs/src/internal/operators/materialize.ts", "../node_modules/rxjs/src/internal/operators/max.ts", "../node_modules/rxjs/src/internal/operators/flatMap.ts", "../node_modules/rxjs/src/internal/operators/mergeMapTo.ts", "../node_modules/rxjs/src/internal/operators/mergeScan.ts", "../node_modules/rxjs/src/internal/operators/merge.ts", "../node_modules/rxjs/src/internal/operators/mergeWith.ts", "../node_modules/rxjs/src/internal/operators/min.ts", "../node_modules/rxjs/src/internal/operators/multicast.ts", "../node_modules/rxjs/src/internal/operators/pairwise.ts", "../node_modules/rxjs/src/internal/operators/pluck.ts", "../node_modules/rxjs/src/internal/operators/publish.ts", "../node_modules/rxjs/src/internal/operators/publishBehavior.ts", "../node_modules/rxjs/src/internal/operators/publishLast.ts", "../node_modules/rxjs/src/internal/operators/publishReplay.ts", "../node_modules/rxjs/src/internal/operators/raceWith.ts", "../node_modules/rxjs/src/internal/operators/repeat.ts", "../node_modules/rxjs/src/internal/operators/repeatWhen.ts", "../node_modules/rxjs/src/internal/operators/retry.ts", "../node_modules/rxjs/src/internal/operators/retryWhen.ts", "../node_modules/rxjs/src/internal/operators/sample.ts", "../node_modules/rxjs/src/internal/operators/sampleTime.ts", "../node_modules/rxjs/src/internal/operators/scan.ts", "../node_modules/rxjs/src/internal/operators/sequenceEqual.ts", "../node_modules/rxjs/src/internal/operators/share.ts", "../node_modules/rxjs/src/internal/operators/shareReplay.ts", "../node_modules/rxjs/src/internal/operators/single.ts", "../node_modules/rxjs/src/internal/operators/skip.ts", "../node_modules/rxjs/src/internal/operators/skipLast.ts", "../node_modules/rxjs/src/internal/operators/skipUntil.ts", "../node_modules/rxjs/src/internal/operators/skipWhile.ts", "../node_modules/rxjs/src/internal/operators/startWith.ts", "../node_modules/rxjs/src/internal/operators/switchMap.ts", "../node_modules/rxjs/src/internal/operators/switchAll.ts", "../node_modules/rxjs/src/internal/operators/switchMapTo.ts", "../node_modules/rxjs/src/internal/operators/switchScan.ts", "../node_modules/rxjs/src/internal/operators/takeUntil.ts", "../node_modules/rxjs/src/internal/operators/takeWhile.ts", "../node_modules/rxjs/src/internal/operators/tap.ts", "../node_modules/rxjs/src/internal/operators/throttle.ts", "../node_modules/rxjs/src/internal/operators/throttleTime.ts", "../node_modules/rxjs/src/internal/operators/timeInterval.ts", "../node_modules/rxjs/src/internal/operators/timeoutWith.ts", "../node_modules/rxjs/src/internal/operators/timestamp.ts", "../node_modules/rxjs/src/internal/operators/window.ts", "../node_modules/rxjs/src/internal/operators/windowCount.ts", "../node_modules/rxjs/src/internal/operators/windowTime.ts", "../node_modules/rxjs/src/internal/operators/windowToggle.ts", "../node_modules/rxjs/src/internal/operators/windowWhen.ts", "../node_modules/rxjs/src/internal/operators/withLatestFrom.ts", "../node_modules/rxjs/src/internal/operators/zipAll.ts", "../node_modules/rxjs/src/internal/operators/zip.ts", "../node_modules/rxjs/src/internal/operators/zipWith.ts", "../node_modules/rxjs/src/index.ts", "../src/server.ts", "../src/utils/logging.ts", "../src/server/utils/utils.ts", "../src/utils/maybe.ts", "../src/server/utils/mime.ts", "../src/server/utils/httpResponse.ts", "../src/utils/utils.ts", "../src/server/utils/requestUtils.ts", "../src/api/serverState.ts", "../src/utils/match.ts", "../src/server/db.ts", "../src/server/utils/fileSystem.ts", "../src/utils/utilityTypes.ts", "../src/utils/milliseconds.ts", "../src/utils/runtimeTypeChecking.ts", "../src/api/data/isA.ts", "../src/utils/tree.ts", "../src/api/data/query.ts", "../src/api/data/mutate.ts", "../src/utils/diffing.ts", "../src/api/data/types.ts"],
+ "sourcesContent": ["export {};\r\n", "export class ArgumentOutOfRangeException extends RangeError {\r\n constructor(paramName) {\r\n super(`${paramName} was out of range.` +\r\n \" Must be non-negative and less than the size of the collection.\");\r\n this.paramName = paramName;\r\n this.name = \"ArgumentOutOfRangeException\";\r\n this.stack = this.stack || (new Error()).stack;\r\n }\r\n}\r\n", "export const EqualityComparer = (x, y) => x == y;\r\n", "export const ErrorString = Object.freeze({\r\n MoreThanOneElement: \"Sequence contains more than one element\",\r\n MoreThanOneMatchingElement: \"Sequence contains more than one matching element\",\r\n NoElements: \"Sequence contains no elements\",\r\n NoMatch: \"Sequence contains no matching element\",\r\n});\r\n", "export class InvalidOperationException extends Error {\r\n constructor(message) {\r\n super(message);\r\n this.name = \"InvalidOperationException\";\r\n this.stack = this.stack || (new Error()).stack;\r\n }\r\n}\r\n", "export const NumberComparer = (x, y) => x - y;\r\n", "export const StrictEqualityComparer = (x, y) => x === y;\r\n", "export const StringifyComparer = (x, y) => JSON.stringify(x) === JSON.stringify(y);\r\n", "export { ArgumentOutOfRangeException } from \"./ArgumentOutOfRangeException.js\";\r\nexport { EqualityComparer } from \"./EqualityComparer.js\";\r\nexport { ErrorString } from \"./ErrorString.js\";\r\nexport { InvalidOperationException } from \"./InvalidOperationException.js\";\r\nexport { NumberComparer } from \"./NumberComparer.js\";\r\nexport { StrictEqualityComparer } from \"./StrictEqualityComparer.js\";\r\nexport { StringifyComparer } from \"./StringifyComparer.js\";\r\n", "export class ArrayEnumerable extends Array {\r\n}\r\n", "export class BasicAsyncEnumerable {\r\n constructor(iterator) {\r\n this.iterator = iterator;\r\n }\r\n [Symbol.asyncIterator]() {\r\n return this.iterator();\r\n }\r\n}\r\n", "export class BasicParallelEnumerable {\r\n constructor(dataFunc) {\r\n this.dataFunc = dataFunc;\r\n }\r\n [Symbol.asyncIterator]() {\r\n const { dataFunc } = this;\r\n async function* iterator() {\r\n switch (dataFunc.type) {\r\n case 1:\r\n for (const value of dataFunc.generator()) {\r\n yield value;\r\n }\r\n break;\r\n case 2:\r\n for (const value of await dataFunc.generator()) {\r\n yield value;\r\n }\r\n break;\r\n case 0:\r\n default:\r\n for (const value of await dataFunc.generator()) {\r\n yield value;\r\n }\r\n break;\r\n }\r\n }\r\n return iterator();\r\n }\r\n}\r\n", "export class BasicEnumerable {\r\n constructor(iterator) {\r\n this.iterator = iterator;\r\n }\r\n [Symbol.iterator]() {\r\n return this.iterator();\r\n }\r\n}\r\n", "import { ArrayEnumerable } from \"../sync/ArrayEnumerable.js\";\r\nexport const bindArray = (jsArray) => {\r\n var _a;\r\n const arrayEnumerablePrototype = ArrayEnumerable.prototype;\r\n const bindToPrototype = jsArray.prototype;\r\n const propertyNames = Object\r\n .getOwnPropertyNames(arrayEnumerablePrototype);\r\n for (const prop of propertyNames) {\r\n bindToPrototype[prop] = (_a = bindToPrototype[prop]) !== null && _a !== void 0 ? _a : arrayEnumerablePrototype[prop];\r\n }\r\n};\r\n", "import { ArgumentOutOfRangeException, ErrorString, InvalidOperationException } from \"../shared/index.js\";\r\nimport { ArrayEnumerable } from \"../sync/ArrayEnumerable.js\";\r\nimport { BasicEnumerable } from \"../sync/BasicEnumerable.js\";\r\nexport const bindArrayEnumerable = () => {\r\n var _a;\r\n const { prototype } = ArrayEnumerable;\r\n const propertyNames = Object.getOwnPropertyNames(BasicEnumerable.prototype);\r\n for (const prop of propertyNames) {\r\n prototype[prop] = (_a = prototype[prop]) !== null && _a !== void 0 ? _a : BasicEnumerable.prototype[prop];\r\n }\r\n prototype.all = function (predicate) {\r\n return this.every(predicate);\r\n };\r\n prototype.any = function (predicate) {\r\n if (predicate) {\r\n return this.some(predicate);\r\n }\r\n else {\r\n return this.length !== 0;\r\n }\r\n };\r\n prototype.count = function (predicate) {\r\n if (predicate) {\r\n let count = 0;\r\n for (let i = 0; i < this.length; i++) {\r\n if (predicate(this[i]) === true) {\r\n count++;\r\n }\r\n }\r\n return count;\r\n }\r\n else {\r\n return this.length;\r\n }\r\n };\r\n prototype.elementAt = function (index) {\r\n if (index < 0 || index >= this.length) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n return this[index];\r\n };\r\n prototype.elementAtOrDefault = function (index) {\r\n return this[index] || null;\r\n };\r\n prototype.first = function (predicate) {\r\n if (predicate) {\r\n const value = this.find(predicate);\r\n if (value === undefined) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n else {\r\n return value;\r\n }\r\n }\r\n else {\r\n if (this.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return this[0];\r\n }\r\n };\r\n prototype.firstOrDefault = function (predicate) {\r\n if (predicate) {\r\n const value = this.find(predicate);\r\n if (value === undefined) {\r\n return null;\r\n }\r\n else {\r\n return value;\r\n }\r\n }\r\n else {\r\n return this.length === 0 ? null : this[0];\r\n }\r\n };\r\n prototype.last = function (predicate) {\r\n if (predicate) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n const value = this[i];\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n else {\r\n if (this.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return this[this.length - 1];\r\n }\r\n };\r\n prototype.lastOrDefault = function (predicate) {\r\n if (predicate) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n const value = this[i];\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n }\r\n else {\r\n return this.length === 0 ? null : this[this.length - 1];\r\n }\r\n };\r\n prototype.max = function (selector) {\r\n if (this.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n if (selector) {\r\n let max = Number.NEGATIVE_INFINITY;\r\n for (let i = 0; i < this.length; i++) {\r\n max = Math.max(selector(this[i]), max);\r\n }\r\n return max;\r\n }\r\n else {\r\n return Math.max.apply(null, this);\r\n }\r\n };\r\n prototype.min = function (selector) {\r\n if (this.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n if (selector) {\r\n let min = Number.POSITIVE_INFINITY;\r\n for (let i = 0; i < this.length; i++) {\r\n min = Math.min(selector(this[i]), min);\r\n }\r\n return min;\r\n }\r\n else {\r\n return Math.min.apply(null, this);\r\n }\r\n };\r\n prototype.reverse = function () {\r\n Array.prototype.reverse.apply(this);\r\n return this;\r\n };\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const aggregate = (source, seedOrFunc, func, resultSelector) => {\r\n if (resultSelector) {\r\n if (!func) {\r\n throw new ReferenceError(\"TAccumulate function is undefined\");\r\n }\r\n return aggregate3(source, seedOrFunc, func, resultSelector);\r\n }\r\n else if (func) {\r\n return aggregate2(source, seedOrFunc, func);\r\n }\r\n else {\r\n return aggregate1(source, seedOrFunc);\r\n }\r\n};\r\nconst aggregate1 = (source, func) => {\r\n let aggregateValue;\r\n for (const value of source) {\r\n if (aggregateValue) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n else {\r\n aggregateValue = value;\r\n }\r\n }\r\n if (aggregateValue === undefined) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return aggregateValue;\r\n};\r\nconst aggregate2 = (source, seed, func) => {\r\n let aggregateValue = seed;\r\n for (const value of source) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n return aggregateValue;\r\n};\r\nconst aggregate3 = (source, seed, func, resultSelector) => {\r\n let aggregateValue = seed;\r\n for (const value of source) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n return resultSelector(aggregateValue);\r\n};\r\n", "export const all = (source, predicate) => {\r\n for (const item of source) {\r\n if (predicate(item) === false) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "export const allAsync = async (source, predicate) => {\r\n for (const item of source) {\r\n if (await predicate(item) === false) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "export const any = (source, predicate) => {\r\n if (predicate) {\r\n return any2(source, predicate);\r\n }\r\n else {\r\n return any1(source);\r\n }\r\n};\r\nconst any1 = (source) => {\r\n for (const _ of source) {\r\n return true;\r\n }\r\n return false;\r\n};\r\nconst any2 = (source, predicate) => {\r\n for (const item of source) {\r\n if (predicate(item) === true) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n", "export const anyAsync = async (source, predicate) => {\r\n for (const item of source) {\r\n if (await predicate(item) === true) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const fromAsync = (promisesOrIterable) => {\r\n if (Array.isArray(promisesOrIterable)) {\r\n if (promisesOrIterable.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return new BasicAsyncEnumerable(async function* () {\r\n for await (const value of promisesOrIterable) {\r\n yield value;\r\n }\r\n });\r\n }\r\n else {\r\n return new BasicAsyncEnumerable(promisesOrIterable);\r\n }\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const asAsync = (source) => {\r\n async function* generator() {\r\n for (const value of source) {\r\n yield value;\r\n }\r\n }\r\n return fromAsync(generator);\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const fromParallel = (type, generator) => {\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type,\r\n });\r\n};\r\n", "import { fromParallel } from \"../../parallel/static/fromParallel.js\";\r\nexport const asParallel = (source) => {\r\n const generator = async () => {\r\n const array = [];\r\n for (const value of source) {\r\n array.push(value);\r\n }\r\n return array;\r\n };\r\n return fromParallel(0, generator);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const average = (source, selector) => {\r\n let value = 0;\r\n let count = 0;\r\n if (selector) {\r\n for (const item of source) {\r\n value = value + selector(item);\r\n count = count + 1;\r\n }\r\n }\r\n else {\r\n for (const item of source) {\r\n value = value + item;\r\n count = count + 1;\r\n }\r\n }\r\n if (count === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return value / count;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const averageAsync = async (source, selector) => {\r\n let value = 0;\r\n let count = 0;\r\n for (const item of source) {\r\n value = value + await selector(item);\r\n count = count + 1;\r\n }\r\n if (count === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return value / count;\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nimport { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nexport const chunk = (source, size) => {\r\n if (size < 1) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n function* iterator() {\r\n let yieldChunk = [];\r\n for (const value of source) {\r\n yieldChunk.push(value);\r\n if (yieldChunk.length === size) {\r\n yield yieldChunk;\r\n yieldChunk = [];\r\n }\r\n }\r\n if (yieldChunk.length) {\r\n yield yieldChunk;\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const concatenate = (first, second) => {\r\n function* iterator() {\r\n yield* first;\r\n yield* second;\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nexport const contains = (source, value, comparer = StrictEqualityComparer) => {\r\n for (const item of source) {\r\n if (comparer(value, item)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n", "export const containsAsync = async (source, value, comparer) => {\r\n for (const item of source) {\r\n if (await comparer(value, item)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n", "export const count = (source, predicate) => {\r\n if (predicate) {\r\n return count2(source, predicate);\r\n }\r\n else {\r\n return count1(source);\r\n }\r\n};\r\nconst count1 = (source) => {\r\n let count = 0;\r\n for (const _ of source) {\r\n count++;\r\n }\r\n return count;\r\n};\r\nconst count2 = (source, predicate) => {\r\n let count = 0;\r\n for (const value of source) {\r\n if (predicate(value) === true) {\r\n count++;\r\n }\r\n }\r\n return count;\r\n};\r\n", "export const countAsync = async (source, predicate) => {\r\n let count = 0;\r\n for (const value of source) {\r\n if (await predicate(value) === true) {\r\n count++;\r\n }\r\n }\r\n return count;\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const defaultIfEmpty = (source, defaultValue) => {\r\n function* generator() {\r\n let found = false;\r\n for (const value of source) {\r\n found = true;\r\n yield value;\r\n }\r\n if (!found) {\r\n yield defaultValue;\r\n }\r\n }\r\n return new BasicEnumerable(generator);\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const distinct = (source, comparer = StrictEqualityComparer) => {\r\n function* iterator() {\r\n const distinctElements = [];\r\n for (const item of source) {\r\n const foundItem = distinctElements.find((x) => comparer(x, item));\r\n if (!foundItem) {\r\n distinctElements.push(item);\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const distinctAsync = (source, comparer) => {\r\n async function* iterator() {\r\n const distinctElements = [];\r\n outerLoop: for (const item of source) {\r\n for (const distinctElement of distinctElements) {\r\n const found = await comparer(distinctElement, item);\r\n if (found) {\r\n continue outerLoop;\r\n }\r\n }\r\n distinctElements.push(item);\r\n yield item;\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const each = (source, action) => {\r\n function* generator() {\r\n for (const value of source) {\r\n action(value);\r\n yield value;\r\n }\r\n }\r\n return new BasicEnumerable(generator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const eachAsync = (source, action) => {\r\n async function* generator() {\r\n for (const value of source) {\r\n await action(value);\r\n yield value;\r\n }\r\n }\r\n return fromAsync(generator);\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nexport const elementAt = (source, index) => {\r\n if (index < 0) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n let i = 0;\r\n for (const item of source) {\r\n if (index === i++) {\r\n return item;\r\n }\r\n }\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n};\r\n", "export const elementAtOrDefault = (source, index) => {\r\n let i = 0;\r\n for (const item of source) {\r\n if (index === i++) {\r\n return item;\r\n }\r\n }\r\n return null;\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const except = (first, second, comparer = StrictEqualityComparer) => {\r\n function* iterator() {\r\n const secondArray = [...second];\r\n for (const firstItem of first) {\r\n let exists = false;\r\n for (let j = 0; j < secondArray.length; j++) {\r\n const secondItem = secondArray[j];\r\n if (comparer(firstItem, secondItem) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n yield firstItem;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const exceptAsync = (first, second, comparer) => {\r\n async function* iterator() {\r\n const secondArray = [...second];\r\n for (const firstItem of first) {\r\n let exists = false;\r\n for (let j = 0; j < secondArray.length; j++) {\r\n const secondItem = secondArray[j];\r\n if (await comparer(firstItem, secondItem) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n yield firstItem;\r\n }\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const first = (source, predicate) => {\r\n if (predicate) {\r\n return first2(source, predicate);\r\n }\r\n else {\r\n return first1(source);\r\n }\r\n};\r\nconst first1 = (source) => {\r\n const first = source[Symbol.iterator]().next();\r\n if (first.done === true) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return first.value;\r\n};\r\nconst first2 = (source, predicate) => {\r\n for (const value of source) {\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const firstAsync = async (source, predicate) => {\r\n for (const value of source) {\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n};\r\n", "export const firstOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return firstOrDefault2(source, predicate);\r\n }\r\n else {\r\n return firstOrDefault1(source);\r\n }\r\n};\r\nconst firstOrDefault1 = (source) => {\r\n const first = source[Symbol.iterator]().next();\r\n return first.value || null;\r\n};\r\nconst firstOrDefault2 = (source, predicate) => {\r\n for (const value of source) {\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n};\r\n", "export const firstOrDefaultAsync = async (source, predicate) => {\r\n for (const value of source) {\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n};\r\n", "import { ArrayEnumerable } from \"./ArrayEnumerable.js\";\r\nexport class Grouping extends ArrayEnumerable {\r\n constructor(key, startingItem) {\r\n super(1);\r\n this.key = key;\r\n this[0] = startingItem;\r\n }\r\n}\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nimport { Grouping } from \"../Grouping.js\";\r\nexport const groupBy_0 = (source, keySelector, comparer) => {\r\n return function* generate() {\r\n const keyMap = new Array();\r\n for (const value of source) {\r\n const key = keySelector(value);\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (comparer(group.key, key)) {\r\n group.push(value);\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n keyMap.push(new Grouping(key, value));\r\n }\r\n }\r\n for (const keyValue of keyMap) {\r\n yield keyValue;\r\n }\r\n };\r\n};\r\nexport const groupBy_0_Simple = (source, keySelector) => {\r\n return function* iterator() {\r\n const keyMap = {};\r\n for (const value of source) {\r\n const key = keySelector(value);\r\n const grouping = keyMap[key];\r\n if (grouping) {\r\n grouping.push(value);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, value);\r\n }\r\n }\r\n for (const value in keyMap) {\r\n yield keyMap[value];\r\n }\r\n };\r\n};\r\nexport const groupBy_1_Simple = (source, keySelector, elementSelector) => {\r\n function* generate() {\r\n const keyMap = {};\r\n for (const value of source) {\r\n const key = keySelector(value);\r\n const grouping = keyMap[key];\r\n const element = elementSelector(value);\r\n if (grouping) {\r\n grouping.push(element);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, element);\r\n }\r\n }\r\n for (const value in keyMap) {\r\n yield keyMap[value];\r\n }\r\n }\r\n return new BasicEnumerable(generate);\r\n};\r\nexport const groupBy_1 = (source, keySelector, elementSelector, comparer) => {\r\n function* generate() {\r\n const keyMap = new Array();\r\n for (const value of source) {\r\n const key = keySelector(value);\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (comparer(group.key, key)) {\r\n group.push(elementSelector(value));\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n const element = elementSelector(value);\r\n keyMap.push(new Grouping(key, element));\r\n }\r\n }\r\n for (const keyValue of keyMap) {\r\n yield keyValue;\r\n }\r\n }\r\n return new BasicEnumerable(generate);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nimport { groupBy_0, groupBy_0_Simple } from \"./groupByShared.js\";\r\nexport const groupBy = (source, keySelector, comparer) => {\r\n let iterable;\r\n if (comparer) {\r\n iterable = groupBy_0(source, keySelector, comparer);\r\n }\r\n else {\r\n iterable = groupBy_0_Simple(source, keySelector);\r\n }\r\n return new BasicEnumerable(iterable);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nimport { Grouping } from \"../Grouping.js\";\r\nexport const groupByAsync = (source, keySelector, comparer) => {\r\n if (comparer) {\r\n return groupByAsync_0(source, keySelector, comparer);\r\n }\r\n else {\r\n return groupByAsync_0_Simple(source, keySelector);\r\n }\r\n};\r\nconst groupByAsync_0_Simple = (source, keySelector) => {\r\n async function* iterator() {\r\n const keyMap = {};\r\n for (const value of source) {\r\n const key = await keySelector(value);\r\n const grouping = keyMap[key];\r\n if (grouping) {\r\n grouping.push(value);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, value);\r\n }\r\n }\r\n for (const value in keyMap) {\r\n yield keyMap[value];\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\nconst groupByAsync_0 = (source, keySelector, comparer) => {\r\n async function* generate() {\r\n const keyMap = new Array();\r\n for (const value of source) {\r\n const key = await keySelector(value);\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (await comparer(group.key, key) === true) {\r\n group.push(value);\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n keyMap.push(new Grouping(key, value));\r\n }\r\n }\r\n for (const keyValue of keyMap) {\r\n yield keyValue;\r\n }\r\n }\r\n return fromAsync(generate);\r\n};\r\n", "import { groupBy_1, groupBy_1_Simple } from \"./groupByShared.js\";\r\nexport const groupByWithSel = (source, keySelector, elementSelector, comparer) => {\r\n if (comparer) {\r\n return groupBy_1(source, keySelector, elementSelector, comparer);\r\n }\r\n else {\r\n return groupBy_1_Simple(source, keySelector, elementSelector);\r\n }\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const groupJoin = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n const generator = comparer ?\r\n groupJoinWithComparer(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) :\r\n groupJoinSimple(outer, inner, outerKeySelector, innerKeySelector, resultSelector);\r\n return new BasicEnumerable(generator);\r\n};\r\nconst groupJoinWithComparer = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n return function* () {\r\n var _a;\r\n const innerKeyMap = [];\r\n for (const innerValue of inner) {\r\n const key = innerKeySelector(innerValue);\r\n const record = innerKeyMap.find(x => comparer(x.key, key));\r\n if (record) {\r\n record.values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.push({ key, values: [innerValue] });\r\n }\r\n }\r\n for (const outerValue of outer) {\r\n const key = outerKeySelector(outerValue);\r\n const innerRecord = (_a = innerKeyMap.find(x => comparer(x.key, key))) !== null && _a !== void 0 ? _a : { key, values: [] };\r\n yield resultSelector(outerValue, innerRecord.values);\r\n }\r\n };\r\n};\r\nconst groupJoinSimple = (outer, inner, outerKeySelector, innerKeySelector, resultSelector) => {\r\n return function* () {\r\n var _a;\r\n const innerKeyMap = new Map();\r\n for (const innerValue of inner) {\r\n const key = innerKeySelector(innerValue);\r\n const values = innerKeyMap.get(key);\r\n if (values) {\r\n values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.set(key, [innerValue]);\r\n }\r\n }\r\n for (const outerValue of outer) {\r\n const key = outerKeySelector(outerValue);\r\n const values = (_a = innerKeyMap.get(key)) !== null && _a !== void 0 ? _a : [];\r\n yield resultSelector(outerValue, values);\r\n }\r\n };\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const groupJoinAsync = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n const generator = comparer ?\r\n groupJoinWithComparer(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) :\r\n groupJoinSimple(outer, inner, outerKeySelector, innerKeySelector, resultSelector);\r\n return fromAsync(generator);\r\n};\r\nconst groupJoinWithComparer = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n return async function* () {\r\n var _a;\r\n const innerKeyMap = [];\r\n for (const innerValue of inner) {\r\n const key = await innerKeySelector(innerValue);\r\n const record = innerKeyMap.find(x => comparer(x.key, key));\r\n if (record) {\r\n record.values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.push({ key, values: [innerValue] });\r\n }\r\n }\r\n for (const outerValue of outer) {\r\n const key = await outerKeySelector(outerValue);\r\n const innerRecord = (_a = innerKeyMap.find(x => comparer(x.key, key))) !== null && _a !== void 0 ? _a : { key, values: [] };\r\n yield resultSelector(outerValue, innerRecord.values);\r\n }\r\n };\r\n};\r\nconst groupJoinSimple = (outer, inner, outerKeySelector, innerKeySelector, resultSelector) => {\r\n return async function* () {\r\n var _a;\r\n const innerKeyMap = new Map();\r\n for (const innerValue of inner) {\r\n const key = await innerKeySelector(innerValue);\r\n const values = innerKeyMap.get(key);\r\n if (values) {\r\n values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.set(key, [innerValue]);\r\n }\r\n }\r\n for (const outerValue of outer) {\r\n const key = await outerKeySelector(outerValue);\r\n const values = (_a = innerKeyMap.get(key)) !== null && _a !== void 0 ? _a : [];\r\n yield resultSelector(outerValue, values);\r\n }\r\n };\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const intersect = (first, second, comparer = StrictEqualityComparer) => {\r\n function* iterator() {\r\n const firstResults = [...first.distinct(comparer)];\r\n if (firstResults.length === 0) {\r\n return;\r\n }\r\n const secondResults = [...second];\r\n for (let i = 0; i < firstResults.length; i++) {\r\n const firstValue = firstResults[i];\r\n for (let j = 0; j < secondResults.length; j++) {\r\n const secondValue = secondResults[j];\r\n if (comparer(firstValue, secondValue) === true) {\r\n yield firstValue;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const intersectAsync = (first, second, comparer) => {\r\n async function* iterator() {\r\n const firstResults = [];\r\n for await (const item of first.distinctAsync(comparer)) {\r\n firstResults.push(item);\r\n }\r\n if (firstResults.length === 0) {\r\n return;\r\n }\r\n const secondResults = [...second];\r\n for (let i = 0; i < firstResults.length; i++) {\r\n const firstValue = firstResults[i];\r\n for (let j = 0; j < secondResults.length; j++) {\r\n const secondValue = secondResults[j];\r\n if (await comparer(firstValue, secondValue) === true) {\r\n yield firstValue;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const join = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer = StrictEqualityComparer) => {\r\n function* iterator() {\r\n const innerArray = [...inner];\r\n for (const o of outer) {\r\n const outerKey = outerKeySelector(o);\r\n for (const i of innerArray) {\r\n const innerKey = innerKeySelector(i);\r\n if (comparer(outerKey, innerKey) === true) {\r\n yield resultSelector(o, i);\r\n }\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const last = (source, predicate) => {\r\n if (predicate) {\r\n return last2(source, predicate);\r\n }\r\n else {\r\n return last1(source);\r\n }\r\n};\r\nconst last1 = (source) => {\r\n let lastItem;\r\n for (const value of source) {\r\n lastItem = value;\r\n }\r\n if (!lastItem) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return lastItem;\r\n};\r\nconst last2 = (source, predicate) => {\r\n let lastItem;\r\n for (const value of source) {\r\n if (predicate(value) === true) {\r\n lastItem = value;\r\n }\r\n }\r\n if (!lastItem) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return lastItem;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const lastAsync = async (source, predicate) => {\r\n let last;\r\n for (const value of source) {\r\n if (await predicate(value) === true) {\r\n last = value;\r\n }\r\n }\r\n if (!last) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return last;\r\n};\r\n", "export const lastOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return lastOrDefault2(source, predicate);\r\n }\r\n else {\r\n return lastOrDefault1(source);\r\n }\r\n};\r\nconst lastOrDefault1 = (source) => {\r\n let last = null;\r\n for (const value of source) {\r\n last = value;\r\n }\r\n return last;\r\n};\r\nconst lastOrDefault2 = (source, predicate) => {\r\n let last = null;\r\n for (const value of source) {\r\n if (predicate(value) === true) {\r\n last = value;\r\n }\r\n }\r\n return last;\r\n};\r\n", "export const lastOrDefaultAsync = async (source, predicate) => {\r\n let last = null;\r\n for (const value of source) {\r\n if (await predicate(value) === true) {\r\n last = value;\r\n }\r\n }\r\n return last;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const max = (source, selector) => {\r\n if (selector) {\r\n return max2(source, selector);\r\n }\r\n else {\r\n return max1(source);\r\n }\r\n};\r\nconst max1 = (source) => {\r\n let maxItem = null;\r\n for (const item of source) {\r\n maxItem = Math.max(maxItem || Number.NEGATIVE_INFINITY, item);\r\n }\r\n if (maxItem === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return maxItem;\r\n }\r\n};\r\nconst max2 = (source, selector) => {\r\n let maxItem = null;\r\n for (const item of source) {\r\n maxItem = Math.max(maxItem || Number.NEGATIVE_INFINITY, selector(item));\r\n }\r\n if (maxItem === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return maxItem;\r\n }\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const maxAsync = async (source, selector) => {\r\n let max = null;\r\n for (const item of source) {\r\n max = Math.max(max || Number.NEGATIVE_INFINITY, await selector(item));\r\n }\r\n if (max === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return max;\r\n }\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const min = (source, selector) => {\r\n if (selector) {\r\n return min2(source, selector);\r\n }\r\n else {\r\n return min1(source);\r\n }\r\n};\r\nconst min1 = (source) => {\r\n let minItem = null;\r\n for (const item of source) {\r\n minItem = Math.min(minItem || Number.POSITIVE_INFINITY, item);\r\n }\r\n if (minItem === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return minItem;\r\n }\r\n};\r\nconst min2 = (source, selector) => {\r\n let minItem = null;\r\n for (const item of source) {\r\n minItem = Math.min(minItem || Number.POSITIVE_INFINITY, selector(item));\r\n }\r\n if (minItem === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return minItem;\r\n }\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const minAsync = async (source, selector) => {\r\n let min = null;\r\n for (const item of source) {\r\n min = Math.min(min || Number.POSITIVE_INFINITY, await selector(item));\r\n }\r\n if (min === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return min;\r\n }\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const ofType = (source, type) => {\r\n const typeCheck = typeof type === \"string\" ?\r\n ((x) => typeof x === type) :\r\n ((x) => x instanceof type);\r\n function* iterator() {\r\n for (const item of source) {\r\n if (typeCheck(item)) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "export const asAsyncKeyMap = async (source, keySelector) => {\r\n const map = new Map();\r\n for await (const item of source) {\r\n const key = await keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asAsyncKeyMap } from \"./asAsyncKeyMap.js\";\r\nexport async function* asAsyncSortedKeyValues(source, keySelector, ascending, comparer) {\r\n const map = await asAsyncKeyMap(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "export const asAsyncKeyMapSync = async (source, keySelector) => {\r\n const map = new Map();\r\n for (const item of source) {\r\n const key = await keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asAsyncKeyMapSync } from \"./asAsyncKeyMapSync.js\";\r\nexport async function* asAsyncSortedKeyValuesSync(source, keySelector, ascending, comparer) {\r\n const map = await asAsyncKeyMapSync(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "export const asKeyMap = async (source, keySelector) => {\r\n const map = new Map();\r\n for await (const item of source) {\r\n const key = keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asKeyMap } from \"./asKeyMap.js\";\r\nexport async function* asSortedKeyValues(source, keySelector, ascending, comparer) {\r\n const map = await asKeyMap(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "export const asKeyMapSync = (source, keySelector) => {\r\n const map = new Map();\r\n for (const item of source) {\r\n const key = keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asKeyMapSync } from \"./asKeyMapSync.js\";\r\nexport function* asSortedKeyValuesSync(source, keySelector, ascending, comparer) {\r\n const map = asKeyMapSync(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "import { asAsyncSortedKeyValues } from \"./_ordered/asAsyncSortedKeyValues.js\";\r\nimport { asAsyncSortedKeyValuesSync } from \"./_ordered/asAsyncSortedKeyValuesSync.js\";\r\nimport { asSortedKeyValues } from \"./_ordered/asSortedKeyValues.js\";\r\nimport { asSortedKeyValuesSync } from \"./_ordered/asSortedKeyValuesSync.js\";\r\nimport { BasicAsyncEnumerable } from \"./BasicAsyncEnumerable.js\";\r\nexport class OrderedAsyncEnumerable extends BasicAsyncEnumerable {\r\n constructor(orderedPairs) {\r\n super(async function* () {\r\n for await (const orderedPair of orderedPairs()) {\r\n yield* orderedPair;\r\n }\r\n });\r\n this.orderedPairs = orderedPairs;\r\n }\r\n static generateAsync(source, keySelector, ascending, comparer) {\r\n let orderedPairs;\r\n if (source instanceof OrderedAsyncEnumerable) {\r\n orderedPairs = async function* () {\r\n for await (const pair of source.orderedPairs()) {\r\n yield* asAsyncSortedKeyValuesSync(pair, keySelector, ascending, comparer);\r\n }\r\n };\r\n }\r\n else {\r\n orderedPairs = () => asAsyncSortedKeyValues(source, keySelector, ascending, comparer);\r\n }\r\n return new OrderedAsyncEnumerable(orderedPairs);\r\n }\r\n static generate(source, keySelector, ascending, comparer) {\r\n let orderedPairs;\r\n if (source instanceof OrderedAsyncEnumerable) {\r\n orderedPairs = async function* () {\r\n for await (const pair of source.orderedPairs()) {\r\n yield* asSortedKeyValuesSync(pair, keySelector, ascending, comparer);\r\n }\r\n };\r\n }\r\n else {\r\n orderedPairs = () => asSortedKeyValues(source, keySelector, ascending, comparer);\r\n }\r\n return new OrderedAsyncEnumerable(orderedPairs);\r\n }\r\n thenBy(keySelector, comparer) {\r\n return OrderedAsyncEnumerable.generate(this, keySelector, true, comparer);\r\n }\r\n thenByAsync(keySelector, comparer) {\r\n return OrderedAsyncEnumerable.generateAsync(this, keySelector, true, comparer);\r\n }\r\n thenByDescending(keySelector, comparer) {\r\n return OrderedAsyncEnumerable.generate(this, keySelector, false, comparer);\r\n }\r\n thenByDescendingAsync(keySelector, comparer) {\r\n return OrderedAsyncEnumerable.generateAsync(this, keySelector, false, comparer);\r\n }\r\n}\r\n", "export const asKeyMap = (source, keySelector) => {\r\n const map = new Map();\r\n for (const item of source) {\r\n const key = keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asKeyMap } from \"./asKeyMap.js\";\r\nexport function* asSortedKeyValues(source, keySelector, ascending, comparer) {\r\n const map = asKeyMap(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "export const asKeyMapAsync = async (source, keySelector) => {\r\n const map = new Map();\r\n for (const item of source) {\r\n const key = await keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asKeyMapAsync } from \"./asKeyMapAsync.js\";\r\nexport async function* asSortedKeyValuesAsync(source, keySelector, ascending, comparer) {\r\n const map = await asKeyMapAsync(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "import { OrderedAsyncEnumerable } from \"../async/OrderedAsyncEnumerable.js\";\r\nimport { asSortedKeyValues } from \"./_ordered/asSortedKeyValues.js\";\r\nimport { asSortedKeyValuesAsync } from \"./_ordered/asSortedKeyValuesAsync.js\";\r\nimport { BasicEnumerable } from \"./BasicEnumerable.js\";\r\nexport class OrderedEnumerable extends BasicEnumerable {\r\n constructor(orderedPairs) {\r\n super(function* () {\r\n for (const orderedPair of orderedPairs()) {\r\n yield* orderedPair;\r\n }\r\n });\r\n this.orderedPairs = orderedPairs;\r\n }\r\n static generate(source, keySelector, ascending, comparer) {\r\n let orderedPairs;\r\n if (source instanceof OrderedEnumerable) {\r\n orderedPairs = function* () {\r\n for (const pair of source.orderedPairs()) {\r\n yield* asSortedKeyValues(pair, keySelector, ascending, comparer);\r\n }\r\n };\r\n }\r\n else {\r\n orderedPairs = () => asSortedKeyValues(source, keySelector, ascending, comparer);\r\n }\r\n return new OrderedEnumerable(orderedPairs);\r\n }\r\n static generateAsync(source, keySelector, ascending, comparer) {\r\n let orderedPairs;\r\n if (source instanceof OrderedEnumerable) {\r\n orderedPairs = async function* () {\r\n for (const pair of source.orderedPairs()) {\r\n yield* asSortedKeyValuesAsync(pair, keySelector, ascending, comparer);\r\n }\r\n };\r\n }\r\n else {\r\n orderedPairs = () => asSortedKeyValuesAsync(source, keySelector, ascending, comparer);\r\n }\r\n return new OrderedAsyncEnumerable(orderedPairs);\r\n }\r\n thenBy(keySelector, comparer) {\r\n return OrderedEnumerable.generate(this, keySelector, true, comparer);\r\n }\r\n thenByAsync(keySelector, comparer) {\r\n return OrderedEnumerable.generateAsync(this, keySelector, true, comparer);\r\n }\r\n thenByDescending(keySelector, comparer) {\r\n return OrderedEnumerable.generate(this, keySelector, false, comparer);\r\n }\r\n thenByDescendingAsync(keySelector, comparer) {\r\n return OrderedEnumerable.generateAsync(this, keySelector, false, comparer);\r\n }\r\n}\r\n", "import { OrderedEnumerable } from \"../OrderedEnumerable.js\";\r\nexport const orderBy = (source, keySelector, comparer) => {\r\n return OrderedEnumerable.generate(source, keySelector, true, comparer);\r\n};\r\n", "import { OrderedEnumerable } from \"../OrderedEnumerable.js\";\r\nexport const orderByAsync = (source, keySelector, comparer) => {\r\n return OrderedEnumerable.generateAsync(source, keySelector, true, comparer);\r\n};\r\n", "import { OrderedEnumerable } from \"../OrderedEnumerable.js\";\r\nexport const orderByDescending = (source, keySelector, comparer) => {\r\n return OrderedEnumerable.generate(source, keySelector, false, comparer);\r\n};\r\n", "import { OrderedEnumerable } from \"../OrderedEnumerable.js\";\r\nexport const orderByDescendingAsync = (source, keySelector, comparer) => {\r\n return OrderedEnumerable.generateAsync(source, keySelector, false, comparer);\r\n};\r\n", "export const partition = (source, predicate) => {\r\n const fail = [];\r\n const pass = [];\r\n for (const value of source) {\r\n if (predicate(value) === true) {\r\n pass.push(value);\r\n }\r\n else {\r\n fail.push(value);\r\n }\r\n }\r\n return [pass, fail];\r\n};\r\n", "export const partitionAsync = async (source, predicate) => {\r\n const fail = [];\r\n const pass = [];\r\n for (const value of source) {\r\n if (await predicate(value) === true) {\r\n pass.push(value);\r\n }\r\n else {\r\n fail.push(value);\r\n }\r\n }\r\n return [pass, fail];\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const reverse = (source) => {\r\n function* iterator() {\r\n const array = [...source];\r\n for (let i = array.length - 1; i >= 0; i--) {\r\n yield array[i];\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const select = (source, selector) => {\r\n if (typeof selector === \"function\") {\r\n const { length } = selector;\r\n if (length === 1) {\r\n return select1(source, selector);\r\n }\r\n else {\r\n return select2(source, selector);\r\n }\r\n }\r\n else {\r\n return select3(source, selector);\r\n }\r\n};\r\nconst select1 = (source, selector) => {\r\n function* iterator() {\r\n for (const value of source) {\r\n yield selector(value);\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst select2 = (source, selector) => {\r\n function* iterator() {\r\n let index = 0;\r\n for (const value of source) {\r\n yield selector(value, index);\r\n index++;\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst select3 = (source, key) => {\r\n function* iterator() {\r\n for (const value of source) {\r\n yield value[key];\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const selectAsync = (source, selector) => {\r\n if (typeof selector === \"function\") {\r\n if (selector.length === 1) {\r\n return selectAsync1(source, selector);\r\n }\r\n else {\r\n return selectAsync2(source, selector);\r\n }\r\n }\r\n else {\r\n return selectAsync3(source, selector);\r\n }\r\n};\r\nconst selectAsync1 = (source, selector) => {\r\n async function* iterator() {\r\n for (const value of source) {\r\n yield selector(value);\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\nconst selectAsync2 = (source, selector) => {\r\n async function* iterator() {\r\n let index = 0;\r\n for (const value of source) {\r\n yield selector(value, index);\r\n index++;\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\nconst selectAsync3 = (source, key) => {\r\n async function* iterator() {\r\n for (const value of source) {\r\n yield value[key];\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const selectMany = (source, selector) => {\r\n if (typeof selector === \"function\") {\r\n if (selector.length === 1) {\r\n return selectMany1(source, selector);\r\n }\r\n else {\r\n return selectMany2(source, selector);\r\n }\r\n }\r\n else {\r\n return selectMany3(source, selector);\r\n }\r\n};\r\nconst selectMany1 = (source, selector) => {\r\n function* iterator() {\r\n for (const value of source) {\r\n for (const selectorValue of selector(value)) {\r\n yield selectorValue;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst selectMany2 = (source, selector) => {\r\n function* iterator() {\r\n let index = 0;\r\n for (const value of source) {\r\n for (const selectorValue of selector(value, index)) {\r\n yield selectorValue;\r\n }\r\n index++;\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst selectMany3 = (source, selector) => {\r\n function* iterator() {\r\n for (const value of source) {\r\n for (const selectorValue of value[selector]) {\r\n yield selectorValue;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const selectManyAsync = (source, selector) => {\r\n if (selector.length === 1) {\r\n return selectManyAsync1(source, selector);\r\n }\r\n else {\r\n return selectManyAsync2(source, selector);\r\n }\r\n};\r\nconst selectManyAsync1 = (source, selector) => {\r\n async function* generator() {\r\n for (const value of source) {\r\n const innerValues = await selector(value);\r\n for (const innerValue of innerValues) {\r\n yield innerValue;\r\n }\r\n }\r\n }\r\n return fromAsync(generator);\r\n};\r\nconst selectManyAsync2 = (source, selector) => {\r\n async function* generator() {\r\n let index = 0;\r\n for (const value of source) {\r\n const innerValues = await selector(value, index);\r\n for (const innerValue of innerValues) {\r\n yield innerValue;\r\n }\r\n index++;\r\n }\r\n }\r\n return fromAsync(generator);\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nexport const sequenceEquals = (first, second, comparer = StrictEqualityComparer) => {\r\n const firstIterator = first[Symbol.iterator]();\r\n const secondIterator = second[Symbol.iterator]();\r\n let firstResult = firstIterator.next();\r\n let secondResult = secondIterator.next();\r\n while (!firstResult.done && !secondResult.done) {\r\n if (!comparer(firstResult.value, secondResult.value)) {\r\n return false;\r\n }\r\n firstResult = firstIterator.next();\r\n secondResult = secondIterator.next();\r\n }\r\n return firstResult.done === true && secondResult.done === true;\r\n};\r\n", "export const sequenceEqualsAsync = async (first, second, comparer) => {\r\n const firstIterator = first[Symbol.iterator]();\r\n const secondIterator = second[Symbol.iterator]();\r\n let firstResult = firstIterator.next();\r\n let secondResult = secondIterator.next();\r\n while (!firstResult.done && !secondResult.done) {\r\n if (await comparer(firstResult.value, secondResult.value) === false) {\r\n return false;\r\n }\r\n firstResult = firstIterator.next();\r\n secondResult = secondIterator.next();\r\n }\r\n return firstResult.done === true && secondResult.done === true;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const single = (source, predicate) => {\r\n if (predicate) {\r\n return single2(source, predicate);\r\n }\r\n else {\r\n return single1(source);\r\n }\r\n};\r\nconst single1 = (source) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of source) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n if (hasValue === false) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return singleValue;\r\n};\r\nconst single2 = (source, predicate) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of source) {\r\n if (predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n if (hasValue === false) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const singleAsync = async (source, predicate) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of source) {\r\n if (await predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n if (hasValue === false) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const singleOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return singleOrDefault2(source, predicate);\r\n }\r\n else {\r\n return singleOrDefault1(source);\r\n }\r\n};\r\nconst singleOrDefault1 = (source) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of source) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n return singleValue;\r\n};\r\nconst singleOrDefault2 = (source, predicate) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of source) {\r\n if (predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const singleOrDefaultAsync = async (source, predicate) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of source) {\r\n if (await predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n return singleValue;\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const skip = (source, count) => {\r\n function* iterator() {\r\n let i = 0;\r\n for (const item of source) {\r\n if (i++ >= count) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const skipWhile = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return skipWhile1(source, predicate);\r\n }\r\n else {\r\n return skipWhile2(source, predicate);\r\n }\r\n};\r\nconst skipWhile1 = (source, predicate) => {\r\n function* iterator() {\r\n let skip = true;\r\n for (const item of source) {\r\n if (skip === false) {\r\n yield item;\r\n }\r\n else if (predicate(item) === false) {\r\n skip = false;\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst skipWhile2 = (source, predicate) => {\r\n function* iterator() {\r\n let index = 0;\r\n let skip = true;\r\n for (const item of source) {\r\n if (skip === false) {\r\n yield item;\r\n }\r\n else if (predicate(item, index) === false) {\r\n skip = false;\r\n yield item;\r\n }\r\n index++;\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const skipWhileAsync = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return skipWhileAsync1(source, predicate);\r\n }\r\n else {\r\n return skipWhileAsync2(source, predicate);\r\n }\r\n};\r\nconst skipWhileAsync1 = (source, predicate) => {\r\n async function* iterator() {\r\n let skip = true;\r\n for (const item of source) {\r\n if (skip === false) {\r\n yield item;\r\n }\r\n else if (await predicate(item) === false) {\r\n skip = false;\r\n yield item;\r\n }\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\nconst skipWhileAsync2 = (source, predicate) => {\r\n async function* iterator() {\r\n let index = 0;\r\n let skip = true;\r\n for (const item of source) {\r\n if (skip === false) {\r\n yield item;\r\n }\r\n else if (await predicate(item, index) === false) {\r\n skip = false;\r\n yield item;\r\n }\r\n index++;\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\n", "export const sum = (source, selector) => {\r\n if (selector) {\r\n return sum2(source, selector);\r\n }\r\n else {\r\n return sum1(source);\r\n }\r\n};\r\nconst sum1 = (source) => {\r\n let total = 0;\r\n for (const value of source) {\r\n total += value;\r\n }\r\n return total;\r\n};\r\nconst sum2 = (source, selector) => {\r\n let total = 0;\r\n for (const value of source) {\r\n total += selector(value);\r\n }\r\n return total;\r\n};\r\n", "export const sumAsync = async (source, selector) => {\r\n let sum = 0;\r\n for (const value of source) {\r\n sum += await selector(value);\r\n }\r\n return sum;\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const take = (source, amount) => {\r\n function* iterator() {\r\n let amountLeft = amount > 0 ? amount : 0;\r\n for (const item of source) {\r\n if (amountLeft-- === 0) {\r\n break;\r\n }\r\n else {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const takeWhile = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return takeWhile1(source, predicate);\r\n }\r\n else {\r\n return takeWhile2(source, predicate);\r\n }\r\n};\r\nconst takeWhile1 = (source, predicate) => {\r\n function* iterator() {\r\n for (const item of source) {\r\n if (predicate(item)) {\r\n yield item;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst takeWhile2 = (source, predicate) => {\r\n function* iterator() {\r\n let index = 0;\r\n for (const item of source) {\r\n if (predicate(item, index++)) {\r\n yield item;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const takeWhileAsync = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return takeWhileAsync1(source, predicate);\r\n }\r\n else {\r\n return takeWhileAsync2(source, predicate);\r\n }\r\n};\r\nconst takeWhileAsync1 = (source, predicate) => {\r\n async function* iterator() {\r\n for (const item of source) {\r\n if (await predicate(item)) {\r\n yield item;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\nconst takeWhileAsync2 = (source, predicate) => {\r\n async function* iterator() {\r\n let index = 0;\r\n for (const item of source) {\r\n if (await predicate(item, index++)) {\r\n yield item;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\n", "export const toArray = (source) => {\r\n return [...source];\r\n};\r\n", "export const toMap = (source, selector) => {\r\n const map = new Map();\r\n for (const value of source) {\r\n const key = selector(value);\r\n const array = map.get(key);\r\n if (array === undefined) {\r\n map.set(key, [value]);\r\n }\r\n else {\r\n array.push(value);\r\n }\r\n }\r\n return map;\r\n};\r\n", "export const toMapAsync = async (source, selector) => {\r\n const map = new Map();\r\n for (const value of source) {\r\n const key = await selector(value);\r\n const array = map.get(key);\r\n if (array === undefined) {\r\n map.set(key, [value]);\r\n }\r\n else {\r\n array.push(value);\r\n }\r\n }\r\n return map;\r\n};\r\n", "export const toObject = (source, selector) => {\r\n const map = {};\r\n for (const value of source) {\r\n map[selector(value)] = value;\r\n }\r\n return map;\r\n};\r\n", "export const toObjectAsync = async (source, selector) => {\r\n const map = {};\r\n for (const value of source) {\r\n map[await selector(value)] = value;\r\n }\r\n return map;\r\n};\r\n", "export const toSet = (source) => {\r\n return new Set(source);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const union = (first, second, comparer) => {\r\n if (comparer) {\r\n return union2(first, second, comparer);\r\n }\r\n else {\r\n return union1(first, second);\r\n }\r\n};\r\nconst union1 = (first, second) => {\r\n function* iterator() {\r\n const set = new Set();\r\n for (const item of first) {\r\n if (set.has(item) === false) {\r\n yield item;\r\n set.add(item);\r\n }\r\n }\r\n for (const item of second) {\r\n if (set.has(item) === false) {\r\n yield item;\r\n set.add(item);\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst union2 = (first, second, comparer) => {\r\n function* iterator() {\r\n const result = [];\r\n for (const source of [first, second]) {\r\n for (const value of source) {\r\n let exists = false;\r\n for (const resultValue of result) {\r\n if (comparer(value, resultValue) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n yield value;\r\n result.push(value);\r\n }\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const unionAsync = (first, second, comparer) => {\r\n async function* iterator() {\r\n const result = [];\r\n for (const source of [first, second]) {\r\n for (const value of source) {\r\n let exists = false;\r\n for (const resultValue of result) {\r\n if (await comparer(value, resultValue) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n yield value;\r\n result.push(value);\r\n }\r\n }\r\n }\r\n }\r\n return fromAsync(iterator);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const where = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return where1(source, predicate);\r\n }\r\n else {\r\n return where2(source, predicate);\r\n }\r\n};\r\nconst where1 = (source, predicate) => {\r\n function* iterator() {\r\n for (const item of source) {\r\n if (predicate(item) === true) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst where2 = (source, predicate) => {\r\n function* iterator() {\r\n let i = 0;\r\n for (const item of source) {\r\n if (predicate(item, i++) === true) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const whereAsync = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return whereAsync1(source, predicate);\r\n }\r\n else {\r\n return whereAsync2(source, predicate);\r\n }\r\n};\r\nconst whereAsync1 = (source, predicate) => {\r\n async function* generator() {\r\n for (const item of source) {\r\n if (await predicate(item) === true) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return fromAsync(generator);\r\n};\r\nconst whereAsync2 = (source, predicate) => {\r\n async function* generator() {\r\n let i = 0;\r\n for (const item of source) {\r\n if (await predicate(item, i++) === true) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return fromAsync(generator);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const zip = (source, second, resultSelector) => {\r\n if (resultSelector) {\r\n return zip2(source, second, resultSelector);\r\n }\r\n else {\r\n return zip1(source, second);\r\n }\r\n};\r\nconst zip1 = (source, second) => {\r\n function* iterator() {\r\n const firstIterator = source[Symbol.iterator]();\r\n const secondIterator = second[Symbol.iterator]();\r\n while (true) {\r\n const a = firstIterator.next();\r\n const b = secondIterator.next();\r\n if (a.done || b.done) {\r\n break;\r\n }\r\n else {\r\n yield [a.value, b.value];\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\nconst zip2 = (source, second, resultSelector) => {\r\n function* iterator() {\r\n const firstIterator = source[Symbol.iterator]();\r\n const secondIterator = second[Symbol.iterator]();\r\n while (true) {\r\n const a = firstIterator.next();\r\n const b = secondIterator.next();\r\n if (a.done || b.done) {\r\n break;\r\n }\r\n else {\r\n yield resultSelector(a.value, b.value);\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const zipAsync = (first, second, resultSelector) => {\r\n async function* generator() {\r\n const firstIterator = first[Symbol.iterator]();\r\n const secondIterator = second[Symbol.iterator]();\r\n while (true) {\r\n const a = firstIterator.next();\r\n const b = secondIterator.next();\r\n if (a.done || b.done) {\r\n break;\r\n }\r\n else {\r\n yield resultSelector(a.value, b.value);\r\n }\r\n }\r\n }\r\n return fromAsync(generator);\r\n};\r\n", "import { aggregate } from \"./../sync/_private/aggregate.js\";\r\nimport { all } from \"./../sync/_private/all.js\";\r\nimport { allAsync } from \"./../sync/_private/allAsync.js\";\r\nimport { any } from \"./../sync/_private/any.js\";\r\nimport { anyAsync } from \"./../sync/_private/anyAsync.js\";\r\nimport { asAsync } from \"./../sync/_private/asAsync.js\";\r\nimport { asParallel } from \"./../sync/_private/asParallel.js\";\r\nimport { average } from \"./../sync/_private/average.js\";\r\nimport { averageAsync } from \"./../sync/_private/averageAsync.js\";\r\nimport { chunk } from \"./../sync/_private/chunk.js\";\r\nimport { concatenate } from \"../sync/_private/concatenate.js\";\r\nimport { contains } from \"./../sync/_private/contains.js\";\r\nimport { containsAsync } from \"./../sync/_private/containsAsync.js\";\r\nimport { count } from \"./../sync/_private/count.js\";\r\nimport { countAsync } from \"./../sync/_private/countAsync.js\";\r\nimport { defaultIfEmpty } from \"../sync/_private/defaultIfEmpty.js\";\r\nimport { distinct } from \"./../sync/_private/distinct.js\";\r\nimport { distinctAsync } from \"./../sync/_private/distinctAsync.js\";\r\nimport { each } from \"./../sync/_private/each.js\";\r\nimport { eachAsync } from \"./../sync/_private/eachAsync.js\";\r\nimport { elementAt } from \"./../sync/_private/elementAt.js\";\r\nimport { elementAtOrDefault } from \"./../sync/_private/elementAtOrDefault.js\";\r\nimport { except } from \"./../sync/_private/except.js\";\r\nimport { exceptAsync } from \"./../sync/_private/exceptAsync.js\";\r\nimport { first } from \"./../sync/_private/first.js\";\r\nimport { firstAsync } from \"./../sync/_private/firstAsync.js\";\r\nimport { firstOrDefault } from \"./../sync/_private/firstOrDefault.js\";\r\nimport { firstOrDefaultAsync } from \"./../sync/_private/firstOrDefaultAsync.js\";\r\nimport { groupBy } from \"./../sync/_private/groupBy.js\";\r\nimport { groupByAsync } from \"./../sync/_private/groupByAsync.js\";\r\nimport { groupByWithSel } from \"./../sync/_private/groupByWithSel.js\";\r\nimport { groupJoin } from \"../sync/_private/groupJoin.js\";\r\nimport { groupJoinAsync } from \"../sync/_private/groupJoinAsync.js\";\r\nimport { intersect } from \"./../sync/_private/intersect.js\";\r\nimport { intersectAsync } from \"./../sync/_private/intersectAsync.js\";\r\nimport { join } from \"./../sync/_private/join.js\";\r\nimport { last } from \"./../sync/_private/last.js\";\r\nimport { lastAsync } from \"./../sync/_private/lastAsync.js\";\r\nimport { lastOrDefault } from \"./../sync/_private/lastOrDefault.js\";\r\nimport { lastOrDefaultAsync } from \"./../sync/_private/lastOrDefaultAsync.js\";\r\nimport { max } from \"./../sync/_private/max.js\";\r\nimport { maxAsync } from \"./../sync/_private/maxAsync.js\";\r\nimport { min } from \"./../sync/_private/min.js\";\r\nimport { minAsync } from \"./../sync/_private/minAsync.js\";\r\nimport { ofType } from \"./../sync/_private/ofType.js\";\r\nimport { orderBy } from \"./../sync/_private/orderBy.js\";\r\nimport { orderByAsync } from \"./../sync/_private/orderByAsync.js\";\r\nimport { orderByDescending } from \"./../sync/_private/orderByDescending.js\";\r\nimport { orderByDescendingAsync } from \"./../sync/_private/orderByDescendingAsync.js\";\r\nimport { partition } from \"./../sync/_private/partition.js\";\r\nimport { partitionAsync } from \"./../sync/_private/partitionAsync.js\";\r\nimport { reverse } from \"./../sync/_private/reverse.js\";\r\nimport { select } from \"./../sync/_private/select.js\";\r\nimport { selectAsync } from \"./../sync/_private/selectAsync.js\";\r\nimport { selectMany } from \"./../sync/_private/selectMany.js\";\r\nimport { selectManyAsync } from \"./../sync/_private/selectManyAsync.js\";\r\nimport { sequenceEquals } from \"./../sync/_private/sequenceEquals.js\";\r\nimport { sequenceEqualsAsync } from \"./../sync/_private/sequenceEqualsAsync.js\";\r\nimport { single } from \"./../sync/_private/single.js\";\r\nimport { singleAsync } from \"./../sync/_private/singleAsync.js\";\r\nimport { singleOrDefault } from \"./../sync/_private/singleOrDefault.js\";\r\nimport { singleOrDefaultAsync } from \"./../sync/_private/singleOrDefaultAsync.js\";\r\nimport { skip } from \"./../sync/_private/skip.js\";\r\nimport { skipWhile } from \"./../sync/_private/skipWhile.js\";\r\nimport { skipWhileAsync } from \"./../sync/_private/skipWhileAsync.js\";\r\nimport { sum } from \"./../sync/_private/sum.js\";\r\nimport { sumAsync } from \"./../sync/_private/sumAsync.js\";\r\nimport { take } from \"./../sync/_private/take.js\";\r\nimport { takeWhile } from \"./../sync/_private/takeWhile.js\";\r\nimport { takeWhileAsync } from \"./../sync/_private/takeWhileAsync.js\";\r\nimport { toArray } from \"./../sync/_private/toArray.js\";\r\nimport { toMap } from \"./../sync/_private/toMap.js\";\r\nimport { toMapAsync } from \"./../sync/_private/toMapAsync.js\";\r\nimport { toObject } from \"./../sync/_private/toObject.js\";\r\nimport { toObjectAsync } from \"./../sync/_private/toObjectAsync.js\";\r\nimport { toSet } from \"./../sync/_private/toSet.js\";\r\nimport { union } from \"./../sync/_private/union.js\";\r\nimport { unionAsync } from \"./../sync/_private/unionAsync.js\";\r\nimport { where } from \"./../sync/_private/where.js\";\r\nimport { whereAsync } from \"./../sync/_private/whereAsync.js\";\r\nimport { zip } from \"./../sync/_private/zip.js\";\r\nimport { zipAsync } from \"./../sync/_private/zipAsync.js\";\r\nexport const bindLinq = (object) => {\r\n const prototype = object.prototype;\r\n const bind = (func, key) => {\r\n const wrapped = function (...params) {\r\n return func(this, ...params);\r\n };\r\n Object.defineProperty(wrapped, \"length\", { value: func.length - 1 });\r\n prototype[key] = wrapped;\r\n };\r\n bind(aggregate, \"aggregate\");\r\n bind(all, \"all\");\r\n bind(allAsync, \"allAsync\");\r\n bind(any, \"any\");\r\n bind(anyAsync, \"anyAsync\");\r\n bind(asAsync, \"asAsync\");\r\n bind(asParallel, \"asParallel\");\r\n bind(average, \"average\");\r\n bind(averageAsync, \"averageAsync\");\r\n bind(chunk, \"chunk\");\r\n bind(concatenate, \"concatenate\");\r\n bind(contains, \"contains\");\r\n bind(containsAsync, \"containsAsync\");\r\n bind(count, \"count\");\r\n bind(countAsync, \"countAsync\");\r\n bind(defaultIfEmpty, \"defaultIfEmpty\");\r\n bind(distinct, \"distinct\");\r\n bind(distinctAsync, \"distinctAsync\");\r\n bind(each, \"each\");\r\n bind(eachAsync, \"eachAsync\");\r\n bind(elementAt, \"elementAt\");\r\n bind(elementAtOrDefault, \"elementAtOrDefault\");\r\n bind(except, \"except\");\r\n bind(exceptAsync, \"exceptAsync\");\r\n bind(first, \"first\");\r\n bind(firstAsync, \"firstAsync\");\r\n bind(firstOrDefault, \"firstOrDefault\");\r\n bind(firstOrDefaultAsync, \"firstOrDefaultAsync\");\r\n bind(groupBy, \"groupBy\");\r\n bind(groupByAsync, \"groupByAsync\");\r\n bind(groupByWithSel, \"groupByWithSel\");\r\n bind(groupJoin, \"groupJoin\");\r\n bind(groupJoinAsync, \"groupJoinAsync\");\r\n bind(intersect, \"intersect\");\r\n bind(intersectAsync, \"intersectAsync\");\r\n bind(join, \"joinByKey\");\r\n bind(last, \"last\");\r\n bind(lastAsync, \"lastAsync\");\r\n bind(lastOrDefault, \"lastOrDefault\");\r\n bind(lastOrDefaultAsync, \"lastOrDefaultAsync\");\r\n bind(max, \"max\");\r\n bind(maxAsync, \"maxAsync\");\r\n bind(min, \"min\");\r\n bind(minAsync, \"minAsync\");\r\n bind(ofType, \"ofType\");\r\n bind(orderBy, \"orderBy\");\r\n bind(orderByAsync, \"orderByAsync\");\r\n bind(orderByDescending, \"orderByDescending\");\r\n bind(orderByDescendingAsync, \"orderByDescendingAsync\");\r\n bind(reverse, \"reverse\");\r\n bind(select, \"select\");\r\n bind(selectAsync, \"selectAsync\");\r\n bind(selectMany, \"selectMany\");\r\n bind(selectManyAsync, \"selectManyAsync\");\r\n bind(sequenceEquals, \"sequenceEquals\");\r\n bind(sequenceEqualsAsync, \"sequenceEqualsAsync\");\r\n bind(single, \"single\");\r\n bind(singleAsync, \"singleAsync\");\r\n bind(singleOrDefault, \"singleOrDefault\");\r\n bind(singleOrDefaultAsync, \"singleOrDefaultAsync\");\r\n bind(skip, \"skip\");\r\n bind(skipWhile, \"skipWhile\");\r\n bind(skipWhileAsync, \"skipWhileAsync\");\r\n bind(sum, \"sum\");\r\n bind(sumAsync, \"sumAsync\");\r\n bind(take, \"take\");\r\n bind(takeWhile, \"takeWhile\");\r\n bind(takeWhileAsync, \"takeWhileAsync\");\r\n bind(toArray, \"toArray\");\r\n bind(toMap, \"toMap\");\r\n bind(toMapAsync, \"toMapAsync\");\r\n bind(toObject, \"toObject\");\r\n bind(toObjectAsync, \"toObjectAsync\");\r\n bind(partition, \"partition\");\r\n bind(partitionAsync, \"partitionAsync\");\r\n bind(toSet, \"toSet\");\r\n bind(union, \"union\");\r\n bind(unionAsync, \"unionAsync\");\r\n bind(where, \"where\");\r\n bind(whereAsync, \"whereAsync\");\r\n bind(zip, \"zip\");\r\n bind(zipAsync, \"zipAsync\");\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const aggregate = (source, seedOrFunc, func, resultSelector) => {\r\n if (resultSelector) {\r\n if (!func) {\r\n throw new ReferenceError(\"TAccumulate function is undefined\");\r\n }\r\n return aggregate3(source, seedOrFunc, func, resultSelector);\r\n }\r\n else if (func) {\r\n return aggregate2(source, seedOrFunc, func);\r\n }\r\n else {\r\n return aggregate1(source, seedOrFunc);\r\n }\r\n};\r\nconst aggregate1 = async (source, func) => {\r\n let aggregateValue;\r\n for await (const value of source) {\r\n if (aggregateValue) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n else {\r\n aggregateValue = value;\r\n }\r\n }\r\n if (aggregateValue === undefined) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return aggregateValue;\r\n};\r\nconst aggregate2 = async (source, seed, func) => {\r\n let aggregateValue = seed;\r\n for await (const value of source) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n return aggregateValue;\r\n};\r\nconst aggregate3 = async (source, seed, func, resultSelector) => {\r\n let aggregateValue = seed;\r\n for await (const value of source) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n return resultSelector(aggregateValue);\r\n};\r\n", "export const all = async (source, predicate) => {\r\n for await (const item of source) {\r\n if (predicate(item) === false) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "export const allAsync = async (source, predicate) => {\r\n for await (const item of source) {\r\n if (await predicate(item) === false) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "export const any = (source, predicate) => {\r\n if (predicate) {\r\n return any2(source, predicate);\r\n }\r\n else {\r\n return any1(source);\r\n }\r\n};\r\nconst any1 = async (source) => {\r\n for await (const _ of source) {\r\n return true;\r\n }\r\n return false;\r\n};\r\nconst any2 = async (source, predicate) => {\r\n for await (const item of source) {\r\n if (predicate(item) === true) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n", "export const anyAsync = async (source, predicate) => {\r\n for await (const item of source) {\r\n if (await predicate(item) === true) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n", "import { fromParallel } from \"../../parallel/static/fromParallel.js\";\r\nexport const asParallel = (source) => {\r\n const generator = async () => {\r\n const data = [];\r\n for await (const value of source) {\r\n data.push(value);\r\n }\r\n return data;\r\n };\r\n return fromParallel(0, generator);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const average = async (source, selector) => {\r\n let value = 0;\r\n let count = 0;\r\n if (selector) {\r\n for await (const item of source) {\r\n value = value + selector(item);\r\n count = count + 1;\r\n }\r\n }\r\n else {\r\n for await (const item of source) {\r\n value = value + item;\r\n count = count + 1;\r\n }\r\n }\r\n if (count === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return value / count;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const averageAsync = async (source, selector) => {\r\n let value = 0;\r\n let count = 0;\r\n for await (const item of source) {\r\n value = value + await selector(item);\r\n count = count + 1;\r\n }\r\n if (count === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return value / count;\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nimport { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nexport const chunk = (source, size) => {\r\n if (size < 1) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n async function* iterator() {\r\n let yieldChunk = [];\r\n for await (const value of source) {\r\n yieldChunk.push(value);\r\n if (yieldChunk.length === size) {\r\n yield yieldChunk;\r\n yieldChunk = [];\r\n }\r\n }\r\n if (yieldChunk.length) {\r\n yield yieldChunk;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const concatenate = (first, second) => {\r\n async function* iterator() {\r\n yield* first;\r\n yield* second;\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nexport const contains = async (source, value, comparer = StrictEqualityComparer) => {\r\n for await (const item of source) {\r\n if (comparer(value, item)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n", "export const containsAsync = async (source, value, comparer) => {\r\n for await (const item of source) {\r\n if (await comparer(value, item)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\r\n", "export const count = (source, predicate) => {\r\n if (predicate) {\r\n return count2(source, predicate);\r\n }\r\n else {\r\n return count1(source);\r\n }\r\n};\r\nconst count1 = async (source) => {\r\n let total = 0;\r\n for await (const _ of source) {\r\n total++;\r\n }\r\n return total;\r\n};\r\nconst count2 = async (source, predicate) => {\r\n let total = 0;\r\n for await (const value of source) {\r\n if (predicate(value) === true) {\r\n total++;\r\n }\r\n }\r\n return total;\r\n};\r\n", "export const countAsync = async (source, predicate) => {\r\n let count = 0;\r\n for await (const value of source) {\r\n if (await predicate(value) === true) {\r\n count++;\r\n }\r\n }\r\n return count;\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const defaultIfEmpty = (source, defaultValue) => {\r\n async function* generator() {\r\n let found = false;\r\n for await (const value of source) {\r\n found = true;\r\n yield value;\r\n }\r\n if (!found) {\r\n yield defaultValue;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(generator);\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const distinct = (source, comparer = StrictEqualityComparer) => {\r\n async function* iterator() {\r\n const distinctElements = [];\r\n for await (const item of source) {\r\n const foundItem = distinctElements.find((x) => comparer(x, item));\r\n if (!foundItem) {\r\n distinctElements.push(item);\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const distinctAsync = (source, comparer) => {\r\n async function* iterator() {\r\n const distinctElements = [];\r\n outerLoop: for await (const item of source) {\r\n for (const distinctElement of distinctElements) {\r\n const found = await comparer(distinctElement, item);\r\n if (found) {\r\n continue outerLoop;\r\n }\r\n }\r\n distinctElements.push(item);\r\n yield item;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const each = (source, action) => {\r\n async function* iterator() {\r\n for await (const value of source) {\r\n action(value);\r\n yield value;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const eachAsync = (source, action) => {\r\n async function* iterator() {\r\n for await (const value of source) {\r\n await action(value);\r\n yield value;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nexport const elementAt = async (source, index) => {\r\n if (index < 0) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n let i = 0;\r\n for await (const item of source) {\r\n if (index === i++) {\r\n return item;\r\n }\r\n }\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n};\r\n", "export const elementAtOrDefault = async (source, index) => {\r\n let i = 0;\r\n for await (const item of source) {\r\n if (index === i++) {\r\n return item;\r\n }\r\n }\r\n return null;\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const except = (first, second, comparer = StrictEqualityComparer) => {\r\n async function* iterator() {\r\n const secondArray = [];\r\n for await (const x of second) {\r\n secondArray.push(x);\r\n }\r\n for await (const firstItem of first) {\r\n let exists = false;\r\n for (let j = 0; j < secondArray.length; j++) {\r\n const secondItem = secondArray[j];\r\n if (comparer(firstItem, secondItem) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n yield firstItem;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const exceptAsync = (first, second, comparer) => {\r\n async function* iterator() {\r\n const secondArray = [];\r\n for await (const x of second) {\r\n secondArray.push(x);\r\n }\r\n for await (const firstItem of first) {\r\n let exists = false;\r\n for (let j = 0; j < secondArray.length; j++) {\r\n const secondItem = secondArray[j];\r\n if (await comparer(firstItem, secondItem) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n yield firstItem;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const first = (source, predicate) => {\r\n if (predicate) {\r\n return first2(source, predicate);\r\n }\r\n else {\r\n return first1(source);\r\n }\r\n};\r\nconst first1 = async (source) => {\r\n const firstElement = await source[Symbol.asyncIterator]().next();\r\n if (firstElement.done === true) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return firstElement.value;\r\n};\r\nconst first2 = async (source, predicate) => {\r\n for await (const value of source) {\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const firstAsync = async (source, predicate) => {\r\n for await (const value of source) {\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n};\r\n", "export const firstOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return firstOrDefault2(source, predicate);\r\n }\r\n else {\r\n return firstOrDefault1(source);\r\n }\r\n};\r\nconst firstOrDefault1 = async (source) => {\r\n const first = await source[Symbol.asyncIterator]().next();\r\n return first.value || null;\r\n};\r\nconst firstOrDefault2 = async (source, predicate) => {\r\n for await (const value of source) {\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n};\r\n", "export const firstOrDefaultAsync = async (source, predicate) => {\r\n for await (const value of source) {\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n};\r\n", "import { Grouping } from \"../../sync/Grouping.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const groupBy = (source, keySelector, comparer) => {\r\n if (comparer) {\r\n return groupBy_0(source, keySelector, comparer);\r\n }\r\n else {\r\n return groupBy_0_Simple(source, keySelector);\r\n }\r\n};\r\nconst groupBy_0 = (source, keySelector, comparer) => {\r\n async function* generate() {\r\n const keyMap = new Array();\r\n for await (const value of source) {\r\n const key = keySelector(value);\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (comparer(group.key, key)) {\r\n group.push(value);\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n keyMap.push(new Grouping(key, value));\r\n }\r\n }\r\n for (const g of keyMap) {\r\n yield g;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(generate);\r\n};\r\nconst groupBy_0_Simple = (source, keySelector) => {\r\n async function* iterator() {\r\n const keyMap = {};\r\n for await (const value of source) {\r\n const key = keySelector(value);\r\n const grouping = keyMap[key];\r\n if (grouping) {\r\n grouping.push(value);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, value);\r\n }\r\n }\r\n for (const value in keyMap) {\r\n yield keyMap[value];\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { Grouping } from \"../../sync/Grouping.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const groupByAsync = (source, keySelector, comparer) => {\r\n if (comparer) {\r\n return groupByAsync_0(source, keySelector, comparer);\r\n }\r\n else {\r\n return groupByAsync_0_Simple(source, keySelector);\r\n }\r\n};\r\nconst groupByAsync_0_Simple = (source, keySelector) => {\r\n async function* iterator() {\r\n const keyMap = {};\r\n for await (const value of source) {\r\n const key = await keySelector(value);\r\n const grouping = keyMap[key];\r\n if (grouping) {\r\n grouping.push(value);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, value);\r\n }\r\n }\r\n for (const value in keyMap) {\r\n yield keyMap[value];\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst groupByAsync_0 = (source, keySelector, comparer) => {\r\n async function* generate() {\r\n const keyMap = new Array();\r\n for await (const value of source) {\r\n const key = await keySelector(value);\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (await comparer(group.key, key) === true) {\r\n group.push(value);\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n keyMap.push(new Grouping(key, value));\r\n }\r\n }\r\n for (const keyValue of keyMap) {\r\n yield keyValue;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(generate);\r\n};\r\n", "import { Grouping } from \"../../sync/Grouping.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const groupByWithSel = (source, keySelector, elementSelector, comparer) => {\r\n if (comparer) {\r\n return groupBy1(source, keySelector, elementSelector, comparer);\r\n }\r\n else {\r\n return groupBy1Simple(source, keySelector, elementSelector);\r\n }\r\n};\r\nconst groupBy1Simple = (source, keySelector, elementSelector) => {\r\n async function* generate() {\r\n const keyMap = {};\r\n for await (const value of source) {\r\n const key = keySelector(value);\r\n const grouping = keyMap[key];\r\n const element = elementSelector(value);\r\n if (grouping) {\r\n grouping.push(element);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, element);\r\n }\r\n }\r\n for (const value in keyMap) {\r\n yield keyMap[value];\r\n }\r\n }\r\n return new BasicAsyncEnumerable(generate);\r\n};\r\nconst groupBy1 = (source, keySelector, elementSelector, comparer) => {\r\n async function* generate() {\r\n const keyMap = new Array();\r\n for await (const value of source) {\r\n const key = keySelector(value);\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (comparer(group.key, key)) {\r\n group.push(elementSelector(value));\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n const element = elementSelector(value);\r\n keyMap.push(new Grouping(key, element));\r\n }\r\n }\r\n for (const value of keyMap) {\r\n yield value;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(generate);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const groupJoin = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n const generator = comparer ?\r\n groupJoinWithComparer(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) :\r\n groupJoinSimple(outer, inner, outerKeySelector, innerKeySelector, resultSelector);\r\n return new BasicAsyncEnumerable(generator);\r\n};\r\nconst groupJoinWithComparer = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n return async function* () {\r\n var _a;\r\n const innerKeyMap = [];\r\n for await (const innerValue of inner) {\r\n const key = innerKeySelector(innerValue);\r\n const record = innerKeyMap.find(x => comparer(x.key, key));\r\n if (record) {\r\n record.values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.push({ key, values: [innerValue] });\r\n }\r\n }\r\n for await (const outerValue of outer) {\r\n const key = outerKeySelector(outerValue);\r\n const innerRecord = (_a = innerKeyMap.find(x => comparer(x.key, key))) !== null && _a !== void 0 ? _a : { key, values: [] };\r\n yield resultSelector(outerValue, innerRecord.values);\r\n }\r\n };\r\n};\r\nconst groupJoinSimple = (outer, inner, outerKeySelector, innerKeySelector, resultSelector) => {\r\n return async function* () {\r\n var _a;\r\n const innerKeyMap = new Map();\r\n for await (const innerValue of inner) {\r\n const key = innerKeySelector(innerValue);\r\n const values = innerKeyMap.get(key);\r\n if (values) {\r\n values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.set(key, [innerValue]);\r\n }\r\n }\r\n for await (const outerValue of outer) {\r\n const key = outerKeySelector(outerValue);\r\n const values = (_a = innerKeyMap.get(key)) !== null && _a !== void 0 ? _a : [];\r\n yield resultSelector(outerValue, values);\r\n }\r\n };\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const groupJoinAsync = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n const generator = comparer ?\r\n groupJoinWithComparer(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) :\r\n groupJoinSimple(outer, inner, outerKeySelector, innerKeySelector, resultSelector);\r\n return new BasicAsyncEnumerable(generator);\r\n};\r\nconst groupJoinWithComparer = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n return async function* () {\r\n var _a;\r\n const innerKeyMap = [];\r\n for await (const innerValue of inner) {\r\n const key = await innerKeySelector(innerValue);\r\n const record = innerKeyMap.find(x => comparer(x.key, key));\r\n if (record) {\r\n record.values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.push({ key, values: [innerValue] });\r\n }\r\n }\r\n for await (const outerValue of outer) {\r\n const key = await outerKeySelector(outerValue);\r\n const innerRecord = (_a = innerKeyMap.find(x => comparer(x.key, key))) !== null && _a !== void 0 ? _a : { key, values: [] };\r\n yield resultSelector(outerValue, innerRecord.values);\r\n }\r\n };\r\n};\r\nconst groupJoinSimple = (outer, inner, outerKeySelector, innerKeySelector, resultSelector) => {\r\n return async function* () {\r\n var _a;\r\n const innerKeyMap = new Map();\r\n for await (const innerValue of inner) {\r\n const key = await innerKeySelector(innerValue);\r\n const values = innerKeyMap.get(key);\r\n if (values) {\r\n values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.set(key, [innerValue]);\r\n }\r\n }\r\n for await (const outerValue of outer) {\r\n const key = await outerKeySelector(outerValue);\r\n const values = (_a = innerKeyMap.get(key)) !== null && _a !== void 0 ? _a : [];\r\n yield resultSelector(outerValue, values);\r\n }\r\n };\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const intersect = (first, second, comparer = StrictEqualityComparer) => {\r\n async function* iterator() {\r\n const firstResults = await first.distinct(comparer).toArray();\r\n if (firstResults.length === 0) {\r\n return;\r\n }\r\n const secondResults = await second.toArray();\r\n for (let i = 0; i < firstResults.length; i++) {\r\n const firstValue = firstResults[i];\r\n for (let j = 0; j < secondResults.length; j++) {\r\n const secondValue = secondResults[j];\r\n if (comparer(firstValue, secondValue) === true) {\r\n yield firstValue;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const intersectAsync = (first, second, comparer) => {\r\n async function* iterator() {\r\n const firstResults = await first.distinctAsync(comparer).toArray();\r\n if (firstResults.length === 0) {\r\n return;\r\n }\r\n const secondResults = await second.toArray();\r\n for (let i = 0; i < firstResults.length; i++) {\r\n const firstValue = firstResults[i];\r\n for (let j = 0; j < secondResults.length; j++) {\r\n const secondValue = secondResults[j];\r\n if (await comparer(firstValue, secondValue) === true) {\r\n yield firstValue;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const join = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer = StrictEqualityComparer) => {\r\n async function* iterator() {\r\n const innerArray = [];\r\n for await (const i of inner) {\r\n innerArray.push(i);\r\n }\r\n for await (const o of outer) {\r\n const outerKey = outerKeySelector(o);\r\n for (const i of innerArray) {\r\n const innerKey = innerKeySelector(i);\r\n if (comparer(outerKey, innerKey) === true) {\r\n yield resultSelector(o, i);\r\n }\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const last = (source, predicate) => {\r\n if (predicate) {\r\n return last2(source, predicate);\r\n }\r\n else {\r\n return last1(source);\r\n }\r\n};\r\nconst last1 = async (source) => {\r\n let lastItem = null;\r\n for await (const value of source) {\r\n lastItem = value;\r\n }\r\n if (!lastItem) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return lastItem;\r\n};\r\nconst last2 = async (source, predicate) => {\r\n let lastItem = null;\r\n for await (const value of source) {\r\n if (predicate(value) === true) {\r\n lastItem = value;\r\n }\r\n }\r\n if (!lastItem) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return lastItem;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const lastAsync = async (source, predicate) => {\r\n let last = null;\r\n for await (const value of source) {\r\n if (await predicate(value) === true) {\r\n last = value;\r\n }\r\n }\r\n if (!last) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return last;\r\n};\r\n", "export const lastOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return lastOrDefault2(source, predicate);\r\n }\r\n else {\r\n return lastOrDefault1(source);\r\n }\r\n};\r\nconst lastOrDefault1 = async (source) => {\r\n let last = null;\r\n for await (const value of source) {\r\n last = value;\r\n }\r\n return last;\r\n};\r\nconst lastOrDefault2 = async (source, predicate) => {\r\n let last = null;\r\n for await (const value of source) {\r\n if (predicate(value) === true) {\r\n last = value;\r\n }\r\n }\r\n return last;\r\n};\r\n", "export const lastOrDefaultAsync = async (source, predicate) => {\r\n let last = null;\r\n for await (const value of source) {\r\n if (await predicate(value) === true) {\r\n last = value;\r\n }\r\n }\r\n return last;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const max = (source, selector) => {\r\n if (selector) {\r\n return max2(source, selector);\r\n }\r\n else {\r\n return max1(source);\r\n }\r\n};\r\nconst max1 = async (source) => {\r\n let maxItem = null;\r\n for await (const item of source) {\r\n maxItem = Math.max(maxItem || Number.NEGATIVE_INFINITY, item);\r\n }\r\n if (maxItem === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return maxItem;\r\n }\r\n};\r\nconst max2 = async (source, selector) => {\r\n let maxItem = null;\r\n for await (const item of source) {\r\n maxItem = Math.max(maxItem || Number.NEGATIVE_INFINITY, selector(item));\r\n }\r\n if (maxItem === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return maxItem;\r\n }\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const maxAsync = async (source, selector) => {\r\n let max = null;\r\n for await (const item of source) {\r\n max = Math.max(max || Number.NEGATIVE_INFINITY, await selector(item));\r\n }\r\n if (max === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return max;\r\n }\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const min = (source, selector) => {\r\n if (selector) {\r\n return min2(source, selector);\r\n }\r\n else {\r\n return min1(source);\r\n }\r\n};\r\nconst min1 = async (source) => {\r\n let minValue = null;\r\n for await (const item of source) {\r\n minValue = Math.min(minValue || Number.POSITIVE_INFINITY, item);\r\n }\r\n if (minValue === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return minValue;\r\n }\r\n};\r\nconst min2 = async (source, selector) => {\r\n let minValue = null;\r\n for await (const item of source) {\r\n minValue = Math.min(minValue || Number.POSITIVE_INFINITY, selector(item));\r\n }\r\n if (minValue === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return minValue;\r\n }\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const minAsync = async (source, selector) => {\r\n let min = null;\r\n for await (const item of source) {\r\n min = Math.min(min || Number.POSITIVE_INFINITY, await selector(item));\r\n }\r\n if (min === null) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return min;\r\n }\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const ofType = (source, type) => {\r\n const typeCheck = typeof type === \"string\" ?\r\n ((x) => typeof x === type) :\r\n ((x) => x instanceof type);\r\n async function* iterator() {\r\n for await (const item of source) {\r\n if (typeCheck(item)) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { OrderedAsyncEnumerable } from \"../OrderedAsyncEnumerable.js\";\r\nexport const orderBy = (source, keySelector, comparer) => {\r\n return OrderedAsyncEnumerable.generate(source, keySelector, true, comparer);\r\n};\r\n", "import { OrderedAsyncEnumerable } from \"../OrderedAsyncEnumerable.js\";\r\nexport const orderByAsync = (source, keySelector, comparer) => {\r\n return OrderedAsyncEnumerable.generateAsync(source, keySelector, true, comparer);\r\n};\r\n", "import { OrderedAsyncEnumerable } from \"../OrderedAsyncEnumerable.js\";\r\nexport const orderByDescending = (source, keySelector, comparer) => {\r\n return OrderedAsyncEnumerable.generate(source, keySelector, false, comparer);\r\n};\r\n", "import { OrderedAsyncEnumerable } from \"../OrderedAsyncEnumerable.js\";\r\nexport const orderByDescendingAsync = (source, keySelector, comparer) => {\r\n return OrderedAsyncEnumerable.generateAsync(source, keySelector, false, comparer);\r\n};\r\n", "export const partition = async (source, predicate) => {\r\n const fail = [];\r\n const pass = [];\r\n for await (const value of source) {\r\n if (predicate(value) === true) {\r\n pass.push(value);\r\n }\r\n else {\r\n fail.push(value);\r\n }\r\n }\r\n return [pass, fail];\r\n};\r\n", "export const partitionAsync = async (source, predicate) => {\r\n const fail = [];\r\n const pass = [];\r\n for await (const value of source) {\r\n if (await predicate(value) === true) {\r\n pass.push(value);\r\n }\r\n else {\r\n fail.push(value);\r\n }\r\n }\r\n return [pass, fail];\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const reverse = (source) => {\r\n async function* iterator() {\r\n const values = [];\r\n for await (const value of source) {\r\n values.push(value);\r\n }\r\n for (let i = values.length - 1; i >= 0; i--) {\r\n yield values[i];\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const select = (source, selector) => {\r\n if (typeof selector === \"function\") {\r\n if (selector.length === 1) {\r\n return select1(source, selector);\r\n }\r\n else {\r\n return select2(source, selector);\r\n }\r\n }\r\n else {\r\n return select3(source, selector);\r\n }\r\n};\r\nconst select1 = (source, selector) => {\r\n async function* iterator() {\r\n for await (const value of source) {\r\n yield selector(value);\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst select2 = (source, selector) => {\r\n async function* iterator() {\r\n let index = 0;\r\n for await (const value of source) {\r\n yield selector(value, index);\r\n index++;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst select3 = (source, key) => {\r\n async function* iterator() {\r\n for await (const value of source) {\r\n yield value[key];\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const selectAsync = (source, selector) => {\r\n if (typeof selector === \"string\") {\r\n return selectAsync2(source, selector);\r\n }\r\n else {\r\n return selectAsync1(source, selector);\r\n }\r\n};\r\nconst selectAsync1 = (source, selector) => {\r\n async function* iterator() {\r\n for await (const value of source) {\r\n yield selector(value);\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst selectAsync2 = (source, key) => {\r\n async function* iterator() {\r\n for await (const value of source) {\r\n yield value[key];\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const selectMany = (source, selector) => {\r\n if (typeof selector === \"function\") {\r\n if (selector.length === 1) {\r\n return selectMany1(source, selector);\r\n }\r\n else {\r\n return selectMany2(source, selector);\r\n }\r\n }\r\n else {\r\n return selectMany3(source, selector);\r\n }\r\n};\r\nconst selectMany1 = (source, selector) => {\r\n async function* iterator() {\r\n for await (const value of source) {\r\n for (const selectorValue of selector(value)) {\r\n yield selectorValue;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst selectMany2 = (source, selector) => {\r\n async function* iterator() {\r\n let index = 0;\r\n for await (const value of source) {\r\n for (const selectorValue of selector(value, index)) {\r\n yield selectorValue;\r\n }\r\n index++;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst selectMany3 = (source, selector) => {\r\n async function* iterator() {\r\n for await (const value of source) {\r\n for (const selectorValue of value[selector]) {\r\n yield selectorValue;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const selectManyAsync = (source, selector) => {\r\n if (selector.length === 1) {\r\n const iterator = async function* () {\r\n for await (const value of source) {\r\n const many = await selector(value);\r\n for (const innerValue of many) {\r\n yield innerValue;\r\n }\r\n }\r\n };\r\n return new BasicAsyncEnumerable(iterator);\r\n }\r\n else {\r\n const iterator = async function* () {\r\n let index = 0;\r\n for await (const value of source) {\r\n const many = await selector(value, index);\r\n for (const innerValue of many) {\r\n yield innerValue;\r\n }\r\n index++;\r\n }\r\n };\r\n return new BasicAsyncEnumerable(iterator);\r\n }\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nexport const sequenceEquals = async (first, second, comparer = StrictEqualityComparer) => {\r\n const firstIterator = first[Symbol.asyncIterator]();\r\n const secondIterator = second[Symbol.asyncIterator]();\r\n let results = await Promise.all([firstIterator.next(), secondIterator.next()]);\r\n let firstResult = results[0];\r\n let secondResult = results[1];\r\n while (!firstResult.done && !secondResult.done) {\r\n if (!comparer(firstResult.value, secondResult.value)) {\r\n return false;\r\n }\r\n results = await Promise.all([firstIterator.next(), secondIterator.next()]);\r\n firstResult = results[0];\r\n secondResult = results[1];\r\n }\r\n return firstResult.done === true && secondResult.done === true;\r\n};\r\n", "export const sequenceEqualsAsync = async (first, second, comparer) => {\r\n const firstIterator = first[Symbol.asyncIterator]();\r\n const secondIterator = second[Symbol.asyncIterator]();\r\n let results = await Promise.all([firstIterator.next(), secondIterator.next()]);\r\n let firstResult = results[0];\r\n let secondResult = results[1];\r\n while (!firstResult.done && !secondResult.done) {\r\n if (await comparer(firstResult.value, secondResult.value) === false) {\r\n return false;\r\n }\r\n results = await Promise.all([firstIterator.next(), secondIterator.next()]);\r\n firstResult = results[0];\r\n secondResult = results[1];\r\n }\r\n return firstResult.done === true && secondResult.done === true;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const single = (source, predicate) => {\r\n if (predicate) {\r\n return single2(source, predicate);\r\n }\r\n else {\r\n return single1(source);\r\n }\r\n};\r\nconst single1 = async (source) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for await (const value of source) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n if (hasValue === false) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return singleValue;\r\n};\r\nconst single2 = async (source, predicate) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for await (const value of source) {\r\n if (predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n if (hasValue === false) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const singleAsync = async (source, predicate) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for await (const value of source) {\r\n if (await predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n if (hasValue === false) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const singleOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return singleOrDefault2(source, predicate);\r\n }\r\n else {\r\n return singleOrDefault1(source);\r\n }\r\n};\r\nconst singleOrDefault1 = async (source) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for await (const value of source) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n return singleValue;\r\n};\r\nconst singleOrDefault2 = async (source, predicate) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for await (const value of source) {\r\n if (predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const singleOrDefaultAsync = async (source, predicate) => {\r\n let hasValue = false;\r\n let singleValue = null;\r\n for await (const value of source) {\r\n if (await predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n return singleValue;\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const skip = (source, count) => {\r\n async function* iterator() {\r\n let i = 0;\r\n for await (const item of source) {\r\n if (i++ >= count) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const skipWhile = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return skipWhile1(source, predicate);\r\n }\r\n else {\r\n return skipWhile2(source, predicate);\r\n }\r\n};\r\nconst skipWhile1 = (source, predicate) => {\r\n async function* iterator() {\r\n let skip = true;\r\n for await (const item of source) {\r\n if (skip === false) {\r\n yield item;\r\n }\r\n else if (predicate(item) === false) {\r\n skip = false;\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst skipWhile2 = (source, predicate) => {\r\n async function* iterator() {\r\n let index = 0;\r\n let skip = true;\r\n for await (const item of source) {\r\n if (skip === false) {\r\n yield item;\r\n }\r\n else if (predicate(item, index) === false) {\r\n skip = false;\r\n yield item;\r\n }\r\n index++;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const skipWhileAsync = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return skipWhileAsync1(source, predicate);\r\n }\r\n else {\r\n return skipWhileAsync2(source, predicate);\r\n }\r\n};\r\nconst skipWhileAsync1 = (source, predicate) => {\r\n async function* iterator() {\r\n let skip = true;\r\n for await (const item of source) {\r\n if (skip === false) {\r\n yield item;\r\n }\r\n else if (await predicate(item) === false) {\r\n skip = false;\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst skipWhileAsync2 = (source, predicate) => {\r\n async function* iterator() {\r\n let index = 0;\r\n let skip = true;\r\n for await (const item of source) {\r\n if (skip === false) {\r\n yield item;\r\n }\r\n else if (await predicate(item, index) === false) {\r\n skip = false;\r\n yield item;\r\n }\r\n index++;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "export const sum = (source, selector) => {\r\n if (selector) {\r\n return sum2(source, selector);\r\n }\r\n else {\r\n return sum1(source);\r\n }\r\n};\r\nconst sum1 = async (source) => {\r\n let total = 0;\r\n for await (const value of source) {\r\n total += value;\r\n }\r\n return total;\r\n};\r\nconst sum2 = async (source, selector) => {\r\n let total = 0;\r\n for await (const value of source) {\r\n total += selector(value);\r\n }\r\n return total;\r\n};\r\n", "export const sumAsync = async (source, selector) => {\r\n let sum = 0;\r\n for await (const value of source) {\r\n sum += await selector(value);\r\n }\r\n return sum;\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const take = (source, amount) => {\r\n async function* iterator() {\r\n let amountLeft = amount > 0 ? amount : 0;\r\n for await (const item of source) {\r\n if (amountLeft-- === 0) {\r\n break;\r\n }\r\n else {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const takeWhile = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return takeWhile1(source, predicate);\r\n }\r\n else {\r\n return takeWhile2(source, predicate);\r\n }\r\n};\r\nconst takeWhile1 = (source, predicate) => {\r\n async function* iterator() {\r\n for await (const item of source) {\r\n if (predicate(item)) {\r\n yield item;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst takeWhile2 = (source, predicate) => {\r\n async function* iterator() {\r\n let index = 0;\r\n for await (const item of source) {\r\n if (predicate(item, index++)) {\r\n yield item;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const takeWhileAsync = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return takeWhileAsync1(source, predicate);\r\n }\r\n else {\r\n return takeWhileAsync2(source, predicate);\r\n }\r\n};\r\nconst takeWhileAsync1 = (source, predicate) => {\r\n async function* iterator() {\r\n for await (const item of source) {\r\n if (await predicate(item)) {\r\n yield item;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst takeWhileAsync2 = (source, predicate) => {\r\n async function* iterator() {\r\n let index = 0;\r\n for await (const item of source) {\r\n if (await predicate(item, index++)) {\r\n yield item;\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "export const toArray = async (source) => {\r\n const array = [];\r\n for await (const item of source) {\r\n array.push(item);\r\n }\r\n return array;\r\n};\r\n", "export const toMap = async (source, selector) => {\r\n const map = new Map();\r\n for await (const value of source) {\r\n const key = selector(value);\r\n const array = map.get(key);\r\n if (array === undefined) {\r\n map.set(key, [value]);\r\n }\r\n else {\r\n array.push(value);\r\n }\r\n }\r\n return map;\r\n};\r\n", "export const toMapAsync = async (source, selector) => {\r\n const map = new Map();\r\n for await (const value of source) {\r\n const key = await selector(value);\r\n const array = map.get(key);\r\n if (array === undefined) {\r\n map.set(key, [value]);\r\n }\r\n else {\r\n array.push(value);\r\n }\r\n }\r\n return map;\r\n};\r\n", "export const toObject = async (source, selector) => {\r\n const map = {};\r\n for await (const value of source) {\r\n map[selector(value)] = value;\r\n }\r\n return map;\r\n};\r\n", "export const toObjectAsync = async (source, selector) => {\r\n const map = {};\r\n for await (const value of source) {\r\n map[await selector(value)] = value;\r\n }\r\n return map;\r\n};\r\n", "export const toSet = async (source) => {\r\n const set = new Set();\r\n for await (const item of source) {\r\n set.add(item);\r\n }\r\n return set;\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const union = (first, second, comparer) => {\r\n if (comparer) {\r\n return union2(first, second, comparer);\r\n }\r\n else {\r\n return union1(first, second);\r\n }\r\n};\r\nconst union1 = (first, second) => {\r\n async function* iterator() {\r\n const set = new Set();\r\n for await (const item of first) {\r\n if (set.has(item) === false) {\r\n yield item;\r\n set.add(item);\r\n }\r\n }\r\n for await (const item of second) {\r\n if (set.has(item) === false) {\r\n yield item;\r\n set.add(item);\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst union2 = (first, second, comparer) => {\r\n async function* iterator() {\r\n const result = [];\r\n for (const source of [first, second]) {\r\n for await (const value of source) {\r\n let exists = false;\r\n for (const resultValue of result) {\r\n if (comparer(value, resultValue) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n yield value;\r\n result.push(value);\r\n }\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const unionAsync = (first, second, comparer) => {\r\n async function* iterator() {\r\n const result = [];\r\n for (const source of [first, second]) {\r\n for await (const value of source) {\r\n let exists = false;\r\n for (const resultValue of result) {\r\n if (await comparer(value, resultValue) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n yield value;\r\n result.push(value);\r\n }\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const where = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return where1(source, predicate);\r\n }\r\n else {\r\n return where2(source, predicate);\r\n }\r\n};\r\nconst where1 = (source, predicate) => {\r\n async function* iterator() {\r\n for await (const item of source) {\r\n if (predicate(item) === true) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst where2 = (source, predicate) => {\r\n async function* iterator() {\r\n let i = 0;\r\n for await (const item of source) {\r\n if (predicate(item, i++) === true) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const whereAsync = (source, predicate) => {\r\n if (predicate.length === 1) {\r\n return whereAsync1(source, predicate);\r\n }\r\n else {\r\n return whereAsync2(source, predicate);\r\n }\r\n};\r\nconst whereAsync1 = (source, predicate) => {\r\n async function* iterator() {\r\n for await (const item of source) {\r\n if (await predicate(item) === true) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst whereAsync2 = (source, predicate) => {\r\n async function* iterator() {\r\n let i = 0;\r\n for await (const item of source) {\r\n if (await predicate(item, i++) === true) {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const zip = (first, second, resultSelector) => {\r\n if (resultSelector) {\r\n return zip2(first, second, resultSelector);\r\n }\r\n else {\r\n return zip1(first, second);\r\n }\r\n};\r\nconst zip1 = (source, second) => {\r\n async function* iterator() {\r\n const firstIterator = source[Symbol.asyncIterator]();\r\n const secondIterator = second[Symbol.asyncIterator]();\r\n while (true) {\r\n const [a, b] = await Promise.all([firstIterator.next(), secondIterator.next()]);\r\n if (a.done || b.done) {\r\n break;\r\n }\r\n else {\r\n yield [a.value, b.value];\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst zip2 = (source, second, resultSelector) => {\r\n async function* iterator() {\r\n const firstIterator = source[Symbol.asyncIterator]();\r\n const secondIterator = second[Symbol.asyncIterator]();\r\n while (true) {\r\n const [a, b] = await Promise.all([firstIterator.next(), secondIterator.next()]);\r\n if (a.done || b.done) {\r\n break;\r\n }\r\n else {\r\n yield resultSelector(a.value, b.value);\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const zipAsync = (first, second, resultSelector) => {\r\n async function* generator() {\r\n const firstIterator = first[Symbol.asyncIterator]();\r\n const secondIterator = second[Symbol.asyncIterator]();\r\n while (true) {\r\n const results = await Promise.all([firstIterator.next(), secondIterator.next()]);\r\n const firstNext = results[0];\r\n const secondNext = results[1];\r\n if (firstNext.done || secondNext.done) {\r\n break;\r\n }\r\n else {\r\n yield resultSelector(firstNext.value, secondNext.value);\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(generator);\r\n};\r\n", "import { aggregate } from \"./../async/_private/aggregate.js\";\r\nimport { all } from \"./../async/_private/all.js\";\r\nimport { allAsync } from \"./../async/_private/allAsync.js\";\r\nimport { any } from \"./../async/_private/any.js\";\r\nimport { anyAsync } from \"./../async/_private/anyAsync.js\";\r\nimport { asParallel } from \"./../async/_private/asParallel.js\";\r\nimport { average } from \"./../async/_private/average.js\";\r\nimport { averageAsync } from \"./../async/_private/averageAsync.js\";\r\nimport { chunk } from \"./../async/_private/chunk.js\";\r\nimport { concatenate } from \"../async/_private/concatenate.js\";\r\nimport { contains } from \"./../async/_private/contains.js\";\r\nimport { containsAsync } from \"./../async/_private/containsAsync.js\";\r\nimport { count } from \"./../async/_private/count.js\";\r\nimport { countAsync } from \"./../async/_private/countAsync.js\";\r\nimport { defaultIfEmpty } from \"../async/_private/defaultIfEmpty.js\";\r\nimport { distinct } from \"./../async/_private/distinct.js\";\r\nimport { distinctAsync } from \"./../async/_private/distinctAsync.js\";\r\nimport { each } from \"./../async/_private/each.js\";\r\nimport { eachAsync } from \"./../async/_private/eachAsync.js\";\r\nimport { elementAt } from \"./../async/_private/elementAt.js\";\r\nimport { elementAtOrDefault } from \"./../async/_private/elementAtOrDefault.js\";\r\nimport { except } from \"./../async/_private/except.js\";\r\nimport { exceptAsync } from \"./../async/_private/exceptAsync.js\";\r\nimport { first } from \"./../async/_private/first.js\";\r\nimport { firstAsync } from \"./../async/_private/firstAsync.js\";\r\nimport { firstOrDefault } from \"./../async/_private/firstOrDefault.js\";\r\nimport { firstOrDefaultAsync } from \"./../async/_private/firstOrDefaultAsync.js\";\r\nimport { groupBy } from \"./../async/_private/groupBy.js\";\r\nimport { groupByAsync } from \"./../async/_private/groupByAsync.js\";\r\nimport { groupByWithSel } from \"./../async/_private/groupByWithSel.js\";\r\nimport { groupJoin } from \"./../async/_private/groupJoin.js\";\r\nimport { groupJoinAsync } from \"./../async/_private/groupJoinAsync.js\";\r\nimport { intersect } from \"./../async/_private/intersect.js\";\r\nimport { intersectAsync } from \"./../async/_private/intersectAsync.js\";\r\nimport { join } from \"./../async/_private/join.js\";\r\nimport { last } from \"./../async/_private/last.js\";\r\nimport { lastAsync } from \"./../async/_private/lastAsync.js\";\r\nimport { lastOrDefault } from \"./../async/_private/lastOrDefault.js\";\r\nimport { lastOrDefaultAsync } from \"./../async/_private/lastOrDefaultAsync.js\";\r\nimport { max } from \"./../async/_private/max.js\";\r\nimport { maxAsync } from \"./../async/_private/maxAsync.js\";\r\nimport { min } from \"./../async/_private/min.js\";\r\nimport { minAsync } from \"./../async/_private/minAsync.js\";\r\nimport { ofType } from \"./../async/_private/ofType.js\";\r\nimport { orderBy } from \"./../async/_private/orderBy.js\";\r\nimport { orderByAsync } from \"./../async/_private/orderByAsync.js\";\r\nimport { orderByDescending } from \"./../async/_private/orderByDescending.js\";\r\nimport { orderByDescendingAsync } from \"./../async/_private/orderByDescendingAsync.js\";\r\nimport { partition } from \"./../async/_private/partition.js\";\r\nimport { partitionAsync } from \"./../async/_private/partitionAsync.js\";\r\nimport { reverse } from \"./../async/_private/reverse.js\";\r\nimport { select } from \"./../async/_private/select.js\";\r\nimport { selectAsync } from \"./../async/_private/selectAsync.js\";\r\nimport { selectMany } from \"./../async/_private/selectMany.js\";\r\nimport { selectManyAsync } from \"./../async/_private/selectManyAsync.js\";\r\nimport { sequenceEquals } from \"./../async/_private/sequenceEquals.js\";\r\nimport { sequenceEqualsAsync } from \"./../async/_private/sequenceEqualsAsync.js\";\r\nimport { single } from \"./../async/_private/single.js\";\r\nimport { singleAsync } from \"./../async/_private/singleAsync.js\";\r\nimport { singleOrDefault } from \"./../async/_private/singleOrDefault.js\";\r\nimport { singleOrDefaultAsync } from \"./../async/_private/singleOrDefaultAsync.js\";\r\nimport { skip } from \"./../async/_private/skip.js\";\r\nimport { skipWhile } from \"./../async/_private/skipWhile.js\";\r\nimport { skipWhileAsync } from \"./../async/_private/skipWhileAsync.js\";\r\nimport { sum } from \"./../async/_private/sum.js\";\r\nimport { sumAsync } from \"./../async/_private/sumAsync.js\";\r\nimport { take } from \"./../async/_private/take.js\";\r\nimport { takeWhile } from \"./../async/_private/takeWhile.js\";\r\nimport { takeWhileAsync } from \"./../async/_private/takeWhileAsync.js\";\r\nimport { toArray } from \"./../async/_private/toArray.js\";\r\nimport { toMap } from \"./../async/_private/toMap.js\";\r\nimport { toMapAsync } from \"./../async/_private/toMapAsync.js\";\r\nimport { toObject } from \"./../async/_private/toObject.js\";\r\nimport { toObjectAsync } from \"./../async/_private/toObjectAsync.js\";\r\nimport { toSet } from \"./../async/_private/toSet.js\";\r\nimport { union } from \"./../async/_private/union.js\";\r\nimport { unionAsync } from \"./../async/_private/unionAsync.js\";\r\nimport { where } from \"./../async/_private/where.js\";\r\nimport { whereAsync } from \"./../async/_private/whereAsync.js\";\r\nimport { zip } from \"./../async/_private/zip.js\";\r\nimport { zipAsync } from \"./../async/_private/zipAsync.js\";\r\nexport const bindLinqAsync = (object) => {\r\n const prototype = object.prototype;\r\n const bind = (func, key) => {\r\n const wrapped = function (...params) {\r\n return func(this, ...params);\r\n };\r\n Object.defineProperty(wrapped, \"length\", { value: func.length - 1 });\r\n prototype[key] = wrapped;\r\n };\r\n bind(aggregate, \"aggregate\");\r\n bind(all, \"all\");\r\n bind(allAsync, \"allAsync\");\r\n bind(any, \"any\");\r\n bind(anyAsync, \"anyAsync\");\r\n bind(asParallel, \"asParallel\");\r\n bind(average, \"average\");\r\n bind(averageAsync, \"averageAsync\");\r\n bind(chunk, \"chunk\");\r\n bind(concatenate, \"concatenate\");\r\n bind(contains, \"contains\");\r\n bind(containsAsync, \"containsAsync\");\r\n bind(count, \"count\");\r\n bind(countAsync, \"countAsync\");\r\n bind(defaultIfEmpty, \"defaultIfEmpty\");\r\n bind(distinct, \"distinct\");\r\n bind(distinctAsync, \"distinctAsync\");\r\n bind(each, \"each\");\r\n bind(eachAsync, \"eachAsync\");\r\n bind(elementAt, \"elementAt\");\r\n bind(elementAtOrDefault, \"elementAtOrDefault\");\r\n bind(except, \"except\");\r\n bind(exceptAsync, \"exceptAsync\");\r\n bind(first, \"first\");\r\n bind(firstAsync, \"firstAsync\");\r\n bind(firstOrDefault, \"firstOrDefault\");\r\n bind(firstOrDefaultAsync, \"firstOrDefaultAsync\");\r\n bind(groupBy, \"groupBy\");\r\n bind(groupByAsync, \"groupByAsync\");\r\n bind(groupByWithSel, \"groupByWithSel\");\r\n bind(groupJoin, \"groupJoin\");\r\n bind(groupJoinAsync, \"groupJoinAsync\");\r\n bind(intersect, \"intersect\");\r\n bind(intersectAsync, \"intersectAsync\");\r\n bind(join, \"joinByKey\");\r\n bind(last, \"last\");\r\n bind(lastAsync, \"lastAsync\");\r\n bind(lastOrDefault, \"lastOrDefault\");\r\n bind(lastOrDefaultAsync, \"lastOrDefaultAsync\");\r\n bind(max, \"max\");\r\n bind(maxAsync, \"maxAsync\");\r\n bind(min, \"min\");\r\n bind(minAsync, \"minAsync\");\r\n bind(ofType, \"ofType\");\r\n bind(orderBy, \"orderBy\");\r\n bind(orderByAsync, \"orderByAsync\");\r\n bind(orderByDescending, \"orderByDescending\");\r\n bind(orderByDescendingAsync, \"orderByDescendingAsync\");\r\n bind(partition, \"partition\");\r\n bind(partitionAsync, \"partitionAsync\");\r\n bind(reverse, \"reverse\");\r\n bind(select, \"select\");\r\n bind(selectAsync, \"selectAsync\");\r\n bind(selectMany, \"selectMany\");\r\n bind(selectManyAsync, \"selectManyAsync\");\r\n bind(sequenceEquals, \"sequenceEquals\");\r\n bind(sequenceEqualsAsync, \"sequenceEqualsAsync\");\r\n bind(single, \"single\");\r\n bind(singleAsync, \"singleAsync\");\r\n bind(singleOrDefault, \"singleOrDefault\");\r\n bind(singleOrDefaultAsync, \"singleOrDefaultAsync\");\r\n bind(skip, \"skip\");\r\n bind(skipWhile, \"skipWhile\");\r\n bind(skipWhileAsync, \"skipWhileAsync\");\r\n bind(sum, \"sum\");\r\n bind(sumAsync, \"sumAsync\");\r\n bind(take, \"take\");\r\n bind(takeWhile, \"takeWhile\");\r\n bind(takeWhileAsync, \"takeWhileAsync\");\r\n bind(toArray, \"toArray\");\r\n bind(toMap, \"toMap\");\r\n bind(toMapAsync, \"toMapAsync\");\r\n bind(toObject, \"toObject\");\r\n bind(toObjectAsync, \"toObjectAsync\");\r\n bind(toSet, \"toSet\");\r\n bind(union, \"union\");\r\n bind(unionAsync, \"unionAsync\");\r\n bind(where, \"where\");\r\n bind(whereAsync, \"whereAsync\");\r\n bind(zip, \"zip\");\r\n bind(zipAsync, \"zipAsync\");\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const aggregate = (source, seedOrFunc, func, resultSelector) => {\r\n if (resultSelector) {\r\n if (!func) {\r\n throw new ReferenceError(\"TAccumulate function is undefined\");\r\n }\r\n return aggregate3(source, seedOrFunc, func, resultSelector);\r\n }\r\n else if (func) {\r\n return aggregate2(source, seedOrFunc, func);\r\n }\r\n else {\r\n return aggregate1(source, seedOrFunc);\r\n }\r\n};\r\nconst aggregate1 = async (source, func) => {\r\n let aggregateValue;\r\n for await (const value of source) {\r\n if (aggregateValue) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n else {\r\n aggregateValue = value;\r\n }\r\n }\r\n if (aggregateValue === undefined) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return aggregateValue;\r\n};\r\nconst aggregate2 = async (source, seed, func) => {\r\n let aggregateValue = seed;\r\n for await (const value of source) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n return aggregateValue;\r\n};\r\nconst aggregate3 = async (source, seed, func, resultSelector) => {\r\n let aggregateValue = seed;\r\n for await (const value of source) {\r\n aggregateValue = func(aggregateValue, value);\r\n }\r\n return resultSelector(aggregateValue);\r\n};\r\n", "export const nextIteration = (source, onfulfilled) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const generator = () => dataFunc.generator().then((x) => {\r\n const convValues = new Array(x.length);\r\n for (let i = 0; i < x.length; i++) {\r\n convValues[i] = onfulfilled(x[i]);\r\n }\r\n return convValues;\r\n });\r\n return {\r\n generator,\r\n type: 0,\r\n };\r\n }\r\n case 1: {\r\n const generator = () => {\r\n const previousData = dataFunc.generator();\r\n const newPromises = new Array(previousData.length);\r\n for (let i = 0; i < previousData.length; i++) {\r\n newPromises[i] = previousData[i].then(onfulfilled);\r\n }\r\n return newPromises;\r\n };\r\n return {\r\n generator,\r\n type: 1,\r\n };\r\n }\r\n case 2: {\r\n const generator = async () => {\r\n const previousData = await dataFunc.generator();\r\n const newPromises = new Array(previousData.length);\r\n for (let i = 0; i < previousData.length; i++) {\r\n newPromises[i] = previousData[i].then(onfulfilled);\r\n }\r\n return newPromises;\r\n };\r\n return {\r\n generator,\r\n type: 2,\r\n };\r\n }\r\n }\r\n};\r\n", "import { nextIteration } from \"./_nextIteration.js\";\r\nexport const all = (source, predicate) => {\r\n const nextIter = nextIteration(source, (x) => {\r\n if (!predicate(x)) {\r\n throw new Error(String(false));\r\n }\r\n return true;\r\n });\r\n switch (nextIter.type) {\r\n case 0:\r\n return nextIter.generator()\r\n .then(() => true, () => false);\r\n case 1:\r\n return Promise.all(nextIter.generator())\r\n .then(() => true, () => false);\r\n case 2:\r\n return nextIter.generator()\r\n .then(Promise.all.bind(Promise))\r\n .then(() => true, () => false);\r\n }\r\n};\r\n", "export const nextIterationAsync = (source, onfulfilled) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const generator = async () => {\r\n const results = await dataFunc.generator();\r\n const newPromises = new Array(results.length);\r\n for (let i = 0; i < results.length; i++) {\r\n newPromises[i] = onfulfilled(results[i]);\r\n }\r\n return newPromises;\r\n };\r\n return {\r\n generator,\r\n type: 2,\r\n };\r\n }\r\n case 1: {\r\n const generator = () => {\r\n const promises = dataFunc.generator();\r\n return promises.map(async (promise) => {\r\n const value = await promise;\r\n return await onfulfilled(value);\r\n });\r\n };\r\n return {\r\n generator,\r\n type: 1,\r\n };\r\n }\r\n case 2: {\r\n const generator = async () => {\r\n const promises = await dataFunc.generator();\r\n return promises.map((promise) => promise.then(onfulfilled));\r\n };\r\n return {\r\n generator,\r\n type: 2,\r\n };\r\n }\r\n }\r\n};\r\n", "import { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nexport const allAsync = (source, predicate) => {\r\n const nextIter = nextIterationAsync(source, async (x) => {\r\n if (await predicate(x) === false) {\r\n throw new Error(String(false));\r\n }\r\n return true;\r\n });\r\n switch (nextIter.type) {\r\n case 1:\r\n return Promise.all(nextIter.generator())\r\n .then(() => true, () => false);\r\n case 2:\r\n return nextIter.generator()\r\n .then(Promise.all.bind(Promise))\r\n .then(() => true, () => false);\r\n }\r\n};\r\n", "import { nextIteration } from \"./_nextIteration.js\";\r\nexport const any = (source, predicate) => {\r\n if (predicate) {\r\n return any2(source, predicate);\r\n }\r\n else {\r\n return any1(source);\r\n }\r\n};\r\nconst any1 = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n let values;\r\n switch (dataFunc.type) {\r\n case 1:\r\n values = dataFunc.generator();\r\n return values.length !== 0;\r\n case 0:\r\n case 2:\r\n values = await dataFunc.generator();\r\n return values.length !== 0;\r\n }\r\n};\r\nconst any2 = async (source, predicate) => {\r\n const dataFunc = nextIteration(source, predicate);\r\n let values;\r\n switch (dataFunc.type) {\r\n case 0:\r\n values = await dataFunc.generator();\r\n return values.includes(true);\r\n case 1:\r\n values = await Promise.all(dataFunc.generator());\r\n return values.includes(true);\r\n case 2:\r\n values = await Promise.all(await dataFunc.generator());\r\n return values.includes(true);\r\n }\r\n};\r\n", "import { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nexport const anyAsync = async (source, predicate) => {\r\n const nextIter = nextIterationAsync(source, predicate);\r\n let promises;\r\n switch (nextIter.type) {\r\n case 1:\r\n promises = nextIter.generator();\r\n if (promises.length === 0) {\r\n return false;\r\n }\r\n return new Promise((resolve, reject) => {\r\n let resolvedCount = 0;\r\n for (const promise of promises) {\r\n promise.then(value => {\r\n resolvedCount++;\r\n if (value) {\r\n resolve(true);\r\n }\r\n else if (resolvedCount === promises.length) {\r\n resolve(false);\r\n }\r\n }, reject);\r\n }\r\n });\r\n case 2:\r\n promises = await nextIter.generator();\r\n if (Promise.length === 0) {\r\n return false;\r\n }\r\n const values = await Promise.all(promises);\r\n return values.includes(true);\r\n }\r\n};\r\n", "import { fromAsync } from \"../../async/static/fromAsync.js\";\r\nexport const asAsync = (source) => {\r\n async function* generator() {\r\n for await (const value of source) {\r\n yield value;\r\n }\r\n }\r\n return fromAsync(generator);\r\n};\r\n", "export const typeDataToArray = async (dataFunc) => {\r\n switch (dataFunc.type) {\r\n case 0:\r\n return await dataFunc.generator();\r\n case 1:\r\n return await Promise.all(dataFunc.generator());\r\n case 2:\r\n const data = await dataFunc.generator();\r\n return await Promise.all(data);\r\n }\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { nextIteration } from \"./_nextIteration.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const average = async (source, selector) => {\r\n let data;\r\n if (selector) {\r\n data = nextIteration(source, selector);\r\n }\r\n else {\r\n data = source.dataFunc;\r\n }\r\n const values = await typeDataToArray(data);\r\n if (values.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n let sum = 0;\r\n for (const item of values) {\r\n sum += item;\r\n }\r\n return sum / values.length;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const averageAsync = async (source, selector) => {\r\n const nextIter = nextIterationAsync(source, selector);\r\n const values = await typeDataToArray(nextIter);\r\n if (values.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n let value = 0;\r\n for (const selectedValue of values) {\r\n value += selectedValue;\r\n }\r\n return value / values.length;\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nexport const chunk = (source, size) => {\r\n if (size < 1) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n let dataFunc;\r\n switch (source.dataFunc.type) {\r\n case 1:\r\n const arrayOfPromises = source.dataFunc.generator;\r\n dataFunc = {\r\n type: 1,\r\n generator: () => {\r\n const chunks = [];\r\n let yieldChunk = [];\r\n for (const promise of arrayOfPromises()) {\r\n yieldChunk.push(promise);\r\n if (yieldChunk.length === size) {\r\n chunks.push(Promise.all(yieldChunk));\r\n yieldChunk = [];\r\n }\r\n }\r\n if (yieldChunk.length) {\r\n chunks.push(Promise.all(yieldChunk));\r\n }\r\n return chunks;\r\n }\r\n };\r\n break;\r\n case 2:\r\n const promiseOfPromises = source.dataFunc.generator;\r\n dataFunc = {\r\n type: 2,\r\n generator: async () => {\r\n const chunks = [];\r\n let yieldChunk = [];\r\n for (const promise of await promiseOfPromises()) {\r\n yieldChunk.push(promise);\r\n if (yieldChunk.length === size) {\r\n chunks.push(Promise.all(yieldChunk));\r\n yieldChunk = [];\r\n }\r\n }\r\n if (yieldChunk.length) {\r\n chunks.push(Promise.all(yieldChunk));\r\n }\r\n return chunks;\r\n }\r\n };\r\n break;\r\n case 0:\r\n const promiseToArray = source.dataFunc.generator;\r\n dataFunc = {\r\n type: 0,\r\n generator: async () => {\r\n const chunks = [];\r\n let yieldChunk = [];\r\n for (const value of await promiseToArray()) {\r\n yieldChunk.push(value);\r\n if (yieldChunk.length === size) {\r\n chunks.push(yieldChunk);\r\n yieldChunk = [];\r\n }\r\n }\r\n if (yieldChunk.length) {\r\n chunks.push(yieldChunk);\r\n }\r\n return chunks;\r\n }\r\n };\r\n break;\r\n }\r\n return new BasicParallelEnumerable(dataFunc);\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const concatenate = (first, second) => {\r\n const generator = async () => {\r\n const [firstData, secondData] = await Promise.all([first.toArray(), second.toArray()]);\r\n return [...firstData, ...secondData];\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { nextIteration } from \"./_nextIteration.js\";\r\nexport const contains = async (source, value, comparer = StrictEqualityComparer) => {\r\n let values;\r\n if (comparer) {\r\n values = nextIteration(source, (x) => comparer(value, x));\r\n }\r\n else {\r\n values = nextIteration(source, (x) => x === value);\r\n }\r\n switch (values.type) {\r\n case 0: {\r\n const data = await values.generator();\r\n return data.some((x) => x);\r\n }\r\n case 1: {\r\n const data = await Promise.all(values.generator());\r\n return data.some((x) => x);\r\n }\r\n case 2: {\r\n const data = await Promise.all(await values.generator());\r\n return data.some((x) => x);\r\n }\r\n }\r\n};\r\n", "import { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nexport const containsAsync = async (source, value, comparer) => {\r\n const values = nextIterationAsync(source, (x) => comparer(value, x));\r\n switch (values.type) {\r\n case 1: {\r\n const data = await Promise.all(values.generator());\r\n return data.some((x) => x);\r\n }\r\n case 2: {\r\n const data = await Promise.all(await values.generator());\r\n return data.some((x) => x);\r\n }\r\n }\r\n};\r\n", "export const count = (source, predicate) => {\r\n if (predicate) {\r\n return count2(source, predicate);\r\n }\r\n else {\r\n return count1(source);\r\n }\r\n};\r\nconst count1 = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0:\r\n case 2:\r\n const arrayData = await source.toArray();\r\n return arrayData.length;\r\n case 1:\r\n const promises = dataFunc.generator();\r\n return promises.length;\r\n }\r\n};\r\nconst count2 = async (source, predicate) => {\r\n const values = await source.toArray();\r\n let totalCount = 0;\r\n for (let i = 0; i < values.length; i++) {\r\n if (predicate(values[i]) === true) {\r\n totalCount++;\r\n }\r\n }\r\n return totalCount;\r\n};\r\n", "import { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nexport const countAsync = async (source, predicate) => {\r\n const data = nextIterationAsync(source, predicate);\r\n let countPromise;\r\n switch (data.type) {\r\n case 1:\r\n countPromise = Promise.all(data.generator());\r\n break;\r\n case 2:\r\n countPromise = Promise.all(await data.generator());\r\n break;\r\n }\r\n let totalCount = 0;\r\n for (const value of await countPromise) {\r\n if (value) {\r\n totalCount++;\r\n }\r\n }\r\n return totalCount;\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const defaultIfEmpty = (source, defaultValue) => {\r\n const dataFunc = source.dataFunc;\r\n const isPromise = defaultValue instanceof Promise;\r\n let typeData;\r\n switch (dataFunc.type) {\r\n case 0:\r\n {\r\n const generator = () => dataFunc\r\n .generator()\r\n .then((values) => {\r\n if (values.length) {\r\n return values;\r\n }\r\n if (isPromise) {\r\n return defaultValue.then(value => [value]);\r\n }\r\n else {\r\n return [defaultValue];\r\n }\r\n });\r\n typeData = {\r\n generator,\r\n type: dataFunc.type\r\n };\r\n }\r\n break;\r\n case 1:\r\n {\r\n const generator = () => {\r\n const promises = dataFunc.generator();\r\n if (promises.length) {\r\n return promises;\r\n }\r\n if (isPromise) {\r\n return [defaultValue];\r\n }\r\n else {\r\n return [Promise.resolve(defaultValue)];\r\n }\r\n };\r\n typeData = {\r\n generator,\r\n type: dataFunc.type\r\n };\r\n }\r\n break;\r\n case 2:\r\n {\r\n const generator = async () => {\r\n const promises = await dataFunc.generator();\r\n if (promises.length) {\r\n return promises;\r\n }\r\n if (isPromise) {\r\n return [defaultValue];\r\n }\r\n else {\r\n return [Promise.resolve(defaultValue)];\r\n }\r\n };\r\n typeData = {\r\n generator,\r\n type: dataFunc.type\r\n };\r\n }\r\n break;\r\n }\r\n return new BasicParallelEnumerable(typeData);\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const distinct = (source, comparer = StrictEqualityComparer) => {\r\n const generator = async () => {\r\n const distinctElements = [];\r\n for (const item of await source.toArray()) {\r\n const foundItem = distinctElements.find((x) => comparer(x, item));\r\n if (!foundItem) {\r\n distinctElements.push(item);\r\n }\r\n }\r\n return distinctElements;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const distinctAsync = (source, comparer) => {\r\n const generator = async () => {\r\n const distinctElements = [];\r\n outerLoop: for (const item of await source.toArray()) {\r\n for (const distinctElement of distinctElements) {\r\n const found = await comparer(distinctElement, item);\r\n if (found) {\r\n continue outerLoop;\r\n }\r\n }\r\n distinctElements.push(item);\r\n }\r\n return distinctElements;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIteration } from \"./_nextIteration.js\";\r\nexport const each = (source, action) => {\r\n return new BasicParallelEnumerable(nextIteration(source, (x) => {\r\n action(x);\r\n return x;\r\n }));\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nexport const eachAsync = (source, action) => {\r\n const dataFunc = nextIterationAsync(source, async (x) => {\r\n await action(x);\r\n return x;\r\n });\r\n return new BasicParallelEnumerable(dataFunc);\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nexport const elementAt = async (source, index) => {\r\n if (index < 0) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n if (index >= values.length) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n else {\r\n return values[index];\r\n }\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n if (index >= promises.length) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n else {\r\n return await promises[index];\r\n }\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n if (index >= promises.length) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n else {\r\n return await promises[index];\r\n }\r\n }\r\n }\r\n};\r\n", "export const elementAtOrDefault = async (source, index) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n if (index >= values.length) {\r\n return null;\r\n }\r\n else {\r\n return values[index];\r\n }\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n if (index >= promises.length) {\r\n return null;\r\n }\r\n else {\r\n return await promises[index];\r\n }\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n if (index >= promises.length) {\r\n return null;\r\n }\r\n else {\r\n return await promises[index];\r\n }\r\n }\r\n }\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const except = (first, second, comparer = StrictEqualityComparer) => {\r\n const generator = async () => {\r\n const [firstValues, secondValues] = await Promise.all([first.toArray(), second.toArray()]);\r\n const resultValues = [];\r\n for (const firstItem of firstValues) {\r\n let exists = false;\r\n for (let j = 0; j < secondValues.length; j++) {\r\n const secondItem = secondValues[j];\r\n if (comparer(firstItem, secondItem) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n resultValues.push(firstItem);\r\n }\r\n }\r\n return resultValues;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const exceptAsync = (first, second, comparer) => {\r\n const generator = async () => {\r\n const [firstValues, secondValues] = await Promise.all([first.toArray(), second.toArray()]);\r\n const resultValues = [];\r\n for (const firstItem of firstValues) {\r\n let exists = false;\r\n for (let j = 0; j < secondValues.length; j++) {\r\n const secondItem = secondValues[j];\r\n if (await comparer(firstItem, secondItem) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n resultValues.push(firstItem);\r\n }\r\n }\r\n return resultValues;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const toArray = (source) => {\r\n return typeDataToArray(source.dataFunc);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { toArray } from \"./toArray.js\";\r\nexport const first = (source, predicate) => {\r\n if (predicate) {\r\n return first2(source, predicate);\r\n }\r\n else {\r\n return first1(source);\r\n }\r\n};\r\nconst first1 = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n if (values.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return values[0];\r\n }\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n if (promises.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return await promises[0];\r\n }\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n if (promises.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return await promises[0];\r\n }\r\n }\r\n }\r\n};\r\nconst first2 = async (source, predicate) => {\r\n const data = await toArray(source);\r\n for (const value of data) {\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { toArray } from \"./toArray.js\";\r\nexport const firstAsync = async (source, predicate) => {\r\n const data = await toArray(source);\r\n for (const value of data) {\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n};\r\n", "import { toArray } from \"./toArray.js\";\r\nexport const firstOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return firstOrDefault2(source, predicate);\r\n }\r\n else {\r\n return firstOrDefault1(source);\r\n }\r\n};\r\nconst firstOrDefault1 = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n if (values.length === 0) {\r\n return null;\r\n }\r\n else {\r\n return values[0];\r\n }\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n if (promises.length === 0) {\r\n return null;\r\n }\r\n else {\r\n return await promises[0];\r\n }\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n if (promises.length === 0) {\r\n return null;\r\n }\r\n else {\r\n return await promises[0];\r\n }\r\n }\r\n }\r\n};\r\nconst firstOrDefault2 = async (source, predicate) => {\r\n const data = await toArray(source);\r\n for (const value of data) {\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n};\r\n", "import { toArray } from \"./toArray.js\";\r\nexport const firstOrDefaultAsync = async (source, predicate) => {\r\n const data = await toArray(source);\r\n for (const value of data) {\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n};\r\n", "import { Grouping } from \"../../sync/Grouping.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const groupBy = (source, keySelector, comparer) => {\r\n if (comparer) {\r\n return groupBy_0(source, keySelector, comparer);\r\n }\r\n else {\r\n return groupBy_0_Simple(source, keySelector);\r\n }\r\n};\r\nconst groupBy_0_Simple = (source, keySelector) => {\r\n const generator = async () => {\r\n const keyMap = {};\r\n for (const value of await source.toArray()) {\r\n const key = keySelector(value);\r\n const grouping = keyMap[key];\r\n if (grouping) {\r\n grouping.push(value);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, value);\r\n }\r\n }\r\n const results = new Array();\r\n for (const value in keyMap) {\r\n results.push(keyMap[value]);\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\nconst groupBy_0 = (source, keySelector, comparer) => {\r\n const generator = async () => {\r\n const keyMap = new Array();\r\n for (const value of await source.toArray()) {\r\n const key = keySelector(value);\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (comparer(group.key, key)) {\r\n group.push(value);\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n keyMap.push(new Grouping(key, value));\r\n }\r\n }\r\n const results = new Array();\r\n for (const g of keyMap) {\r\n results.push(g);\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { Grouping } from \"../../sync/Grouping.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nexport const groupByAsync = (source, keySelector, comparer) => {\r\n if (comparer) {\r\n return groupByAsync_0(source, keySelector, comparer);\r\n }\r\n else {\r\n return groupByAsync_0_Simple(source, keySelector);\r\n }\r\n};\r\nconst groupByAsync_0 = (source, keySelector, comparer) => {\r\n const generator = async () => {\r\n const typedData = nextIterationAsync(source, async (value) => {\r\n const key = await keySelector(value);\r\n return [key, value];\r\n });\r\n let values;\r\n switch (typedData.type) {\r\n case 1:\r\n values = await Promise.all(typedData.generator());\r\n break;\r\n case 2:\r\n values = await Promise.all(await typedData.generator());\r\n break;\r\n }\r\n const keyMap = new Array();\r\n for (const [key, value] of values) {\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (await comparer(group.key, key) === true) {\r\n group.push(value);\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n keyMap.push(new Grouping(key, value));\r\n }\r\n }\r\n const results = new Array();\r\n for (const g of keyMap) {\r\n results.push(g);\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\nconst groupByAsync_0_Simple = (source, keySelector) => {\r\n const generator = async () => {\r\n const typedData = nextIterationAsync(source, async (value) => {\r\n const key = await keySelector(value);\r\n return [key, value];\r\n });\r\n let values;\r\n switch (typedData.type) {\r\n case 1:\r\n values = await Promise.all(typedData.generator());\r\n break;\r\n case 2:\r\n values = await Promise.all(await typedData.generator());\r\n break;\r\n }\r\n const keyMap = {};\r\n for (const [key, value] of values) {\r\n const grouping = keyMap[key];\r\n if (grouping) {\r\n grouping.push(value);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, value);\r\n }\r\n }\r\n const results = new Array();\r\n for (const value in keyMap) {\r\n results.push(keyMap[value]);\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { Grouping } from \"../../sync/Grouping.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const groupByWithSel = (source, keySelector, elementSelector, comparer) => {\r\n if (comparer) {\r\n return groupBy1(source, keySelector, elementSelector, comparer);\r\n }\r\n else {\r\n return groupBy1Simple(source, keySelector, elementSelector);\r\n }\r\n};\r\nconst groupBy1 = (source, keySelector, elementSelector, comparer) => {\r\n const generator = async () => {\r\n const keyMap = new Array();\r\n for await (const value of source) {\r\n const key = keySelector(value);\r\n let found = false;\r\n for (let i = 0; i < keyMap.length; i++) {\r\n const group = keyMap[i];\r\n if (comparer(group.key, key)) {\r\n group.push(elementSelector(value));\r\n found = true;\r\n break;\r\n }\r\n }\r\n if (found === false) {\r\n const element = elementSelector(value);\r\n keyMap.push(new Grouping(key, element));\r\n }\r\n }\r\n const results = new Array();\r\n for (const value of keyMap) {\r\n results.push(value);\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\nconst groupBy1Simple = (source, keySelector, elementSelector) => {\r\n const generator = async () => {\r\n const keyMap = {};\r\n for (const value of await source.toArray()) {\r\n const key = keySelector(value);\r\n const grouping = keyMap[key];\r\n const element = elementSelector(value);\r\n if (grouping) {\r\n grouping.push(element);\r\n }\r\n else {\r\n keyMap[key] = new Grouping(key, element);\r\n }\r\n }\r\n const results = new Array();\r\n for (const value in keyMap) {\r\n results.push(keyMap[value]);\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const groupJoin = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n const generator = comparer ?\r\n groupJoinWithComparer(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) :\r\n groupJoinSimple(outer, inner, outerKeySelector, innerKeySelector, resultSelector);\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0\r\n });\r\n};\r\nconst groupJoinWithComparer = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n return async () => {\r\n const innerKeyMap = [];\r\n for await (const innerValue of inner) {\r\n const key = innerKeySelector(innerValue);\r\n const record = innerKeyMap.find(x => comparer(x.key, key));\r\n if (record) {\r\n record.values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.push({ key, values: [innerValue] });\r\n }\r\n }\r\n const outerValues = await outer.toArray();\r\n return outerValues\r\n .map(outerValue => {\r\n var _a;\r\n const key = outerKeySelector(outerValue);\r\n const innerRecord = (_a = innerKeyMap.find(x => comparer(x.key, key))) !== null && _a !== void 0 ? _a : { key, values: [] };\r\n return resultSelector(outerValue, innerRecord.values);\r\n });\r\n };\r\n};\r\nconst groupJoinSimple = (outer, inner, outerKeySelector, innerKeySelector, resultSelector) => {\r\n return async () => {\r\n const innerKeyMap = new Map();\r\n for await (const innerValue of inner) {\r\n const key = innerKeySelector(innerValue);\r\n const values = innerKeyMap.get(key);\r\n if (values) {\r\n values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.set(key, [innerValue]);\r\n }\r\n }\r\n const outerValues = await outer.toArray();\r\n return outerValues\r\n .map(outerValue => {\r\n var _a;\r\n const key = outerKeySelector(outerValue);\r\n const values = (_a = innerKeyMap.get(key)) !== null && _a !== void 0 ? _a : [];\r\n return resultSelector(outerValue, values);\r\n });\r\n };\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const groupJoinAsync = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n const generator = comparer ?\r\n groupJoinWithComparer(outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) :\r\n groupJoinSimple(outer, inner, outerKeySelector, innerKeySelector, resultSelector);\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0\r\n });\r\n};\r\nconst groupJoinWithComparer = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer) => {\r\n return async () => {\r\n const innerKeyMap = [];\r\n for await (const innerValue of inner) {\r\n const key = await innerKeySelector(innerValue);\r\n const record = innerKeyMap.find(x => comparer(x.key, key));\r\n if (record) {\r\n record.values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.push({ key, values: [innerValue] });\r\n }\r\n }\r\n const outerValues = await outer.toArray();\r\n const resultPromises = outerValues.map(async (outerValue) => {\r\n var _a;\r\n const key = await outerKeySelector(outerValue);\r\n const innerRecord = (_a = innerKeyMap.find(x => comparer(x.key, key))) !== null && _a !== void 0 ? _a : { key, values: [] };\r\n return resultSelector(outerValue, innerRecord.values);\r\n });\r\n return await Promise.all(resultPromises);\r\n };\r\n};\r\nconst groupJoinSimple = (outer, inner, outerKeySelector, innerKeySelector, resultSelector) => {\r\n return async () => {\r\n const innerKeyMap = new Map();\r\n for await (const innerValue of inner) {\r\n const key = await innerKeySelector(innerValue);\r\n const values = innerKeyMap.get(key);\r\n if (values) {\r\n values.push(innerValue);\r\n }\r\n else {\r\n innerKeyMap.set(key, [innerValue]);\r\n }\r\n }\r\n const outerValues = await outer.toArray();\r\n const resultPromises = outerValues.map(async (outerValue) => {\r\n var _a;\r\n const key = await outerKeySelector(outerValue);\r\n const values = (_a = innerKeyMap.get(key)) !== null && _a !== void 0 ? _a : [];\r\n return resultSelector(outerValue, values);\r\n });\r\n return await Promise.all(resultPromises);\r\n };\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const intersect = (first, second, comparer = StrictEqualityComparer) => {\r\n const generator = async () => {\r\n const firstResults = await first.distinct(comparer).toArray();\r\n if (firstResults.length === 0) {\r\n return [];\r\n }\r\n const secondResults = await second.toArray();\r\n const results = new Array();\r\n for (let i = 0; i < firstResults.length; i++) {\r\n const firstValue = firstResults[i];\r\n for (let j = 0; j < secondResults.length; j++) {\r\n const secondValue = secondResults[j];\r\n if (comparer(firstValue, secondValue) === true) {\r\n results.push(firstValue);\r\n break;\r\n }\r\n }\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const intersectAsync = (first, second, comparer) => {\r\n const generator = async () => {\r\n const firstResults = await first.distinctAsync(comparer).toArray();\r\n if (firstResults.length === 0) {\r\n return [];\r\n }\r\n const secondResults = await second.toArray();\r\n const results = new Array();\r\n for (let i = 0; i < firstResults.length; i++) {\r\n const firstValue = firstResults[i];\r\n for (let j = 0; j < secondResults.length; j++) {\r\n const secondValue = secondResults[j];\r\n if (await comparer(firstValue, secondValue) === true) {\r\n results.push(firstValue);\r\n break;\r\n }\r\n }\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const join = (outer, inner, outerKeySelector, innerKeySelector, resultSelector, comparer = StrictEqualityComparer) => {\r\n const generator = async () => {\r\n const [innerArray, outerArray] = await Promise.all([inner.toArray(), outer.toArray()]);\r\n const results = new Array();\r\n for (const o of outerArray) {\r\n const outerKey = outerKeySelector(o);\r\n for (const i of innerArray) {\r\n const innerKey = innerKeySelector(i);\r\n if (comparer(outerKey, innerKey) === true) {\r\n results.push(resultSelector(o, i));\r\n }\r\n }\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const last = (source, predicate) => {\r\n if (predicate) {\r\n return last2(source, predicate);\r\n }\r\n else {\r\n return last1(source);\r\n }\r\n};\r\nconst last1 = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n if (values.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return values[values.length - 1];\r\n }\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n if (promises.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return await promises[promises.length - 1];\r\n }\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n if (promises.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n else {\r\n return await promises[promises.length - 1];\r\n }\r\n }\r\n }\r\n};\r\nconst last2 = async (source, predicate) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n for (let i = values.length - 1; i >= 0; i--) {\r\n const value = values[i];\r\n if (predicate(value)) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n for (let i = promises.length - 1; i >= 0; i--) {\r\n const value = await promises[i];\r\n if (predicate(value)) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n for (let i = promises.length - 1; i >= 0; i--) {\r\n const value = await promises[i];\r\n if (predicate(value)) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nexport const lastAsync = async (source, predicate) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n for (let i = values.length - 1; i >= 0; i--) {\r\n const value = values[i];\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n for (let i = promises.length - 1; i >= 0; i--) {\r\n const value = await promises[i];\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n for (let i = promises.length - 1; i >= 0; i--) {\r\n const value = await promises[i];\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n};\r\n", "export const lastOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return lastOrDefault2(source, predicate);\r\n }\r\n else {\r\n return lastOrDefault1(source);\r\n }\r\n};\r\nconst lastOrDefault1 = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n if (values.length === 0) {\r\n return null;\r\n }\r\n else {\r\n return values[values.length - 1];\r\n }\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n if (promises.length === 0) {\r\n return null;\r\n }\r\n else {\r\n return await promises[promises.length - 1];\r\n }\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n if (promises.length === 0) {\r\n return null;\r\n }\r\n else {\r\n return await promises[promises.length - 1];\r\n }\r\n }\r\n }\r\n};\r\nconst lastOrDefault2 = async (source, predicate) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n for (let i = values.length - 1; i >= 0; i--) {\r\n const value = values[i];\r\n if (predicate(value)) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n for (let i = promises.length - 1; i >= 0; i--) {\r\n const value = await promises[i];\r\n if (predicate(value)) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n for (let i = promises.length - 1; i >= 0; i--) {\r\n const value = await promises[i];\r\n if (predicate(value)) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n return null;\r\n};\r\n", "export const lastOrDefaultAsync = async (source, predicate) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const values = await dataFunc.generator();\r\n for (let i = values.length - 1; i >= 0; i--) {\r\n const value = values[i];\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n case 1: {\r\n const promises = dataFunc.generator();\r\n for (let i = promises.length - 1; i >= 0; i--) {\r\n const value = await promises[i];\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n case 2: {\r\n const promises = await dataFunc.generator();\r\n for (let i = promises.length - 1; i >= 0; i--) {\r\n const value = await promises[i];\r\n if (await predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n return null;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { nextIteration } from \"./_nextIteration.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const max = async (source, selector) => {\r\n let dataFunc;\r\n if (selector) {\r\n dataFunc = nextIteration(source, selector);\r\n }\r\n else {\r\n dataFunc = source.dataFunc;\r\n }\r\n const data = await typeDataToArray(dataFunc);\r\n if (data.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return Math.max.apply(null, data);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const maxAsync = async (source, selector) => {\r\n const dataFunc = nextIterationAsync(source, selector);\r\n const maxInfo = await typeDataToArray(dataFunc);\r\n if (maxInfo.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return Math.max.apply(null, maxInfo);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { nextIteration } from \"./_nextIteration.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const min = async (source, selector) => {\r\n let dataFunc;\r\n if (selector) {\r\n dataFunc = nextIteration(source, selector);\r\n }\r\n else {\r\n dataFunc = source.dataFunc;\r\n }\r\n const data = await typeDataToArray(dataFunc);\r\n if (data.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return Math.min.apply(null, data);\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const minAsync = async (source, selector) => {\r\n const dataFunc = nextIterationAsync(source, selector);\r\n const maxInfo = await typeDataToArray(dataFunc);\r\n if (maxInfo.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return Math.min.apply(null, maxInfo);\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIteration } from \"./_nextIteration.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const ofType = (source, type) => {\r\n const typeCheck = typeof type === \"string\" ?\r\n (x) => [typeof x === type, x] :\r\n (x) => [x instanceof type, x];\r\n const generator = async () => {\r\n const dataFunc = nextIteration(source, typeCheck);\r\n const values = await typeDataToArray(dataFunc);\r\n const filteredValues = [];\r\n for (const [pass, value] of values) {\r\n if (pass) {\r\n filteredValues.push(value);\r\n }\r\n }\r\n return filteredValues;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "export const asAsyncKeyMap = async (source, keySelector) => {\r\n const map = new Map();\r\n for await (const item of source) {\r\n const key = await keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asAsyncKeyMap } from \"./asAsyncKeyMap.js\";\r\nexport async function* asAsyncSortedKeyValues(source, keySelector, ascending, comparer) {\r\n const map = await asAsyncKeyMap(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "export const asAsyncKeyMapSync = async (source, keySelector) => {\r\n const map = new Map();\r\n for (const item of source) {\r\n const key = await keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asAsyncKeyMapSync } from \"./asAsyncKeyMapSync.js\";\r\nexport async function* asAsyncSortedKeyValuesSync(source, keySelector, ascending, comparer) {\r\n const map = await asAsyncKeyMapSync(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "export const asKeyMap = async (source, keySelector) => {\r\n const map = new Map();\r\n for await (const item of source) {\r\n const key = keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asKeyMap } from \"./asKeyMap.js\";\r\nexport async function* asSortedKeyValues(source, keySelector, ascending, comparer) {\r\n const map = await asKeyMap(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "export const asKeyMapSync = (source, keySelector) => {\r\n const map = new Map();\r\n for (const item of source) {\r\n const key = keySelector(item);\r\n const currentMapping = map.get(key);\r\n if (currentMapping) {\r\n currentMapping.push(item);\r\n }\r\n else {\r\n map.set(key, [item]);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { asKeyMapSync } from \"./asKeyMapSync.js\";\r\nexport async function* asSortedKeyValuesSync(source, keySelector, ascending, comparer) {\r\n const map = asKeyMapSync(source, keySelector);\r\n const sortedKeys = [...map.keys()].sort(comparer ? comparer : undefined);\r\n if (ascending) {\r\n for (let i = 0; i < sortedKeys.length; i++) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n else {\r\n for (let i = sortedKeys.length - 1; i >= 0; i--) {\r\n yield map.get(sortedKeys[i]);\r\n }\r\n }\r\n}\r\n", "import { asAsyncSortedKeyValues } from \"./_ordered/asAsyncSortedKeyValues.js\";\r\nimport { asAsyncSortedKeyValuesSync } from \"./_ordered/asAsyncSortedKeyValuesSync.js\";\r\nimport { asSortedKeyValues } from \"./_ordered/asSortedKeyValues.js\";\r\nimport { asSortedKeyValuesSync } from \"./_ordered/asSortedKeyValuesSync.js\";\r\nimport { BasicParallelEnumerable } from \"./BasicParallelEnumerable.js\";\r\nexport class OrderedParallelEnumerable extends BasicParallelEnumerable {\r\n constructor(orderedPairs) {\r\n super({\r\n generator: async () => {\r\n const asyncVals = orderedPairs();\r\n const array = [];\r\n for await (const val of asyncVals) {\r\n array.push(...val);\r\n }\r\n return array;\r\n },\r\n type: 0,\r\n });\r\n this.orderedPairs = orderedPairs;\r\n }\r\n static generateAsync(source, keySelector, ascending, comparer) {\r\n let orderedPairs;\r\n if (source instanceof OrderedParallelEnumerable) {\r\n orderedPairs = async function* () {\r\n for await (const pair of source.orderedPairs()) {\r\n yield* asAsyncSortedKeyValuesSync(pair, keySelector, ascending, comparer);\r\n }\r\n };\r\n }\r\n else {\r\n orderedPairs = () => asAsyncSortedKeyValues(source, keySelector, ascending, comparer);\r\n }\r\n return new OrderedParallelEnumerable(orderedPairs);\r\n }\r\n static generate(source, keySelector, ascending, comparer) {\r\n let orderedPairs;\r\n if (source instanceof OrderedParallelEnumerable) {\r\n orderedPairs = async function* () {\r\n for await (const pair of source.orderedPairs()) {\r\n yield* asSortedKeyValuesSync(pair, keySelector, ascending, comparer);\r\n }\r\n };\r\n }\r\n else {\r\n orderedPairs = () => asSortedKeyValues(source, keySelector, ascending, comparer);\r\n }\r\n return new OrderedParallelEnumerable(orderedPairs);\r\n }\r\n thenBy(keySelector, comparer) {\r\n return OrderedParallelEnumerable.generate(this, keySelector, true, comparer);\r\n }\r\n thenByAsync(keySelector, comparer) {\r\n return OrderedParallelEnumerable.generateAsync(this, keySelector, true, comparer);\r\n }\r\n thenByDescending(keySelector, comparer) {\r\n return OrderedParallelEnumerable.generate(this, keySelector, false, comparer);\r\n }\r\n thenByDescendingAsync(keySelector, comparer) {\r\n return OrderedParallelEnumerable.generateAsync(this, keySelector, false, comparer);\r\n }\r\n}\r\n", "import { OrderedParallelEnumerable } from \"../OrderedParallelEnumerable.js\";\r\nexport const orderBy = (source, keySelector, comparer) => {\r\n return OrderedParallelEnumerable.generate(source, keySelector, true, comparer);\r\n};\r\n", "import { OrderedParallelEnumerable } from \"../OrderedParallelEnumerable.js\";\r\nexport const orderByAsync = (source, keySelector, comparer) => {\r\n return OrderedParallelEnumerable.generateAsync(source, keySelector, true, comparer);\r\n};\r\n", "import { OrderedParallelEnumerable } from \"../OrderedParallelEnumerable.js\";\r\nexport const orderByDescending = (source, keySelector, comparer) => {\r\n return OrderedParallelEnumerable.generate(source, keySelector, false, comparer);\r\n};\r\n", "import { OrderedParallelEnumerable } from \"../OrderedParallelEnumerable.js\";\r\nexport const orderByDescendingAsync = (source, keySelector, comparer) => {\r\n return OrderedParallelEnumerable.generateAsync(source, keySelector, false, comparer);\r\n};\r\n", "import { nextIteration } from \"./_nextIteration.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const partition = async (source, predicate) => {\r\n const dataFunc = nextIteration(source, (value) => {\r\n return [predicate(value), value];\r\n });\r\n const values = await typeDataToArray(dataFunc);\r\n const fail = [];\r\n const pass = [];\r\n for (const [passed, value] of values) {\r\n if (passed) {\r\n pass.push(value);\r\n }\r\n else {\r\n fail.push(value);\r\n }\r\n }\r\n return [pass, fail];\r\n};\r\n", "import { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const partitionAsync = async (source, predicate) => {\r\n const dataFunc = nextIterationAsync(source, async (value) => {\r\n const passed = await predicate(value);\r\n return [passed, value];\r\n });\r\n const values = await typeDataToArray(dataFunc);\r\n const fail = [];\r\n const pass = [];\r\n for (const [passed, value] of values) {\r\n if (passed) {\r\n pass.push(value);\r\n }\r\n else {\r\n fail.push(value);\r\n }\r\n }\r\n return [pass, fail];\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const reverse = (source) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 1: {\r\n const generator = () => {\r\n return dataFunc.generator().reverse();\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: dataFunc.type,\r\n });\r\n }\r\n case 2: {\r\n const generator = async () => {\r\n const array = await dataFunc.generator();\r\n return array.reverse();\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: dataFunc.type,\r\n });\r\n }\r\n case 0: {\r\n const generator = async () => {\r\n const array = await dataFunc.generator();\r\n return array.reverse();\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: dataFunc.type,\r\n });\r\n }\r\n }\r\n};\r\n", "export const nextIterationWithIndex = (source, onfulfilled) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const generator = () => dataFunc.generator().then((x) => {\r\n const convValues = new Array(x.length);\r\n for (let i = 0; i < x.length; i++) {\r\n convValues[i] = onfulfilled(x[i], i);\r\n }\r\n return convValues;\r\n });\r\n return {\r\n generator,\r\n type: 0,\r\n };\r\n }\r\n case 1: {\r\n const generator = () => {\r\n const previousData = dataFunc.generator();\r\n const newPromises = new Array(previousData.length);\r\n for (let i = 0; i < previousData.length; i++) {\r\n newPromises[i] = previousData[i].then((value) => {\r\n return onfulfilled(value, i);\r\n });\r\n }\r\n return newPromises;\r\n };\r\n return {\r\n generator,\r\n type: 1,\r\n };\r\n }\r\n case 2: {\r\n const generator = async () => {\r\n const previousData = await dataFunc.generator();\r\n const newPromises = new Array(previousData.length);\r\n for (let i = 0; i < previousData.length; i++) {\r\n newPromises[i] = previousData[i].then((value) => onfulfilled(value, i));\r\n }\r\n return newPromises;\r\n };\r\n return {\r\n generator,\r\n type: 2,\r\n };\r\n }\r\n }\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIteration } from \"./_nextIteration.js\";\r\nimport { nextIterationWithIndex } from \"./_nextIterationWithIndex.js\";\r\nexport const select = (source, key) => {\r\n if (typeof key === \"function\") {\r\n if (key.length === 1) {\r\n return new BasicParallelEnumerable(nextIteration(source, key));\r\n }\r\n else {\r\n return new BasicParallelEnumerable(nextIterationWithIndex(source, key));\r\n }\r\n }\r\n else {\r\n return new BasicParallelEnumerable(nextIteration(source, (x) => x[key]));\r\n }\r\n};\r\n", "export const nextIterationWithIndexAsync = (source, onfulfilled) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const generator = async () => {\r\n const results = await dataFunc.generator();\r\n const newPromises = new Array(results.length);\r\n for (let i = 0; i < results.length; i++) {\r\n newPromises[i] = onfulfilled(results[i], i);\r\n }\r\n return newPromises;\r\n };\r\n return {\r\n generator,\r\n type: 2,\r\n };\r\n }\r\n case 1: {\r\n const generator = () => dataFunc\r\n .generator()\r\n .map((promise, index) => promise.then((x) => onfulfilled(x, index)));\r\n return {\r\n generator,\r\n type: 1,\r\n };\r\n }\r\n case 2: {\r\n const generator = async () => {\r\n const promises = await dataFunc.generator();\r\n return promises.map((promise, index) => promise.then((x) => onfulfilled(x, index)));\r\n };\r\n return {\r\n generator,\r\n type: 2,\r\n };\r\n }\r\n }\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { nextIterationWithIndexAsync } from \"./_nextIterationWithIndexAsync.js\";\r\nexport const selectAsync = (source, keyOrSelector) => {\r\n let generator;\r\n if (typeof keyOrSelector === \"function\") {\r\n if (keyOrSelector.length === 1) {\r\n generator = nextIterationAsync(source, keyOrSelector);\r\n }\r\n else {\r\n generator = nextIterationWithIndexAsync(source, keyOrSelector);\r\n }\r\n }\r\n else {\r\n generator = nextIterationAsync(source, (x) => (x[keyOrSelector]));\r\n }\r\n return new BasicParallelEnumerable(generator);\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIteration } from \"./_nextIteration.js\";\r\nimport { nextIterationWithIndex } from \"./_nextIterationWithIndex.js\";\r\nexport const selectMany = (source, selector) => {\r\n const generator = async () => {\r\n let values;\r\n if (typeof selector === \"function\") {\r\n if (selector.length === 1) {\r\n values = nextIteration(source, selector);\r\n }\r\n else {\r\n values = nextIterationWithIndex(source, selector);\r\n }\r\n }\r\n else {\r\n values = nextIteration(source, (x) => x[selector]);\r\n }\r\n const valuesArray = [];\r\n switch (values.type) {\r\n case 0: {\r\n for (const outer of await values.generator()) {\r\n for (const y of outer) {\r\n valuesArray.push(y);\r\n }\r\n }\r\n break;\r\n }\r\n case 1: {\r\n for (const outer of values.generator()) {\r\n for (const y of await outer) {\r\n valuesArray.push(y);\r\n }\r\n }\r\n break;\r\n }\r\n case 2: {\r\n for (const outer of await values.generator()) {\r\n for (const y of await outer) {\r\n valuesArray.push(y);\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n return valuesArray;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { nextIterationWithIndexAsync } from \"./_nextIterationWithIndexAsync.js\";\r\nexport const selectManyAsync = (source, selector) => {\r\n const generator = async () => {\r\n let values;\r\n if (selector.length === 1) {\r\n values = nextIterationAsync(source, selector);\r\n }\r\n else {\r\n values = nextIterationWithIndexAsync(source, selector);\r\n }\r\n const valuesArray = [];\r\n switch (values.type) {\r\n case 1: {\r\n for (const outer of values.generator()) {\r\n for (const y of await outer) {\r\n valuesArray.push(y);\r\n }\r\n }\r\n break;\r\n }\r\n case 2: {\r\n for (const outer of await values.generator()) {\r\n for (const y of await outer) {\r\n valuesArray.push(y);\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n return valuesArray;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { StrictEqualityComparer } from \"../../shared/index.js\";\r\nexport const sequenceEquals = async (first, second, comparer = StrictEqualityComparer) => {\r\n const firstArray = await first.toArray();\r\n const secondArray = await second.toArray();\r\n if (firstArray.length !== secondArray.length) {\r\n return false;\r\n }\r\n for (let i = 0; i < firstArray.length; i++) {\r\n const firstResult = firstArray[i];\r\n const secondResult = secondArray[i];\r\n if (comparer(firstResult, secondResult) === false) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "export const sequenceEqualsAsync = async (first, second, comparer) => {\r\n const firstArray = await first.toArray();\r\n const secondArray = await second.toArray();\r\n if (firstArray.length !== secondArray.length) {\r\n return false;\r\n }\r\n for (let i = 0; i < firstArray.length; i++) {\r\n const firstResult = firstArray[i];\r\n const secondResult = secondArray[i];\r\n if (await comparer(firstResult, secondResult) === false) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { toArray } from \"./toArray.js\";\r\nexport const single = (source, predicate) => {\r\n if (predicate) {\r\n return single2(source, predicate);\r\n }\r\n else {\r\n return single1(source);\r\n }\r\n};\r\nconst single1 = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const results = await dataFunc.generator();\r\n if (results.length > 1) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else if (results.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return results[0];\r\n }\r\n case 1: {\r\n const results = dataFunc.generator();\r\n if (results.length > 1) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else if (results.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return results[0];\r\n }\r\n case 2: {\r\n const results = await dataFunc.generator();\r\n if (results.length > 1) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else if (results.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return await results[0];\r\n }\r\n }\r\n};\r\nconst single2 = async (source, predicate) => {\r\n const results = await toArray(source);\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of results) {\r\n if (predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n if (hasValue === false) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { toArray } from \"./toArray.js\";\r\nexport const singleAsync = async (source, predicate) => {\r\n const results = await toArray(source);\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of results) {\r\n if (await predicate(value) === true) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneMatchingElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n if (hasValue === false) {\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { toArray } from \"./toArray.js\";\r\nexport const singleOrDefault = (source, predicate) => {\r\n if (predicate) {\r\n return singleOrDefault2(source, predicate);\r\n }\r\n else {\r\n return singleOrDefault1(source);\r\n }\r\n};\r\nconst singleOrDefault1 = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const results = await dataFunc.generator();\r\n if (results.length > 1) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else if (results.length === 0) {\r\n return null;\r\n }\r\n return results[0];\r\n }\r\n case 1: {\r\n const results = dataFunc.generator();\r\n if (results.length > 1) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else if (results.length === 0) {\r\n return null;\r\n }\r\n return results[0];\r\n }\r\n case 2: {\r\n const results = await dataFunc.generator();\r\n if (results.length > 1) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else if (results.length === 0) {\r\n return null;\r\n }\r\n return await results[0];\r\n }\r\n }\r\n};\r\nconst singleOrDefault2 = async (source, predicate) => {\r\n const results = await toArray(source);\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of results) {\r\n if (predicate(value)) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n return singleValue;\r\n};\r\n", "import { ErrorString, InvalidOperationException } from \"../../shared/index.js\";\r\nimport { toArray } from \"./toArray.js\";\r\nexport const singleOrDefaultAsync = async (source, predicate) => {\r\n const results = await toArray(source);\r\n let hasValue = false;\r\n let singleValue = null;\r\n for (const value of results) {\r\n if (await predicate(value) === true) {\r\n if (hasValue === true) {\r\n throw new InvalidOperationException(ErrorString.MoreThanOneElement);\r\n }\r\n else {\r\n hasValue = true;\r\n singleValue = value;\r\n }\r\n }\r\n }\r\n return singleValue;\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const skip = (source, count) => {\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 0: {\r\n const generator = async () => (await dataFunc.generator()).slice(count);\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n }\r\n case 1: {\r\n const generator = () => dataFunc.generator().slice(count);\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 1,\r\n });\r\n }\r\n case 2: {\r\n const generator = async () => {\r\n const dataInner = await dataFunc.generator();\r\n return dataInner.slice(count);\r\n };\r\n const dataFuncNew = {\r\n generator,\r\n type: 2,\r\n };\r\n return new BasicParallelEnumerable(dataFuncNew);\r\n }\r\n }\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const skipWhile = (source, predicate) => {\r\n const generator = async () => {\r\n const values = await source.toArray();\r\n let i = 0;\r\n for (; i < values.length; i++) {\r\n const value = values[i];\r\n if (predicate(value, i) === false) {\r\n break;\r\n }\r\n }\r\n const returnedValues = [];\r\n for (; i < values.length; i++) {\r\n returnedValues.push(values[i]);\r\n }\r\n return returnedValues;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const skipWhileAsync = (source, predicate) => {\r\n const generator = async () => {\r\n const values = await source.toArray();\r\n let i = 0;\r\n for (; i < values.length; i++) {\r\n const value = values[i];\r\n if (await predicate(value, i) === false) {\r\n break;\r\n }\r\n }\r\n const returnedValues = [];\r\n for (; i < values.length; i++) {\r\n returnedValues.push(values[i]);\r\n }\r\n return returnedValues;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "export const sum = (source, selector) => {\r\n if (selector) {\r\n return sum2(source, selector);\r\n }\r\n else {\r\n return sum1(source);\r\n }\r\n};\r\nconst sum1 = async (source) => {\r\n let totalSum = 0;\r\n for (const value of await source.toArray()) {\r\n totalSum += value;\r\n }\r\n return totalSum;\r\n};\r\nconst sum2 = async (source, selector) => {\r\n let total = 0;\r\n for (const value of await source.toArray()) {\r\n total += selector(value);\r\n }\r\n return total;\r\n};\r\n", "import { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const sumAsync = async (source, selector) => {\r\n const dataFunc = nextIterationAsync(source, selector);\r\n const values = await typeDataToArray(dataFunc);\r\n let sum = 0;\r\n for (const value of values) {\r\n sum += value;\r\n }\r\n return sum;\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const take = (source, amount) => {\r\n const amountLeft = amount > 0 ? amount : 0;\r\n const dataFunc = source.dataFunc;\r\n switch (dataFunc.type) {\r\n case 1:\r\n const generator1 = () => dataFunc.generator().splice(0, amountLeft);\r\n return new BasicParallelEnumerable({\r\n generator: generator1,\r\n type: 1,\r\n });\r\n case 2:\r\n const generator2 = () => dataFunc.generator().then((x) => x.splice(0, amountLeft));\r\n return new BasicParallelEnumerable({\r\n generator: generator2,\r\n type: 2,\r\n });\r\n case 0:\r\n default:\r\n const generator3 = () => dataFunc.generator().then((x) => x.splice(0, amountLeft));\r\n return new BasicParallelEnumerable({\r\n generator: generator3,\r\n type: 0,\r\n });\r\n }\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const takeWhile = (source, predicate) => {\r\n const generator = async () => {\r\n const values = await source.toArray();\r\n const results = new Array();\r\n if (predicate.length === 1) {\r\n for (const value of values) {\r\n if (predicate(value) === true) {\r\n results.push(value);\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n else {\r\n for (let i = 0; i < values.length; i++) {\r\n const value = values[i];\r\n if (predicate(value, i) === true) {\r\n results.push(value);\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const takeWhileAsync = (source, predicate) => {\r\n const generator = async () => {\r\n const values = await source.toArray();\r\n const results = new Array();\r\n if (predicate.length === 1) {\r\n const sPredicate = predicate;\r\n for (const value of values) {\r\n if (await sPredicate(value) === true) {\r\n results.push(value);\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n else {\r\n for (let i = 0; i < values.length; i++) {\r\n const value = values[i];\r\n if (await predicate(value, i) === true) {\r\n results.push(value);\r\n }\r\n else {\r\n break;\r\n }\r\n }\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { nextIteration } from \"./_nextIteration.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const toMap = async (source, selector) => {\r\n const map = new Map();\r\n const dataFunc = nextIteration(source, (value) => {\r\n const key = selector(value);\r\n return [key, value];\r\n });\r\n const keyValues = await typeDataToArray(dataFunc);\r\n for (const [key, value] of keyValues) {\r\n const array = map.get(key);\r\n if (array === undefined) {\r\n map.set(key, [value]);\r\n }\r\n else {\r\n array.push(value);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const toMapAsync = async (source, selector) => {\r\n const map = new Map();\r\n const dataFunc = nextIterationAsync(source, async (value) => {\r\n const key = await selector(value);\r\n return [key, value];\r\n });\r\n const keyValues = await typeDataToArray(dataFunc);\r\n for (const [key, value] of keyValues) {\r\n const array = map.get(key);\r\n if (array === undefined) {\r\n map.set(key, [value]);\r\n }\r\n else {\r\n array.push(value);\r\n }\r\n }\r\n return map;\r\n};\r\n", "import { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const toObject = async (source, selector) => {\r\n const dataFunc = source.dataFunc;\r\n const values = await typeDataToArray(dataFunc);\r\n const map = {};\r\n for (const value of values) {\r\n map[selector(value)] = value;\r\n }\r\n return map;\r\n};\r\n", "import { nextIterationAsync } from \"./_nextIterationAsync.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const toObjectAsync = async (source, selector) => {\r\n const dataFunc = nextIterationAsync(source, async (value) => {\r\n const key = await selector(value);\r\n return [key, value];\r\n });\r\n const keyValues = await typeDataToArray(dataFunc);\r\n const map = {};\r\n for (const [key, value] of keyValues) {\r\n map[key] = value;\r\n }\r\n return map;\r\n};\r\n", "import { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const toSet = async (source) => {\r\n const dataFunc = source.dataFunc;\r\n const values = await typeDataToArray(dataFunc);\r\n return new Set(values);\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const union = (first, second, comparer) => {\r\n if (comparer) {\r\n return union2(first, second, comparer);\r\n }\r\n else {\r\n return union1(first, second);\r\n }\r\n};\r\nconst union1 = (first, second) => {\r\n const generator = async () => {\r\n const set = new Set();\r\n const secondPromise = second.toArray();\r\n for await (const item of first) {\r\n if (set.has(item) === false) {\r\n set.add(item);\r\n }\r\n }\r\n const secondValues = await secondPromise;\r\n for (const item of secondValues) {\r\n if (set.has(item) === false) {\r\n set.add(item);\r\n }\r\n }\r\n return [...set.keys()];\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\nconst union2 = (first, second, comparer) => {\r\n const generator = async () => {\r\n const result = [];\r\n const values = await Promise.all([first.toArray(), second.toArray()]);\r\n for (const source of values) {\r\n for (const value of source) {\r\n let exists = false;\r\n for (const resultValue of result) {\r\n if (comparer(value, resultValue) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n result.push(value);\r\n }\r\n }\r\n }\r\n return result;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const unionAsync = (first, second, comparer) => {\r\n const generator = async () => {\r\n const result = [];\r\n const values = await Promise.all([first.toArray(), second.toArray()]);\r\n for (const source of values) {\r\n for (const value of source) {\r\n let exists = false;\r\n for (const resultValue of result) {\r\n if (await comparer(value, resultValue) === true) {\r\n exists = true;\r\n break;\r\n }\r\n }\r\n if (exists === false) {\r\n result.push(value);\r\n }\r\n }\r\n }\r\n return result;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const where = (source, predicate) => {\r\n const generator = async () => {\r\n const values = await source.toArray();\r\n return values.filter(predicate);\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nimport { nextIterationWithIndexAsync } from \"./_nextIterationWithIndexAsync.js\";\r\nimport { typeDataToArray } from \"./_typeDataToArray.js\";\r\nexport const whereAsync = (source, predicate) => {\r\n const generator = async () => {\r\n const dataFunc = nextIterationWithIndexAsync(source, async (value, index) => {\r\n const keep = await predicate(value, index);\r\n return [keep, value];\r\n });\r\n const valuesAsync = await typeDataToArray(dataFunc);\r\n const filteredValues = [];\r\n for (const [keep, value] of valuesAsync) {\r\n if (keep) {\r\n filteredValues.push(value);\r\n }\r\n }\r\n return filteredValues;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const zip = (first, second, resultSelector) => {\r\n if (resultSelector) {\r\n return zip2(first, second, resultSelector);\r\n }\r\n else {\r\n return zip1(first, second);\r\n }\r\n};\r\nconst zip1 = (source, second) => {\r\n const generator = async () => {\r\n const [left, right] = await Promise.all([source.toArray(), second.toArray()]);\r\n const minLength = left.length < right.length ? left.length : right.length;\r\n const results = new Array(minLength);\r\n for (let i = 0; i < minLength; i++) {\r\n const a = left[i];\r\n const b = right[i];\r\n results[i] = [a, b];\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\nconst zip2 = (source, second, resultSelector) => {\r\n const generator = async () => {\r\n const [left, right] = await Promise.all([source.toArray(), second.toArray()]);\r\n const minLength = left.length < right.length ? left.length : right.length;\r\n const results = new Array(minLength);\r\n for (let i = 0; i < minLength; i++) {\r\n const a = left[i];\r\n const b = right[i];\r\n results[i] = resultSelector(a, b);\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const zipAsync = (first, second, resultSelector) => {\r\n const generator = async () => {\r\n const [left, right] = await Promise.all([first.toArray(), second.toArray()]);\r\n const minLength = left.length < right.length ? left.length : right.length;\r\n const resultPromises = new Array(minLength);\r\n for (let i = 0; i < minLength; i++) {\r\n const a = left[i];\r\n const b = right[i];\r\n resultPromises[i] = resultSelector(a, b);\r\n }\r\n return Promise.all(resultPromises);\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { aggregate } from \"./../parallel/_private/aggregate.js\";\r\nimport { all } from \"./../parallel/_private/all.js\";\r\nimport { allAsync } from \"./../parallel/_private/allAsync.js\";\r\nimport { any } from \"./../parallel/_private/any.js\";\r\nimport { anyAsync } from \"./../parallel/_private/anyAsync.js\";\r\nimport { asAsync } from \"./../parallel/_private/asAsync.js\";\r\nimport { average } from \"./../parallel/_private/average.js\";\r\nimport { averageAsync } from \"./../parallel/_private/averageAsync.js\";\r\nimport { chunk } from \"./../parallel/_private/chunk.js\";\r\nimport { concatenate } from \"../parallel/_private/concatenate.js\";\r\nimport { contains } from \"./../parallel/_private/contains.js\";\r\nimport { containsAsync } from \"./../parallel/_private/containsAsync.js\";\r\nimport { count } from \"./../parallel/_private/count.js\";\r\nimport { countAsync } from \"./../parallel/_private/countAsync.js\";\r\nimport { defaultIfEmpty } from \"./../parallel/_private/defaultIfEmpty.js\";\r\nimport { distinct } from \"./../parallel/_private/distinct.js\";\r\nimport { distinctAsync } from \"./../parallel/_private/distinctAsync.js\";\r\nimport { each } from \"./../parallel/_private/each.js\";\r\nimport { eachAsync } from \"./../parallel/_private/eachAsync.js\";\r\nimport { elementAt } from \"./../parallel/_private/elementAt.js\";\r\nimport { elementAtOrDefault } from \"./../parallel/_private/elementAtOrDefault.js\";\r\nimport { except } from \"./../parallel/_private/except.js\";\r\nimport { exceptAsync } from \"./../parallel/_private/exceptAsync.js\";\r\nimport { first } from \"./../parallel/_private/first.js\";\r\nimport { firstAsync } from \"./../parallel/_private/firstAsync.js\";\r\nimport { firstOrDefault } from \"./../parallel/_private/firstOrDefault.js\";\r\nimport { firstOrDefaultAsync } from \"./../parallel/_private/firstOrDefaultAsync.js\";\r\nimport { groupBy } from \"./../parallel/_private/groupBy.js\";\r\nimport { groupByAsync } from \"./../parallel/_private/groupByAsync.js\";\r\nimport { groupByWithSel } from \"./../parallel/_private/groupByWithSel.js\";\r\nimport { groupJoin } from \"./../parallel/_private/groupJoin.js\";\r\nimport { groupJoinAsync } from \"./../parallel/_private/groupJoinAsync.js\";\r\nimport { intersect } from \"./../parallel/_private/intersect.js\";\r\nimport { intersectAsync } from \"./../parallel/_private/intersectAsync.js\";\r\nimport { join } from \"./../parallel/_private/join.js\";\r\nimport { last } from \"./../parallel/_private/last.js\";\r\nimport { lastAsync } from \"./../parallel/_private/lastAsync.js\";\r\nimport { lastOrDefault } from \"./../parallel/_private/lastOrDefault.js\";\r\nimport { lastOrDefaultAsync } from \"./../parallel/_private/lastOrDefaultAsync.js\";\r\nimport { max } from \"./../parallel/_private/max.js\";\r\nimport { maxAsync } from \"./../parallel/_private/maxAsync.js\";\r\nimport { min } from \"./../parallel/_private/min.js\";\r\nimport { minAsync } from \"./../parallel/_private/minAsync.js\";\r\nimport { ofType } from \"./../parallel/_private/ofType.js\";\r\nimport { orderBy } from \"./../parallel/_private/orderBy.js\";\r\nimport { orderByAsync } from \"./../parallel/_private/orderByAsync.js\";\r\nimport { orderByDescending } from \"./../parallel/_private/orderByDescending.js\";\r\nimport { orderByDescendingAsync } from \"./../parallel/_private/orderByDescendingAsync.js\";\r\nimport { partition } from \"./../parallel/_private/partition.js\";\r\nimport { partitionAsync } from \"./../parallel/_private/partitionAsync.js\";\r\nimport { reverse } from \"./../parallel/_private/reverse.js\";\r\nimport { select } from \"./../parallel/_private/select.js\";\r\nimport { selectAsync } from \"./../parallel/_private/selectAsync.js\";\r\nimport { selectMany } from \"./../parallel/_private/selectMany.js\";\r\nimport { selectManyAsync } from \"./../parallel/_private/selectManyAsync.js\";\r\nimport { sequenceEquals } from \"./../parallel/_private/sequenceEquals.js\";\r\nimport { sequenceEqualsAsync } from \"./../parallel/_private/sequenceEqualsAsync.js\";\r\nimport { single } from \"./../parallel/_private/single.js\";\r\nimport { singleAsync } from \"./../parallel/_private/singleAsync.js\";\r\nimport { singleOrDefault } from \"./../parallel/_private/singleOrDefault.js\";\r\nimport { singleOrDefaultAsync } from \"./../parallel/_private/singleOrDefaultAsync.js\";\r\nimport { skip } from \"./../parallel/_private/skip.js\";\r\nimport { skipWhile } from \"./../parallel/_private/skipWhile.js\";\r\nimport { skipWhileAsync } from \"./../parallel/_private/skipWhileAsync.js\";\r\nimport { sum } from \"./../parallel/_private/sum.js\";\r\nimport { sumAsync } from \"./../parallel/_private/sumAsync.js\";\r\nimport { take } from \"./../parallel/_private/take.js\";\r\nimport { takeWhile } from \"./../parallel/_private/takeWhile.js\";\r\nimport { takeWhileAsync } from \"./../parallel/_private/takeWhileAsync.js\";\r\nimport { toArray } from \"./../parallel/_private/toArray.js\";\r\nimport { toMap } from \"./../parallel/_private/toMap.js\";\r\nimport { toMapAsync } from \"./../parallel/_private/toMapAsync.js\";\r\nimport { toObject } from \"./../parallel/_private/toObject.js\";\r\nimport { toObjectAsync } from \"./../parallel/_private/toObjectAsync.js\";\r\nimport { toSet } from \"./../parallel/_private/toSet.js\";\r\nimport { union } from \"./../parallel/_private/union.js\";\r\nimport { unionAsync } from \"./../parallel/_private/unionAsync.js\";\r\nimport { where } from \"./../parallel/_private/where.js\";\r\nimport { whereAsync } from \"./../parallel/_private/whereAsync.js\";\r\nimport { zip } from \"./../parallel/_private/zip.js\";\r\nimport { zipAsync } from \"./../parallel/_private/zipAsync.js\";\r\nexport const bindLinqParallel = (object) => {\r\n const prototype = object.prototype;\r\n const bind = (func, key) => {\r\n const wrapped = function (...params) {\r\n return func(this, ...params);\r\n };\r\n Object.defineProperty(wrapped, \"length\", { value: func.length - 1 });\r\n prototype[key] = wrapped;\r\n };\r\n bind(aggregate, \"aggregate\");\r\n bind(all, \"all\");\r\n bind(allAsync, \"allAsync\");\r\n bind(any, \"any\");\r\n bind(anyAsync, \"anyAsync\");\r\n bind(asAsync, \"asAsync\");\r\n bind(average, \"average\");\r\n bind(averageAsync, \"averageAsync\");\r\n bind(chunk, \"chunk\");\r\n bind(concatenate, \"concatenate\");\r\n bind(contains, \"contains\");\r\n bind(containsAsync, \"containsAsync\");\r\n bind(count, \"count\");\r\n bind(countAsync, \"countAsync\");\r\n bind(defaultIfEmpty, \"defaultIfEmpty\");\r\n bind(distinct, \"distinct\");\r\n bind(distinctAsync, \"distinctAsync\");\r\n bind(each, \"each\");\r\n bind(eachAsync, \"eachAsync\");\r\n bind(elementAt, \"elementAt\");\r\n bind(elementAtOrDefault, \"elementAtOrDefault\");\r\n bind(except, \"except\");\r\n bind(exceptAsync, \"exceptAsync\");\r\n bind(first, \"first\");\r\n bind(firstAsync, \"firstAsync\");\r\n bind(firstOrDefault, \"firstOrDefault\");\r\n bind(firstOrDefaultAsync, \"firstOrDefaultAsync\");\r\n bind(groupBy, \"groupBy\");\r\n bind(groupByAsync, \"groupByAsync\");\r\n bind(groupByWithSel, \"groupByWithSel\");\r\n bind(groupJoin, \"groupJoin\");\r\n bind(groupJoinAsync, \"groupJoinAsync\");\r\n bind(groupJoin, \"groupJoin\");\r\n bind(groupJoinAsync, \"groupJoinAsync\");\r\n bind(intersect, \"intersect\");\r\n bind(intersectAsync, \"intersectAsync\");\r\n bind(join, \"joinByKey\");\r\n bind(last, \"last\");\r\n bind(lastAsync, \"lastAsync\");\r\n bind(lastOrDefault, \"lastOrDefault\");\r\n bind(lastOrDefaultAsync, \"lastOrDefaultAsync\");\r\n bind(max, \"max\");\r\n bind(maxAsync, \"maxAsync\");\r\n bind(min, \"min\");\r\n bind(minAsync, \"minAsync\");\r\n bind(ofType, \"ofType\");\r\n bind(orderBy, \"orderBy\");\r\n bind(orderByAsync, \"orderByAsync\");\r\n bind(orderByDescending, \"orderByDescending\");\r\n bind(orderByDescendingAsync, \"orderByDescendingAsync\");\r\n bind(partition, \"partition\");\r\n bind(partitionAsync, \"partitionAsync\");\r\n bind(reverse, \"reverse\");\r\n bind(select, \"select\");\r\n bind(selectAsync, \"selectAsync\");\r\n bind(selectMany, \"selectMany\");\r\n bind(selectManyAsync, \"selectManyAsync\");\r\n bind(sequenceEquals, \"sequenceEquals\");\r\n bind(sequenceEqualsAsync, \"sequenceEqualsAsync\");\r\n bind(single, \"single\");\r\n bind(singleAsync, \"singleAsync\");\r\n bind(singleOrDefault, \"singleOrDefault\");\r\n bind(singleOrDefaultAsync, \"singleOrDefaultAsync\");\r\n bind(skip, \"skip\");\r\n bind(skipWhile, \"skipWhile\");\r\n bind(skipWhileAsync, \"skipWhileAsync\");\r\n bind(sum, \"sum\");\r\n bind(sumAsync, \"sumAsync\");\r\n bind(take, \"take\");\r\n bind(takeWhile, \"takeWhile\");\r\n bind(takeWhileAsync, \"takeWhileAsync\");\r\n bind(toArray, \"toArray\");\r\n bind(toMap, \"toMap\");\r\n bind(toMapAsync, \"toMapAsync\");\r\n bind(toObject, \"toObject\");\r\n bind(toObjectAsync, \"toObjectAsync\");\r\n bind(toSet, \"toSet\");\r\n bind(union, \"union\");\r\n bind(unionAsync, \"unionAsync\");\r\n bind(where, \"where\");\r\n bind(whereAsync, \"whereAsync\");\r\n bind(zip, \"zip\");\r\n bind(zipAsync, \"zipAsync\");\r\n};\r\n", "import { ArgumentOutOfRangeException, ErrorString, InvalidOperationException } from \"../shared/index.js\";\r\nimport { BasicEnumerable } from \"../sync/BasicEnumerable.js\";\r\nexport const bindString = () => {\r\n var _a;\r\n const prototype = String.prototype;\r\n const propertyNames = Object.getOwnPropertyNames(BasicEnumerable.prototype);\r\n for (const prop of propertyNames) {\r\n prototype[prop] = (_a = prototype[prop]) !== null && _a !== void 0 ? _a : BasicEnumerable.prototype[prop];\r\n }\r\n prototype.first = function (predicate) {\r\n if (predicate) {\r\n for (let i = 0; i < this.length; i++) {\r\n const value = this[i];\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n if (this.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return this[0];\r\n };\r\n prototype.firstOrDefault = function (predicate) {\r\n if (predicate) {\r\n for (let i = 0; i < this.length; i++) {\r\n const value = this[i];\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n }\r\n return this.length === 0 ? null : this[0];\r\n };\r\n prototype.count = function (predicate) {\r\n if (predicate) {\r\n let count = 0;\r\n for (let i = 0; i < this.length; i++) {\r\n if (predicate(this[i]) === true) {\r\n count++;\r\n }\r\n }\r\n return count;\r\n }\r\n else {\r\n return this.length;\r\n }\r\n };\r\n prototype.elementAt = function (index) {\r\n if (index < 0 || index >= this.length) {\r\n throw new ArgumentOutOfRangeException(\"index\");\r\n }\r\n return this[index];\r\n };\r\n prototype.elementAtOrDefault = function (index) {\r\n return this[index] || null;\r\n };\r\n prototype.last = function (predicate) {\r\n if (predicate) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n const value = this[i];\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n throw new InvalidOperationException(ErrorString.NoMatch);\r\n }\r\n else {\r\n if (this.length === 0) {\r\n throw new InvalidOperationException(ErrorString.NoElements);\r\n }\r\n return this[this.length - 1];\r\n }\r\n };\r\n prototype.lastOrDefault = function (predicate) {\r\n if (predicate) {\r\n for (let i = this.length - 1; i >= 0; i--) {\r\n const value = this[i];\r\n if (predicate(value) === true) {\r\n return value;\r\n }\r\n }\r\n return null;\r\n }\r\n else {\r\n return this.length === 0 ? null : this[this.length - 1];\r\n }\r\n };\r\n prototype.reverse = function () {\r\n const outer = this;\r\n function* generator() {\r\n for (let i = outer.length - 1; i >= 0; i--) {\r\n yield outer[i];\r\n }\r\n }\r\n return new BasicEnumerable(generator);\r\n };\r\n};\r\n", "import { bindArray } from \"./bindArray.js\";\r\nimport { bindString } from \"./bindString.js\";\r\nimport { bindLinq } from \"./bindLinq.js\";\r\nexport const initializeLinq = () => {\r\n bindLinq(Map);\r\n bindLinq(Set);\r\n bindString();\r\n bindArray(Array);\r\n bindArray(Int8Array);\r\n bindArray(Int16Array);\r\n bindArray(Int32Array);\r\n bindArray(Uint8Array);\r\n bindArray(Uint8ClampedArray);\r\n bindArray(Uint16Array);\r\n bindArray(Uint32Array);\r\n bindArray(Float32Array);\r\n bindArray(Float64Array);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../async/BasicAsyncEnumerable.js\";\r\nimport { BasicParallelEnumerable } from \"../parallel/BasicParallelEnumerable.js\";\r\nimport { BasicEnumerable } from \"../sync/BasicEnumerable.js\";\r\nimport { bindArray } from \"./bindArray.js\";\r\nimport { bindArrayEnumerable } from \"./bindArrayEnumerable.js\";\r\nimport { bindLinq } from \"./bindLinq.js\";\r\nimport { bindLinqAsync } from \"./bindLinqAsync.js\";\r\nimport { bindLinqParallel } from \"./bindLinqParallel.js\";\r\nimport { bindString } from \"./bindString.js\";\r\nbindLinq(BasicEnumerable);\r\nbindLinqAsync(BasicAsyncEnumerable);\r\nbindLinqParallel(BasicParallelEnumerable);\r\nbindArrayEnumerable();\r\nexport { bindLinq, bindLinqAsync, bindArray, bindString };\r\nexport { initializeLinq } from \"./initializeLinq.js\";\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const empty = () => {\r\n return new BasicEnumerable(function* () { });\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const enumerateObject = (source) => {\r\n function* iterable() {\r\n for (const key in source) {\r\n yield [key, source[key]];\r\n }\r\n }\r\n return new BasicEnumerable(iterable);\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const flatten = (source, shallow) => {\r\n function* iterator(source) {\r\n for (const item of source) {\r\n if (item[Symbol.iterator] !== undefined && typeof item !== \"string\") {\r\n yield* shallow ? item : iterator(item);\r\n }\r\n else {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicEnumerable(() => iterator(source));\r\n};\r\n", "import { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const from = (source) => {\r\n const isArrayLike = (x) => {\r\n return Array.isArray(x) || (typeof x === \"object\" && typeof x.length === \"number\" && (x.length === 0 || 0 in x));\r\n };\r\n const isIterableType = (x) => typeof x === \"function\";\r\n if (isArrayLike(source)) {\r\n const generator = function* () {\r\n for (let i = 0; i < source.length; i++) {\r\n yield source[i];\r\n }\r\n };\r\n return new BasicEnumerable(generator);\r\n }\r\n if (isIterableType(source)) {\r\n return new BasicEnumerable(source);\r\n }\r\n return new BasicEnumerable(function* () {\r\n for (const val of source) {\r\n yield val;\r\n }\r\n });\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nimport { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const range = (start, count) => {\r\n if (start < 0 || (start + count - 1) > Number.MAX_SAFE_INTEGER) {\r\n throw new ArgumentOutOfRangeException(\"start\");\r\n }\r\n function* iterator() {\r\n const max = start + count;\r\n for (let i = start; i < max; i++) {\r\n yield i;\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nimport { BasicEnumerable } from \"../BasicEnumerable.js\";\r\nexport const repeat = (element, count) => {\r\n if (count < 0) {\r\n throw new ArgumentOutOfRangeException(\"count\");\r\n }\r\n function* iterator() {\r\n for (let i = 0; i < count; i++) {\r\n yield element;\r\n }\r\n }\r\n return new BasicEnumerable(iterator);\r\n};\r\n", "export { empty } from \"./empty.js\";\r\nexport { enumerateObject } from \"./enumerateObject.js\";\r\nexport { flatten } from \"./flatten.js\";\r\nexport { from } from \"./from.js\";\r\nexport { range } from \"./range.js\";\r\nexport { repeat } from \"./repeat.js\";\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const emptyAsync = () => {\r\n return new BasicAsyncEnumerable(async function* iterable() { });\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const enumerateObjectAsync = (source) => {\r\n async function* iterable() {\r\n for (const key in source) {\r\n yield [key, source[key]];\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterable);\r\n};\r\n", "import { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const flattenAsync = (source, shallow) => {\r\n async function* iterator(sourceInner) {\r\n for await (const item of sourceInner) {\r\n if (item[Symbol.asyncIterator] !== undefined) {\r\n const items = shallow ? item : iterator(item);\r\n for await (const inner of items) {\r\n yield inner;\r\n }\r\n }\r\n else {\r\n yield item;\r\n }\r\n }\r\n }\r\n return new BasicAsyncEnumerable(() => iterator(source));\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const rangeAsync = (start, count) => {\r\n if (start < 0 || (start + count - 1) > Number.MAX_SAFE_INTEGER) {\r\n throw new ArgumentOutOfRangeException(\"start\");\r\n }\r\n async function* iterator() {\r\n const max = start + count;\r\n for (let i = start; i < max; i++) {\r\n yield i;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nimport { BasicAsyncEnumerable } from \"../BasicAsyncEnumerable.js\";\r\nexport const repeatAsync = (element, count, delay) => {\r\n if (count < 0) {\r\n throw new ArgumentOutOfRangeException(\"count\");\r\n }\r\n if (delay) {\r\n return repeat2(element, count, delay);\r\n }\r\n else {\r\n return repeat1(element, count);\r\n }\r\n};\r\nconst repeat1 = (element, count) => {\r\n async function* iterator() {\r\n for (let i = 0; i < count; i++) {\r\n yield element;\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\nconst repeat2 = (element, count, delay) => {\r\n async function* iterator() {\r\n for (let i = 0; i < count; i++) {\r\n yield await new Promise((resolve) => setTimeout(() => resolve(element), delay));\r\n }\r\n }\r\n return new BasicAsyncEnumerable(iterator);\r\n};\r\n", "export { emptyAsync } from \"./emptyAsync.js\";\r\nexport { enumerateObjectAsync } from \"./enumerateObjectAsync.js\";\r\nexport { flattenAsync } from \"./flattenAsync.js\";\r\nexport { fromAsync } from \"./fromAsync.js\";\r\nexport { rangeAsync } from \"./rangeAsync.js\";\r\nexport { repeatAsync } from \"./repeatAsync.js\";\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const emptyParallel = () => {\r\n const dataFunc = {\r\n generator: async () => [],\r\n type: 0,\r\n };\r\n return new BasicParallelEnumerable(dataFunc);\r\n};\r\n", "import { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const flattenParallel = (source, shallow) => {\r\n async function* iterator(sourceInner) {\r\n for await (const item of sourceInner) {\r\n if (item[Symbol.asyncIterator] !== undefined) {\r\n const items = shallow ? item : iterator(item);\r\n for await (const inner of items) {\r\n yield inner;\r\n }\r\n }\r\n else {\r\n yield item;\r\n }\r\n }\r\n }\r\n const generator = async () => {\r\n const results = [];\r\n for await (const x of iterator(source)) {\r\n results.push(x);\r\n }\r\n return results;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const rangeParallel = (start, count) => {\r\n if (start < 0 || (start + count - 1) > Number.MAX_SAFE_INTEGER) {\r\n throw new ArgumentOutOfRangeException(\"start\");\r\n }\r\n const generator = () => {\r\n const items = [];\r\n const maxI = start + count;\r\n for (let i = start; i < maxI; i++) {\r\n items.push(Promise.resolve(i));\r\n }\r\n return items;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 1,\r\n });\r\n};\r\n", "import { ArgumentOutOfRangeException } from \"../../shared/index.js\";\r\nimport { BasicParallelEnumerable } from \"../BasicParallelEnumerable.js\";\r\nexport const repeatParallel = (element, count, delay) => {\r\n if (count < 0) {\r\n throw new ArgumentOutOfRangeException(\"count\");\r\n }\r\n if (delay) {\r\n return repeat2(element, count, delay);\r\n }\r\n else {\r\n return repeat1(element, count);\r\n }\r\n};\r\nconst repeat1 = (element, count) => {\r\n const generator = async () => {\r\n const values = new Array(count);\r\n for (let i = 0; i < count; i++) {\r\n values[i] = element;\r\n }\r\n return values;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 0,\r\n });\r\n};\r\nconst repeat2 = (element, count, delay) => {\r\n const generator = async () => {\r\n const values = new Array(count);\r\n for (let i = 0; i < count; i++) {\r\n values[i] = new Promise((resolve) => setTimeout(() => resolve(element), delay));\r\n }\r\n return values;\r\n };\r\n return new BasicParallelEnumerable({\r\n generator,\r\n type: 2,\r\n });\r\n};\r\n", "export { emptyParallel } from \"./emptyParallel.js\";\r\nexport { flattenParallel } from \"./flattenParallel.js\";\r\nexport { fromParallel } from \"./fromParallel.js\";\r\nexport { rangeParallel } from \"./rangeParallel.js\";\r\nexport { repeatParallel } from \"./repeatParallel.js\";\r\n", "import { ArrayEnumerable } from \"./ArrayEnumerable.js\";\r\nimport { BasicEnumerable } from \"./BasicEnumerable.js\";\r\nexport const isEnumerable = (source) => {\r\n if (!source) {\r\n return false;\r\n }\r\n if (source instanceof BasicEnumerable) {\r\n return true;\r\n }\r\n if (source instanceof ArrayEnumerable) {\r\n return true;\r\n }\r\n if (typeof source[Symbol.iterator] !== \"function\") {\r\n return false;\r\n }\r\n const propertyNames = Object.getOwnPropertyNames(BasicEnumerable.prototype)\r\n .filter((v) => v !== \"constructor\");\r\n const methods = source.prototype || source;\r\n for (const prop of propertyNames) {\r\n if (typeof methods[prop] !== \"function\") {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "import { BasicParallelEnumerable } from \"./BasicParallelEnumerable.js\";\r\nexport const isParallelEnumerable = (source) => {\r\n if (!source) {\r\n return false;\r\n }\r\n if (source instanceof BasicParallelEnumerable) {\r\n return true;\r\n }\r\n if (typeof source[Symbol.asyncIterator] !== \"function\") {\r\n return false;\r\n }\r\n const propertyNames = Object.getOwnPropertyNames(BasicParallelEnumerable.prototype)\r\n .filter((v) => v !== \"constructor\");\r\n const methods = source.prototype || source;\r\n for (const prop of propertyNames) {\r\n if (typeof methods[prop] !== \"function\") {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "import { BasicAsyncEnumerable } from \"./BasicAsyncEnumerable.js\";\r\nexport const isAsyncEnumerable = (source) => {\r\n if (!source) {\r\n return false;\r\n }\r\n if (source instanceof BasicAsyncEnumerable) {\r\n return true;\r\n }\r\n if (typeof source[Symbol.asyncIterator] !== \"function\") {\r\n return false;\r\n }\r\n const propertyNames = Object.getOwnPropertyNames(BasicAsyncEnumerable.prototype)\r\n .filter((v) => v !== \"constructor\");\r\n const methods = source.prototype || source;\r\n for (const prop of propertyNames) {\r\n if (typeof methods[prop] !== \"function\") {\r\n return false;\r\n }\r\n }\r\n return true;\r\n};\r\n", "export * from \"./types/index.js\";\r\nexport * from \"./shared/index.js\";\r\nexport { ArrayEnumerable } from \"./sync/ArrayEnumerable.js\";\r\nexport * from \"./initializer/initializer.js\";\r\nexport * from \"./sync/static/index.js\";\r\nexport * from \"./async/static/index.js\";\r\nexport * from \"./parallel/static/index.js\";\r\nexport { isEnumerable } from \"./sync/isEnumerable.js\";\r\nexport { isParallelEnumerable } from \"./parallel/isParallelEnumerable.js\";\r\nexport { isAsyncEnumerable } from \"./async/isAsyncEnumerable.js\";\r\n", "// 0. Import Module\n\nimport {IEnumerable, initializeLinq} from \"linq-to-typescript\"\n// 1. Declare that the JS types implement the IEnumerable interface\ndeclare global {\n interface Array extends IEnumerable { }\n interface Uint8Array extends IEnumerable { }\n interface Uint8ClampedArray extends IEnumerable { }\n interface Uint16Array extends IEnumerable { }\n interface Uint32Array extends IEnumerable { }\n interface Int8Array extends IEnumerable { }\n interface Int16Array extends IEnumerable { }\n interface Int32Array extends IEnumerable { }\n interface Float32Array extends IEnumerable { }\n interface Float64Array extends IEnumerable { }\n interface Map extends IEnumerable<[K, V]> { }\n interface Set extends IEnumerable { }\n interface String extends IEnumerable { }\n}\n// 2. Bind Linq Functions to Array, Map, etc\ninitializeLinq()", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n//# sourceMappingURL=types.js.map", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "import './utils/linq'\nimport {IncomingMessage} from \"http\";\nimport {getLogger} from \"./utils/logging\";\nimport {getPath} from \"./server/utils/utils\";\nimport HTTP, {HttpResponse} from \"./server/utils/httpResponse\";\nimport {getRequestJson} from \"./server/utils/requestUtils\";\nimport {isDefined, isUndefined} from \"./utils/maybe\";\nimport {ServerRequest} from \"./api/serverCommand\";\nimport {AccountState, LoggedIn, loggedOut, ServerState} from \"./api/serverState\";\nimport {base, match, unwrap} from \"./utils/match\";\nimport {DbReply, dispatchCommand, getAccountState, login} from \"./server/db\";\nimport {DbObject, User, UserTypes} from \"./api/data/types\";\nimport {isUser} from \"./api/data/isA\";\n\nconst log = getLogger('SERVER')\nconst wwwDir = __dirname + '/www';\nconst staticFileHeaders = {};\nconst port = 8080\n\n// const test = {foo:1 , bar:\"asf\"}\n//\n//\n// const draft = createDraft(test)\n// const t1 = draft.foo;\n// const x = finishDraft(draft)\n// const t2 = original(draft)\n//\n// const t3 = 0\n\nfunction removeUsers(children: DbObject[])\n{\n return children.filter(c => !isUser(c))\n}\n\n\n\nfunction removeAllUsers(k: string, v: unknown)\n{\n return k === \"children\"\n ? removeUsers(v as DbObject[])\n : v;\n}\n\nfunction removeOwnerUser(user: User)\n{\n const userId = unwrap(user).id\n\n function remove(k: string, v: unknown)\n {\n return k === \"children\"\n ? (v as DbObject[]).filter(c => unwrap(c).id !== userId)\n : v;\n }\n\n return remove\n}\n\nfunction getReplacer(serverState: ServerState)\n{\n const accountState = serverState.account;\n const user = base(accountState).user;\n const isAdmin = isDefined(user) && unwrap(user).userType === UserTypes.admin\n\n return isAdmin ? removeAllUsers\n : isDefined(user) ? removeOwnerUser(user)\n : undefined;\n}\n\nasync function serve(request: IncomingMessage): Promise\n{\n log(`got request ${request.url}`)\n\n if (request.method === \"GET\")\n return HTTP.file(wwwDir, getPath(request), staticFileHeaders, \"/index.html\")\n\n if (request.method !== \"POST\")\n return HTTP.forbidden()\n\n const serverState = await serveApi(request);\n\n // TODO: no replacer for now because with the new update (instead of remove etc.) users got removed from db\n // const replacer = getReplacer(serverState);\n // return HTTP.json(serverState, replacer)\n\n return HTTP.json(serverState)\n}\n\n\nfunction isLoggedIn(state: AccountState) : state is LoggedIn\n{\n return match(state, {loggedIn: _ => true}, false);\n}\n\nasync function serveApi(request: IncomingMessage): Promise\n{\n const {command, token} = await getRequestJson(request);\n\n if (isUndefined(token))\n return await login(command)\n\n const account = getAccountState(token)\n\n if (!isLoggedIn(account))\n return {...loggedOut, error: \"please log in\"}\n\n const loggedIn = unwrap(account);\n const reply = await dispatchCommand(command)(loggedIn)\n\n return reply === DbReply.Success ? {account}\n : reply === DbReply.LoggedOut ? loggedOut\n : {account, error: reply};\n}\n\n\nconst server = HTTP.createServer(serve);\nlog(`Starting server on port ${port}`)\n\nserver.listen(port);\n\n", "let subsystemPadding = 0\n\nexport function getLogger(subsystem: string): (msg: string) => void\n{\n subsystemPadding = Math.max(subsystem.length, subsystemPadding)\n\n // eslint-disable-next-line no-console\n return (msg: string) => console.log(`${new Date().toLocaleString()} | ${(subsystem.padEnd(subsystemPadding))} | ${msg}`);\n}\n\n\n", "\nimport {IncomingMessage} from \"http\";\nimport {Dictionary} from \"../../utils/utilityTypes\";\nimport {from} from \"linq-to-typescript\";\nimport {isUndefined, Maybe} from \"../../utils/maybe\";\n\ntype StringValued =\n{\n [Key in keyof T]: T[Key] extends number ? Maybe\n : T[Key] extends string ? Maybe\n : T[Key] extends boolean ? Maybe\n : never\n}\n\nexport function getQueryParams(request: IncomingMessage): Maybe>\n{\n if (isUndefined(request.url))\n return undefined\n\n const url = new URL(request.url, `https://${request.headers.host}/`);\n\n const query: Dictionary = {}\n const urlSearchParams = new URLSearchParams(url.search);\n\n if (!from(urlSearchParams.entries()).any())\n return undefined\n\n for (const [key, value] of urlSearchParams.entries())\n query[key] = value;\n\n return query as StringValued;\n}\n\nexport function getPath(req: IncomingMessage)\n{\n return new URL(req.url!, `https://${req.headers.host}/`).pathname;\n}", "export type Maybe = T | undefined | null;\n\nexport function isDefined(e: Maybe): e is T\n{\n return e != undefined // != by design to include null\n}\n\nexport function isUndefined(e: Maybe): e is undefined | null\n{\n return e == undefined // == by design to include null\n}\n\nexport function toArray(e: Maybe): T[]\n{\n return isDefined(e) ? [e] : []\n}\n", "import PlatformPath from \"path\";\nimport {isDefined, isUndefined} from \"../../utils/maybe\";\n\n\nfunction guessFromPath(path: string) : string\n{\n const ext = PlatformPath.parse(path).ext?.substring(1) as keyof typeof MimeType;\n\n const mimeType = MimeType[ext]\n\n return isDefined(mimeType) && typeof mimeType === \"string\"\n ? mimeType\n : 'application/octet-stream'\n}\n\nconst MimeType =\n{\n ico : 'image/x-icon',\n html: 'text/html; charset=UTF-8',\n js : 'text/javascript',\n json: 'application/json; charset=UTF-8',\n css : 'text/css; charset=UTF-8',\n png : 'image/png',\n jpg : 'image/jpeg',\n wav : 'audio/wav',\n mp3 : 'audio/mpeg',\n svg : 'image/svg+xml; charset=UTF-8',\n pdf : 'application/pdf',\n guessFromPath\n};\n\nexport default MimeType", "import {isDefined, isUndefined, Maybe} from \"../../utils/maybe\";\nimport {Dictionary} from \"../../utils/utilityTypes\";\nimport MimeType from \"./mime\";\nimport {promisify} from \"util\";\nimport fs from \"fs\";\nimport http, {IncomingMessage, ServerResponse} from \"http\";\nimport {entries} from \"../../utils/utils\";\nimport {getLogger} from \"../../utils/logging\";\n\nconst log = getLogger(\"HTTP\")\nconst readFile = promisify(fs.readFile)\n\nexport type HttpResponse = {\n body: Maybe\n headers : Dictionary\n statusCode: number\n}\n\n\nfunction contentTypeHeader(mimeType: string)\n{\n return {['Content-type']: mimeType};\n}\n\nfunction forbidden(message = \"403 : forbidden\", headers: Dictionary = {}): HttpResponse\n{\n return text(message, 403, headers)\n}\n\nfunction notFound(message =\"404 : not found\", headers: Dictionary = {}): HttpResponse\n{\n return text(message, 404, headers)\n}\n\nfunction text(text: string, statusCode = 200, headers: Dictionary = {}): HttpResponse\n{\n return {\n statusCode: statusCode,\n headers : {...headers, ...contentTypeHeader('text/plain')},\n body : text\n };\n}\n\nfunction json(json: Dictionary,\n replacer?: (k: string, v: unknown) => unknown,\n headers: Dictionary = {}): HttpResponse\n{\n return {\n statusCode: 200,\n headers : {...headers, ['Content-type']: MimeType.json},\n body: JSON.stringify(json, replacer)\n }\n}\n\nfunction empty(headers: Dictionary = {}): HttpResponse\n{\n return {\n statusCode: 200,\n headers,\n body: undefined\n }\n}\n\nfunction ok(body: Maybe, headers: Dictionary = {}): HttpResponse\n{\n return {\n statusCode: 200,\n headers,\n body\n }\n}\n\nasync function file(localRootPath: string, urlPath: string, headers: Dictionary = {}, defaultPath = \"/\"): Promise\n{\n if (urlPath.contains('..'))\n return HTTP.forbidden();\n\n const localPath = localRootPath + (urlPath === \"/\" ? defaultPath : urlPath);\n\n const body = await readFile(localPath).catch(_ => undefined)\n\n if (isUndefined(body))\n return HTTP.notFound();\n\n if (!('Content-type' in headers))\n {\n headers = {...headers, ...contentTypeHeader(MimeType.guessFromPath(localPath))}\n }\n\n return HTTP.ok(body, headers)\n}\n\nfunction createServer(serve: (request: IncomingMessage) => Promise)\n{\n async function wrapServe(request: IncomingMessage, response: ServerResponse): Promise\n {\n const r = await serve(request)\n\n entries(r.headers).forEach(([k, v]) => response.setHeader(k, v))\n\n response.statusCode = r.statusCode\n\n if (isDefined(r.body))\n response.end(r.body)\n else\n response.end()\n }\n\n return http.createServer(wrapServe);\n}\n\nconst HTTP =\n{\n contentTypeHeader,\n forbidden,\n notFound,\n ok,\n json,\n empty,\n file,\n createServer\n}\n\nexport default HTTP;\n", "import {Dictionary, Func, Lazy} from \"./utilityTypes\";\nimport {isUndefined, Maybe} from \"./maybe\";\nimport {IEnumerable} from \"linq-to-typescript\";\nimport {Builder} from \"../client/njsx/njsx\";\n\nexport const id = (e:T) => e;\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport const nop = (_?:unknown) => {};\n\nexport function sleep(ms: number): Promise\n{\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n\nexport function fail(error?: string) : T\n{\n throw new Error(error)\n}\n\nexport function first(a: Array) : Maybe\n{\n return a[0]\n}\n\nexport function last(array: T[]) : Maybe\n{\n const last = array.length - 1\n\n return last < 0\n ? undefined\n : array[last]\n}\n\n\nexport function compactArray(array: T[])\n{\n let j = 0;\n\n array.forEach((e, i) =>\n {\n if (i !== j)\n array[j] = e;\n j++;\n });\n\n array.length = j;\n\n return array;\n}\n\n\nexport const delay = (ms: number) => new Promise((resolve) => setTimeout(() => resolve(), ms));\n\n\nexport function hasOwnProperty(thing: unknown, key : keyof any)\n{\n return Object.prototype.hasOwnProperty.call(thing, key)\n}\n\nexport function toDictionary(ts: IEnumerable, keySelector: (element: T) => string): Dictionary\n{\n function addEntry(d: Dictionary, t: T)\n {\n const key = keySelector(t);\n d[key] = t;\n return d\n }\n\n return ts.aggregate({}, addEntry)\n}\n\nexport function keys(t: T): (keyof T)[]\n{\n return Object.keys(t as object) as (keyof T)[]\n}\n\n\nexport function values(t: Record): V[]\n{\n return Object.values(t)\n}\n\ntype Entry =\n{\n [P in keyof T]: P extends number ? [`${P}`, T[P]]\n : P extends string ? [P, T[P]]\n : never\n};\n\nexport function entries(t: T)\n{\n return Object.entries(t as Dictionary)\n}\n\nexport function shallowEqual(left: any, right: any)\n{\n const keysLeft = keys(left) ;\n const keysRight = keys(right);\n\n return keysLeft.length === keysRight.length &&\n keysLeft.every(key => Object.prototype.hasOwnProperty.call(right, key) && left[key] === right[key]);\n}\n\n\nexport function objectEquals(x: any, y: any): boolean\n{\n if (isUndefined(x) || isUndefined(y))\n return x === y;\n\n // after this just checking type of one would be enough\n if (x.constructor !== y.constructor)\n return false;\n\n // if they are functions, they should exactly refer to same one (because of closures)\n // if they are regexps, they should exactly refer to same one (it is hard to better equality check on current ES)\n if (x instanceof Function || x instanceof RegExp)\n return x === y;\n\n if (x === y || x.valueOf() === y.valueOf())\n return true;\n\n // optimization\n if (Array.isArray(x) && x.length !== y.length)\n return false;\n\n // optimization: if they are dates, they must have had equal valueOf (above)\n if (x instanceof Date)\n return false;\n\n // if they are strictly equal, they both need to be an object at least\n if (!(x instanceof Object && y instanceof Object)) return false;\n\n\n const xKeys = Object.keys(x);\n const yKeys = Object.keys(y);\n\n // recursive object equality check\n return xKeys.length === yKeys.length\n && yKeys.every(yKey => yKey in x)\n && xKeys.every(xKey => objectEquals(x[xKey], y[xKey]));\n}\n\nexport function structurallyEqual(left: any, right: any)\n{\n if (left === right)\n return true;\n\n if (typeof left !== typeof right)\n return false;\n\n if (typeof left !== 'object')\n return left === right;\n\n if (keys(left).length !== keys(right).length)\n return false;\n\n for (const key in left)\n {\n if (!(key in right))\n return false;\n\n if (!structurallyEqual(left[key], right[key]))\n return false;\n }\n\n return true;\n}\n\n\n\ntype FuncDict ={ [P in keyof T]: (a: T[P]) => any };\ntype Out> = { [P in keyof T]: ReturnType };\n\n// TODO: use Ramda ?\nexport function mapObject>(src: S, map: M): Out>\n{\n const result : Partial>> = {}\n\n for (const k in src)\n result[k] = map[k](src[k])\n\n return result as Out>\n}\n\nexport function mapDict(src: Dictionary, map: (arg: T) => R): Dictionary\n{\n const result : Partial> = {}\n\n for (const k in src)\n result[k] = map(src[k])\n\n return result as Dictionary\n}\n\n\nexport function valueToFunction(tr: Func | R) : Func\n{\n if (typeof tr === \"function\")\n return tr as Func\n\n return (_: T) => tr\n}\n\n\n// export function mapEntries(src: Dictionary, map: (k: string, v: V) => [string, R]): Dictionary\n// {\n// const result: Dictionary = {}\n//\n// entries(src).forEach(([key, value]) =>\n// {\n// const [k, v] = map(key, value)\n// result[k] = v;\n// })\n//\n// return result\n// }\n\nexport function once(action: Builder) : Builder\nexport function once(action: Lazy) : Lazy>\n{\n let done = false;\n return () =>\n {\n if (done)\n return undefined\n\n done = true\n return action()\n }\n}\n\n\n// export function deepMerge(...objects: Record[])\n// {\n// function extracted(prev: Record, cur: Record)\n// {\n// for (const key of keys(cur))\n// {\n// const k = key as K\n//\n// const pVal = prev[k];\n// const oVal = cur[k];\n//\n// if (isArray(pVal) && isArray(oVal))\n// {\n// prev[k] = pVal.concat(...oVal);\n// }\n// else if (isObject(pVal) && isObject(oVal))\n// {\n// prev[k] = deepMerge(pVal, oVal);\n// }\n// else\n// {\n// prev[k] = oVal;\n// }\n// }\n//\n// return prev;\n// }\n//\n// return objects.reduce((prev, cur) => extracted(prev, cur), {} as Record);\n// }\n\n// // Test objects\n// const obj1 = {\n// a: 1,\n// b: 1,\n// c: { x: 1, y: 1 },\n// d: [ 1, 1 ]\n// }\n// const obj2 = {\n// b: 2,\n// c: { y: 2, z: 2 },\n// d: [ 2, 2 ],\n// e: 2\n// }\n// const obj3 = deepMerge(obj1, obj2);\n\n\n", "import {IncomingMessage} from \"http\";\nimport {firstValueFrom, map, Observable, startWith, toArray} from \"rxjs\";\n\nexport function observeData(request: IncomingMessage, maxLength: number = Number.POSITIVE_INFINITY): Observable\n{\n let nBytes = 0;\n\n return new Observable(subscriber =>\n {\n request.on('end', () => subscriber.complete());\n request.on('data', (data: Uint8Array) =>\n {\n nBytes += data.byteLength\n\n if (nBytes <= maxLength)\n subscriber.next(data);\n else\n {\n const error = `too much data: expected ${maxLength} bytes or less, got ${nBytes} bytes.`;\n subscriber.error(error);\n request.destroy(new Error(error))\n }\n });\n });\n}\n\nexport async function getRequestJson(request: IncomingMessage, maxLength = 500000): Promise\n{\n const data = await getData(request, maxLength)\n return JSON.parse(data.toString())\n}\n\nconst noData = new Uint8Array(0);\n\nexport function getData(request: IncomingMessage, maxLength: number = Number.POSITIVE_INFINITY): Promise\n{\n const data = observeData(request, maxLength).pipe\n (\n startWith(noData),\n toArray(),\n map(b => Buffer.concat(b)), // cannot inline!\n )\n\n return firstValueFrom(data);\n}", "import {ParentDbObject, User} from \"./data/types\";\n\nexport const loggedOut : ServerState = {account: {loggedOut: []}};\n\nexport type LoggedOut = { loggedOut: [] } ;\nexport type LoggedIn = {\n loggedIn:\n {\n home : ParentDbObject,\n token: string,\n user : User,\n }\n};\n\nexport type AccountState =\n | LoggedOut\n | LoggedIn\n\nexport type ServerState =\n{\n account : AccountState,\n error? : string,\n}\n\nexport const initialServerState : ServerState = {account: {loggedOut: []}};\n\n// export function isLoggedIn(accountState : AccountState): accountState is LoggedIn\n// {\n// return match(accountState, {loggedIn: _ => true}, false)\n// }\n//\n// export function isLoggedInAsAdmin(accountState: AccountState)\n// {\n// const user = base(accountState).user;\n// return isDefined(user) && unwrap(user).userType === UserTypes.admin;\n// }\n", "import {Dictionary, Func, Normalize1} from \"./utilityTypes\";\nimport {keys, valueToFunction} from \"./utils\";\nimport {isUndefined} from \"./maybe\";\nimport {UnionToIntersection} from \"simplytyped\";\nimport {current} from \"immer\";\n\n// Type Compatibility\n// https://www.typescriptlang.org/docs/handbook/type-compatibility.html\n\n\n//TODO: review\nexport type IsUnionCase =\n T extends Dictionary\n ? [UnionToIntersection] extends [keyof T]\n ? [keyof T] extends [UnionToIntersection]\n ? true\n : false\n : false\n : false\n\n//TODO: review\nexport type IsTaggedUnion = true extends UnionToIntersection> ? Dictionary : never\n\nexport type Unwrap> = UnionToIntersection[keyof UnionToIntersection] ;\n\nexport function update>(u: U, e: Partial>)\n{\n const v = u as UnionToIntersection\n const o = current(v)\n\n const ks = keys(v)\n\n if (ks.length != 1)\n throw new Error(\"not a valid union case\")\n\n const tag = ks[0]\n\n const before = v[tag];\n const before2 = current(before);\n\n\n const newVar = {...before, ...e};\n v[tag] = newVar\n}\n\nexport function unwrap>(u: U) : Normalize1>\n{\n const v = u as UnionToIntersection\n\n const ks = keys(v)\n\n if (ks.length != 1)\n throw new Error(\"not a valid union case\")\n\n const key = ks[0]\n return v[key] as any;\n}\n\nexport function base>(u: U): Normalize1 & Partial>>>\n{\n return unwrap(u) as Normalize1 & Partial>>>\n}\n\nexport function tag>(u: U) : keyof UnionToIntersection\n{\n const v = u as UnionToIntersection\n\n const ks = keys(v)\n\n if (ks.length != 1)\n throw new Error(\"not a valid union case\")\n\n return ks[0]\n}\n\nexport function tagsEqual>(u: U, v: U) : v is U\n{\n return tag(u) === tag(v)\n}\n\n\ntype MapFuncs = { [k in keyof UnionToIntersection]: Func[k]> }\ntype OtherwiseKeys = Exclude, keyof M>;\n\ntype OtherwiseArg = {\n [k in keyof UnionToIntersection]: Record[k]>\n}[OtherwiseKeys]\n\ntype OtherwiseFunc>, R> = Func extends never ? unknown : OtherwiseArg, R>;\n\n\nexport function match, M extends Partial>, R>(uCase: U, matchFuncs: M, otherwise: OtherwiseFunc | R):{ [k in keyof M]: M[k] extends Func ? O : never }[keyof M] | R\n{\n const otw = valueToFunction(otherwise)\n\n const c = uCase as UnionToIntersection\n\n const ks = keys(c)\n\n if (ks.length != 1)\n return otw(c)\n\n const key = ks[0]\n const arg = c[key]\n\n const matchFunc = matchFuncs[key]\n\n if (isUndefined(matchFunc))\n return otw(c);\n\n return matchFunc(arg as any) as any;\n}\n\n\nexport function dispatch>()\n{\n // type Intersection = UnionToIntersection;\n //\n // type MapFuncs = { [k in keyof Intersection]: Func }\n // type OtherwiseKeys = Exclude;\n //\n // type OtherwiseArg = {\n // [k in keyof Intersection]: Record\n // }[OtherwiseKeys]\n //\n // type OtherwiseFunc, R> = Func extends never ? unknown : OtherwiseArg, R>;\n\n return >, R>(matchFuncs: M, otherwise: OtherwiseFunc | R) =>\n {\n const otw = valueToFunction(otherwise)\n\n return (uCase: U): { [k in keyof M]: M[k] extends Func ? O : never }[keyof M] | R =>\n {\n const c = uCase as UnionToIntersection\n\n const ks = keys(c)\n\n if (ks.length != 1)\n return otw(c)\n\n const key = ks[0]\n const arg = c[key]\n\n const matchFunc = matchFuncs[key]\n\n if (isUndefined(matchFunc))\n return otw(c);\n\n return matchFunc(arg as any) as any;\n }\n };\n}\n\n\nexport function concat, T extends Dictionary>(rec: R, t:T)\n{\n\n const result = {} as {\n [k in keyof UnionToIntersection]: Record[k] & T>\n }[keyof UnionToIntersection]\n\n for (const k in rec)\n {\n\n // @ts-ignore\n result[k] = { ...rec[k], ...t}\n }\n\n return result\n}\n\n\n\n\n\n\n", "import fs from \"fs\";\nimport {interval} from \"rxjs\";\nimport {readJsonFile, writeJsonFilePretty} from \"./utils/fileSystem\";\nimport {getLogger} from \"../utils/logging\";\nimport {isDefined, isUndefined, Maybe} from \"../utils/maybe\";\nimport {Base64, mutable, Mutable, SyncAction} from \"../utils/utilityTypes\";\nimport {randomBytes, scrypt} from \"crypto\";\nimport {Milliseconds} from \"../utils/milliseconds\";\nimport {entries, keys, toDictionary} from \"../utils/utils\";\nimport {isString} from \"../utils/runtimeTypeChecking\";\nimport {CreateCommand, LoginCommand, LogoutCommand, RemoveCommand, ServerCommand, UpdateCommand} from \"../api/serverCommand\";\nimport {AccountState, LoggedIn, loggedOut, ServerState} from \"../api/serverState\";\nimport {dispatch, match, tag, tagsEqual, unwrap, Unwrap} from \"../utils/match\";\nimport {isParent, isUser} from \"../api/data/isA\";\nimport {Database, DbObject, User, VrmInstallation} from \"../api/data/types\";\nimport {getDbObjectById, getDescendants, getDescendantsWithPath, getDescendantVrmInstallations, getParent, getPath} from \"../api/data/query\";\nimport {addChild, removeChild} from \"../api/data/mutate\";\nimport {applyChanges, getChanges} from \"../utils/diffing\";\nimport {vrmInstallations} from \"./vrm/vrmSync\";\n\nexport const tokenBytes = 64\nexport const hmacBytes = 60\nexport const idBytes = 12\n\nexport const DbReply =\n{\n Success : \"ok\",\n LoggedOut : \"loggedOut\"\n} as const\n\nconst log = getLogger(\"DB\")\nconst cleanSessionsPeriod = Milliseconds.fromDays(1);\n\nconst db$ = readLatestSavedVersionFromDisk();\n\nconst maxSessionAge = Milliseconds.fromWeeks(1)\n\ninterval(cleanSessionsPeriod).subscribe(deleteOldSessions)\ndeleteOldSessions()\n\n//vrmInstallations.subscribe(syncFromVrm)\n\nfunction createDataId(): string\n{\n return randomBytes(idBytes).toString('base64');\n}\n\nfunction getLatestSavedVersion()\n{\n const rxDbVersion = /^db_v(\\d+)\\.json$/;\n\n return fs\n .readdirSync(\".\")\n .select(f => rxDbVersion.exec(f))\n .where(isDefined)\n .select(ms => ms![1])\n .where(isDefined)\n .select(v => parseInt(v))\n .max()\n}\n\nfunction readLatestSavedVersionFromDisk() : Database\n{\n const dbFileName = getDbFileName(getLatestSavedVersion())\n log(`reading ${dbFileName}`)\n return readJsonFile(dbFileName)\n}\n\nfunction getDbFileName(version: number)\n{\n return `db_v${version}.json`;\n}\n\nfunction writeDbToDisk(db: Database)\n{\n const dbFileName = getDbFileName(db.version);\n log(`writing ${dbFileName}`)\n writeJsonFilePretty(dbFileName, db)\n}\n\nfunction updateDb(modificationMsg: string, modifiedBy?: User)\n{\n log(modificationMsg)\n\n const user = isDefined(modifiedBy)? unwrap(modifiedBy) : undefined\n\n db$.version++\n db$.timestamp = Date.now()\n db$.modification = modificationMsg\n db$.modifiedBy = isDefined(user)\n ? `${user.name} [${user.id}]`\n : \"Server\";\n\n writeDbToDisk(db$)\n}\n\nfunction deleteOldSessions()\n{\n const now = Date.now()\n\n const deletedSessions = entries(db$.sessions)\n .where(([_, session]) => now - session.created > maxSessionAge)\n .select(([t, _]) => delete db$.sessions[t])\n .count();\n\n if (deletedSessions > 0)\n log(`deleted ${deletedSessions} old sessions`)\n\n // do NOT save to disk and create new version\n}\n\n\nexport function getAccountState(token: Maybe): AccountState\n{\n if (isUndefined(token))\n return loggedOut.account\n\n const userId = db$.sessions[token]?.userId;\n\n if (isUndefined(userId))\n return loggedOut.account\n\n const [user, home] = getPath(db$.rootFolder, userId)!\n\n if (!isUser(user) || !isParent(home))\n return loggedOut.account\n\n return {loggedIn: {user, home, token}}\n}\n\nfunction syncFromVrm(installationsFromVrm: VrmInstallation[])\n{\n // TODO: operate on single VrmInstallation not VrmInstallation[]\n\n //const db = structuredClone(db$)\n\n const root = db$.rootFolder;\n\n const installationsFromDb = getDescendantVrmInstallations(root)\n\n const dbDict = toDictionary(installationsFromDb, i => unwrap(i).id)\n const vrmDict = toDictionary(installationsFromVrm, i => unwrap(i).id)\n\n let changed = 0\n for (const id of keys(vrmDict).where(k => k in dbDict))\n {\n const dbInstallation = dbDict[id]\n const vrmInstallation = vrmDict[id]\n\n const changes = getChanges(dbInstallation, vrmInstallation).toArray()\n\n if (changes.any())\n {\n changed++\n applyChanges(dbInstallation, changes)\n }\n }\n\n let added = 0\n for (const id of keys(vrmDict).where(k => !(k in dbDict)))\n {\n added++\n addChild(root, vrmDict[id])\n }\n\n let removed = 0\n for (const id of keys(dbDict).where(k => !(k in vrmDict)))\n {\n removed++\n\n const installationToRemove = dbDict[id]\n const parent = getParent(root, installationToRemove)\n\n if (isUndefined(parent))\n continue; // TODO\n\n removeChild(parent, installationToRemove)\n }\n\n if (changed + added + removed <= 0)\n return // nothing to do\n\n const msg = \"Synced from VRM:\" +\n (changed > 0 ? ` ${changed} installations changed,` : \"\") +\n (added > 0 ? ` ${added} installations added,` : \"\") +\n (removed > 0 ? ` ${removed} installations removed,` : \"\")\n\n updateDb(msg.slice(0, -1))\n}\n\nfunction calcPasswordHmac(user: User, password: string): Promise>\n{\n function computeScrypt(resolve: SyncAction>)\n {\n function onResult(err: Error | null, buffer: Buffer)\n {\n if (isDefined(err))\n resolve(undefined)\n else\n resolve(buffer.toString('base64'))\n }\n\n scrypt(password, unwrap(user).id, hmacBytes, onResult);\n }\n\n return new Promise(computeScrypt)\n}\n\nasync function checkPassword(user: User, password: string): Promise\n{\n const hmac = await calcPasswordHmac(user, password)\n return hmac === db$.passwords[unwrap(user).id]\n}\n\nfunction createToken()\n{\n return randomBytes(tokenBytes).toString('base64');\n}\n\nfunction isValidName(name: Maybe): name is string\n{\n return isDefined(name) && name.length > 0;\n}\n\n// async function renameDescendantVrmInstallations(db: Database, parent: UserHome)\n// {\n// for (const i of getDescendantVrmInstallations(parent))\n// {\n// const vrmId = i.vrmId\n// const vrmName = getMangledVrmInstallationName(db.rootFolder, i)\n// await vrm.editInstallation(vrmId, vrmName) // TODO: handle failure\n// }\n// }\n//\n// async function deleteDescendantVrmInstallations(parent: UserHome)\n// {\n// for (const i of getDescendantVrmInstallations(parent))\n// {\n// const vrmId = i.vrmId\n// await vrm.deleteInstallation(vrmId) // TODO: handle failure\n// }\n// }\n\nconst remove = (cmd: Unwrap) => async (login: Unwrap) =>\n{\n const itemId = cmd.dbObjectId;\n const {home, user} = login;\n\n if (!isString(itemId))\n return \"error\" // TODO\n\n const path = getPath(home, itemId);\n if (path.length < 2)\n return \"error\" // TODO\n\n const [child, parent] = path\n\n // await deleteDescendantVrmInstallations(child) // TODO\n\n if (!removeChild(parent, child))\n return \"error\" // TODO\n\n updateDb(`removed ${unwrap(child).name}`, user)\n\n return DbReply.Success\n};\n\nconst create = (cmd: Unwrap) => async (login: Unwrap) =>\n{\n // {item: DbObject, parentId: string}}\n\n const {dbObject, parentId} = cmd; // TODO: security: dont assume item has correct shape\n const {home, user} = login;\n\n if (isUndefined(dbObject) || isValidName(unwrap(dbObject).name))\n return \"error\" // TODO\n\n if (unwrap(user).userType !== \"Admin\")\n return \"error\" // TODO\n\n if (!isString(parentId))\n return \"error\" // TODO\n\n const parent = getDescendants(home)\n .firstOrDefault(d => unwrap(d).id === parentId)\n\n if (isUndefined(parent))\n return \"error\" // TODO\n\n if (!addChild(parent, dbObject as DbObject)) // TODO: security: dont assume item has correct shape\n return \"error\" // TODO\n\n mutable(unwrap(dbObject)).id = createDataId() // IMPORTANT\n\n updateDb(`created ${unwrap(dbObject).name}`, login.user)\n\n return DbReply.Success\n};\n\n\n\n\nconst update = (cmd: Unwrap) => async (login: Unwrap) =>\n{\n // {item: DbObject, parentId: string}}\n\n const {dbObject} = cmd; // TODO: security: dont assume item has correct shape\n const {home, user} = login;\n\n if (unwrap(user).userType !== \"Admin\")\n return \"error\" // TODO\n\n const itemId = unwrap(dbObject).id\n\n if (isUndefined(itemId))\n return \"error\" // TODO\n\n const itemToUpdate = getDbObjectById(home,itemId)\n\n if (isUndefined(itemToUpdate) || !tagsEqual(itemToUpdate, dbObject))\n return \"error\" // TODO\n\n // @ts-ignore\n itemToUpdate[tag(itemToUpdate)] = {...unwrap(itemToUpdate), ...unwrap(dbObject)}\n\n const needId = getDescendants(itemToUpdate)\n .select(unwrap)\n .where(o => o.id.length < 4)\n\n // TODO: ensure unique ids\n\n for (const e of needId)\n {\n (e as Mutable).id = createDataId()\n }\n\n updateDb(`updated ${unwrap(dbObject).name}`, login.user)\n\n return DbReply.Success\n};\n\n\nconst unknownCommand = (_: any) => async (_: Unwrap) => \"Unknown Command\"\n\n//\n// const addNewVrmInstallation = (cmd: CreateVrmInstallationCommand) => async (login: Unwrap) =>\n// {\n// const {country, ibn, locality, name, orderNumber, parentFolderId, region, vrmPortalId} = cmd;\n//\n// const parentFolder = getDescendantFolders(login.home)\n// .firstOrDefault(f => f.id === parentFolderId) // nullability checked by isFolder below\n//\n// if (isUndefined(parentFolder))\n// return \"invalid parentFolderId\"\n//\n// if (isUndefined(vrmPortalId))\n// return \"invalid vrmPortalId\"\n//\n// if (isUndefined(name))\n// return \"invalid name\"\n//\n// // first add installation to VRM with a temporary name (vrmPortalId)\n// const success = await vrm.addInstallation(vrmPortalId, vrmPortalId)\n//\n// if (!success)\n// return \"Failed to add installation on VRM\"\n//\n// // then read it back from VRM, so we get \"vrm\" prefixed id, and settings\n// const vrmInstallationData = await getInstallationData(vrmPortalId)\n//\n// if (isUndefined(vrmInstallationData))\n// return \"Failed to add installation on VRM\"\n//\n// const vrmInstallation : VrmInstallation =\n// {\n// ...toVrmInstallation(vrmInstallationData),\n// name,\n// locality,\n// region,\n// country,\n// orderNumbers: toArray(orderNumber),\n// tags : isDefined(ibn) && ibn ? [\"IBN\"] : []\n// }\n//\n// addInstallation(parentFolder, vrmInstallation)\n//\n// const vrmInstallationName = getMangledVrmInstallationName(vrmInstallation)\n//\n// // write mangled name back to VRM\n// await vrm.editInstallation(vrmInstallation.settings.vrmId, vrmInstallationName)\n//\n// updateDb(`added new VRM installation ${vrmInstallationName}`, login.user)\n//\n// return Success\n// };\n\nconst loginFailed: ServerState = {account: {loggedOut: []}, error: \"login failed\"};\n\nexport function login(cmd: ServerCommand): Promise\n{\n return match(cmd, {login: doLogin}, Promise.resolve(loginFailed));\n\n async function doLogin(cmd: Unwrap)\n {\n const {password, username} = cmd;\n\n if (!isString(username) || !isString(password))\n return loginFailed;\n\n const path = getDescendantsWithPath(db$.rootFolder)\n .firstOrDefault(u => unwrap(u[0]).name === username && isUser(u[0]));\n\n if (isUndefined(path) || path.length < 2)\n return loginFailed;\n\n const [user, home] = path\n\n if (isUndefined(user) || isUndefined(home) || !isUser(user) || !isParent(home))\n return loginFailed;\n\n const pwdOk = await checkPassword(user, password);\n\n if (!pwdOk)\n return loginFailed;\n\n const token = createToken();\n const userId = unwrap(user).id;\n\n db$.sessions[token] = {userId, created: Date.now()};\n\n log(`user ${username} logged in`)\n\n const account: AccountState = {loggedIn: {token, home, user}};\n return {account}\n }\n}\n\nconst logout = (_: Unwrap) => async (login: Unwrap) =>\n{\n delete db$.sessions[login?.token]; // TODO: immutable\n return DbReply.Success;\n};\n\n\nexport const dispatchCommand = dispatch()(\n {\n create,\n update,\n remove,\n logout\n }\n ,\n unknownCommand\n)\n\n//vrmInstallations.subscribe(syncFromVrm)", "import fs from \"fs\";\n\nexport function doesFileExist(path: string): boolean\n{\n try\n {\n fs.accessSync(path, fs.constants.F_OK);\n return true;\n }\n catch (e)\n {\n return false;\n }\n}\n\nexport function doesDirExist(path: string): boolean\n{\n try\n {\n fs.readdirSync(path)\n return true;\n }\n catch (e)\n {\n return false;\n }\n}\n\nexport function readJsonFile(path: string)\n{\n const data = fs.readFileSync(path, \"utf-8\")\n return JSON.parse(data) as T\n}\n\nexport function writeJsonFile(path: string, contents: T)\n{\n const data = JSON.stringify(contents)\n return fs.writeFileSync(path, data, \"utf-8\")\n}\n\nexport function writeJsonFilePretty(path: string, contents: T)\n{\n const data = JSON.stringify(contents,undefined,2)\n return fs.writeFileSync(path, data, \"utf-8\")\n}\n\n", "import {UnionToIntersection} from \"simplytyped\";\n\nexport type Dictionary = Record\nexport type Nothing = Dictionary\n\nexport type IsUnion = [T] extends [UnionToIntersection] ? false : true;\n\nexport type UnionToDeepPartialIntersection = DeepPartial>\nexport type UnionToPartialIntersection = Partial>\n\nexport type Func = (arg: T) => R\nexport type AsyncFunc = (arg: T) => Promise\n\nexport type SyncAction = (arg: T) => void\nexport type AsyncAction = (arg: T) => Promise\nexport type Action = SyncAction | AsyncAction\n\nexport type Lazy = () => T\nexport type Base64 = string\nexport type ValueOf = T[keyof T];\n\nexport type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; } : T;\nexport type DeepMutable = { -readonly [P in keyof T]: DeepMutable };\nexport type Mutable = { -readonly [P in keyof T]: T[P] };\nexport type NumberLiteralToStringLiteral = T extends number ? `${T}` : T\n\nexport type KeyedChildren = { children?: Dictionary }\n\nexport type Union = { [S in K] : V}\n\nexport type IntersectionToUnion = { [Prop in keyof T]: Record }[keyof T] // not sure if this is aptly named\n\n// helper to flatten (instantiate) types in editor popups\n// eslint-disable-next-line @typescript-eslint/ban-types\n\nexport type Normalize = T extends (...args: infer A) => infer R ? (...args: Normalize) => Normalize\n : [T] extends [any] ? { [K in keyof T]: Normalize }\n : never\n\nexport type Normalize1 = T extends (...args: infer A) => infer R ? (...args: A) => R\n : [T] extends [any] ? { [K in keyof T]: T[K] }\n : T\n\nexport type Normalize2 = T extends (...args: infer A) => infer R ? (...args: Normalize1) => Normalize1\n : [T] extends [any] ? { [K in keyof T]: Normalize1 }\n : never\n\nexport function mutable(t: T)\n{\n return t as Mutable\n}\n\n", "\nexport type Milliseconds = number\n\nexport const Milliseconds =\n{\n fromSeconds: (count: number): Milliseconds => count * 1000,\n fromMinutes: (count: number): Milliseconds => count * 1000 * 60,\n fromHours : (count: number): Milliseconds => count * 1000 * 60 * 60,\n fromDays : (count: number): Milliseconds => count * 1000 * 60 * 60 * 24,\n fromWeeks : (count: number): Milliseconds => count * 1000 * 60 * 60 * 24 * 7,\n\n toSeconds: (count: Milliseconds): number => count / 1000,\n toMinutes: (count: Milliseconds): number => count / 1000 / 60,\n toHours : (count: Milliseconds): number => count / 1000 / 60 / 60,\n toDays : (count: Milliseconds): number => count / 1000 / 60 / 60 / 24,\n toWeeks : (count: Milliseconds): number => count / 1000 / 60 / 60 / 24 / 7,\n} as const\n\n", "export type TypeCode =\n | \"undefined\"\n | \"object\"\n | \"boolean\"\n | \"number\"\n | \"string\"\n | \"function\"\n | \"symbol\"\n | \"bigint\";\n\nexport type PlainObject = Record\n\nexport function isObject(thing: unknown) : thing is object\n{\n return typeof thing === \"object\"\n}\n\nexport function isDate(thing: unknown) : thing is Date\n{\n return thing instanceof Date\n}\n\nexport function isPlainObject(thing: unknown) : thing is PlainObject\n{\n return isObject(thing) && !isDate(thing)\n}\n\nexport function isArray(thing: unknown) : thing is Array\n{\n return Array.isArray(thing)\n}\n\nexport function isNumber(thing: unknown) : thing is number\n{\n return typeof thing === \"number\"\n}\n\nexport function isBoolean(thing: unknown) : thing is boolean\n{\n return typeof thing === \"boolean\"\n}\n\nexport function isString(thing: unknown) : thing is string\n{\n return typeof thing === \"string\"\n}\n\n// export function isFunction(thing: unknown): thing is (...args: unknown[]) => unknown\n// {\n// return typeof thing === \"function\"\n// }\n\nexport function isFunction(obj: unknown): obj is (...args: any[]) => any\n{\n return obj instanceof Function;\n}\n\nexport function isSymbol(thing: unknown) : thing is symbol\n{\n return typeof thing === \"symbol\"\n}\n\nexport function isBigint(thing: unknown) : thing is bigint\n{\n return typeof thing === \"bigint\"\n}\n", "import {match, tag} from \"../../utils/match\";\nimport {DbObject, Folder, Installation, ParentDbObject, User, VrmInstallation} from \"./types\";\nimport {isDefined, Maybe} from \"../../utils/maybe\";\n\nexport function isFolder(data: Maybe): data is Folder\n{\n return isDefined(data) && match(data, {folder: () => true}, false)\n}\n\nexport function isVrmInstallation(data: Maybe): data is VrmInstallation\n{\n return isDefined(data) && match(data, {vrmInstallation: () => true}, false);\n}\n\nexport function isUser(data: Maybe): data is User\n{\n return isDefined(data) && match(data, {user: () => true}, false);\n}\n\nexport function isInstallation(data: Maybe): data is Installation\n{\n return isDefined(data) && tag(data).endsWith(\"Installation\")\n}\n\nexport function isParent(data: Maybe): data is ParentDbObject\n{\n return isDefined(data) && (isFolder(data) || isInstallation(data))\n}", "import {from, IEnumerable} from \"linq-to-typescript\";\nimport {isDefined, isUndefined, Maybe} from \"./maybe\";\n\n\nexport function Tree(getChildren: (t: T) => IEnumerable