UNPKG

janus

Version:

the two-faced application library-framework

197 lines (140 loc) 5.39 kB
// Generated by CoffeeScript 1.12.2 (function() { var AnyFold, Base, Enumerable, IncludesFold, IndexOfFold, Mappable, MinMaxFold, Sequence, SumFold, Traversal, Varying, folds, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty, slice = [].slice; Base = require('../core/base').Base; Varying = require('../core/varying').Varying; Traversal = require('./traversal').Traversal; folds = require('./folds'); IndexOfFold = require('./derived/indexof-fold').IndexOfFold; IncludesFold = require('./derived/includes-fold').IncludesFold; AnyFold = require('./derived/any-fold').AnyFold; MinMaxFold = require('./derived/min-max-fold').MinMaxFold; SumFold = require('./derived/sum-fold').SumFold; Enumerable = (function(superClass) { var Enumeration$; extend(Enumerable, superClass); function Enumerable() { return Enumerable.__super__.constructor.apply(this, arguments); } Enumerable.prototype.isEnumerable = true; Enumeration$ = null; Enumerable.prototype.enumerate_ = function() { return (Enumeration$ != null ? Enumeration$ : Enumeration$ = require('./enumeration').Enumeration).get_(this); }; Enumerable.prototype.enumerate = function() { if (Enumeration$ == null) { Enumeration$ = require('./enumeration').Enumeration; } return (this.enumerate$ != null ? this.enumerate$ : this.enumerate$ = Base.managed((function(_this) { return function() { return Enumeration$.get(_this); }; })(this)))(); }; Enumerable.prototype.keys_ = Enumerable.prototype.enumerate_; Enumerable.prototype.keys = Enumerable.prototype.enumerate; Enumerable.prototype.serialize = function() { return Traversal.natural_(Traversal["default"].serialize, this); }; Enumerable.prototype.modified = function() { if (this._parent != null) { return this.diff(this._parent); } else { return new Varying(false); } }; Enumerable.prototype.diff = function(other) { return Traversal.list(Traversal["default"].diff, [this, other]); }; return Enumerable; })(Base); Mappable = (function(superClass) { extend(Mappable, superClass); function Mappable() { return Mappable.__super__.constructor.apply(this, arguments); } Mappable.prototype.isMappable = true; Mappable.prototype.map = function(f) { return new (require('./derived/mapped-list').MappedList)(this, f); }; Mappable.prototype.flatMap = function(f) { return new (require('./derived/mapped-list').FlatMappedList)(this, f); }; Mappable.prototype.filter = function(f) { return new (require('./derived/filtered-list').FilteredList)(this, f); }; Mappable.prototype.flatten = function() { return new (require('./derived/flattened-list').FlattenedList)(this); }; Mappable.prototype.uniq = function() { return new (require('./derived/uniq-list').UniqList)(this); }; Mappable.prototype.includes = function(x) { return IncludesFold.includes(this, x); }; Mappable.prototype.any = function(f) { return AnyFold.any(this, f); }; Mappable.prototype.min = function() { return MinMaxFold.min(this); }; Mappable.prototype.max = function() { return MinMaxFold.max(this); }; Mappable.prototype.sum = function() { return SumFold.sum(this); }; return Mappable; })(Enumerable); Sequence = (function(superClass) { extend(Sequence, superClass); function Sequence() { return Sequence.__super__.constructor.apply(this, arguments); } Sequence.prototype.isSequence = true; Sequence.prototype.mapPairs = function(f) { return this.enumerate().mapPairs(f); }; Sequence.prototype.flatMapPairs = function(f) { return this.enumerate().flatMapPairs(f); }; Sequence.prototype.take = function(x) { return new (require('./derived/taken-list').TakenList)(this, x); }; Sequence.prototype.concat = function() { var lists; lists = 1 <= arguments.length ? slice.call(arguments, 0) : []; return new (require('./derived/catted-list').CattedList)([this].concat(lists)); }; Sequence.prototype.indexOf = function(value) { return IndexOfFold.indexOf(this, value); }; Sequence.prototype.join = function(joiner) { return folds.join(this, joiner); }; Sequence.prototype.apply = function(f) { return folds.apply(this, f); }; Sequence.prototype.scanl = function(memo, f) { return folds.scanl(this, memo, f); }; Sequence.prototype.foldl = function(memo, f) { return folds.foldl(this, memo, f); }; Sequence.prototype.flatScanl = function(memo, f) { return folds.flatScanl(this, memo, f); }; Sequence.prototype.flatFoldl = function(memo, f) { return folds.flatFoldl(this, memo, f); }; return Sequence; })(Mappable); module.exports = { Enumerable: Enumerable, Mappable: Mappable, Sequence: Sequence }; }).call(this);