Commit 433c754 1 parent 36fb1a2 commit 433c754 Copy full SHA for 433c754
File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ const gcd = require('./src/gcd')
57
57
const getNth = require ( './src/get-nth' )
58
58
const gt = require ( './src/gt' )
59
59
const gte = require ( './src/gte' )
60
+ const halve = require ( './src/halve.js' )
60
61
const hasProp = require ( './src/has-prop' )
61
62
const head = require ( './src/head' )
62
63
const id = require ( './src/id' )
@@ -250,6 +251,7 @@ module.exports = {
250
251
getNth,
251
252
gt,
252
253
gte,
254
+ halve,
253
255
hasProp,
254
256
head,
255
257
id,
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+ const and = require ( './and' )
3
+ const curry = require ( './curry' )
4
+ const div = require ( './div' )
5
+ const len = require ( './len' )
6
+ const notArr = require ( './not-arr' )
7
+ const notStr = require ( './not-str' )
8
+ const partitionAt = require ( './partition-at' )
9
+ const trunc = require ( './trunc' )
10
+
11
+ function halve ( xs ) {
12
+ if ( and ( notArr ( xs ) , notStr ( xs ) ) )
13
+ throw new TypeError ( '[halve] Argument must be an array or a string' )
14
+
15
+ return partitionAt ( trunc ( div ( len ( xs ) , 2 ) ) , xs )
16
+ }
17
+
18
+ module . exports = curry ( halve )
You can’t perform that action at this time.
0 commit comments