forked from jashkenas/underscore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tighten specification for _.sortedIndex
sortedIndex should specify that it returns the lowest index at which an item may be inserted to maintain sorted order, rather than any index which satisfies this property, in order to provide easier use maintaining a sorted list of unique elements. For example, with the previous specification, the following behavior is possible: _.sortedIndex([10, 20, 30, 40], 30) => 3 To accommodate this behavior users would have to check both array[si] and array[si-1] (when si > 0) before inserting to ensure uniqueness, or to examine the underscore.js implementation and rely on the implementation not changing. Note: This specification change does not require any changes to the code. Signed-off-by: Kevin Locke <[email protected]>
- Loading branch information
Showing
2 changed files
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters