lodash APIs
- get
- isEmpty
- cloneDeep
- debounce
- omit
- isEqual
- find
- merge
- map
- filter
- throttle
- sortBy
- set
- isString
- isArray
- pick
- orderBy
- groupBy
- includes
- isObject
- noop
- findIndex
- isFunction
- isNil
- uniqueId
- pickBy
- uniq
- kebabCase
- without
- camelCase
- isNumber
- uniqBy
- isUndefined
- capitalize
- clone
- range
- omitBy
- remove
- forIn
- forEach
- reduce
- flatten
- zipObject
- mapValues
- concat
- trim
- castArray
- difference
- memoize
- keyBy
- assign
- each
- upperFirst
- chain
- sample
- isPlainObject
- has
- mapKeys
- isNull
- last
- isBoolean
- identity
- padStart
- head
- size
- conformsTo
- mergeWith
- transform
- uniqWith
- union
- toString
- reject
- snakeCase
- max
- min
- reverse
- slice
- isInteger
- startsWith
- first
- sumBy
- maxBy
- minBy
- _
- xor
- replace
- take
- endsWith
- toLower
- clamp
- toPairs
- some
- extend
- times
- flattenDeep
- escapeRegExp
- shuffle
- round
- toInteger
- isNaN
- unset
- VERSION
- nth
- flow
- sum
- isFinite
- values
- lowerCase
- deburr
- isEqualWith
- cloneDeepWith
- hasIn
- findLast
- findKey
- differenceBy
- pull
- findLastIndex
- partition
- at
- defer
- intersectionBy
- invert
- delay
- forOwn
- pullAt
- once
- sampleSize
- random
- defaults
- unescape
- keys
- toNumber
- wrap
- inRange
- join
- template
- split
- words
- toSafeInteger
- pullAllBy
- unionWith
- xorBy
- differenceWith
- indexOf
- multiply
- divide
- every
- toPath
- defaultTo
- isObjectLike
- intersection
- startCase
- sortedIndexBy
OtherRelated APIs
lodash#partition JavaScript Examples
The following examples show how to use
lodash#partition.
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: workflows.js From holo-schedule with MIT License | 6 votes |
syncOpenLives = async () => {
const [currentLives, scheduledLives] = partition(filterLives(await getOpenLives({
membersMask: getMembersMask(getSubscriptionByMember()),
startBefore: getUnixAfterDays(7),
})), ({ start_at: startAt }) => dayjs().isAfter(startAt))
await browser.action.setBadgeText({ text: currentLives.length.toString() })
console.log(`[background/workflow]Badge text has been set to ${currentLives.length}`)
// Subscription is simplified cause here is the only mutation of currentLives
const endedLives = getCachedEndedLives() ?? []
// Skip if endedLives is empty
if (endedLives.length > 0) {
differenceBy((getCachedCurrentLives() ?? []), currentLives, 'id').map(live => ({
...live, duration: dayjs().diff(dayjs(live['start_at']), 'second'),
})).forEach(live => {
const index = findLastIndex(
endedLives,
({ start_at: startAt }) => startAt <= live['start_at'],
)
endedLives.splice(index + 1, 0, live)
})
}
await Promise.resolve({
[CURRENT_LIVES]: currentLives,
[SCHEDULED_LIVES]: scheduledLives,
[ENDED_LIVES]: limitRight(filterLives(uniqRightBy(endedLives, 'id')), MAX_LIVES_LENGTH),
}).then(data => store.set(data))
.catch(data => store.set(data, { local: false }))
return [...currentLives, ...scheduledLives]
}