--------------------------------------------------------------------------------
/index.d.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | export * from "./dist/lib";
--------------------------------------------------------------------------------
/es5/index.d.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | export * from "../dist/es5";
--------------------------------------------------------------------------------
/es2015/index.d.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | export * from "../dist/es2015";
--------------------------------------------------------------------------------
/fn/index.d.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | export * from "../dist/lib/fn";
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | module.exports = require("./dist/lib");
--------------------------------------------------------------------------------
/es5/fn/index.d.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | export * from "../../dist/es5/fn";
--------------------------------------------------------------------------------
/es5/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | module.exports = require("../dist/es5");
--------------------------------------------------------------------------------
/es2015/fn/index.d.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | export * from "../../dist/es2015/fn";
--------------------------------------------------------------------------------
/es2015/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | module.exports = require("../dist/es2015");
--------------------------------------------------------------------------------
/fn/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | module.exports = require("../dist/lib/fn");
--------------------------------------------------------------------------------
/es5/fn/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | module.exports = require("../../dist/es5/fn");
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/member.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{#if name}}
4 |
{{#each flags}}{{this}} {{/each}}{{{wbr name}}}
5 | {{/if}}
6 |
7 | {{#if signatures}}
8 | {{> member.signatures}}
9 | {{else if hasGetterOrSetter}}
10 | {{> member.getterSetter}}
11 | {{else}}
12 | {{> member.declaration}}
13 | {{/if}}
14 |
15 | {{#each groups}}
16 | {{#each children}}
17 | {{#unless hasOwnDocument}}
18 | {{> member}}
19 | {{/unless}}
20 | {{/each}}
21 | {{/each}}
22 |
23 |
--------------------------------------------------------------------------------
/es2015/fn/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | module.exports = require("../../dist/es2015/fn");
--------------------------------------------------------------------------------
/src/lib/compat/index.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import "./es2015";
18 | import "./es2017";
--------------------------------------------------------------------------------
/src/tests/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2015",
4 | "lib": ["esnext"],
5 | "module": "commonjs",
6 | "outDir": "../../dist/tests",
7 | "noImplicitAny": true,
8 | "noEmitOnError": true,
9 | "sourceMap": true,
10 | "stripInternal": true,
11 | "declaration": true,
12 | "experimentalDecorators": true,
13 | "rootDirs": ["../es5", "../es2015", "../lib"]
14 | },
15 | "references": [
16 | { "path": "../lib/tsconfig.json" },
17 | { "path": "../lib/tsconfig.es5.json" },
18 | { "path": "../lib/tsconfig.es2015.json" },
19 | ],
20 | "include": [
21 | "**/*.ts"
22 | ]
23 | }
--------------------------------------------------------------------------------
/src/lib/fn/select.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { map as select } from "./map";
--------------------------------------------------------------------------------
/src/lib/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2017",
4 | "module": "commonjs",
5 | "lib": ["esnext"],
6 | "outDir": "../../dist/lib",
7 | "experimentalDecorators": true,
8 | "importHelpers": true,
9 | "noEmitOnError": true,
10 | "noImplicitAny": true,
11 | "sourceMap": true,
12 | "stripInternal": true,
13 | "declaration": true,
14 | "declarationMap": true,
15 | "skipLibCheck": true,
16 | "strict": true,
17 | "composite": true,
18 | "noUnusedLocals": true,
19 | "preserveConstEnums": true,
20 | // "noUnusedParameters": true
21 | },
22 | "include": [
23 | "**/*.ts"
24 | ]
25 | }
--------------------------------------------------------------------------------
/src/lib/fn/nth.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { elementAt as nth } from "./elementAt";
--------------------------------------------------------------------------------
/src/lib/fn/where.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { filter as where } from "./filter";
--------------------------------------------------------------------------------
/src/lib/fn/doAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { tapAsync as doAsync } from "./tapAsync";
--------------------------------------------------------------------------------
/src/lib/fn/whereBy.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { filterBy as whereBy } from "./filterBy";
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/members.group.hbs:
--------------------------------------------------------------------------------
1 | {{#if categories}}
2 | {{#each categories}}
3 |
4 |
{{../title}}{{#ifCond title '==' "Other"}}{{else}} ({{title}}){{/ifCond}}
15 | {{#each children}}
16 | {{#unless hasOwnDocument}}
17 | {{> member}}
18 | {{/unless}}
19 | {{/each}}
20 |
21 | {{/if}}
--------------------------------------------------------------------------------
/src/lib/fn/selectMany.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { flatMap as selectMany } from "./flatMap";
--------------------------------------------------------------------------------
/src/lib/fn/selectAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { mapAsync as selectAsync } from "./mapAsync";
--------------------------------------------------------------------------------
/src/lib/fn/nthAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { elementAtAsync as nthAsync } from "./elementAtAsync";
--------------------------------------------------------------------------------
/src/lib/fn/whereAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { filterAsync as whereAsync } from "./filterAsync";
--------------------------------------------------------------------------------
/src/lib/fn/xor.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { symmetricDifference as xor } from "./symmetricDifference";
--------------------------------------------------------------------------------
/src/lib/fn/relativeComplement.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { except as relativeComplement } from "./except";
--------------------------------------------------------------------------------
/src/lib/fn/whereByAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { filterByAsync as whereByAsync } from "./filterByAsync";
--------------------------------------------------------------------------------
/src/lib/fn/whereDefined.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { filterDefined as whereDefined } from "./filterDefined";
--------------------------------------------------------------------------------
/src/typedoc/plugin/model/exportBinding.ts:
--------------------------------------------------------------------------------
1 | import { Reflection, DeclarationReflection } from "typedoc";
2 |
3 | export class ExportBinding {
4 | name: string;
5 | symbolID?: number;
6 | reflection?: Reflection;
7 | isExportStar?: boolean;
8 |
9 | constructor(name: string, symbolID?: number, reflection?: Reflection) {
10 | this.name = name;
11 | this.symbolID = symbolID;
12 | this.reflection = reflection;
13 | }
14 |
15 | toObject() {
16 | const result = {} as any;
17 | result.name = this.name;
18 | if (this.reflection) result.id = this.reflection.id;
19 | return result;
20 | }
21 |
22 | toString() {
23 | return this.reflection ? this.reflection.name : this.name;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/lib/fn/conditionalAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { ifAsync as conditionalAsync } from "./ifAsync";
19 |
--------------------------------------------------------------------------------
/src/lib/fn/selectManyAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { flatMapAsync as selectManyAsync } from "./flatMapAsync";
--------------------------------------------------------------------------------
/src/lib/fn/xorBy.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { symmetricDifferenceBy as xorBy } from "./symmetricDifferenceBy";
--------------------------------------------------------------------------------
/src/lib/fn/relativeComplementBy.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { exceptBy as relativeComplementBy } from "./exceptBy";
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/comment.hbs:
--------------------------------------------------------------------------------
1 | {{#with comment}}
2 | {{#if hasVisibleComponent}}
3 |
21 | {{/if}}
22 | {{/with}}
--------------------------------------------------------------------------------
/src/lib/fn/xorAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { symmetricDifferenceAsync as xorAsync } from "./symmetricDifferenceAsync";
--------------------------------------------------------------------------------
/scripts/mocha.js:
--------------------------------------------------------------------------------
1 | const foreground = require("foreground-child");
2 |
3 | /**
4 | * @param {object} options
5 | * @param {string[]} options.files
6 | * @param {string} [options.reporter]
7 | * @param {string} [options.coverageTempDirectory]
8 | */
9 | async function mocha(options) {
10 | const cmd = "./node_modules/.bin/mocha";
11 | let args = [];
12 | if (options.reporter) args.push("-R", options.reporter);
13 | if (options.coverageTempDirectory) process.env.NODE_V8_COVERAGE = options.coverageTempDirectory;
14 | try {
15 | await new Promise(resolve => foreground(cmd, [...args, ...options.files], () => resolve()));
16 | }
17 | finally {
18 | if (options.coverageTempDirectory) process.env.NODE_V8_COVERAGE = "";
19 | }
20 | }
21 |
22 | exports.mocha = mocha;
--------------------------------------------------------------------------------
/src/lib/fn/relativeComplementAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { exceptAsync as relativeComplementAsync } from "./exceptAsync";
--------------------------------------------------------------------------------
/src/lib/fn/whereDefinedAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { filterDefinedAsync as whereDefinedAsync } from "./filterDefinedAsync";
--------------------------------------------------------------------------------
/src/lib/fn/xorByAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { symmetricDifferenceByAsync as xorByAsync } from "./symmetricDifferenceByAsync";
--------------------------------------------------------------------------------
/src/lib/fn/relativeComplementByAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | export { exceptByAsync as relativeComplementByAsync } from "./exceptByAsync";
--------------------------------------------------------------------------------
/src/lib/fn/do.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | // TODO: remove comment once auto-import is fixed
19 | /** @internal */
20 | export { tap as do } from "./tap";
--------------------------------------------------------------------------------
/src/lib/fn/if.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | // TODO: remove comment once auto-import is fixed
19 | /** @internal */
20 | export { conditional as if } from "./conditional";
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/comment.inline.hbs:
--------------------------------------------------------------------------------
1 | {{#with comment}}
2 | {{#if hasVisibleComponent}}
3 | —
4 |
24 | {{/if}}
25 | {{/if}}
26 | {{/if}}
27 |
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/member.signature.title.hbs:
--------------------------------------------------------------------------------
1 | {{#compact}}
2 | {{#unless hideName}}{{{wbr name}}}{{/unless}}
3 | {{#if typeParameters}}
4 | <
5 | {{#each typeParameters}}
6 | {{#if @index}}, {{/if}}
7 | {{name}}
8 | {{/each}}
9 | >
10 | {{/if}}
11 | (
12 | {{#each parameters}}
13 | {{#if @index}}, {{/if}}
14 | {{#if flags.isRest}}...{{/if}}
15 | {{name}}
16 |
17 | {{#if flags.isOptional}}?{{/if}}
18 | {{#if defaultValue}}?{{/if}}
19 | :
20 |
21 | {{#with type}}{{>type}}{{/with}}
22 | {{/each}}
23 | )
24 | {{#if type}}
25 | :
26 | {{#with type}}{{>type}}{{/with}}
27 | {{/if}}
28 | {{/compact}}
--------------------------------------------------------------------------------
/src/lib/fn/empty.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an [[Iterable]] with no elements.
22 | * @category Query
23 | */
24 | export function empty(): Iterable {
25 | return new EmptyIterable();
26 | }
27 |
28 | @ToStringTag("EmptyIterable")
29 | class EmptyIterable implements Iterable {
30 | *[Symbol.iterator](): Iterator {
31 | }
32 | }
--------------------------------------------------------------------------------
/src/lib/fn/drain.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable} from "../internal";
19 | import { Queryable } from "../types";
20 |
21 | /**
22 | * Iterates over all of the elements in a [[Queryable]], ignoring the results.
23 | *
24 | * @param source A [[Queryable]] object.
25 | * @category Scalar
26 | */
27 | export function drain(source: Queryable): void {
28 | assert.mustBeQueryable(source, "source");
29 | for (const _ of ToIterable(source)) ;
30 | }
--------------------------------------------------------------------------------
/src/lib/fn/emptyAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an [[AsyncIterable]] with no elements.
22 | * @category Query
23 | */
24 | export function emptyAsync(): AsyncIterable {
25 | return new AsyncEmptyIterable();
26 | }
27 |
28 | @ToStringTag("AsyncEmptyIterable")
29 | class AsyncEmptyIterable implements AsyncIterable {
30 | async *[Symbol.asyncIterator](): AsyncIterator {
31 | }
32 | }
--------------------------------------------------------------------------------
/src/tests/lazy.ts:
--------------------------------------------------------------------------------
1 | import { Lazy } from "../lib";
2 | import { expect } from "chai";
3 |
4 | describe("Lazy", () => {
5 | describe("from()", () => {
6 | it("eval only once", () => {
7 | let counter = 0;
8 | const lazy = Lazy.from(() => counter++);
9 | expect(counter).to.equal(0);
10 | expect(lazy.hasValue).to.be.false;
11 | expect(lazy.value).to.equal(0);
12 | expect(lazy.hasValue).to.be.true;
13 | expect(counter).to.equal(1);
14 | expect(lazy.value).to.equal(0);
15 | expect(counter).to.equal(1);
16 | });
17 | it("throws if recursive", () => {
18 | const lazy: Lazy = Lazy.from(() => lazy.value);
19 | expect(lazy.hasValue).to.be.false;
20 | expect(() => lazy.value).to.throw();
21 | expect(lazy.hasValue).to.be.false;
22 | });
23 | });
24 | describe("for()", () => {
25 | it("is value", () => {
26 | const lazy = Lazy.for(0);
27 | expect(lazy.hasValue).to.be.true;
28 | expect(lazy.value).to.equal(0);
29 | })
30 | });
31 | });
--------------------------------------------------------------------------------
/src/lib/internal/index.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | /** @internal */
18 | export * from "./decorators";
19 | /** @internal */
20 | export * from "./conversion";
21 | /** @internal */
22 | export * from "./flow";
23 | /** @internal */
24 | export * from "./guards";
25 | /** @internal */
26 | export * from "./utils";
27 | /** @internal */
28 | export * from "./types";
29 | /** @internal */
30 | import * as assert from "./assert";
31 | /** @internal */
32 | import * as Debug from "./debug";
33 | /** @internal */
34 | export { assert, Debug };
35 |
--------------------------------------------------------------------------------
/src/lib/internal/debug.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | interface ErrorConstructorWithStackTraceApi extends ErrorConstructor {
18 | captureStackTrace(target: any, stackCrawlMark?: Function): void;
19 | }
20 |
21 | declare const Error: ErrorConstructorWithStackTraceApi;
22 |
23 | /** @internal */
24 | export function captureStackTrace(error: any, stackCrawlMark?: Function) {
25 | if (typeof error === "object" && error !== null && Error.captureStackTrace) {
26 | Error.captureStackTrace(error, stackCrawlMark || captureStackTrace);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/lib/fn/drainAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToPossiblyAsyncIterable } from "../internal";
19 | import { AsyncQueryable } from "../types";
20 |
21 | /**
22 | * Iterates over all of the elements in an [[AsyncQueryable]], ignoring the results.
23 | *
24 | * @param source A [[Queryable]] object.
25 | * @category Scalar
26 | */
27 | export async function drainAsync(source: AsyncQueryable): Promise {
28 | assert.mustBeAsyncQueryable(source, "source");
29 | for await (const _ of ToPossiblyAsyncIterable(source)) ;
30 | }
--------------------------------------------------------------------------------
/src/lib/internal/decorators.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | /** @internal */
18 | import "../compat";
19 |
20 | /** @internal */
21 | export function ToStringTag(tag: string) {
22 | return (ctor: T) => {
23 | Object.defineProperty(ctor.prototype, Symbol.toStringTag, { configurable: true, value: tag });
24 | return ctor;
25 | };
26 | }
27 |
28 | /** @internal */
29 | export function ClassName(name: string) {
30 | return (ctor: T) => {
31 | Object.defineProperty(ctor, "name", { value: name, writable: false, enumerable: false, configurable: true });
32 | return ctor;
33 | };
34 | }
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/member.getterSetter.hbs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lib/fn/once.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { ToStringTag} from "../internal";
19 |
20 | /**
21 | * Creates an [[Iterable]] over a single element.
22 | *
23 | * @param value The only element for the [[Iterable]].
24 | * @category Query
25 | */
26 | export function once(value: T): Iterable {
27 | return new OnceIterable(value);
28 | }
29 |
30 | @ToStringTag("OnceIterable")
31 | class OnceIterable implements Iterable {
32 | private _value: T;
33 |
34 | constructor(value: T) {
35 | this._value = value;
36 | }
37 |
38 | *[Symbol.iterator](): Iterator {
39 | yield this._value;
40 | }
41 | }
--------------------------------------------------------------------------------
/src/lib/internal/types.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import { Queryable, AsyncQueryable } from "../types";
18 |
19 | // Queries
20 |
21 | /** @internal */
22 | export namespace QuerySource {
23 | export const source = Symbol("QuerySource.source");
24 | }
25 |
26 | /** @internal */
27 | export interface QuerySource extends Iterable {
28 | [QuerySource.source](): Queryable;
29 | }
30 |
31 | /** @internal */
32 | export namespace AsyncQuerySource {
33 | export const source = Symbol("AsyncQuerySource.source");
34 | }
35 |
36 | /** @internal */
37 | export interface AsyncQuerySource extends AsyncIterable {
38 | [AsyncQuerySource.source](): AsyncQueryable;
39 | }
--------------------------------------------------------------------------------
/src/lib/fn/forEach.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable} from "../internal";
19 | import { Queryable } from "../types";
20 |
21 | /**
22 | * Invokes a callback for each element of `source`.
23 | *
24 | * @param source A [[Queryable]] object.
25 | * @param callback The callback to invoke.
26 | * @category Scalar
27 | */
28 | export function forEach(source: Queryable, callback: (element: T, offset: number) => void): void {
29 | assert.mustBeQueryable(source, "source");
30 | assert.mustBeFunction(callback, "callback");
31 | let offset = 0;
32 | for (const element of ToIterable(source)) {
33 | callback(element, offset++);
34 | }
35 | }
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/exportBinding.hbs:
--------------------------------------------------------------------------------
1 | {{#compact}}
2 | {{#if reflection}}
3 | {{#ifTest reflection.parent '!==' ../parent}}
4 | {{#if isExportStar}}
5 | {{#if showStar}}* from {{/if}}
6 | {{#if reflection.url}}
7 | {{reflection.name}}
8 | {{else}}
9 | {{reflection.name}}
10 | {{/if}}
11 | {{else}}
12 | {{#if reflection.url}}
13 | {{reflection.name}}
14 | {{else}}
15 | {{reflection.name}}
16 | {{/if}}
17 | from
18 | {{#if reflection.parent.url}}
19 | {{reflection.parent.name}}
20 | {{else}}
21 | {{reflection.parent.name}}
22 | {{/if}}
23 | {{/if}}
24 | {{else}}
25 | {{#if reflection.url}}
26 | {{reflection.name}}
27 | {{else}}
28 | {{reflection.name}}
29 | {{/if}}
30 | {{/ifTest}}
31 | {{else}}
32 | {{this}}
33 | {{/if}}
34 | {{/compact}}
--------------------------------------------------------------------------------
/src/lib/fn/hierarchy.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, MakeHierarchyIterable } from "../internal";
19 | import { HierarchyProvider, HierarchyIterable } from "../types";
20 | import { once } from "./once";
21 |
22 | /**
23 | * Creates a [[HierarchyIterable]] for a root element using the provided [[HierarchyProvider]].
24 | *
25 | * @param root The root element.
26 | * @param hierarchy A [[HierarchyProvider]] object.
27 | * @category Hierarchy
28 | */
29 | export function hierarchy(root: T, hierarchy: HierarchyProvider): HierarchyIterable {
30 | assert.mustBeHierarchyProvider(hierarchy, "hierarchy");
31 | return MakeHierarchyIterable(once(root), hierarchy);
32 | }
--------------------------------------------------------------------------------
/src/lib/fn/through.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert } from "../internal";
19 | import { Queryable } from "../types";
20 |
21 | /**
22 | * Pass the entire source to the provided callback, returning a [[Queryable]] from the result.
23 | *
24 | * @param source A [[Queryable]] object.
25 | * @param callback A callback function.
26 | * @category Subquery
27 | */
28 | export function through = Queryable, R extends Queryable = Queryable>(source: S, callback: (source: S) => R): R {
29 | assert.mustBeQueryable(source, "source");
30 | assert.mustBeFunction(callback, "callback");
31 | const result = callback(source);
32 | assert.mustBeQueryable(result);
33 | return result;
34 | }
--------------------------------------------------------------------------------
/src/lib/fn/onceAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an [[AsyncIterable]] over a single element.
22 | *
23 | * @param value The only element for the [[AsyncIterable]].
24 | * @category Query
25 | */
26 | export function onceAsync(value: PromiseLike | T): AsyncIterable {
27 | return new AsyncOnceIterable(value);
28 | }
29 |
30 | @ToStringTag("AsyncOnceIterable")
31 | class AsyncOnceIterable implements AsyncIterable {
32 | private _value: PromiseLike | T;
33 |
34 | constructor(value: PromiseLike | T) {
35 | this._value = value;
36 | }
37 |
38 | async *[Symbol.asyncIterator](): AsyncIterator {
39 | yield this._value;
40 | }
41 | }
--------------------------------------------------------------------------------
/src/lib/fn/continuous.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { ToStringTag} from "../internal";
19 |
20 | /**
21 | * Creates an [[Iterable]] that repeats the provided value forever.
22 | *
23 | * @param value The value for each element of the [[Iterable]].
24 | * @category Query
25 | */
26 | export function continuous(value: T): Iterable {
27 | return new ContinuousIterable(value);
28 | }
29 |
30 | @ToStringTag("ContinuousIterable")
31 | class ContinuousIterable implements Iterable {
32 | private _value: T;
33 |
34 | constructor(value: T) {
35 | this._value = value;
36 | }
37 |
38 | *[Symbol.iterator](): Iterator {
39 | const value = this._value;
40 | for (;;) {
41 | yield value;
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/src/lib/fn/hierarchyAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, MakeAsyncHierarchyIterable } from "../internal";
19 | import { HierarchyProvider, AsyncHierarchyIterable } from "../types";
20 | import { onceAsync } from "./onceAsync";
21 |
22 | /**
23 | * Creates an [[AsyncHierarchyIterable]] for a resolved root element using the provided [[HierarchyProvider]].
24 | *
25 | * @param root The root element.
26 | * @param hierarchy A [[HierarchyProvider]] object.
27 | * @category Hierarchy
28 | */
29 | export function hierarchyAsync(root: PromiseLike | T, hierarchy: HierarchyProvider): AsyncHierarchyIterable {
30 | assert.mustBeHierarchyProvider(hierarchy, "hierarchy");
31 | return MakeAsyncHierarchyIterable(onceAsync(root), hierarchy);
32 | }
--------------------------------------------------------------------------------
/src/lib/fn/throughAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert } from "../internal";
19 | import { AsyncQueryable } from "../types";
20 |
21 | /**
22 | * Pass the entire source to the provided callback, returning an [[AsyncQueryable]] from the result.
23 | *
24 | * @param source An [[AsyncQueryable]] object.
25 | * @param callback A callback function.
26 | * @category Subquery
27 | */
28 | export function throughAsync = AsyncQueryable, R extends AsyncQueryable = AsyncQueryable>(source: S, callback: (source: S) => R): R {
29 | assert.mustBeAsyncQueryable(source, "source");
30 | assert.mustBeFunction(callback, "callback");
31 | const result = callback(source);
32 | assert.mustBeAsyncQueryable(result);
33 | return result;
34 | }
--------------------------------------------------------------------------------
/src/lib/fn/first.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable} from "../internal";
19 | import { Queryable } from "../types";
20 | import { T } from "./common";
21 |
22 | /**
23 | * Gets the first element, optionally filtering elements using the supplied callback.
24 | *
25 | * @param source A [[Queryable]] object.
26 | * @param predicate An optional callback used to match each element.
27 | * @category Scalar
28 | */
29 | export function first(source: Queryable, predicate: (element: T) => boolean = T): T | undefined {
30 | assert.mustBeQueryable(source, "source");
31 | assert.mustBeFunction(predicate, "predicate");
32 | for (const element of ToIterable(source)) {
33 | if (predicate(element)) {
34 | return element;
35 | }
36 | }
37 | return undefined;
38 | }
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/index.hbs:
--------------------------------------------------------------------------------
1 | {{#if groups}}
2 |
3 |
28 |
29 |
30 | {{/if}}
--------------------------------------------------------------------------------
/src/tests/data/nodes.ts:
--------------------------------------------------------------------------------
1 | import { HierarchyProvider } from "../../lib";
2 |
3 | export interface Node {
4 | name: string;
5 | parent?: Node;
6 | children?: Node[];
7 | toJSON?: () => any;
8 | marker?: boolean;
9 | }
10 |
11 | function makeTree(node: Node, parent?: Node) {
12 | node.toJSON = () => node.name;
13 | node.parent = parent;
14 | if (node.children) {
15 | for (const child of node.children) {
16 | if (child) makeTree(child, node);
17 | }
18 | }
19 |
20 | return node;
21 | }
22 |
23 | export const nodeAAAA: Node = { name: "AAAA" }
24 | export const nodeAAA: Node = { name: "AAA", children: [nodeAAAA] };
25 | export const nodeAAB: Node = { name: "AAB", marker: true };
26 | export const nodeAAC: Node = { name: "AAC" };
27 | export const nodeAA: Node = { name: "AA", children: [nodeAAA, nodeAAB, nodeAAC] };
28 | export const nodeAB: Node = { name: "AB" };
29 | export const nodeACA: Node = { name: "ACA" };
30 | export const nodeAC: Node = { name: "AC", children: [nodeACA] };
31 | export const nodeA: Node = { name: "A", children: [nodeAA, nodeAB, nodeAC] };
32 | makeTree(nodeA);
33 |
34 | export const badNode: Node = { name: "bad", children: [undefined!] };
35 |
36 | export const nodeHierarchy: HierarchyProvider = {
37 | owns(_: Node) {
38 | return true;
39 | },
40 | parent(node: Node) {
41 | return node.parent;
42 | },
43 | children(node: Node) {
44 | return node.children || [];
45 | }
46 | };
47 |
--------------------------------------------------------------------------------
/src/lib/fn/forEachAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToPossiblyAsyncIterable } from "../internal";
19 | import { AsyncQueryable } from "../types";
20 |
21 | /**
22 | * Invokes a callback for each element of `source`.
23 | *
24 | * @param source An [[AsyncQueryable]] object.
25 | * @param callback The callback to invoke.
26 | * @category Scalar
27 | */
28 | export async function forEachAsync(source: AsyncQueryable, callback: (element: T, offset: number) => void | PromiseLike): Promise {
29 | assert.mustBeAsyncQueryable(source, "source");
30 | assert.mustBeFunction(callback, "callback");
31 | let offset = 0;
32 | for await (const element of ToPossiblyAsyncIterable(source)) {
33 | const result = callback(element, offset++);
34 | if (typeof result !== "undefined") await result;
35 | }
36 | }
--------------------------------------------------------------------------------
/src/lib/fn/some.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable } from "../internal";
19 | import { Queryable } from "../types";
20 | import { T } from "./common";
21 |
22 | /**
23 | * Computes a scalar value indicating whether `source` contains any elements,
24 | * optionally filtering the elements using the supplied callback.
25 | *
26 | * @param source A [[Queryable]] object.
27 | * @param predicate An optional callback used to match each element.
28 | * @category Scalar
29 | */
30 | export function some(source: Queryable, predicate: (element: T) => boolean = T): boolean {
31 | assert.mustBeQueryable(source, "source");
32 | assert.mustBeFunction(predicate, "predicate");
33 | for (const element of ToIterable(source)) {
34 | if (predicate(element)) {
35 | return true;
36 | }
37 | }
38 | return false;
39 | }
--------------------------------------------------------------------------------
/src/lib/fn/last.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable} from "../internal";
19 | import { Queryable } from "../types";
20 | import { T } from "./common";
21 |
22 | /**
23 | * Gets the last element of a [[Queryable]], optionally filtering elements using the supplied
24 | * callback.
25 | *
26 | * @param source A [[Queryable]] object.
27 | * @param predicate An optional callback used to match each element.
28 | * @category Scalar
29 | */
30 | export function last(source: Queryable, predicate: (element: T) => boolean = T): T | undefined {
31 | assert.mustBeQueryable(source, "source");
32 | assert.mustBeFunction(predicate, "predicate");
33 | let result: T | undefined;
34 | for (const element of ToIterable(source)) {
35 | if (predicate(element)) {
36 | result = element;
37 | }
38 | }
39 | return result;
40 | }
--------------------------------------------------------------------------------
/src/typedoc/plugin/plugins/noJekyll.ts:
--------------------------------------------------------------------------------
1 | import * as fs from "fs";
2 | import * as path from "path";
3 | import { RendererComponent, Component } from "typedoc/dist/lib/output/components";
4 | import { Option, writeFile } from "typedoc/dist/lib/utils";
5 | import { ParameterType } from "typedoc/dist/lib/utils/options/declaration";
6 | import { ComponentHost } from "typedoc/dist/lib/utils/component";
7 | import { Renderer } from "typedoc";
8 | import { RendererEvent } from "typedoc/dist/lib/output/events";
9 |
10 | @Component({
11 | name: "no-jekyll",
12 | })
13 | export class NoJekyllPlugin extends RendererComponent {
14 | @Option({
15 | name: "noJekyll",
16 | help: "Generates a .nojekyll file as part of the output",
17 | type: ParameterType.Boolean
18 | })
19 | noJekyll!: boolean;
20 |
21 | constructor(owner: ComponentHost) {
22 | if (!(owner instanceof Renderer)) throw new TypeError();
23 | super(owner);
24 | }
25 |
26 | initialize() {
27 | super.initialize();
28 | this.listenTo(this.owner, RendererEvent.END, this.onEnd);
29 | }
30 |
31 | private onEnd(event: RendererEvent) {
32 | if (this.noJekyll) {
33 | const filename = path.resolve(event.outputDirectory, ".nojekyll");
34 | try {
35 | writeFile(filename, "", /*writeByteOrderMark*/ false);
36 | }
37 | catch (e) {
38 | this.application.logger.error("Could not write file %s", filename);
39 | }
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/lib/fn/eval.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, FlowHierarchy} from "../internal";
19 | import { Queryable, HierarchyIterable } from "../types";
20 | import { toArray } from "./toArray";
21 |
22 | /**
23 | * Eagerly evaluate a [[HierarchyIterable]], returning a [[HierarchyIterable]] for the elements of the original sequence.
24 | * @category Scalar
25 | */
26 | function _eval(source: HierarchyIterable): HierarchyIterable;
27 | /**
28 | * Eagerly evaluate a [[Queryable]], returning an [[Iterable]] for the elements of the original sequence.
29 | * @category Scalar
30 | */
31 | function _eval(source: Queryable): Iterable;
32 | function _eval(source: Queryable): Iterable {
33 | assert.mustBeQueryable(source, "source");
34 | return FlowHierarchy(toArray(source), source);
35 | }
36 |
37 | export { _eval as eval };
38 |
--------------------------------------------------------------------------------
/src/lib/fn/continuousAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an [[AsyncIterable]] that repeats the provided value forever.
22 | *
23 | * @param value The value for each element of the [[AsyncIterable]].
24 | * @category Query
25 | */
26 | export function continuousAsync(value: PromiseLike | T): AsyncIterable {
27 | return new AsyncContinuousIterable(value);
28 | }
29 |
30 | @ToStringTag("AsyncContinuousIterable")
31 | class AsyncContinuousIterable implements AsyncIterable {
32 | private _value: PromiseLike | T;
33 |
34 | constructor(value: PromiseLike | T) {
35 | this._value = value;
36 | }
37 |
38 | async *[Symbol.asyncIterator](): AsyncIterator {
39 | const value = await this._value;
40 | for (;;) {
41 | yield value;
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/src/lib/fn/max.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert } from "../internal";
19 | import { Queryable } from "../types";
20 | import { identity } from "./common";
21 | import { maxBy } from './maxBy';
22 | import { Comparison, Comparer } from '@esfx/equatable';
23 |
24 | /**
25 | * Gets the maximum element of a [[Queryable]], optionally comparing elements using the supplied callback.
26 | *
27 | * @param source A [[Queryable]] object.
28 | * @param comparer An optional callback used to compare two elements.
29 | * @category Scalar
30 | */
31 | export function max(source: Queryable, comparer: Comparison | Comparer = Comparer.defaultComparer): T | undefined {
32 | if (typeof comparer === "function") comparer = Comparer.create(comparer);
33 | assert.mustBeQueryable(source, "source");
34 | assert.mustBeComparer(comparer, "comparer");
35 | return maxBy(source, identity, comparer);
36 | }
--------------------------------------------------------------------------------
/src/lib/fn/min.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert } from "../internal";
19 | import { Queryable } from "../types";
20 | import { identity } from "./common";
21 | import { minBy } from './minBy';
22 | import { Comparison, Comparer } from '@esfx/equatable';
23 |
24 | /**
25 | * Gets the minimum element of a [[Queryable]], optionally comparing elements using the supplied callback.
26 | *
27 | * @param source A [[Queryable]] object.
28 | * @param comparer An optional callback used to compare two elements.
29 | * @category Scalar
30 | */
31 | export function min(source: Queryable, comparer: Comparison | Comparer = Comparer.defaultComparer): T | undefined {
32 | if (typeof comparer === "function") comparer = Comparer.create(comparer);
33 | assert.mustBeQueryable(source, "source");
34 | assert.mustBeComparer(comparer, "comparer");
35 | return minBy(source, identity, comparer);
36 | }
--------------------------------------------------------------------------------
/src/lib/fn/objectKeys.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an [[Iterable]] for the own property keys of an `object`.
22 | *
23 | * @param source An `object`.
24 | * @category Query
25 | */
26 | export function objectKeys(source: T): Iterable> {
27 | assert.mustBeObject(source, "source");
28 | return new ObjectKeysIterable(source);
29 | }
30 |
31 | @ToStringTag("ObjectKeysIterable")
32 | class ObjectKeysIterable implements Iterable> {
33 | private _source: T;
34 | constructor(source: T) {
35 | this._source = source;
36 | }
37 |
38 | *[Symbol.iterator](): Iterator> {
39 | const source = this._source;
40 | yield* Object.keys(source) as Extract[];
41 | }
42 | }
--------------------------------------------------------------------------------
/src/lib/fn/maxAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert } from "../internal";
19 | import { AsyncQueryable } from "../types";
20 | import { identity } from "./common";
21 | import { maxByAsync } from './maxByAsync';
22 | import { Comparison, Comparer } from '@esfx/equatable';
23 |
24 | /**
25 | * Gets the maximum element of an [[AsyncQueryable]], optionally comparing elements using the supplied callback.
26 | *
27 | * @param source An [[AsyncQueryable]] object.
28 | * @param comparer An optional callback used to compare two elements.
29 | * @category Scalar
30 | */
31 | export async function maxAsync(source: AsyncQueryable, comparer: Comparison | Comparer = Comparer.defaultComparer): Promise {
32 | if (typeof comparer === "function") comparer = Comparer.create(comparer);
33 | assert.mustBeAsyncQueryable(source, "source");
34 | assert.mustBeComparer(comparer, "comparer");
35 | return maxByAsync(source, identity, comparer);
36 | }
--------------------------------------------------------------------------------
/src/lib/fn/minAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert } from "../internal";
19 | import { AsyncQueryable } from "../types";
20 | import { identity } from "./common";
21 | import { minByAsync } from './minByAsync';
22 | import { Comparison, Comparer } from '@esfx/equatable';
23 |
24 | /**
25 | * Gets the minimum element of an [[AsyncQueryable]], optionally comparing elements using the supplied callback.
26 | *
27 | * @param source An [[AsyncQueryable]] object.
28 | * @param comparer An optional callback used to compare two elements.
29 | * @category Scalar
30 | */
31 | export async function minAsync(source: AsyncQueryable, comparer: Comparison | Comparer = Comparer.defaultComparer): Promise {
32 | if (typeof comparer === "function") comparer = Comparer.create(comparer);
33 | assert.mustBeAsyncQueryable(source, "source");
34 | assert.mustBeComparer(comparer, "comparer");
35 | return minByAsync(source, identity, comparer);
36 | }
--------------------------------------------------------------------------------
/src/typedoc/plugin/index.ts:
--------------------------------------------------------------------------------
1 | import "source-map-support/register";
2 | import { PluginHost } from "typedoc/dist/lib/utils";
3 | import { ExportDeclarationConverter } from "./nodes/exportDeclaration";
4 | import { ReflectionEventsPlugin } from "./plugins/reflectionEvents";
5 | import { ExcludeEmptyPlugin } from "./plugins/excludeEmpty";
6 | import { StripInternalPlugin } from "./plugins/stripInternal";
7 | import { ExportsPlugin } from "./plugins/exports";
8 | import { UncategorizedPlugin } from "./plugins/uncategorized";
9 | import { GroupCategoriesPlugin } from "./plugins/groupCategories";
10 | import { MergePlugin } from "./plugins/merge";
11 | import { NamingPlugin } from "./plugins/naming";
12 | import { BiblioPlugin } from "./plugins/biblio";
13 | import { NoJekyllPlugin } from "./plugins/noJekyll";
14 |
15 | function load(host: PluginHost) {
16 | const app = host.owner;
17 | app.converter.addComponent("reflectionEvents", ReflectionEventsPlugin);
18 | app.converter.addComponent("excludeEmpty", ExcludeEmptyPlugin);
19 | app.converter.addComponent("stripInternal", StripInternalPlugin);
20 | app.converter.addComponent("exports", ExportsPlugin);
21 | app.converter.addComponent("uncategorized", UncategorizedPlugin);
22 | app.converter.addComponent("groupCategories", GroupCategoriesPlugin);
23 | app.converter.addComponent("merge", MergePlugin);
24 | app.converter.addComponent("naming", NamingPlugin);
25 | app.converter.addComponent("biblio", BiblioPlugin);
26 | app.converter.addComponent("node:exportDeclaration", ExportDeclarationConverter);
27 | app.renderer.addComponent("no-jekyll", NoJekyllPlugin);
28 | }
29 |
30 | export = load;
--------------------------------------------------------------------------------
/src/lib/fn/single.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable } from "../internal";
19 | import { Queryable } from "../types";
20 | import { T } from "./common";
21 |
22 | /**
23 | * Gets the only element, or returns `undefined`.
24 | *
25 | * @param source A [[Queryable]] object.
26 | * @param predicate An optional callback used to match each element.
27 | * @category Scalar
28 | */
29 | export function single(source: Queryable, predicate: (element: T) => boolean = T) {
30 | assert.mustBeQueryable(source, "source");
31 | assert.mustBeFunction(predicate, "predicate");
32 | let hasResult = false;
33 | let result: T | undefined;
34 | for (const element of ToIterable(source)) {
35 | if (predicate(element)) {
36 | if (hasResult) {
37 | return undefined;
38 | }
39 | hasResult = true;
40 | result = element;
41 | }
42 | }
43 | return hasResult ? result : undefined;
44 | }
--------------------------------------------------------------------------------
/src/lib/fn/objectValues.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an [[Iterable]] for the own property values of an `object`.
22 | *
23 | * @param source An `object`.
24 | * @category Query
25 | */
26 | export function objectValues(source: T): Iterable]> {
27 | assert.mustBeObject(source, "source");
28 | return new ObjectValuesIterable(source);
29 | }
30 |
31 | @ToStringTag("ObjectValuesIterable")
32 | class ObjectValuesIterable implements Iterable]> {
33 | private _source: T;
34 | constructor(source: T) {
35 | this._source = source;
36 | }
37 |
38 | *[Symbol.iterator](): Iterator]> {
39 | const source = this._source;
40 | for (const key of Object.keys(source) as Extract[]) {
41 | yield source[key];
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/typeAndParent.hbs:
--------------------------------------------------------------------------------
1 | {{#compact}}
2 | {{#if this}}
3 | {{#if elementType}}
4 | {{#with elementType}}
5 | {{> typeAndParent}}
6 | {{/with}}
7 | []
8 | {{else}}
9 | {{#if reflection}}
10 | {{#ifSignature reflection}}
11 | {{#if reflection.parent.parent.url}}
12 | {{reflection.parent.parent.name}}
13 | {{else}}
14 | {{reflection.parent.parent.name}}
15 | {{/if}}
16 | .
17 | {{#if reflection.parent.url}}
18 | {{reflection.parent.name}}
19 | {{else}}
20 | {{reflection.parent.name}}
21 | {{/if}}
22 | {{else}}
23 | {{#if reflection.parent.url}}
24 | {{reflection.parent.name}}
25 | {{else}}
26 | {{reflection.parent.name}}
27 | {{/if}}
28 | .
29 | {{#if reflection.url}}
30 | {{reflection.name}}
31 | {{else}}
32 | {{reflection.name}}
33 | {{/if}}
34 | {{/ifSignature}}
35 | {{else}}
36 | {{this}}
37 | {{/if}}
38 | {{/if}}
39 | {{else}}
40 | void
41 | {{/if}}
42 | {{/compact}}
--------------------------------------------------------------------------------
/src/lib/fn/repeat.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToStringTag} from "../internal";
19 |
20 | /**
21 | * Creates an Iterable for a value repeated a provided number of times.
22 | *
23 | * @param value The value for each element of the Iterable.
24 | * @param count The number of times to repeat the value.
25 | * @category Query
26 | */
27 | export function repeat(value: T, count: number): Iterable {
28 | assert.mustBePositiveFiniteNumber(count, "count");
29 | return new RepeatIterable(value, count);
30 | }
31 |
32 | @ToStringTag("RepeatIterable")
33 | class RepeatIterable implements Iterable {
34 | private _value: T;
35 | private _count: number;
36 |
37 | constructor(value: T, count: number) {
38 | this._value = value;
39 | this._count = count;
40 | }
41 |
42 | *[Symbol.iterator](): Iterator {
43 | const value = this._value;
44 | for (let count = this._count; count > 0; --count) {
45 | yield value;
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/src/lib/fn/everyAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToPossiblyAsyncIterable } from "../internal";
19 | import { AsyncQueryable } from "../types";
20 |
21 | /**
22 | * Computes a scalar value indicating whether all elements match the supplied callback.
23 | *
24 | * @param source An [[AsyncQueryable]] object.
25 | * @param predicate A callback used to match each element.
26 | * @category Scalar
27 | */
28 | export async function everyAsync(source: AsyncQueryable, predicate: (element: T) => boolean | PromiseLike): Promise {
29 | assert.mustBeAsyncQueryable(source, "source");
30 | assert.mustBeFunction(predicate, "predicate");
31 | let hasMatchingElements = false;
32 | for await (const element of ToPossiblyAsyncIterable(source)) {
33 | const result = predicate(element);
34 | if (!(typeof result === "boolean" ? result : await result)) {
35 | return false;
36 | }
37 | hasMatchingElements = true;
38 | }
39 | return hasMatchingElements;
40 | }
--------------------------------------------------------------------------------
/src/lib/fn/someAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToPossiblyAsyncIterable } from "../internal";
19 | import { AsyncQueryable } from "../types";
20 | import { T } from "./common";
21 |
22 | /**
23 | * Computes a scalar value indicating whether `source` contains any elements,
24 | * optionally filtering the elements using the supplied callback.
25 | *
26 | * @param source An [[AsyncQueryable]] object.
27 | * @param predicate An optional callback used to match each element.
28 | * @category Scalar
29 | */
30 | export async function someAsync(source: AsyncQueryable, predicate: (element: T) => boolean | PromiseLike = T): Promise {
31 | assert.mustBeAsyncQueryable(source, "source");
32 | assert.mustBeFunction(predicate, "predicate");
33 | for await (const element of ToPossiblyAsyncIterable(source)) {
34 | const result = predicate(element);
35 | if (typeof result === "boolean" ? result : await result) {
36 | return true;
37 | }
38 | }
39 | return false;
40 | }
--------------------------------------------------------------------------------
/src/typedoc/theme/layouts/default.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{#ifCond model.name '==' project.name}}{{project.name}}{{else}}{{model.name}} | {{project.name}}{{/ifCond}}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | {{> header}}
15 |
16 |
17 |
18 |
19 | {{{contents}}}
20 |
21 |
22 |
29 |
30 |
37 |
38 |
39 |
40 |
41 | {{> footer}}
42 |
43 |
44 |
45 |
46 |
47 | {{> analytics}}
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/lib/fn/count.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable} from "../internal";
19 | import { Queryable } from "../types";
20 | import { Map, Set } from "../collections";
21 | import { T } from "./common";
22 |
23 | /**
24 | * Counts the number of elements, optionally filtering elements using the supplied callback.
25 | *
26 | * @param source A [[Queryable]] object.
27 | * @param predicate An optional callback used to match each element.
28 | * @category Scalar
29 | */
30 | export function count(source: Queryable, predicate: (element: T) => boolean = T): number {
31 | assert.mustBeQueryable(source, "source");
32 | assert.mustBeFunction(predicate, "predicate");
33 |
34 | if (predicate === T) {
35 | if (Array.isArray(source)) return source.length;
36 | if (source instanceof Set || source instanceof Map) return source.size;
37 | }
38 |
39 | let count = 0;
40 | for (const element of ToIterable(source)) {
41 | if (predicate(element)) {
42 | count++;
43 | }
44 | }
45 |
46 | return count;
47 | }
--------------------------------------------------------------------------------
/src/lib/fn/objectKeysAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an [[AsyncIterable]] for the own property keys of an `object`.
22 | *
23 | * @param source An `object` or a [[Promise]] for an `object`.
24 | * @category Query
25 | */
26 | export function objectKeysAsync(source: PromiseLike | T): AsyncIterable> {
27 | assert.mustBeObject(source, "source");
28 | return new AsyncObjectKeysIterable(source);
29 | }
30 |
31 | @ToStringTag("AsyncObjectKeysIterable")
32 | class AsyncObjectKeysIterable implements AsyncIterable> {
33 | private _source: PromiseLike | T;
34 | constructor(source: PromiseLike | T) {
35 | this._source = source;
36 | }
37 |
38 | async *[Symbol.asyncIterator](): AsyncIterator> {
39 | const source = await this._source;
40 | assert.mustBeObject(source, "source");
41 | yield* Object.keys(source) as Extract[];
42 | }
43 | }
--------------------------------------------------------------------------------
/src/lib/fn/exclude.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert } from "../internal";
19 | import { Queryable, HierarchyIterable } from "../types";
20 | import { exceptBy } from './exceptBy';
21 | import { identity } from './common';
22 |
23 | /**
24 | * Creates a [[HierarchyIterable]] with every instance of the specified value removed.
25 | *
26 | * @param source A [[HierarchyIterable]] object.
27 | * @param values The values to exclude.
28 | * @category Subquery
29 | */
30 | export function exclude(source: HierarchyIterable, ...values: [T, ...T[]]): HierarchyIterable;
31 | /**
32 | * Creates an [[Iterable]] with every instance of the specified value removed.
33 | *
34 | * @param source A [[Queryable]] object.
35 | * @param values The values to exclude.
36 | * @category Subquery
37 | */
38 | export function exclude(source: Queryable, ...values: [T, ...T[]]): Iterable;
39 | export function exclude(source: Queryable, ...values: [T, ...T[]]): Iterable {
40 | assert.mustBeQueryable(source, "left");
41 | return exceptBy(source, values, identity);
42 | }
--------------------------------------------------------------------------------
/src/lib/fn/objectEntries.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToStringTag } from "../internal";
19 | import { KeyValuePair } from "../types";
20 |
21 | /**
22 | * Creates an [[Iterable]] for the own property entries of an `object`.
23 | *
24 | * @param source An `object`.
25 | * @category Query
26 | */
27 | export function objectEntries(source: T): Iterable>> {
28 | assert.mustBeObject(source, "source");
29 | return new ObjectEntriesIterable(source);
30 | }
31 |
32 | @ToStringTag("ObjectEntriesIterable")
33 | class ObjectEntriesIterable implements Iterable>> {
34 | private _source: T;
35 | constructor(source: T) {
36 | this._source = source;
37 | }
38 |
39 | *[Symbol.iterator](): Iterator>> {
40 | const source = this._source;
41 | for (const key of Object.keys(source) as Extract[]) {
42 | yield [key, source[key]] as KeyValuePair>;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/lib/fn/toArray.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable} from "../internal";
19 | import { Queryable } from "../types";
20 | import { identity } from "./common";
21 |
22 | /**
23 | * Creates an Array for the elements of the [[Queryable]].
24 | *
25 | * @param source A [[Queryable]] object.
26 | * @category Scalar
27 | */
28 | export function toArray(source: Queryable): T[];
29 | /**
30 | * Creates an Array for the elements of the [[Queryable]].
31 | *
32 | * @param source A [[Queryable]] object.
33 | * @param elementSelector A callback that selects a value for each element.
34 | * @category Scalar
35 | */
36 | export function toArray(source: Queryable, elementSelector: (element: T) => V): V[];
37 | export function toArray(source: Queryable, elementSelector: (element: T) => T = identity): T[] {
38 | assert.mustBeQueryable(source, "source");
39 | assert.mustBeFunction(elementSelector, "elementSelector");
40 | const result: T[] = [];
41 | for (const element of ToIterable(source)) {
42 | result.push(elementSelector(element));
43 | }
44 | return result;
45 | }
46 | ;;
--------------------------------------------------------------------------------
/src/typedoc/theme/partials/member.signature.body.hbs:
--------------------------------------------------------------------------------
1 | {{#unless hideSources}}
2 | {{> member.sources isSignature=true}}
3 | {{/unless}}
4 |
5 | {{> comment}}
6 |
7 | {{#if typeParameters}}
8 |
44 |
45 | {{#if comment.returns}}
46 | {{#markdown}}{{{comment.returns}}}{{/markdown}}
47 | {{/if}}
48 |
49 | {{#if type.declaration}}
50 | {{#with type.declaration}}
51 | {{> parameter}}
52 | {{/with}}
53 | {{/if}}
54 | {{/if}}
--------------------------------------------------------------------------------
/src/lib/fn/repeatAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an Iterable for a value repeated a provided number of times.
22 | *
23 | * @param value The value for each element of the Iterable.
24 | * @param count The number of times to repeat the value.
25 | * @category Query
26 | */
27 | export function repeatAsync(value: PromiseLike | T, count: number): AsyncIterable {
28 | assert.mustBePositiveFiniteNumber(count, "count");
29 | return new AsyncRepeatIterable(value, count);
30 | }
31 |
32 | @ToStringTag("AsyncRepeatIterable")
33 | class AsyncRepeatIterable implements AsyncIterable {
34 | private _value: PromiseLike | T;
35 | private _count: number;
36 |
37 | constructor(value: PromiseLike | T, count: number) {
38 | this._value = value;
39 | this._count = count;
40 | }
41 |
42 | async *[Symbol.asyncIterator](): AsyncIterator {
43 | const value = await this._value;
44 | let count = this._count;
45 | while (count > 0) {
46 | yield value;
47 | count--;
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/lib/fn/objectValuesAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToStringTag } from "../internal";
19 |
20 | /**
21 | * Creates an [[AsyncIterable]] for the own property values of an `object`.
22 | *
23 | * @param source An `object` or a [[Promise]] for an `object`.
24 | * @category Query
25 | */
26 | export function objectValuesAsync(source: PromiseLike | T): AsyncIterable]> {
27 | assert.mustBeObject(source, "source");
28 | return new AsyncObjectValuesIterable(source);
29 | }
30 |
31 | @ToStringTag("AsyncObjectValuesIterable")
32 | class AsyncObjectValuesIterable implements AsyncIterable]> {
33 | private _source: PromiseLike | T;
34 | constructor(source: PromiseLike | T) {
35 | this._source = source;
36 | }
37 |
38 | async *[Symbol.asyncIterator](): AsyncIterator]> {
39 | const source = await this._source;
40 | assert.mustBeObject(source, "source");
41 | for (const key of Object.keys(source) as Extract[]) {
42 | yield source[key];
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/lib/fn/sum.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable} from "../internal";
19 | import { Queryable } from "../types";
20 | import { identity } from "./common";
21 |
22 | /**
23 | * Computes the sum for a series of numbers.
24 | *
25 | * @param source A [[Queryable]] object.
26 | * @category Scalar
27 | */
28 | export function sum(source: Queryable): number;
29 | /**
30 | * Computes the sum for a series of numbers.
31 | *
32 | * @param source A [[Queryable]] object.
33 | * @param elementSelector A callback used to convert a value in `source` to a number.
34 | * @category Scalar
35 | */
36 | export function sum(source: Queryable, elementSelector: (element: T) => number): number;
37 | export function sum(source: Queryable, elementSelector: (element: number) => number = identity): number {
38 | assert.mustBeQueryable(source, "source");
39 | assert.mustBeFunction(elementSelector, "elementSelector");
40 | let sum = 0;
41 | for (const value of ToIterable(source)) {
42 | const result = elementSelector(value);
43 | if (typeof result !== "number") throw new TypeError();
44 | sum += result;
45 | }
46 | return sum;
47 | }
--------------------------------------------------------------------------------
/src/lib/fn/copyTo.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable } from "../internal";
19 | import { Queryable, WritableArrayLike } from "../types";
20 |
21 | /**
22 | * Writes each element of a source iterable to a destination array.
23 | *
24 | * @param source A [[Queryable]] object.
25 | * @param dest The destination array.
26 | * @param start The offset into the array at which to start writing.
27 | * @param count The number of elements to write to the array.
28 | * @category Scalar
29 | */
30 | export function copyTo>(source: Queryable, dest: U, start: number = 0, count: number = dest.length - start): U {
31 | assert.mustBeQueryable(source, "source");
32 | assert.mustBeArrayLike(dest, "dest");
33 | assert.mustBePositiveInteger(start, "start");
34 | assert.mustBePositiveInteger(count, "count");
35 | if (count > 0) {
36 | const minLength = start + count;
37 | for (const element of ToIterable(source)) {
38 | if (count > 0) {
39 | dest[start++] = element;
40 | count--;
41 | }
42 | }
43 | if (dest.length < minLength) dest.length = minLength;
44 | }
45 | return dest;
46 | }
--------------------------------------------------------------------------------
/src/lib/fn/generate.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToStringTag} from "../internal";
19 |
20 | /**
21 | * Creates an [[Iterable]] whose values are provided by a callback executed a provided number of
22 | * times.
23 | *
24 | * @param count The number of times to execute the callback.
25 | * @param generator The callback to execute.
26 | * @category Query
27 | */
28 | export function generate(count: number, generator: (offset: number) => T): Iterable {
29 | assert.mustBePositiveFiniteNumber(count, "count");
30 | assert.mustBeFunction(generator, "generator");
31 | return new GenerateIterable(count, generator);
32 | }
33 |
34 | @ToStringTag("GenerateIterable")
35 | class GenerateIterable implements Iterable {
36 | private _count: number;
37 | private _generator: (offset: number) => T;
38 |
39 | constructor(count: number, generator: (offset: number) => T) {
40 | this._count = count;
41 | this._generator = generator;
42 | }
43 |
44 | *[Symbol.iterator](): Iterator {
45 | const count = this._count;
46 | const generator = this._generator;
47 | for (let i = 0; i < count; i++) {
48 | yield generator(i);
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/src/lib/fn/reverse.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable, FlowHierarchy, ToStringTag} from "../internal";
19 | import { Queryable, HierarchyIterable } from "../types";
20 | import { toArray } from "./toArray";
21 |
22 | /**
23 | * Creates a subquery whose elements are in the reverse order.
24 | * @category Subquery
25 | */
26 | export function reverse(source: HierarchyIterable): HierarchyIterable;
27 | /**
28 | * Creates a subquery whose elements are in the reverse order.
29 | * @category Subquery
30 | */
31 | export function reverse(source: Queryable): Iterable;
32 | export function reverse(source: Queryable): Iterable {
33 | assert.mustBeQueryable(source, "source");
34 | return FlowHierarchy(new ReverseIterable(ToIterable(source)), source);
35 | }
36 |
37 | @ToStringTag("ReverseIterable")
38 | class ReverseIterable implements Iterable {
39 | private _source: Iterable;
40 |
41 | constructor(source: Iterable) {
42 | this._source = source;
43 | }
44 |
45 | *[Symbol.iterator](): Iterator {
46 | const list = toArray(this._source);
47 | list.reverse();
48 | yield* list;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/lib/fn/evalAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, FlowHierarchy } from "../internal";
19 | import { AsyncQueryable, PossiblyAsyncHierarchyIterable, HierarchyIterable } from "../types";
20 | import { toArrayAsync } from "./toArrayAsync";
21 |
22 | /**
23 | * Eagerly evaluate a [[HierarchyIterable]] or [[AsyncHierarchyIterable]], returning a [[Promise]]
24 | * for a [[HierarchyIterable]] for the resolved elements of the original sequence.
25 | *
26 | * @param source A [[HierarchyIterable]] or [[AsyncHierarchyIterable]] object.
27 | * @category Scalar
28 | */
29 | export async function evalAsync(source: PossiblyAsyncHierarchyIterable): Promise>;
30 | /**
31 | * Eagerly evaluate an [[AsyncQueryable]], returning a [[Promise]] for an [[Iterable]] for the
32 | * resolved elements of the original sequence.
33 | *
34 | * @param An [[AsyncQueryable]] object.
35 | * @category Scalar
36 | */
37 | export async function evalAsync(source: AsyncQueryable): Promise>;
38 | export async function evalAsync(source: AsyncQueryable): Promise> {
39 | assert.mustBeAsyncQueryable(source, "source");
40 | return FlowHierarchy(await toArrayAsync(source), source);
41 | }
--------------------------------------------------------------------------------
/src/lib/fn/elementAt.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToIterable} from "../internal";
19 | import { Queryable } from "../types";
20 | import { last } from "./last";
21 |
22 | /**
23 | * Finds the value at the provided offset. A negative offset starts from the
24 | * last element.
25 | *
26 | * @param source A [[Queryable]] object.
27 | * @param offset An offset.
28 | * @category Scalar
29 | */
30 | export function elementAt(source: Queryable, offset: number): T | undefined {
31 | assert.mustBeQueryable(source, "source")
32 | assert.mustBeInteger(offset, "offset");
33 | if (offset === -1) {
34 | return last(source);
35 | }
36 | if (offset < 0) {
37 | offset = Math.abs(offset);
38 | const array: T[] = [];
39 | for (const element of ToIterable(source)) {
40 | if (array.length >= offset) {
41 | array.shift();
42 | }
43 | array.push(element);
44 | }
45 | return array.length - offset >= 0 ? array[array.length - offset] : undefined;
46 | }
47 | for (const element of ToIterable(source)) {
48 | if (offset === 0) {
49 | return element;
50 | }
51 | offset--;
52 | }
53 | return undefined;
54 | }
--------------------------------------------------------------------------------
/src/lib/fn/distinct.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert } from "../internal";
19 | import { Queryable, HierarchyIterable } from "../types";
20 | import { identity } from "./common";
21 | import { Equaler } from '@esfx/equatable';
22 | import { distinctBy } from './distinctBy';
23 |
24 | /**
25 | * Creates a [[HierarchyIterable]] for the distinct elements of `source`.
26 | * @category Subquery
27 | *
28 | * @param source A [[HierarchyIterable]] object.
29 | * @param equaler An [[Equaler]] object used to compare element equality.
30 | */
31 | export function distinct(source: HierarchyIterable, equaler?: Equaler): HierarchyIterable;
32 | /**
33 | * Creates an [[Iterable]] for the distinct elements of `source`.
34 | * @category Subquery
35 | *
36 | * @param source A [[Queryable]] object.
37 | * @param equaler An [[Equaler]] object used to compare element equality.
38 | */
39 | export function distinct(source: Queryable, equaler?: Equaler): Iterable;
40 | export function distinct(source: Queryable, equaler?: Equaler): Iterable {
41 | assert.mustBeQueryable(source, "source");
42 | assert.mustBeEqualerOrUndefined(equaler, "equaler");
43 | return distinctBy(source, identity, equaler);
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/fn/countAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToPossiblyAsyncIterable, GetAsyncSource } from "../internal";
19 | import { Map, Set } from "../collections";
20 | import { AsyncQueryable } from "../types";
21 | import { T } from "./common";
22 |
23 | /**
24 | * Counts the number of elements, optionally filtering elements using the supplied callback.
25 | *
26 | * @param source A [[Queryable]] object.
27 | * @param predicate An optional callback used to match each element.
28 | * @category Scalar
29 | */
30 | export async function countAsync(source: AsyncQueryable, predicate: (element: T) => boolean | PromiseLike = T): Promise {
31 | assert.mustBeAsyncQueryable(source, "source");
32 | assert.mustBeFunction(predicate, "predicate");
33 |
34 | if (predicate === T) {
35 | const realSource = GetAsyncSource(source);
36 | if (Array.isArray(realSource)) return realSource.length;
37 | if (realSource instanceof Set || realSource instanceof Map) return realSource.size;
38 | }
39 |
40 | let count = 0;
41 | for await (const element of ToPossiblyAsyncIterable(source)) {
42 | if (predicate === T || await predicate(element)) {
43 | count++;
44 | }
45 | }
46 |
47 | return count;
48 | }
--------------------------------------------------------------------------------
/src/lib/fn/copyToAsync.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, ToPossiblyAsyncIterable } from "../internal";
19 | import { WritableArrayLike, AsyncQueryable } from "../types";
20 |
21 | /**
22 | * Writes each element of a source iterable to a destination array.
23 | *
24 | * @param source A [[Queryable]] object.
25 | * @param dest The destination array.
26 | * @param start The offset into the array at which to start writing.
27 | * @param count The number of elements to write to the array.
28 | * @category Scalar
29 | */
30 | export async function copyToAsync>(source: AsyncQueryable, dest: U, start: number = 0, count: number = dest.length - start): Promise {
31 | assert.mustBeAsyncQueryable(source, "source");
32 | assert.mustBeArrayLike(dest, "dest");
33 | assert.mustBePositiveInteger(start, "start");
34 | assert.mustBePositiveInteger(count, "count");
35 | if (count > 0) {
36 | const minLength = start + count;
37 | for await (const element of ToPossiblyAsyncIterable(source)) {
38 | if (count > 0) {
39 | dest[start++] = element;
40 | count--;
41 | }
42 | }
43 | if (dest.length < minLength) dest.length = minLength;
44 | }
45 | return dest;
46 | }
--------------------------------------------------------------------------------
/src/lib/fn/toHierarchy.ts:
--------------------------------------------------------------------------------
1 | /*!
2 | Copyright 2018 Ron Buckton (rbuckton@chronicles.org)
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | /** @module "iterable-query/fn" */
17 |
18 | import { assert, MakeHierarchyIterable} from "../internal";
19 | import { Queryable, HierarchyIterable, HierarchyProvider, OrderedIterable, OrderedHierarchyIterable } from "../types";
20 |
21 | /**
22 | * Creates a [[HierarchyIterable]] using the provided `HierarchyProvider`.
23 | *
24 | * @param source A [[Queryable]] object.
25 | * @param hierarchy A `HierarchyProvider`.
26 | * @category Hierarchy
27 | */
28 | export function toHierarchy(source: OrderedIterable, hierarchy: HierarchyProvider): OrderedHierarchyIterable;
29 | /**
30 | * Creates a [[HierarchyIterable]] using the provided `HierarchyProvider`.
31 | *
32 | * @param source A [[Queryable]] object.
33 | * @param hierarchy A `HierarchyProvider`.
34 | * @category Hierarchy
35 | */
36 | export function toHierarchy(source: Queryable, hierarchy: HierarchyProvider
14 | {{#each tags}} 15 |- {{tagName}}
16 | - {{#markdown}}{{{text}}}{{/markdown}}
17 | {{/each}}
18 |
19 | {{/if}} 20 |