-
Notifications
You must be signed in to change notification settings - Fork 7
/
boiler.min.js
1 lines (1 loc) · 7.29 KB
/
boiler.min.js
1
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.__boiler__=t()}}(function(){return function t(e,n,r){function o(i,s){if(!n[i]){if(!e[i]){var u="function"==typeof require&&require;if(!s&&u)return u(i,!0);if(a)return a(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[i]={exports:{}};e[i][0].call(f.exports,function(t){var n=e[i][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(t,e,n){var r=t("./statement");e.exports={testStatementDefinition:function(t){try{var e=new r(t),n=e.transactions,o="transaction"+(1===n.length?"":"s"),a="==============================================";console.log(a),console.log("Boiler: "+e.name()),console.log(n.length+" "+o+" parsed"),e.transactions.length>1?(console.log("First transaction:",n.first().toJSON()),console.log("Last transaction:",n.last().toJSON())):e.transactions.length&&console.log("Transaction:",n.first()),console.log(a)}catch(t){console.log("Could not create Statement: "+t.message)}}}},{"./statement":8}],2:[function(t,e,n){var r=t("./make-number");e.exports=function(t){var e=r(t);return null==e?null:Math.abs(e)}},{"./make-number":3}],3:[function(t,e,n){e.exports=function(t){var e=Number(String(t).replace(/[^\d\.-]/g,""));return e||null}},{}],4:[function(t,e,n){function r(t,e){function n(t){for(var e=0;e<r.length;e++)if(t.test(r[e]))return e}var r=e.match(/(D{1,2})|(M{1,4})|(Y{2,4})/g),a=RegExp(e.replace(/DD?/,"(\\d\\d?)").replace(/M{3,4}/,"([a-zA-Z]{3,})").replace(/MM?/,"(\\d\\d?)").replace(/Y{2,4}/,"(\\d{2,4})")),i=t.match(a);if(!i)throw new Error("Cannot parse: `"+t+"` with format: `"+e+"`");i=i.splice(1);var s=i[n(/D/)],u=function(){var t,e=n(/M/),a=r[e],s=i[e].toLowerCase();return t=a.length>2?o[a].indexOf(s):Number(s)-1}(),c=function(){var t=i[n(/Y/)];return t&&2===t.length&&(t="20"+t),t}();return{year:c,month:u,date:s}}var o={MMM:["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],MMMM:["january","february","march","april","may","june","july","august","september","october","november","december"]};e.exports=r},{}],5:[function(t,e,n){e.exports=function(t){return"function"==typeof t?t.call(t):t}},{}],6:[function(t,e,n){function r(t){this.element=t}function o(t){function e(t){return t.replace(/\s{2,}/g," ").trim()}return e(t.textContent)}function a(t,e){return Array.prototype.map.call(t,e)}function i(t){return t}r.prototype.rowsToArray=function(t,e){e=e||{};var n=e.processRow||i,r=e.processCell||i;return a(t,function(t,e,i){var s=a(t.cells,function(t,e,n){return r(o(t),e,n,t)});return n(s,e,i,t)})},r.prototype.toArray=function(){return this.rowsToArray(this.element.querySelectorAll("tbody tr"))},e.exports=r},{}],7:[function(t,e,n){function r(t,e){for(var n={},r=t.length-1;r>=0;r--)n[t[r]]=e[r];return n}e.exports=r},{}],8:[function(t,e,n){function r(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=o(t[e]));var n=a.prototype.rowsToArray(this.rows,{processRow:function(t){return this.createTransaction(i(this.columns,t))}.bind(this)});this.transactions=new u(n,this)}var o=t("./lib/result"),a=t("./lib/table"),i=t("./lib/weld"),s=t("./transaction"),u=t("./transactions");r.prototype.createTransaction=function(t){return t.dateString=t.date,t.dateFormat=this.dateFormat,delete t.date,new s(t)},r.prototype.name=function(){var t=this.institution+" Statement";return this.transactions.length?t+" "+this.transactions.last().getFormatted("date"):t},e.exports=r},{"./lib/result":5,"./lib/table":6,"./lib/weld":7,"./transaction":11,"./transactions":12}],9:[function(t,e,n){function r(t,e,n){n=n||{};var r=o(t,e);this.year=r.year,this.month=r.month,this.date=r.date,!this.year&&n.succeedingDate&&(this.year=this.calculateYear(n.succeedingDate))}var o=t("./lib/parse-date");r.prototype.toDate=function(){return Date.parse(this.year,this.month,this.date)?new Date(this.year,this.month,this.date):null},r.prototype.calculateYear=function(t){var e=t.getFullYear();return 0===t.getMonth()&&11===this.month&&e--,e},e.exports=r},{"./lib/parse-date":4}],10:[function(t,e,n){function r(t){this.dates=t}r.prototype.chronological=function(){var t=this.uniq();return t.length<2||this.compare(t[0],t[1])>=0},r.prototype.uniq=function(){function t(t){return e.some(function(e){return e.year===t.year&&e.month===t.month&&e.date===t.date})}for(var e=[],n=0;n<this.dates.length;n++){var r=this.dates[n];t(r)||e.push(r)}return e},r.prototype.compare=function(t,e){if(!(t.year&&e.year||11!==t.month||0!==e.month))return 1;if(t.year===e.year){if(t.month===e.month)return t.date>e.date?-1:t.date<e.date?1:0;if(t.month>e.month)return-1;if(t.month<e.month)return 1}return t.year>e.year?-1:t.year<e.year?1:void 0},e.exports=r},{}],11:[function(t,e,n){function r(t){this.attributes={};for(var e in t)t.hasOwnProperty(e)&&this.set(e,t[e]);this.get("date")||this.setDate(),this.get("amount")||this.setAmount()}function o(t,e){return t||-e}function a(t){function e(t){return String("00"+t).slice(-2)}var n=t.getFullYear(),r=e(t.getMonth()+1),o=e(t.getDate());return[n,r,o].join("-")}function i(t){return t}var s=t("./lib/number/make-number"),u=t("./lib/number/make-absolute-number"),c=t("./transaction-date");r.prototype.transformers={amount:s,balance:s,paidIn:u,paidOut:u,date:function(t){return t instanceof Date?(t.setHours(t.getHours()-t.getTimezoneOffset()/60),t):t}},r.prototype.formatters={date:a},r.prototype.set=function(t,e){var n=this.transformers[t]||i;this.attributes[t]=n(e)},r.prototype.get=function(t){return this.attributes[t]},r.prototype.getFormatted=function(t){var e=this.formatters[t]||i;return e(this.get(t))},r.prototype.toArray=function(t){return t=t||Object.keys(this.attributes),t.map(this.getFormatted.bind(this))},r.prototype.toJSON=function(t){t=t||Object.keys(this.attributes);for(var e={},n=t.length-1;n>=0;n--){var r=t[n];e[r]=this.getFormatted(r)}return e},r.prototype.setDate=function(t){t=t||{};var e=t.dateString||this.get("dateString"),n=t.dateFormat||this.get("dateFormat"),r=t.succeedingDate,o=new c(e,n,{succeedingDate:r});this.set("transactionDate",o),this.set("date",o.toDate())},r.prototype.setAmount=function(){var t=this.get("paidIn"),e=this.get("paidOut");this.set("amount",o(t,e))},e.exports=r},{"./lib/number/make-absolute-number":2,"./lib/number/make-number":3,"./transaction-date":9}],12:[function(t,e,n){function r(t,e){if(r._injectPrototypeMethods(t),!/Y{2,}/.test(e.dateFormat)){t.chronological()||(t=t.reverse());for(var n=e.date,o=t.length-1;o>=0;o--){var a=t[o];a.setDate({succeedingDate:n}),n=a.get("date")}}return t}var o=t("./transaction-dates");r.prototype.chronological=function(){function t(){var t=this.map(function(t){return t.get("transactionDate")});return new o(t)}return t.call(this).chronological()},r.prototype.first=function(){return this[0]},r.prototype.last=function(){return this[this.length-1]},r.prototype.toArray=function(t){return this.map(function(e){return e.toArray(t)})},r.prototype.toJSON=function(t){return this.map(function(e){return e.toJSON(t)})},r._injectPrototypeMethods=function(t){for(var e in this.prototype)this.prototype.hasOwnProperty(e)&&(t[e]=this.prototype[e])},e.exports=r},{"./transaction-dates":10}]},{},[1])(1)});