UNPKG

beautylog

Version:

beautiful logging, TypeScript ready

1,553 lines (1,331 loc) 821 kB
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ var beautylog = require("./index.js"); console.log("*** start browser console test (Might look weird in OS console and travis log...) ***"); beautylog.log("hello"); console.log("*** end browser console test ***"); },{"./index.js":2}],2:[function(require,module,exports){ /// <reference path="./index.ts" /> var BeautylogPlugins; (function (BeautylogPlugins) { BeautylogPlugins.init = function () { var plugins = { smartenv: require("smartenv") }; return plugins; }; })(BeautylogPlugins || (BeautylogPlugins = {})); /// <reference path="./index.ts" /> var tableHelpers = { makeRow: function (cellCounterArg, colorArg) { if (cellCounterArg === void 0) { cellCounterArg = 2; } if (colorArg === void 0) { colorArg = "cyan"; } var rowArray = []; for (var i = 0; i < (cellCounterArg); i++) { rowArray.push(String(i + 1).cyan); } return rowArray; } }; var ConsoleTable = (function () { function ConsoleTable(tableTypeArg, tableHeadArrayArg) { if (tableHeadArrayArg === void 0) { tableHeadArrayArg = tableHelpers.makeRow(); } switch (tableTypeArg) { case "checks": this.tableHead = ['Check Item:'.cyan, 'Status:'.cyan]; break; case "custom": this.tableHead = tableHeadArrayArg; break; default: break; } this.rows = []; this.type = tableTypeArg; } ConsoleTable.prototype.push = function (row) { this.rows.push(row); }; ConsoleTable.prototype.print = function () { var table = new BeautylogOsTable.cliTable({ head: this.tableHead }); for (var row in this.rows) { if (this.rows[row][1] == "success") { this.rows[row][1] = ' '.bgGreen + ' ' + this.rows[row][1]; } else if (this.rows[row][1] == "error") { this.rows[row][1] = ' '.bgRed + ' ' + this.rows[row][1]; } table.push(this.rows[row]); } ; console.log(table.toString()); }; return ConsoleTable; })(); /// <reference path="./index.ts" /> var BeautylogNode; (function (BeautylogNode) { function init() { var colors = require("colors"); var clc = require("cli-color"); var beautylogNode = {}; //object to append to all public facing functions var localBl; // object to append to all private params and functions localBl = {}; localBl.dirPrefix = clc.bgXterm(39).xterm(231).bold(' DIR ') + ' '; localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' '; localBl.infoPrefix = clc.bgXterm(198).xterm(231).bold(' INFO ') + ' '; localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' '; localBl.okPrefix = ' '.bgGreen + ' OK! '.bgBlack.green.bold + ' '; localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' '; localBl.warnPrefix = ' '.bgYellow + ' Warn: '.bgBlack.yellow.bold + ' '; /** * * @param logText * @param logType * @returns {boolean} */ beautylogNode.log = function (logText, logType) { if (logText === void 0) { logText = 'empty log'; } if (logType === void 0) { logType = 'normal'; } try { switch (logType) { case 'dir': logText = localBl.dirPrefix + clc.xterm(26)(logText); break; case 'error': logText = localBl.errorPrefix + logText.red.bold; break; case 'info': logText = localBl.infoPrefix + clc.xterm(198)(logText); break; case 'normal': logText = localBl.normalPrefix + logText.cyan.bold; break; case 'ok': logText = localBl.okPrefix + logText.bold; break; case 'success': logText = localBl.successPrefix + logText.green.bold; break; case 'warn': logText = localBl.warnPrefix + logText.bold; break; case 'log': default: logText.blue.bold; console.log(('unknown logType for "' + logText + '"').red.bold); break; } console.log(logText); return true; } catch (error) { console.log(localBl.errorPrefix + 'You seem to have tried logging something strange'.red.bold + error); return false; } }; /** * logs an directory to console * @param logText * @returns {boolean} */ beautylogNode.dir = function (logText) { return beautylogNode.log(logText, 'dir'); }; /** * logs an error to console * @param logText * @returns {boolean} */ beautylogNode.error = function (logText) { return beautylogNode.log(logText, 'error'); }; /** * logs an info to console * @param logText * @returns {boolean} */ beautylogNode.info = function (logText) { return beautylogNode.log(logText, 'info'); }; /** * logs an 'OK!' message to console * @param logText * @returns {boolean} */ beautylogNode.ok = function (logText) { return beautylogNode.log(logText, 'ok'); }; /** * logs a success to console * @param logText string to log as error * @returns {boolean} */ beautylogNode.success = function (logText) { return beautylogNode.log(logText, 'success'); }; /** * logs a 'warn:' message to console * @param logText string to log as error * @returns {boolean} */ beautylogNode.warn = function (logText) { return beautylogNode.log(logText, 'warn'); }; beautylogNode.table = BeautylogOsTable.init(); return beautylogNode; } BeautylogNode.init = init; })(BeautylogNode || (BeautylogNode = {})); /// <reference path="./index.ts" /> var BeautylogOsTable; (function (BeautylogOsTable) { function init() { BeautylogOsTable.cliTable = require("cli-table2"); var beautylogOsTable = {}; beautylogOsTable.new = function (typeArg, tableHeadArrayArg) { var newConsoleTable = new ConsoleTable(typeArg, tableHeadArrayArg); return newConsoleTable; }; return beautylogOsTable; } BeautylogOsTable.init = init; })(BeautylogOsTable || (BeautylogOsTable = {})); /// <reference path="./index.ts" /> var BeautylogBrowser; (function (BeautylogBrowser) { function init() { var beautylogBrowser = {}; beautylogBrowser.log = function (message) { console.log('%c Log: %c ' + message, "background:#42A5F5;color:#ffffff", "color:#42A5F5;"); }; beautylogBrowser.info = function (message) { console.log('%c Info: %c ' + message, 'background:#EC407A;color:#ffffff;', 'color:#EC407A;'); }; beautylogBrowser.ok = function (message) { console.log('%c OK: %c ' + message, "background:#000000;color:#8BC34A;", "color:#000000;"); }; beautylogBrowser.success = function (message) { console.log('%c Success: %c ' + message, "background:#8BC34A;color:#ffffff;", "color:#8BC34A;"); }; beautylogBrowser.warn = function (message) { console.log('%c Warn: %c ' + message, "background:#000000;color:#FB8C00;", "color:#000000;"); }; return beautylogBrowser; } BeautylogBrowser.init = init; })(BeautylogBrowser || (BeautylogBrowser = {})); /// <reference path="./typings/tsd.d.ts" /> /// <reference path="./beautylog.plugins.ts" /> /// <reference path="./beautylog.classes.ts" /> /// <reference path="./beautylog.node.ts" /> /// <reference path="./beautylog.node.table.ts" /> /// <reference path="./beautylog.browser.ts" /> var plugins = BeautylogPlugins.init(); var beautylog = (function () { switch (plugins.smartenv.getEnv().runtimeEnv) { case "node": var beautylogOs = BeautylogNode.init(); return beautylogOs; break; case "browser": var beautylogBrowser = BeautylogBrowser.init(); return beautylogBrowser; break; default: console.log("something is strange about the platform in which you try to use beautylog"); break; } })(); module.exports = beautylog; },{"cli-color":9,"cli-table2":122,"colors":142,"smartenv":150}],3:[function(require,module,exports){ 'use strict'; var object = require('es5-ext/object/valid-object') , stringifiable = require('es5-ext/object/validate-stringifiable-value') , forOf = require('es6-iterator/for-of'); module.exports = function (text, style) { var result = ''; text = stringifiable(text); object(style); forOf(text, function (char) { result += style[char] || char; }); return result; }; },{"es5-ext/object/valid-object":69,"es5-ext/object/validate-stringifiable-value":71,"es6-iterator/for-of":82}],4:[function(require,module,exports){ (function (process){ 'use strict'; var d = require('d') , assign = require('es5-ext/object/assign') , forEach = require('es5-ext/object/for-each') , map = require('es5-ext/object/map') , primitiveSet = require('es5-ext/object/primitive-set') , setPrototypeOf = require('es5-ext/object/set-prototype-of') , memoize = require('memoizee') , memoizeMethods = require('memoizee/methods') , sgr = require('./lib/sgr') , mods = sgr.mods , join = Array.prototype.join, defineProperty = Object.defineProperty , max = Math.max, min = Math.min , variantModes = primitiveSet('_fg', '_bg') , xtermMatch, getFn; // Some use cli-color as: console.log(clc.red('Error!')); // Which is inefficient as on each call it configures new clc object // with memoization we reuse once created object var memoized = memoize(function (scope, mod) { return defineProperty(getFn(), '_cliColorData', d(assign({}, scope._cliColorData, mod))); }); var proto = Object.create(Function.prototype, assign(map(mods, function (mod) { return d.gs(function () { return memoized(this, mod); }); }), memoizeMethods({ // xterm (255) color xterm: d(function (code) { code = isNaN(code) ? 255 : min(max(code, 0), 255); return defineProperty(getFn(), '_cliColorData', d(assign({}, this._cliColorData, { _fg: [xtermMatch ? xtermMatch[code] : ('38;5;' + code), 39] }))); }), bgXterm: d(function (code) { code = isNaN(code) ? 255 : min(max(code, 0), 255); return defineProperty(getFn(), '_cliColorData', d(assign({}, this._cliColorData, { _bg: [xtermMatch ? (xtermMatch[code] + 10) : ('48;5;' + code), 49] }))); }) }))); var getEndRe = memoize(function (code) { return new RegExp('\x1b\\[' + code + 'm', 'g'); }, { primitive: true }); if (process.platform === 'win32') xtermMatch = require('./lib/xterm-match'); getFn = function () { return setPrototypeOf(function self(/*…msg*/) { var start = '', end = '', msg = join.call(arguments, ' '), conf = self._cliColorData , hasAnsi = sgr.hasCSI(msg); forEach(conf, function (mod, key) { end = sgr(mod[1]) + end; start += sgr(mod[0]); if (hasAnsi) { msg = msg.replace(getEndRe(mod[1]), variantModes[key] ? sgr(mod[0]) : ''); } }, null, true); return start + msg + end; }, proto); }; module.exports = Object.defineProperties(getFn(), { xtermSupported: d(!xtermMatch), _cliColorData: d('', {}) }); }).call(this,require('_process')) },{"./lib/sgr":10,"./lib/xterm-match":12,"_process":149,"d":16,"es5-ext/object/assign":48,"es5-ext/object/for-each":54,"es5-ext/object/map":61,"es5-ext/object/primitive-set":64,"es5-ext/object/set-prototype-of":65,"memoizee":98,"memoizee/methods":105}],5:[function(require,module,exports){ 'use strict'; module.exports = '\x07'; },{}],6:[function(require,module,exports){ 'use strict'; var from = require('es5-ext/array/from') , iterable = require('es5-ext/iterable/validate-object') , stringifiable = require('es5-ext/object/validate-stringifiable') , pad = require('es5-ext/string/#/pad'); module.exports = function (rows/*, options*/) { var options = Object(arguments[1]), cols = []; return from(iterable(rows), function (row, index) { return from(iterable(row), function (str, index) { var col = cols[index]; if (!col) col = cols[index] = { width: 0 }; str = stringifiable(str); if (str.length > col.width) col.width = str.length; return str; }); }).map(function (row) { return row.map(function (item, index) { return pad.call(item, ' ', -cols[index].width); }).join((options.sep == null) ? ' | ' : options.sep); }).join('\n') + '\n'; }; },{"es5-ext/array/from":22,"es5-ext/iterable/validate-object":33,"es5-ext/object/validate-stringifiable":72,"es5-ext/string/#/pad":76}],7:[function(require,module,exports){ 'use strict'; module.exports = { screen: '\x1b[2J', screenLeft: '\x1b[1J', screenRight: '\x1b[J', line: '\x1b[2K', lineLeft: '\x1b[1K', lineRight: '\x1b[K' }; },{}],8:[function(require,module,exports){ 'use strict'; /* * get actual length of ANSI-formatted string */ var strip = require('./strip'); module.exports = function (str) { return strip(str).length; }; },{"./strip":119}],9:[function(require,module,exports){ 'use strict'; var d = require('d'); module.exports = Object.defineProperties(require('./bare'), { windowSize: d(require('./window-size')), erase: d(require('./erase')), move: d(require('./move')), beep: d(require('./beep')), columns: d(require('./columns')), strip: d(require('./strip')), getStrippedLength: d(require('./get-stripped-length')), slice: d(require('./slice')), throbber: d(require('./throbber')), reset: d(require('./reset')), art: d(require('./art')) }); },{"./art":3,"./bare":4,"./beep":5,"./columns":6,"./erase":7,"./get-stripped-length":8,"./move":13,"./reset":117,"./slice":118,"./strip":119,"./throbber":120,"./window-size":121,"d":16}],10:[function(require,module,exports){ 'use strict'; /* CSI - control sequence introducer */ /* SGR - set graphic rendition */ var assign = require('es5-ext/object/assign') , includes = require('es5-ext/string/#/contains') , forOwn = require('es5-ext/object/for-each') , onlyKey = require('es5-ext/object/first-key') , forEachRight = require('es5-ext/array/#/for-each-right') , uniq = require('es5-ext/array/#/uniq.js'); var CSI = '\x1b['; var sgr = function (code) { return CSI + code + 'm'; }; sgr.CSI = CSI; var mods = assign({ // Style bold: { _bold: [1, 22] }, italic: { _italic: [3, 23] }, underline: { _underline: [4, 24] }, blink: { _blink: [5, 25] }, inverse: { _inverse: [7, 27] }, strike: { _strike: [9, 29] } // Color }, ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'] .reduce(function (obj, color, index) { // foreground obj[color] = { _fg: [30 + index, 39] }; obj[color + 'Bright'] = { _fg: [90 + index, 39] }; // background obj['bg' + color[0].toUpperCase() + color.slice(1)] = { _bg: [40 + index, 49] }; obj['bg' + color[0].toUpperCase() + color.slice(1) + 'Bright'] = { _bg: [100 + index, 49] }; return obj; }, {})); sgr.mods = mods; sgr.openers = {}; sgr.closers = {}; forOwn(mods, function (mod) { var modPair = mod[onlyKey(mod)]; sgr.openers[modPair[0]] = modPair; sgr.closers[modPair[1]] = modPair; }); sgr.openStyle = function (mods, code) { mods.push(sgr.openers[code]); }; sgr.closeStyle = function (mods, code) { forEachRight.call(mods, function (modPair, index) { if (modPair[1] === code) { mods.splice(index, 1); } }); }; /* prepend openers */ sgr.prepend = function (mods) { return mods.map(function (modPair, key) { return sgr(modPair[0]); }); }; /* complete non-closed openers with corresponding closers */ sgr.complete = function (mods, closerCodes) { closerCodes.forEach(function (code) { sgr.closeStyle(mods, code); }); // mods must be closed from the last opened to first opened mods = mods.reverse(); mods = mods.map(function (modPair, key) { return modPair[1]; }); // one closer can close many openers (31, 32 -> 39) mods = uniq.call(mods); return mods.map(sgr); }; var hasCSI = function (str) { return includes.call(str, CSI); }; sgr.hasCSI = hasCSI; var extractCode = function (csi) { var code = csi.slice(2, -1); code = Number(code); return code; }; sgr.extractCode = extractCode; module.exports = sgr; },{"es5-ext/array/#/for-each-right":20,"es5-ext/array/#/uniq.js":21,"es5-ext/object/assign":48,"es5-ext/object/first-key":53,"es5-ext/object/for-each":54,"es5-ext/string/#/contains":73}],11:[function(require,module,exports){ 'use strict'; module.exports = [ "000000", "800000", "008000", "808000", "000080", "800080", "008080", "c0c0c0", "808080", "ff0000", "00ff00", "ffff00", "0000ff", "ff00ff", "00ffff", "ffffff", "000000", "00005f", "000087", "0000af", "0000d7", "0000ff", "005f00", "005f5f", "005f87", "005faf", "005fd7", "005fff", "008700", "00875f", "008787", "0087af", "0087d7", "0087ff", "00af00", "00af5f", "00af87", "00afaf", "00afd7", "00afff", "00d700", "00d75f", "00d787", "00d7af", "00d7d7", "00d7ff", "00ff00", "00ff5f", "00ff87", "00ffaf", "00ffd7", "00ffff", "5f0000", "5f005f", "5f0087", "5f00af", "5f00d7", "5f00ff", "5f5f00", "5f5f5f", "5f5f87", "5f5faf", "5f5fd7", "5f5fff", "5f8700", "5f875f", "5f8787", "5f87af", "5f87d7", "5f87ff", "5faf00", "5faf5f", "5faf87", "5fafaf", "5fafd7", "5fafff", "5fd700", "5fd75f", "5fd787", "5fd7af", "5fd7d7", "5fd7ff", "5fff00", "5fff5f", "5fff87", "5fffaf", "5fffd7", "5fffff", "870000", "87005f", "870087", "8700af", "8700d7", "8700ff", "875f00", "875f5f", "875f87", "875faf", "875fd7", "875fff", "878700", "87875f", "878787", "8787af", "8787d7", "8787ff", "87af00", "87af5f", "87af87", "87afaf", "87afd7", "87afff", "87d700", "87d75f", "87d787", "87d7af", "87d7d7", "87d7ff", "87ff00", "87ff5f", "87ff87", "87ffaf", "87ffd7", "87ffff", "af0000", "af005f", "af0087", "af00af", "af00d7", "af00ff", "af5f00", "af5f5f", "af5f87", "af5faf", "af5fd7", "af5fff", "af8700", "af875f", "af8787", "af87af", "af87d7", "af87ff", "afaf00", "afaf5f", "afaf87", "afafaf", "afafd7", "afafff", "afd700", "afd75f", "afd787", "afd7af", "afd7d7", "afd7ff", "afff00", "afff5f", "afff87", "afffaf", "afffd7", "afffff", "d70000", "d7005f", "d70087", "d700af", "d700d7", "d700ff", "d75f00", "d75f5f", "d75f87", "d75faf", "d75fd7", "d75fff", "d78700", "d7875f", "d78787", "d787af", "d787d7", "d787ff", "d7af00", "d7af5f", "d7af87", "d7afaf", "d7afd7", "d7afff", "d7d700", "d7d75f", "d7d787", "d7d7af", "d7d7d7", "d7d7ff", "d7ff00", "d7ff5f", "d7ff87", "d7ffaf", "d7ffd7", "d7ffff", "ff0000", "ff005f", "ff0087", "ff00af", "ff00d7", "ff00ff", "ff5f00", "ff5f5f", "ff5f87", "ff5faf", "ff5fd7", "ff5fff", "ff8700", "ff875f", "ff8787", "ff87af", "ff87d7", "ff87ff", "ffaf00", "ffaf5f", "ffaf87", "ffafaf", "ffafd7", "ffafff", "ffd700", "ffd75f", "ffd787", "ffd7af", "ffd7d7", "ffd7ff", "ffff00", "ffff5f", "ffff87", "ffffaf", "ffffd7", "ffffff", "080808", "121212", "1c1c1c", "262626", "303030", "3a3a3a", "444444", "4e4e4e", "585858", "626262", "6c6c6c", "767676", "808080", "8a8a8a", "949494", "9e9e9e", "a8a8a8", "b2b2b2", "bcbcbc", "c6c6c6", "d0d0d0", "dadada", "e4e4e4", "eeeeee" ]; },{}],12:[function(require,module,exports){ 'use strict'; var push = Array.prototype.push, reduce = Array.prototype.reduce, abs = Math.abs , colors, match, result, i; colors = require('./xterm-colors').map(function (color) { return { r: parseInt(color.slice(0, 2), 16), g: parseInt(color.slice(2, 4), 16), b: parseInt(color.slice(4), 16) }; }); match = colors.slice(0, 16); module.exports = result = []; i = 0; while (i < 8) { result.push(30 + i++); } i = 0; while (i < 8) { result.push(90 + i++); } push.apply(result, colors.slice(16).map(function (data) { var index, diff = Infinity; match.every(function (match, i) { var ndiff = reduce.call('rgb', function (diff, channel) { diff += abs(match[channel] - data[channel]); return diff; }, 0); if (ndiff < diff) { index = i; diff = ndiff; } return ndiff; }); return result[index]; })); },{"./xterm-colors":11}],13:[function(require,module,exports){ 'use strict'; var d = require('d') , trunc = require('es5-ext/math/trunc') , up, down, right, left , abs = Math.abs, floor = Math.floor, max = Math.max; var getMove = function (control) { return function (num) { num = isNaN(num) ? 0 : max(floor(num), 0); return num ? ('\x1b[' + num + control) : ''; }; }; module.exports = Object.defineProperties(function (x, y) { x = isNaN(x) ? 0 : floor(x); y = isNaN(y) ? 0 : floor(y); return ((x > 0) ? right(x) : left(-x)) + ((y > 0) ? down(y) : up(-y)); }, { up: d(up = getMove('A')), down: d(down = getMove('B')), right: d(right = getMove('C')), left: d(left = getMove('D')), to: d(function (x, y) { x = isNaN(x) ? 1 : (max(floor(x), 0) + 1); y = isNaN(y) ? 1 : (max(floor(y), 0) + 1); return '\x1b[' + y + ';' + x + 'H'; }), lines: d(function (n) { var dir; n = trunc(n) || 0; dir = (n >= 0) ? 'E' : 'F'; n = floor(abs(n)); return '\x1b[' + n + dir; }) }); },{"d":16,"es5-ext/math/trunc":37}],14:[function(require,module,exports){ 'use strict'; module.exports = function () { return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; }; },{}],15:[function(require,module,exports){ 'use strict'; var copy = require('es5-ext/object/copy') , map = require('es5-ext/object/map') , callable = require('es5-ext/object/valid-callable') , validValue = require('es5-ext/object/valid-value') , bind = Function.prototype.bind, defineProperty = Object.defineProperty , hasOwnProperty = Object.prototype.hasOwnProperty , define; define = function (name, desc, bindTo) { var value = validValue(desc) && callable(desc.value), dgs; dgs = copy(desc); delete dgs.writable; delete dgs.value; dgs.get = function () { if (hasOwnProperty.call(this, name)) return value; desc.value = bind.call(value, (bindTo == null) ? this : this[bindTo]); defineProperty(this, name, desc); return this[name]; }; return dgs; }; module.exports = function (props/*, bindTo*/) { var bindTo = arguments[1]; return map(props, function (desc, name) { return define(name, desc, bindTo); }); }; },{"es5-ext/object/copy":51,"es5-ext/object/map":61,"es5-ext/object/valid-callable":68,"es5-ext/object/valid-value":70}],16:[function(require,module,exports){ 'use strict'; var assign = require('es5-ext/object/assign') , normalizeOpts = require('es5-ext/object/normalize-options') , isCallable = require('es5-ext/object/is-callable') , contains = require('es5-ext/string/#/contains') , d; d = module.exports = function (dscr, value/*, options*/) { var c, e, w, options, desc; if ((arguments.length < 2) || (typeof dscr !== 'string')) { options = value; value = dscr; dscr = null; } else { options = arguments[2]; } if (dscr == null) { c = w = true; e = false; } else { c = contains.call(dscr, 'c'); e = contains.call(dscr, 'e'); w = contains.call(dscr, 'w'); } desc = { value: value, configurable: c, enumerable: e, writable: w }; return !options ? desc : assign(normalizeOpts(options), desc); }; d.gs = function (dscr, get, set/*, options*/) { var c, e, options, desc; if (typeof dscr !== 'string') { options = set; set = get; get = dscr; dscr = null; } else { options = arguments[3]; } if (get == null) { get = undefined; } else if (!isCallable(get)) { options = get; get = set = undefined; } else if (set == null) { set = undefined; } else if (!isCallable(set)) { options = set; set = undefined; } if (dscr == null) { c = true; e = false; } else { c = contains.call(dscr, 'c'); e = contains.call(dscr, 'e'); } desc = { get: get, set: set, configurable: c, enumerable: e }; return !options ? desc : assign(normalizeOpts(options), desc); }; },{"es5-ext/object/assign":48,"es5-ext/object/is-callable":56,"es5-ext/object/normalize-options":63,"es5-ext/string/#/contains":73}],17:[function(require,module,exports){ 'use strict'; var map = require('es5-ext/object/map') , isCallable = require('es5-ext/object/is-callable') , validValue = require('es5-ext/object/valid-value') , contains = require('es5-ext/string/#/contains') , call = Function.prototype.call , defineProperty = Object.defineProperty , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor , getPrototypeOf = Object.getPrototypeOf , hasOwnProperty = Object.prototype.hasOwnProperty , cacheDesc = { configurable: false, enumerable: false, writable: false, value: null } , define; define = function (name, options) { var value, dgs, cacheName, desc, writable = false, resolvable , flat; options = Object(validValue(options)); cacheName = options.cacheName; flat = options.flat; if (cacheName == null) cacheName = name; delete options.cacheName; value = options.value; resolvable = isCallable(value); delete options.value; dgs = { configurable: Boolean(options.configurable), enumerable: Boolean(options.enumerable) }; if (name !== cacheName) { dgs.get = function () { if (hasOwnProperty.call(this, cacheName)) return this[cacheName]; cacheDesc.value = resolvable ? call.call(value, this, options) : value; cacheDesc.writable = writable; defineProperty(this, cacheName, cacheDesc); cacheDesc.value = null; if (desc) defineProperty(this, name, desc); return this[cacheName]; }; } else if (!flat) { dgs.get = function self() { var ownDesc; if (hasOwnProperty.call(this, name)) { ownDesc = getOwnPropertyDescriptor(this, name); // It happens in Safari, that getter is still called after property // was defined with a value, following workarounds that if (ownDesc.hasOwnProperty('value')) return ownDesc.value; if ((typeof ownDesc.get === 'function') && (ownDesc.get !== self)) { return ownDesc.get.call(this); } return value; } desc.value = resolvable ? call.call(value, this, options) : value; defineProperty(this, name, desc); desc.value = null; return this[name]; }; } else { dgs.get = function self() { var base = this, ownDesc; if (hasOwnProperty.call(this, name)) { // It happens in Safari, that getter is still called after property // was defined with a value, following workarounds that ownDesc = getOwnPropertyDescriptor(this, name); if (ownDesc.hasOwnProperty('value')) return ownDesc.value; if ((typeof ownDesc.get === 'function') && (ownDesc.get !== self)) { return ownDesc.get.call(this); } } while (!hasOwnProperty.call(base, name)) base = getPrototypeOf(base); desc.value = resolvable ? call.call(value, base, options) : value; defineProperty(base, name, desc); desc.value = null; return base[name]; }; } dgs.set = function (value) { dgs.get.call(this); this[cacheName] = value; }; if (options.desc) { desc = { configurable: contains.call(options.desc, 'c'), enumerable: contains.call(options.desc, 'e') }; if (cacheName === name) { desc.writable = contains.call(options.desc, 'w'); desc.value = null; } else { writable = contains.call(options.desc, 'w'); desc.get = dgs.get; desc.set = dgs.set; } delete options.desc; } else if (cacheName === name) { desc = { configurable: Boolean(options.configurable), enumerable: Boolean(options.enumerable), writable: Boolean(options.writable), value: null }; } delete options.configurable; delete options.enumerable; delete options.writable; return dgs; }; module.exports = function (props) { return map(props, function (desc, name) { return define(name, desc); }); }; },{"es5-ext/object/is-callable":56,"es5-ext/object/map":61,"es5-ext/object/valid-value":70,"es5-ext/string/#/contains":73}],18:[function(require,module,exports){ // Inspired by Google Closure: // http://closure-library.googlecode.com/svn/docs/ // closure_goog_array_array.js.html#goog.array.clear 'use strict'; var value = require('../../object/valid-value'); module.exports = function () { value(this).length = 0; return this; }; },{"../../object/valid-value":70}],19:[function(require,module,exports){ 'use strict'; var toPosInt = require('../../number/to-pos-integer') , value = require('../../object/valid-value') , indexOf = Array.prototype.indexOf , hasOwnProperty = Object.prototype.hasOwnProperty , abs = Math.abs, floor = Math.floor; module.exports = function (searchElement/*, fromIndex*/) { var i, l, fromIndex, val; if (searchElement === searchElement) { //jslint: ignore return indexOf.apply(this, arguments); } l = toPosInt(value(this).length); fromIndex = arguments[1]; if (isNaN(fromIndex)) fromIndex = 0; else if (fromIndex >= 0) fromIndex = floor(fromIndex); else fromIndex = toPosInt(this.length) - floor(abs(fromIndex)); for (i = fromIndex; i < l; ++i) { if (hasOwnProperty.call(this, i)) { val = this[i]; if (val !== val) return i; //jslint: ignore } } return -1; }; },{"../../number/to-pos-integer":46,"../../object/valid-value":70}],20:[function(require,module,exports){ 'use strict'; var toPosInt = require('../../number/to-pos-integer') , callable = require('../../object/valid-callable') , value = require('../../object/valid-value') , hasOwnProperty = Object.prototype.hasOwnProperty , call = Function.prototype.call; module.exports = function (cb/*, thisArg*/) { var i, self, thisArg; self = Object(value(this)); callable(cb); thisArg = arguments[1]; for (i = (toPosInt(self.length) - 1); i >= 0; --i) { if (hasOwnProperty.call(self, i)) call.call(cb, thisArg, self[i], i, self); } }; },{"../../number/to-pos-integer":46,"../../object/valid-callable":68,"../../object/valid-value":70}],21:[function(require,module,exports){ 'use strict'; var indexOf = require('./e-index-of') , filter = Array.prototype.filter , isFirst; isFirst = function (value, index) { return indexOf.call(this, value) === index; }; module.exports = function () { return filter.call(this, isFirst, this); }; },{"./e-index-of":19}],22:[function(require,module,exports){ 'use strict'; module.exports = require('./is-implemented')() ? Array.from : require('./shim'); },{"./is-implemented":23,"./shim":24}],23:[function(require,module,exports){ 'use strict'; module.exports = function () { var from = Array.from, arr, result; if (typeof from !== 'function') return false; arr = ['raz', 'dwa']; result = from(arr); return Boolean(result && (result !== arr) && (result[1] === 'dwa')); }; },{}],24:[function(require,module,exports){ 'use strict'; var iteratorSymbol = require('es6-symbol').iterator , isArguments = require('../../function/is-arguments') , isFunction = require('../../function/is-function') , toPosInt = require('../../number/to-pos-integer') , callable = require('../../object/valid-callable') , validValue = require('../../object/valid-value') , isString = require('../../string/is-string') , isArray = Array.isArray, call = Function.prototype.call , desc = { configurable: true, enumerable: true, writable: true, value: null } , defineProperty = Object.defineProperty; module.exports = function (arrayLike/*, mapFn, thisArg*/) { var mapFn = arguments[1], thisArg = arguments[2], Constructor, i, j, arr, l, code, iterator , result, getIterator, value; arrayLike = Object(validValue(arrayLike)); if (mapFn != null) callable(mapFn); if (!this || (this === Array) || !isFunction(this)) { // Result: Plain array if (!mapFn) { if (isArguments(arrayLike)) { // Source: Arguments l = arrayLike.length; if (l !== 1) return Array.apply(null, arrayLike); arr = new Array(1); arr[0] = arrayLike[0]; return arr; } if (isArray(arrayLike)) { // Source: Array arr = new Array(l = arrayLike.length); for (i = 0; i < l; ++i) arr[i] = arrayLike[i]; return arr; } } arr = []; } else { // Result: Non plain array Constructor = this; } if (!isArray(arrayLike)) { if ((getIterator = arrayLike[iteratorSymbol]) !== undefined) { // Source: Iterator iterator = callable(getIterator).call(arrayLike); if (Constructor) arr = new Constructor(); result = iterator.next(); i = 0; while (!result.done) { value = mapFn ? call.call(mapFn, thisArg, result.value, i) : result.value; if (!Constructor) { arr[i] = value; } else { desc.value = value; defineProperty(arr, i, desc); } result = iterator.next(); ++i; } l = i; } else if (isString(arrayLike)) { // Source: String l = arrayLike.length; if (Constructor) arr = new Constructor(); for (i = 0, j = 0; i < l; ++i) { value = arrayLike[i]; if ((i + 1) < l) { code = value.charCodeAt(0); if ((code >= 0xD800) && (code <= 0xDBFF)) value += arrayLike[++i]; } value = mapFn ? call.call(mapFn, thisArg, value, j) : value; if (!Constructor) { arr[j] = value; } else { desc.value = value; defineProperty(arr, j, desc); } ++j; } l = j; } } if (l === undefined) { // Source: array or array-like l = toPosInt(arrayLike.length); if (Constructor) arr = new Constructor(l); for (i = 0; i < l; ++i) { value = mapFn ? call.call(mapFn, thisArg, arrayLike[i], i) : arrayLike[i]; if (!Constructor) { arr[i] = value; } else { desc.value = value; defineProperty(arr, i, desc); } } } if (Constructor) { desc.value = null; arr.length = l; } return arr; }; },{"../../function/is-arguments":29,"../../function/is-function":30,"../../number/to-pos-integer":46,"../../object/valid-callable":68,"../../object/valid-value":70,"../../string/is-string":80,"es6-symbol":40}],25:[function(require,module,exports){ 'use strict'; var from = require('./from') , isArray = Array.isArray; module.exports = function (arrayLike) { return isArray(arrayLike) ? arrayLike : from(arrayLike); }; },{"./from":22}],26:[function(require,module,exports){ 'use strict'; var assign = require('../object/assign') , captureStackTrace = Error.captureStackTrace; exports = module.exports = function (message/*, code, ext*/) { var err = new Error(), code = arguments[1], ext = arguments[2]; if (ext == null) { if (code && (typeof code === 'object')) { ext = code; code = null; } } if (ext != null) assign(err, ext); err.message = String(message); if (code != null) err.code = String(code); if (captureStackTrace) captureStackTrace(err, exports); return err; }; },{"../object/assign":48}],27:[function(require,module,exports){ 'use strict'; var callable = require('../../object/valid-callable') , aFrom = require('../../array/from') , apply = Function.prototype.apply, call = Function.prototype.call , callFn = function (arg, fn) { return call.call(fn, this, arg); }; module.exports = function (fn/*, …fnn*/) { var fns, first; if (!fn) callable(fn); fns = [this].concat(aFrom(arguments)); fns.forEach(callable); fns = fns.reverse(); first = fns[0]; fns = fns.slice(1); return function (arg) { return fns.reduce(callFn, apply.call(first, this, arguments)); }; }; },{"../../array/from":22,"../../object/valid-callable":68}],28:[function(require,module,exports){ 'use strict'; var toPosInt = require('../number/to-pos-integer') , test = function (a, b) {}, desc, defineProperty , generate, mixin; try { Object.defineProperty(test, 'length', { configurable: true, writable: false, enumerable: false, value: 1 }); } catch (ignore) {} if (test.length === 1) { // ES6 desc = { configurable: true, writable: false, enumerable: false }; defineProperty = Object.defineProperty; module.exports = function (fn, length) { length = toPosInt(length); if (fn.length === length) return fn; desc.value = length; return defineProperty(fn, 'length', desc); }; } else { mixin = require('../object/mixin'); generate = (function () { var cache = []; return function (l) { var args, i = 0; if (cache[l]) return cache[l]; args = []; while (l--) args.push('a' + (++i).toString(36)); return new Function('fn', 'return function (' + args.join(', ') + ') { return fn.apply(this, arguments); };'); }; }()); module.exports = function (src, length) { var target; length = toPosInt(length); if (src.length === length) return src; target = generate(length)(src); try { mixin(target, src); } catch (ignore) {} return target; }; } },{"../number/to-pos-integer":46,"../object/mixin":62}],29:[function(require,module,exports){ 'use strict'; var toString = Object.prototype.toString , id = toString.call((function () { return arguments; }())); module.exports = function (x) { return (toString.call(x) === id); }; },{}],30:[function(require,module,exports){ 'use strict'; var toString = Object.prototype.toString , id = toString.call(require('./noop')); module.exports = function (f) { return (typeof f === "function") && (toString.call(f) === id); }; },{"./noop":31}],31:[function(require,module,exports){ 'use strict'; module.exports = function () {}; },{}],32:[function(require,module,exports){ 'use strict'; var iteratorSymbol = require('es6-symbol').iterator , isArrayLike = require('../object/is-array-like'); module.exports = function (x) { if (x == null) return false; if (typeof x[iteratorSymbol] === 'function') return true; return isArrayLike(x); }; },{"../object/is-array-like":55,"es6-symbol":40}],33:[function(require,module,exports){ 'use strict'; var isObject = require('../object/is-object') , is = require('./is'); module.exports = function (x) { if (is(x) && isObject(x)) return x; throw new TypeError(x + " is not an iterable or array-like object"); }; },{"../object/is-object":57,"./is":32}],34:[function(require,module,exports){ 'use strict'; module.exports = require('./is-implemented')() ? Math.sign : require('./shim'); },{"./is-implemented":35,"./shim":36}],35:[function(require,module,exports){ 'use strict'; module.exports = function () { var sign = Math.sign; if (typeof sign !== 'function') return false; return ((sign(10) === 1) && (sign(-20) === -1)); }; },{}],36:[function(require,module,exports){ 'use strict'; module.exports = function (value) { value = Number(value); if (isNaN(value) || (value === 0)) return value; return (value > 0) ? 1 : -1; }; },{}],37:[function(require,module,exports){ 'use strict'; module.exports = require('./is-implemented')() ? Math.trunc : require('./shim'); },{"./is-implemented":38,"./shim":39}],38:[function(require,module,exports){ 'use strict'; module.exports = function () { var trunc = Math.trunc; if (typeof trunc !== 'function') return false; return (trunc(13.67) === 13) && (trunc(-13.67) === -13); }; },{}],39:[function(require,module,exports){ 'use strict'; var floor = Math.floor; module.exports = function (x) { if (isNaN(x)) return NaN; x = Number(x); if (x === 0) return x; if (x === Infinity) return Infinity; if (x === -Infinity) return -Infinity; if (x > 0) return floor(x); return -floor(-x); }; },{}],40:[function(require,module,exports){ 'use strict'; module.exports = require('./is-implemented')() ? Symbol : require('./polyfill'); },{"./is-implemented":41,"./polyfill":43}],41:[function(require,module,exports){ 'use strict'; module.exports = function () { var symbol; if (typeof Symbol !== 'function') return false; symbol = Symbol('test symbol'); try { String(symbol); } catch (e) { return false; } if (typeof Symbol.iterator === 'symbol') return true; // Return 'true' for polyfills if (typeof Symbol.isConcatSpreadable !== 'object') return false; if (typeof Symbol.iterator !== 'object') return false; if (typeof Symbol.toPrimitive !== 'object') return false; if (typeof Symbol.toStringTag !== 'object') return false; if (typeof Symbol.unscopables !== 'object') return false; return true; }; },{}],42:[function(require,module,exports){ 'use strict'; module.exports = function (x) { return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false; }; },{}],43:[function(require,module,exports){ // ES2015 Symbol polyfill for environments that do not support it (or partially support it_ 'use strict'; var d = require('d') , validateSymbol = require('./validate-symbol') , create = Object.create, defineProperties = Object.defineProperties , defineProperty = Object.defineProperty, objPrototype = Object.prototype , NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create(null); if (typeof Symbol === 'function') NativeSymbol = Symbol; var generateName = (function () { var created = create(null); return function (desc) { var postfix = 0, name, ie11BugWorkaround; while (created[desc + (postfix || '')]) ++postfix; desc += (postfix || ''); created[desc] = true; name = '@@' + desc; defineProperty(objPrototype, name, d.gs(null, function (value) { // For IE11 issue see: // https://connect.microsoft.com/IE/feedbackdetail/view/1928508/ // ie11-broken-getters-on-dom-objects // https://github.com/medikoo/es6-symbol/issues/12 if (ie11BugWorkaround) return; ie11BugWorkaround = true; defineProperty(this, name, d(value)); ie11BugWorkaround = false; })); return name; }; }()); // Internal constructor (not one exposed) for creating Symbol instances. // This one is used to ensure that `someSymbol instanceof Symbol` always return false HiddenSymbol = function Symbol(description) { if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor'); return SymbolPolyfill(description); }; // Exposed `Symbol` constructor // (returns instances of HiddenSymbol) module.exports = SymbolPolyfill = function Symbol(description) { var symbol; if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor'); symbol = create(HiddenSymbol.prototype); description = (description === undefined ? '' : String(description)); return defineProperties(symbol, { __description__: d('', description), __name__: d('', generateName(description)) }); }; defineProperties(SymbolPolyfill, { for: d(function (key) { if (globalSymbols[key]) return globalSymbols[key]; return (globalSymbols[key] = SymbolPolyfill(String(key))); }), keyFor: d(function (s) { var key; validateSymbol(s); for (key in globalSymbols) if (globalSymbols[key] === s) return key; }), // If there's native implementation of given symbol, let's fallback to it // to ensure proper interoperability with other native functions e.g. Array.from hasInstance: d('', (NativeSymbol && NativeSymbol.hasInstance) || SymbolPolyfill('hasInstance')), isConcatSpreadable: d('', (NativeSymbol && NativeSymbol.isConcatSpreadable) || SymbolPolyfill('isConcatSpreadable')), iterator: d('', (NativeSymbol && NativeSymbol.iterator) || SymbolPolyfill('iterator')), match: d('', (NativeSymbol && NativeSymbol.match) || SymbolPolyfill('match')), replace: d('', (NativeSymbol && NativeSymbol.replace) || SymbolPolyfill('replace')), search: d('', (NativeSymbol && NativeSymbol.search) || SymbolPolyfill('search')), species: d('', (NativeSymbol && NativeSymbol.species) || SymbolPolyfill('species')), split: d('', (NativeSymbol && NativeSymbol.split) || SymbolPolyfill('split')), toPrimitive: d('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')), toStringTag: d('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')), unscopables: d('', (NativeSymbol && NativeSymbol.unscopables) || SymbolPolyfill('unscopables')) }); // Internal tweaks for real symbol producer defineProperties(HiddenSymbol.prototype, { constructor: d(SymbolPolyfill), toString: d('', function () { return this.__name__; }) }); // Proper implementation of methods exposed on Symbol.prototype // They won't be accessible on produced symbol instances as they derive from HiddenSymbol.prototype defineProperties(SymbolPolyfill.prototype, { toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), valueOf: d(function () { return validateSymbol(this); }) }); defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('', function () { return validateSymbol(this); })); defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d('c', 'Symbol')); // Proper implementaton of toPrimitive and toStringTag for returned symbol instances defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toStringTag, d('c', SymbolPolyfill.prototype[SymbolPolyfill.toStringTag])); // Note: It's important to define `toPrimitive` as last one, as some implementations // implement `toPrimitive` natively without implementing `toStringTag` (or other specified symbols) // And that may invoke error in definition flow: // See: https://github.com/medikoo/es6-symbol/issues/13#issuecomment-164146149 defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toPrimitive, d('c', SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive])); },{"./validate-symbol":44,"d":16}],44:[function(require,module,exports){ 'use strict'; var isSymbol = require('./is-symbol'); module.exports = function (value) { if (!isSymbol(value)) throw new TypeError(value + " is not a symbol"); return value; }; },{"./is-symbol":42}],45:[function(require,module,exports){ 'use strict'; var sign = require('../math/sign') , abs = Math.abs, floor = Math.floor; module.exports = function (value) { if (isNaN(value)) return 0; value = Number(value); if ((value === 0) || !isFinite(value)) return value; return sign(value) * floor(abs(value)); }; },{"../math/sign":34}],46:[function(require,module,exports){ 'use strict'; var toInteger = require('./to-integer') , max = Math.max; module.exports = function (value) { return max(0, toInteger(value)); }; },{"./to-integer":45}],47:[function(require,module,exports){ // Internal method, used by iteration functions. // Calls a function for each key-value pair found in object // Optionally takes compareFn to iterate object in specific order 'use strict'; var callable = require('./valid-callable') , value = require('./valid-value') , bind = Function.prototype.bind, call = Function.prototype.call, keys = Object.keys , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; module.exports = function (method, defVal) { return function (obj, cb/*, thisArg, compareFn*/) { var list, thisArg = arguments[2], compareFn = arguments[3]; obj = Object(value(obj)); callable(cb); list = keys(obj); if (compareFn) { list.sort((typeof compareFn === 'function') ? bind.call(compareFn, obj) : undefined); } if (typeof method !== 'function') method = list[method]; return call.call(method, list, function (key, index) { if (!propertyIsEnumerable.call(obj, key)) return defVal; return call.call(cb, thisArg, obj[key], key, obj, index); }); }; }; },{"./valid-callable":68,"./valid-value":70}],48:[function(require,module,exports){ 'use strict'; module.exports = require('./is-implemented')() ? Object.assign : require('./shim'); },{"./is-implemented":49,"./shim":50}],49:[function(require,module,exports){ 'use strict'; module.exports = function () { var assign = Object.assign, obj; if (typeof assign !== 'function') return false; obj = { foo: 'raz' }; assign(obj, { bar: 'dwa' }, { trzy: 'trzy' }); return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy'; }; },{}],50:[function(require,module,exports){ 'use strict'; var keys = require('../keys') , value = require('../valid-value') , max = Math.max; module.exports = function (dest, src/*, …srcn*/) { var error, i, l = max(arguments.length, 2), assign; dest = Object(value(dest)); assign = function (key) { try { dest[key] = src[key]; } catch (e) { if (!error) error = e; } }; for (i = 1; i < l; ++i) { src = arguments[i]; keys(src).forEach(assign); } if (error !== undefined) throw error; return dest; }; },{"../keys":58,"../valid-value":70}],51:[function(require,module,exports){ 'use strict'; var assign = require('./assign') , value = require('./valid-value'); module.exports = function (obj) { var copy = Object(value(obj)); if (copy !== obj) return copy; return assign({}, obj); }; },{"./assign":48,"./valid-value":70}],52:[function(require,module,exports){ // Workaround for http://code.google.com/p/v8/issues/detail?id=2804 'use strict'; var create = Object.create, shim; if (!require('./set-prototype-of/is-implemented')()) { shim = require('./set-prototype-of/shim'); } module.exports = (function () { var nullObject, props, desc; if (!shim) return create; if (shim.level !== 1) return c