-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
29 lines (24 loc) · 772 Bytes
/
Copy pathmain.js
File metadata and controls
29 lines (24 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { array2bool, array2item, array2children } from '.'
import './style.css'
document.querySelector('#app').innerHTML = `
<h1>Open Console</h1>
`
const arr = [{ id: 1, name: 'hjx' }, { id: 2, name: 'enjoy' }]
const arr2 = ['a', 'b']
const arr3 = [2, 5]
console.log(array2bool(arr2))
console.log(array2bool(arr3))
console.log(array2bool(arr, 'id'))
console.log(array2item(arr, 'id'))
console.log(array2item(arr, item => item.id, item => item.name))
console.log(array2item(arr3, item => `double-${item}`, item => item * 2))
const arr4 = [{
id: 1,
name: 'hjx',
codes: [{ id: 3, name: 'h' }, { id: 4, name: 'jx' }]
}, {
id: 2,
name: 'enjoy',
codes: [{ id: 5, name: 'en' }, { id: 6, name: 'joy' }]
}]
console.log(array2children(arr4, item => item.codes))