How to use the streams/core.createNode function in streams

To help you get started, we’ve selected a few streams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / interest-dashboard / lib / streams / interestDashboardDataProcessorBolt.js View on Github external
create: function _CDPB_create(storageBackend) {
    let node = createNode({
      identifier: "interestDashboardDataProcessorBolt",
      listenType: "chartData",
      emitType: "interestDashboardData",

      _daysPostEpochToDate: function(dayCount) {
        return parseInt(dayCount) * 24 * 60 * 60 * 1000;
      },

      ingest: function _HSB_ingest(message) {
        DataProcessorHelper.initChartInStorage("interestDashboardData", this.storage);

        /* Processing data for pie chart. */
        let interestDashboardTypeNamespace = message["keywords"]["58-cat"];

        let chartData = [];
        for (let interestData of interestDashboardTypeNamespace.sortedInterests) {
github mozilla / interest-dashboard / lib / streams / spiderDataProcessorBolt.js View on Github external
create: function _SDPB_create(storageBackend) {
    let node = createNode({
      _spiderInput: {"children": {}, "weight": 100},
      NUM_NODES_PER_LAYER: 4,
      identifier: "spiderDataProcessorBolt",
      listenType: "chartData", // Can also listen to other chart data processors
      emitType: "spiderData",

      _getRadius: function(isToplevel, parentRadius) {
        if (!isToplevel) {
          return parentRadius / 3.5; // A subcat should be 3.5 times smaller than its parent.
        }

        // For demo purposes, generate a random number of recommendations between 1-50.
        let recommendationCount = Math.floor(Math.random() * 50) + 1;

        let radius = 0;
        if (recommendationCount <= 10) {
github mozilla / interest-dashboard / lib / streams / areaDataProcessorBolt.js View on Github external
create: function _TDPB_create(storageBackend) {
    let node = createNode({
      identifier: "areaDataProcessorBolt",
      listenType: "chartData", // Can also listen to other chart data processors
      emitType: "areaData",

      _daysPostEpochToDate: function(dayCount) {
        return parseInt(dayCount) * 24 * 60 * 60 * 1000;
      },

      ingest: function _HSB_ingest(message) {
        DataProcessorHelper.initChartInStorage("areaData", this.storage);
        let areaTypeNamespace = message["keywords"]["58-cat"];
        let chartJSON = [];

        let top = areaTypeNamespace.sortedInterests.slice(0, 6);
        let topInterests = top.map(interest => {
          return interest.name;
github mozilla / interest-dashboard / lib / streams / weightIntensityDataProcessorBolt.js View on Github external
create: function _WIDPB_create(storageBackend) {
    let node = createNode({
      identifier: "weightIntensityDataProcessorBolt",
      listenType: "chartData", // Can also listen to other chart data processors
      emitType: "weightIntensityData",
      ingest: function _HSB_ingest(message) {
        DataProcessorHelper.initChartInStorage("weightIntensityData", this.storage);
        DataProcessorHelper.iterateOverTypeNamespace(message, this.storage.chartData.weightIntensityData, (message, storedData) => {
          // pointToInterestsMap is used to make up for a bug in nvd3 where multiple points can't
          // appear in the same location.
          let pointToInterestsMap = {};
          let values = [];

          storedData["xMin"] = message.xMin;
          storedData["yMin"] = message.yMin;
          storedData["xMax"] = message.xMax;
          storedData["yMax"] = message.yMax;
github mozilla / interest-dashboard / lib / streams / timelineDataProcessorBolt.js View on Github external
create: function _TDPB_create(storageBackend) {
    let node = createNode({
      identifier: "timelineDataProcessorBolt",
      listenType: "chartData", // Can also listen to other chart data processors
      emitType: "timelineData",
      ingest: function _HSB_ingest(message) {
        DataProcessorHelper.initChartInStorage("timelineData", this.storage);
        DataProcessorHelper.iterateOverTypeNamespace(message, this.storage.chartData.timelineData, (message, storedData) => {
          let chartJSON = [];
          let interestList = Object.keys(message.categories);
          for (let i = 0; i < interestList.length; i++) {
            let dataPoints = message.categories[interestList[i]].days;
            chartJSON.push({
              key: interestList[i],
              values: Object.keys(dataPoints).map(key => {
                dataPoints[key]["y"] = i;
                return dataPoints[key];
              })
github mozilla / interest-dashboard / lib / streams / intentInterestDataProcessorBolt.js View on Github external
create: function _IIDPB_create(storageBackend) {
    let node = createNode({
      identifier: "intentInterestDataProcessorBolt",
      listenType: "chartData", // Can also listen to other chart data processors
      emitType: "intentInterestData",
      ingest: function _HSB_ingest(message) {
        DataProcessorHelper.initChartInStorage("intentInterestData", this.storage);
        DataProcessorHelper.iterateOverTypeNamespace(message, this.storage.chartData.intentInterestData, (message, storedData) => {
          storedData["sortedInterests"] = [];
          storedData["sortedIntents"] = [];

          for (let intentData of message.sortedIntents.splice(0, 10)) {
            let maxWeightDate = intentData.maxWeightDate;
            let domainList = intentData.days[maxWeightDate]["domainList"];
            let maxIntentDate = (new Date(intentData.days[maxWeightDate]["x"])).toLocaleDateString();
            let title = intentData.name + " (" + maxIntentDate + ")";
            let chartJSON = IntentInterestDataProcessorBolt._createChartData(domainList, storedData, "sortedIntents", title);
          }
github mozilla / interest-dashboard / lib / streams / dailyInterestsSpout.js View on Github external
create: function _DIS_create(storageBackend) {
    let node = createNode({
      identifier: "dailyInterestsSpout",
      listenType: "interest",
      emitType: "dailyInterests",

      init: function _DIS_init() {
        if (!this.storage.dayBufferInterests) {
          this.storage.dayBufferInterests = {};
        }
      },

      getInterests: function _DIS__getInterests() {
        return this.storage.dayBufferInterests;
      },

      _storeInterest: function _DIS__storeInterest(host, visitIDs, visitDate, visitCount, namespace, type, interest, subcat) {
        if (!this.storage.dayBufferInterests[visitDate]) {
github mozilla / interest-dashboard / lib / streams / dayCountRankerBolt.js View on Github external
create: function _DCRB_create(namespace, type, storageBackend) {
    let capitalizedType = type.charAt(0).toUpperCase() + type.slice(1);
    let node = createNode({
      identifier: namespace+capitalizedType+"Ranker",
      listenType: "dailyInterests",
      namespace: namespace,
      type: type,
      storageKey: "daycount_" + namespace + "_" + type,
      emitType: null,

      init: function _DIR_init() {
        if (!this.storage.ranking) {
          this.storage.ranking = {};
        }
        if (!this.storage.ranking[this.storageKey]) {
          this.storage.ranking[this.storageKey] = {};
        }
        this.interests = this.storage.ranking[this.storageKey];
      },
github mozilla / interest-dashboard / lib / streams / chartDataProcessorBolt.js View on Github external
create: function _CDPB_create(storageBackend) {
    let node = createNode({
      identifier: "chartDataProcessorBolt",
      listenType: "dailyInterests",
      emitType: "chartData",
      ingest: function _HSB_ingest(message) {
        try {
          this.debugReport.push("~*~* chartDataProcessorBolt ingest() start *~*~");
          DataProcessorHelper.initChartInStorage("genericChartData", this.storage);
          let storageData = this.storage.chartData.genericChartData;
          let days = Object.keys(message);
          this.debugReport.push("Processing chart data for " + days.length + " days: [" + days.toString().replace(/,/g, '; ') + "]");
          for (let day in message) {
            for (let type in message[day]) {
              for (let namespace in message[day][type]) {
                if (!storageData[type]) {
                  storageData[type] = {};
                }
github mozilla / interest-dashboard / lib / streams / hostStripBolt.js View on Github external
create: function _HSB_create() {
    let node = createNode({
      identifier: "hostStripBolt",
      listenType: "dailyInterests",
      emitType: "hostlessInterests",
      ingest: function _HSB_ingest(message) {
        for (let timeKey in message) {
          let period = message[timeKey];
          for (let typeKey in period) {
            let type = period[typeKey];
            for (let nsKey in type) {
              let namespace = type[nsKey];
              for (let interestKey in namespace) {
                let interest = namespace[interestKey];
                let counts = [];
                for (let hostKey in interest) {
                  counts.push(interest[hostKey]);
                }

streams

A lazy streams library for functional composition in JavaScript.

MIT
Latest version published 22 days ago

Package Health Score

70 / 100
Full package analysis