packages/plugin/index.js
function apply(x) {
      const policyPathLength = policyPath.length;
      policyPath[policyPathLength] = x;
      if (Array.isArray(x)) {
        for (let i = 0, len = x.length; i < len; ++i) {
          policyPath[policyPathLength + 1] = i;
          apply(x[i]);
        }
      } else if (x && typeof x === 'object') {
        for (const key of Object.getOwnPropertyNames(x)) {
          policyPath[policyPathLength + 1] = key;
          const valueType = typeof policy[key];
          if (valueType === 'function') {
            policy[key](x[key]);
          } else if (valueType === 'object') {
            const policyMember = policy[key][x[key]];
            if (typeof policyMember === 'function') {
              policyMember(x);
            }
          }
          if (key === 'test' || key === 'expr') {
            checkCodeDoesNotInterfere(x, key, true);
          }
          apply(x[key]);
        }
      }
      policyPath.length = policyPathLength;
    }
function apply(x) {
      const policyPathLength = policyPath.length;
      policyPath[policyPathLength] = x;
      if (Array.isArray(x)) {
        for (let i = 0, len = x.length; i < len; ++i) {
          policyPath[policyPathLength + 1] = i;
          apply(x[i]);
        }
      } else if (x && typeof x === 'object') {
        for (const key of Object.getOwnPropertyNames(x)) {
          policyPath[policyPathLength + 1] = key;
          const valueType = typeof policy[key];
          if (valueType === 'function') {
            policy[key](x[key]);
          } else if (valueType === 'object') {
            const policyMember = policy[key][x[key]];
            if (typeof policyMember === 'function') {
              policyMember(x);
            }
          }
          if (key === 'test' || key === 'expr') {
            checkCodeDoesNotInterfere(x, key, true);
          }
          apply(x[key]);
        }
      }
      policyPath.length = policyPathLength;
    }
function apply ( x ) { const policyPathLength = policyPath . length ; policyPath [ policyPathLength ] = x ; if ( Array . isArray ( x ) ) { for ( let i = 0 , len = x . length ; i < len ; ++ i ) { policyPath [ policyPathLength + 1 ] = i ; apply ( x [ i ] ) ; } } else if ( x && typeof x === 'object' ) { for ( const key of Object . getOwnPropertyNames ( x ) ) { policyPath [ policyPathLength + 1 ] = key ; const valueType = typeof policy [ key ] ; if ( valueType === 'function' ) { policy [ key ] ( x [ key ] ) ; } else if ( valueType === 'object' ) { const policyMember = policy [ key ] [ x [ key ] ] ; if ( typeof policyMember === 'function' ) { policyMember ( x ) ; } } if ( key === 'test' || key === 'expr' ) { checkCodeDoesNotInterfere ( x , key , true ) ; } apply ( x [ key ] ) ; } } policyPath . length = policyPathLength ; }
Walk the AST applying the policy
Walk the AST applying the policy