1- const testValue = require ( 'test-value' )
2- const where = testValue . where
31const arrayify = require ( 'array-back' )
42const omit = require ( 'lodash.omit' )
53const findReplace = require ( 'find-replace' )
@@ -55,14 +53,20 @@ function transform (data) {
5553 return doclet
5654 } )
5755
58- const exported = json . filter ( where ( { isExported : true } ) )
56+ const exported = json . filter ( i => i . isExported === true )
5957 const newIDs = exported . map ( d => d . id )
6058
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+ }
6670
6771 json = removeEnumChildren ( json )
6872 json = json . map ( removeUnwanted )
@@ -175,17 +179,11 @@ hence the need for these four functions */
175179function getEs6Constructor ( data , parent ) {
176180 return data . find ( i => isES6Constructor ( i ) && i . memberof === parent . longname )
177181}
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'
183184}
184185function 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'
189187}
190188
191189function replaceID ( id , oldID , newID ) {
@@ -356,17 +354,6 @@ function sortIdentifier (doclet) {
356354 } )
357355}
358356
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-
370357function renameThisProperty ( doclet ) {
371358 doclet . thisvalue = doclet . this
372359 delete doclet . this
@@ -386,7 +373,7 @@ function fixES6ConstructorMemberLongnames (data) {
386373 if ( isES6Class ( i ) ) {
387374 const es6constructor = getEs6Constructor ( data , i )
388375 if ( es6constructor ) {
389- const constructorChildren = data . filter ( where ( { memberof : es6constructor . longname } ) )
376+ const constructorChildren = data . filter ( c => c . memberof === es6constructor . longname )
390377 constructorChildren . forEach ( child => {
391378 child . memberof = i . longname
392379 } )
@@ -407,7 +394,7 @@ function convertIsEnumFlagToKind (doclet) {
407394/* remove properties which have enum parents.. depends on convertIsEnumFlagToKind */
408395function removeEnumChildren ( json ) {
409396 return json . filter ( function ( doclet ) {
410- const parent = json . find ( where ( { id : doclet . memberof } ) )
397+ const parent = json . find ( i => i . id === doclet . memberof )
411398 if ( parent && parent . kind === 'enum' ) {
412399 return false
413400 } else {
0 commit comments