Giter Site home page Giter Site logo

kutyel / linq.ts Goto Github PK

View Code? Open in Web Editor NEW
830.0 28.0 74.0 1.37 MB

πŸŒ€LINQ for TypeScript

Home Page: http://kutyel.github.io/linq.ts/

License: MIT License

TypeScript 100.00%
linq typescript linq-to-objects linq-expressions linq-typescript linq-methods linq-extensions linq-samples hacktoberfest

linq.ts's Introduction

LinQ for TypeScript

Build Coverage Status Downloads Version Sponsors linqts

Install

$ npm i linqts

Usage

import { List } from 'linqts';

const arr = new List<number>([1, 2, 3, 4, 5])
  .Where(x => x > 3)
  .Select(y => y * 2)
  .ToArray(); // > [8, 10]

const query = people.Join(pets,
  person => person,
  pet => pet.Owner,
  (person, pet) =>
    ({ OwnerName: person.Name, Pet: pet.Name }));

Demo

linqts.gif

Documentation

If you do not know LinQ or just want to remember what is all about, have a look at the docs.

Tests

$ npm t

Powered by AVA.

Contributors

Thanks goes to these wonderful people (emoji key):


Flavio Corpa

πŸ’» πŸ’¬ πŸ“– πŸ‘€

Luis Rogelio HernΓ‘ndez LΓ³pez

πŸ’» πŸ”§

Zsolt KovΓ‘cs

πŸ’»

Mo Abbas

πŸ’»

JuliΓ‘n Salgado Napolitano

πŸ’» πŸ”§

mstrzoda

πŸ’» πŸ› ⚠️

Kyle Wascher

⚠️

James Richford

πŸ”§

Natarajan Ganapathi

πŸ’» πŸ”§

Jonas Brekle

πŸ’» πŸ›

LP

πŸ’» ⚠️

Asier Ferro

πŸ’» πŸ”§

marlon-tucker

πŸ’» πŸ”§ πŸ“¦

Misha Sulikashvili

πŸ’» ⚠️

Saurav Sahu

πŸš‡

Bob Cook

πŸ’΅

Adrien

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT Β© Flavio Corpa

linq.ts's People

Contributors

abbasmhd avatar asierferro avatar greenkeeper[bot] avatar grofit avatar jamesadarich avatar keropodium avatar kurtz1993 avatar kutyel avatar marlon-tucker avatar mrsauravsahu avatar mstrzoda avatar natarajanmca11 avatar skeletonskelettron avatar zoxive 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linq.ts's Issues

Fix module for browser/node

d:\TypeScriptSamples\warship>webpack
Hash: 396f0bfb9d565b6f60f0
Version: webpack 1.13.2
Time: 29ms

ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' ./app.ts in d:\TypeScriptSamples\warship

d:\TypeScriptSamples\warship>

Help on GroupBy

Hi, how can I convert the result of the GroupBy to something enumerable?

Update to TypeScript 2.0

The guide for this issue is quite simple, you just have to check the following link:

http://www.typescriptlang.org/docs/release-notes/typescript-2.0.html

After that you will notice that there are many changes to be made to the linq.ts file. Luckily, because is TypeScript, once you change the version from the package.json and re-run npm install all the warnings will help you accomplish your task. Code should transpile correctly and should pass all the unit tests plus the CI.

Good luck and happy #hacktoberfest!!

add to Primitive extension method

LK"I

Hi,

Have you considered adding toPrimitive extension method?
In that case , we can easily convert the LINQ List object into TypeScript array primitive.

Harel

wrong sorting with multiple ThenBy's

Hi,
I tried using your library but I have a issue with multiple ThenBy's - it seems the last ThenBy has precendence over the first when it shouldn't.

let unsorted = new List([
    {a:2, b:1, c:1},
    {a:1, b:2, c:2},
    {a:1, b:1, c:3}
]);
let sorted = unsorted.OrderBy(x => x.a)
    .ThenBy(x => x.b)
    .ThenBy(x => x.c)
    .ToArray();

I constructed the example in a way that without the last ThenBy, the items should be sorted reversed. The last ThenBy should have no effect because there are no equalities in the first two sort steps. But it does.
Is there something wrong in my logic or is this a bug?

Regards,
Jonas

First() and FirstOrDefault() returns T | Error

I'm having issues where I expect:

private _foo: MyThing;
private _fooList: List<MyThing>;
get Foo(){return _foo;}
set Foo(value : MyThing){ _foo = value;}
DoStuff(){
 Foo = this._fooList.FirstOrDefault(x=> x.id == 1);
}

DoStuff() doesn't work because this._fooList.FirstOrDefault() isn't returning MyThing, it's returning MyThing | Error.

Or am I misusing this thing?

Remove dependency on Immutable.js?

I would like the opinion of the community regarding whether I should remove the dependency upon Immutable.js or not. As I return a new instance of my class every time in most methods, this makes the library already "immutable" by definition. Moreover, this would allow me to make my own methods implementation, maybe using approaches similar to the ones in lodash to make it as fastest as possible.

.Distinct() not working for complex types

Hi,

the .Distinct() method seems to not work for complex types:

new List<IdName>([
  new IdName(1, 'Boston'),
  new IdName(1, 'Boston'),
  new IdName(2, 'London')
]).Distinct()

returns all three elements. It would be cool to be able to use

.Distinct(x => x.id);

Thanks for your help
Ingo

GroupBy and then select

Maybe I missed something but it looks like group by doesn't return collection and as result it is not possible to use Select with some aggregate operation.

What about returning IGrouping?

Cannot import TypeScript module

Hi I get unexpected token export while trying to use List<T>...

import { List } from 'linqts';
let arr = new List<number>([1,2,3,4,5])
    .Where(x => x > 3)
    .Select(y => y * 2)
    .ToArray(); // > [8, 10] 
console.log(arr);

console log:

linq.ts:10 Uncaught SyntaxError: Unexpected token export
exports.runInThisContext @ vm.js:53Module._compile @ module.js:511Module._extensions..js @ module.js:550Module.load @ module.js:456tryModuleLoad @ module.js:415Module._load @ module.js:407Module.require @ module.js:466require @ internal/module.js:20(anonymous function) @ app.js:5Module._compile @ module.js:541Module._extensions..js @ module.js:550Module.load @ module.js:456tryModuleLoad @ module.js:415Module._load @ module.js:407Module.require @ module.js:466require @ internal/module.js:20(anonymous function) @ index.html:18

using node tsc -w

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "noImplicitAny": true,
        "sourceMap": false
    },
    "exclude": [
        "node_modules"
    ]
}

es3, es5 does not make any difference

Got no idea what am I doing wrong πŸ˜•

Implement ThenBy()

Implement the method according to the following specification:

string[] fruits = { "grape", "passionfruit", "banana", "mango", 
                      "orange", "raspberry", "apple", "blueberry" };

// Sort the strings first by their length and then 
//alphabetically by passing the identity selector function.
IEnumerable<string> query =
    fruits.OrderBy(fruit => fruit.Length).ThenBy(fruit => fruit);

foreach (string fruit in query)
{
    Console.WriteLine(fruit);
}

/*
    This code produces the following output:

    apple
    grape
    mango
    banana
    orange
    blueberry
    raspberry
    passionfruit
*/

The unit test for this method shoud be implemented here.

Explicit undefined as return type

Methods like FirstOrDefault need explicit undefined as return type (mostly for intellisense and compilation errors in strict mode)

public FirstOrDefault(): T;
will become
public FirstOrDefault(): T | undefined;

And all cases like this πŸ‘
Any suggestions?

Uncaught ReferenceError: exports is not defined

Typescript compiler options are:

  "compilerOptions": {
    "module": "amd",
    "moduleResolution": "node",
    "target": "es2016",
    "lib": [
      "es2016",
      "dom"
    ],
    "declarationDir": "node_modules/@types",
    "declaration": true,
    "outDir": "dist",
    "types": [
      "vss-web-extension-sdk",
      "c3",
      "d3",
      "jquery",
      "knockout"
    ]
  },

Upon Load the message Uncaught ReferenceError: exports is not defined is seen in Chrome console pointing to line 372.

exports

Attempts to install dependencies via NPM Update and or Install for this package doesn't work. Please advise.

Implement TakeWhile()

Implement the method according to the following specification:

string[] fruits = { "apple", "banana", "mango", "orange", 
                      "passionfruit", "grape" };

IEnumerable<string> query =
    fruits.TakeWhile(fruit => String.Compare("orange", fruit, true) != 0);

foreach (string fruit in query)
{
    Console.WriteLine(fruit);
}

/*
 This code produces the following output:

 apple
 banana
 mango
*/

The unit test for this method is ready to be uncommented when this issue closes.

Array -> List

What about having something like:

Array.prototype.toList = function<T>(): List<T> {
    return new List<T>(this);
}

Undefined: Performance and logic

Hi,

I noticed that you are using undefined as default value in FirstOrDefault, etc.

As seen here, checking for null is way faster than undefined (and makes more sense from the design perspective).

What about me creating a PR to change all undefined to null when it makes sense?

Cannot find module "."

Hi,

when I run ionic serve on Windows command prompt, the google chrome developer console throws the following error:

Cannot find module "."

in file <project dir>\node_modules\linqts\dist\linq.js at line 8.

The content of the linq.js file is:

var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
(function (dependencies, factory) {
    if (typeof module === 'object' && typeof module.exports === 'object') {
        var v = factory(require, exports); if (v !== undefined) module.exports = v;
    }
    else if (typeof define === 'function' && define.amd) {
        define(dependencies, factory);
    }
})(["require", "exports"], function (require, exports) {
    "use strict";
...

What can be the problem?

Thanks in advance.

GroupBy using grouper function that returns complex type doesn not work

When performing a GroupBy on a List<> using a grouper function that returns a "complex" anonymous type, GroupBy returns a flat array of objects (untyped "T" objects) instead of a list of key/value pairs as it does when grouping with a grouper function that returns a primitive type.

e.g with a type.

interface IReferral {
    origin: string;
    modalityType: string;
    qtyReferrals: number;
}

Not working:

let referralsByOrigin = new List<IReferral>(data).GroupBy(key => ({ org: key.origin, modType: key.modalityType}), element => element);

I am currently working around this by creating a primitive returning grouper that returns a concatenation of my grouping elements like below, and then, when processing the result, retrieving the actual grouping elements from the first item. (instead of retrieving them as "menbers" of the grouper result (key) :

let groupedData = new List<IReferral>(result).GroupBy(key => key.origin + '_' + key.modalityType , element => element);

for (var key in groupedData) {
  // count the total nr of referrals
  var totalReferrals = groupedData[key].reduce((a, b) => a + b.qtyReferrals, 0);
  var firstItem : IReferral = new List<IReferral> (groupedData[key]).First();
  this.chartData.push([firstItem.origin, firstItem.modalityType, totalReferrals]);
}

a fix to this would be great!

MissInheritance of Enumerable

In short words: everything must inherit from Enumerable

Currently on C#:

Enumerable<T>:

- Select
- Where
- First, Single
- FirstOrDefault, SingleOrDefault
- Basically all filter / select based methods

List<T> extends Enumerable<T>

- All inherited stuff
- Add, Delete, DeleteWhere (or DeleteAll), ...
- OrderBy, OrderByDesc

SortedList<T> extends List<T>

- Correctly implemented

Etc ...

Project has dependency to typescript?

https://github.com/kutyel/linq.ts/blob/master/package.json

  "dependencies": {
    "typescript": "^2.3.1"
  },
  "devDependencies": {
    "ava": "^0.20.0",
    "commitizen": "^2.8.6",
    "coveralls": "^2.11.14",
    "cz-conventional-changelog": "^2.0.0",
    "ghooks": "^2.0.0",
    "npm-run-all": "^4.0.0",
    "nyc": "^11.0.2",
    "rimraf": "^2.5.4",
    "semantic-release": "^6.3.2",
    "ts-loader": "^2.0.0",
    "ts-node": "^3.0.0",
    "tslint": "^5.0.0",
    "typedoc": "^0.7.0",
    "webpack": "^3.0.0"
  },

CMIIW, but shouldn't that be devDependencies instead? I don't see any TypeScript imports in https://github.com/kutyel/linq.ts/blob/master/linq.ts

I just don't feel comfortable downloading / having a 26 MB dependency inside my node_modules for a library that is only 50 KB in size...

How to import linq.ts into module

I have my angular 1.5 typescript app organised in several files: app.ts, controller.ts, ientity.ts etc. All files re wrapped in module MyApp {}. In tsconfig I have outFile option set so that everything compiles into a single app.js file.

How do I use linq.ts in such project? If I try to import {List} from "linqts" at the top of any of my *.ts files outside module MyApp then compilation breaks because of compiler not being able to find types defined in same module but another file (for example interfaces declared in ientity.ts are no longer valid in controller.ts).

But if I put import declaration inside module MyApp {} then I get following compiler error:
TS1147 Import declarations in a namespace cannot reference a module.

What is correct why to use this library in multi-file single module project setup?
Am not sure if it might affect, but I use typings to reference angular, underscore, etc.

node_modules\linqts\linq.ts (154,43): Index signature of object type implicitly has an 'any' type. (7017)

Hi,

I am getting the following error at runtime. Compile the code does not throw any error.

image

Compiler Options FYR - tsconfig.json

"compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "declaration": false,
    "removeComments": true,
    "noLib": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "pretty": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitUseStrict": false,
    "noFallthroughCasesInSwitch": true
  },

I hit an Unexpected token. (NG2 Project)

Compile work but when I run I got :

zone.js:323 Error: SyntaxError: Unexpected token <at Object.eval 
(http://localhost/fusion/app/component/common/floatingCombo.component.js:23:16)
--> var linqts_1 = require('linqts');

Webpack install is necessary?

And btw why you didn't supply .js?

module and namespace collision

we are following namespace in the ts files and the linq.ts has module declarations. I can't import the modules because of the modules and namespaces are not working together. could you please help me how can i consume linq.ts module inside namespace?

Coverage 100%

I made this library following TDD principles, therefore every method is very well tested, however, It seems that something might be missing because coverage is not 100%, I would really like to know what it is and get it done! πŸ˜‰

Any() doesn't have empty overload as .NET

I found that when trying to use the .Any() method I'm getting an error because it's always expecting a predicate.
In .NET there's an overload that doesn't require a predicate and returns a boolean by checking if there are any elements (something like javascript this._elements.length > 0

I will try to prepare a PR as well for this

Extension methods case question

I know that .NET types all use Pascal casing (e.g. FirstOrDefault), but would it not make more sense to have this lib follow the JS conventions of Camel casing (e.g. firstOrDefault)?

Implement GroupJoin()

Implement the method according to the following specification:

class Person
{
    public string Name { get; set; }
}

class Pet
{
    public string Name { get; set; }
    public Person Owner { get; set; }
}

public static void GroupJoinEx1()
{
    Person magnus = new Person { Name = "Hedlund, Magnus" };
    Person terry = new Person { Name = "Adams, Terry" };
    Person charlotte = new Person { Name = "Weiss, Charlotte" };

    Pet barley = new Pet { Name = "Barley", Owner = terry };
    Pet boots = new Pet { Name = "Boots", Owner = terry };
    Pet whiskers = new Pet { Name = "Whiskers", Owner = charlotte };
    Pet daisy = new Pet { Name = "Daisy", Owner = magnus };

    List<Person> people = new List<Person> { magnus, terry, charlotte };
    List<Pet> pets = new List<Pet> { barley, boots, whiskers, daisy };

    // Create a list where each element is an anonymous 
    // type that contains a person's name and 
    // a collection of names of the pets they own.
    var query =
        people.GroupJoin(pets,
                         person => person,
                         pet => pet.Owner,
                         (person, petCollection) =>
                             new
                             {
                                 OwnerName = person.Name,
                                 Pets = petCollection.Select(pet => pet.Name)
                             });

    foreach (var obj in query)
    {
        // Output the owner's name.
        Console.WriteLine("{0}:", obj.OwnerName);
        // Output each of the owner's pet's names.
        foreach (string pet in obj.Pets)
        {
            Console.WriteLine("  {0}", pet);
        }
    }
}

/*
 This code produces the following output:

 Hedlund, Magnus:
   Daisy
 Adams, Terry:
   Barley
   Boots
 Weiss, Charlotte:
   Whiskers
*/

The unit test for this method is ready to be unskipped when this issue closes.

.ToArray() confusing description? "Copies the elements of the List<T> to a new array."

In your documentation you mentioned that List.ToArray() copies the elements of the List to a new array. But its actual function upon testing returns the same reference of the elements(which is good by the way because I would want to via linq and end up getting a new copy of the array of objects I want to modify) and not a copy of the new array.

cannot find module.

I had to change to
"typings": "dist/linq.d.ts" instead of
"typings": "linq.ts"
in package.json in order to find the module with
import { List } from 'linqts'; in the typescript file.

Expression Func

Hello, first of all, great project, thank you for it.

I would like to ask, if is possible to do something like this in C#:

public static Expression<Func<Actuality, ActualityViewModel>> ToModel()
{
    return s => new ActualityViewModel
        {
            Id = s.Id,
            ...
        }
}

And later in select: ... Select(MyClass.ToModel()).First()... etc.

Is there way, how to select properties to model with using LinQ.ts?

Thanks for your answer!

Implement Join()

Implement the method according to the following specification:

class Person
{
    public string Name { get; set; }
}

class Pet
{
    public string Name { get; set; }
    public Person Owner { get; set; }
}

public static void JoinEx1()
{
    Person magnus = new Person { Name = "Hedlund, Magnus" };
    Person terry = new Person { Name = "Adams, Terry" };
    Person charlotte = new Person { Name = "Weiss, Charlotte" };

    Pet barley = new Pet { Name = "Barley", Owner = terry };
    Pet boots = new Pet { Name = "Boots", Owner = terry };
    Pet whiskers = new Pet { Name = "Whiskers", Owner = charlotte };
    Pet daisy = new Pet { Name = "Daisy", Owner = magnus };

    List<Person> people = new List<Person> { magnus, terry, charlotte };
    List<Pet> pets = new List<Pet> { barley, boots, whiskers, daisy };

    // Create a list of Person-Pet pairs where 
    // each element is an anonymous type that contains a
    // Pet's name and the name of the Person that owns the Pet.
    var query =
        people.Join(pets,
                    person => person,
                    pet => pet.Owner,
                    (person, pet) =>
                        new { OwnerName = person.Name, Pet = pet.Name });

    foreach (var obj in query)
    {
        Console.WriteLine(
            "{0} - {1}",
            obj.OwnerName,
            obj.Pet);
    }
}

/*
 This code produces the following output:

 Hedlund, Magnus - Daisy
 Adams, Terry - Barley
 Adams, Terry - Boots
 Weiss, Charlotte - Whiskers
*/

The unit test for this method shoud be implemented here.

Add browser build

Add webpack as a dev dependency and provide a browser distribution built-in, therefore erase all the browser no-longer-needed stuff on README πŸ˜…

After importing linqts error showed: linqts not found

Hi, I am using a linqts with angular 2 typescript (TypeScriptToolsVersion 1.8) project on vs 2015.
But when i do
import {List} from 'linqts'; and some code related to linq, it gives me an error on the browser
the server responded with a status of 404 (Not Found)
and this is my tsconfit.json

{
 "compileOnSave": true,
 "compilerOptions": {
 "target": "es5",
 "module": "system",
 "moduleResolution": "node",
 "sourceMap": true,
 "emitDecoratorMetadata": true,
 "experimentalDecorators": true,
 "removeComments": false,
 "noImplicitAny": false
 },
 "exclude": [
 "node_modules"
 ] 
}

I don't know what i miss .. so I need some help with that .. thank you :)

Bug: Distinct() does not work for complex types

The same test case of DistinctBy should pass without providing any key selector, I wanted to refactor the Distinct function some time ago using this trick:

return new List([...new Set(this._elements)])

Nevertheless, this does not work either, help would be much appreciated.

cc: @abbasmhd @IngoBleile

[Question] What Linq queries do you support so far?

I am just looking for a good linq.net implementation done in TS.

Would you please be that kind and put a list of linq.net supported queries you have done so far on your main page?

Looking at your source code quickly I like it groupby,intersect,except all there :-)

Replace Webpack with Rollup

Should be fairly easy and improve performance as well, in the end I just want the browser build, and Webpack is an overkill just for that.


cc: @alexjoverm πŸ˜‰

Implement SkipWhile()

Implement the method according to the following docs:

int[] grades = { 59, 82, 70, 56, 92, 98, 85 };

IEnumerable<int> lowerGrades =
    grades
    .OrderByDescending(grade => grade)
    .SkipWhile(grade => grade >= 80);

Console.WriteLine("All grades below 80:");
foreach (int grade in lowerGrades)
{
    Console.WriteLine(grade);
}

/*
 This code produces the following output:

 All grades below 80:
 70
 59
 56
*/

The unit test for this method is ready to be uncommented when this issue closes.

List from API

How can I get List<T> instead of Array<T> from API?

In development I have autocomplete as if it is a List<T> as it should but at run time it becomes an Array<T> and I fall on LINQ functions...

Help will be appreciated.

First should throw if no elements in list

Like the Single function that throws an error when there are not exactly 1 element in the list,, the First (and also Last) function should throw if the list is empty and the ElementAt function should also throw if the provided index exceeds the list length.

Errors in Angular2 (Angular cli) application after updating from 1.6.1 to version 1.7.0

Hi,
I am using linqts within an angular-cli project.
There is a problem with linqts, since I updated from 1.6.1 to 1.7.0.
I am not sure, if it is a webpack or angular-cli problem - or just my fault.
Maybe someone here can help.

system: windows 7
node: v7.3.0
npm: 4.0.2

My project uses angular-cli version 1.0.0-beta.24.
When updating linqts to version 1.7.0, the angular 2 app throws this error:

zone.js:682Uncaught Error: Cannot find module "."
    at webpackMissingModule (linq.js:8) [<root>]
    at List.List.elements (linq.js:8) [<root>]
    at Object.<anonymous> (linq.js:13) [<root>]
    at __webpack_require__ (bootstrap c8b9130…:52) [<root>]
    at Object.481 (main.ts:12) [<root>]
    at __webpack_require__ (bootstrap c8b9130…:52) [<root>]
    at Object.482 (app.component.ts:24) [<root>]
    at __webpack_require__ (bootstrap c8b9130…:52) [<root>]
    at Object.372 (src async:7) [<root>]
    at __webpack_require__ (bootstrap c8b9130…:52) [<root>]
    at Object.694 (main.bundle.js:223) [<root>]
    at __webpack_require__ (bootstrap c8b9130…:52) [<root>]
    at webpackJsonpCallback (bootstrap c8b9130…:23) [<root>]
    at :4200/main.bundle.js:1:1 [<root>]
ZoneAwareError @ zone.js:682
webpackMissingModule @ linq.js:8
List.List.elements @ linq.js:8
(anonymous) @ linq.js:13
__webpack_require__ @ bootstrap c8b9130…:52
481 @ main.ts:12
__webpack_require__ @ bootstrap c8b9130…:52
482 @ app.component.ts:24
__webpack_require__ @ bootstrap c8b9130…:52
372 @ src async:7
__webpack_require__ @ bootstrap c8b9130…:52
694 @ main.bundle.js:223
__webpack_require__ @ bootstrap c8b9130…:52
webpackJsonpCallback @ bootstrap c8b9130…:23
(anonymous) @ main.bundle.js:1

To reproduce the Problem create a dummy project with:

  npm install -g webpack
  npm install -g webpack-dev-server
  npm install -g angular-cli
  ng new linqtstest
  cd linqtstest
  npm install linqts@latest -D

Replace the file linqtstest\src\app\app.component.ts with some linqts :

  import { Component } from '@angular/core';
  import { List, Enumerable } from 'linqts';

  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  export class AppComponent {
    name: string;
    private linqs: string[];
    constructor() {
      this.name = 'LinqTs + Angular2'
      this.linqs = Enumerable
        .Range(1, 5)
        .Select(i => 'LinqTs ' + i)
        .ToArray();
    }

    foo(l: string): void {
      console.log(l);
      alert(l)
    }
  }

Replace the file linqtstest\src\app\app.component.html with the following

  <div>
    <h2>Hello {{name}}</h2>
      <button *ngFor="let l of linqs" (click)="foo(l)" md-fab>
          <span>{{l}}</span>
      </button>
  </div>

Run the dummy project with:

  ng serve

The app should now run on http://localhost:4200 and You should see the described error.
The same app with linqts version 1.6.1 runs without any errors.

d.ts is not uptodate with implementation

I see that at least IndexOf, Remove, RemoveAll and RemoveAt are missing.
Then there are some overloads with optional parameters are missing but I am not sure whether that is on purpose.
I could provide a pull request.

Error: InvalidOperationException: The source sequence is empty.

Error: Uncaught (in promise): Error: InvalidOperationException: The source sequence is empty.
Error: InvalidOperationException: The source sequence is empty.

When an array is empty
example:

let array: SelectItem[] = [];
const existingItem = new List<SelectItem>(array).
Where(x => x.value === compatMarca.value)
.First();

EDIT: i think the error is trhown after Where (because nothing is found) and First() of empty should returns "undefined", not Error.

An in-range update of typescript is breaking the build 🚨

Version 2.2.2 of typescript just got published.

Branch Build failing 🚨
Dependency typescript
Current Version 2.2.1
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As typescript is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Release Notes TypeScript 2.2.2

This release include a set of bug fixes reported against TypeScript 2.2.1. For the complete list of fixed issues, check out the fixed issues query for TypeScript 2.2.2.

Download:

Commits

The new version differs by 6 commits .

  • d89553f Update LKG
  • 7ea8d9f Fix Per Request Cancellation Tokens
  • 8f41444 send error if obtaining of types-registry package failed (#14573) (#14585)
  • 6e8c44f Ports #14566 to release-2.2 (#14571)
  • f6b1738 Update LKG
  • e440dbb Update version

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

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.