You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In v1, there was one basic object and it had the same interface.
In v2, those interfaces were divided into Object, Array and Map.
The problem with this is when dealing with for statements. The following is a general usage of the for statement for each object in v2.
; Object
obj := { key: "value", key2: "value2" }
for key in obj.ownProps() {
value = obj.%key%
}
; Mapfor key, value in Map("key", "value", "key2", "value2") {
}
; Arrayfor i, value in [ "value", "value2" ] {
}
Only the objects take a bit of work to enumerate. However, there are two things that will be retrieved in the end: the key (or index) and the value.
This library provides a way to handle the same interface regardless of the object type as follows.
for key, value in bee.Enumerable({ key: "value", key2: "value2" ) {
}
for key, value in bee.Enumerable(Map("key", "value", "key2", "value2")) {
}
for i, value in bee.Enumerable([ "value", "value2" ]) {
}
Enumerable will be evaluated lazily. In other words, when the method of an Enumerable is called, as follows, only what is to be done is defined, and only when the enumeration is started using a for statement, etc., are they executed.
; It is not executed in the following stages. In other words, it does not take long even for huge objects.
enumerable = bee.Enumerable({ key: "value", key2: "value2" })
.values(obj)
.select(value) => value == "value2")
; The process starts when you actually start the enumeration as follows. If it is a huge object, it will take some time.
enumerable.toArray()
for key, value in enumerable {
}
The text was updated successfully, but these errors were encountered:
Reference sources:
In v1, there was one basic object and it had the same interface.
In v2, those interfaces were divided into Object, Array and Map.
The problem with this is when dealing with
for
statements. The following is a general usage of thefor
statement for each object in v2.Only the objects take a bit of work to enumerate. However, there are two things that will be retrieved in the end: the key (or index) and the value.
This library provides a way to handle the same interface regardless of the object type as follows.
Enumerable will be evaluated lazily. In other words, when the method of an Enumerable is called, as follows, only what is to be done is defined, and only when the enumeration is started using a for statement, etc., are they executed.
The text was updated successfully, but these errors were encountered: