Skip to content

Commit 02e45b9

Browse files
committed
Swap out ramda for self written substitutes
1 parent 84a18c8 commit 02e45b9

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"draw ascii"
6161
],
6262
"dependencies": {
63-
"core-js": "^2.4.1",
64-
"ramda": "^0.22.1"
63+
"core-js": "^2.4.1"
6564
}
6665
}

src/ascii-data-table.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import R from 'ramda'
1+
import * as R from './functions'
22
import repeat from 'core-js/library/fn/string/repeat'
33

44
const len = (val) => typeof val === 'undefined' ? 0 : ('' + val).length
@@ -71,7 +71,7 @@ const renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {
7171
const widths = colWidths(maxColWidth, minColWidth, rows)
7272
const heights = rowHeights(maxColWidth, rows)
7373
const norm = splitRowsToLines(maxColWidth, heights, widths, rows)
74-
const header = createLines([R.head(norm)])
74+
const header = createLines(R.head(norm))
7575
const separated = R.intersperse(getThinSeparatorLine(widths), R.tail(norm))
7676
const lines = createLines(separated)
7777
return [

src/functions.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
export const pluck = (p, arr) => arr.map((o) => o[p])
2+
export const apply = (fn, arr) => fn.apply(null, arr)
3+
export const splitEvery = (w, a) => {
4+
if (!a) return a
5+
const tot = a.length
6+
let out = []
7+
let pos = 0
8+
while (pos < tot) {
9+
let got = a.slice(pos, pos + w)
10+
out = out.concat(got)
11+
pos += got.length
12+
}
13+
return out
14+
}
15+
export const last = (arr) => arr.slice(-1)
16+
export const head = (arr) => arr.slice(0, 1)
17+
export const tail = (arr) => arr.slice(1)
18+
export const concat = (one, two) => {
19+
if (Array.isArray(one)) return [].concat(one, two)
20+
return '' + one + two
21+
}
22+
export const transpose = (arr) => {
23+
return arr[0].map((_, i) => {
24+
return arr.map((v) => v[i])
25+
})
26+
}
27+
export const intersperse = (c, a) => {
28+
return a.reduce((all, v, i) => {
29+
if (i === a.length - 1) {
30+
all.push(v)
31+
return all
32+
}
33+
all.push(v, c)
34+
return all
35+
}, [])
36+
}

0 commit comments

Comments
 (0)