deno.land / x / rambda@v9.1.1 / source / splitAt.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { isArray } from './_internals/isArray.js'import { drop } from './drop.js'import { maybe } from './maybe.js'import { take } from './take.js'
export function splitAt(index, input){ if (arguments.length === 1){ return _list => splitAt(index, _list) } if (!input) throw new TypeError(`Cannot read property 'slice' of ${ input }`)
if (!isArray(input) && typeof input !== 'string') return [ [], [] ]
const correctIndex = maybe( index < 0, input.length + index < 0 ? 0 : input.length + index, index )
return [ take(correctIndex, input), drop(correctIndex, input) ]}
rambda

Version Info

Tagged at
2 months ago