<commit_before>(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define([], factory); // AMD. Register as an anonymous module.
  } else if (typeof exports === 'object') {
    module.exports = factory(); // NodeJS
  } else { // Browser globals (root is window)
    root.flyd = factory();
  }
}(this, function () {

'use strict';

function isFunction(obj) {
  return !!(obj && obj.constructor && obj.call && obj.apply);
}

function isUndefined(v) {
  return v === undefined;
}

// Globals
var curStream;
var nextId = 0;

var queue = [];

function flushQueue() {
  for (var q; q = queue.pop();) {
    for (var i = 0; i < q.l.length; ++i) {
      q.l[i](q.v);
    }
  }
}

function addDependency(to, from) {
  if (!(from.id in to.deps)) {
    to.deps[from.id] = from.listeners;
    from.listeners.push(to.update);
  }
}

function checkCirc(stream, id) {
  if (stream.deps[id]) {
    throw new Error('Circular dependency detected');
  }
}

function removeListener(listeners, cb) {
  var idx = listeners.indexOf(cb);
  listeners[idx] = listeners[listeners.length - 1];
  listeners.length--;
}

function map(s, f) {
  return stream([s], function() { return f(s()); }, true);
}

function reduce(s, f, acc) {
  return stream([s], function() {
    return (acc = f(acc, s()));
  });
}

function merge(s1, s2) {
  return stream(function(n, changed) {
    var v1, v2;
    if (changed) return changed();
    else {
     v1 = s1(), v2 = s2();
     return v1 === undefined ? v2 : v1;
    }
  });
}

function ap(s2) {
  var s1 = this;
  return stream(function() { return s1()(s2()); });
}

function of(v) {
  return stream()(v);
}

function initialDepsNotMet(stream) {
  if (stream.initialDeps) {
    var met = stream.initialDeps.every(function(stream) {
      return !isUndefined(stream());
    });
    if(met) stream.initialDeps = undefined;
  }
  return !isUndefined(stream.initialDeps);
}

function updateStream(stream, cb, changed) {
  if (initialDepsNotMet(stream)) return;
  curStream = stream;
  var returnVal = cb(stream, changed);
  curStream = undefined;
  if (returnVal !== undefined) stream(returnVal);
  flushQueue();
}

function destroyStream(stream) {
  if (stream.listeners.length !== 0) {
    throw new Error('Trying to destroy stream with listeners attached');
  }
  for (var id in stream.deps) {
    if (stream.deps[id]) removeListener(stream.deps[id], stream.update);
  }
}

function stream(arg) {
  function s(n) {
    if (arguments.length === 1) {
      if (!isUndefined(n) && isFunction(n.then)) {
        n.then(s);
        return;
      }
      s.val = n;
      if (!isUndefined(curStream)) {
        checkCirc(curStream, s.id);
        queue.push({v: s, l: s.listeners});
      } else {
        s.listeners.forEach(function(f) { f(s); });
      }
      return s;
    } else {
      if (curStream && curStream.dynamicDeps) {
        addDependency(curStream, s);
      }
      return s.val;
    }
  }
  s.val = undefined;
  s.listeners = [];<commit_msg>Additional unneeded arguments to streams are ignored<commit_after>(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define([], factory); // AMD. Register as an anonymous module.
  } else if (typeof exports === 'object') {
    module.exports = factory(); // NodeJS
  } else { // Browser globals (root is window)
    root.flyd = factory();
  }
}(this, function () {

'use strict';

function isFunction(obj) {
  return !!(obj && obj.constructor && obj.call && obj.apply);
}

function isUndefined(v) {
  return v === undefined;
}

// Globals
var curStream;
var nextId = 0;

var queue = [];

function flushQueue() {
  for (var q; q = queue.pop();) {
    for (var i = 0; i < q.l.length; ++i) {
      q.l[i](q.v);
    }
  }
}

function addDependency(to, from) {
  if (!(from.id in to.deps)) {
    to.deps[from.id] = from.listeners;
    from.listeners.push(to.update);
  }
}

function checkCirc(stream, id) {
  if (stream.deps[id]) {
    throw new Error('Circular dependency detected');
  }
}

function removeListener(listeners, cb) {
  var idx = listeners.indexOf(cb);
  listeners[idx] = listeners[listeners.length - 1];
  listeners.length--;
}

function map(s, f) {
  return stream([s], function() { return f(s()); }, true);
}

function reduce(s, f, acc) {
  return stream([s], function() {
    return (acc = f(acc, s()));
  });
}

function merge(s1, s2) {
  return stream(function(n, changed) {
    var v1, v2;
    if (changed) return changed();
    else {
     v1 = s1(), v2 = s2();
     return v1 === undefined ? v2 : v1;
    }
  });
}

function ap(s2) {
  var s1 = this;
  return stream(function() { return s1()(s2()); });
}

function of(v) {
  return stream()(v);
}

function initialDepsNotMet(stream) {
  if (stream.initialDeps) {
    var met = stream.initialDeps.every(function(stream) {
      return !isUndefined(stream());
    });
    if(met) stream.initialDeps = undefined;
  }
  return !isUndefined(stream.initialDeps);
}

function updateStream(stream, cb, changed) {
  if (initialDepsNotMet(stream)) return;
  curStream = stream;
  var returnVal = cb(stream, changed);
  curStream = undefined;
  if (returnVal !== undefined) stream(returnVal);
  flushQueue();
}

function destroyStream(stream) {
  if (stream.listeners.length !== 0) {
    throw new Error('Trying to destroy stream with listeners attached');
  }
  for (var id in stream.deps) {
    if (stream.deps[id]) removeListener(stream.deps[id], stream.update);
  }
}

function stream(arg) {
  function s(n) {
    if (arguments.length > 0) {
      if (!isUndefined(n) && isFunction(n.then)) {
        n.then(s);
        return;
      }
      s.val = n;
      if (!isUndefined(curStream)) {
        checkCirc(curStream, s.id);
        queue.push({v: s, l: s.listeners});
      } else {
        s.listeners.forEach(function(f) { f(s); });
      }
      return s;
    } else {
      if (curStream && curStream.dynamicDeps) {
        addDependency(curStream, s);
      }
      return s.val;
    }
  }
  s.val = undefined;
  s.listeners = [];
{'fraction_non_alphanumeric': 0.16824290691886512, 'fraction_numerical': 0.00663680106188817, 'mean_word_length': 3.015989340439707, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, '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': '3028217', 'n_tokens_mistral': 2118, 'n_tokens_neox': 2103, 'n_words': 510}