There was another request say on the node source with an issue saying that we will need the file API. And yes, today we have file API. In this example, we do a new file, dummy.txt.exe and asserting a few things from what it returns on the file attribute, the file name should be there, which is there and file size is zero and file last modified is a number and file last modified is less than date.now of course, because it is created before the date.now. So it gives you like all the features that the file API provides and it's easy to operate with files.
On v18, here's an example where we have array of objects with values x with repeating values of one, two, one, two, and suppose you want to find the last, which is a TC39 proposal that's got implemented here, array.findLast, where we're seeing o.x equals one, which is equal to array of the second, the third index array of two, right? So you, which is equal to true, or you could also find the index. The last index is zero to the last index is two in this case, because the zero it also has x whose value is one. The second also has the value, which is one. So find the last index finds the last in the array, which is two. The index is two, and array.two is x, whose value is one. So you can do last and last index on array.
We have Intel local, where you can pass in the local. Here we are passing Arabic, Arabic Egyptian local, which returns your calendars, collisions, R cycles, numbering systems, and time zones. And also it has this easy util method, which says supported value off for, for which you can pass calendar, collision, currency, numbering system, time zone and unit, and that would return all the supported values, say, Buddhist, Chinese, calendar here or African and white and Celsius and centimeters and all the units. So it makes it super easy to handle different internalization and efforts in, may it be currency or calendar or numbering system and times on our legs. So you have a number one, two, three, four, five dot seven, eight, nine, you could do an internationalization number format and pass in the locale that you want and the style is currency and the currencies you are in this case, it formats based on that locale and also puts in the pound sign. It says one, two, three dot four, five, six, seven, nine pounds. And, and same thing for a Japanese and, and you could also limit it to three significant digits. Here is an example for E and I, in we format with maximum significant digits to be three, it says one comma two three, zero, zero, zero. Right. So it makes it super easy to like handle numbers in terms of like handling currencies, which is a pretty common use case. We also have experimental shadow realm. In this case we do a new shadow realm and create the shadow realm and within the shadow realm we have evaluate where we are saying global this dot realm value equals inner. And then we have a getter, which returns the global this daughter. Look at the street equal here. When we do a getter, we get an inner. But if we check the real value in global this, it just falls. So you can think of Sharon as that box, which in which is not exposed to the global this, but can also has it its own global, this which where you can operate and add values and not leak into the the global scope of not right. So then that value is not in global this but getter does the returns in it, which has its own globalness. So federal makes it interesting. And encapsulation and of course, it brings in all the other aspects of sharing in the standard.
Comments