Giter VIP home page Giter VIP logo

linqtotypescript's People

Contributors

arogozine avatar martincostello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linqtotypescript's Issues

one shot queries

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?

max() on empty sequence from array throws

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?

esbuild outerLoop' error

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

Running into issues with React

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.

image

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.

how to use select with chained groupby

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?

Support for LINQ to SQL

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

Node.js 20 LTS compatibility

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)

Performance comparison/measurements

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!

IEnumerable Min returns wrong result

For some reason, min method in IEnumerable<TSource> returns a wrong result. You can see here, with this test that fails:

itEnumerable("Min", (asEnumerable) => { expect(asEnumerable([1, 2, 0, 1, 3, 4, 9, 8, 5]).min()).toBe(0) })

image

LINQ .concat conflicts with native Typescript / Javascript .concat method

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!

Unsupported engine for Node v16?

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 :)

orderBy<number> with default comparer uses string-based sort order

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);
        }
    }

functions GroupJoin, DefaultIfEmpty are not available

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,
  }))
);

The library is great but does not work with React. Please Fix !!!

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.

Support typescript 3.7

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.