import { isExpectType } from '../utils' ; export const hasProto = '__proto__' in { } ; export function def ( obj , key , val , enumerable ? ) { Object . defineProperty ( obj , key , { value : val , enumerable : ! ! enumerable , writable : true , configurable : true } ) ; } export function parsePath ( path ) { path += '.' ; let segments = [ ] , segment = '' ; for ( let i = 0 ; i < path . length ; i ++ ) { let curr = path [ i ] ; if ( /\[|\./ . test ( curr ) ) { segments . push ( segment ) ; segment = '' ; } else if ( /\W/ . test ( curr ) ) { continue ; } else { segment += curr ; } } return function ( data ) { return segments . reduce ( ( data , key ) => { return data [ key ] ; } , data ) ; } ; } export function traverse ( value ) { const dfs = ( data ) => { if ( ! isExpectType ( data , 'array' , 'object' ) ) return ; Object . keys ( data ) . forEach ( key => { const value = data [ key ] ; dfs ( value ) ; } ) ; } ; dfs ( value ) ; }