openxmldev / linq-to-xml Goto Github PK
View Code? Open in Web Editor NEWLINQ to XML for TypeScript
License: MIT License
LINQ to XML for TypeScript
License: MIT License
This looks like an interesting project.
Just a note, tsdotnet already has classes that seem to fit some of your use cases:
https://github.com/tsdotnet/string-builder
https://github.com/tsdotnet/linq/blob/master/src/linqExtended.ts
You might try inheriting from LinqExtended<T>
instead of writing your own.
I love how your API is turning out.
I am still a bit concerned about making assumptions in your LinqIterableBase about what the defaults should be. In respect to selecting 'nodes', null
is obviously a valid default, but you (or I) might be better served providing an .xOrNull()
method to be more explicit.
// TypeScript
textNodes.select(parseFloat).firstOrDefault() // if textNodes is empty, the value returned here is null.
// C#
textNodes.Select(double.Parse).FirstOrDefault() // if textNodes is empty, the value returned here is 0.
As I pointed out before, when calling an .xOrDefault()
, if for some reason T
is of type number
you won't get 0
as the default as you would in C#. And if you were attempting to filter by type: typeof null == 'object'
where typeof undefined == 'undefined'
. So the behavior differs even though you are conforming to the .NET API.
Where I see having null
as an acceptable default is whenever the expected type should be an object like a node. It's just difficult to forsee how things might get weird if some amount of transformation is done by the consumer.
I'd also point to the weirdness in JS around 0
and null
. Really strange things can happen that simply won't happen in C#.
https://www.tutorialspoint.com/what-is-the-relation-between-null-and-0-in-javascript
https://blog.campvanilla.com/javascript-the-curious-case-of-null-0-7b131644e274?gi=bc5bbbc977f4
null > 0 || null == 0; // == false
undefined > 0 || undefined == 0; // == false
undefined >= 0 // == false
null >= 0; // == true WHAT!?
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.