# All files / src/core native.js

100% Statements 10/10
100% Branches 4/4
100% Functions 4/4
100% Lines 10/10

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    2923x

    87x

    87x
    87x
    130x
    130x
    130x

    27x

    27x

    103x

     import Syntax from '../Syntax';

    export default function nativePlugin() {
      return {
        semantics() {
          return {
            ArraySubscript: next => (args, transform) => {
              const [node, context] = args;
              const [identifier, field] = node.params;
              if (
                identifier.Type === Syntax.Type &&
                field.Type === Syntax.FunctionCall
              ) {
                return {
                  ...node,
                  Type: Syntax.NativeMethod,
                  type: identifier.value,
                  value: identifier.value + '.' + field.value,
                  params: field.params.map(p => transform([p, context])),
                };
              }

              return next(args);
            },
          };
        },
      };
    }