koel/resources/assets/js/utils/helpers.ts

16 lines
395 B
TypeScript
Raw Normal View History

2022-04-20 09:37:22 +00:00
export const use = <T> (value: T, cb: (arg: T) => void) => {
2022-04-15 14:24:30 +00:00
if (typeof value === 'undefined' || value === null) {
return
}
cb(value)
}
2022-04-20 09:37:22 +00:00
export const arrayify = <T> (maybeArray: T | Array<T>) => ([] as Array<T>).concat(maybeArray)
// @ts-ignore
2022-05-14 15:13:29 +00:00
export const noop = () => {
}
export const limitBy = <T> (arr: T[], n: number, offset: number = 0): T[] => arr.slice(offset, offset + n)