Helper functions
428032
function wrapStreams () {
    // Iterate over the param-array (which should consist of Streams)
    for (let stream of arguments) {
        // Set a textContent property
        stream.textContent = "";

        // Set the stream encoding
        stream.setEncoding ("utf-8");

        // When the stream receives data, add it to the textContent
        stream.on ("data", (data) => { stream.textContent += data; });
    }
}
1131887
function styleBlockHandler(element) {
    const {property, value} = element
    let result = []
    const styleContent = value && value.children ? value.children : []
    const defaultUnit = "px"
    styleContent.forEach(e => {
        switch (e.type) {
            case "Identifier":
                result.push(e.name);
                break
            case "Dimension":
                result.push(e.value + defaultUnit);
                break
            case 'Function': {
                //function case need '()' container,such as rgb(255,0,0)
                let name = e.name + "("
                e.children.forEach(e => name += e.value + queryUnit(e.unit))
                result.push(name + ")")
                break
            }
            case "HexColor": {
                result.push("#" + e.value)
                break
            }
            case "String": {
                const str = e.value
                result.push(str)
                break
            }
            case "Number": {
                result.push(e.value)
                break
            }
            case "Percentage": {
                result.push(e.value + "%")
                break
            }
            case "WhiteSpace": {
                break
            }
            case "Operator": {
                break
            }
            case "Url": {
                break
            }
            default:
                // console.log("unknown,", property, e)
                break
        }
    })
    //padding modification
    if (result.length > 0)
        return paddingElementForTransform(property, result)
    return []
}
1270724
function ttEach($els, fn) {
    $els.each(function() {
      var $input = $(this), typeahead;

      (typeahead = $input.data(keys.typeahead)) && fn(typeahead, $input);
    });
  }
1229025
function(data) {
        var TTML_BODY = '',
            index = 0,
            splitText,
            captions = data;

        TTML_BODY += TTML.header.join('\n') + '\n';
        captions.forEach(function(caption) {
            if (caption.text.length > 0 && validateText(caption.text)) {
                if ((/&/.test(caption.text)) && !(/&amp;/.test(caption.text))) {
                    caption.text = caption.text.replace(/&/g, '&amp;');
                }
                if ((/</.test(caption.text)) && !(/&lt;/.test(caption.text))) {
                    caption.text = caption.text.replace(/</g, '&lt;');
                }
                if ((/>/.test(caption.text)) && !(/&gt;/.test(caption.text))) {
                    caption.text = caption.text.replace(/>/g, '&gt;');
                }
                if (/\{break\}/.test(caption.text)) {
                    splitText = caption.text.split('{break}');
                    //TODO this should count for number of breaks and add the appropriate pops where needed.
                    for (index = 0; index < splitText.length; index++) {
                        TTML_BODY += TTML.lineTemplate.replace('{region}', 'pop' + (index + 1))
                            .replace('{startTime}', module.exports.formatTime(caption.startTimeMicro))
                            .replace('{endTime}', module.exports.formatTime(caption.endTimeMicro))
                            .replace('{text}', module.exports.renderMacros(macros.fixItalics(macros.cleanMacros(splitText[index])))) + '\n';
                    }
                } else {
                    TTML_BODY += TTML.lineTemplate.replace('{region}', 'pop1')
                        .replace('{startTime}', module.exports.formatTime(caption.startTimeMicro))
                        .replace('{endTime}', module.exports.formatTime(caption.endTimeMicro))
                        .replace('{text}', module.exports.renderMacros(macros.fixItalics(macros.cleanMacros(caption.text)))) + '\n';
                }
            }
        });

        return TTML_BODY + TTML.footer.join('\n') + '\n';
    }
710693
function (item, disabled) {
            return {
                title: item.title,
                aClass: item.aClass,
                value: item.aClass ? '' : item.value,
                liClass: disabled ? scope.disabledClass : '',
                pgHref: disabled ? '' : scope.pgHref.replace(regex, item.page),
                action: function () {
                    if (!disabled) {
                        internalAction(scope, item.page);
                    }
                }
            };    
        }
605715
function jsTreeCtrl() {
        /*jshint validthis:true */
        var nodeSerialId = 1;
        var vm = this;

        vm.nodesFingerprint = function (e) {
            if (!e.__uiNodeId) {
                e.__uiNodeId = nodeSerialId++;
            }
            return '' + e.__uiNodeId + (e.id || '') + (e.text || '') + (e.type || '');
        };

        vm.changeWatcher = function (arraySource, tokenFn) {
            var self;
            var getTokens = function () {
                var result = [], token, el;
                if (arraySource) {
                    var array = angular.isFunction(arraySource) ? arraySource() : arraySource;
                    for (var i = 0, n = array.length; i < n; i++) {
                        el = array[i];
                        token = tokenFn(el);
                        map[token] = el;
                        result.push(token);
                    }
                }
                return result;
            };
            // returns elements in that are in a but not in b
            // subtractAsSets([4, 5, 6], [4, 5, 7]) => [6]
            var subtractAsSets = function (a, b) {
                var result = [], inB = {}, i, n;
                for (i = 0, n = b.length; i < n; i++) {
                    inB[b[i]] = true;
                }
                for (i = 0, n = a.length; i < n; i++) {
                    if (!inB[a[i]]) {
                        result.push(a[i]);
                    }
                }
                return result;
            };

            // Map objects to tokens and vice-versa
            var map = {};

            var applyChanges = function (newTokens, oldTokens) {
                var i, n, el, token;
                var replacedTokens = {};
                var removedTokens = subtractAsSets(oldTokens, newTokens);
                for (i = 0, n = removedTokens.length; i < n; i++) {
                    var removedToken = removedTokens[i];
                    el = map[removedToken];
                    delete map[removedToken];
                    var newToken = tokenFn(el);
                    // if the element wasn't removed but simply got a new token, its old token will be different from the current one
                    if (newToken === removedToken) {
                        self.onRemoved(el);
                    } else {
                        replacedTokens[newToken] = removedToken;
                        self.onChanged(el);
                    }
                }

                var addedTokens = subtractAsSets(newTokens, oldTokens);
                for (i = 0, n = addedTokens.length; i < n; i++) {
                    token = addedTokens[i];
                    el = map[token];
                    if (!replacedTokens[token]) {
                        self.onAdded(el);
                    }
                }

            };
            self = {
                subscribe: function (scope, onChanged) {
                    scope.$watch(getTokens, function (newTokens, oldTokens) {
                        if (!onChanged || onChanged(newTokens, oldTokens) !== false) {
                            applyChanges(newTokens, oldTokens);
                        }
                    }, true);
                },
                onAdded: angular.noop,
                onChanged: angular.noop,
                onRemoved: angular.noop
            };
            return self;
        };
    }
1156251
function() {
    if (!ICAL.debug) {
      return;
    }

    if (typeof (console) !== 'undefined' && 'log' in console) {
      ICAL.helpers.dumpn = function consoleDumpn(input) {
        console.log(input);
      };
    } else {
      ICAL.helpers.dumpn = function geckoDumpn(input) {
        dump(input + '\n');
      };
    }

    ICAL.helpers.dumpn(arguments[0]);
  }
466063
function (value) {
    
            var process = value.split('-');
            value = beyond.css.values;
            for (var i in process) {
    
                value = value[process[i]];
                if (typeof value === 'undefined') return;
    
            }
    
            return value;
    
        }
97666
function helper(app, file, key, re) {
  var h = get(app._.asyncHelpers, key);
  var a = get(app._.helpers, key);

  if (!h && !a) {
    set(file.data, key, function () {
      return comment(key, 'helper');
    });

    if (re.test(file.content)) {
      var message = 'MISSING helper: "' + key + '".\n';
      // rethrow (or actually throw) the error
      var err = new SyntaxError(message);
      if (app.disabled('silent')) {
        rethrow(err, file.path, file.content, re);
      }
    }
  }
}
1079254
function mapCOW(arr, func) {
    var res = null;

    for(var i=0; i<arr.length; i++) {
        var item = func(arr[i]);

        if(item !== arr[i]) {
            if(!res) {
                res = arr.slice();
            }

            res[i] = item;
        }
    }

    return res || arr;
}
1164652
function(key, ctx, partials, returnFound) {
      var names = key.split('.'),
          val = this.f(names[0], ctx, partials, returnFound),
          cx = null;

      if (key === '.' && isArray(ctx[ctx.length - 2])) {
        return ctx[ctx.length - 1];
      }

      for (var i = 1; i < names.length; i++) {
        if (val && typeof val == 'object' && names[i] in val) {
          cx = val;
          val = val[names[i]];
        } else {
          val = '';
        }
      }

      if (returnFound && !val) {
        return false;
      }

      if (!returnFound && typeof val == 'function') {
        ctx.push(cx);
        val = this.lv(val, ctx, partials);
        ctx.pop();
      }

      return val;
    }
137353
function unescapeHtml(s) {
            if (_toString.call(s) != "[object String]") return s;
            if (!s) return "";
            return s.replace(/(&lt;)|(&gt;)|(&amp;)|(&quot;)/gm, function (match) {
                switch (match) {
                    case "&lt;":
                        return "<";
                    case "&gt;":
                        return ">";
                    case "&amp;":
                        return "&";
                    case "&quot;":
                        return "\"";
                    default:
                        return match;
                }
            });
        }
182520
function (a, element, event, callback) {
                var cbCheck;
                for (var i = 0, l = a.length; i < l; i = i + 1) {
                    var li = a[i];
                    if (li && this.typesUtil.isObject(li[FN]) && !li[FN].$Callback) {
                        cbCheck = ("fn" in callback) && (li[FN].fn == callback.fn);
                    } else {
                        cbCheck = (li[FN] == callback);
                    }
                    if (li && cbCheck && li[EL] == element && li[TYPE] == event) {
                        return i;
                    }
                }

                return -1;
            }
1140417
function selector(str) {
        var elems = [];

        each(str.split(/\s*,\s*/), function(s) {
            var m = s.match(/([#.])(\w+)/);
            if (m === null) {
                throw Error('Supports only simple single #ID or .CLASS selector.');
            }

            if (m[1]) {
                var elem = document.getElementById(m[2]);

                if (elem) {
                    elems.push(elem);
                }
            }

            elems = elems.concat(getElementsByClassName(str));
        });

        return elems;
    }
1356608
function(keysFunc, undefinedOnly) {
    return function(obj) {
      var length = arguments.length;
      if (length < 2 || obj === null) return obj;
      for (var index = 1; index < length; index++) {
        var source = arguments[index];
        var keys = keysFunc(source);
        var l = keys.length;

        for (var i = 0; i < l; i++) {
          var key = keys[i];
          if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
        }
      }

      return obj;
    };
  }
34802
function generalLike(d, value, comparator, sensitive) {
            var regex;

            RegExp.escape = function(str) {
                return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
            };

            regex = RegExp.escape(value);
            regex = regex.replace(/%/g, '.*').replace(/_/g, '.');
            regex = new RegExp('^' + regex + '$', sensitive);

            if ('object' === typeof d) {
                return function(elem) {
                    var i, len;
                    len = d.length;
                    for (i = 0; i < len; i++) {
                        if ('undefined' !== typeof elem[d[i]]) {
                            if (regex.test(elem[d[i]])) {
                                return elem;
                            }
                        }
                    }
                };
            }
            else if (d === '*') {
                return function(elem) {
                    var d;
                    for (d in elem) {
                        if ('undefined' !== typeof elem[d]) {
                            if (regex.test(elem[d])) {
                                return elem;
                            }
                        }
                    }
                };
            }
            else {
                return function(elem) {
                    if ('undefined' !== typeof elem[d]) {
                        if (regex.test(elem[d])) {
                            return elem;
                        }
                    }
                };
            }
        }
734061
function _preCommand(commands) {
  commander.on('--help', function () {

    var hasExample = _.map(_.values(commands), 'examples')
      .filter(function (elem) {
        return elem !== undefined;
      });
    if (hasExample.length > 0) {
      hasExample = hasExample.reduce(function (a, b) {
        return a.concat(b);
      });
    }
    hasExample = hasExample.length > 0;

    if (hasExample) {

      console.log('  Examples:\n');

      Object.keys(commands).forEach(function (command) {
        if (!_.isEmpty(commands[command].examples)) {
          console.log('    %s:', command);
          commands[command].examples.forEach(function (example) {
            console.log('      %s', example);
          });
        }
      });
    }
  });
}