File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,10 +28,9 @@ const revalueAttr = (attr, val) => {
2828export 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}
Original file line number Diff line number Diff line change 1- import { assignAttrs , prepareExcludedAttrs } from './attrs.js'
1+ import { mixinAttrs , prepareExcludedAttrs } from './attrs.js'
22import { traverse } from './traverse.js'
33
44export 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
Original file line number Diff line number Diff line change 1- import { assignAttrs , prepareExcludedAttrs } from './attrs.js'
1+ import { mixinAttrs , prepareExcludedAttrs } from './attrs.js'
22import { traverse } from './traverse.js'
33
44export 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
You can’t perform that action at this time.
0 commit comments