/* ---------------------------------------------------------------------------
GET node
-------------------------------------------------------------------------
4340
function AvrYamahaNodeGet(config) {
    RED.nodes.createNode(this, config);

    // Save settings in local node
    this.device = config.device;
    this.deviceNode = RED.nodes.getNode(this.device);
    this.name = config.name;
    this.topic = config.topic;

    var node = this;
    if (this.deviceNode) {

  		// Input handler, called on incoming flow
      this.on('input', function(msg) {

        // If no topic is given in the config, then we use the topic in the msg.
        var topic = (node.topic) ? node.topic : msg.topic;
        if (!topic) {
          node.error('No topic given. Specify either in the config or via msg.topic!');
          return;
        }

        // Get data from the device.
        node.deviceNode.sendGetCommand(topic).then(function(value) {
          msg.payload = value;
          node.send(msg);
        }).catch(function(error) {
          node.error("Failed to request data from AVR with error: " + error);
        });

      });

    } else {
      this.error(RED._("avr-yamaha.errors.missing-config"));
    }
  }
244788
function (nodes, id) {
            for (var i = 0; i < nodes.length; i++) {
                var attrId = nodes.item(i).getAttribute("id");
                if (!attrId) {
                    continue;
                }
                if (attrId.toString() === id) {
                    return nodes.item(i);
                }
            }
            return null;
        }
1093247
def get_node(self, key):
        
        self._check_if_open()
        try:
            if not key.startswith('/'):
                key = '/' + key
            return self._handle.get_node(self.root, key)
        except _table_mod.exceptions.NoSuchNodeError:
            return None
1350938
function isLastNode(node) {
            const token = sourceCode.getTokenAfter(node);

            return !token || (token.type === "Punctuator" && token.value === "}");
        }
667198
Node getUserNode(Session session, String userName) throws PathNotFoundException, RepositoryException
   {
      return (Node)session.getItem(getUserNodePath(userName));
   }
1278504
function (node) {
            var first = node, length = 1;
            if (node.nodeType == 11) {
                first = node.firstChild;
                length = node.childNodes.length;
            }
            this.trimBoundary(true);
            var start = this.startContainer,
                offset = this.startOffset;
            var nextNode = start.childNodes[ offset ];
            if (nextNode) {
                start.insertBefore(node, nextNode);
            } else {
                start.appendChild(node);
            }
            if (first.parentNode === this.endContainer) {
                this.endOffset = this.endOffset + length;
            }
            return this.setStartBefore(first);
        }
943621
NodeAVL getNextNode(NodeAVL n) {

        if (n == null) {
            n = nPrimaryNode;
        } else {
            n = n.nNext;
        }

        return n;
    }
193078
function() {
    var node = this.primary();
    if (node) {
      while (this.accept('.')) {
        var id = new nodes.Ident(this.expect('ident').val.string);
        node = new nodes.Member(node, id);
      }
      this.skipSpaces();
      if (this.accept('=')) {
        node.val = this.list();
        // @block support
        if (node.val.isEmpty) this.assignAtblock(node.val);
      }
    }
    return node;
  }
1069213
function getNodeParameters() {
        return typeof process !== "undefined" && process.argv && process.argv.length > 1 ? process.argv.slice(1) : null;
    }
1353509
public Node<T> get(T element) {
		for (Node<T> node : nodes)
			if (node.element.equals(element))
				return node;
		return null;
	}
280427
function getNextSourceNode( node, startFromSibling, lastNode )
	{
		var next = node.getNextSourceNode( startFromSibling, null, lastNode );
		while ( !bookmarkGuard( next ) )
			next = next.getNextSourceNode( startFromSibling, null, lastNode );
		return next;
	}
112569
def get_node(self, name, memory=False, binary=False):
        
        return self._api_get(
            url='/api/nodes/{0}'.format(name),
            params=dict(
                binary=binary,
                memory=memory,
            ),
        )
1352175
function() {
    var node = this.member()
      , id;
    while (this.accept('[')) {
      node = new nodes.BinOp('[]', node, this.expression());
      this.expect(']');
    }
    // TODO: TernaryOp :)
    if (this.accept('=')) {
      node.op += '=';
      node.val = this.list();
      // @block support
      if (node.val.isEmpty) this.assignAtblock(node.val);
    }
    return node;
  }
776312
function processNode(node) {
    if (node.tagName === 'P' || node.tagName === 'DIV' || node.tagName === 'UL' || node.tagName === 'OL' || node.tagName === 'PRE')
      setContent(node, getContent(node), '\n\n', '\n\n');
    else if (node.tagName === 'BR')
      setContent(node, '\n\n');
    else if (node.tagName === 'HR')
      setContent(node, '\n***\n');
    else if (node.tagName === 'H1')
      setContent(node, nltrim(getContent(node)), '\n# ', '\n');
    else if (node.tagName === 'H2') 
      setContent(node, nltrim(getContent(node)), '\n## ', '\n');
    else if (node.tagName === 'H3')
      setContent(node, nltrim(getContent(node)), '\n### ', '\n');
    else if (node.tagName === 'H4') 
      setContent(node, nltrim(getContent(node)), '\n#### ', '\n');
    else if (node.tagName === 'H5') 
      setContent(node, nltrim(getContent(node)), '\n##### ', '\n');
    else if (node.tagName === 'H6')
      setContent(node, nltrim(getContent(node)), '\n###### ', '\n');
    else if (node.tagName === 'B' || node.tagName === 'STRONG')
      setContent(node, nltrim(getContent(node)), '**', '**');
    else if (node.tagName === 'I' || node.tagName === 'EM')
      setContent(node, nltrim(getContent(node)), '_', '_');
    else if (node.tagName === 'A') {
      var href = node.href ? nltrim(node.href) : '', text = nltrim(getContent(node)) || href, title = node.title ? nltrim(node.title) : '';
      if (href.length > 0)
        setContent(node, '[' + text + '](' + href + (title ? ' "' + title + '"' : '') + ')');
      else
        setContent(node, '');
    } else if (node.tagName === 'IMG') {
      var src = node.getAttribute('src') ? nltrim(node.getAttribute('src')) : '', alt = node.alt ? nltrim(node.alt) : '', caption = node.title ? nltrim(node.title) : '';
      if (src.length > 0)
        setContent(node, '![' + alt + '](' + src  + (caption ? ' "' + caption + '"' : '') + ')');
      else
        setContent(node, '');
    } else if (node.tagName === 'BLOCKQUOTE') {
      var block_content = getContent(node);
      if (block_content.length > 0)
        setContent(node, prefixBlock('> ', block_content), '\n\n', '\n\n');
      else
        setContent(node, '');
    } else if (node.tagName === 'CODE') {
      if (node._bfs_parent.tagName === 'PRE' && node._bfs_parent._bfs_parent !== null)
        setContent(node, prefixBlock('    ', getContent(node)));
      else
        setContent(node, nltrim(getContent(node)), '`', '`');
    } else if (node.tagName === 'LI') {
      var list_content = getContent(node);
      if (list_content.length > 0)
        if (node._bfs_parent.tagName === 'OL') 
          setContent(node, trim(prefixBlock('    ', list_content, true)), '1. ', '\n\n');
        else
          setContent(node, trim(prefixBlock('    ', list_content, true)), '- ', '\n\n');
      else
        setContent(node, '');
    } else 
      setContent(node, getContent(node));
  }
1115753
function ENV_node() {
      var Module = module.constructor;

      var parent = module.parent;
      var req = util.bind(parent, parent && parent.require || require);

      var fs = req('fs');
      var path = req('path');
      var vm = req('vm');

      this.requireCache = require.cache;
      this.main = require.main;
      this.name = 'node';
      this.global = global;
      this.isWindowsNode = (process.platform === 'win32');

      var _cwd = process.cwd();
      this.setCwd = function (cwd) { _cwd = path.resolve(_cwd, cwd); };
      this.getCwd = function () { return _cwd; };

      this.pathSep = path.sep;

      // var parentPath = util.splitPath(module.parent.filename);
      // module.parent.require = function(request, opts) {
      //   if (!opts) { opts = {}; }
      //   opts.dontExport = true;
      //   return _require({}, parentPath.directory, parentPath.filename, request, opts);
      // };

      this.log = function() {
        var msg;
        try {
          msg = Array.prototype.map.call(arguments, function(a) {
              if ((a instanceof Error) && a.message) {
                return 'Error:' + a.message + '\nStack:' + a.stack + '\nArguments:' + a.arguments;
              }
              return (typeof a == 'string' ? a : JSON.stringify(a));
            }).join(' ') + '\n';
        } catch(e) {
          msg = Array.prototype.join.call(arguments, ' ') + '\n';
        }

        process.stderr.write(msg);
        return msg;
      };

      this.getPath = function() {
        return __dirname;
      };

      this.eval = function (code, path) {
        return vm.runInThisContext(code, path, true);
      };

      this.fetch = function (p) {
        p = util.resolve(this.getCwd(), p);

        var filename, lowercaseFilename, files;
        try {
          var dirname = path.dirname(p);
          filename = path.basename(p);
          lowercaseFilename = filename.toLowerCase();
          files = fs.readdirSync(dirname);
        } catch (e) {
          return false;
        }

        for (var i = 0, testName; testName = files[i]; ++i) {
          if (testName.toLowerCase() == lowercaseFilename && testName != filename) {
            throw "Invalid case when importing [" + p + "].  You probably meant" + testName;
          }
        }

        try {
          return fs.readFileSync(p, 'utf8');
        } catch(e) {
          return false;
        }
      };

      var stackRe = /\((?!module.js)(?:file:\/\/)?(.*?)(:\d+)(:\d+)\)/g;
      this.loadModule = function (baseLoader, fromDir, fromFile, item, opts) {
        if (fromFile == INITIAL_FILE && !opts.initialImport) {
          var stack = new Error().stack;
          var match;
          stackRe.lastIndex = 0;
          do {
            match = stackRe.exec(stack);
          } while (match && /jsio\.js$/.test(match[1]));

          if (match) {
            fromDir = path.dirname(match[1]);
            fromFile = path.basename(match[1]);
          }
        }

        try {
          return baseLoader(null, fromDir, fromFile, item, opts);
        } catch(e) {
          if (e.code == MODULE_NOT_FOUND) {
            var require = req;
            // lookup node module for relative imports
            var module;
            var filename = path.join(fromDir, fromFile);
            module = this.requireCache[filename];
            if (!module) {
              module = new Module(filename);
              module.filename = filename;
              module.paths = Module._nodeModulePaths(path.dirname(filename));
            }
            var request = item.original || item.from;
            try {
              return {
                exports: module ? module.require(request) : require(request),
                path: item.from
              };
            } catch (e2) {
              if (e2.code == MODULE_NOT_FOUND) {
                throw e;
              }

              throw e2;
            }
          } else {
            throw e;
          }
        }
      };
    }
844248
@Override
    public Node get(ArchivePath path) {
        Validate.notNull(path, "No path was specified");
        Node node = content.get(path);
        if (node == null && contains(path)) {
            node = getNestedNode(path);
        }
        return node;
    }
1503
function getDataSource(node) {
    const config = Object.assign({}, copyXmlAttributes(node));

    if (node.childNodes.length) {
        // parse datasource options
        for (let i = 0; i < node.childNodes.length; ++i) {
            const childNode = node.childNodes.item(i);

            if (childNode.nodeType === TEXT_NODE && childNode.textContent.trim().length > 0) {
                throw new ImplementationError(`dataSource contains useless text: "${childNode.textContent.trim()}"`);
            }

            if (
                childNode.nodeType === ELEMENT_NODE &&
                childNode.namespaceURI === 'urn:flora:options' &&
                childNode.localName === 'option'
            ) {
                if (childNode.attributes.length !== 1)
                    throw new Error('flora:option element requires a name attribute');

                const attr = childNode.attributes.item(0);
                if (attr.localName !== 'name') throw new Error('flora:option element requires a name attribute');
                if (config[attr.value]) throw new Error(`Data source option "${attr.value}" already defined`);

                config[attr.value] = childNode.textContent.trim();
            }
        }
    }

    const name = config.name ? config.name : 'primary';
    if (config.name) delete config.name;

    return { name, config };
}