multiplex / multiplex.js Goto Github PK
View Code? Open in Web Editor NEWLINQ for JavaScript.
Home Page: http://multiplex.github.io
License: MIT License
LINQ for JavaScript.
Home Page: http://multiplex.github.io
License: MIT License
Typescript 2.4.
'.../multiplex.d.ts' is not a module
while using the import syntax:
import * as mx from "multiplexjs";
Not sure about the exact resolution, I guess the definition should be different depending on global browser, or ES6 module usage.
My workround is to use:
import "multiplexjs"; // makes the mx type definition usable
const mx: mx.MultiplexStatic = require("multiplexjs"); // makes the mx static function available
// TODO: Set with Object define property, and set 'enumerable: false'
String.prototype.asEnumerable = function () {
return mx(this);
};
Array.prototype.asEnumerable = function () {
return mx(this);
};
Typescript definition:
interface String {
asEnumerable(): mx.Enumerable<String>;
}
interface Array<T> {
asEnumerable(): mx.Enumerable<T>;
}
The definition can only extend the built-in types if the definition is global, not a module. But in the current situation, that is the case.
it causes infinite loop when i test join method with below code.
var data1 = [28, 26, 25, 24, 23, 21, 20, 19, 18, 16];
var data2 = [1, 2, 3, 4, 5, 6, 7, 8];
var data3 = mx(data1).join(data2, it => it, it => it, (a, b) => {
return {
Id: a
}
}).toArray();
console.log(data3);
value: resultSelector ? resultSelector(next.value.key, next.value) : next.value,
should be
value: resultSelector ? resultSelector(next.value.key, next.value.elements) : next.value,
According to the LINQ spec and multiplex.d.ts
Hi
I want to use multiplex as basis for data munging in js. Does multiplex cover this in total or should i be using an xpath library in conjunction with multiplex?
For the hashtable: The generic hashtable functionality (insert, retrieve) seems to work using string hashes, but iteration check's whether the bucket's hash is >=
zero, which is false for any string. As a fix you should probably use an equality check ===
rather than a numeric check, possibly defaulting the hash to null
rather than 0
.
Hash functions returning strings can be supplied by implementing your own EqualityComparer;
orderBy<TKey>(keySelector: (item: T) => TKey, comparer: EqualityComparer<TKey>): OrderedEnumerable<T>
should be:
orderBy<TKey>(keySelector: (item: T) => TKey, comparer: Comparer<TKey>): OrderedEnumerable<T>
and orderByDescending:
orderByDescending<TKey>(keySelector: (item: T) => TKey, comparer: Comparer<TKey>): OrderedEnumerable<T>
var data1 = [{
Id: 1,
Name: "one"
}, {
Id: 2,
Name: "two"
}];
var data2 = [{
Id: 1,
Phone: 123456
}, {
Id: 2,
Phone: 654321
}];
var data3 = mx(data1).join(data2, it => it.Id, it => it.Id, (a, b) => {
return {
Id: a.Id,
Name: a.Name,
Phone: b.Phone
}
}).toArray();
console.log(data3);
src/lib/linq/_linq.js
line 264:src/lib/linq/join.js
and my test is passed.i have an object array [{ Expression: "model" }, { Expression: "data" }]
and i use mx to count the predicated items.
here is my code:
var data = [{ Expression: "model" }, { Expression: "data" }];
var c = mx(data).where(function (it) { return it.Expression == "data" }).count();
console.log(c);
it expected that c is 1,but got zero. the following code doesn't works either.
var data = [{ Expression: "model" }, { Expression: "data" }];
var c = mx(data).where(function (it) { return mx.equals(it.Expression, "data") }).count();
console.log(c);
is there any mistakes in my code?
Importing mx from 'multiplexjs' does not get types, mx is always 'any' and using it throws excepion: Object(...) is not a function
TS2430: Interface 'List<T>' incorrectly extends interface 'Collection<T>'.
Types of property 'forEach' are incompatible.
Type '(action: (item: T) => void) => void' is not assignable to type '{ (action: (item: T) => void): void; (action: (item: T, index: number) => void): void; }'.
Types of parameters 'action' and 'action' are incompatible.
using Typescript 2.4.
The error can be resolved by removing the forEach
declaration from List<T>
, as it is inherited from
Enumerable<T>
through Collection<T>
.
I'd love to see some benchmarks and how this compares to other js libraries like lodash, underscore, lazy, jlinq, etc...
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.