lodash APIs
- cloneDeep
- get
- isEqual
- isEmpty
- debounce
- merge
- uniq
- omit
- isString
- isArray
- pick
- sortBy
- groupBy
- flatten
- set
- find
- orderBy
- mapValues
- isObject
- last
- isNil
- isNumber
- range
- chunk
- throttle
- filter
- uniqBy
- difference
- pickBy
- noop
- capitalize
- uniqueId
- has
- isUndefined
- map
- camelCase
- isFunction
- kebabCase
- intersection
- random
- includes
- isPlainObject
- compact
- Dictionary
- findIndex
- keyBy
- forEach
- trim
- clamp
- identity
- remove
- keys
- isNull
- times
- startCase
- first
- values
- mapKeys
- sumBy
- max
- reduce
- some
- zip
- every
- memoize
- clone
- countBy
- concat
- snakeCase
- assign
- isBoolean
- uniqWith
- omitBy
- without
- minBy
- head
- maxBy
- min
- upperFirst
- escapeRegExp
- reverse
- sample
- shuffle
- defaults
- inRange
- flattenDeep
- take
- union
- sum
- mergeWith
- castArray
- replace
- flatMap
- reject
- zipObject
- template
- isNaN
- mean
- size
- findLast
- unset
- partition
- round
- fromPairs
- floor
- toPairs
- indexOf
- toString
- sampleSize
- differenceBy
- update
- chain
- startsWith
- xor
- pull
- DebouncedFunc
- defaultsDeep
- split
- findKey
- unescape
- partial
- toNumber
- invert
- each
- differenceWith
- endsWith
- slice
- isDate
- unionBy
- findLastIndex
- join
- isInteger
- delay
- isObjectLike
- padStart
- result
- isError
- extend
- cloneDeepWith
- upperCase
- trimStart
- constant
- matches
- lowerCase
- forIn
- lowerFirst
- once
- transform
- isMatch
- escape
- isEqualWith
- zipWith
- isRegExp
- entries
- sortedIndexBy
- dropWhile
- takeWhile
- isElement
- forEachRight
- ReplaceFunction
- TemplateExecutor
- keysIn
- IsEqualCustomizer
- isTypedArray
- cond
- stubTrue
- toUpper
- isMap
- isSet
- meanBy
- rangeRight
- repeat
- trimEnd
- now
- nth
- pullAt
- toPath
- eq
- lt
- lte
- gt
- gte
- pullAllBy
- pullAll
- toLower
- fill
- ceil
- flatMapDeep
- CloneDeepWithCustomizer
- negate
- takeRightWhile
- invoke
- tap
- intersectionWith
- truncate
- Collection
- bind
- curry
- partialRight
- sortedUniq
- sortedIndexOf
- Object
- drop
- _
Other Related APIs
lodash#sortedIndexBy TypeScript Examples
The following examples show how to use
lodash#sortedIndexBy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Optimize.tsx From sc2-planner with MIT License | 4 votes |
onAddConstraint(index: number, action: ConstraintType): void {
let didChangeConstraints = false
index = index === -1 ? this.props.gamelogic.bo.length - 1 : index
const name = this.props.gamelogic.bo[index].name
const pos = filter(this.props.gamelogic.bo.slice(0, index), { name }).length
const eventLog = filter(this.props.gamelogic.eventLog, { name })[pos]
const itemEndFrame = eventLog?.end || eventLog?.start
const endTime = Math.floor(itemEndFrame / 22.4)
if (endTime === undefined) {
return
}
const list: Constraint[] = getConstraintList(this.props.optimizeSettings)
if (action === "remove") {
didChangeConstraints = remove(list, { name, pos }).length > 0
} else {
const toRemoveList: Constraint[] = []
let foundName = false
for (const constraint of list) {
if (
constraint.type === "time" &&
constraint.name === name &&
constraint.pos === pos
) {
if (action === "after" || action === "at") {
foundName = true
if (constraint.after !== endTime) {
didChangeConstraints = true
constraint.after = endTime
}
}
if (action === "after" && constraint.before <= endTime) {
foundName = true
didChangeConstraints = true
constraint.before = Infinity
}
if (action === "before" || action === "at") {
foundName = true
if (constraint.before !== endTime) {
didChangeConstraints = true
constraint.before = endTime
}
}
if (action === "before" && constraint.after >= endTime) {
foundName = true
didChangeConstraints = true
constraint.after = -Infinity
}
}
}
for (const toRemove of toRemoveList) {
remove(list, toRemove)
}
if (!foundName) {
didChangeConstraints = true
const newConstraint: TimeConstraint = {
type: "time",
name,
pos,
after: action === "after" || action === "at" ? endTime : -Infinity,
before: action === "before" || action === "at" ? endTime : Infinity,
}
const whereToInsert = sortedIndexBy(
list,
newConstraint,
(constraint) => `${constraint.name}#${constraint.pos}`
)
list.splice(whereToInsert, 0, newConstraint)
}
}
if (didChangeConstraints) {
const constraints: string = setConstraintList(list)
this.props.log({
autoClose: true,
notice: `New optimize constraints: ${constraints ? constraints : "none!"}`,
temporary: true,
})
this.props.updateOptimize("c", constraints, false)
this.setState({
constraintsChangeCount: this.state.constraintsChangeCount + 1,
})
}
}