-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,271 additions
and
365 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no-install commitlint --edit "$1" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest All", | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": ["--runInBand"], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"windows": { | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
} | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest Current File", | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": ["--runTestsByPath", "${relativeFile}"], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"windows": { | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
} | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest Selected Test Name", | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": ["--runTestsByPath", "${relativeFile}", "-t=${selectedText}$"], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"windows": { | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,69 @@ | ||
# typescript-extended-linq | ||
|
||
This is a library that is a direct translation of [System.Linq](https://docs.microsoft.com/en-us/dotnet/api/system.linq) from .NET and many additional functions from [MoreLINQ](https://github.com/morelinq/MoreLINQ). | ||
|
||
## Installation: | ||
|
||
```typescript | ||
npm i typescript-extended-linq | ||
``` | ||
|
||
## Why use this LRU Cache? | ||
|
||
### Additional Functionality | ||
|
||
- Native JavaScript/TypeScript provides many useful functions that are similar to LINQ (such as map, filter, reduce, etc). This library fills in the missing gaps with many functions that are not included in the native language such as joins, multi-level ordering, grouping, etc. | ||
|
||
### Deferred Execution | ||
|
||
- Just like LINQ, this library uses [deferred execution and lazy evaluation](https://docs.microsoft.com/en-us/dotnet/standard/linq/deferred-execution-lazy-evaluation). | ||
|
||
### TypeScript First | ||
|
||
- This library was written in Typescript so type definitions are included out of the box and are always up to date. The Typescript source code is included in the package so users can easily look at the implementation. | ||
- [Documentation](https://rob893.github.io/typescript-extended-linq/) is also auto-generated on every release so they will always be up to date as well. | ||
|
||
## Documentation | ||
|
||
Please see full documentation [here](https://rob893.github.io/typescript-extended-linq/). | ||
|
||
## Basic Usage: | ||
|
||
```typescript | ||
import { from } from 'typescript-extended-linq'; | ||
|
||
const items = [ | ||
{ id: 1, foo: 'a', bar: new Date('8/1/2021') }, | ||
{ id: 2, foo: 'a', bar: new Date('8/1/2021') }, | ||
{ id: 2, foo: 'b', bar: new Date('8/1/2021') }, | ||
{ id: 2, foo: 'a', bar: new Date('9/1/2021') }, | ||
{ id: 3, foo: 'a', bar: new Date('8/1/2021') }, | ||
{ id: 3, foo: 'b', bar: new Date('8/1/2021') } | ||
]; | ||
|
||
const query = from(items) | ||
.where(item => item.id % 2 === 0) | ||
.orderBy(item => item.id) | ||
.thenBy(item => item.foo) | ||
.thenBy(item => item.bar); | ||
|
||
/** | ||
* Will log: | ||
* [ | ||
* { id: 2, foo: 'a', bar: 2021-08-01T07:00:00.000Z }, | ||
* { id: 2, foo: 'a', bar: 2021-09-01T07:00:00.000Z }, | ||
* { id: 2, foo: 'b', bar: 2021-08-01T07:00:00.000Z } | ||
* ] | ||
*/ | ||
console.log(query.toArray()); | ||
|
||
const sumOfIds = query.sum(item => item.id); | ||
|
||
// Will log 6 | ||
console.log(sumOfIds); | ||
|
||
const distinct = query.distinctBy(item => item.id).toArray(); | ||
|
||
// Will log [ { id: 2, foo: 'a', bar: 2021-08-01T07:00:00.000Z } ] | ||
console.log(distinct); | ||
``` |
Oops, something went wrong.