skgmn / fromjs Goto Github PK
View Code? Open in Web Editor NEWLINQ engine for JavaScript
LINQ engine for JavaScript
Hi,
I am using an array with numbers only.
When I group these numbers, the result function received it in a string.
It changes the type from number to string.
I created jsFiddle to show the problem
Sébastien
var arr2 = [
{name: "a", color: "yellow"},
{name: "b", color: "red"},
{name: "c", color: "blue"},
{name: "c", color: "blue"}
];
var val2 = from(arr2).indexOf("$color==@","red");
//result:val2=1
A nice feature, though It might affect performance (minimal), would be the ability to set function execution context (this). In other words in ***Iterable.prototype.each
functions using f.call(context,arg1,arg2,arg3,)
instead of f(arg1,arg2,arg3)
and similarly with non-eval'd proc
lambdas. I can submit a pull request if this is something you might consider!
var petOwners = [
{ name: "ab", pets: [ "a", "b" ] },
{ name: "cd", pets: [ "c", "d" ] },
{ name: "ef", pets: [ "e", "f" ] }
];
from(petOwners).selectMany("$pets").concat(["x","y"]).toArray();
result:["a", "b", "c", "d", "e", "f"]
not ["a", "b", "c", "d", "e", "f", "x", "y"]
The sequence has more than one element satisfying the condition. I am very sure that my list of strings, which I inspect with break points in webstorm does not contain multiple objects which satisfy the condition.
var type = 'subst';
var filePaths = ['./lib/hangman/wordlists/adv.nor.wordlist.txt',
'./lib/hangman/wordlists/subst.nor.wordlist.txt']
var path = from(filePaths).singleOrDefault(function(x){ return S(x).contains('/' + type + '.'); });
the error thrown is "The sequence has more than one element satisfying the condition";
var path = from(filePaths).singleOrDefault(function(x){ return x.indexOf(type) !== -1; });
this live gives the same result.
I'm not sure if this is the intended functionality but since lazy evaluation is already in place. The following snippet might be expected to have ['value'] as it's output
var array = [];
var x = from(array);
x.toArray();
//-->[]
array.push('value');
x.data
//-->['value']
x.toArray();
//-->[]
//ideal output of toArray() would reflect x.data
so i can include it as a module
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.