arogozine / linqtotypescript Goto Github PK
View Code? Open in Web Editor NEWLINQ to TypeScript
Home Page: https://arogozine.github.io/linqtotypescript/
License: MIT License
LINQ to TypeScript
Home Page: https://arogozine.github.io/linqtotypescript/
License: MIT License
Hi there!
It looks like some queries are 'one shot' queries. They are not reusable. For example the following test passes.
test('ienum', () => { function* foo() { yield 0 } const e = from(foo()) expect(e.count()).toBe(1) expect(e.count()).toBe(0) })
Please notice that the first call to e.count() returns 1 as the second returns 0!
Is it by design?
Hello Guys,
IEnumerable<>.max() function in .NET returns null when sequence is empty (semantics maximum is unknown). LinqToTypeScript throws an error. Is this by design?
moving to angular 17 i get a blocking issue using esbuild (does not happen with webpack)
Illegal continue statement: 'outerLoop' does not denote an iteration statement
just wandering if this will affect your great job in the future
thanks
Hi, I had no issues using this great library in Vue, but in React (created with current npx create-react-app) I'm not able to make it work.
I tried to use it with both "from" approach and global initialization. As soon as I import anything from "linq-to-typescript" it does not compile. If there is any more info I can provide please let me know.
Hello,
In c# I have the following code:
// customers
// Name: Brian, PriceUnit: 10, Quantity: 1
// Name: John, PriceUnit: 10, Quantity: 2
// Name: Brian, PriceUnit: 10, Quantity: 3
var list = customers
.Select(c => new { c.Name, Total = c.PriceUnit * c.Quantity })
.GroupBy(g => new { g.Name })
.Select(x => new { x.Name, Total = x.Sum(s => x.Total)})
.ToList();
// list
// Name: Brian, Total: 40
// Name: John, Total: 20
I tried to reproduce this using LinqToTypeScript but I couldn't. Can you help me?
do you have any plan or idea for creating such an amazing thing like what EF Core does?
i mean creating a tool that can convert LINQ expressions to SQL queries
LingToTypescript does not work with node.js 20 LTS.
Uncaught SyntaxError: Illegal continue statement: 'outerLoop' does not denote an iteration statement (at linq-to-typescript.js?v=09a07e09:3073:26)
Hi guys,
First of all, many thanks for this library! I consider C# my 'native' programming language and was happy to discover your library. JS/TS lacks a lot of built-in capabilities, and libraries as yours help it to thrive.
However, I was wondering, do you have any perf tests to estimate influence of the library on the app performance?
Thanks again!
We just installed your linq-to-typescript package in our Angular application and we found that it overrides the native .concat method for Typescript / JavaScript. Is there any possibility you can either rename the LINQ .concat method to something other than .concat? If not, is there any way to set up the package to not override the native .concat method?
Another great option is if the LINQ methods are being extended to the specific object, when it's a string, it would help to return a string instead of an IEnumerable. The native .concat method for strings just takes two strings and returns a concatenated string. The linq-to-typescript package will return an IEnumerable, which breaks a lot of other packages that use the native .concat. That's the reason for even bothering you with this. Thank you!
Severity Low
Impact Testing with Karma
Need to wait for karma to update,
#karma-runner/karma#2994
When I install this package I get the following message:
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=17' },
npm WARN EBADENGINE current: { node: 'v16.13.2', npm: '8.1.2' }
npm WARN EBADENGINE }
I can't update to Node v17 so I was wondering whether it's really a problem or I can just ignore it?
Thank you for your work, btw :)
Hello Alex,
Another thing I ran into, not to miss. Maybe everybody who knows javascript is perfectly aware of it, but a default "comparer" sucks at comparing numbers.
For example,
let x = [1, 2, 100];
x.sort();
console.log('sorted', x);
prints
1
100
2
I am concluding array.sort uses toString for sorting. This was totally unexpected, and I suggest comparer should be made a mandatory argument.
Now, in regard to sort implementation, eh, why does it populate map of arrays instead of say quick sort? Quick look on referencesource
https://github.com/microsoft/referencesource/blob/master/System.Core/System/Linq/Enumerable.cs
internal abstract class EnumerableSorter<TElement>
{
internal abstract void ComputeKeys(TElement[] elements, int count);
internal abstract int CompareKeys(int index1, int index2);
internal int[] Sort(TElement[] elements, int count) {
ComputeKeys(elements, count);
int[] map = new int[count];
for (int i = 0; i < count; i++) map[i] = i;
QuickSort(map, 0, count - 1);
return map;
}
void QuickSort(int[] map, int left, int right) {
do {
int i = left;
int j = right;
int x = map[i + ((j - i) >> 1)];
do {
while (i < map.Length && CompareKeys(x, map[i]) > 0) i++;
while (j >= 0 && CompareKeys(x, map[j]) < 0) j--;
if (i > j) break;
if (i < j) {
int temp = map[i];
map[i] = map[j];
map[j] = temp;
}
i++;
j--;
} while (i <= j);
if (j - left <= right - i) {
if (left < j) QuickSort(map, left, j);
left = i;
}
else {
if (i < right) QuickSort(map, i, right);
right = j;
}
} while (left < right);
}
}
Which ECMAScript 2022 features are needed for the library to work correctly?
Is it possible to reduce the required version using polyfills?
I don't do this often but had to implement left join. This is not easy, a couple of shorthands from LINQ, GroupJoin and DefaultIfEmpty are not present. Can they be introduced? Thanks!
let list1: KV[] = [
{ key: 0, value: 'a' },
{ key: 1, value: 'b' },
{ key: 2, value: 'c' },
{ key: 3, value: 'd' },
];
let list2: KV[] = [
{ key: 0, value: 'aa' },
{ key: 1, value: 'bb' },
{ key: 3, value: 'dd' },
];
let rightGroups = from(list2)
.groupBy(x => x.key)
.toMap(x => x.key);
let groupLeftJoin = from(list1).select((left) => {
let matches = rightGroups.get(left.key);
return { left: left, right: matches ? from(matches) : from([null]) };
});
let leftJoin = groupLeftJoin.selectMany((x) =>
x.right.select((right) => ({
left: x.left,
right,
}))
);
Hi,
An overwhelmingly large proportion of React apps are created with CRA (Create React App). This lib looks very promising as it generator based and can perform LINQ on Typescript without any additional boilerplate code.
We have tried this on a few different machines with CRA. It builds, but at runtime throws the following error (using the steps from your readme) on InitializeLinq():
TypeError: Object(...) is not a function
Module../src/common/utils/Linq.ts
{My_React_App_Directory }/src/common/utils/Linq.ts:28
25 | interface String extends IEnumerable { }
26 | }
27 | // 2. Bind Linq Functions to Array and Map
28 | initializeLinq();
Please test and fix with CRA.
Thanks in advance.
Hi,
When upgrading to ts 3.7, the fallowing error occur
node_modules/linq-to-typescript/types/IParallelEnumerable.d.ts:1:148
TS2440: Import declaration conflicts with local declaration of 'IParallelEnumerable'.
If I remove the declaration, all is fine
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.