[feature request] a way to break forEach - or add some ? #2

Open
opened 2017-01-20 14:50:49 +01:00 by kapouer · 1 comment
kapouer commented 2017-01-20 14:50:49 +01:00 (Migrated from github.com)

It can be frustrating to loop over each key, value when searching for one value in particular.

It can be frustrating to loop over each key, value when searching for one value in particular.
Tezraine commented 2023-07-22 13:14:49 +02:00 (Migrated from github.com)

Default implementation for this

  // :: (any, string, index) → boolean
  // Takes a predicate function that takes 3 arguments
  // Value, key, index
  // Returns true if any item matches the predicate, false otherwise
  some: function(predicate) {
    for (var i = 1; i < this.content.length; i += 2)
      if (predicate(this.content[i], this.content[i-1], i/2)) return true
    return false
  },
Default implementation for this ``` // :: (any, string, index) → boolean // Takes a predicate function that takes 3 arguments // Value, key, index // Returns true if any item matches the predicate, false otherwise some: function(predicate) { for (var i = 1; i < this.content.length; i += 2) if (predicate(this.content[i], this.content[i-1], i/2)) return true return false }, ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
marijn/orderedmap#2
No description provided.