<commit_before>;(function(global) {
  "use strict";

var Kefir = global.Kefir;
if ((typeof Kefir === 'undefined') &&
    (typeof require !== 'undefined')) Kefir = require('../vendor/kefir.min.js');
if (!Kefir) throw new Error('Kefir.js (https://github.com/rpominov/kefir) is required for Rpd to work');

Kefir.DEPRECATION_WARNINGS = false;

var Rpd = (function() {

// Rpd.NOTHING, Rpd.ID_LENGTH, ...

var nodetypes = {};
var linktypes = {};
var channeltypes = {};
var noderenderers = {};
var channelrenderers = {};
var nodedescriptions = {};

var renderer_registry = {};

var event_conf = { 'model/new': function(model) { return { model: model }; } };
var event = event_map(event_conf);
var events = events_stream(event_conf, event);

event['model/new'].onValue(function(model) { events.plug(model.events); });

function ƒ(v) { return function() { return v; } }

// ================================== Model ====================================
// =============================================================================

function Model(name) {
    this.id = short_uid();
    this.name = name;

    var myself = this;

    var event_conf = {
        'model/ready':   function(model)   { return { model: model } },
        'model/render':  function(data)    { return { model: myself, renderer: data[0], target: data[1], configuration: data[2] } },
        'model/enter':   function(model)   { return { model: model }; },
        'model/exit':    function(model)   { return { model: model }; },
        'model/inputs':  function(inputs)  { return { model: myself, inputs: inputs }; },
        'model/outputs': function(outputs) { return { model: myself, outputs: outputs }; },
        'model/refer':   function(data)    { return { model: myself, node: data[0], target: data[1] }; },
        'model/project': function(data)    { return { model: myself, node: data[0], inputs: data[1], outputs: data[2] }; },
        'node/add':      function(node)    { return { node: node }; },
        'node/remove':   function(node)    { return { node: node }; }
    };
    this.event = event_map(event_conf);
    this.events = events_stream(event_conf, this.event);

    Kefir.combine([ this.events.filter(function(event) { return event.type !== 'model/render'; }) ],
                  [ this.event['model/render'].scan(function(renderers, event) {
                        var alias = event[0], target = event[1], configuration = event[2];
                        var renderer = renderers[alias];
                        if (!renderer) {
                            renderer = {};
                            renderer.produce = renderer_registry[alias](myself);
                            renderer.handlers = [];
                            renderers[alias] = renderer;
                        }
                        renderer.handlers.push(renderer.produce(target, configuration));
                        return renderers;
                    }, { }) ])
         .bufferWhileBy(Kefir.merge([
                            this.event['model/enter'].map(ƒ(false)),
                            this.event['model/exit'].map(ƒ(true)).flatMap(function(x) {
                                return Kefir.later(1, x) // let exit event get into combined stream
                            })
                        ]),
                        { flushOnChange: true }).flatten().onValue(function(value) {
            console.log(value[0], value[0].type, value[1]);
            var event = value[0], renderers = value[1];
            var aliases = Object.keys(renderers);
            var renderer, handlers;
            for (var i = 0, il = aliases.length; i < il; i++) {
                renderer = renderers[aliases[i]]; handlers = renderer.handlers;
                for (var j = 0, jl = handlers.length; j < jl; j++) {
                    if (handlers[j][event.type]) handlers[j][event.type](inject_render(event, aliases[i]));
                }
            }
        }
    );

    this.projections = Kefir.emitter();
    Kefir.combine(
        [ this.projections ],
        [ this.event['model/inputs'],
          this.event['model/outputs'] ]
    ).onValue(function(value) {
        var node = value[0], inputs = value[1], outputs = value[2];
        var inlet, outlet;
        for (var i = 0; i < inputs.length; i++) {<commit_msg>replace `Kefir.later` for `model/exit` stream with `.delay(0)`<commit_after>;(function(global) {
  "use strict";

var Kefir = global.Kefir;
if ((typeof Kefir === 'undefined') &&
    (typeof require !== 'undefined')) Kefir = require('../vendor/kefir.min.js');
if (!Kefir) throw new Error('Kefir.js (https://github.com/rpominov/kefir) is required for Rpd to work');

Kefir.DEPRECATION_WARNINGS = false;

var Rpd = (function() {

// Rpd.NOTHING, Rpd.ID_LENGTH, ...

var nodetypes = {};
var linktypes = {};
var channeltypes = {};
var noderenderers = {};
var channelrenderers = {};
var nodedescriptions = {};

var renderer_registry = {};

var event_conf = { 'model/new': function(model) { return { model: model }; } };
var event = event_map(event_conf);
var events = events_stream(event_conf, event);

event['model/new'].onValue(function(model) { events.plug(model.events); });

function ƒ(v) { return function() { return v; } }

// ================================== Model ====================================
// =============================================================================

function Model(name) {
    this.id = short_uid();
    this.name = name;

    var myself = this;

    var event_conf = {
        'model/ready':   function(model)   { return { model: model } },
        'model/render':  function(data)    { return { model: myself, renderer: data[0], target: data[1], configuration: data[2] } },
        'model/enter':   function(model)   { return { model: model }; },
        'model/exit':    function(model)   { return { model: model }; },
        'model/inputs':  function(inputs)  { return { model: myself, inputs: inputs }; },
        'model/outputs': function(outputs) { return { model: myself, outputs: outputs }; },
        'model/refer':   function(data)    { return { model: myself, node: data[0], target: data[1] }; },
        'model/project': function(data)    { return { model: myself, node: data[0], inputs: data[1], outputs: data[2] }; },
        'node/add':      function(node)    { return { node: node }; },
        'node/remove':   function(node)    { return { node: node }; }
    };
    this.event = event_map(event_conf);
    this.events = events_stream(event_conf, this.event);

    Kefir.combine([ this.events.filter(function(event) { return event.type !== 'model/render'; }) ],
                  [ this.event['model/render'].scan(function(renderers, event) {
                        var alias = event[0], target = event[1], configuration = event[2];
                        var renderer = renderers[alias];
                        if (!renderer) {
                            renderer = {};
                            renderer.produce = renderer_registry[alias](myself);
                            renderer.handlers = [];
                            renderers[alias] = renderer;
                        }
                        renderer.handlers.push(renderer.produce(target, configuration));
                        return renderers;
                    }, { }) ])
         .bufferWhileBy(Kefir.merge([
                            this.event['model/enter'].map(ƒ(false)),
                            this.event['model/exit'].map(ƒ(true)).delay(0) // let exit event get into combined stream
                        ]),
                        { flushOnChange: true }).flatten().onValue(function(value) {
            console.log(value[0], value[0].type, value[1]);
            var event = value[0], renderers = value[1];
            var aliases = Object.keys(renderers);
            var renderer, handlers;
            for (var i = 0, il = aliases.length; i < il; i++) {
                renderer = renderers[aliases[i]]; handlers = renderer.handlers;
                for (var j = 0, jl = handlers.length; j < jl; j++) {
                    if (handlers[j][event.type]) handlers[j][event.type](inject_render(event, aliases[i]));
                }
            }
        }
    );

    this.projections = Kefir.emitter();
    Kefir.combine(
        [ this.projections ],
        [ this.event['model/inputs'],
          this.event['model/outputs'] ]
    ).onValue(function(value) {
        var node = value[0], inputs = value[1], outputs = value[2];
        var inlet, outlet;
        for (var i = 0; i < inputs.length; i++) {
{'fraction_non_alphanumeric': 0.18500816041035206, 'fraction_numerical': 0.005479132664956867, 'mean_word_length': 2.2203453453453452, 'pattern_counts': {'":': 0, '<': 9, '<?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': '42362', 'n_tokens_mistral': 2504, 'n_tokens_neox': 2444, 'n_words': 535}