1
- const testValue = require ( 'test-value' )
2
- const where = testValue . where
3
1
const arrayify = require ( 'array-back' )
4
2
const omit = require ( 'lodash.omit' )
5
3
const findReplace = require ( 'find-replace' )
@@ -55,14 +53,20 @@ function transform (data) {
55
53
return doclet
56
54
} )
57
55
58
- const exported = json . filter ( where ( { isExported : true } ) )
56
+ const exported = json . filter ( i => i . isExported === true )
59
57
const newIDs = exported . map ( d => d . id )
60
58
61
- newIDs . forEach ( function ( newID ) {
62
- update ( json , { isExported : undefined , '!kind' : 'module' } , function ( doclet ) {
63
- return updateIDReferences ( doclet , newID )
64
- } )
65
- } )
59
+ for ( const newID of newIDs ) {
60
+ for ( let i = 0 ; i < json . length ; i ++ ) {
61
+ const doclet = json [ i ]
62
+ if ( doclet . isExported === undefined && doclet . kind !== 'module' ) {
63
+ const values = updateIDReferences ( doclet , newID )
64
+ for ( const prop in values ) {
65
+ if ( values [ prop ] !== undefined ) doclet [ prop ] = values [ prop ]
66
+ }
67
+ }
68
+ }
69
+ }
66
70
67
71
json = removeEnumChildren ( json )
68
72
json = json . map ( removeUnwanted )
@@ -175,17 +179,11 @@ hence the need for these four functions */
175
179
function getEs6Constructor ( data , parent ) {
176
180
return data . find ( i => isES6Constructor ( i ) && i . memberof === parent . longname )
177
181
}
178
- function isES6Class ( doclet ) {
179
- return testValue ( doclet , {
180
- kind : 'class' ,
181
- meta : { code : { type : 'ClassDeclaration' } }
182
- } )
182
+ function isES6Class ( doclet = { } ) {
183
+ return doclet . kind === 'class' && doclet . meta && doclet . meta . code && doclet . meta . code . type === 'ClassDeclaration'
183
184
}
184
185
function isES6Constructor ( doclet ) {
185
- return testValue ( doclet , {
186
- kind : 'class' ,
187
- meta : { code : { type : 'MethodDefinition' } }
188
- } )
186
+ return doclet . kind === 'class' && doclet . meta && doclet . meta . code && doclet . meta . code . type === 'MethodDefinition'
189
187
}
190
188
191
189
function replaceID ( id , oldID , newID ) {
@@ -356,17 +354,6 @@ function sortIdentifier (doclet) {
356
354
} )
357
355
}
358
356
359
- function update ( array , query , newValues ) {
360
- for ( let i = 0 ; i < array . length ; i ++ ) {
361
- if ( testValue ( array [ i ] , query ) ) {
362
- const values = typeof newValues === 'function' ? newValues ( array [ i ] ) : newValues
363
- for ( const prop in values ) {
364
- if ( values [ prop ] !== undefined ) array [ i ] [ prop ] = values [ prop ]
365
- }
366
- }
367
- }
368
- }
369
-
370
357
function renameThisProperty ( doclet ) {
371
358
doclet . thisvalue = doclet . this
372
359
delete doclet . this
@@ -386,7 +373,7 @@ function fixES6ConstructorMemberLongnames (data) {
386
373
if ( isES6Class ( i ) ) {
387
374
const es6constructor = getEs6Constructor ( data , i )
388
375
if ( es6constructor ) {
389
- const constructorChildren = data . filter ( where ( { memberof : es6constructor . longname } ) )
376
+ const constructorChildren = data . filter ( c => c . memberof === es6constructor . longname )
390
377
constructorChildren . forEach ( child => {
391
378
child . memberof = i . longname
392
379
} )
@@ -407,7 +394,7 @@ function convertIsEnumFlagToKind (doclet) {
407
394
/* remove properties which have enum parents.. depends on convertIsEnumFlagToKind */
408
395
function removeEnumChildren ( json ) {
409
396
return json . filter ( function ( doclet ) {
410
- const parent = json . find ( where ( { id : doclet . memberof } ) )
397
+ const parent = json . find ( i => i . id === doclet . memberof )
411
398
if ( parent && parent . kind === 'enum' ) {
412
399
return false
413
400
} else {
0 commit comments