Skip to content

Commit 42adec8

Browse files
committed
Rename assigning functions
1 parent 4b1cd58 commit 42adec8

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

lib/parse/attrs.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ const revalueAttr = (attr, val) => {
2828
export const prepareExcludedAttrs = attrs =>
2929
attrs && new Set(attrs.map(attr => attr.toLowerCase()))
3030

31-
export const assignAttrs = (item, attrs, excluded) => {
31+
export const mixinAttrs = (item, attrs, excluded) => {
3232
for (const attr in attrs) {
3333
if (excluded?.has(attr)) continue
3434
item[attr] = revalueAttr(attr, attrs[attr])
3535
}
36-
return item
3736
}

lib/parse/flat-parse.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { assignAttrs, prepareExcludedAttrs } from './attrs.js'
1+
import { mixinAttrs, prepareExcludedAttrs } from './attrs.js'
22
import { traverse } from './traverse.js'
33

44
export const flatParse = (text, opts = {}) => {
55
const bookmarks = []
66
const folders = []
77

88
let currFolder = []
9-
let entityId = 0
9+
let itemId = 0
1010

1111
const excludedAttrs = prepareExcludedAttrs(opts.excludeAttrs)
1212

1313
const setupItem = (item, attrs) => {
14-
assignAttrs(item, attrs, excludedAttrs)
15-
opts.withId && (item.id = entityId++)
14+
mixinAttrs(item, attrs, excludedAttrs)
15+
opts.withId && (item.id = itemId++)
1616
return item
1717
}
1818

lib/parse/parse.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { assignAttrs, prepareExcludedAttrs } from './attrs.js'
1+
import { mixinAttrs, prepareExcludedAttrs } from './attrs.js'
22
import { traverse } from './traverse.js'
33

44
export const parse = (text, opts = {}) => {
5-
let rootFolder
6-
let currFolder
5+
let currFolder, rootFolder
76

87
const folders = []
98

109
const excludedAttrs = prepareExcludedAttrs(opts.excludeAttrs)
1110

12-
const assignId = item => {
11+
const mixinId = item => {
1312
if (currFolder) {
1413
const { id, items } = currFolder
1514
item.pid = id
@@ -20,8 +19,8 @@ export const parse = (text, opts = {}) => {
2019
}
2120

2221
const setupItem = (item, attrs) => {
23-
assignAttrs(item, attrs, excludedAttrs)
24-
opts.withId && assignId(item)
22+
mixinAttrs(item, attrs, excludedAttrs)
23+
opts.withId && mixinId(item)
2524
return item
2625
}
2726

0 commit comments

Comments
 (0)