<commit_before>'use strict';

var gonzales = require('gonzales-pe'),
    jspath = require('jspath'),
    gonzo = require('gonzales-ast'),
    path = require('path'),
    Q = require('q'),
    _ = require('lodash');

function astToSrc(ast, syntax) {
  return gonzales.astToSrc({
    ast: ast,
    syntax: syntax
  });
}

// Parse Style variables to object
function parseVariableDeclarations(string, syntax) {
  syntax = syntax || 'scss';

  var out = [],
      ast = gonzales.parse(string, {
        syntax: syntax
      }),
      visitors = {
        sass: {
          // Visitor for SASS and SCSS syntaxes
          test: function(name, nodes) {
            return name === 'declaration' && nodes[1][0] === 'variable';
          },
          process: function(nodes) {
            var varName = nodes[1][1][1].filter(function(element) {
              return element !== 'ident';
            })[0];

            out.push({name: varName, value: astToSrc(nodes[4], syntax)});
          }
        },
        less: {
          // Visitor for LESS syntax
          test: function(name) {
            return name === 'atrules';
          },
          process: function(nodes) {
            var varName = nodes[1][1][1],
              varVal = '';

            // Skip at-keywords that do not decrade variable (Ex. @imports)
            if (nodes[2][0] === 'operator' && nodes[2][1] === ':') {
              /* Grabs all the listed values
              * Fix then https://github.com/tonyganch/gonzales-pe/issues/17 is fixed */
              nodes.forEach(function(element) {
                if (element === 'atrules' || element[0] === 'atkeyword') {
                  return;
                }
                if (element[0] === 'operator' && element[1] === ':'
                ) {
                  return;
                }
                varVal += astToSrc(element, syntax); // Syntax is always less as this visitor is only for LESS
              });

              out.push({name: varName, value: varVal.trim()});
            }
          }
        }
      },
      traversers = {
        sass: function(node) {
          if (node.type !== 'declaration') {
            return;
          }
          var variable = {}
          ast.map.call(node, function(nnode){
            if (nnode.type === 'variable') {
              ast.map.call(nnode, function(nnnode){<commit_msg>Use .map method of AST nodes<commit_after>'use strict';

var gonzales = require('gonzales-pe'),
    jspath = require('jspath'),
    gonzo = require('gonzales-ast'),
    path = require('path'),
    Q = require('q'),
    _ = require('lodash');

function astToSrc(ast, syntax) {
  return gonzales.astToSrc({
    ast: ast,
    syntax: syntax
  });
}

// Parse Style variables to object
function parseVariableDeclarations(string, syntax) {
  syntax = syntax || 'scss';

  var out = [],
      ast = gonzales.parse(string, {
        syntax: syntax
      }),
      visitors = {
        sass: {
          // Visitor for SASS and SCSS syntaxes
          test: function(name, nodes) {
            return name === 'declaration' && nodes[1][0] === 'variable';
          },
          process: function(nodes) {
            var varName = nodes[1][1][1].filter(function(element) {
              return element !== 'ident';
            })[0];

            out.push({name: varName, value: astToSrc(nodes[4], syntax)});
          }
        },
        less: {
          // Visitor for LESS syntax
          test: function(name) {
            return name === 'atrules';
          },
          process: function(nodes) {
            var varName = nodes[1][1][1],
              varVal = '';

            // Skip at-keywords that do not decrade variable (Ex. @imports)
            if (nodes[2][0] === 'operator' && nodes[2][1] === ':') {
              /* Grabs all the listed values
              * Fix then https://github.com/tonyganch/gonzales-pe/issues/17 is fixed */
              nodes.forEach(function(element) {
                if (element === 'atrules' || element[0] === 'atkeyword') {
                  return;
                }
                if (element[0] === 'operator' && element[1] === ':'
                ) {
                  return;
                }
                varVal += astToSrc(element, syntax); // Syntax is always less as this visitor is only for LESS
              });

              out.push({name: varName, value: varVal.trim()});
            }
          }
        }
      },
      traversers = {
        sass: function(node) {
          var variable = {};

          if (node.type !== 'declaration') {
            return;
          }

          node.map(function(nnode){
            if (nnode.type === 'variable') {
              nnode.map(function(nnnode){
{'fraction_non_alphanumeric': 0.1478664976763836, 'fraction_numerical': 0.008027038445289396, 'mean_word_length': 1.5945205479452054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3720464', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1334, 'n_words': 312}