-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript standard library contents #16
Comments
enhanced promises
@littledan is this issue a dump for proposals? If that's the case I don't think we will ever be able to close it. |
Changing something that’s already in the language would need its own proposal; i think the standard library would be for adding new things. |
@ljharb If the change is too radical or breaking, it has to be externalized: an alternative with another name to avoid confusion; future comes to mind in my case. |
I meant this as a brainstorming thread. What we talk about here might graduate into proposals. As @ljharb says, let's try to focus on additions of new features, rather than changes to existing things (it's not clear how to expose what you're talking about as a built-in module). If this thread gets too unwieldy, we can close it. |
WHATWG |
Would be nice to have promise cancelation |
uuid? |
Anything that validates ECMAScript internal stuff. |
@Mouvedia Would uuid make sense as part of WebCrypto? w3c/webcrypto#215 |
@mathiasbynens 's Unicode RegExp properties should help with making that checker more efficient! |
That validator is just an example. My point is that the language should expose its own validators/assertors. That would permit to have a basis for other interfaces (like the DOM). |
I don't know. Last time I checked the polyfill was enormous—it was almost impractical. |
@Mouvedia Well, the idea would be that you just use uuid if you don't have the built-in one. (uuid actually uses WebCrypto in browsers today.) |
The idea of futures is something that should be pursued; in the same way that |
It would be great to be able to access object properties without having to do something along the lines of
Something like the lodash |
My two longstanding bugbears with the JS standard library (going back to my pre-jQuery days) are:
For a language that spends a lot of its time running in a browser these seem like obvious candidates for a standard library. |
@decadecity I'm wondering if the solutions at the web level, currently shipping in browsers, are enough for your use case.
|
@JonForest Have you see the optional chaining proposal? It's attempting to add that operator. |
|
@decadecity Work is ongoing to evolve the cookie API itself at https://github.com/WICG/cookie-store . TC39 is probably the wrong place to advance work in this area, as we focus on things that don't involve I/O. Cookies don't mean much outside of the Web. |
In terms of what we can see people using, lodash is the most depended upon library that would be potentially appropriate to exist in core: It's a bit harder to break down which functions are used the most, but you can get an idea here: There is also a minimal version of the library: |
No, the JS standard library should not be minimal. Part of the reason there's so many variations on the underscore theme is that there's a lot of really basic stuff missing from the language (like deep copy.) Unfortunately it's not clear where feature requests belong. While I was writing out a flood, I was told "not here. Maybe on issue 16." There's dozens of easy one-liners that would massively improve the language if gatekeepers would permit them |
I'll copy pasta a bunch right now if someone tells me where to put them |
@StoneCypher I'm glad you came here to do additional brainstorming for contents. For JavaScript one-liners, maybe could you make your own repository or gist for development and link to it from here? |
Somehow I feel like the input from @kgryte could be useful to this discussion ;) |
Would be really nice if there was an official place to give people recommendations for a more complete standard libary |
Indeed, |
Here's a summary of the most popular proposals based on the 👍:
|
Good summary, those all seem like good ideas (though I'm skeptical of the last one). |
If partial application ever reaches stage 4, you will have to bow down to our new functional overlords. |
Certainly a Result would work very well in Promise.allSettled, and in the proposed Set/Map find methods, and a number of other places. |
I kinda wish Promises never happened in JS core. They're eager evaluated and miss valuable use cases (ex async vs waterfall vs parallel) that some of the more popular Promise libs (ex bluebird, async.js) provide out of the box. I like the idea of Futures as a 'do over' to provide a more useful alternative to promises.
|
Hello, for anyone who wants a |
If you are adding a static method for numbers then Id expect the analogue on /* String.range(range: String, charset = 'UTF-8': String): String */
String.range('∏-»', 'machintosh'); // ∏π∫ªºΩæø¿¡¬√ƒ≈∆«»
String.range('Ø-é', 'ISO-8859-1'); // ØÙÚÛÜÝÞßàáâãäåæçèé |
The range for String is not in the goals of Number.range, you can build your own proposal, I'll focus on numbers and BigInts only 😉 |
I was using the generic you i.e. I wasn't talking to you :) |
@Mouvedia |
@obedm503 you will have to come up with the use cases yourself. ruby: https://ruby-doc.org/core-2.2.0/Range.html |
a builtin sqlite3 (like python) would be far more practical and useful in web-applications than a low-level tree-library. |
i don't know how it would be implemented, but some sort of full-text-search primitives would greatly benefit the industry. |
@kaizhu256 a builtin sqlite3 (like python) would be far more practical and useful in web-applications than a low-level tree-library. Local storage can be used for quickly/easily persisting smaller amounts of data. Also, keep in mind that this would be for JS as a whole; so probably needs to be useful in bith the browser and node. |
i may be wrong but i think what industry really wants is a "standardized" sqlite3 in browser with full-text-search capabilities (ala websql, which never seems to have truly died [1]). indexeddb is just terrible in terms of practical usability/performance (joins need to be done in userland-javascript? really?). adding a low-level tree-library so users can reinvent even crappier versions of indexeddb is pointless. i also don't mind a sqlite3-library to be memory-only, so it can be encapsulated for security reasons. one can always [infrequently] persist it to indexeddb as a blob. speaking of indexedb, its sorely in need of an appendFile feature. without it, popular browser-db's like nedb are impractical for persisting largish datasets (> 20mb) [2]. [1] current websql browser-support [2] nedb emulates appendFile by re-saving its entire database as a blob to indexedb whenever a row insert/delete/update is performed. |
I'd recommend making feature requests for IndexedDB in their GitHub repository; you're not likely to reach the right folks here. |
related: https://github.com/samchon/tstl |
leftpad? |
It exists. |
SQL is everywhere, and I think some sort of supported SQL library built in on top of indexedDB without downloading a megabyte of asm.js generated code would be amazing. We also need generic versions of the whole array and string -prototype functions. For extra functionality, see python for inspiration. For example: https://docs.python.org/3/library/textwrap.html A universal print function! That must be in. Math and date functions. Especially date functions for dealing with time-zones and all. Some way to work with complex numbers in the math library? Just look here: https://docs.python.org/3/library/ |
@lazarljubenovic I stand corrected! Thanks :) |
there already exists asm.js-compiled sqlite3 at http://kripken.github.io/sql.js/GUI/. |
|
The stdlib should be similar in functionality to that of other languages. As such, I would suggest taking something like lodash or underscore and pairing it down to its most useful functions. For example, JS has never had a simple way to deep-extend an object - but the two aforementioned libraries do. They are essentially the same thing and probably the most ubiquitous libs for basic operations. Suggestion: Start from Lodash or Underscore and pair back, then extend with any missing functionality but only those that affect the built-in objects. |
@bfattori-TDA IMO, lodash/underscore are a step in the right direction in terms of providing functional transforms for data. Unfortunately, if the pipeline-operator proposal passes, we'll likely see their functionality re-incarnated in a new library that fully leverages native pipes. Adding them in their current form would be premature. |
The JavaScript standard library is very minimal. Is this how it should be? What should we add?
Note, the purpose of this repository is to develop the infrastructure for built-in modules, not the contents. However, I know many of you have ideas for the contents as well, so let's brainstorm those in this issue exclusively.
The text was updated successfully, but these errors were encountered: