API Documentation

On GitHub

IP API

NoFlo - Flow-Based Programming for JavaScript
(c) 2016-2017 Flowhub UG
NoFlo may be freely distributed under the MIT license

Information Packets

IP objects are the way information is transmitted between components running in a NoFlo network. IP objects contain a type that defines whether they’re regular data IPs or whether they are the beginning or end of a stream (openBracket, closeBracket).

The component currently holding an IP object is identified with the owner key.

By default, IP objects may be sent to multiple components. If they’re set to be clonable, each component will receive its own clone of the IP. This should be enabled for any IP object working with data that is safe to clone.

It is also possible to carry metadata with an IP object. For example, the datatype and schema of the sending port is transmitted with the IP object.

var IP;

module.exports = IP = (function() {
  class IP {

Detects if an arbitrary value is an IP

    static isIP(obj) {
      return obj && typeof obj === 'object' && obj._isIP === true;
    }

Creates as new IP object Valid types: ‘data’, ‘openBracket’, ‘closeBracket’

    constructor(type = 'data', data = null, options = {}) {
      var key, val;
      this.type = type;
      this.data = data;
      this._isIP = true;
      this.scope = null; // sync scope id
      this.owner = null; // packet owner process
      this.clonable = false; // cloning safety flag
      this.index = null; // addressable port index
      this.schema = null;
      this.datatype = 'all';
      for (key in options) {
        val = options[key];
        this[key] = val;
      }
    }

Creates a new IP copying its contents by value not reference

    clone() {
      var ip, key, ref, val;
      ip = new IP(this.type);
      ref = this;
      for (key in ref) {
        val = ref[key];
        if (['owner'].indexOf(key) !== -1) {
          continue;
        }
        if (val === null) {
          continue;
        }
        if (typeof val === 'object') {
          ip[key] = JSON.parse(JSON.stringify(val));
        } else {
          ip[key] = val;
        }
      }
      return ip;
    }

Moves an IP to a different owner

    move(owner) {
      this.owner = owner;
    }

no-op

Frees IP contents

    drop() {
      var key, ref, results, val;
      ref = this;
      results = [];
      for (key in ref) {
        val = ref[key];
        results.push(delete this[key]);
      }
      return results;
    }

  };

Valid IP types

  IP.types = ['data', 'openBracket', 'closeBracket'];

  return IP;

}).call(this);

This page contains documentation generated automatically from NoFlo's IP.coffee file.