diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 319b5155..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,17 +0,0 @@ -Master: - -## Master Changes: - -- Transactions are immediately invoked as A+ promises - #470 -- Nested transactions automatically become savepoints, - with commit & rollback committing or rolling back to the savepoint -- Migrations are now wrapped in transactions where possible -- Using Pool2 in favor of generic-pool-redux -- Support for strong-oracle driver, #580 -- Subqueries in insert statements, #627 -- Allow mysql2 to use non-default port, #588 -- Support creating & dropping extensions in PostgreSQL, #540 -- Support for nested having, #572 -- CLI support for knexfiles that do not provide environment keys, #527 -- Added sqlite3 dialect version of whereRaw/andWhereRaw (#477). -- Support object syntax for joins, similar to "where" #743 \ No newline at end of file diff --git a/docs/assets/knex.js b/build/knex.js similarity index 75% rename from docs/assets/knex.js rename to build/knex.js index b9faaf13..f0332588 100644 --- a/docs/assets/knex.js +++ b/build/knex.js @@ -7,7 +7,7 @@ exports["Knex"] = factory(require("lodash"), require("bluebird")); else root["Knex"] = factory(root["_"], root["Promise"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_12__, __WEBPACK_EXTERNAL_MODULE_83__) { +})(this, function(__WEBPACK_EXTERNAL_MODULE_11__, __WEBPACK_EXTERNAL_MODULE_43__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -52,38 +52,18 @@ return /******/ (function(modules) { // webpackBootstrap /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(1) - - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - // Knex.js 0.8.0 - // -------------- - // (c) 2014 Tim Griesser - // Knex may be freely distributed under the MIT license. - // For details and documentation: - // http://knexjs.org - - module.exports = __webpack_require__(2) - -/***/ }, -/* 2 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - var Raw = __webpack_require__(3) - var warn = __webpack_require__(4).warn - var Client = __webpack_require__(5) + var Raw = __webpack_require__(1) + var warn = __webpack_require__(2).warn + var Client = __webpack_require__(3) - var makeClient = __webpack_require__(6) - var makeKnex = __webpack_require__(7) - var parseConnection = __webpack_require__(8) - var assign = __webpack_require__(14) + var makeClient = __webpack_require__(4) + var makeKnex = __webpack_require__(5) + var parseConnection = __webpack_require__(6) + var assign = __webpack_require__(27) function Knex(config) { if (typeof config === 'string') { @@ -94,7 +74,10 @@ return /******/ (function(modules) { // webpackBootstrap Dialect = makeClient(Client) } else { var clientName = config.client || config.dialect - Dialect = makeClient(__webpack_require__(9)("./" + (aliases[clientName] || clientName) + '/index.js')) + Dialect = makeClient(__webpack_require__(7)("./" + (aliases[clientName] || clientName) + '/index.js')) + } + if (typeof config.connection === 'string') { + config = assign({}, config, {connection: parseConnection(config.connection)}) } return makeKnex(new Dialect(config)) } @@ -111,6 +94,9 @@ return /******/ (function(modules) { // webpackBootstrap return new Knex(config) } + // Bluebird + Knex.Promise = __webpack_require__(8) + // The client names we'll allow in the `{name: lib}` pairing. var aliases = { 'mariadb' : 'maria', @@ -119,52 +105,56 @@ return /******/ (function(modules) { // webpackBootstrap 'sqlite' : 'sqlite3' }; + // Doing this ensures Browserify works. Still need to figure out + // the best way to do some of this. if (process.browser) { - __webpack_require__(10) + __webpack_require__(9) } module.exports = Knex - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 3 */ +/* 1 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // Raw // ------- - var _ = __webpack_require__(12) - var inherits = __webpack_require__(46) - var EventEmitter = __webpack_require__(42).EventEmitter - var assign = __webpack_require__(14); + var inherits = __webpack_require__(44) + var EventEmitter = __webpack_require__(41).EventEmitter + var assign = __webpack_require__(27) function Raw(client) { + this.client = client + this.sql = '' this.bindings = [] - this.client = client + this._cached = undefined + + // Todo: Deprecate + this._wrappedBefore = undefined + this._wrappedAfter = undefined + this._debug = client && client.options && client.options.debug } inherits(Raw, EventEmitter) assign(Raw.prototype, { - set: function(sql, bindings) { - if (sql && sql.toSQL) { - var output = sql.toSQL() - sql = output.sql - bindings = output.bindings - } - this.sql = sql + '' - this.bindings = ([]).concat(bindings === undefined ? [] : bindings) - this.interpolateBindings() - this._debug = void 0 + set: function(sql, bindings) { + this._cached = undefined + this.sql = sql + this.bindings = bindings return this }, // Wraps the current sql with `before` and `after`. wrap: function(before, after) { - this.sql = before + this.sql + after + this._cached = undefined + this._wrappedBefore = before + this._wrappedAfter = after return this }, @@ -173,73 +163,110 @@ return /******/ (function(modules) { // webpackBootstrap return this.toQuery() }, - // Ensure all Raw / builder bindings are mixed-in to the ? placeholders - // as appropriate. - interpolateBindings: function() { - var replacements = [] - this.bindings = _.reduce(this.bindings, function(accum, param, index) { - var innerBindings = [param] - if (param && param.toSQL) { - var result = this.splicer(param, index) - innerBindings = result.bindings - replacements.push(result.replacer) - } - return accum.concat(innerBindings) - }, [], this) - - // we run this in reverse order, because ? concats earlier in the - // query string will disrupt indices for later ones - this.sql = _.reduce(replacements.reverse(), function(accum, fn) { - return fn(accum) - }, this.sql.split('?')).join('?') - }, - - // Returns a replacer function that splices into the i'th - // ? in the sql string the inner raw's sql, - // and the bindings associated with it - splicer: function(raw, i) { - var obj = raw.toSQL() - - // the replacer function assumes that the sql has been - // already sql.split('?') and will be arr.join('?') - var replacer = function(arr) { - arr[i] = arr[i] + obj.sql + arr[i + 1] - arr.splice(i + 1, 1) - return arr - } - - return { - replacer: replacer, - bindings: obj.bindings - } - }, - // Returns the raw sql for the query. toSQL: function() { - return { - sql: this.sql, - method: 'raw', - bindings: this.bindings + if (this._cached) return this._cached + if (Array.isArray(this.bindings)) { + this._cached = replaceRawArrBindings(this) + } else if (this.bindings && typeof this.bindings === 'object') { + this._cached = replaceKeyBindings(this) + } else { + this._cached = { + method: 'raw', + sql: this.sql, + bindings: this.bindings + } } + if (this._wrappedBefore) { + this._cached.sql = this._wrappedBefore + this._cached.sql + } + if (this._wrappedAfter) { + this._cached.sql = this._cached.sql + this._wrappedAfter + } + return this._cached } }) + function replaceRawArrBindings(raw) { + var expectedBindings = raw.bindings.length + var values = raw.bindings + var client = raw.client + var index = 0; + var bindings = [] + + var sql = raw.sql.replace(/\?\??/g, function(match) { + var value = values[index++] + + if (value && typeof value.toSQL === 'function') { + var bindingSQL = value.toSQL() + bindings = bindings.concat(bindingSQL.bindings) + return bindingSQL.sql + } + + if (match === '??') { + return client.wrapIdentifier(value) + } + bindings.push(value) + return '?' + }) + + if (expectedBindings !== index) { + throw new Error('Expected ' + expectedBindings + ' bindings, saw ' + index) + } + + return { + method: 'raw', + sql: sql, + bindings: bindings + } + } + + function replaceKeyBindings(raw) { + var values = raw.bindings + var keys = Object.keys(values) + var client = raw.client + var sql = raw.sql, bindings = [] + + if (keys.length > 0) { + var regex = new RegExp('\\:(' + keys.join('|') + ')\\:?', 'g') + sql = raw.sql.replace(regex, function(match) { + if (match[match.length - 1] === ':') { + return client.wrapIdentifier(values[match.slice(1, -1)]) + } + var value = values[match.slice(1)] + if (value && typeof value.toSQL === 'function') { + var bindingSQL = value.toSQL() + bindings = bindings.concat(bindingSQL.bindings) + return bindingSQL.sql + } + bindings.push(value) + return '?' + }) + } + + return { + method: 'raw', + sql: sql, + bindings: bindings + } + } + // Allow the `Raw` object to be utilized with full access to the relevant // promise API. - __webpack_require__(15)(Raw) + __webpack_require__(12)(Raw) module.exports = Raw /***/ }, -/* 4 */ +/* 2 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - var _ = __webpack_require__(12) - var chalk = __webpack_require__(43) + var _ = __webpack_require__(11) + var chalk = __webpack_require__(40) var helpers = { @@ -285,47 +312,49 @@ return /******/ (function(modules) { // webpackBootstrap }; module.exports = helpers; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 5 */ +/* 3 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {'use strict'; + 'use strict'; - var Promise = __webpack_require__(16) - var helpers = __webpack_require__(4) + var Promise = __webpack_require__(8) + var helpers = __webpack_require__(2) - var Raw = __webpack_require__(3) - var Runner = __webpack_require__(17) - var Formatter = __webpack_require__(18) - var Transaction = __webpack_require__(19) + var Raw = __webpack_require__(1) + var Runner = __webpack_require__(13) + var Formatter = __webpack_require__(14) + var Transaction = __webpack_require__(15) - var QueryBuilder = __webpack_require__(20) - var QueryCompiler = __webpack_require__(21) + var QueryBuilder = __webpack_require__(16) + var QueryCompiler = __webpack_require__(17) - var SchemaBuilder = __webpack_require__(22) - var SchemaCompiler = __webpack_require__(23) - var TableBuilder = __webpack_require__(24) - var TableCompiler = __webpack_require__(25) - var ColumnBuilder = __webpack_require__(26) - var ColumnCompiler = __webpack_require__(27) + var SchemaBuilder = __webpack_require__(18) + var SchemaCompiler = __webpack_require__(19) + var TableBuilder = __webpack_require__(20) + var TableCompiler = __webpack_require__(21) + var ColumnBuilder = __webpack_require__(22) + var ColumnCompiler = __webpack_require__(23) - var Pool2 = __webpack_require__(44) - var inherits = __webpack_require__(46) - var EventEmitter = __webpack_require__(42).EventEmitter + var Pool2 = __webpack_require__(28) + var inherits = __webpack_require__(44) + var EventEmitter = __webpack_require__(41).EventEmitter + var SqlString = __webpack_require__(24) - var assign = __webpack_require__(14) - var uniqueId = __webpack_require__(28) - var cloneDeep = __webpack_require__(29) - var debug = __webpack_require__(48)('knex:client') - var debugQuery = __webpack_require__(48)('knex:query') + var assign = __webpack_require__(27) + var uniqueId = __webpack_require__(29) + var cloneDeep = __webpack_require__(30) + var debug = __webpack_require__(45)('knex:client') + var debugQuery = __webpack_require__(45)('knex:query') // The base client provides the general structure // for a dialect specific client object. function Client(config) { config = config || {} this.config = config + this.connectionSettings = cloneDeep(config.connection || {}) if (this.driverName && config.connection) { this.initializeDriver() this.initializePool(config) @@ -413,7 +442,7 @@ return /******/ (function(modules) { // webpackBootstrap this.emit('query', assign({__knexUid: connection.__knexUid}, obj)) debugQuery(obj.sql) return this._query.call(this, connection, obj).catch(function(err) { - err.message = obj.sql + ' - ' + err.message + err.message = SqlString.format(obj.sql, obj.bindings) + ' - ' + err.message throw err }) }, @@ -430,19 +459,16 @@ return /******/ (function(modules) { // webpackBootstrap }, initializeDriver: function() { - if (!process.browser) { - try { - this.driver = __webpack_require__(13)(this.driverName) - } catch (e) { - helpers.exit('Knex: run\n$ npm install ' + this.driverName + ' --save') - } + try { + this.driver = this._driver() + } catch (e) { + helpers.exit('Knex: run\n$ npm install ' + this.driverName + ' --save' + '\n' + e.stack) } }, Pool: Pool2, initializePool: function(config) { - this.connectionSettings = cloneDeep(config.connection) if (this.pool) this.destroy() this.pool = new this.Pool(assign(this.poolDefaults(config.pool || {}), config.pool)) this.pool.on('error', function(err) { @@ -532,7 +558,7 @@ return /******/ (function(modules) { // webpackBootstrap // Return the database being used by this client. database: function() { - return this.databaseName || this.connectionSettings.database + return this.connectionSettings.database }, toString: function() { @@ -543,16 +569,15 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Client - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) /***/ }, -/* 6 */ +/* 4 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var assign = __webpack_require__(14); - var inherits = __webpack_require__(46) + var assign = __webpack_require__(27); + var inherits = __webpack_require__(44) // Ensure the client has fresh objects so we can tack onto // the prototypes without mutating them globally. @@ -622,19 +647,19 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 7 */ +/* 5 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var EventEmitter = __webpack_require__(42).EventEmitter - var assign = __webpack_require__(14); + var EventEmitter = __webpack_require__(41).EventEmitter + var assign = __webpack_require__(27); - var Migrator = __webpack_require__(32) - var Seeder = __webpack_require__(41) - var FunctionHelper = __webpack_require__(30) - var QueryInterface = __webpack_require__(31) - var helpers = __webpack_require__(4) + var Migrator = __webpack_require__(28) + var Seeder = __webpack_require__(28) + var FunctionHelper = __webpack_require__(25) + var QueryInterface = __webpack_require__(26) + var helpers = __webpack_require__(2) module.exports = function makeKnex(client) { @@ -649,6 +674,8 @@ return /******/ (function(modules) { // webpackBootstrap assign(knex, { + Promise: __webpack_require__(8), + // A new query builder instance queryBuilder: function() { return client.queryBuilder() @@ -742,12 +769,12 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 8 */ +/* 6 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var url = __webpack_require__(45) + var url = __webpack_require__(42) module.exports = parseConnectionString @@ -804,18 +831,18 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 9 */ +/* 7 */ /***/ function(module, exports, __webpack_require__) { var map = { - "./maria/index.js": 33, - "./mysql/index.js": 34, - "./mysql2/index.js": 35, - "./oracle/index.js": 36, - "./postgres/index.js": 37, - "./sqlite3/index.js": 38, - "./strong-oracle/index.js": 39, - "./websql/index.js": 10 + "./maria/index.js": 32, + "./mysql/index.js": 33, + "./mysql2/index.js": 34, + "./oracle/index.js": 35, + "./postgres/index.js": 36, + "./sqlite3/index.js": 37, + "./strong-oracle/index.js": 38, + "./websql/index.js": 9 }; function webpackContext(req) { return __webpack_require__(webpackContextResolve(req)); @@ -828,24 +855,44 @@ return /******/ (function(modules) { // webpackBootstrap }; webpackContext.resolve = webpackContextResolve; module.exports = webpackContext; - webpackContext.id = 9; + webpackContext.id = 7; /***/ }, -/* 10 */ +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var Promise = __webpack_require__(31)(); + var deprecate = __webpack_require__(2).deprecate + + // Incase we're using an older version of bluebird + Promise.prototype.asCallback = Promise.prototype.nodeify + + Promise.prototype.exec = function(cb) { + deprecate('.exec', '.nodeify or .asCallback') + return this.nodeify(cb) + }; + + module.exports = Promise; + + +/***/ }, +/* 9 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // WebSQL // ------- - var inherits = __webpack_require__(46) - var _ = __webpack_require__(12) + var inherits = __webpack_require__(44) + var _ = __webpack_require__(11) - var Transaction = __webpack_require__(40) - var Client_SQLite3 = __webpack_require__(38) - var Promise = __webpack_require__(16) - var assign = __webpack_require__(14) + var Transaction = __webpack_require__(39) + var Client_SQLite3 = __webpack_require__(37) + var Promise = __webpack_require__(8) + var assign = __webpack_require__(27) function Client_WebSQL(config) { Client_SQLite3.call(this, config); @@ -946,7 +993,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 11 */ +/* 10 */ /***/ function(module, exports, __webpack_require__) { // shim for using process in browser @@ -1009,217 +1056,26 @@ return /******/ (function(modules) { // webpackBootstrap process.umask = function() { return 0; }; +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_11__; + /***/ }, /* 12 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_12__; - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - var map = { - "./bin/cli": 41, - "./bin/cli.js": 41, - "./client": 5, - "./client.js": 5, - "./dialects/maria/index": 33, - "./dialects/maria/index.js": 33, - "./dialects/mysql/index": 34, - "./dialects/mysql/index.js": 34, - "./dialects/mysql/query/compiler": 49, - "./dialects/mysql/query/compiler.js": 49, - "./dialects/mysql/schema/columncompiler": 50, - "./dialects/mysql/schema/columncompiler.js": 50, - "./dialects/mysql/schema/compiler": 51, - "./dialects/mysql/schema/compiler.js": 51, - "./dialects/mysql/schema/tablecompiler": 52, - "./dialects/mysql/schema/tablecompiler.js": 52, - "./dialects/mysql2/index": 35, - "./dialects/mysql2/index.js": 35, - "./dialects/oracle/formatter": 53, - "./dialects/oracle/formatter.js": 53, - "./dialects/oracle/index": 36, - "./dialects/oracle/index.js": 36, - "./dialects/oracle/query/compiler": 54, - "./dialects/oracle/query/compiler.js": 54, - "./dialects/oracle/schema/columnbuilder": 55, - "./dialects/oracle/schema/columnbuilder.js": 55, - "./dialects/oracle/schema/columncompiler": 56, - "./dialects/oracle/schema/columncompiler.js": 56, - "./dialects/oracle/schema/compiler": 57, - "./dialects/oracle/schema/compiler.js": 57, - "./dialects/oracle/schema/tablecompiler": 58, - "./dialects/oracle/schema/tablecompiler.js": 58, - "./dialects/oracle/stream": 59, - "./dialects/oracle/stream.js": 59, - "./dialects/oracle/transaction": 60, - "./dialects/oracle/transaction.js": 60, - "./dialects/oracle/utils": 61, - "./dialects/oracle/utils.js": 61, - "./dialects/postgres/index": 37, - "./dialects/postgres/index.js": 37, - "./dialects/postgres/query/compiler": 62, - "./dialects/postgres/query/compiler.js": 62, - "./dialects/postgres/schema/columncompiler": 63, - "./dialects/postgres/schema/columncompiler.js": 63, - "./dialects/postgres/schema/compiler": 64, - "./dialects/postgres/schema/compiler.js": 64, - "./dialects/postgres/schema/tablecompiler": 65, - "./dialects/postgres/schema/tablecompiler.js": 65, - "./dialects/postgres/utils": 66, - "./dialects/postgres/utils.js": 66, - "./dialects/sqlite3/index": 38, - "./dialects/sqlite3/index.js": 38, - "./dialects/sqlite3/query/compiler": 67, - "./dialects/sqlite3/query/compiler.js": 67, - "./dialects/sqlite3/schema/columncompiler": 68, - "./dialects/sqlite3/schema/columncompiler.js": 68, - "./dialects/sqlite3/schema/compiler": 69, - "./dialects/sqlite3/schema/compiler.js": 69, - "./dialects/sqlite3/schema/ddl": 70, - "./dialects/sqlite3/schema/ddl.js": 70, - "./dialects/sqlite3/schema/tablecompiler": 71, - "./dialects/sqlite3/schema/tablecompiler.js": 71, - "./dialects/strong-oracle/index": 39, - "./dialects/strong-oracle/index.js": 39, - "./dialects/websql/index": 10, - "./dialects/websql/index.js": 10, - "./dialects/websql/transaction": 40, - "./dialects/websql/transaction.js": 40, - "./formatter": 18, - "./formatter.js": 18, - "./functionhelper": 30, - "./functionhelper.js": 30, - "./helpers": 4, - "./helpers.js": 4, - "./index": 2, - "./index.js": 2, - "./interface": 15, - "./interface.js": 15, - "./migrate/index": 32, - "./migrate/index.js": 32, - "./migrate/index.web": 32, - "./migrate/index.web.js": 32, - "./migrate/stub/knexfile-js.stub": 75, - "./promise": 16, - "./promise.js": 16, - "./query/builder": 20, - "./query/builder.js": 20, - "./query/compiler": 21, - "./query/compiler.js": 21, - "./query/joinclause": 77, - "./query/joinclause.js": 77, - "./query/methods": 31, - "./query/methods.js": 31, - "./query/string": 78, - "./query/string.js": 78, - "./raw": 3, - "./raw.js": 3, - "./runner": 17, - "./runner.js": 17, - "./schema/builder": 22, - "./schema/builder.js": 22, - "./schema/columnbuilder": 26, - "./schema/columnbuilder.js": 26, - "./schema/columncompiler": 27, - "./schema/columncompiler.js": 27, - "./schema/compiler": 23, - "./schema/compiler.js": 23, - "./schema/helpers": 79, - "./schema/helpers.js": 79, - "./schema/tablebuilder": 24, - "./schema/tablebuilder.js": 24, - "./schema/tablecompiler": 25, - "./schema/tablecompiler.js": 25, - "./seed/index": 41, - "./seed/index.js": 41, - "./seed/seed-stub": 80, - "./seed/seed-stub.js": 80, - "./seed/stub/js.stub": 82, - "./transaction": 19, - "./transaction.js": 19, - "./util/bluebird": 47, - "./util/bluebird.js": 47, - "./util/make-client": 6, - "./util/make-client.js": 6, - "./util/make-knex": 7, - "./util/make-knex.js": 7, - "./util/parse-connection": 8, - "./util/parse-connection.js": 8 - }; - function webpackContext(req) { - return __webpack_require__(webpackContextResolve(req)); - }; - function webpackContextResolve(req) { - return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }()); - }; - webpackContext.keys = function webpackContextKeys() { - return Object.keys(map); - }; - webpackContext.resolve = webpackContextResolve; - module.exports = webpackContext; - webpackContext.id = 13; - - -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - var baseAssign = __webpack_require__(84), - createAssigner = __webpack_require__(85); - - /** - * Assigns own enumerable properties of source object(s) to the destination - * object. Subsequent sources overwrite property assignments of previous sources. - * If `customizer` is provided it is invoked to produce the assigned values. - * The `customizer` is bound to `thisArg` and invoked with five arguments; - * (objectValue, sourceValue, key, object, source). - * - * @static - * @memberOf _ - * @alias extend - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @param {Function} [customizer] The function to customize assigning values. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {Object} Returns `object`. - * @example - * - * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); - * // => { 'user': 'fred', 'age': 40 } - * - * // using a customizer callback - * var defaults = _.partialRight(_.assign, function(value, other) { - * return typeof value == 'undefined' ? other : value; - * }); - * - * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); - * // => { 'user': 'barney', 'age': 36 } - */ - var assign = createAssigner(baseAssign); - - module.exports = assign; - - -/***/ }, -/* 15 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var assert = __webpack_require__(93); - var helpers = __webpack_require__(4) + var helpers = __webpack_require__(2) module.exports = function(Target) { - var _ = __webpack_require__(12); - var SqlString = __webpack_require__(78); + var _ = __webpack_require__(11); + var SqlString = __webpack_require__(24); Target.prototype.toQuery = function(tz) { var data = this.toSQL(this._method); - if (this._errors && this._errors.length > 0) throw this._errors[0]; if (!_.isArray(data)) data = [data]; return _.map(data, function(statement) { return this._formatQuery(statement.sql, statement.bindings, tz); @@ -1231,7 +1087,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.client && this.client.prepBindings) { bindings = this.client.prepBindings(bindings, tz); } - return SqlString.format(sql, bindings, true, tz); + return SqlString.format(sql, bindings, tz); }; // Create a new instance of the `Runner`, passing in the current object. @@ -1256,7 +1112,6 @@ return /******/ (function(modules) { // webpackBootstrap // Set a debug flag for the current schema query stack. Target.prototype.debug = function(enabled) { - assert(!arguments.length || typeof enabled === 'boolean', 'debug requires a boolean'); this._debug = arguments.length ? enabled : true; return this; }; @@ -1298,34 +1153,14 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 16 */ +/* 13 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var Promise = __webpack_require__(47)(); - var deprecate = __webpack_require__(4).deprecate - - // Incase we're using an older version of bluebird - Promise.prototype.asCallback = Promise.prototype.nodeify - - Promise.prototype.exec = function(cb) { - deprecate('.exec', '.nodeify or .asCallback') - return this.nodeify(cb) - }; - - module.exports = Promise; - - -/***/ }, -/* 17 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var _ = __webpack_require__(12) - var Promise = __webpack_require__(16) - var assign = __webpack_require__(14); + var _ = __webpack_require__(11) + var Promise = __webpack_require__(8) + var assign = __webpack_require__(27); var PassThrough; @@ -1353,14 +1188,13 @@ return /******/ (function(modules) { // webpackBootstrap return Promise.using(this.ensureConnection(), function(connection) { runner.connection = connection; - // Emit a "start" event on both the builder and the client, - // allowing us to listen in on any events. We fire on the "client" - // before building the SQL, and on the builder after building the SQL - // in case we want to determine at how long it actually - // took to build the query. - runner.client.emit('start', runner.builder); + runner.client.emit('start', runner.builder) + runner.builder.emit('start', runner.builder) var sql = runner.builder.toSQL(); - runner.builder.emit('start', runner.builder); + + if (runner.builder._debug) { + console.log(sql) + } if (_.isArray(sql)) { return runner.queryArray(sql); @@ -1403,7 +1237,7 @@ return /******/ (function(modules) { // webpackBootstrap var hasHandler = typeof handler === 'function'; // Lazy-load the "PassThrough" dependency. - PassThrough = PassThrough || __webpack_require__(96).PassThrough; + PassThrough = PassThrough || __webpack_require__(89).PassThrough; var runner = this; var stream = new PassThrough({objectMode: true}); @@ -1432,8 +1266,8 @@ return /******/ (function(modules) { // webpackBootstrap }, // Allow you to pipe the stream to a writable stream. - pipe: function(writable) { - return this.stream().pipe(writable); + pipe: function(writable, options) { + return this.stream().pipe(writable, options); }, // "Runs" a query, returning a promise. All queries specified by the builder are guaranteed @@ -1476,15 +1310,15 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Runner; /***/ }, -/* 18 */ +/* 14 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var QueryBuilder = __webpack_require__(20) - var Raw = __webpack_require__(3) - var assign = __webpack_require__(14) - var transform = __webpack_require__(87) + var QueryBuilder = __webpack_require__(16) + var Raw = __webpack_require__(1) + var assign = __webpack_require__(27) + var transform = __webpack_require__(54) function Formatter(client) { this.client = client @@ -1527,18 +1361,20 @@ return /******/ (function(modules) { // webpackBootstrap }, unwrapRaw: function(value, isParameter) { + var query; if (value instanceof QueryBuilder) { - var query = this.client.queryCompiler(value).toSQL() + query = this.client.queryCompiler(value).toSQL() if (query.bindings) { this.bindings = this.bindings.concat(query.bindings); } return this.outputQuery(query, isParameter); } if (value instanceof Raw) { - if (value.bindings) { - this.bindings = this.bindings.concat(value.bindings); + query = value.toSQL() + if (query.bindings) { + this.bindings = this.bindings.concat(query.bindings); } - return value.sql; + return query.sql } if (isParameter) { this.bindings.push(value); @@ -1654,37 +1490,38 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 19 */ +/* 15 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // Transaction // ------- - var Promise = __webpack_require__(16) - var EventEmitter = __webpack_require__(42).EventEmitter - var inherits = __webpack_require__(46) + var Promise = __webpack_require__(8) + var EventEmitter = __webpack_require__(41).EventEmitter + var inherits = __webpack_require__(44) - var makeKnex = __webpack_require__(7) - var assign = __webpack_require__(14) - var uniqueId = __webpack_require__(28) - var debug = __webpack_require__(48)('knex:tx') + var makeKnex = __webpack_require__(5) + var assign = __webpack_require__(27) + var uniqueId = __webpack_require__(29) + var debug = __webpack_require__(45)('knex:tx') // Acts as a facade for a Promise, keeping the internal state // and managing any child transactions. function Transaction(client, container, config, outerTx) { var txid = this.txid = uniqueId('trx') - + this.client = client this.outerTx = outerTx this.trxClient = undefined; + this._debug = client.config && client.config.debug debug('%s: Starting %s transaction', txid, outerTx ? 'nested' : 'top level') var t = this - this._promise = Promise.using(acquireConnection(client, config, txid), function(connection) { + this._promise = Promise.using(this.acquireConnection(client, config, txid), function(connection) { var trxClient = t.trxClient = makeTxClient(t, client, connection) var init = client.transacting ? t.savepoint(connection) : t.begin(connection) @@ -1746,28 +1583,10 @@ return /******/ (function(modules) { // webpackBootstrap } inherits(Transaction, EventEmitter) - // Acquire a connection and create a disposer - either using the one passed - // via config or getting one off the client. The disposer will be called once - // the original promise is marked completed. - function acquireConnection(client, config, txid) { - var configConnection = config && config.connection - return Promise.try(function() { - return configConnection || client.acquireConnection() - }) - .disposer(function(connection) { - if (!configConnection) { - debug('%s: releasing connection', txid) - client.releaseConnection(connection) - } else { - debug('%s: not releasing external connection', txid) - } - }) - } - assign(Transaction.prototype, { - isCancelled: function() { - return this._cancelled || this.outerTx && this.outerTx.isCancelled() || false + isCompleted: function() { + return this._completed || this.outerTx && this.outerTx.isCompleted() || false }, begin: function(conn) { @@ -1775,7 +1594,7 @@ return /******/ (function(modules) { // webpackBootstrap }, savepoint: function(conn) { - return this.query(conn, 'savepoint ' + this.txid + ';') + return this.query(conn, 'savepoint ' + this.txid) }, commit: function(conn, value) { @@ -1783,7 +1602,7 @@ return /******/ (function(modules) { // webpackBootstrap }, release: function(conn, value) { - return this.query(conn, 'release savepoint ' + this.txid + ';', 1, value) + return this.query(conn, 'release savepoint ' + this.txid, 1, value) }, rollback: function(conn, error) { @@ -1791,29 +1610,53 @@ return /******/ (function(modules) { // webpackBootstrap }, rollbackTo: function(conn, error) { - return this.query(conn, 'rollback to savepoint ' + this.txid + ';', 2, error) + return this.query(conn, 'rollback to savepoint ' + this.txid, 2, error) }, query: function(conn, sql, status, value) { - var t = this - return this.trxClient.query(conn, sql) + var q = this.trxClient.query(conn, sql) .catch(function(err) { status = 2 value = err + t._completed = true debug('%s error running transaction query', t.txid) }) .tap(function() { if (status === 1) t._resolver(value) if (status === 2) t._rejecter(value) - if (status === 1 || status === 2) { - t._completed = true - } }) + if (status === 1 || status === 2) { + t._completed = true + } + return q; + }, + + debug: function(enabled) { + this._debug = arguments.length ? enabled : true; + return this }, _skipping: function(sql) { return Promise.reject(new Error('Transaction ' + this.txid + ' has already been released skipping: ' + sql)) + }, + + // Acquire a connection and create a disposer - either using the one passed + // via config or getting one off the client. The disposer will be called once + // the original promise is marked completed. + acquireConnection: function(client, config, txid) { + var configConnection = config && config.connection + return Promise.try(function() { + return configConnection || client.acquireConnection() + }) + .disposer(function(connection) { + if (!configConnection) { + debug('%s: releasing connection', txid) + client.releaseConnection(connection) + } else { + debug('%s: not releasing external connection', txid) + } + }) } }) @@ -1858,9 +1701,11 @@ return /******/ (function(modules) { // webpackBootstrap // connection and does not release back into the pool. function makeTxClient(trx, client, connection) { - var trxClient = Object.create(client.constructor.prototype) - trxClient.config = client.config - trxClient.transacting = true + var trxClient = Object.create(client.constructor.prototype) + trxClient.config = client.config + trxClient.driver = client.driver + trxClient.connectionSettings = client.connectionSettings + trxClient.transacting = true trxClient.on('query', function(arg) { trx.emit('query', arg) @@ -1868,15 +1713,19 @@ return /******/ (function(modules) { // webpackBootstrap var _query = trxClient.query; trxClient.query = function(conn, obj) { + var completed = trx.isCompleted() return Promise.try(function() { if (conn !== connection) throw new Error('Invalid connection for transaction query.') + if (completed) completedError(trx, obj) return _query.call(trxClient, conn, obj) }) } var _stream = trxClient.stream trxClient.stream = function(conn, obj, stream, options) { + var completed = trx.isCompleted() return Promise.try(function() { if (conn !== connection) throw new Error('Invalid connection for transaction query.') + if (completed) completedError(trx, obj) return _stream.call(trxClient, conn, obj, stream, options) }) } @@ -1892,7 +1741,11 @@ return /******/ (function(modules) { // webpackBootstrap return trxClient } - Transaction.prototype.transacting = undefined + function completedError(trx, obj) { + var sql = typeof obj === 'string' ? obj : obj && obj.sql + debug('%s: Transaction completed: %s', trx.id, sql) + throw new Error('Transaction query already complete, run with DEBUG=knex:tx for more info') + } var promiseInterface = [ 'then', 'bind', 'catch', 'finally', 'asCallback', @@ -1912,759 +1765,761 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 20 */ +/* 16 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // Builder // ------- - var _ = __webpack_require__(12) - var assert = __webpack_require__(93) - var inherits = __webpack_require__(46) - var EventEmitter = __webpack_require__(42).EventEmitter + var _ = __webpack_require__(11) + var assert = __webpack_require__(87) + var inherits = __webpack_require__(44) + var EventEmitter = __webpack_require__(41).EventEmitter - var Raw = __webpack_require__(3) - var helpers = __webpack_require__(4) - var JoinClause = __webpack_require__(77) + var Raw = __webpack_require__(1) + var helpers = __webpack_require__(2) + var JoinClause = __webpack_require__(55) + var assign = __webpack_require__(27); // Typically called from `knex.builder`, // start a new query building chain. function QueryBuilder(client) { this.client = client + this.and = this; this._single = {}; this._statements = []; // Internal flags used in the builder. + this._method = 'select' this._joinFlag = 'inner'; this._boolFlag = 'and'; this._notFlag = false; - - this.and = this; + this._debug = client.config && client.config.debug; } inherits(QueryBuilder, EventEmitter); - QueryBuilder.prototype.toString = function() { - return this.toQuery(); - }; + assign(QueryBuilder.prototype, { - // Convert the current query "toSQL" - QueryBuilder.prototype.toSQL = function() { - return this.client.queryCompiler(this).toSQL(this._method || 'select'); - }; + toString: function() { + return this.toQuery(); + }, - // Create a shallow clone of the current query builder. - // TODO: Test this!! - QueryBuilder.prototype.clone = function() { - var cloned = new this.constructor(this.client); - cloned._method = this._method; - cloned._single = _.clone(this._single); - cloned._options = _.clone(this._options); - cloned._statements = this._statements.slice(); - return cloned; - }; + // Convert the current query "toSQL" + toSQL: function(method) { + return this.client.queryCompiler(this).toSQL(method || this._method); + }, - // Select - // ------ + // Create a shallow clone of the current query builder. + // TODO: Test this!! + clone: function() { + var cloned = new this.constructor(this.client); + cloned._method = this._method; + cloned._single = _.clone(this._single); + cloned._options = _.clone(this._options); + cloned._statements = this._statements.slice(); + return cloned; + }, - // Sets the values for a `select` query, - // which is the same as specifying the columns. - QueryBuilder.prototype.select = + // Select + // ------ - // Adds a column or columns to the list of "columns" - // being selected on the query. - QueryBuilder.prototype.columns = - QueryBuilder.prototype.column = function(column) { - if (!column) return this; - this._statements.push({ - grouping: 'columns', - value: helpers.normalizeArr.apply(null, arguments) - }); - return this; - }; + // Adds a column or columns to the list of "columns" + // being selected on the query. + columns: function(column) { + if (!column) return this; + this._statements.push({ + grouping: 'columns', + value: helpers.normalizeArr.apply(null, arguments) + }); + return this; + }, - // Takes a JS object of methods to call and calls them - QueryBuilder.prototype.fromJS = function(obj) { - _.each(obj, function(val, key) { - if (typeof this[key] !== 'function') { - helpers.warn('Knex Error: unknown key ' + key) - } - if (Array.isArray(val)) { - this[key].apply(this, val) + // Allow for a sub-select to be explicitly aliased as a column, + // without needing to compile the query in a where. + as: function(column) { + this._single.as = column; + return this; + }, + + // Sets the `tableName` on the query. + // Alias to "from" for select and "into" for insert statements + // e.g. builder.insert({a: value}).into('tableName') + table: function(tableName) { + this._single.table = tableName; + return this; + }, + + // Adds a `distinct` clause to the query. + distinct: function() { + this._statements.push({ + grouping: 'columns', + value: helpers.normalizeArr.apply(null, arguments), + distinct: true + }); + return this; + }, + + // Adds a join clause to the query, allowing for advanced joins + // with an anonymous function as the second argument. + // function(table, first, operator, second) + join: function(table, first) { + var join; + var joinType = this._joinType(); + if (typeof first === 'function') { + join = new JoinClause(table, joinType); + first.call(join, join); + } else if (joinType === 'raw') { + join = new JoinClause(this.client.raw(table, first), 'raw'); } else { - this[key](val) + join = new JoinClause(table, joinType); + if (arguments.length > 1) { + join.on.apply(join, _.toArray(arguments).slice(1)); + } } - }, this) - return this - } + this._statements.push(join); + return this; + }, - // Allow for a sub-select to be explicitly aliased as a column, - // without needing to compile the query in a where. - QueryBuilder.prototype.as = function(column) { - this._single.as = column; - return this; - }; + // JOIN blocks: + innerJoin: function() { + return this._joinType('inner').join.apply(this, arguments); + }, + leftJoin: function() { + return this._joinType('left').join.apply(this, arguments); + }, + leftOuterJoin: function() { + return this._joinType('left outer').join.apply(this, arguments); + }, + rightJoin: function() { + return this._joinType('right').join.apply(this, arguments); + }, + rightOuterJoin: function() { + return this._joinType('right outer').join.apply(this, arguments); + }, + outerJoin: function() { + return this._joinType('outer').join.apply(this, arguments); + }, + fullOuterJoin: function() { + return this._joinType('full outer').join.apply(this, arguments); + }, + crossJoin: function() { + return this._joinType('cross').join.apply(this, arguments); + }, + joinRaw: function() { + return this._joinType('raw').join.apply(this, arguments); + }, - // Sets the `tableName` on the query. - // Alias to "from" for select and "into" for insert statements - // e.g. builder.insert({a: value}).into('tableName') - QueryBuilder.prototype.table = function(tableName) { - this._single.table = tableName; - return this; - }; - QueryBuilder.prototype.from = QueryBuilder.prototype.table; - QueryBuilder.prototype.into = QueryBuilder.prototype.table; + // The where function can be used in several ways: + // The most basic is `where(key, value)`, which expands to + // where key = value. + where: function(column, operator, value) { - // Adds a `distinct` clause to the query. - QueryBuilder.prototype.distinct = function() { - this._statements.push({ - grouping: 'columns', - value: helpers.normalizeArr.apply(null, arguments), - distinct: true - }); - return this; - }; - - // Adds a join clause to the query, allowing for advanced joins - // with an anonymous function as the second argument. - // function(table, first, operator, second) - QueryBuilder.prototype.join = function(table, first) { - var join; - var joinType = this._joinType(); - if (typeof first === 'function') { - join = new JoinClause(table, joinType); - first.call(join, join); - } else if (joinType === 'raw') { - join = new JoinClause(this.client.raw(table, first), 'raw'); - } else { - join = new JoinClause(table, joinType); - if (arguments.length > 1) { - join.on.apply(join, _.toArray(arguments).slice(1)); + // Support "where true || where false" + if (column === false || column === true) { + return this.where(1, '=', column ? 1 : 0) } - } - this._statements.push(join); - return this; - }; - // JOIN blocks: - QueryBuilder.prototype.innerJoin = function() { - return this._joinType('inner').join.apply(this, arguments); - }; - QueryBuilder.prototype.leftJoin = function() { - return this._joinType('left').join.apply(this, arguments); - }; - QueryBuilder.prototype.leftOuterJoin = function() { - return this._joinType('left outer').join.apply(this, arguments); - }; - QueryBuilder.prototype.rightJoin = function() { - return this._joinType('right').join.apply(this, arguments); - }; - QueryBuilder.prototype.rightOuterJoin = function() { - return this._joinType('right outer').join.apply(this, arguments); - }; - QueryBuilder.prototype.outerJoin = function() { - return this._joinType('outer').join.apply(this, arguments); - }; - QueryBuilder.prototype.fullOuterJoin = function() { - return this._joinType('full outer').join.apply(this, arguments); - }; - QueryBuilder.prototype.crossJoin = function() { - return this._joinType('cross').join.apply(this, arguments); - }; - QueryBuilder.prototype.joinRaw = function() { - return this._joinType('raw').join.apply(this, arguments); - }; + // Check if the column is a function, in which case it's + // a where statement wrapped in parens. + if (typeof column === 'function') { + return this.whereWrapped(column); + } - // The where function can be used in several ways: - // The most basic is `where(key, value)`, which expands to - // where key = value. - QueryBuilder.prototype.where = - QueryBuilder.prototype.andWhere = function(column, operator, value) { + // Allow a raw statement to be passed along to the query. + if (column instanceof Raw && arguments.length === 1) return this.whereRaw(column); - // Support "where true || where false" - if (column === false || column === true) { - return this.where(1, '=', column ? 1 : 0) - } + // Allows `where({id: 2})` syntax. + if (_.isObject(column) && !(column instanceof Raw)) return this._objectWhere(column); - // Check if the column is a function, in which case it's - // a where statement wrapped in parens. - if (typeof column === 'function') { - return this.whereWrapped(column); - } + // Enable the where('key', value) syntax, only when there + // are explicitly two arguments passed, so it's not possible to + // do where('key', '!=') and have that turn into where key != null + if (arguments.length === 2) { + value = operator; + operator = '='; - // Allow a raw statement to be passed along to the query. - if (column instanceof Raw && arguments.length === 1) return this.whereRaw(column); + // If the value is null, and it's a two argument query, + // we assume we're going for a `whereNull`. + if (value === null) { + return this.whereNull(column); + } + } - // Allows `where({id: 2})` syntax. - if (_.isObject(column) && !(column instanceof Raw)) return this._objectWhere(column); + // lower case the operator for comparison purposes + var checkOperator = ('' + operator).toLowerCase().trim(); - // Enable the where('key', value) syntax, only when there - // are explicitly two arguments passed, so it's not possible to - // do where('key', '!=') and have that turn into where key != null - if (arguments.length === 2) { - value = operator; - operator = '='; + // If there are 3 arguments, check whether 'in' is one of them. + if (arguments.length === 3) { + if (checkOperator === 'in' || checkOperator === 'not in') { + return this._not(checkOperator === 'not in').whereIn(arguments[0], arguments[2]); + } + if (checkOperator === 'between' || checkOperator === 'not between') { + return this._not(checkOperator === 'not between').whereBetween(arguments[0], arguments[2]); + } + } - // If the value is null, and it's a two argument query, - // we assume we're going for a `whereNull`. + // If the value is still null, check whether they're meaning + // where value is null if (value === null) { - return this.whereNull(column); + + // Check for .where(key, 'is', null) or .where(key, 'is not', 'null'); + if (checkOperator === 'is' || checkOperator === 'is not') { + return this._not(checkOperator === 'is not').whereNull(column); + } } - } - // lower case the operator for comparison purposes - var checkOperator = ('' + operator).toLowerCase().trim(); + // Push onto the where statement stack. + this._statements.push({ + grouping: 'where', + type: 'whereBasic', + column: column, + operator: operator, + value: value, + not: this._not(), + bool: this._bool() + }); + return this; + }, + // Adds an `or where` clause to the query. + orWhere: function() { + return this._bool('or').where.apply(this, arguments); + }, - // If there are 3 arguments, check whether 'in' is one of them. - if (arguments.length === 3) { - if (checkOperator === 'in' || checkOperator === 'not in') { - return this._not(checkOperator === 'not in').whereIn(arguments[0], arguments[2]); + // Adds an `not where` clause to the query. + whereNot: function() { + return this._not(true).where.apply(this, arguments); + }, + + // Adds an `or not where` clause to the query. + orWhereNot: function() { + return this._bool('or').whereNot.apply(this, arguments); + }, + + // Processes an object literal provided in a "where" clause. + _objectWhere: function(obj) { + var boolVal = this._bool(); + var notVal = this._not() ? 'Not' : ''; + for (var key in obj) { + this[boolVal + 'Where' + notVal](key, obj[key]); } - if (checkOperator === 'between' || checkOperator === 'not between') { - return this._not(checkOperator === 'not between').whereBetween(arguments[0], arguments[2]); + return this; + }, + + // Adds a raw `where` clause to the query. + whereRaw: function(sql, bindings) { + var raw = (sql instanceof Raw ? sql : this.client.raw(sql, bindings)); + this._statements.push({ + grouping: 'where', + type: 'whereRaw', + value: raw, + bool: this._bool() + }); + return this; + }, + + orWhereRaw: function(sql, bindings) { + return this._bool('or').whereRaw(sql, bindings); + }, + + // Helper for compiling any advanced `where` queries. + whereWrapped: function(callback) { + this._statements.push({ + grouping: 'where', + type: 'whereWrapped', + value: callback, + not: this._not(), + bool: this._bool() + }); + return this; + }, + + + // Helper for compiling any advanced `having` queries. + havingWrapped: function(callback) { + this._statements.push({ + grouping: 'having', + type: 'whereWrapped', + value: callback, + bool: this._bool() + }); + return this; + }, + + // Adds a `where exists` clause to the query. + whereExists: function(callback) { + this._statements.push({ + grouping: 'where', + type: 'whereExists', + value: callback, + not: this._not(), + bool: this._bool(), + }); + return this; + }, + + // Adds an `or where exists` clause to the query. + orWhereExists: function(callback) { + return this._bool('or').whereExists(callback); + }, + + // Adds a `where not exists` clause to the query. + whereNotExists: function(callback) { + return this._not(true).whereExists(callback); + }, + + // Adds a `or where not exists` clause to the query. + orWhereNotExists: function(callback) { + return this._bool('or').whereNotExists(callback); + }, + + // Adds a `where in` clause to the query. + whereIn: function(column, values) { + if (Array.isArray(values) && _.isEmpty(values)) return this.where(this._not()); + this._statements.push({ + grouping: 'where', + type: 'whereIn', + column: column, + value: values, + not: this._not(), + bool: this._bool() + }); + return this; + }, + + // Adds a `or where in` clause to the query. + orWhereIn: function(column, values) { + return this._bool('or').whereIn(column, values); + }, + + // Adds a `where not in` clause to the query. + whereNotIn: function(column, values) { + return this._not(true).whereIn(column, values); + }, + + // Adds a `or where not in` clause to the query. + orWhereNotIn: function(column, values) { + return this._bool('or')._not(true).whereIn(column, values); + }, + + // Adds a `where null` clause to the query. + whereNull: function(column) { + this._statements.push({ + grouping: 'where', + type: 'whereNull', + column: column, + not: this._not(), + bool: this._bool() + }); + return this; + }, + + // Adds a `or where null` clause to the query. + orWhereNull: function(column) { + return this._bool('or').whereNull(column); + }, + + // Adds a `where not null` clause to the query. + whereNotNull: function(column) { + return this._not(true).whereNull(column); + }, + + // Adds a `or where not null` clause to the query. + orWhereNotNull: function(column) { + return this._bool('or').whereNotNull(column); + }, + + // Adds a `where between` clause to the query. + whereBetween: function(column, values) { + assert(Array.isArray(values), 'The second argument to whereBetween must be an array.') + assert(values.length === 2, 'You must specify 2 values for the whereBetween clause') + this._statements.push({ + grouping: 'where', + type: 'whereBetween', + column: column, + value: values, + not: this._not(), + bool: this._bool() + }); + return this; + }, + + // Adds a `where not between` clause to the query. + whereNotBetween: function(column, values) { + return this._not(true).whereBetween(column, values); + }, + + // Adds a `or where between` clause to the query. + orWhereBetween: function(column, values) { + return this._bool('or').whereBetween(column, values); + }, + + // Adds a `or where not between` clause to the query. + orWhereNotBetween: function(column, values) { + return this._bool('or').whereNotBetween(column, values); + }, + + // Adds a `group by` clause to the query. + groupBy: function(item) { + if (item instanceof Raw) { + return this.groupByRaw.apply(this, arguments); } - } + this._statements.push({ + grouping: 'group', + type: 'groupByBasic', + value: helpers.normalizeArr.apply(null, arguments) + }); + return this; + }, - // If the value is still null, check whether they're meaning - // where value is null - if (value === null) { + // Adds a raw `group by` clause to the query. + groupByRaw: function(sql, bindings) { + var raw = (sql instanceof Raw ? sql : this.client.raw(sql, bindings)); + this._statements.push({ + grouping: 'group', + type: 'groupByRaw', + value: raw + }); + return this; + }, - // Check for .where(key, 'is', null) or .where(key, 'is not', 'null'); - if (checkOperator === 'is' || checkOperator === 'is not') { - return this._not(checkOperator === 'is not').whereNull(column); + // Adds a `order by` clause to the query. + orderBy: function(column, direction) { + this._statements.push({ + grouping: 'order', + type: 'orderByBasic', + value: column, + direction: direction + }); + return this; + }, + + // Add a raw `order by` clause to the query. + orderByRaw: function(sql, bindings) { + var raw = (sql instanceof Raw ? sql : this.client.raw(sql, bindings)); + this._statements.push({ + grouping: 'order', + type: 'orderByRaw', + value: raw + }); + return this; + }, + + // Add a union statement to the query. + union: function(callbacks, wrap) { + if (arguments.length === 1 || + (arguments.length === 2 && _.isBoolean(wrap))) { + if (!Array.isArray(callbacks)) { + callbacks = [callbacks]; + } + for (var i = 0, l = callbacks.length; i < l; i++) { + this._statements.push({ + grouping: 'union', + clause: 'union', + value: callbacks[i], + wrap: wrap || false + }); + } + } else { + callbacks = _.toArray(arguments).slice(0, arguments.length - 1); + wrap = arguments[arguments.length - 1]; + if (!_.isBoolean(wrap)) { + callbacks.push(wrap); + wrap = false; + } + this.union(callbacks, wrap); } - } + return this; + }, - // Push onto the where statement stack. - this._statements.push({ - grouping: 'where', - type: 'whereBasic', - column: column, - operator: operator, - value: value, - not: this._not(), - bool: this._bool() - }); - return this; - }; - // Adds an `or where` clause to the query. - QueryBuilder.prototype.orWhere = function() { - return this._bool('or').where.apply(this, arguments); - }; + // Adds a union all statement to the query. + unionAll: function(callback, wrap) { + this._statements.push({ + grouping: 'union', + clause: 'union all', + value: callback, + wrap: wrap || false + }); + return this; + }, - // Adds an `not where` clause to the query. - QueryBuilder.prototype.andWhereNot = - QueryBuilder.prototype.whereNot = function() { - return this._not(true).where.apply(this, arguments); - }; - - // Adds an `or not where` clause to the query. - QueryBuilder.prototype.orWhereNot = function() { - return this._bool('or').whereNot.apply(this, arguments); - }; - - - // Processes an object literal provided in a "where" clause. - QueryBuilder.prototype._objectWhere = function(obj) { - var boolVal = this._bool(); - var notVal = this._not() ? 'Not' : ''; - for (var key in obj) { - this[boolVal + 'Where' + notVal](key, obj[key]); - } - return this; - }; - - // Adds a raw `where` clause to the query. - QueryBuilder.prototype.whereRaw = - QueryBuilder.prototype.andWhereRaw = function(sql, bindings) { - var raw = (sql instanceof Raw ? sql : this.client.raw(sql, bindings)); - this._statements.push({ - grouping: 'where', - type: 'whereRaw', - value: raw, - bool: this._bool() - }); - return this; - }; - QueryBuilder.prototype.orWhereRaw = function(sql, bindings) { - return this._bool('or').whereRaw(sql, bindings); - }; - - // Helper for compiling any advanced `where` queries. - QueryBuilder.prototype.whereWrapped = function(callback) { - this._statements.push({ - grouping: 'where', - type: 'whereWrapped', - value: callback, - not: this._not(), - bool: this._bool() - }); - return this; - }; - - - // Helper for compiling any advanced `having` queries. - QueryBuilder.prototype.havingWrapped = function(callback) { - this._statements.push({ - grouping: 'having', - type: 'whereWrapped', - value: callback, - bool: this._bool() - }); - return this; - }; - - // Adds a `where exists` clause to the query. - QueryBuilder.prototype.whereExists = function(callback) { - this._statements.push({ - grouping: 'where', - type: 'whereExists', - value: callback, - not: this._not(), - bool: this._bool(), - }); - return this; - }; - - // Adds an `or where exists` clause to the query. - QueryBuilder.prototype.orWhereExists = function(callback) { - return this._bool('or').whereExists(callback); - }; - - // Adds a `where not exists` clause to the query. - QueryBuilder.prototype.whereNotExists = function(callback) { - return this._not(true).whereExists(callback); - }; - - // Adds a `or where not exists` clause to the query. - QueryBuilder.prototype.orWhereNotExists = function(callback) { - return this._bool('or').whereNotExists(callback); - }; - - // Adds a `where in` clause to the query. - QueryBuilder.prototype.whereIn = function(column, values) { - if (Array.isArray(values) && _.isEmpty(values)) return this.where(this._not()); - this._statements.push({ - grouping: 'where', - type: 'whereIn', - column: column, - value: values, - not: this._not(), - bool: this._bool() - }); - return this; - }; - - // Adds a `or where in` clause to the query. - QueryBuilder.prototype.orWhereIn = function(column, values) { - return this._bool('or').whereIn(column, values); - }; - - // Adds a `where not in` clause to the query. - QueryBuilder.prototype.whereNotIn = function(column, values) { - return this._not(true).whereIn(column, values); - }; - - // Adds a `or where not in` clause to the query. - QueryBuilder.prototype.orWhereNotIn = function(column, values) { - return this._bool('or')._not(true).whereIn(column, values); - }; - - // Adds a `where null` clause to the query. - QueryBuilder.prototype.whereNull = function(column) { - this._statements.push({ - grouping: 'where', - type: 'whereNull', - column: column, - not: this._not(), - bool: this._bool() - }); - return this; - }; - - // Adds a `or where null` clause to the query. - QueryBuilder.prototype.orWhereNull = function(column) { - return this._bool('or').whereNull(column); - }; - - // Adds a `where not null` clause to the query. - QueryBuilder.prototype.whereNotNull = function(column) { - return this._not(true).whereNull(column); - }; - - // Adds a `or where not null` clause to the query. - QueryBuilder.prototype.orWhereNotNull = function(column) { - return this._bool('or').whereNotNull(column); - }; - - // Adds a `where between` clause to the query. - QueryBuilder.prototype.whereBetween = function(column, values) { - assert(Array.isArray(values), 'The second argument to whereBetween must be an array.') - assert(values.length === 2, 'You must specify 2 values for the whereBetween clause') - this._statements.push({ - grouping: 'where', - type: 'whereBetween', - column: column, - value: values, - not: this._not(), - bool: this._bool() - }); - return this; - }; - - // Adds a `where not between` clause to the query. - QueryBuilder.prototype.whereNotBetween = function(column, values) { - return this._not(true).whereBetween(column, values); - }; - - // Adds a `or where between` clause to the query. - QueryBuilder.prototype.orWhereBetween = function(column, values) { - return this._bool('or').whereBetween(column, values); - }; - - // Adds a `or where not between` clause to the query. - QueryBuilder.prototype.orWhereNotBetween = function(column, values) { - return this._bool('or').whereNotBetween(column, values); - }; - - // Adds a `group by` clause to the query. - QueryBuilder.prototype.groupBy = function(item) { - if (item instanceof Raw) { - return this.groupByRaw.apply(this, arguments); - } - this._statements.push({ - grouping: 'group', - type: 'groupByBasic', - value: helpers.normalizeArr.apply(null, arguments) - }); - return this; - }; - - // Adds a raw `group by` clause to the query. - QueryBuilder.prototype.groupByRaw = function(sql, bindings) { - var raw = (sql instanceof Raw ? sql : this.client.raw(sql, bindings)); - this._statements.push({ - grouping: 'group', - type: 'groupByRaw', - value: raw - }); - return this; - }; - - // Adds a `order by` clause to the query. - QueryBuilder.prototype.orderBy = function(column, direction) { - this._statements.push({ - grouping: 'order', - type: 'orderByBasic', - value: column, - direction: direction - }); - return this; - }; - - // Add a raw `order by` clause to the query. - QueryBuilder.prototype.orderByRaw = function(sql, bindings) { - var raw = (sql instanceof Raw ? sql : this.client.raw(sql, bindings)); - this._statements.push({ - grouping: 'order', - type: 'orderByRaw', - value: raw - }); - return this; - }; - - // Add a union statement to the query. - QueryBuilder.prototype.union = function(callbacks, wrap) { - if (arguments.length === 1 || - (arguments.length === 2 && _.isBoolean(wrap))) { - if (!Array.isArray(callbacks)) { - callbacks = [callbacks]; + // Adds a `having` clause to the query. + having: function(column, operator, value) { + if (column instanceof Raw && arguments.length === 1) { + return this._havingRaw(column); } - for (var i = 0, l = callbacks.length; i < l; i++) { - this._statements.push({ - grouping: 'union', - clause: 'union', - value: callbacks[i], - wrap: wrap || false - }); + + // Check if the column is a function, in which case it's + // a having statement wrapped in parens. + if (typeof column === 'function') { + return this.havingWrapped(column); } - } else { - callbacks = _.toArray(arguments).slice(0, arguments.length - 1); - wrap = arguments[arguments.length - 1]; - if (!_.isBoolean(wrap)) { - callbacks.push(wrap); - wrap = false; + + this._statements.push({ + grouping: 'having', + type: 'havingBasic', + column: column, + operator: operator, + value: value, + bool: this._bool() + }); + return this; + }, + // Adds an `or having` clause to the query. + orHaving: function() { + return this._bool('or').having.apply(this, arguments); + }, + havingRaw: function(sql, bindings) { + return this._havingRaw(sql, bindings); + }, + orHavingRaw: function(sql, bindings) { + return this._bool('or').havingRaw(sql, bindings); + }, + // Adds a raw `having` clause to the query. + _havingRaw: function(sql, bindings) { + var raw = (sql instanceof Raw ? sql : this.client.raw(sql, bindings)); + this._statements.push({ + grouping: 'having', + type: 'havingRaw', + value: raw, + bool: this._bool() + }); + return this; + }, + + // Only allow a single "offset" to be set for the current query. + offset: function(value) { + this._single.offset = value; + return this; + }, + + // Only allow a single "limit" to be set for the current query. + limit: function(value) { + var val = parseInt(value, 10) + if (isNaN(val)) { + helpers.warn('A valid integer must be provided to limit') + } else { + this._single.limit = val; } - this.union(callbacks, wrap); - } - return this; - }; + return this; + }, - // Adds a union all statement to the query. - QueryBuilder.prototype.unionAll = function(callback, wrap) { - this._statements.push({ - grouping: 'union', - clause: 'union all', - value: callback, - wrap: wrap || false - }); - return this; - }; + // Retrieve the "count" result of the query. + count: function(column) { + return this._aggregate('count', (column || '*')); + }, - // Adds a `having` clause to the query. - QueryBuilder.prototype.having = - QueryBuilder.prototype.andHaving = function(column, operator, value) { - if (column instanceof Raw && arguments.length === 1) { - return this._havingRaw(column); - } - - // Check if the column is a function, in which case it's - // a having statement wrapped in parens. - if (typeof column === 'function') { - return this.havingWrapped(column); - } - - this._statements.push({ - grouping: 'having', - type: 'havingBasic', - column: column, - operator: operator, - value: value, - bool: this._bool() - }); - return this; - }; - // Adds an `or having` clause to the query. - QueryBuilder.prototype.orHaving = function() { - return this._bool('or').having.apply(this, arguments); - }; - QueryBuilder.prototype.havingRaw = function(sql, bindings) { - return this._havingRaw(sql, bindings); - }; - QueryBuilder.prototype.orHavingRaw = function(sql, bindings) { - return this._bool('or').havingRaw(sql, bindings); - }; - // Adds a raw `having` clause to the query. - QueryBuilder.prototype._havingRaw = function(sql, bindings) { - var raw = (sql instanceof Raw ? sql : this.client.raw(sql, bindings)); - this._statements.push({ - grouping: 'having', - type: 'havingRaw', - value: raw, - bool: this._bool() - }); - return this; - }; + // Retrieve the minimum value of a given column. + min: function(column) { + return this._aggregate('min', column); + }, - // Only allow a single "offset" to be set for the current query. - QueryBuilder.prototype.offset = function(value) { - this._single.offset = value; - return this; - }; + // Retrieve the maximum value of a given column. + max: function(column) { + return this._aggregate('max', column); + }, - // Only allow a single "limit" to be set for the current query. - QueryBuilder.prototype.limit = function(value) { - this._single.limit = value; - return this; - }; + // Retrieve the sum of the values of a given column. + sum: function(column) { + return this._aggregate('sum', column); + }, - // Retrieve the "count" result of the query. - QueryBuilder.prototype.count = function(column) { - return this._aggregate('count', (column || '*')); - }; + // Retrieve the average of the values of a given column. + avg: function(column) { + return this._aggregate('avg', column); + }, - // Retrieve the minimum value of a given column. - QueryBuilder.prototype.min = function(column) { - return this._aggregate('min', column); - }; + // Increments a column's value by the specified amount. + increment: function(column, amount) { + return this._counter(column, amount); + }, - // Retrieve the maximum value of a given column. - QueryBuilder.prototype.max = function(column) { - return this._aggregate('max', column); - }; + // Decrements a column's value by the specified amount. + decrement: function(column, amount) { + return this._counter(column, amount, '-'); + }, - // Retrieve the sum of the values of a given column. - QueryBuilder.prototype.sum = function(column) { - return this._aggregate('sum', column); - }; - - // Retrieve the average of the values of a given column. - QueryBuilder.prototype.avg = function(column) { - return this._aggregate('avg', column); - }; - - // Increments a column's value by the specified amount. - QueryBuilder.prototype.increment = function(column, amount) { - return this._counter(column, amount); - }; - - // Decrements a column's value by the specified amount. - QueryBuilder.prototype.decrement = function(column, amount) { - return this._counter(column, amount, '-'); - }; - - // Sets the values for a `select` query, informing that only the first - // row should be returned (limit 1). - QueryBuilder.prototype.first = function() { - var i, args = new Array(arguments.length); - for (i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - this.select.apply(this, args); - this._method = 'first'; - this.limit(1); - return this; - }; - - // Pluck a column from a query. - QueryBuilder.prototype.pluck = function(column) { - this._method = 'pluck'; - this._single.pluck = column; - this._statements.push({ - grouping: 'columns', - type: 'pluck', - value: column - }); - return this; - }; - - // Insert & Update - // ------ - - // Sets the values for an `insert` query. - QueryBuilder.prototype.insert = function(values, returning) { - this._method = 'insert'; - if (!_.isEmpty(returning)) this.returning(returning); - this._single.insert = values - return this; - }; - - // Sets the values for an `update`, allowing for both - // `.update(key, value, [returning])` and `.update(obj, [returning])` syntaxes. - QueryBuilder.prototype.update = function(values, returning) { - var ret, obj = {}; - this._method = 'update'; - var i, args = new Array(arguments.length); - for (i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - if (_.isString(values)) { - obj[values] = returning; - if (args.length > 2) { - ret = args[2]; + // Sets the values for a `select` query, informing that only the first + // row should be returned (limit 1). + first: function() { + var i, args = new Array(arguments.length); + for (i = 0; i < args.length; i++) { + args[i] = arguments[i]; } - } else { - obj = values; - ret = args[1]; - } - if (!_.isEmpty(ret)) this.returning(ret); - this._single.update = obj; - return this; - }; + this.select.apply(this, args); + this._method = 'first'; + this.limit(1); + return this; + }, - // Sets the returning value for the query. - QueryBuilder.prototype.returning = function(returning) { - this._single.returning = returning; - return this; - }; + // Pluck a column from a query. + pluck: function(column) { + this._method = 'pluck'; + this._single.pluck = column; + this._statements.push({ + grouping: 'columns', + type: 'pluck', + value: column + }); + return this; + }, - // Delete - // ------ + // Insert & Update + // ------ - // Executes a delete statement on the query; - QueryBuilder.prototype.delete = function(ret) { - this._method = 'del'; - if (!_.isEmpty(ret)) this.returning(ret); - return this; - }; - QueryBuilder.prototype.del = QueryBuilder.prototype.delete + // Sets the values for an `insert` query. + insert: function(values, returning) { + this._method = 'insert'; + if (!_.isEmpty(returning)) this.returning(returning); + this._single.insert = values + return this; + }, - // Truncates a table, ends the query chain. - QueryBuilder.prototype.truncate = function(tableName) { - this._method = 'truncate'; - if (tableName) { - this._single.table = tableName - } - return this; - }; + // Sets the values for an `update`, allowing for both + // `.update(key, value, [returning])` and `.update(obj, [returning])` syntaxes. + update: function(values, returning) { + var ret, obj = this._single.update || {}; + this._method = 'update'; + if (_.isString(values)) { + obj[values] = returning; + if (arguments.length > 2) { + ret = arguments[2]; + } + } else { + var i = -1, keys = Object.keys(values) + if (this._single.update) { + helpers.warn('Update called multiple times with objects.') + } + while (++i < keys.length) { + obj[keys[i]] = values[keys[i]] + } + ret = arguments[1]; + } + if (!_.isEmpty(ret)) this.returning(ret); + this._single.update = obj; + return this; + }, - // Retrieves columns for the table specified by `knex(tableName)` - QueryBuilder.prototype.columnInfo = function(column) { - this._method = 'columnInfo'; - this._single.columnInfo = column; - return this; - }; + // Sets the returning value for the query. + returning: function(returning) { + this._single.returning = returning; + return this; + }, - // Set a lock for update constraint. - QueryBuilder.prototype.forUpdate = function() { - this._single.lock = 'forUpdate'; - return this; - }; + // Delete + // ------ - // Set a lock for share constraint. - QueryBuilder.prototype.forShare = function() { - this._single.lock = 'forShare'; - return this; - }; + // Executes a delete statement on the query; + delete: function(ret) { + this._method = 'del'; + if (!_.isEmpty(ret)) this.returning(ret); + return this; + }, - // ---------------------------------------------------------------------- - // Helper for the incrementing/decrementing queries. - QueryBuilder.prototype._counter = function(column, amount, symbol) { - var amt = parseInt(amount, 10); - if (isNaN(amt)) amt = 1; - this._method = 'counter'; - this._single.counter = { - column: column, - amount: amt, - symbol: (symbol || '+') - }; - return this; - }; + // Truncates a table, ends the query chain. + truncate: function(tableName) { + this._method = 'truncate'; + if (tableName) { + this._single.table = tableName + } + return this; + }, - // Helper to get or set the "boolFlag" value. - QueryBuilder.prototype._bool = function(val) { - if (arguments.length === 1) { - this._boolFlag = val; + // Retrieves columns for the table specified by `knex(tableName)` + columnInfo: function(column) { + this._method = 'columnInfo'; + this._single.columnInfo = column; + return this; + }, + + // Set a lock for update constraint. + forUpdate: function() { + this._single.lock = 'forUpdate'; + return this; + }, + + // Set a lock for share constraint. + forShare: function() { + this._single.lock = 'forShare'; + return this; + }, + + // Takes a JS object of methods to call and calls them + fromJS: function(obj) { + _.each(obj, function(val, key) { + if (typeof this[key] !== 'function') { + helpers.warn('Knex Error: unknown key ' + key) + } + if (Array.isArray(val)) { + this[key].apply(this, val) + } else { + this[key](val) + } + }, this) + return this + }, + + // ---------------------------------------------------------------------- + + // Helper for the incrementing/decrementing queries. + _counter: function(column, amount, symbol) { + var amt = parseInt(amount, 10); + if (isNaN(amt)) amt = 1; + this._method = 'counter'; + this._single.counter = { + column: column, + amount: amt, + symbol: (symbol || '+') + }; + return this; + }, + + // Helper to get or set the "boolFlag" value. + _bool: function(val) { + if (arguments.length === 1) { + this._boolFlag = val; + return this; + } + var ret = this._boolFlag; + this._boolFlag = 'and'; + return ret; + }, + + // Helper to get or set the "notFlag" value. + _not: function(val) { + if (arguments.length === 1) { + this._notFlag = val; + return this; + } + var ret = this._notFlag; + this._notFlag = false; + return ret; + }, + + // Helper to get or set the "joinFlag" value. + _joinType: function (val) { + if (arguments.length === 1) { + this._joinFlag = val; + return this; + } + var ret = this._joinFlag || 'inner'; + this._joinFlag = 'inner'; + return ret; + }, + + // Helper for compiling any aggregate queries. + _aggregate: function(method, column) { + this._statements.push({ + grouping: 'columns', + type: 'aggregate', + method: method, + value: column + }); return this; } - var ret = this._boolFlag; - this._boolFlag = 'and'; - return ret; - }; - // Helper to get or set the "notFlag" value. - QueryBuilder.prototype._not = function(val) { - if (arguments.length === 1) { - this._notFlag = val; - return this; - } - var ret = this._notFlag; - this._notFlag = false; - return ret; - }; - - // Helper to get or set the "joinFlag" value. - QueryBuilder.prototype._joinType = function (val) { - if (arguments.length === 1) { - this._joinFlag = val; - return this; - } - var ret = this._joinFlag || 'inner'; - this._joinFlag = 'inner'; - return ret; - }; - - // Helper for compiling any aggregate queries. - QueryBuilder.prototype._aggregate = function(method, column) { - this._statements.push({ - grouping: 'columns', - type: 'aggregate', - method: method, - value: column - }); - return this; - }; + }) Object.defineProperty(QueryBuilder.prototype, 'or', { get: function () { @@ -2678,24 +2533,34 @@ return /******/ (function(modules) { // webpackBootstrap } }); + QueryBuilder.prototype.select = QueryBuilder.prototype.columns + QueryBuilder.prototype.column = QueryBuilder.prototype.columns + QueryBuilder.prototype.andWhereNot = QueryBuilder.prototype.whereNot + QueryBuilder.prototype.andWhere = QueryBuilder.prototype.where + QueryBuilder.prototype.andWhereRaw = QueryBuilder.prototype.whereRaw + QueryBuilder.prototype.andHaving = QueryBuilder.prototype.having + QueryBuilder.prototype.from = QueryBuilder.prototype.table + QueryBuilder.prototype.into = QueryBuilder.prototype.table + QueryBuilder.prototype.del = QueryBuilder.prototype.delete + // Attach all of the top level promise methods that should be chainable. - __webpack_require__(15)(QueryBuilder); + __webpack_require__(12)(QueryBuilder); module.exports = QueryBuilder; /***/ }, -/* 21 */ +/* 17 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // Query Compiler // ------- - var _ = __webpack_require__(12); - var helpers = __webpack_require__(4); - var Raw = __webpack_require__(3); - var assign = __webpack_require__(14) + var _ = __webpack_require__(11); + var helpers = __webpack_require__(2); + var Raw = __webpack_require__(1); + var assign = __webpack_require__(27) // The "QueryCompiler" takes all of the query statements which // have been gathered in the "QueryBuilder" and turns them into a @@ -2841,25 +2706,26 @@ return /******/ (function(modules) { // webpackBootstrap // Compiles all each of the `join` clauses on the query, // including any nested join queries. join: function() { - var joins = this.grouped.join; + var sql = '', i = -1, joins = this.grouped.join; if (!joins) return ''; - var sql = _.reduce(joins, function(acc, join) { + while (++i < joins.length) { + var join = joins[i] + if (i > 0) sql += ' ' if (join.joinType === 'raw') { - acc.push(this.formatter.unwrapRaw(join.table)); + sql += this.formatter.unwrapRaw(join.table) } else { - acc.push(join.joinType + ' join ' + this.formatter.wrap(join.table)); - var i = -1; - while (++i < join.clauses.length) { - var clause = join.clauses[i] - acc.push(i > 0 ? clause[1] : clause[0]); - acc.push(this.formatter.wrap(clause[2])); - if (clause[3]) acc.push(this.formatter.operator(clause[3])); - if (clause[4]) acc.push(this.formatter.wrap(clause[4])); + sql += join.joinType + ' join ' + this.formatter.wrap(join.table) + var ii = -1 + while (++ii < join.clauses.length) { + var clause = join.clauses[ii] + sql += ' ' + (ii > 0 ? clause[0] : clause[1]) + ' ' + sql += this.formatter.wrap(clause[2]) + if (clause[3]) sql += ' ' + this.formatter.operator(clause[3]) + if (clause[4]) sql += ' ' + this.formatter.wrap(clause[4]) } } - return acc; - }, [], this); - return sql.length > 0 ? sql.join(' ') : ''; + } + return sql; }, // Compiles all `where` statements on the query. @@ -3070,6 +2936,7 @@ return /******/ (function(modules) { // webpackBootstrap while (++k < values.length) { values[k].splice(idx, 0, undefined) } + row.splice(idx, 0, undefined) } row[idx] = data[i][key] } @@ -3125,14 +2992,14 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 22 */ +/* 18 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var _ = __webpack_require__(12) - var inherits = __webpack_require__(46) - var EventEmitter = __webpack_require__(42).EventEmitter + var _ = __webpack_require__(11) + var inherits = __webpack_require__(44) + var EventEmitter = __webpack_require__(41).EventEmitter // Constructor for the builder instance, typically called from // `knex.builder`, accepting the current `knex` instance, @@ -3141,6 +3008,7 @@ return /******/ (function(modules) { // webpackBootstrap function SchemaBuilder(client) { this.client = client this._sequence = [] + this._debug = client.config && client.config.debug } inherits(SchemaBuilder, EventEmitter) @@ -3164,8 +3032,7 @@ return /******/ (function(modules) { // webpackBootstrap 'dropTable', 'renameTable', 'dropTableIfExists', - 'raw', - 'debug' + 'raw' ], function(method) { SchemaBuilder.prototype[method] = function() { if (method === 'table') method = 'alterTable'; @@ -3177,7 +3044,7 @@ return /******/ (function(modules) { // webpackBootstrap } }) - __webpack_require__(15)(SchemaBuilder) + __webpack_require__(12)(SchemaBuilder) SchemaBuilder.prototype.toString = function() { return this.toQuery() @@ -3191,13 +3058,13 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 23 */ +/* 19 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var helpers = __webpack_require__(79) - var assign = __webpack_require__(14); + var helpers = __webpack_require__(56) + var assign = __webpack_require__(27); // The "SchemaCompiler" takes all of the query statements which have been // gathered in the "SchemaBuilder" and turns them into an array of @@ -3258,7 +3125,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 24 */ +/* 20 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -3271,8 +3138,8 @@ return /******/ (function(modules) { // webpackBootstrap // method, pushing everything we want to do onto the "allStatements" array, // which is then compiled into sql. // ------ - var _ = __webpack_require__(12); - var helpers = __webpack_require__(4); + var _ = __webpack_require__(11); + var helpers = __webpack_require__(2); function TableBuilder(client, method, tableName, fn) { this.client = client @@ -3514,16 +3381,16 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 25 */ +/* 21 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // Table Compiler // ------- - var _ = __webpack_require__(12); - var helpers = __webpack_require__(79); - var normalizeArr = __webpack_require__(4).normalizeArr + var _ = __webpack_require__(11); + var helpers = __webpack_require__(56); + var normalizeArr = __webpack_require__(2).normalizeArr function TableCompiler(client, tableBuilder) { this.client = client @@ -3686,12 +3553,12 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = TableCompiler; /***/ }, -/* 26 */ +/* 22 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var _ = __webpack_require__(12); + var _ = __webpack_require__(11); // The chainable interface off the original "column" method. function ColumnBuilder(client, tableBuilder, type, args) { @@ -3788,7 +3655,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 27 */ +/* 23 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -3797,9 +3664,9 @@ return /******/ (function(modules) { // webpackBootstrap // Used for designating column definitions // during the table "create" / "alter" statements. // ------- - var _ = __webpack_require__(12); - var Raw = __webpack_require__(3); - var helpers = __webpack_require__(79) + var _ = __webpack_require__(11); + var Raw = __webpack_require__(1); + var helpers = __webpack_require__(56) function ColumnCompiler(client, tableCompiler, columnBuilder) { this.client = client @@ -3936,98 +3803,128 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 28 */ +/* 24 */ /***/ function(module, exports, __webpack_require__) { - var baseToString = __webpack_require__(90); + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict' - /** Used to generate unique IDs. */ - var idCounter = 0; + var SqlString = exports; + var helpers = __webpack_require__(2) - /** - * Generates a unique ID. If `prefix` is provided the ID is appended to it. - * - * @static - * @memberOf _ - * @category Utility - * @param {string} [prefix] The value to prefix the ID with. - * @returns {string} Returns the unique ID. - * @example - * - * _.uniqueId('contact_'); - * // => 'contact_104' - * - * _.uniqueId(); - * // => '105' - */ - function uniqueId(prefix) { - var id = ++idCounter; - return baseToString(prefix) + id; + SqlString.escape = function(val, timeZone) { + if (val == null) { + return 'NULL'; + } + + switch (typeof val) { + case 'boolean': return (val) ? 'true' : 'false'; + case 'number': return val+''; + } + + if (val instanceof Date) { + val = SqlString.dateToString(val, timeZone || 'local'); + } + + if (Buffer.isBuffer(val)) { + return SqlString.bufferToString(val); + } + + if (Array.isArray(val)) { + return SqlString.arrayToList(val, timeZone); + } + + if (typeof val === 'object') { + try { + val = JSON.stringify(val) + } catch (e) { + helpers.warn(e) + val = val + '' + } + } + + val = val.replace(/[\0\n\r\b\t\\\'\"\x1a]/g, function(s) { + switch(s) { + case "\0": return "\\0"; + case "\n": return "\\n"; + case "\r": return "\\r"; + case "\b": return "\\b"; + case "\t": return "\\t"; + case "\x1a": return "\\Z"; + default: return "\\"+s; + } + }); + return "'"+val+"'"; + }; + + SqlString.arrayToList = function(array, timeZone) { + return array.map(function(v) { + if (Array.isArray(v)) return '(' + SqlString.arrayToList(v, timeZone) + ')'; + return SqlString.escape(v, timeZone); + }).join(', '); + }; + + SqlString.format = function(sql, values, timeZone) { + values = values == null ? [] : [].concat(values); + var index = 0; + return sql.replace(/\?/g, function(match) { + if (index === values.length) { + return match; + } + var value = values[index++]; + return SqlString.escape(value, timeZone) + }); + }; + + SqlString.dateToString = function(date, timeZone) { + var dt = new Date(date); + + if (timeZone !== 'local') { + var tz = convertTimezone(timeZone); + + dt.setTime(dt.getTime() + (dt.getTimezoneOffset() * 60000)); + if (tz !== false) { + dt.setTime(dt.getTime() + (tz * 60000)); + } + } + + var year = dt.getFullYear(); + var month = zeroPad(dt.getMonth() + 1, 2); + var day = zeroPad(dt.getDate(), 2); + var hour = zeroPad(dt.getHours(), 2); + var minute = zeroPad(dt.getMinutes(), 2); + var second = zeroPad(dt.getSeconds(), 2); + var millisecond = zeroPad(dt.getMilliseconds(), 3); + + return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second + '.' + millisecond; + }; + + SqlString.bufferToString = function bufferToString(buffer) { + return "X'" + buffer.toString('hex') + "'"; } - module.exports = uniqueId; + function zeroPad(number, length) { + number = number.toString(); + while (number.length < length) { + number = '0' + number; + } - -/***/ }, -/* 29 */ -/***/ function(module, exports, __webpack_require__) { - - var baseClone = __webpack_require__(88), - bindCallback = __webpack_require__(89); - - /** - * Creates a deep clone of `value`. If `customizer` is provided it is invoked - * to produce the cloned values. If `customizer` returns `undefined` cloning - * is handled by the method instead. The `customizer` is bound to `thisArg` - * and invoked with two argument; (value [, index|key, object]). - * - * **Note:** This method is loosely based on the structured clone algorithm. - * The enumerable properties of `arguments` objects and objects created by - * constructors other than `Object` are cloned to plain `Object` objects. An - * empty object is returned for uncloneable values such as functions, DOM nodes, - * Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) - * for more details. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to deep clone. - * @param {Function} [customizer] The function to customize cloning values. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {*} Returns the deep cloned value. - * @example - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; - * - * var deep = _.cloneDeep(users); - * deep[0] === users[0]; - * // => false - * - * // using a customizer callback - * var el = _.cloneDeep(document.body, function(value) { - * return _.isElement(value) ? value.cloneNode(true) : undefined; - * }); - * - * body === document.body - * // => false - * body.nodeName - * // => BODY - * body.childNodes.length; - * // => 20 - */ - function cloneDeep(value, customizer, thisArg) { - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); - return baseClone(value, true, customizer); + return number; } - module.exports = cloneDeep; + function convertTimezone(tz) { + if (tz === "Z") return 0; + var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/); + if (m) { + return (m[1] === '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60; + } + return false; + } + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) /***/ }, -/* 30 */ +/* 25 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -4045,7 +3942,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = FunctionHelper /***/ }, -/* 31 */ +/* 26 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -4130,46 +4027,187 @@ return /******/ (function(modules) { // webpackBootstrap ]; /***/ }, -/* 32 */ +/* 27 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; + var baseAssign = __webpack_require__(57), + createAssigner = __webpack_require__(58); - // Stub Migrate: - // Used for now in browser builds, where filesystem access isn't - // available. Maybe we can eventually do websql migrations - // with jsonp and a json migration api. - var StubMigrate = module.exports = function() {}; + /** + * Assigns own enumerable properties of source object(s) to the destination + * object. Subsequent sources overwrite property assignments of previous sources. + * If `customizer` is provided it is invoked to produce the assigned values. + * The `customizer` is bound to `thisArg` and invoked with five arguments; + * (objectValue, sourceValue, key, object, source). + * + * @static + * @memberOf _ + * @alias extend + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @param {Function} [customizer] The function to customize assigning values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {Object} Returns `object`. + * @example + * + * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); + * // => { 'user': 'fred', 'age': 40 } + * + * // using a customizer callback + * var defaults = _.partialRight(_.assign, function(value, other) { + * return typeof value == 'undefined' ? other : value; + * }); + * + * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); + * // => { 'user': 'barney', 'age': 36 } + */ + var assign = createAssigner(baseAssign); - var Promise = __webpack_require__(83) - - var noSuchMethod = Promise.method(function() { - throw new Error("Migrations are not supported"); - }); - - StubMigrate.prototype = { - make: noSuchMethod, - latest: noSuchMethod, - rollback: noSuchMethod, - currentVersion: noSuchMethod - }; + module.exports = assign; /***/ }, -/* 33 */ +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * A no-operation function. + * + * @static + * @memberOf _ + * @category Utility + * @example + * + * var object = { 'user': 'fred' }; + * _.noop(object) === undefined; + * // => true + */ + function noop() { + // No operation performed. + } + + module.exports = noop; + + +/***/ }, +/* 29 */ +/***/ function(module, exports, __webpack_require__) { + + var baseToString = __webpack_require__(59); + + /** Used to generate unique IDs. */ + var idCounter = 0; + + /** + * Generates a unique ID. If `prefix` is provided the ID is appended to it. + * + * @static + * @memberOf _ + * @category Utility + * @param {string} [prefix] The value to prefix the ID with. + * @returns {string} Returns the unique ID. + * @example + * + * _.uniqueId('contact_'); + * // => 'contact_104' + * + * _.uniqueId(); + * // => '105' + */ + function uniqueId(prefix) { + var id = ++idCounter; + return baseToString(prefix) + id; + } + + module.exports = uniqueId; + + +/***/ }, +/* 30 */ +/***/ function(module, exports, __webpack_require__) { + + var baseClone = __webpack_require__(60), + bindCallback = __webpack_require__(61); + + /** + * Creates a deep clone of `value`. If `customizer` is provided it is invoked + * to produce the cloned values. If `customizer` returns `undefined` cloning + * is handled by the method instead. The `customizer` is bound to `thisArg` + * and invoked with two argument; (value [, index|key, object]). + * + * **Note:** This method is loosely based on the structured clone algorithm. + * The enumerable properties of `arguments` objects and objects created by + * constructors other than `Object` are cloned to plain `Object` objects. An + * empty object is returned for uncloneable values such as functions, DOM nodes, + * Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) + * for more details. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to deep clone. + * @param {Function} [customizer] The function to customize cloning values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {*} Returns the deep cloned value. + * @example + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * var deep = _.cloneDeep(users); + * deep[0] === users[0]; + * // => false + * + * // using a customizer callback + * var el = _.cloneDeep(document.body, function(value) { + * return _.isElement(value) ? value.cloneNode(true) : undefined; + * }); + * + * body === document.body + * // => false + * body.nodeName + * // => BODY + * body.childNodes.length; + * // => 20 + */ + function cloneDeep(value, customizer, thisArg) { + customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); + return baseClone(value, true, customizer); + } + + module.exports = cloneDeep; + + +/***/ }, +/* 31 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict' + + // Use this shim module rather than "bluebird/js/main/promise" + // when bundling for client + module.exports = function() { + return __webpack_require__(43) + } + +/***/ }, +/* 32 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // MariaSQL Client // ------- - var inherits = __webpack_require__(46) - var assign = __webpack_require__(14) - var Client_MySQL = __webpack_require__(34) - var Promise = __webpack_require__(16) - var SqlString = __webpack_require__(78) - var helpers = __webpack_require__(4) - var pluck = __webpack_require__(91); + var inherits = __webpack_require__(44) + var assign = __webpack_require__(27) + var Client_MySQL = __webpack_require__(33) + var Promise = __webpack_require__(8) + var SqlString = __webpack_require__(24) + var helpers = __webpack_require__(2) + var pluck = __webpack_require__(62) function Client_MariaSQL(config) { Client_MySQL.call(this, config) @@ -4178,10 +4216,14 @@ return /******/ (function(modules) { // webpackBootstrap assign(Client_MariaSQL.prototype, { - dialect: 'mariasql', + dialect: 'mariadb', driverName: 'mariasql', + _driver: function() { + return __webpack_require__(46) + }, + // Get a raw connection, called by the `pool` whenever a new // connection needs to be added to the pool. acquireRawConnection: function() { @@ -4231,7 +4273,7 @@ return /******/ (function(modules) { // webpackBootstrap return new Promise(function(resolver, rejecter) { if (!obj.sql) return resolver() var rows = []; - var query = connection.query(SqlString.format(obj.sql, obj.bindings, false, tz), []) + var query = connection.query(SqlString.format(obj.sql, obj.bindings, tz), []) query.on('result', function(result) { result.on('row', rowHandler(function(row) { rows.push(row); })) .on('end', function(data) { @@ -4299,25 +4341,25 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 34 */ +/* 33 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // MySQL Client // ------- - var inherits = __webpack_require__(46) - var assign = __webpack_require__(14) + var inherits = __webpack_require__(44) + var assign = __webpack_require__(27) - var Client = __webpack_require__(5) - var Promise = __webpack_require__(16) - var helpers = __webpack_require__(4) + var Client = __webpack_require__(3) + var Promise = __webpack_require__(8) + var helpers = __webpack_require__(2) - var QueryCompiler = __webpack_require__(49) - var SchemaCompiler = __webpack_require__(51) - var TableCompiler = __webpack_require__(52) - var ColumnCompiler = __webpack_require__(50) - var pluck = __webpack_require__(91) + var QueryCompiler = __webpack_require__(63) + var SchemaCompiler = __webpack_require__(64) + var TableCompiler = __webpack_require__(65) + var ColumnCompiler = __webpack_require__(66) + var pluck = __webpack_require__(62) // Always initialize with the "QueryBuilder" and "QueryCompiler" // objects, which extend the base 'lib/query/builder' and @@ -4333,6 +4375,10 @@ return /******/ (function(modules) { // webpackBootstrap driverName: 'mysql', + _driver: function() { + return __webpack_require__(47) + }, + QueryCompiler: QueryCompiler, SchemaCompiler: SchemaCompiler, @@ -4350,7 +4396,6 @@ return /******/ (function(modules) { // webpackBootstrap acquireRawConnection: function() { var client = this var connection = this.driver.createConnection(this.connectionSettings) - this.databaseName = connection.config.database return new Promise(function(resolver, rejecter) { connection.connect(function(err) { if (err) return rejecter(err) @@ -4435,20 +4480,20 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 35 */ +/* 34 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // MySQL2 Client // ------- - var inherits = __webpack_require__(46) - var Client_MySQL = __webpack_require__(34) - var Promise = __webpack_require__(16) - var helpers = __webpack_require__(4) - var pick = __webpack_require__(92) - var pluck = __webpack_require__(91) - var assign = __webpack_require__(14); + var inherits = __webpack_require__(44) + var Client_MySQL = __webpack_require__(33) + var Promise = __webpack_require__(8) + var helpers = __webpack_require__(2) + var pick = __webpack_require__(67) + var pluck = __webpack_require__(62) + var assign = __webpack_require__(27); var configOptions = ['user', 'database', 'host', 'password', 'port', 'ssl', 'connection', 'stream']; @@ -4465,11 +4510,14 @@ return /******/ (function(modules) { // webpackBootstrap // The "dialect", for reference elsewhere. driverName: 'mysql2', + _driver: function() { + return __webpack_require__(48) + }, + // Get a raw connection, called by the `pool` whenever a new // connection needs to be added to the pool. acquireRawConnection: function() { var connection = this.driver.createConnection(pick(this.connectionSettings, configOptions)) - this.databaseName = connection.config.database; return new Promise(function(resolver, rejecter) { connection.connect(function(err) { if (err) return rejecter(err) @@ -4508,28 +4556,31 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 36 */ +/* 35 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; + /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; // Oracle Client // ------- - var _ = __webpack_require__(12) - var inherits = __webpack_require__(46) - var Client = __webpack_require__(5) - var Promise = __webpack_require__(16) - var Formatter = __webpack_require__(53) - var assign = __webpack_require__(14) - var helpers = __webpack_require__(4) + var _ = __webpack_require__(11) + var inherits = __webpack_require__(44) + var assign = __webpack_require__(27) - var Transaction = __webpack_require__(60) - var QueryCompiler = __webpack_require__(54) - var SchemaCompiler = __webpack_require__(57) - var ColumnBuilder = __webpack_require__(55) - var ColumnCompiler = __webpack_require__(56) - var TableCompiler = __webpack_require__(58) - var OracleQueryStream = __webpack_require__(59) + var Formatter = __webpack_require__(68) + var Client = __webpack_require__(3) + var Promise = __webpack_require__(8) + var helpers = __webpack_require__(2) + var SqlString = __webpack_require__(24) + + var Transaction = __webpack_require__(69) + var QueryCompiler = __webpack_require__(70) + var SchemaCompiler = __webpack_require__(71) + var ColumnBuilder = __webpack_require__(72) + var ColumnCompiler = __webpack_require__(73) + var TableCompiler = __webpack_require__(74) + var OracleQueryStream = __webpack_require__(75) + var ReturningHelper = __webpack_require__(76).ReturningHelper // Always initialize with the "QueryBuilder" and "QueryCompiler" // objects, which extend the base 'lib/query/builder' and @@ -4545,6 +4596,10 @@ return /******/ (function(modules) { // webpackBootstrap driverName: 'oracle', + _driver: function() { + return __webpack_require__(49) + }, + Transaction: Transaction, Formatter: Formatter, @@ -4559,6 +4614,22 @@ return /******/ (function(modules) { // webpackBootstrap TableCompiler: TableCompiler, + prepBindings: function(bindings) { + return _.map(bindings, function(value) { + // returning helper uses always ROWID as string + if (value instanceof ReturningHelper && this.driver) { + return new this.driver.OutParam(this.driver.OCCISTRING) + } + else if (typeof value === 'boolean') { + return value ? 1 : 0 + } + else if (Buffer.isBuffer(value)) { + return SqlString.bufferToString(value) + } + return value + }, this) + }, + // Get a raw connection, called by the `pool` whenever a new // connection needs to be added to the pool. acquireRawConnection: function() { @@ -4566,6 +4637,7 @@ return /******/ (function(modules) { // webpackBootstrap return new Promise(function(resolver, rejecter) { client.driver.connect(client.connectionSettings, function(err, connection) { + Promise.promisifyAll(connection) if (err) return rejecter(err) if (client.connectionSettings.prefetchRowCount) { connection.setPrefetchRowCount(client.connectionSettings.prefetchRowCount) @@ -4611,33 +4683,23 @@ return /******/ (function(modules) { // webpackBootstrap _query: function(connection, obj) { // convert ? params into positional bindings (:1) - obj.sql = this.client.positionBindings(obj.sql); + obj.sql = this.positionBindings(obj.sql); - obj.bindings = obj.bindings || []; + obj.bindings = this.prepBindings(obj.bindings) || []; if (!obj.sql) throw new Error('The query is empty'); - return new Promise(function(resolver, rejecter) { - connection.execute(obj.sql, obj.bindings, function(err, response) { - if (err) return rejecter(err); - - if (obj.returning) { - var rowIds = obj.outParams.map(function (v, i) { - return response['returnParam' + (i ? i : '')]; - }); - - return connection.execute(obj.returningSql, rowIds, function (err, subres) { - if (err) return rejecter(err); - obj.response = subres; - resolver(obj); - }); - - } else { - obj.response = response; - resolver(obj); - } + return connection.executeAsync(obj.sql, obj.bindings).then(function(response) { + if (!obj.returning) return response + var rowIds = obj.outParams.map(function (v, i) { + return response['returnParam' + (i ? i : '')]; }); - }); + return connection.executeAsync(obj.returningSql, rowIds) + }).then(function(response) { + obj.response = response; + return obj + }) + }, // Process the response as returned from the query. @@ -4673,26 +4735,27 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Client_Oracle + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) /***/ }, -/* 37 */ +/* 36 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; + /* WEBPACK VAR INJECTION */(function(process) {'use strict'; // PostgreSQL // ------- - var _ = __webpack_require__(12) - var inherits = __webpack_require__(46) - var Client = __webpack_require__(5) - var Promise = __webpack_require__(16) - var utils = __webpack_require__(66) - var assign = __webpack_require__(14) + var _ = __webpack_require__(11) + var inherits = __webpack_require__(44) + var Client = __webpack_require__(3) + var Promise = __webpack_require__(8) + var utils = __webpack_require__(77) + var assign = __webpack_require__(27) - var QueryCompiler = __webpack_require__(62) - var ColumnCompiler = __webpack_require__(63) - var TableCompiler = __webpack_require__(65) - var SchemaCompiler = __webpack_require__(64) + var QueryCompiler = __webpack_require__(78) + var ColumnCompiler = __webpack_require__(79) + var TableCompiler = __webpack_require__(80) + var SchemaCompiler = __webpack_require__(81) var PGQueryStream; function Client_PG(config) { @@ -4717,6 +4780,10 @@ return /******/ (function(modules) { // webpackBootstrap driverName: 'pg', + _driver: function() { + return __webpack_require__(50) + }, + wrapIdentifier: function(value) { if (value === '*') return value; var matched = value.match(/(.*?)(\[[0-9]\])/); @@ -4737,7 +4804,6 @@ return /******/ (function(modules) { // webpackBootstrap var client = this; return new Promise(function(resolver, rejecter) { var connection = new client.driver.Client(client.connectionSettings); - client.databaseName = connection.database; connection.connect(function(err, connection) { if (err) return rejecter(err); connection.on('error', client.__endConnection.bind(client, connection)); @@ -4781,7 +4847,7 @@ return /******/ (function(modules) { // webpackBootstrap }, _stream: function(connection, obj, stream, options) { - PGQueryStream = PGQueryStream || __webpack_require__(86); + PGQueryStream = process.browser ? undefined : __webpack_require__(51); var sql = obj.sql = this.positionBindings(obj.sql) return new Promise(function(resolver, rejecter) { stream.on('error', rejecter); @@ -4846,29 +4912,30 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Client_PG + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 38 */ +/* 37 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // SQLite3 // ------- - var Promise = __webpack_require__(16) + var Promise = __webpack_require__(8) - var inherits = __webpack_require__(46) - var assign = __webpack_require__(14) - var pluck = __webpack_require__(91); + var inherits = __webpack_require__(44) + var assign = __webpack_require__(27) + var pluck = __webpack_require__(62); - var Client = __webpack_require__(5) - var helpers = __webpack_require__(4) + var Client = __webpack_require__(3) + var helpers = __webpack_require__(2) - var QueryCompiler = __webpack_require__(67) - var SchemaCompiler = __webpack_require__(69) - var ColumnCompiler = __webpack_require__(68) - var TableCompiler = __webpack_require__(71) - var SQLite3_DDL = __webpack_require__(70) + var QueryCompiler = __webpack_require__(82) + var SchemaCompiler = __webpack_require__(83) + var ColumnCompiler = __webpack_require__(84) + var TableCompiler = __webpack_require__(85) + var SQLite3_DDL = __webpack_require__(86) function Client_SQLite3(config) { Client.call(this, config) @@ -4881,6 +4948,10 @@ return /******/ (function(modules) { // webpackBootstrap driverName: 'sqlite3', + _driver: function() { + return __webpack_require__(52) + }, + SchemaCompiler: SchemaCompiler, QueryCompiler: QueryCompiler, @@ -4994,37 +5065,42 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 39 */ +/* 38 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // Oracle Client // ------- - var inherits = __webpack_require__(46) - var Client_Oracle = __webpack_require__(36) + var inherits = __webpack_require__(44) + var Client_Oracle = __webpack_require__(35) + var helpers = __webpack_require__(2) function Client_StrongOracle() { Client_Oracle.apply(this, arguments); } inherits(Client_StrongOracle, Client_Oracle); + Client_StrongOracle.prototype._driver = function() { + return __webpack_require__(53)() + } + Client_StrongOracle.prototype.driverName = 'strong-oracle' module.exports = Client_StrongOracle; /***/ }, -/* 40 */ +/* 39 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var makeKnex = __webpack_require__(7) - var Promise = __webpack_require__(16) - var helpers = __webpack_require__(4) - var inherits = __webpack_require__(46) - var EventEmitter = __webpack_require__(42).EventEmitter + var makeKnex = __webpack_require__(5) + var Promise = __webpack_require__(8) + var helpers = __webpack_require__(2) + var inherits = __webpack_require__(44) + var EventEmitter = __webpack_require__(41).EventEmitter function Transaction_WebSQL(client, container) { helpers.warn('WebSQL transactions will run queries, but do not commit or rollback') @@ -5037,9 +5113,10 @@ return /******/ (function(modules) { // webpackBootstrap function makeClient(trx, client) { - var trxClient = Object.create(client.constructor.prototype) - trxClient.config = client.config - trxClient.transacting = true + var trxClient = Object.create(client.constructor.prototype) + trxClient.config = client.config + trxClient.connectionSettings = client.connectionSettings + trxClient.transacting = true trxClient.on('query', function(arg) { trx.emit('query', arg) @@ -5068,30 +5145,114 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 41 */ +/* 40 */ /***/ function(module, exports, __webpack_require__) { - /** - * A no-operation function. - * - * @static - * @memberOf _ - * @category Utility - * @example - * - * var object = { 'user': 'fred' }; - * _.noop(object) === undefined; - * // => true - */ - function noop() { - // No operation performed. + /* WEBPACK VAR INJECTION */(function(process) {'use strict'; + var escapeStringRegexp = __webpack_require__(108); + var ansiStyles = __webpack_require__(109); + var stripAnsi = __webpack_require__(110); + var hasAnsi = __webpack_require__(111); + var supportsColor = __webpack_require__(112); + var defineProps = Object.defineProperties; + + function Chalk(options) { + // detect mode if not set manually + this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled; } - module.exports = noop; + // use bright blue on Windows as the normal blue color is illegible + if (process.platform === 'win32') { + ansiStyles.blue.open = '\u001b[94m'; + } + function build(_styles) { + var builder = function builder() { + return applyStyle.apply(builder, arguments); + }; + builder._styles = _styles; + builder.enabled = this.enabled; + // __proto__ is used because we must return a function, but there is + // no way to create a function with a different prototype. + builder.__proto__ = proto; + return builder; + } + + var styles = (function () { + var ret = {}; + + Object.keys(ansiStyles).forEach(function (key) { + ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); + + ret[key] = { + get: function () { + return build.call(this, this._styles.concat(key)); + } + }; + }); + + return ret; + })(); + + var proto = defineProps(function chalk() {}, styles); + + function applyStyle() { + // support varags, but simply cast to string in case there's only one arg + var args = arguments; + var argsLen = args.length; + var str = argsLen !== 0 && String(arguments[0]); + if (argsLen > 1) { + // don't slice `arguments`, it prevents v8 optimizations + for (var a = 1; a < argsLen; a++) { + str += ' ' + args[a]; + } + } + + if (!this.enabled || !str) { + return str; + } + + /*jshint validthis: true */ + var nestedStyles = this._styles; + + var i = nestedStyles.length; + while (i--) { + var code = ansiStyles[nestedStyles[i]]; + // Replace any instances already present with a re-opening code + // otherwise only the part of the string until said closing code + // will be colored, and the rest will simply be 'plain'. + str = code.open + str.replace(code.closeRe, code.open) + code.close; + } + + return str; + } + + function init() { + var ret = {}; + + Object.keys(styles).forEach(function (name) { + ret[name] = { + get: function () { + return build.call(this, [name]); + } + }; + }); + + return ret; + } + + defineProps(Chalk.prototype, init()); + + module.exports = new Chalk(); + module.exports.styles = ansiStyles; + module.exports.hasColor = hasAnsi; + module.exports.stripColor = stripAnsi; + module.exports.supportsColor = supportsColor; + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 42 */ +/* 41 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -5398,127 +5559,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 43 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - var escapeStringRegexp = __webpack_require__(116); - var ansiStyles = __webpack_require__(117); - var stripAnsi = __webpack_require__(118); - var hasAnsi = __webpack_require__(119); - var supportsColor = __webpack_require__(120); - var defineProps = Object.defineProperties; - - function Chalk(options) { - // detect mode if not set manually - this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled; - } - - // use bright blue on Windows as the normal blue color is illegible - if (process.platform === 'win32') { - ansiStyles.blue.open = '\u001b[94m'; - } - - function build(_styles) { - var builder = function builder() { - return applyStyle.apply(builder, arguments); - }; - builder._styles = _styles; - builder.enabled = this.enabled; - // __proto__ is used because we must return a function, but there is - // no way to create a function with a different prototype. - builder.__proto__ = proto; - return builder; - } - - var styles = (function () { - var ret = {}; - - Object.keys(ansiStyles).forEach(function (key) { - ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); - - ret[key] = { - get: function () { - return build.call(this, this._styles.concat(key)); - } - }; - }); - - return ret; - })(); - - var proto = defineProps(function chalk() {}, styles); - - function applyStyle() { - // support varags, but simply cast to string in case there's only one arg - var args = arguments; - var argsLen = args.length; - var str = argsLen !== 0 && String(arguments[0]); - if (argsLen > 1) { - // don't slice `arguments`, it prevents v8 optimizations - for (var a = 1; a < argsLen; a++) { - str += ' ' + args[a]; - } - } - - if (!this.enabled || !str) { - return str; - } - - /*jshint validthis: true */ - var nestedStyles = this._styles; - - var i = nestedStyles.length; - while (i--) { - var code = ansiStyles[nestedStyles[i]]; - // Replace any instances already present with a re-opening code - // otherwise only the part of the string until said closing code - // will be colored, and the rest will simply be 'plain'. - str = code.open + str.replace(code.closeRe, code.open) + code.close; - } - - return str; - } - - function init() { - var ret = {}; - - Object.keys(styles).forEach(function (name) { - ret[name] = { - get: function () { - return build.call(this, [name]); - } - }; - }); - - return ret; - } - - defineProps(Chalk.prototype, init()); - - module.exports = new Chalk(); - module.exports.styles = ansiStyles; - module.exports.hasColor = hasAnsi; - module.exports.stripColor = stripAnsi; - module.exports.supportsColor = supportsColor; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) - -/***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Pool = __webpack_require__(94), - Cluster = __webpack_require__(95); - - Pool.Cluster = Cluster; - module.exports = Pool; - - -/***/ }, -/* 45 */ +/* 42 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -5542,7 +5583,7 @@ return /******/ (function(modules) { // webpackBootstrap // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - var punycode = __webpack_require__(115); + var punycode = __webpack_require__(99); exports.parse = urlParse; exports.resolve = urlResolve; @@ -5614,7 +5655,7 @@ return /******/ (function(modules) { // webpackBootstrap 'gopher:': true, 'file:': true }, - querystring = __webpack_require__(121); + querystring = __webpack_require__(113); function urlParse(url, parseQueryString, slashesDenoteHost) { if (url && isObject(url) && url instanceof Url) return url; @@ -6231,7 +6272,13 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 46 */ +/* 43 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_43__; + +/***/ }, +/* 44 */ /***/ function(module, exports, __webpack_require__) { if (typeof Object.create === 'function') { @@ -6260,19 +6307,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 47 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict' - - // Use this shim module rather than "bluebird/js/main/promise" - // when bundling for client - module.exports = function() { - return __webpack_require__(83) - } - -/***/ }, -/* 48 */ +/* 45 */ /***/ function(module, exports, __webpack_require__) { @@ -6282,7 +6317,7 @@ return /******/ (function(modules) { // webpackBootstrap * Expose `debug()` as the module. */ - exports = module.exports = __webpack_require__(97); + exports = module.exports = __webpack_require__(90); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; @@ -6452,17 +6487,583 @@ return /******/ (function(modules) { // webpackBootstrap } +/***/ }, +/* 46 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ + /***/ }, /* 49 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ + +/***/ }, +/* 50 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ + +/***/ }, +/* 51 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ + +/***/ }, +/* 52 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ + +/***/ }, +/* 53 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ + +/***/ }, +/* 54 */ +/***/ function(module, exports, __webpack_require__) { + + var arrayEach = __webpack_require__(91), + baseCallback = __webpack_require__(92), + baseCreate = __webpack_require__(93), + baseForOwn = __webpack_require__(94), + isArray = __webpack_require__(95), + isFunction = __webpack_require__(96), + isObject = __webpack_require__(97), + isTypedArray = __webpack_require__(98); + + /** + * An alternative to `_.reduce`; this method transforms `object` to a new + * `accumulator` object which is the result of running each of its own enumerable + * properties through `iteratee`, with each invocation potentially mutating + * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked + * with four arguments; (accumulator, value, key, object). Iterator functions + * may exit iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @category Object + * @param {Array|Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The custom accumulator value. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the accumulated value. + * @example + * + * var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) { + * n *= n; + * if (n % 2) { + * return result.push(n) < 3; + * } + * }); + * // => [1, 9, 25] + * + * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * result[key] = n * 3; + * }); + * // => { 'a': 3, 'b': 6, 'c': 9 } + */ + function transform(object, iteratee, accumulator, thisArg) { + var isArr = isArray(object) || isTypedArray(object); + iteratee = baseCallback(iteratee, thisArg, 4); + + if (accumulator == null) { + if (isArr || isObject(object)) { + var Ctor = object.constructor; + if (isArr) { + accumulator = isArray(object) ? new Ctor : []; + } else { + accumulator = baseCreate(isFunction(Ctor) && Ctor.prototype); + } + } else { + accumulator = {}; + } + } + (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; + } + + module.exports = transform; + + +/***/ }, +/* 55 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var assign = __webpack_require__(27); + + // JoinClause + // ------- + + // The "JoinClause" is an object holding any necessary info about a join, + // including the type, and any associated tables & columns being joined. + function JoinClause(table, type) { + this.table = table; + this.joinType = type; + this.and = this; + this.clauses = []; + } + + assign(JoinClause.prototype, { + + grouping: 'join', + + // Adds an "on" clause to the current join object. + on: function(first, operator, second) { + var data, bool = this._bool() + switch (arguments.length) { + case 1: { + if (typeof first === 'object' && typeof first.toSQL !== 'function') { + var i = -1, keys = Object.keys(first) + var method = bool === 'or' ? 'orOn' : 'on' + while (++i < keys.length) { + this[method](keys[i], first[keys[i]]) + } + return this; + } else { + data = [bool, 'on', first] + } + break; + } + case 2: data = [bool, 'on', first, '=', operator]; break; + default: data = [bool, 'on', first, operator, second]; + } + this.clauses.push(data); + return this; + }, + + // Adds a "using" clause to the current join. + using: function(table) { + return this.clauses.push([this._bool(), 'using', table]); + }, + + // Adds an "and on" clause to the current join object. + andOn: function() { + return this.on.apply(this, arguments); + }, + + // Adds an "or on" clause to the current join object. + orOn: function(first, operator, second) { + /*jshint unused: false*/ + return this._bool('or').on.apply(this, arguments); + }, + + // Explicitly set the type of join, useful within a function when creating a grouped join. + type: function(type) { + this.joinType = type; + return this; + }, + + _bool: function(bool) { + if (arguments.length === 1) { + this._boolFlag = bool; + return this; + } + var ret = this._boolFlag || 'and'; + this._boolFlag = 'and'; + return ret; + } + + }) + + Object.defineProperty(JoinClause.prototype, 'or', { + get: function () { + return this._bool('or'); + } + }); + + module.exports = JoinClause; + +/***/ }, +/* 56 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _ = __webpack_require__(11); + + // Push a new query onto the compiled "sequence" stack, + // creating a new formatter, returning the compiler. + exports.pushQuery = function(query) { + if (!query) return; + if (_.isString(query)) { + query = {sql: query}; + } else { + query = query; + } + if (!query.bindings) { + query.bindings = this.formatter.bindings; + } + this.sequence.push(query); + this.formatter = this.client.formatter(); + }; + + // Used in cases where we need to push some additional column specific statements. + exports.pushAdditional = function(fn) { + var child = new this.constructor(this.client, this.tableCompiler, this.columnBuilder); + fn.call(child, _.rest(arguments)); + this.sequence.additional = (this.sequence.additional || []).concat(child.sequence); + }; + + +/***/ }, +/* 57 */ +/***/ function(module, exports, __webpack_require__) { + + var baseCopy = __webpack_require__(100), + keys = __webpack_require__(101); + + /** + * The base implementation of `_.assign` without support for argument juggling, + * multiple sources, and `this` binding `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {Function} [customizer] The function to customize assigning values. + * @returns {Object} Returns the destination object. + */ + function baseAssign(object, source, customizer) { + var props = keys(source); + if (!customizer) { + return baseCopy(source, object, props); + } + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index], + value = object[key], + result = customizer(value, source[key], key, object, source); + + if ((result === result ? result !== value : value === value) || + (typeof value == 'undefined' && !(key in object))) { + object[key] = result; + } + } + return object; + } + + module.exports = baseAssign; + + +/***/ }, +/* 58 */ +/***/ function(module, exports, __webpack_require__) { + + var bindCallback = __webpack_require__(61), + isIterateeCall = __webpack_require__(102); + + /** + * Creates a function that assigns properties of source object(s) to a given + * destination object. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ + function createAssigner(assigner) { + return function() { + var length = arguments.length, + object = arguments[0]; + + if (length < 2 || object == null) { + return object; + } + if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { + length = 2; + } + // Juggle arguments. + if (length > 3 && typeof arguments[length - 2] == 'function') { + var customizer = bindCallback(arguments[--length - 1], arguments[length--], 5); + } else if (length > 2 && typeof arguments[length - 1] == 'function') { + customizer = arguments[--length]; + } + var index = 0; + while (++index < length) { + var source = arguments[index]; + if (source) { + assigner(object, source, customizer); + } + } + return object; + }; + } + + module.exports = createAssigner; + + +/***/ }, +/* 59 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Converts `value` to a string if it is not one. An empty string is returned + * for `null` or `undefined` values. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ + function baseToString(value) { + if (typeof value == 'string') { + return value; + } + return value == null ? '' : (value + ''); + } + + module.exports = baseToString; + + +/***/ }, +/* 60 */ +/***/ function(module, exports, __webpack_require__) { + + var arrayCopy = __webpack_require__(103), + arrayEach = __webpack_require__(91), + baseCopy = __webpack_require__(100), + baseForOwn = __webpack_require__(94), + initCloneArray = __webpack_require__(104), + initCloneByTag = __webpack_require__(105), + initCloneObject = __webpack_require__(106), + isArray = __webpack_require__(95), + isObject = __webpack_require__(97), + keys = __webpack_require__(101); + + /** `Object#toString` result references. */ + var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + mapTag = '[object Map]', + numberTag = '[object Number]', + objectTag = '[object Object]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + weakMapTag = '[object WeakMap]'; + + var arrayBufferTag = '[object ArrayBuffer]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + + /** Used to identify `toStringTag` values supported by `_.clone`. */ + var cloneableTags = {}; + cloneableTags[argsTag] = cloneableTags[arrayTag] = + cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = + cloneableTags[dateTag] = cloneableTags[float32Tag] = + cloneableTags[float64Tag] = cloneableTags[int8Tag] = + cloneableTags[int16Tag] = cloneableTags[int32Tag] = + cloneableTags[numberTag] = cloneableTags[objectTag] = + cloneableTags[regexpTag] = cloneableTags[stringTag] = + cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = + cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; + cloneableTags[errorTag] = cloneableTags[funcTag] = + cloneableTags[mapTag] = cloneableTags[setTag] = + cloneableTags[weakMapTag] = false; + + /** Used for native method references. */ + var objectProto = Object.prototype; + + /** + * Used to resolve the `toStringTag` of values. + * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) + * for more details. + */ + var objToString = objectProto.toString; + + /** + * The base implementation of `_.clone` without support for argument juggling + * and `this` binding `customizer` functions. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @param {Function} [customizer] The function to customize cloning values. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The object `value` belongs to. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates clones with source counterparts. + * @returns {*} Returns the cloned value. + */ + function baseClone(value, isDeep, customizer, key, object, stackA, stackB) { + var result; + if (customizer) { + result = object ? customizer(value, key, object) : customizer(value); + } + if (typeof result != 'undefined') { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return arrayCopy(value, result); + } + } else { + var tag = objToString.call(value), + isFunc = tag == funcTag; + + if (tag == objectTag || tag == argsTag || (isFunc && !object)) { + result = initCloneObject(isFunc ? {} : value); + if (!isDeep) { + return baseCopy(value, result, keys(value)); + } + } else { + return cloneableTags[tag] + ? initCloneByTag(value, tag, isDeep) + : (object ? value : {}); + } + } + // Check for circular references and return corresponding clone. + stackA || (stackA = []); + stackB || (stackB = []); + + var length = stackA.length; + while (length--) { + if (stackA[length] == value) { + return stackB[length]; + } + } + // Add the source value to the stack of traversed objects and associate it with its clone. + stackA.push(value); + stackB.push(result); + + // Recursively populate clone (susceptible to call stack limits). + (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { + result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); + }); + return result; + } + + module.exports = baseClone; + + +/***/ }, +/* 61 */ +/***/ function(module, exports, __webpack_require__) { + + var identity = __webpack_require__(107); + + /** + * A specialized version of `baseCallback` which only supports `this` binding + * and specifying the number of arguments to provide to `func`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ + function bindCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + if (typeof thisArg == 'undefined') { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; + } + return function() { + return func.apply(thisArg, arguments); + }; + } + + module.exports = bindCallback; + + +/***/ }, +/* 62 */ +/***/ function(module, exports, __webpack_require__) { + + var baseProperty = __webpack_require__(114), + map = __webpack_require__(115); + + /** + * Gets the value of `key` from all elements in `collection`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {string} key The key of the property to pluck. + * @returns {Array} Returns the property values. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * _.pluck(users, 'user'); + * // => ['barney', 'fred'] + * + * var userIndex = _.indexBy(users, 'user'); + * _.pluck(userIndex, 'age'); + * // => [36, 40] (iteration order is not guaranteed) + */ + function pluck(collection, key) { + return map(collection, baseProperty(key)); + } + + module.exports = pluck; + + +/***/ }, +/* 63 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // MySQL Query Compiler // ------ - var inherits = __webpack_require__(46) - var QueryCompiler = __webpack_require__(21) - var assign = __webpack_require__(14); + var inherits = __webpack_require__(44) + var QueryCompiler = __webpack_require__(17) + var assign = __webpack_require__(27); function QueryCompiler_MySQL(client, builder) { QueryCompiler.call(this, client, builder) @@ -6533,17 +7134,257 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 50 */ +/* 64 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + // MySQL Schema Compiler + // ------- + var inherits = __webpack_require__(44); + var SchemaCompiler = __webpack_require__(19); + var assign = __webpack_require__(27); + + function SchemaCompiler_MySQL(client, builder) { + SchemaCompiler.call(this, client, builder) + } + inherits(SchemaCompiler_MySQL, SchemaCompiler) + + assign(SchemaCompiler_MySQL.prototype, { + + // Rename a table on the schema. + renameTable: function(tableName, to) { + this.pushQuery('rename table ' + this.formatter.wrap(tableName) + ' to ' + this.formatter.wrap(to)); + }, + + // Check whether a table exists on the query. + hasTable: function(tableName) { + this.pushQuery({ + sql: 'show tables like ' + this.formatter.parameter(tableName), + output: function(resp) { + return resp.length > 0; + } + }); + }, + + // Check whether a column exists on the schema. + hasColumn: function(tableName, column) { + this.pushQuery({ + sql: 'show columns from ' + this.formatter.wrap(tableName) + + ' like ' + this.formatter.parameter(column), + output: function(resp) { + return resp.length > 0; + } + }); + } + + }) + + module.exports = SchemaCompiler_MySQL; + + +/***/ }, +/* 65 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + // MySQL Table Builder & Compiler + // ------- + var inherits = __webpack_require__(44); + var TableCompiler = __webpack_require__(21); + var helpers = __webpack_require__(2); + var Promise = __webpack_require__(8); + var assign = __webpack_require__(27); + + // Table Compiler + // ------ + + function TableCompiler_MySQL() { + TableCompiler.apply(this, arguments); + } + inherits(TableCompiler_MySQL, TableCompiler); + + assign(TableCompiler_MySQL.prototype, { + + createQuery: function(columns, ifNot) { + var createStatement = ifNot ? 'create table if not exists ' : 'create table '; + var client = this.client, conn = {}, + sql = createStatement + this.tableName() + ' (' + columns.sql.join(', ') + ')'; + + // Check if the connection settings are set. + if (client.connectionSettings) { + conn = client.connectionSettings; + } + + var charset = this.single.charset || conn.charset || ''; + var collation = this.single.collate || conn.collate || ''; + var engine = this.single.engine || ''; + + // var conn = builder.client.connectionSettings; + if (charset) sql += ' default character set ' + charset; + if (collation) sql += ' collate ' + collation; + if (engine) sql += ' engine = ' + engine; + + if (this.single.comment) { + var comment = (this.single.comment || ''); + if (comment.length > 60) helpers.warn('The max length for a table comment is 60 characters'); + sql += " comment = '" + comment + "'"; + } + + this.pushQuery(sql); + }, + + addColumnsPrefix: 'add ', + + dropColumnPrefix: 'drop ', + + // Compiles the comment on the table. + comment: function(comment) { + this.pushQuery('alter table ' + this.tableName() + " comment = '" + comment + "'"); + }, + + changeType: function() { + // alter table + table + ' modify ' + wrapped + '// type'; + }, + + // Renames a column on the table. + renameColumn: function(from, to) { + var compiler = this; + var table = this.tableName(); + var wrapped = this.formatter.wrap(from) + ' ' + this.formatter.wrap(to); + + this.pushQuery({ + sql: 'show fields from ' + table + ' where field = ' + + this.formatter.parameter(from), + output: function(resp) { + var column = resp[0]; + var runner = this; + return compiler.getFKRefs(runner).get(0) + .then(function (refs) { + return Promise.try(function () { + if (!refs.length) { return; } + return compiler.dropFKRefs(runner, refs); + }).then(function () { + return runner.query({ + sql: 'alter table ' + table + ' change ' + wrapped + ' ' + column.Type + }); + }).then(function () { + if (!refs.length) { return; } + return compiler.createFKRefs(runner, refs.map(function (ref) { + if (ref.REFERENCED_COLUMN_NAME === from) { + ref.REFERENCED_COLUMN_NAME = to; + } + if (ref.COLUMN_NAME === from) { + ref.COLUMN_NAME = to; + } + return ref; + })); + }); + }); + } + }); + }, + + getFKRefs: function (runner) { + var formatter = this.client.formatter(); + var sql = 'SELECT KCU.CONSTRAINT_NAME, KCU.TABLE_NAME, KCU.COLUMN_NAME, '+ + ' KCU.REFERENCED_TABLE_NAME, KCU.REFERENCED_COLUMN_NAME, '+ + ' RC.UPDATE_RULE, RC.DELETE_RULE '+ + 'FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU '+ + 'JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC '+ + ' USING(CONSTRAINT_NAME)' + + 'WHERE KCU.REFERENCED_TABLE_NAME = ' + formatter.parameter(this.tableNameRaw) + ' '+ + ' AND KCU.CONSTRAINT_SCHEMA = ' + formatter.parameter(this.client.database()); + + return runner.query({ + sql: sql, + bindings: formatter.bindings + }); + }, + + dropFKRefs: function (runner, refs) { + var formatter = this.client.formatter(); + + return Promise.all(refs.map(function (ref) { + var constraintName = formatter.wrap(ref.CONSTRAINT_NAME); + return runner.query({ + sql: 'alter table ' + this.tableName() + ' drop foreign key ' + constraintName + }); + }.bind(this))); + }, + createFKRefs: function (runner, refs) { + var formatter = this.client.formatter(); + + return Promise.all(refs.map(function (ref) { + var keyName = formatter.wrap(ref.COLUMN_NAME); + var column = formatter.columnize(ref.COLUMN_NAME); + var references = formatter.columnize(ref.REFERENCED_COLUMN_NAME); + var inTable = formatter.wrap(ref.REFERENCED_TABLE_NAME); + var onUpdate = ' ON UPDATE ' + ref.UPDATE_RULE; + var onDelete = ' ON DELETE ' + ref.DELETE_RULE; + + return runner.query({ + sql: 'alter table ' + this.tableName() + ' add constraint ' + keyName + ' ' + + 'foreign key (' + column + ') references ' + inTable + ' (' + references + ')' + onUpdate + onDelete + }); + }.bind(this))); + }, + index: function(columns, indexName) { + indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); + this.pushQuery('alter table ' + this.tableName() + " add index " + indexName + "(" + this.formatter.columnize(columns) + ")"); + }, + + primary: function(columns, indexName) { + indexName = indexName || this._indexCommand('primary', this.tableNameRaw, columns); + this.pushQuery('alter table ' + this.tableName() + " add primary key " + indexName + "(" + this.formatter.columnize(columns) + ")"); + }, + + unique: function(columns, indexName) { + indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); + this.pushQuery('alter table ' + this.tableName() + " add unique " + indexName + "(" + this.formatter.columnize(columns) + ")"); + }, + + // Compile a drop index command. + dropIndex: function(columns, indexName) { + indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); + this.pushQuery('alter table ' + this.tableName() + ' drop index ' + indexName); + }, + + // Compile a drop foreign key command. + dropForeign: function(columns, indexName) { + indexName = indexName || this._indexCommand('foreign', this.tableNameRaw, columns); + this.pushQuery('alter table ' + this.tableName() + ' drop foreign key ' + indexName); + }, + + // Compile a drop primary key command. + dropPrimary: function() { + this.pushQuery('alter table ' + this.tableName() + ' drop primary key'); + }, + + // Compile a drop unique key command. + dropUnique: function(column, indexName) { + indexName = indexName || this._indexCommand('unique', this.tableNameRaw, column); + this.pushQuery('alter table ' + this.tableName() + ' drop index ' + indexName); + } + + }) + + module.exports = TableCompiler_MySQL; + + +/***/ }, +/* 66 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // MySQL Column Compiler // ------- - var inherits = __webpack_require__(46) - var ColumnCompiler = __webpack_require__(27) - var helpers = __webpack_require__(4) - var assign = __webpack_require__(14); + var inherits = __webpack_require__(44) + var ColumnCompiler = __webpack_require__(23) + var helpers = __webpack_require__(2) + var assign = __webpack_require__(27); function ColumnCompiler_MySQL() { ColumnCompiler.apply(this, arguments); @@ -6655,255 +7496,62 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 51 */ +/* 67 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; + var baseFlatten = __webpack_require__(116), + bindCallback = __webpack_require__(61), + pickByArray = __webpack_require__(117), + pickByCallback = __webpack_require__(118); - // MySQL Schema Compiler - // ------- - var inherits = __webpack_require__(46); - var SchemaCompiler = __webpack_require__(23); - var assign = __webpack_require__(14); - - function SchemaCompiler_MySQL(client, builder) { - SchemaCompiler.call(this, client, builder) - } - inherits(SchemaCompiler_MySQL, SchemaCompiler) - - assign(SchemaCompiler_MySQL.prototype, { - - // Rename a table on the schema. - renameTable: function(tableName, to) { - this.pushQuery('rename table ' + this.formatter.wrap(tableName) + ' to ' + this.formatter.wrap(to)); - }, - - // Check whether a table exists on the query. - hasTable: function(tableName) { - this.pushQuery({ - sql: 'show tables like ' + this.formatter.parameter(tableName), - output: function(resp) { - return resp.length > 0; - } - }); - }, - - // Check whether a column exists on the schema. - hasColumn: function(tableName, column) { - this.pushQuery({ - sql: 'show columns from ' + this.formatter.wrap(tableName) + - ' like ' + this.formatter.parameter(column), - output: function(resp) { - return resp.length > 0; - } - }); + /** + * Creates an object composed of the picked `object` properties. Property + * names may be specified as individual arguments or as arrays of property + * names. If `predicate` is provided it is invoked for each property of `object` + * picking the properties `predicate` returns truthy for. The predicate is + * bound to `thisArg` and invoked with three arguments; (value, key, object). + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {Function|...(string|string[])} [predicate] The function invoked per + * iteration or property names to pick, specified as individual property + * names or arrays of property names. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'user': 'fred', 'age': 40 }; + * + * _.pick(object, 'user'); + * // => { 'user': 'fred' } + * + * _.pick(object, _.isString); + * // => { 'user': 'fred' } + */ + function pick(object, predicate, thisArg) { + if (object == null) { + return {}; } + return typeof predicate == 'function' + ? pickByCallback(object, bindCallback(predicate, thisArg, 3)) + : pickByArray(object, baseFlatten(arguments, false, false, 1)); + } - }) - - module.exports = SchemaCompiler_MySQL; + module.exports = pick; /***/ }, -/* 52 */ +/* 68 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - // MySQL Table Builder & Compiler - // ------- - var inherits = __webpack_require__(46); - var TableCompiler = __webpack_require__(25); - var helpers = __webpack_require__(4); - var Promise = __webpack_require__(16); - var assign = __webpack_require__(14); - - // Table Compiler - // ------ - - function TableCompiler_MySQL() { - TableCompiler.apply(this, arguments); - } - inherits(TableCompiler_MySQL, TableCompiler); - - assign(TableCompiler_MySQL.prototype, { - - createQuery: function(columns, ifNot) { - var createStatement = ifNot ? 'create table if not exists ' : 'create table '; - var client = this.client, conn = {}, - sql = createStatement + this.tableName() + ' (' + columns.sql.join(', ') + ')'; - - // Check if the connection settings are set. - if (client.connectionSettings) { - conn = client.connectionSettings; - } - - var charset = this.single.charset || conn.charset || ''; - var collation = this.single.collate || conn.collate || ''; - var engine = this.single.engine || ''; - - // var conn = builder.client.connectionSettings; - if (charset) sql += ' default character set ' + charset; - if (collation) sql += ' collate ' + collation; - if (engine) sql += ' engine = ' + engine; - - if (this.single.comment) { - var comment = (this.single.comment || ''); - if (comment.length > 60) helpers.warn('The max length for a table comment is 60 characters'); - sql += " comment = '" + comment + "'"; - } - - this.pushQuery(sql); - }, - - addColumnsPrefix: 'add ', - - dropColumnPrefix: 'drop ', - - // Compiles the comment on the table. - comment: function(comment) { - this.pushQuery('alter table ' + this.tableName() + " comment = '" + comment + "'"); - }, - - changeType: function() { - // alter table + table + ' modify ' + wrapped + '// type'; - }, - - // Renames a column on the table. - renameColumn: function(from, to) { - var compiler = this; - var table = this.tableName(); - var wrapped = this.formatter.wrap(from) + ' ' + this.formatter.wrap(to); - - this.pushQuery({ - sql: 'show fields from ' + table + ' where field = ' + - this.formatter.parameter(from), - output: function(resp) { - var column = resp[0]; - var runner = this; - return compiler.getFKRefs(runner).get(0) - .then(function (refs) { - return Promise.try(function () { - if (!refs.length) { return; } - return compiler.dropFKRefs(runner, refs); - }).then(function () { - return runner.query({ - sql: 'alter table ' + table + ' change ' + wrapped + ' ' + column.Type - }); - }).then(function () { - if (!refs.length) { return; } - return compiler.createFKRefs(runner, refs.map(function (ref) { - if (ref.REFERENCED_COLUMN_NAME === from) { - ref.REFERENCED_COLUMN_NAME = to; - } - if (ref.COLUMN_NAME === from) { - ref.COLUMN_NAME = to; - } - return ref; - })); - }); - }); - } - }); - }, - - getFKRefs: function (runner) { - var formatter = this.client.formatter(); - var sql = 'SELECT KCU.CONSTRAINT_NAME, KCU.TABLE_NAME, KCU.COLUMN_NAME, '+ - ' KCU.REFERENCED_TABLE_NAME, KCU.REFERENCED_COLUMN_NAME, '+ - ' RC.UPDATE_RULE, RC.DELETE_RULE '+ - 'FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU '+ - 'JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC '+ - ' USING(CONSTRAINT_NAME)' + - 'WHERE KCU.REFERENCED_TABLE_NAME = ' + formatter.parameter(this.tableNameRaw) + ' '+ - ' AND KCU.CONSTRAINT_SCHEMA = ' + formatter.parameter(this.client.databaseName); - - return runner.query({ - sql: sql, - bindings: formatter.bindings - }); - }, - - dropFKRefs: function (runner, refs) { - var formatter = this.client.formatter(); - - return Promise.all(refs.map(function (ref) { - var constraintName = formatter.wrap(ref.CONSTRAINT_NAME); - return runner.query({ - sql: 'alter table ' + this.tableName() + ' drop foreign key ' + constraintName - }); - }.bind(this))); - }, - createFKRefs: function (runner, refs) { - var formatter = this.client.formatter(); - - return Promise.all(refs.map(function (ref) { - var keyName = formatter.wrap(ref.COLUMN_NAME); - var column = formatter.columnize(ref.COLUMN_NAME); - var references = formatter.columnize(ref.REFERENCED_COLUMN_NAME); - var inTable = formatter.wrap(ref.REFERENCED_TABLE_NAME); - var onUpdate = ' ON UPDATE ' + ref.UPDATE_RULE; - var onDelete = ' ON DELETE ' + ref.DELETE_RULE; - - return runner.query({ - sql: 'alter table ' + this.tableName() + ' add constraint ' + keyName + ' ' + - 'foreign key (' + column + ') references ' + inTable + ' (' + references + ')' + onUpdate + onDelete - }); - }.bind(this))); - }, - index: function(columns, indexName) { - indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); - this.pushQuery('alter table ' + this.tableName() + " add index " + indexName + "(" + this.formatter.columnize(columns) + ")"); - }, - - primary: function(columns, indexName) { - indexName = indexName || this._indexCommand('primary', this.tableNameRaw, columns); - this.pushQuery('alter table ' + this.tableName() + " add primary key " + indexName + "(" + this.formatter.columnize(columns) + ")"); - }, - - unique: function(columns, indexName) { - indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); - this.pushQuery('alter table ' + this.tableName() + " add unique " + indexName + "(" + this.formatter.columnize(columns) + ")"); - }, - - // Compile a drop index command. - dropIndex: function(columns, indexName) { - indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); - this.pushQuery('alter table ' + this.tableName() + ' drop index ' + indexName); - }, - - // Compile a drop foreign key command. - dropForeign: function(columns, indexName) { - indexName = indexName || this._indexCommand('foreign', this.tableNameRaw, columns); - this.pushQuery('alter table ' + this.tableName() + ' drop foreign key ' + indexName); - }, - - // Compile a drop primary key command. - dropPrimary: function() { - this.pushQuery('alter table ' + this.tableName() + ' drop primary key'); - }, - - // Compile a drop unique key command. - dropUnique: function(column, indexName) { - indexName = indexName || this._indexCommand('unique', this.tableNameRaw, column); - this.pushQuery('alter table ' + this.tableName() + ' drop index ' + indexName); - } - - }) - - module.exports = TableCompiler_MySQL; - - -/***/ }, -/* 53 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var inherits = __webpack_require__(46) - var assign = __webpack_require__(14) - var Formatter = __webpack_require__(18) - var ReturningHelper = __webpack_require__(61).ReturningHelper + var inherits = __webpack_require__(44) + var assign = __webpack_require__(27) + var Formatter = __webpack_require__(14) + var ReturningHelper = __webpack_require__(76).ReturningHelper function Oracle_Formatter(client) { Formatter.call(this, client) @@ -6917,11 +7565,11 @@ return /******/ (function(modules) { // webpackBootstrap }, parameter: function(value, notSetValue) { - // returning helper uses always ROWID as string + // Returning helper uses always ROWID as string if (value instanceof ReturningHelper && this.client.driver) { - value = this.client.driver.OutParam(this.client.driver.OCCISTRING) + value = new this.client.driver.OutParam(this.client.driver.OCCISTRING) } - if (typeof value === 'boolean') { + else if (typeof value === 'boolean') { value = value ? 1 : 0 } return Formatter.prototype.parameter.call(this, value, notSetValue) @@ -6932,19 +7580,84 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Oracle_Formatter /***/ }, -/* 54 */ +/* 69 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var inherits = __webpack_require__(44) + var Promise = __webpack_require__(8) + var Transaction = __webpack_require__(15) + var assign = __webpack_require__(27); + var debugTx = __webpack_require__(45)('knex:tx') + + function Oracle_Transaction(client, container, config, outerTx) { + Transaction.call(this, client, container, config, outerTx) + } + inherits(Oracle_Transaction, Transaction) + + assign(Oracle_Transaction.prototype, { + + // disable autocommit to allow correct behavior (default is true) + begin: function() { + return Promise.resolve() + }, + + commit: function(conn, value) { + return conn.commitAsync() + .return(value) + .then(this._resolver, this._rejecter) + }, + + release: function(conn, value) { + return this._resolver(value) + }, + + rollback: function(conn, err) { + debugTx('%s: rolling back', this.txid) + return conn.rollbackAsync() + .throw(err) + .catch(this._rejecter) + }, + + acquireConnection: function(config) { + var t = this + return Promise.try(function() { + return config.connection || t.client.acquireConnection() + }).tap(function(connection) { + if (!t.outerTx) { + connection.setAutoCommit(false) + } + }).disposer(function(connection) { + debugTx('%s: releasing connection', t.txid) + connection.setAutoCommit(true) + if (!config.connection) { + t.client.releaseConnection(connection) + } else { + debugTx('%s: not releasing external connection', t.txid) + } + }) + } + + }) + + module.exports = Oracle_Transaction + + +/***/ }, +/* 70 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // Oracle Query Builder & Compiler // ------ - var _ = __webpack_require__(12); - var inherits = __webpack_require__(46); - var QueryCompiler = __webpack_require__(21); - var helpers = __webpack_require__(4); - var assign = __webpack_require__(14); - var ReturningHelper = __webpack_require__(61).ReturningHelper; + var _ = __webpack_require__(11); + var inherits = __webpack_require__(44); + var QueryCompiler = __webpack_require__(17); + var helpers = __webpack_require__(2); + var assign = __webpack_require__(27); + var ReturningHelper = __webpack_require__(76).ReturningHelper; // Query Compiler // ------- @@ -6965,6 +7678,10 @@ return /******/ (function(modules) { // webpackBootstrap var insertValues = this.single.insert || [] var returning = this.single.returning; + if (!Array.isArray(insertValues) && _.isPlainObject(this.single.insert)) { + insertValues = [this.single.insert] + } + // always wrap returning argument in array if (returning && !Array.isArray(returning)) { returning = [returning]; @@ -7156,14 +7873,85 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 55 */ +/* 71 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var inherits = __webpack_require__(46); - var ColumnBuilder = __webpack_require__(26); - var _ = __webpack_require__(12) + // Oracle Schema Compiler + // ------- + var inherits = __webpack_require__(44); + var SchemaCompiler = __webpack_require__(19); + var utils = __webpack_require__(76); + + function SchemaCompiler_Oracle() { + SchemaCompiler.apply(this, arguments); + } + inherits(SchemaCompiler_Oracle, SchemaCompiler); + + // Rename a table on the schema. + SchemaCompiler_Oracle.prototype.renameTable = function(tableName, to) { + this.pushQuery('rename ' + this.formatter.wrap(tableName) + ' to ' + this.formatter.wrap(to)); + }; + + // Check whether a table exists on the query. + SchemaCompiler_Oracle.prototype.hasTable = function(tableName) { + this.pushQuery({ + sql: 'select TABLE_NAME from USER_TABLES where TABLE_NAME = ' + + this.formatter.parameter(tableName), + output: function(resp) { + return resp.length > 0; + } + }); + }; + + // Check whether a column exists on the schema. + SchemaCompiler_Oracle.prototype.hasColumn = function(tableName, column) { + this.pushQuery({ + sql: 'select COLUMN_NAME from USER_TAB_COLUMNS where TABLE_NAME = ' + this.formatter.parameter(tableName) + + ' and COLUMN_NAME = ' + this.formatter.parameter(column), + output: function(resp) { + return resp.length > 0; + } + }); + }; + + SchemaCompiler_Oracle.prototype.dropSequenceIfExists = function (sequenceName) { + this.pushQuery(utils.wrapSqlWithCatch("drop sequence " + this.formatter.wrap(sequenceName), -2289)); + }; + + SchemaCompiler_Oracle.prototype._dropRelatedSequenceIfExists = function (tableName) { + // removing the sequence that was possibly generated by increments() column + var sequenceName = utils.generateCombinedName('seq', tableName); + this.dropSequenceIfExists(sequenceName); + }; + + SchemaCompiler_Oracle.prototype.dropTable = function (tableName) { + this.pushQuery('drop table ' + this.formatter.wrap(tableName)); + + // removing the sequence that was possibly generated by increments() column + this._dropRelatedSequenceIfExists(tableName); + }; + + SchemaCompiler_Oracle.prototype.dropTableIfExists = function(tableName) { + this.pushQuery(utils.wrapSqlWithCatch("drop table " + this.formatter.wrap(tableName), -942)); + + // removing the sequence that was possibly generated by increments() column + this._dropRelatedSequenceIfExists(tableName); + }; + + module.exports = SchemaCompiler_Oracle; + + +/***/ }, +/* 72 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var inherits = __webpack_require__(44); + var ColumnBuilder = __webpack_require__(22); + var _ = __webpack_require__(11) function ColumnBuilder_Oracle() { ColumnBuilder.apply(this, arguments); @@ -7180,17 +7968,17 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = ColumnBuilder_Oracle /***/ }, -/* 56 */ +/* 73 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var _ = __webpack_require__(12) - var inherits = __webpack_require__(46) - var assign = __webpack_require__(14) - var utils = __webpack_require__(61) - var Raw = __webpack_require__(3) - var ColumnCompiler = __webpack_require__(27) + var _ = __webpack_require__(11) + var inherits = __webpack_require__(44) + var assign = __webpack_require__(27) + var utils = __webpack_require__(76) + var Raw = __webpack_require__(1) + var ColumnCompiler = __webpack_require__(23) // Column Compiler // ------- @@ -7321,87 +8109,16 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 57 */ +/* 74 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - // Oracle Schema Compiler - // ------- - var inherits = __webpack_require__(46); - var SchemaCompiler = __webpack_require__(23); - var utils = __webpack_require__(61); - - function SchemaCompiler_Oracle() { - SchemaCompiler.apply(this, arguments); - } - inherits(SchemaCompiler_Oracle, SchemaCompiler); - - // Rename a table on the schema. - SchemaCompiler_Oracle.prototype.renameTable = function(tableName, to) { - this.pushQuery('rename ' + this.formatter.wrap(tableName) + ' to ' + this.formatter.wrap(to)); - }; - - // Check whether a table exists on the query. - SchemaCompiler_Oracle.prototype.hasTable = function(tableName) { - this.pushQuery({ - sql: 'select TABLE_NAME from USER_TABLES where TABLE_NAME = ' + - this.formatter.parameter(tableName), - output: function(resp) { - return resp.length > 0; - } - }); - }; - - // Check whether a column exists on the schema. - SchemaCompiler_Oracle.prototype.hasColumn = function(tableName, column) { - this.pushQuery({ - sql: 'select COLUMN_NAME from USER_TAB_COLUMNS where TABLE_NAME = ' + this.formatter.parameter(tableName) + - ' and COLUMN_NAME = ' + this.formatter.parameter(column), - output: function(resp) { - return resp.length > 0; - } - }); - }; - - SchemaCompiler_Oracle.prototype.dropSequenceIfExists = function (sequenceName) { - this.pushQuery(utils.wrapSqlWithCatch("drop sequence " + this.formatter.wrap(sequenceName), -2289)); - }; - - SchemaCompiler_Oracle.prototype._dropRelatedSequenceIfExists = function (tableName) { - // removing the sequence that was possibly generated by increments() column - var sequenceName = utils.generateCombinedName('seq', tableName); - this.dropSequenceIfExists(sequenceName); - }; - - SchemaCompiler_Oracle.prototype.dropTable = function (tableName) { - this.pushQuery('drop table ' + this.formatter.wrap(tableName)); - - // removing the sequence that was possibly generated by increments() column - this._dropRelatedSequenceIfExists(tableName); - }; - - SchemaCompiler_Oracle.prototype.dropTableIfExists = function(tableName) { - this.pushQuery(utils.wrapSqlWithCatch("drop table " + this.formatter.wrap(tableName), -942)); - - // removing the sequence that was possibly generated by increments() column - this._dropRelatedSequenceIfExists(tableName); - }; - - module.exports = SchemaCompiler_Oracle; - - -/***/ }, -/* 58 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var inherits = __webpack_require__(46); - var utils = __webpack_require__(61); - var TableCompiler = __webpack_require__(25); - var helpers = __webpack_require__(4); - var assign = __webpack_require__(14); + var inherits = __webpack_require__(44); + var utils = __webpack_require__(76); + var TableCompiler = __webpack_require__(21); + var helpers = __webpack_require__(2); + var assign = __webpack_require__(27); // Table Compiler // ------ @@ -7501,15 +8218,15 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 59 */ +/* 75 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; /*jslint node:true, nomen: true*/ - var inherits = __webpack_require__(46) - var merge = __webpack_require__(98) - var Readable = __webpack_require__(127).Readable + var inherits = __webpack_require__(44) + var merge = __webpack_require__(119) + var Readable = __webpack_require__(120).Readable function OracleQueryStream(connection, sql, bindings, options) { Readable.call(this, merge({}, { @@ -7555,73 +8272,18 @@ return /******/ (function(modules) { // webpackBootstrap } module.exports = OracleQueryStream - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 60 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - var Promise = __webpack_require__(16) - var Transaction = __webpack_require__(19) - var assign = __webpack_require__(14); - var debugTx = __webpack_require__(48)('knex:tx') - - function Oracle_Transaction(client, container, config, outerTx) { - Transaction.call(this, client, container, config, outerTx) - } - - assign(Oracle_Transaction.prototype, { - - // disable autocommit to allow correct behavior (default is true) - beginTransaction: function() { - return Promise.resolve() - }, - - commit: function(conn, value) { - return Promise.promisify(conn.commit.bind(conn)) - .return(value) - .then(this._resolver, this._rejecter) - }, - - rollback: function(conn, err) { - return Promise.promisify(conn.rollback.bind(conn)) - .throw(err) - .then(this._resolver, this._rejecter) - }, - - acquireConnection: function(config) { - var t = this - return Promise.try(function() { - return config.connection || t.client.acquireConnection() - }).tap(function(connection) { - if (!t._outerTx) { - return connection.setAutoCommit(false) - } - }).disposer(function(connection) { - if (!config.connection) { - t.client.releaseConnection(connection) - } else { - debugTx('%s: not releasing external connection', t.txid) - } - }) - } - - }) - - module.exports = Oracle_Transaction - - -/***/ }, -/* 61 */ +/* 76 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var helpers = __webpack_require__(4); + var helpers = __webpack_require__(2); function generateCombinedName(postfix, name, subNames) { - var crypto = __webpack_require__(128); + var crypto = __webpack_require__(121); var limit = 30; if (!Array.isArray(subNames)) subNames = subNames ? [subNames] : []; var table = name.replace(/\.|-/g, '_'); @@ -7658,342 +8320,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 62 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - // PostgreSQL Query Builder & Compiler - // ------ - var _ = __webpack_require__(12); - var inherits = __webpack_require__(46); - - var QueryCompiler = __webpack_require__(21); - var assign = __webpack_require__(14); - - function QueryCompiler_PG(client, builder) { - QueryCompiler.call(this, client, builder); - } - inherits(QueryCompiler_PG, QueryCompiler); - - assign(QueryCompiler_PG.prototype, { - - // Compiles a truncate query. - truncate: function() { - return 'truncate ' + this.tableName + ' restart identity'; - }, - - // is used if the an array with multiple empty values supplied - _defaultInsertValue: 'default', - - // Compiles an `insert` query, allowing for multiple - // inserts using a single query statement. - insert: function() { - var sql = QueryCompiler.prototype.insert.call(this) - if (sql === '') return sql; - var returning = this.single.returning; - return { - sql: sql + this._returning(returning), - returning: returning - }; - }, - - // Compiles an `update` query, allowing for a return value. - update: function() { - var updateData = this._prepUpdate(this.single.update); - var wheres = this.where(); - var returning = this.single.returning; - return { - sql: 'update ' + this.tableName + ' set ' + updateData.join(', ') + - (wheres ? ' ' + wheres : '') + - this._returning(returning), - returning: returning - }; - }, - - // Compiles an `update` query, allowing for a return value. - del: function() { - var sql = QueryCompiler.prototype.del.apply(this, arguments); - var returning = this.single.returning; - return { - sql: sql + this._returning(returning), - returning: returning - }; - }, - - _returning: function(value) { - return value ? ' returning ' + this.formatter.columnize(value) : ''; - }, - - forUpdate: function() { - return 'for update'; - }, - - forShare: function() { - return 'for share'; - }, - - // Compiles a columnInfo query - columnInfo: function() { - var column = this.single.columnInfo; - return { - sql: 'select * from information_schema.columns where table_name = ? and table_catalog = ?', - bindings: [this.single.table, this.client.database()], - output: function(resp) { - var out = _.reduce(resp.rows, function(columns, val) { - columns[val.column_name] = { - type: val.data_type, - maxLength: val.character_maximum_length, - nullable: (val.is_nullable === 'YES'), - defaultValue: val.column_default - }; - return columns; - }, {}); - return column && out[column] || out; - } - }; - } - - }) - - module.exports = QueryCompiler_PG; - - -/***/ }, -/* 63 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - // PostgreSQL Column Compiler - // ------- - - var inherits = __webpack_require__(46); - var ColumnCompiler = __webpack_require__(27); - var assign = __webpack_require__(14); - - function ColumnCompiler_PG() { - ColumnCompiler.apply(this, arguments); - this.modifiers = ['nullable', 'defaultTo', 'comment'] - } - inherits(ColumnCompiler_PG, ColumnCompiler); - - assign(ColumnCompiler_PG.prototype, { - - // Types - // ------ - bigincrements: 'bigserial primary key', - bigint: 'bigint', - binary: 'bytea', - - bit: function(column) { - return column.length !== false ? 'bit(' + column.length + ')' : 'bit'; - }, - - bool: 'boolean', - - // Create the column definition for an enum type. - // Using method "2" here: http://stackoverflow.com/a/10984951/525714 - enu: function(allowed) { - return 'text check (' + this.formatter.wrap(this.args[0]) + " in ('" + allowed.join("', '") + "'))"; - }, - - double: 'double precision', - floating: 'real', - increments: 'serial primary key', - json: function(jsonb) { - if (!this.client.version || parseFloat(this.client.version) >= 9.2) return jsonb ? 'jsonb' : 'json'; - return 'text'; - }, - smallint: 'smallint', - tinyint: 'smallint', - datetime: function(without) { - return without ? 'timestamp' : 'timestamptz'; - }, - timestamp: function(without) { - return without ? 'timestamp' : 'timestamptz'; - }, - uuid: 'uuid', - - // Modifiers: - // ------ - comment: function(comment) { - this.pushAdditional(function() { - this.pushQuery('comment on column ' + this.tableCompiler.tableName() + '.' + - this.formatter.wrap(this.args[0]) + " is " + (comment ? "'" + comment + "'" : 'NULL')); - }, comment); - } - - }) - - module.exports = ColumnCompiler_PG; - - -/***/ }, -/* 64 */ -/***/ function(module, exports, __webpack_require__) { - - // PostgreSQL Schema Compiler - // ------- - - 'use strict'; - - var inherits = __webpack_require__(46); - var SchemaCompiler = __webpack_require__(23); - - function SchemaCompiler_PG() { - SchemaCompiler.apply(this, arguments); - } - inherits(SchemaCompiler_PG, SchemaCompiler); - - // Check whether the current table - SchemaCompiler_PG.prototype.hasTable = function(tableName) { - this.pushQuery({ - sql: 'select * from information_schema.tables where table_name = ?', - bindings: [tableName], - output: function(resp) { - return resp.rows.length > 0; - } - }); - }; - - // Compile the query to determine if a column exists in a table. - SchemaCompiler_PG.prototype.hasColumn = function(tableName, columnName) { - this.pushQuery({ - sql: 'select * from information_schema.columns where table_name = ? and column_name = ?', - bindings: [tableName, columnName], - output: function(resp) { - return resp.rows.length > 0; - } - }); - }; - - // Compile a rename table command. - SchemaCompiler_PG.prototype.renameTable = function(from, to) { - this.pushQuery('alter table ' + this.formatter.wrap(from) + ' rename to ' + this.formatter.wrap(to)); - }; - - SchemaCompiler_PG.prototype.createSchema = function(schemaName) { - this.pushQuery('create schema ' + this.formatter.wrap(schemaName)); - }; - - SchemaCompiler_PG.prototype.createSchemaIfNotExists = function(schemaName) { - this.pushQuery('create schema if not exists ' + this.formatter.wrap(schemaName)); - }; - - SchemaCompiler_PG.prototype.dropSchema = function(schemaName) { - this.pushQuery('drop schema ' + this.formatter.wrap(schemaName)); - }; - - SchemaCompiler_PG.prototype.dropSchemaIfExists = function(schemaName) { - this.pushQuery('drop schema if exists ' + this.formatter.wrap(schemaName)); - }; - - SchemaCompiler_PG.prototype.dropExtension = function(extensionName) { - this.pushQuery('drop extension ' + this.formatter.wrap(extensionName)); - }; - - SchemaCompiler_PG.prototype.dropExtensionIfExists = function(extensionName) { - this.pushQuery('drop extension if exists ' + this.formatter.wrap(extensionName)); - }; - - SchemaCompiler_PG.prototype.createExtension = function(extensionName) { - this.pushQuery('create extension ' + this.formatter.wrap(extensionName)); - }; - - SchemaCompiler_PG.prototype.createExtensionIfNotExists = function(extensionName) { - this.pushQuery('create extension if not exists ' + this.formatter.wrap(extensionName)); - }; - - module.exports = SchemaCompiler_PG; - - -/***/ }, -/* 65 */ -/***/ function(module, exports, __webpack_require__) { - - // PostgreSQL Table Builder & Compiler - // ------- - 'use strict'; - - var _ = __webpack_require__(12); - var inherits = __webpack_require__(46); - var TableCompiler = __webpack_require__(25); - - function TableCompiler_PG() { - TableCompiler.apply(this, arguments); - } - inherits(TableCompiler_PG, TableCompiler); - - // Compile a rename column command. - TableCompiler_PG.prototype.renameColumn = function(from, to) { - return this.pushQuery({ - sql: 'alter table ' + this.tableName() + ' rename '+ this.formatter.wrap(from) + ' to ' + this.formatter.wrap(to) - }); - }; - - TableCompiler_PG.prototype.compileAdd = function(builder) { - var table = this.formatter.wrap(builder); - var columns = this.prefixArray('add column', this.getColumns(builder)); - return this.pushQuery({ - sql: 'alter table ' + table + ' ' + columns.join(', ') - }); - }; - - // Adds the "create" query to the query sequence. - TableCompiler_PG.prototype.createQuery = function(columns, ifNot) { - var createStatement = ifNot ? 'create table if not exists ' : 'create table '; - this.pushQuery({ - sql: createStatement + this.tableName() + ' (' + columns.sql.join(', ') + ')', - bindings: columns.bindings - }); - var hasComment = _.has(this.single, 'comment'); - if (hasComment) this.comment(this.single.comment); - }; - - // Compiles the comment on the table. - TableCompiler_PG.prototype.comment = function(comment) { - /*jshint unused: false*/ - this.pushQuery('comment on table ' + this.tableName() + ' is ' + "'" + (this.single.comment || '') + "'"); - }; - - // Indexes: - // ------- - - TableCompiler_PG.prototype.primary = function(columns) { - this.pushQuery('alter table ' + this.tableName() + " add primary key (" + this.formatter.columnize(columns) + ")"); - }; - TableCompiler_PG.prototype.unique = function(columns, indexName) { - indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); - this.pushQuery('alter table ' + this.tableName() + ' add constraint ' + indexName + - ' unique (' + this.formatter.columnize(columns) + ')'); - }; - TableCompiler_PG.prototype.index = function(columns, indexName, indexType) { - indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); - this.pushQuery('create index ' + indexName + ' on ' + this.tableName() + (indexType && (' using ' + indexType) || '') + - ' (' + this.formatter.columnize(columns) + ')'); - }; - TableCompiler_PG.prototype.dropPrimary = function() { - this.pushQuery('alter table ' + this.tableName() + " drop constraint " + this.tableNameRaw + "_pkey"); - }; - TableCompiler_PG.prototype.dropIndex = function(columns, indexName) { - indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); - this.pushQuery('drop index ' + indexName); - }; - TableCompiler_PG.prototype.dropUnique = function(columns, indexName) { - indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); - this.pushQuery('alter table ' + this.tableName() + ' drop constraint ' + indexName); - }; - TableCompiler_PG.prototype.dropForeign = function(columns, indexName) { - indexName = indexName || this._indexCommand('foreign', this.tableNameRaw, columns); - this.pushQuery('alter table ' + this.tableName() + ' drop constraint ' + indexName); - }; - - module.exports = TableCompiler_PG; - - -/***/ }, -/* 66 */ +/* 77 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict'; @@ -8101,20 +8428,355 @@ return /******/ (function(modules) { // webpackBootstrap normalizeQueryConfig: normalizeQueryConfig }; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) /***/ }, -/* 67 */ +/* 78 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + // PostgreSQL Query Builder & Compiler + // ------ + var _ = __webpack_require__(11); + var inherits = __webpack_require__(44); + + var QueryCompiler = __webpack_require__(17); + var assign = __webpack_require__(27); + + function QueryCompiler_PG(client, builder) { + QueryCompiler.call(this, client, builder); + } + inherits(QueryCompiler_PG, QueryCompiler); + + assign(QueryCompiler_PG.prototype, { + + // Compiles a truncate query. + truncate: function() { + return 'truncate ' + this.tableName + ' restart identity'; + }, + + // is used if the an array with multiple empty values supplied + _defaultInsertValue: 'default', + + // Compiles an `insert` query, allowing for multiple + // inserts using a single query statement. + insert: function() { + var sql = QueryCompiler.prototype.insert.call(this) + if (sql === '') return sql; + var returning = this.single.returning; + return { + sql: sql + this._returning(returning), + returning: returning + }; + }, + + // Compiles an `update` query, allowing for a return value. + update: function() { + var updateData = this._prepUpdate(this.single.update); + var wheres = this.where(); + var returning = this.single.returning; + return { + sql: 'update ' + this.tableName + ' set ' + updateData.join(', ') + + (wheres ? ' ' + wheres : '') + + this._returning(returning), + returning: returning + }; + }, + + // Compiles an `update` query, allowing for a return value. + del: function() { + var sql = QueryCompiler.prototype.del.apply(this, arguments); + var returning = this.single.returning; + return { + sql: sql + this._returning(returning), + returning: returning + }; + }, + + _returning: function(value) { + return value ? ' returning ' + this.formatter.columnize(value) : ''; + }, + + forUpdate: function() { + return 'for update'; + }, + + forShare: function() { + return 'for share'; + }, + + // Compiles a columnInfo query + columnInfo: function() { + var column = this.single.columnInfo; + return { + sql: 'select * from information_schema.columns where table_name = ? and table_catalog = ?', + bindings: [this.single.table, this.client.database()], + output: function(resp) { + var out = _.reduce(resp.rows, function(columns, val) { + columns[val.column_name] = { + type: val.data_type, + maxLength: val.character_maximum_length, + nullable: (val.is_nullable === 'YES'), + defaultValue: val.column_default + }; + return columns; + }, {}); + return column && out[column] || out; + } + }; + } + + }) + + module.exports = QueryCompiler_PG; + + +/***/ }, +/* 79 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + // PostgreSQL Column Compiler + // ------- + + var inherits = __webpack_require__(44); + var ColumnCompiler = __webpack_require__(23); + var assign = __webpack_require__(27); + + function ColumnCompiler_PG() { + ColumnCompiler.apply(this, arguments); + this.modifiers = ['nullable', 'defaultTo', 'comment'] + } + inherits(ColumnCompiler_PG, ColumnCompiler); + + assign(ColumnCompiler_PG.prototype, { + + // Types + // ------ + bigincrements: 'bigserial primary key', + bigint: 'bigint', + binary: 'bytea', + + bit: function(column) { + return column.length !== false ? 'bit(' + column.length + ')' : 'bit'; + }, + + bool: 'boolean', + + // Create the column definition for an enum type. + // Using method "2" here: http://stackoverflow.com/a/10984951/525714 + enu: function(allowed) { + return 'text check (' + this.formatter.wrap(this.args[0]) + " in ('" + allowed.join("', '") + "'))"; + }, + + double: 'double precision', + floating: 'real', + increments: 'serial primary key', + json: function(jsonb) { + if (!this.client.version || parseFloat(this.client.version) >= 9.2) return jsonb ? 'jsonb' : 'json'; + return 'text'; + }, + smallint: 'smallint', + tinyint: 'smallint', + datetime: function(without) { + return without ? 'timestamp' : 'timestamptz'; + }, + timestamp: function(without) { + return without ? 'timestamp' : 'timestamptz'; + }, + uuid: 'uuid', + + // Modifiers: + // ------ + comment: function(comment) { + this.pushAdditional(function() { + this.pushQuery('comment on column ' + this.tableCompiler.tableName() + '.' + + this.formatter.wrap(this.args[0]) + " is " + (comment ? "'" + comment + "'" : 'NULL')); + }, comment); + } + + }) + + module.exports = ColumnCompiler_PG; + + +/***/ }, +/* 80 */ +/***/ function(module, exports, __webpack_require__) { + + // PostgreSQL Table Builder & Compiler + // ------- + 'use strict'; + + var _ = __webpack_require__(11); + var inherits = __webpack_require__(44); + var TableCompiler = __webpack_require__(21); + + function TableCompiler_PG() { + TableCompiler.apply(this, arguments); + } + inherits(TableCompiler_PG, TableCompiler); + + // Compile a rename column command. + TableCompiler_PG.prototype.renameColumn = function(from, to) { + return this.pushQuery({ + sql: 'alter table ' + this.tableName() + ' rename '+ this.formatter.wrap(from) + ' to ' + this.formatter.wrap(to) + }); + }; + + TableCompiler_PG.prototype.compileAdd = function(builder) { + var table = this.formatter.wrap(builder); + var columns = this.prefixArray('add column', this.getColumns(builder)); + return this.pushQuery({ + sql: 'alter table ' + table + ' ' + columns.join(', ') + }); + }; + + // Adds the "create" query to the query sequence. + TableCompiler_PG.prototype.createQuery = function(columns, ifNot) { + var createStatement = ifNot ? 'create table if not exists ' : 'create table '; + this.pushQuery({ + sql: createStatement + this.tableName() + ' (' + columns.sql.join(', ') + ')', + bindings: columns.bindings + }); + var hasComment = _.has(this.single, 'comment'); + if (hasComment) this.comment(this.single.comment); + }; + + // Compiles the comment on the table. + TableCompiler_PG.prototype.comment = function(comment) { + /*jshint unused: false*/ + this.pushQuery('comment on table ' + this.tableName() + ' is ' + "'" + (this.single.comment || '') + "'"); + }; + + // Indexes: + // ------- + + TableCompiler_PG.prototype.primary = function(columns) { + this.pushQuery('alter table ' + this.tableName() + " add primary key (" + this.formatter.columnize(columns) + ")"); + }; + TableCompiler_PG.prototype.unique = function(columns, indexName) { + indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); + this.pushQuery('alter table ' + this.tableName() + ' add constraint ' + indexName + + ' unique (' + this.formatter.columnize(columns) + ')'); + }; + TableCompiler_PG.prototype.index = function(columns, indexName, indexType) { + indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); + this.pushQuery('create index ' + indexName + ' on ' + this.tableName() + (indexType && (' using ' + indexType) || '') + + ' (' + this.formatter.columnize(columns) + ')'); + }; + TableCompiler_PG.prototype.dropPrimary = function() { + this.pushQuery('alter table ' + this.tableName() + " drop constraint " + this.tableNameRaw + "_pkey"); + }; + TableCompiler_PG.prototype.dropIndex = function(columns, indexName) { + indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); + this.pushQuery('drop index ' + indexName); + }; + TableCompiler_PG.prototype.dropUnique = function(columns, indexName) { + indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); + this.pushQuery('alter table ' + this.tableName() + ' drop constraint ' + indexName); + }; + TableCompiler_PG.prototype.dropForeign = function(columns, indexName) { + indexName = indexName || this._indexCommand('foreign', this.tableNameRaw, columns); + this.pushQuery('alter table ' + this.tableName() + ' drop constraint ' + indexName); + }; + + module.exports = TableCompiler_PG; + + +/***/ }, +/* 81 */ +/***/ function(module, exports, __webpack_require__) { + + // PostgreSQL Schema Compiler + // ------- + + 'use strict'; + + var inherits = __webpack_require__(44); + var SchemaCompiler = __webpack_require__(19); + + function SchemaCompiler_PG() { + SchemaCompiler.apply(this, arguments); + } + inherits(SchemaCompiler_PG, SchemaCompiler); + + // Check whether the current table + SchemaCompiler_PG.prototype.hasTable = function(tableName) { + this.pushQuery({ + sql: 'select * from information_schema.tables where table_name = ?', + bindings: [tableName], + output: function(resp) { + return resp.rows.length > 0; + } + }); + }; + + // Compile the query to determine if a column exists in a table. + SchemaCompiler_PG.prototype.hasColumn = function(tableName, columnName) { + this.pushQuery({ + sql: 'select * from information_schema.columns where table_name = ? and column_name = ?', + bindings: [tableName, columnName], + output: function(resp) { + return resp.rows.length > 0; + } + }); + }; + + // Compile a rename table command. + SchemaCompiler_PG.prototype.renameTable = function(from, to) { + this.pushQuery('alter table ' + this.formatter.wrap(from) + ' rename to ' + this.formatter.wrap(to)); + }; + + SchemaCompiler_PG.prototype.createSchema = function(schemaName) { + this.pushQuery('create schema ' + this.formatter.wrap(schemaName)); + }; + + SchemaCompiler_PG.prototype.createSchemaIfNotExists = function(schemaName) { + this.pushQuery('create schema if not exists ' + this.formatter.wrap(schemaName)); + }; + + SchemaCompiler_PG.prototype.dropSchema = function(schemaName) { + this.pushQuery('drop schema ' + this.formatter.wrap(schemaName)); + }; + + SchemaCompiler_PG.prototype.dropSchemaIfExists = function(schemaName) { + this.pushQuery('drop schema if exists ' + this.formatter.wrap(schemaName)); + }; + + SchemaCompiler_PG.prototype.dropExtension = function(extensionName) { + this.pushQuery('drop extension ' + this.formatter.wrap(extensionName)); + }; + + SchemaCompiler_PG.prototype.dropExtensionIfExists = function(extensionName) { + this.pushQuery('drop extension if exists ' + this.formatter.wrap(extensionName)); + }; + + SchemaCompiler_PG.prototype.createExtension = function(extensionName) { + this.pushQuery('create extension ' + this.formatter.wrap(extensionName)); + }; + + SchemaCompiler_PG.prototype.createExtensionIfNotExists = function(extensionName) { + this.pushQuery('create extension if not exists ' + this.formatter.wrap(extensionName)); + }; + + module.exports = SchemaCompiler_PG; + + +/***/ }, +/* 82 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // SQLite3 Query Builder & Compiler - var _ = __webpack_require__(12) - var inherits = __webpack_require__(46) - var QueryCompiler = __webpack_require__(21) - var assign = __webpack_require__(14); + var _ = __webpack_require__(11) + var inherits = __webpack_require__(44) + var QueryCompiler = __webpack_require__(17) + var assign = __webpack_require__(27); function QueryCompiler_SQLite3(client, builder) { QueryCompiler.call(this, client, builder) @@ -8233,44 +8895,16 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 68 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var inherits = __webpack_require__(46); - var ColumnCompiler = __webpack_require__(27); - - // Column Compiler - // ------- - - function ColumnCompiler_SQLite3() { - this.modifiers = ['nullable', 'defaultTo']; - ColumnCompiler.apply(this, arguments); - } - inherits(ColumnCompiler_SQLite3, ColumnCompiler); - - // Types - // ------- - - ColumnCompiler_SQLite3.prototype.double = - ColumnCompiler_SQLite3.prototype.decimal = - ColumnCompiler_SQLite3.prototype.floating = 'float'; - ColumnCompiler_SQLite3.prototype.timestamp = 'datetime'; - - module.exports = ColumnCompiler_SQLite3; - -/***/ }, -/* 69 */ +/* 83 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; // SQLite3: Column Builder & Compiler // ------- - var _ = __webpack_require__(12); - var inherits = __webpack_require__(46); - var SchemaCompiler = __webpack_require__(23); + var _ = __webpack_require__(11); + var inherits = __webpack_require__(44); + var SchemaCompiler = __webpack_require__(19); // Schema Compiler // ------- @@ -8309,7 +8943,161 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 70 */ +/* 84 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var inherits = __webpack_require__(44); + var ColumnCompiler = __webpack_require__(23); + + // Column Compiler + // ------- + + function ColumnCompiler_SQLite3() { + this.modifiers = ['nullable', 'defaultTo']; + ColumnCompiler.apply(this, arguments); + } + inherits(ColumnCompiler_SQLite3, ColumnCompiler); + + // Types + // ------- + + ColumnCompiler_SQLite3.prototype.double = + ColumnCompiler_SQLite3.prototype.decimal = + ColumnCompiler_SQLite3.prototype.floating = 'float'; + ColumnCompiler_SQLite3.prototype.timestamp = 'datetime'; + + module.exports = ColumnCompiler_SQLite3; + +/***/ }, +/* 85 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _ = __webpack_require__(11); + var inherits = __webpack_require__(44); + var TableCompiler = __webpack_require__(21); + + // Table Compiler + // ------- + + function TableCompiler_SQLite3() { + TableCompiler.apply(this, arguments); + this.primaryKey = void 0; + } + inherits(TableCompiler_SQLite3, TableCompiler); + + // Create a new table. + TableCompiler_SQLite3.prototype.createQuery = function(columns, ifNot) { + var createStatement = ifNot ? 'create table if not exists ' : 'create table '; + var sql = createStatement + this.tableName() + ' (' + columns.sql.join(', '); + + // SQLite forces primary keys to be added when the table is initially created + // so we will need to check for a primary key commands and add the columns + // to the table's declaration here so they can be created on the tables. + sql += this.foreignKeys() || ''; + sql += this.primaryKeys() || ''; + sql += ')'; + + this.pushQuery(sql); + }; + + TableCompiler_SQLite3.prototype.addColumns = function(columns) { + for (var i = 0, l = columns.sql.length; i < l; i++) { + this.pushQuery({ + sql: 'alter table ' + this.tableName() + ' add column ' + columns.sql[i], + bindings: columns.bindings[i] + }); + } + }; + + // Compile a drop unique key command. + TableCompiler_SQLite3.prototype.dropUnique = function(columns, indexName) { + indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); + this.pushQuery('drop index ' + indexName); + }; + + TableCompiler_SQLite3.prototype.dropIndex = function(columns, indexName) { + indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); + this.pushQuery('drop index ' + indexName); + }; + + // Compile a unique key command. + TableCompiler_SQLite3.prototype.unique = function(columns, indexName) { + indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); + columns = this.formatter.columnize(columns); + this.pushQuery('create unique index ' + indexName + ' on ' + this.tableName() + ' (' + columns + ')'); + }; + + // Compile a plain index key command. + TableCompiler_SQLite3.prototype.index = function(columns, indexName) { + indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); + columns = this.formatter.columnize(columns); + this.pushQuery('create index ' + indexName + ' on ' + this.tableName() + ' (' + columns + ')'); + }; + + TableCompiler_SQLite3.prototype.primary = + TableCompiler_SQLite3.prototype.foreign = function() { + if (this.method !== 'create' && this.method !== 'createIfNot') { + console.warn('SQLite3 Foreign & Primary keys may only be added on create'); + } + }; + + TableCompiler_SQLite3.prototype.primaryKeys = function() { + var pks = _.where(this.grouped.alterTable || [], {method: 'primary'}); + if (pks.length > 0 && pks[0].args.length > 0) { + var args = Array.isArray(pks[0].args[0]) ? pks[0].args[0] : pks[0].args; + return ', primary key (' + this.formatter.columnize(args) + ')'; + } + }; + + TableCompiler_SQLite3.prototype.foreignKeys = function() { + var sql = ''; + var foreignKeys = _.where(this.grouped.alterTable || [], {method: 'foreign'}); + for (var i = 0, l = foreignKeys.length; i < l; i++) { + var foreign = foreignKeys[i].args[0]; + var column = this.formatter.columnize(foreign.column); + var references = this.formatter.columnize(foreign.references); + var foreignTable = this.formatter.wrap(foreign.inTable); + sql += ', foreign key(' + column + ') references ' + foreignTable + '(' + references + ')'; + if (foreign.onDelete) sql += ' on delete ' + foreign.onDelete; + if (foreign.onUpdate) sql += ' on update ' + foreign.onUpdate; + } + return sql; + }; + + TableCompiler_SQLite3.prototype.createTableBlock = function() { + return this.getColumns().concat().join(','); + }; + + // Compile a rename column command... very complex in sqlite + TableCompiler_SQLite3.prototype.renameColumn = function(from, to) { + var compiler = this; + this.pushQuery({ + sql: 'PRAGMA table_info(' + this.tableName() + ')', + output: function(pragma) { + return compiler.client.ddl(compiler, pragma, this.connection).renameColumn(from, to); + } + }); + }; + + TableCompiler_SQLite3.prototype.dropColumn = function(column) { + var compiler = this; + this.pushQuery({ + sql: 'PRAGMA table_info(' + this.tableName() + ')', + output: function(pragma) { + return compiler.client.ddl(compiler, pragma, this.connection).dropColumn(column); + } + }); + }; + + module.exports = TableCompiler_SQLite3; + + +/***/ }, +/* 86 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -8320,9 +9108,9 @@ return /******/ (function(modules) { // webpackBootstrap // columns and changing datatypes. // ------- - var _ = __webpack_require__(12); - var Promise = __webpack_require__(16); - var assign = __webpack_require__(14); + var _ = __webpack_require__(11); + var Promise = __webpack_require__(8); + var assign = __webpack_require__(27); // So altering the schema in SQLite3 is a major pain. // We have our own object to deal with the renaming and altering the types @@ -8554,941 +9342,8 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = SQLite3_DDL; -/***/ }, -/* 71 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var _ = __webpack_require__(12); - var inherits = __webpack_require__(46); - var TableCompiler = __webpack_require__(25); - - // Table Compiler - // ------- - - function TableCompiler_SQLite3() { - TableCompiler.apply(this, arguments); - this.primaryKey = void 0; - } - inherits(TableCompiler_SQLite3, TableCompiler); - - // Create a new table. - TableCompiler_SQLite3.prototype.createQuery = function(columns, ifNot) { - var createStatement = ifNot ? 'create table if not exists ' : 'create table '; - var sql = createStatement + this.tableName() + ' (' + columns.sql.join(', '); - - // SQLite forces primary keys to be added when the table is initially created - // so we will need to check for a primary key commands and add the columns - // to the table's declaration here so they can be created on the tables. - sql += this.foreignKeys() || ''; - sql += this.primaryKeys() || ''; - sql += ')'; - - this.pushQuery(sql); - }; - - TableCompiler_SQLite3.prototype.addColumns = function(columns) { - for (var i = 0, l = columns.sql.length; i < l; i++) { - this.pushQuery({ - sql: 'alter table ' + this.tableName() + ' add column ' + columns.sql[i], - bindings: columns.bindings[i] - }); - } - }; - - // Compile a drop unique key command. - TableCompiler_SQLite3.prototype.dropUnique = function(columns, indexName) { - indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); - this.pushQuery('drop index ' + indexName); - }; - - TableCompiler_SQLite3.prototype.dropIndex = function(columns, indexName) { - indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); - this.pushQuery('drop index ' + indexName); - }; - - // Compile a unique key command. - TableCompiler_SQLite3.prototype.unique = function(columns, indexName) { - indexName = indexName || this._indexCommand('unique', this.tableNameRaw, columns); - columns = this.formatter.columnize(columns); - this.pushQuery('create unique index ' + indexName + ' on ' + this.tableName() + ' (' + columns + ')'); - }; - - // Compile a plain index key command. - TableCompiler_SQLite3.prototype.index = function(columns, indexName) { - indexName = indexName || this._indexCommand('index', this.tableNameRaw, columns); - columns = this.formatter.columnize(columns); - this.pushQuery('create index ' + indexName + ' on ' + this.tableName() + ' (' + columns + ')'); - }; - - TableCompiler_SQLite3.prototype.primary = - TableCompiler_SQLite3.prototype.foreign = function() { - if (this.method !== 'create' && this.method !== 'createIfNot') { - console.warn('SQLite3 Foreign & Primary keys may only be added on create'); - } - }; - - TableCompiler_SQLite3.prototype.primaryKeys = function() { - var pks = _.where(this.grouped.alterTable || [], {method: 'primary'}); - if (pks.length > 0 && pks[0].args.length > 0) { - var args = Array.isArray(pks[0].args[0]) ? pks[0].args[0] : pks[0].args; - return ', primary key (' + this.formatter.columnize(args) + ')'; - } - }; - - TableCompiler_SQLite3.prototype.foreignKeys = function() { - var sql = ''; - var foreignKeys = _.where(this.grouped.alterTable || [], {method: 'foreign'}); - for (var i = 0, l = foreignKeys.length; i < l; i++) { - var foreign = foreignKeys[i].args[0]; - var column = this.formatter.columnize(foreign.column); - var references = this.formatter.columnize(foreign.references); - var foreignTable = this.formatter.wrap(foreign.inTable); - sql += ', foreign key(' + column + ') references ' + foreignTable + '(' + references + ')'; - if (foreign.onDelete) sql += ' on delete ' + foreign.onDelete; - if (foreign.onUpdate) sql += ' on update ' + foreign.onUpdate; - } - return sql; - }; - - TableCompiler_SQLite3.prototype.createTableBlock = function() { - return this.getColumns().concat().join(','); - }; - - // Compile a rename column command... very complex in sqlite - TableCompiler_SQLite3.prototype.renameColumn = function(from, to) { - var compiler = this; - this.pushQuery({ - sql: 'PRAGMA table_info(' + this.tableName() + ')', - output: function(pragma) { - return compiler.client.ddl(compiler, pragma, this.connection).renameColumn(from, to); - } - }); - }; - - TableCompiler_SQLite3.prototype.dropColumn = function(column) { - var compiler = this; - this.pushQuery({ - sql: 'PRAGMA table_info(' + this.tableName() + ')', - output: function(pragma) { - return compiler.client.ddl(compiler, pragma, this.connection).dropColumn(column); - } - }); - }; - - module.exports = TableCompiler_SQLite3; - - -/***/ }, -/* 72 */, -/* 73 */, -/* 74 */, -/* 75 */ -/***/ function(module, exports, __webpack_require__) { - - // Update with your config settings. - - module.exports = { - - development: { - client: 'sqlite3', - connection: { - filename: './dev.sqlite3' - } - }, - - staging: { - client: 'postgresql', - connection: { - database: 'my_db', - user: 'username', - password: 'password' - }, - pool: { - min: 2, - max: 10 - }, - migrations: { - tableName: 'knex_migrations' - } - }, - - production: { - client: 'postgresql', - connection: { - database: 'my_db', - user: 'username', - password: 'password' - }, - pool: { - min: 2, - max: 10 - }, - migrations: { - tableName: 'knex_migrations' - } - } - - }; - - -/***/ }, -/* 76 */, -/* 77 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - // JoinClause - // ------- - - // The "JoinClause" is an object holding any necessary info about a join, - // including the type, and any associated tables & columns being joined. - function JoinClause(table, type) { - this.table = table; - this.joinType = type; - this.and = this; - this.clauses = []; - } - - JoinClause.prototype.grouping = 'join'; - - // Adds an "on" clause to the current join object. - JoinClause.prototype.on = function(first, operator, second) { - var data; - switch (arguments.length) { - case 1: data = ['on', this._bool(), first]; break; - case 2: data = ['on', this._bool(), first, '=', operator]; break; - default: data = ['on', this._bool(), first, operator, second]; - } - this.clauses.push(data); - return this; - }; - - // Adds a "using" clause to the current join. - JoinClause.prototype.using = function(table) { - return this.clauses.push(['using', this._bool(), table]); - }; - - // Adds an "and on" clause to the current join object. - JoinClause.prototype.andOn = function() { - return this.on.apply(this, arguments); - }; - - // Adds an "or on" clause to the current join object. - JoinClause.prototype.orOn = function(first, operator, second) { - /*jshint unused: false*/ - return this._bool('or').on.apply(this, arguments); - }; - - // Explicitly set the type of join, useful within a function when creating a grouped join. - JoinClause.prototype.type = function(type) { - this.joinType = type; - return this; - }; - - JoinClause.prototype._bool = function(bool) { - if (arguments.length === 1) { - this._boolFlag = bool; - return this; - } - var ret = this._boolFlag || 'and'; - this._boolFlag = 'and'; - return ret; - }; - - Object.defineProperty(JoinClause.prototype, 'or', { - get: function () { - return this._bool('or'); - } - }); - - module.exports = JoinClause; - -/***/ }, -/* 78 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {'use strict' - - var SqlString = exports; - - SqlString.escapeId = function (val, forbidQualified) { - if (Array.isArray(val)) { - return val.map(function(v) { - return SqlString.escapeId(v, forbidQualified); - }).join(', '); - } - - if (forbidQualified) { - return '`' + val.replace(/`/g, '``') + '`'; - } - return '`' + val.replace(/`/g, '``').replace(/\./g, '`.`') + '`'; - }; - - SqlString.escape = function(val, stringifyObjects, timeZone) { - if (val == null) { - return 'NULL'; - } - - switch (typeof val) { - case 'boolean': return (val) ? 'true' : 'false'; - case 'number': return val+''; - } - - if (val instanceof Date) { - val = SqlString.dateToString(val, timeZone || 'local'); - } - - if (Buffer.isBuffer(val)) { - return SqlString.bufferToString(val); - } - - if (Array.isArray(val)) { - return SqlString.arrayToList(val, timeZone); - } - - if (typeof val === 'object') { - if (stringifyObjects) { - val = val.toString(); - } else { - return SqlString.objectToValues(val, timeZone); - } - } - - val = val.replace(/[\0\n\r\b\t\\\'\"\x1a]/g, function(s) { - switch(s) { - case "\0": return "\\0"; - case "\n": return "\\n"; - case "\r": return "\\r"; - case "\b": return "\\b"; - case "\t": return "\\t"; - case "\x1a": return "\\Z"; - default: return "\\"+s; - } - }); - return "'"+val+"'"; - }; - - SqlString.arrayToList = function(array, timeZone) { - return array.map(function(v) { - if (Array.isArray(v)) return '(' + SqlString.arrayToList(v, timeZone) + ')'; - return SqlString.escape(v, true, timeZone); - }).join(', '); - }; - - SqlString.format = function(sql, values, stringifyObjects, timeZone) { - values = values == null ? [] : [].concat(values); - - var index = 0; - return sql.replace(/\?\??/g, function(match) { - if (index === values.length) { - return match; - } - - var value = values[index++]; - - return match === '??' ? SqlString.escapeId(value) : - SqlString.escape(value, stringifyObjects, timeZone); - }); - }; - - SqlString.dateToString = function(date, timeZone) { - var dt = new Date(date); - - if (timeZone !== 'local') { - var tz = convertTimezone(timeZone); - - dt.setTime(dt.getTime() + (dt.getTimezoneOffset() * 60000)); - if (tz !== false) { - dt.setTime(dt.getTime() + (tz * 60000)); - } - } - - var year = dt.getFullYear(); - var month = zeroPad(dt.getMonth() + 1, 2); - var day = zeroPad(dt.getDate(), 2); - var hour = zeroPad(dt.getHours(), 2); - var minute = zeroPad(dt.getMinutes(), 2); - var second = zeroPad(dt.getSeconds(), 2); - var millisecond = zeroPad(dt.getMilliseconds(), 3); - - return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second + '.' + millisecond; - }; - - SqlString.bufferToString = function bufferToString(buffer) { - return "X'" + buffer.toString('hex') + "'"; - }; - - SqlString.objectToValues = function(object, timeZone) { - var values = []; - for (var key in object) { - var value = object[key]; - if(typeof value === 'function') { - continue; - } - - values.push(this.escapeId(key) + ' = ' + SqlString.escape(value, true, timeZone)); - } - - return values.join(', '); - }; - - function zeroPad(number, length) { - number = number.toString(); - while (number.length < length) { - number = '0' + number; - } - - return number; - } - - function convertTimezone(tz) { - if (tz === "Z") return 0; - - var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/); - if (m) { - return (m[1] === '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60; - } - return false; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) - -/***/ }, -/* 79 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var _ = __webpack_require__(12); - - // Push a new query onto the compiled "sequence" stack, - // creating a new formatter, returning the compiler. - exports.pushQuery = function(query) { - if (!query) return; - if (_.isString(query)) { - query = {sql: query}; - } else { - query = query; - } - if (!query.bindings) { - query.bindings = this.formatter.bindings; - } - this.sequence.push(query); - this.formatter = this.client.formatter(); - }; - - // Used in cases where we need to push some additional column specific statements. - exports.pushAdditional = function(fn) { - var child = new this.constructor(this.client, this.tableCompiler, this.columnBuilder); - fn.call(child, _.rest(arguments)); - this.sequence.additional = (this.sequence.additional || []).concat(child.sequence); - }; - - -/***/ }, -/* 80 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - // Stub Seed: - // Used for now in browser builds, where filesystem access isn't - // available. Maybe we can eventually do websql migrations - // with jsonp and a json migration api. - var StubSeed = module.exports = function() {}; - - var Promise = __webpack_require__(83); - - var noSuchMethod = Promise.method(function() { - throw new Error("Seeds are not supported"); - }); - - StubSeed.prototype = { - make: noSuchMethod, - run: noSuchMethod - }; - - -/***/ }, -/* 81 */, -/* 82 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.seed = function(knex, Promise) { - return Promise.join( - // Deletes ALL existing entries - knex('table_name').del(), - - // Inserts seed entries - knex('table_name').insert({id: 1, colName: 'rowValue'}), - knex('table_name').insert({id: 2, colName: 'rowValue2'}), - knex('table_name').insert({id: 3, colName: 'rowValue3'}) - ); - }; - - -/***/ }, -/* 83 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __WEBPACK_EXTERNAL_MODULE_83__; - -/***/ }, -/* 84 */ -/***/ function(module, exports, __webpack_require__) { - - var baseCopy = __webpack_require__(99), - keys = __webpack_require__(100); - - /** - * The base implementation of `_.assign` without support for argument juggling, - * multiple sources, and `this` binding `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {Function} [customizer] The function to customize assigning values. - * @returns {Object} Returns the destination object. - */ - function baseAssign(object, source, customizer) { - var props = keys(source); - if (!customizer) { - return baseCopy(source, object, props); - } - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index], - value = object[key], - result = customizer(value, source[key], key, object, source); - - if ((result === result ? result !== value : value === value) || - (typeof value == 'undefined' && !(key in object))) { - object[key] = result; - } - } - return object; - } - - module.exports = baseAssign; - - -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { - - var bindCallback = __webpack_require__(89), - isIterateeCall = __webpack_require__(101); - - /** - * Creates a function that assigns properties of source object(s) to a given - * destination object. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ - function createAssigner(assigner) { - return function() { - var length = arguments.length, - object = arguments[0]; - - if (length < 2 || object == null) { - return object; - } - if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { - length = 2; - } - // Juggle arguments. - if (length > 3 && typeof arguments[length - 2] == 'function') { - var customizer = bindCallback(arguments[--length - 1], arguments[length--], 5); - } else if (length > 2 && typeof arguments[length - 1] == 'function') { - customizer = arguments[--length]; - } - var index = 0; - while (++index < length) { - var source = arguments[index]; - if (source) { - assigner(object, source, customizer); - } - } - return object; - }; - } - - module.exports = createAssigner; - - -/***/ }, -/* 86 */ -/***/ function(module, exports, __webpack_require__) { - - /* (ignored) */ - /***/ }, /* 87 */ -/***/ function(module, exports, __webpack_require__) { - - var arrayEach = __webpack_require__(102), - baseCallback = __webpack_require__(103), - baseCreate = __webpack_require__(104), - baseForOwn = __webpack_require__(105), - isArray = __webpack_require__(106), - isFunction = __webpack_require__(107), - isObject = __webpack_require__(108), - isTypedArray = __webpack_require__(109); - - /** - * An alternative to `_.reduce`; this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own enumerable - * properties through `iteratee`, with each invocation potentially mutating - * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked - * with four arguments; (accumulator, value, key, object). Iterator functions - * may exit iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @category Object - * @param {Array|Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the accumulated value. - * @example - * - * var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) { - * n *= n; - * if (n % 2) { - * return result.push(n) < 3; - * } - * }); - * // => [1, 9, 25] - * - * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { - * result[key] = n * 3; - * }); - * // => { 'a': 3, 'b': 6, 'c': 9 } - */ - function transform(object, iteratee, accumulator, thisArg) { - var isArr = isArray(object) || isTypedArray(object); - iteratee = baseCallback(iteratee, thisArg, 4); - - if (accumulator == null) { - if (isArr || isObject(object)) { - var Ctor = object.constructor; - if (isArr) { - accumulator = isArray(object) ? new Ctor : []; - } else { - accumulator = baseCreate(isFunction(Ctor) && Ctor.prototype); - } - } else { - accumulator = {}; - } - } - (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iteratee(accumulator, value, index, object); - }); - return accumulator; - } - - module.exports = transform; - - -/***/ }, -/* 88 */ -/***/ function(module, exports, __webpack_require__) { - - var arrayCopy = __webpack_require__(110), - arrayEach = __webpack_require__(102), - baseCopy = __webpack_require__(99), - baseForOwn = __webpack_require__(105), - initCloneArray = __webpack_require__(111), - initCloneByTag = __webpack_require__(112), - initCloneObject = __webpack_require__(113), - isArray = __webpack_require__(106), - isObject = __webpack_require__(108), - keys = __webpack_require__(100); - - /** `Object#toString` result references. */ - var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - weakMapTag = '[object WeakMap]'; - - var arrayBufferTag = '[object ArrayBuffer]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - - /** Used to identify `toStringTag` values supported by `_.clone`. */ - var cloneableTags = {}; - cloneableTags[argsTag] = cloneableTags[arrayTag] = - cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = - cloneableTags[dateTag] = cloneableTags[float32Tag] = - cloneableTags[float64Tag] = cloneableTags[int8Tag] = - cloneableTags[int16Tag] = cloneableTags[int32Tag] = - cloneableTags[numberTag] = cloneableTags[objectTag] = - cloneableTags[regexpTag] = cloneableTags[stringTag] = - cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = - cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; - cloneableTags[errorTag] = cloneableTags[funcTag] = - cloneableTags[mapTag] = cloneableTags[setTag] = - cloneableTags[weakMapTag] = false; - - /** Used for native method references. */ - var objectProto = Object.prototype; - - /** - * Used to resolve the `toStringTag` of values. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) - * for more details. - */ - var objToString = objectProto.toString; - - /** - * The base implementation of `_.clone` without support for argument juggling - * and `this` binding `customizer` functions. - * - * @private - * @param {*} value The value to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @param {Function} [customizer] The function to customize cloning values. - * @param {string} [key] The key of `value`. - * @param {Object} [object] The object `value` belongs to. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates clones with source counterparts. - * @returns {*} Returns the cloned value. - */ - function baseClone(value, isDeep, customizer, key, object, stackA, stackB) { - var result; - if (customizer) { - result = object ? customizer(value, key, object) : customizer(value); - } - if (typeof result != 'undefined') { - return result; - } - if (!isObject(value)) { - return value; - } - var isArr = isArray(value); - if (isArr) { - result = initCloneArray(value); - if (!isDeep) { - return arrayCopy(value, result); - } - } else { - var tag = objToString.call(value), - isFunc = tag == funcTag; - - if (tag == objectTag || tag == argsTag || (isFunc && !object)) { - result = initCloneObject(isFunc ? {} : value); - if (!isDeep) { - return baseCopy(value, result, keys(value)); - } - } else { - return cloneableTags[tag] - ? initCloneByTag(value, tag, isDeep) - : (object ? value : {}); - } - } - // Check for circular references and return corresponding clone. - stackA || (stackA = []); - stackB || (stackB = []); - - var length = stackA.length; - while (length--) { - if (stackA[length] == value) { - return stackB[length]; - } - } - // Add the source value to the stack of traversed objects and associate it with its clone. - stackA.push(value); - stackB.push(result); - - // Recursively populate clone (susceptible to call stack limits). - (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { - result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); - }); - return result; - } - - module.exports = baseClone; - - -/***/ }, -/* 89 */ -/***/ function(module, exports, __webpack_require__) { - - var identity = __webpack_require__(114); - - /** - * A specialized version of `baseCallback` which only supports `this` binding - * and specifying the number of arguments to provide to `func`. - * - * @private - * @param {Function} func The function to bind. - * @param {*} thisArg The `this` binding of `func`. - * @param {number} [argCount] The number of arguments to provide to `func`. - * @returns {Function} Returns the callback. - */ - function bindCallback(func, thisArg, argCount) { - if (typeof func != 'function') { - return identity; - } - if (typeof thisArg == 'undefined') { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - case 5: return function(value, other, key, object, source) { - return func.call(thisArg, value, other, key, object, source); - }; - } - return function() { - return func.apply(thisArg, arguments); - }; - } - - module.exports = bindCallback; - - -/***/ }, -/* 90 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Converts `value` to a string if it is not one. An empty string is returned - * for `null` or `undefined` values. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ - function baseToString(value) { - if (typeof value == 'string') { - return value; - } - return value == null ? '' : (value + ''); - } - - module.exports = baseToString; - - -/***/ }, -/* 91 */ -/***/ function(module, exports, __webpack_require__) { - - var baseProperty = __webpack_require__(122), - map = __webpack_require__(123); - - /** - * Gets the value of `key` from all elements in `collection`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {string} key The key of the property to pluck. - * @returns {Array} Returns the property values. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * _.pluck(users, 'user'); - * // => ['barney', 'fred'] - * - * var userIndex = _.indexBy(users, 'user'); - * _.pluck(userIndex, 'age'); - * // => [36, 40] (iteration order is not guaranteed) - */ - function pluck(collection, key) { - return map(collection, baseProperty(key)); - } - - module.exports = pluck; - - -/***/ }, -/* 92 */ -/***/ function(module, exports, __webpack_require__) { - - var baseFlatten = __webpack_require__(124), - bindCallback = __webpack_require__(89), - pickByArray = __webpack_require__(125), - pickByCallback = __webpack_require__(126); - - /** - * Creates an object composed of the picked `object` properties. Property - * names may be specified as individual arguments or as arrays of property - * names. If `predicate` is provided it is invoked for each property of `object` - * picking the properties `predicate` returns truthy for. The predicate is - * bound to `thisArg` and invoked with three arguments; (value, key, object). - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {Function|...(string|string[])} [predicate] The function invoked per - * iteration or property names to pick, specified as individual property - * names or arrays of property names. - * @param {*} [thisArg] The `this` binding of `predicate`. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'user': 'fred', 'age': 40 }; - * - * _.pick(object, 'user'); - * // => { 'user': 'fred' } - * - * _.pick(object, _.isString); - * // => { 'user': 'fred' } - */ - function pick(object, predicate, thisArg) { - if (object == null) { - return {}; - } - return typeof predicate == 'function' - ? pickByCallback(object, bindCallback(predicate, thisArg, 3)) - : pickByArray(object, baseFlatten(arguments, false, false, 1)); - } - - module.exports = pick; - - -/***/ }, -/* 93 */ /***/ function(module, exports, __webpack_require__) { // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 @@ -9518,7 +9373,7 @@ return /******/ (function(modules) { // webpackBootstrap // when used in node, this will actually load the util module we depend on // versus loading the builtin util module as happens otherwise // this is a bug in node module loading as far as I am concerned - var util = __webpack_require__(140); + var util = __webpack_require__(127); var pSlice = Array.prototype.slice; var hasOwn = Object.prototype.hasOwnProperty; @@ -9853,652 +9708,1436 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 94 */ +/* 88 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {'use strict'; + /* WEBPACK VAR INJECTION */(function(Buffer) {/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ - var Deque = __webpack_require__(159), - HashMap = __webpack_require__(160); + var base64 = __webpack_require__(149) + var ieee754 = __webpack_require__(138) + var isArray = __webpack_require__(139) - var inherits = __webpack_require__(140).inherits, - EventEmitter = __webpack_require__(42).EventEmitter, - debug = __webpack_require__(48)('pool2'); + exports.Buffer = Buffer + exports.SlowBuffer = SlowBuffer + exports.INSPECT_MAX_BYTES = 50 + Buffer.poolSize = 8192 // not used by this implementation - var assert = __webpack_require__(93); + var kMaxLength = 0x3fffffff + var rootParent = {} - function deprecate(old, current) { - if (process.env.NODE_ENV === 'testing') { return; } - console.log('Pool2: ' + old + ' is deprecated, please use ' + current); + /** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Note: + * + * - Implementation must support adding new properties to `Uint8Array` instances. + * Firefox 4-29 lacked support, fixed in Firefox 30+. + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + * + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will + * get the Object implementation, which is slower but will work correctly. + */ + Buffer.TYPED_ARRAY_SUPPORT = (function () { + try { + var buf = new ArrayBuffer(0) + var arr = new Uint8Array(buf) + arr.foo = function () { return 42 } + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } + })() + + /** + * Class: Buffer + * ============= + * + * The Buffer constructor returns instances of `Uint8Array` that are augmented + * with function properties for all the node `Buffer` API functions. We use + * `Uint8Array` so that square bracket notation works as expected -- it returns + * a single octet. + * + * By augmenting the instances, we can avoid modifying the `Uint8Array` + * prototype. + */ + function Buffer (arg) { + if (!(this instanceof Buffer)) { + // Avoid going through an ArgumentsAdaptorTrampoline in the common case. + if (arguments.length > 1) return new Buffer(arg, arguments[1]) + return new Buffer(arg) + } + + this.length = 0 + this.parent = undefined + + // Common case. + if (typeof arg === 'number') { + return fromNumber(this, arg) + } + + // Slightly less common case. + if (typeof arg === 'string') { + return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') + } + + // Unusual. + return fromObject(this, arg) } - function validNum(opts, val, standard, allowZero) { // jshint maxcomplexity: 8 - if (!opts || !opts.hasOwnProperty(val)) { - return standard; + function fromNumber (that, length) { + that = allocate(that, length < 0 ? 0 : checked(length) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < length; i++) { + that[i] = 0 } - var num = parseInt(opts[val], 10); - if (isNaN(num) || num !== +opts[val] || !isFinite(num) || num < 0) { - throw new RangeError('Pool2: ' + val + ' must be a positive integer, ' + opts[val] + ' given.'); - } - if (!allowZero && num === 0) { - throw new RangeError('Pool2: ' + val + ' cannot be 0.'); - } - return num; + } + return that } - function HOP(a, b) { return a && hasOwnProperty.call(a, b); } - function Pool(opts) { // jshint maxcomplexity: 12, maxstatements: 40 - EventEmitter.call(this); - - opts = opts || { }; + function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' - if (HOP(opts, 'release')) { - deprecate('opts.release', 'opts.dispose'); - opts.dispose = opts.release; - } + // Assumption: byteLength() return value is always < kMaxLength. + var length = byteLength(string, encoding) | 0 + that = allocate(that, length) - if (HOP(opts, 'releaseTimeout')) { - deprecate('opts.releaseTimeout', 'opts.disposeTimeout'); - opts.disposeTimeout = opts.releaseTimeout; - } - - assert(HOP(opts, 'acquire'), 'new Pool(): opts.acquire is required'); - assert(HOP(opts, 'dispose'), 'new Pool(): opts.dispose is required'); - assert(typeof opts.acquire === 'function', 'new Pool(): opts.acquire must be a function'); - assert(typeof opts.dispose === 'function', 'new Pool(): opts.dispose must be a function'); - assert(!HOP(opts, 'destroy') || typeof opts.destroy === 'function', 'new Pool(): opts.destroy must be a function'); - assert(!HOP(opts, 'ping') || typeof opts.ping === 'function', 'new Pool(): opts.ping must be a function'); - - this._acquire = opts.acquire; - this._dispose = opts.dispose; - this._destroy = opts.destroy || function () { }; - this._ping = opts.ping || function (res, cb) { cb(); }; - - this.max = validNum(opts, 'max', Pool.defaults.max); - this.min = validNum(opts, 'min', Pool.defaults.min, true); - - assert(this.max >= this.min, 'new Pool(): opts.min cannot be greater than opts.max'); - - this.maxRequests = validNum(opts, 'maxRequests', Infinity); - this.acquireTimeout = validNum(opts, 'acquireTimeout', Pool.defaults.acquireTimeout, true); - this.disposeTimeout = validNum(opts, 'disposeTimeout', Pool.defaults.disposeTimeout, true); - this.pingTimeout = validNum(opts, 'pingTimeout', Pool.defaults.pingTimeout); - this.idleTimeout = validNum(opts, 'idleTimeout', Pool.defaults.idleTimeout); - this.syncInterval = validNum(opts, 'syncInterval', Pool.defaults.syncInterval, true); - - assert(this.syncInterval > 0 || !HOP(opts, 'idleTimeout'), 'new Pool(): Cannot specify opts.idleTimeout when opts.syncInterval is 0'); - - this.capabilities = Array.isArray(opts.capabilities) ? opts.capabilities.slice() : [ ]; - - if (this.syncInterval !== 0) { - this.syncTimer = setInterval(function () { - this._ensureMinimum(); - this._reap(); - this._maybeAllocateResource(); - }.bind(this), this.syncInterval); - } - - this.live = false; - this.ending = false; - this.destroyed = false; - - this.acquiring = 0; - - this.pool = new HashMap(); - this.available = [ ]; - this.requests = new Deque(); - - process.nextTick(this._ensureMinimum.bind(this)); + that.write(string, encoding) | 0 + return that } - inherits(Pool, EventEmitter); - Pool.defaults = { - min: 0, - max: 10, - acquireTimeout: 30 * 1000, - disposeTimeout: 30 * 1000, - pingTimeout: 10 * 1000, - idleTimeout: 60 * 1000, - syncInterval: 10 * 1000 - }; + function fromObject (that, object) { + if (Buffer.isBuffer(object)) return fromBuffer(that, object) - // return stats on the pool - Pool.prototype.stats = function () { - var allocated = this.pool.count(); - return { - min: this.min, - max: this.max, - allocated: allocated, - available: this.max - (allocated - this.available.length), - queued: this.requests.length, - maxRequests: this.maxRequests - }; - }; + if (isArray(object)) return fromArray(that, object) - // request a resource from the pool - Pool.prototype.acquire = function (cb) { - if (this.destroyed || this.ending) { - cb(new Error('Pool is ' + (this.ending ? 'ending' : 'destroyed'))); - return; + if (object == null) { + throw new TypeError('must start with number, buffer, array or string') + } + + if (typeof ArrayBuffer !== 'undefined' && object.buffer instanceof ArrayBuffer) { + return fromTypedArray(that, object) + } + + if (object.length) return fromArrayLike(that, object) + + return fromJsonObject(that, object) + } + + function fromBuffer (that, buffer) { + var length = checked(buffer.length) | 0 + that = allocate(that, length) + buffer.copy(that, 0, 0, length) + return that + } + + function fromArray (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that + } + + // Duplicate of fromArray() to keep fromArray() monomorphic. + function fromTypedArray (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + // Truncating the elements is probably not what people expect from typed + // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior + // of the old Buffer constructor. + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that + } + + function fromArrayLike (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that + } + + // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. + // Returns a zero-length buffer for inputs that don't conform to the spec. + function fromJsonObject (that, object) { + var array + var length = 0 + + if (object.type === 'Buffer' && isArray(object.data)) { + array = object.data + length = checked(array.length) | 0 + } + that = allocate(that, length) + + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that + } + + function allocate (that, length) { + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = Buffer._augment(new Uint8Array(length)) + } else { + // Fallback: Return an object instance of the Buffer class + that.length = length + that._isBuffer = true + } + + var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 + if (fromPool) that.parent = rootParent + + return that + } + + function checked (length) { + // Note: cannot use `length < kMaxLength` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength.toString(16) + ' bytes') + } + return length >>> 0 + } + + function SlowBuffer (subject, encoding) { + if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) + + var buf = new Buffer(subject, encoding) + delete buf.parent + return buf + } + + Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) + } + + Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} + if (i !== len) { + x = a[i] + y = b[i] + } + if (x < y) return -1 + if (y < x) return 1 + return 0 + } + + Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'binary': + case 'base64': + case 'raw': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } + } + + Buffer.concat = function concat (list, length) { + if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') + + if (list.length === 0) { + return new Buffer(0) + } else if (list.length === 1) { + return list[0] + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; i++) { + length += list[i].length } - - if (this.requests.length >= this.maxRequests) { - cb(new Error('Pool is full')); - return; - } - - this.requests.push({ ts: new Date(), cb: cb }); - process.nextTick(this._maybeAllocateResource.bind(this)); - }; + } - // release the resource back into the pool - Pool.prototype.release = function (res) { // jshint maxstatements: 17 - var err; - - if (!this.pool.has(res)) { - err = new Error('Pool.release(): Resource not member of pool'); - err.res = res; - this.emit('error', err); - return; - } - - if (this.available.indexOf(res) > -1) { - err = new Error('Pool.release(): Resource already released'); - err.res = res; - this.emit('error', err); - return; - } - - - this.pool.set(res, new Date()); - this.available.unshift(res); - - if (this.requests.length === 0) { this.emit('drain'); } - - this._maybeAllocateResource(); - }; + var buf = new Buffer(length) + var pos = 0 + for (i = 0; i < list.length; i++) { + var item = list[i] + item.copy(buf, pos) + pos += item.length + } + return buf + } - // destroy the resource -- should be called only on error conditions and the like - Pool.prototype.destroy = function (res) { - debug('Ungracefully destroying resource'); - // make sure resource is not in our available resources array - var idx = this.available.indexOf(res); - if (idx > -1) { this.available.splice(idx, 1); } + function byteLength (string, encoding) { + if (typeof string !== 'string') string = String(string) - // remove from pool if present - if (this.pool.has(res)) { - this.pool.remove(res); - } - - // destroy is fire-and-forget - try { this._destroy(res); } - catch (e) { this.emit('warn', e); } - - this._ensureMinimum(); - }; + if (string.length === 0) return 0 - // attempt to tear down the resource nicely -- should be called when the resource is still valid - // (that is, the dispose callback is expected to behave correctly) - Pool.prototype.remove = function (res, cb) { // jshint maxcomplexity: 7 - // called sometimes internally for the timeout logic, but don't want to emit an error in those cases - var timer, skipError = false; - if (typeof cb === 'boolean') { - skipError = cb; - cb = null; - } - - // ensure resource is not in our available resources array - var idx = this.available.indexOf(res); - if (idx > -1) { this.available.splice(idx, 1); } - - if (this.pool.has(res)) { - this.pool.remove(res); - } else if (!skipError) { - // object isn't in our pool -- emit an error - this.emit('error', new Error('Pool.remove() called on non-member')); - } + switch (encoding || 'utf8') { + case 'ascii': + case 'binary': + case 'raw': + return string.length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return string.length * 2 + case 'hex': + return string.length >>> 1 + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'base64': + return base64ToBytes(string).length + default: + return string.length + } + } + Buffer.byteLength = byteLength - // if we don't get a response from the dispose callback - // within the timeout period, attempt to destroy the resource - if (this.disposeTimeout !== 0) { - timer = setTimeout(this.destroy.bind(this, res), this.disposeTimeout); - } + // pre-set for values that may exist in the future + Buffer.prototype.length = undefined + Buffer.prototype.parent = undefined - try { - debug('Attempting to gracefully remove resource'); - this._dispose(res, function (e) { - clearTimeout(timer); - if (e) { this.emit('warn', e); } - else { this._ensureMinimum(); } - - if (typeof cb === 'function') { cb(e); } - }.bind(this)); - } catch (e) { - clearTimeout(timer); - this.emit('warn', e); - if (typeof cb === 'function') { cb(e); } - } - }; + // toString(encoding, start=0, end=buffer.length) + Buffer.prototype.toString = function toString (encoding, start, end) { + var loweredCase = false - // attempt to gracefully close the pool - Pool.prototype.end = function (cb) { - cb = cb || function () { }; - - this.ending = true; - - var closeResources = function () { - debug('Closing resources'); - clearInterval(this.syncTimer); - - var count = this.pool.count(), - errors = [ ]; - - if (count === 0) { - cb(); - return; - } - - this.pool.forEach(function (value, key) { - this.remove(key, function (err, res) { - if (err) { errors.push(err); } - - count--; - if (count === 0) { - debug('Resources closed'); - if (errors.length) { cb(errors); } - else { cb(); } - } - }); - }.bind(this)); - }.bind(this); - - // begin now, or wait until there are no pending requests - if (this.requests.length === 0 && this.acquiring === 0) { - closeResources(); + start = start >>> 0 + end = end === undefined || end === Infinity ? this.length : end >>> 0 + + if (!encoding) encoding = 'utf8' + if (start < 0) start = 0 + if (end > this.length) end = this.length + if (end <= start) return '' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'binary': + return binarySlice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } + } + + Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 + } + + Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' + } + + Buffer.prototype.compare = function compare (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return 0 + return Buffer.compare(this, b) + } + + Buffer.prototype.indexOf = function indexOf (val, byteOffset) { + if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff + else if (byteOffset < -0x80000000) byteOffset = -0x80000000 + byteOffset >>= 0 + + if (this.length === 0) return -1 + if (byteOffset >= this.length) return -1 + + // Negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) + + if (typeof val === 'string') { + if (val.length === 0) return -1 // special case: looking for empty string always fails + return String.prototype.indexOf.call(this, val, byteOffset) + } + if (Buffer.isBuffer(val)) { + return arrayIndexOf(this, val, byteOffset) + } + if (typeof val === 'number') { + if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { + return Uint8Array.prototype.indexOf.call(this, val, byteOffset) + } + return arrayIndexOf(this, [ val ], byteOffset) + } + + function arrayIndexOf (arr, val, byteOffset) { + var foundIndex = -1 + for (var i = 0; byteOffset + i < arr.length; i++) { + if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex + } else { + foundIndex = -1 + } + } + return -1 + } + + throw new TypeError('val must be string, number or Buffer') + } + + // `get` will be removed in Node 0.13+ + Buffer.prototype.get = function get (offset) { + console.log('.get() is deprecated. Access using array indexes instead.') + return this.readUInt8(offset) + } + + // `set` will be removed in Node 0.13+ + Buffer.prototype.set = function set (v, offset) { + console.log('.set() is deprecated. Access using array indexes instead.') + return this.writeUInt8(v, offset) + } + + function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new Error('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; i++) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) throw new Error('Invalid hex string') + buf[offset + i] = parsed + } + return i + } + + function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) + } + + function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) + } + + function binaryWrite (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) + } + + function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) + } + + function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) + } + + Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' } else { - debug('Waiting for active requests to conclude before closing resources'); - this.once('drain', closeResources); + encoding = length + length = undefined } - }; + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + var swap = encoding + encoding = offset + offset = length >>> 0 + length = swap + } - // close idle resources - Pool.prototype._reap = function () { - var n = this.pool.count(), - i, c = 0, res, idleTimestamp, - idleThreshold = (new Date()) - this.idleTimeout; - - debug('reap (cur=%d, av=%d)', n, this.available.length); - - for (i = this.available.length; n > this.min && i >= 0; i--) { - res = this.available[i]; - idleTimestamp = this.pool.get(res); - - if (idleTimestamp < idleThreshold) { - n--; c++; - this.remove(res); - } + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'binary': + return binaryWrite(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true } - - if (c) { debug('Shrinking pool: destroying %d idle connections', c); } - }; - - // attempt to acquire at least the minimum quantity of resources - Pool.prototype._ensureMinimum = function () { - if (this.ending || this.destroyed) { return; } - - var n = this.min - (this.pool.count() + this.acquiring); - if (n <= 0) { return; } - - debug('Attempting to acquire minimum resources (cur=%d, min=%d)', this.pool.count(), this.min); - while (n--) { this._allocateResource(); } - }; - - // allocate a resource to a waiting request, if possible - Pool.prototype._maybeAllocateResource = function () { - // do nothing if there are no requests to serve - if (this.requests.length === 0) { return; } - - // call callback if there is a request and a resource to give it - if (this.available.length) { - var res = this.available.shift(); - - var abort = function () { - this.remove(res); - this._maybeAllocateResource(); - }.bind(this); - - var timer = setTimeout(abort, this.pingTimeout); - - try { - this._ping(res, function (err) { - clearTimeout(timer); - if (err) { - err.message = 'Ping failed, releasing resource: ' + err.message; - this.emit('warn', err); - abort(); - return; - } - - var req = this.requests.shift(); - debug('Allocating resource to request; waited %ds', ((new Date()) - req.ts) / 1000); - req.cb(null, res); - }.bind(this)); - } catch (err) { - err.message = 'Synchronous throw attempting to ping resource: ' + err.message; - this.emit('error', err); - abort(); - } - - return; - } - - // allocate a new resource if there is a request but no resource to give it - // and there's room in the pool - if (this.pool.count() + this.acquiring < this.max) { - debug('Growing pool: no resource to serve request'); - this._allocateResource(); - } - }; - - // create a new resource - Pool.prototype._allocateResource = function () { - if (this.destroyed) { - debug('Not allocating resource: destroyed'); - return; - } - - debug('Attempting to acquire resource (cur=%d, ac=%d)', this.pool.count(), this.acquiring); - - // acquiring is asynchronous, don't over-allocate due to in-progress resource allocation - this.acquiring++; - - var onError, timer; - - onError = function (err) { - clearTimeout(timer); - - debug('Couldn\'t allocate new resource:', err); - - // throw an error if we haven't successfully allocated a resource yet - if (this.live === false) { - this._destroyPool(); - err.message = 'Error allocating resources: ' + err.message; - this.emit('error', err); - } - }.bind(this); - - if (this.acquireTimeout !== 0) { - timer = setTimeout(function () { - debug('Timed out acquiring resource'); - timer = null; - this.acquiring--; - - onError(new Error('Timed out acquiring resource')); - - // timed out allocations are dropped; this could leave us below the - // minimum threshold; try to bring us up to the minimum, but don't spam - setTimeout(this._ensureMinimum.bind(this), 2 * 1000); - }.bind(this), this.acquireTimeout); - } - - try { - this._acquire(function (err, res) { // jshint maxstatements: 20 - if (timer) { - clearTimeout(timer); - timer = null; - this.acquiring--; - } else if (!err) { - this.remove(res, true); - return; - } - - if (err) { - onError(err); - return; - } - - this.live = true; - - debug('Successfully allocated new resource (cur=%d, ac=%d)', this.pool.count(), this.acquiring); - - this.pool.set(res, new Date()); - this.available.unshift(res); - - // normally 'drain' is emitted when the pending requests queue is empty; pending requests - // are the primary source of acquiring new resources. the pool minimum can cause resources - // to be acquired with no pending requests, however. if pool.end() is called while resources - // are being acquired to fill the minimum, the 'drain' event will never get triggered because - // there were no requests pending. in this case, we want to trigger the cleanup routine that - // normally binds to 'drain' - if (this.ending && this.requests.length === 0 && this.acquiring === 0) { - this.emit('drain'); - return; - } - - // we've successfully acquired a resource, and we only get - // here if something wants it, so... do that - this._maybeAllocateResource(); - }.bind(this)); - } catch (e) { - onError(e); - } - }; - - // destroy the pool itself - Pool.prototype._destroyPool = function () { - this.destroyed = true; - clearInterval(this.syncTimer); - this.pool.forEach(function (value, key) { - this.destroy(key); - }.bind(this)); - this.pool.clear(); - }; - - Pool._validNum = validNum; - - module.exports = Pool; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) - -/***/ }, -/* 95 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - - var HashMap = __webpack_require__(160), - Pool = __webpack_require__(94); - - var inherits = __webpack_require__(140).inherits, - EventEmitter = __webpack_require__(42).EventEmitter; - - function Cluster(pools) { - EventEmitter.call(this); - - if (!pools) { pools = [ ]; } - else if (!Array.isArray(pools)) { pools = [ pools ]; } - - this.pools = [ ]; - this.caps = { }; - this.removeListeners = new HashMap(); - this.sources = new HashMap(); - - this.ended = false; - - pools.forEach(this.addPool, this); + } } - inherits(Cluster, EventEmitter); - Cluster.prototype.addPool = function (pool) { - if (this.ended) { - throw new Error('Cluster.addPool(): Cluster is ended'); + Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } + } + + function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } + } + + function utf8Slice (buf, start, end) { + var res = '' + var tmp = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + if (buf[i] <= 0x7F) { + res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) + tmp = '' + } else { + tmp += '%' + buf[i].toString(16) } - if (!(pool instanceof Pool)) { - throw new Error('Cluster.addPool(): Not a valid pool'); + } + + return res + decodeUtf8Char(tmp) + } + + function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret + } + + function binarySlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i]) + } + return ret + } + + function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; i++) { + out += toHex(buf[i]) + } + return out + } + + function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res + } + + Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = Buffer._augment(this.subarray(start, end)) + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; i++) { + newBuf[i] = this[i + start] } - if (this.pools.indexOf(pool) > -1) { - throw new Error('Cluster.addPool(): Pool already in cluster'); + } + + if (newBuf.length) newBuf.parent = this.parent || this + + return newBuf + } + + /* + * Need to make sure that buffer isn't trying to write out of bounds. + */ + function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') + } + + Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val + } + + Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val + } + + Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] + } + + Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) + } + + Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] + } + + Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) + } + + Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) + } + + Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val + } + + Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val + } + + Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) + } + + Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val + } + + Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val + } + + Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) + } + + Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) + } + + Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) + } + + Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) + } + + Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) + } + + Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) + } + + function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') + } + + Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) >>> 0 & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) >>> 0 & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = value + return offset + 1 + } + + function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } + } + + Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 + } + + Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = value + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 + } + + function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } + } + + Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = value + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 + } + + Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = value + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 + } + + Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkInt( + this, value, offset, byteLength, + Math.pow(2, 8 * byteLength - 1) - 1, + -Math.pow(2, 8 * byteLength - 1) + ) + } + + var i = 0 + var mul = 1 + var sub = value < 0 ? 1 : 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkInt( + this, value, offset, byteLength, + Math.pow(2, 8 * byteLength - 1) - 1, + -Math.pow(2, 8 * byteLength - 1) + ) + } + + var i = byteLength - 1 + var mul = 1 + var sub = value < 0 ? 1 : 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength + } + + Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = value + return offset + 1 + } + + Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 + } + + Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = value + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 + } + + Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 + } + + Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = value + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 + } + + function checkIEEE754 (buf, value, offset, ext, max, min) { + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') + if (offset < 0) throw new RangeError('index out of range') + } + + function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 + } + + Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) + } + + Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) + } + + function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 + } + + Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) + } + + Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) + } + + // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) + Buffer.prototype.copy = function copy (target, target_start, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (target_start >= target.length) target_start = target.length + if (!target_start) target_start = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (target_start < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - target_start < end - start) { + end = target.length - target_start + start + } + + var len = end - start + + if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < len; i++) { + target[i + target_start] = this[i + start] } - - this.pools.push(pool); - this._bindListeners(pool); - this._addCapabilities(pool); - }; - Cluster.prototype.removePool = function (pool) { - if (!(pool instanceof Pool)) { - throw new Error('Cluster.removePool(): Not a valid pool'); + } else { + target._set(this.subarray(start, start + len), target_start) + } + + return len + } + + // fill(value, start=0, end=buffer.length) + Buffer.prototype.fill = function fill (value, start, end) { + if (!value) value = 0 + if (!start) start = 0 + if (!end) end = this.length + + if (end < start) throw new RangeError('end < start') + + // Fill 0 bytes; we're done + if (end === start) return + if (this.length === 0) return + + if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') + if (end < 0 || end > this.length) throw new RangeError('end out of bounds') + + var i + if (typeof value === 'number') { + for (i = start; i < end; i++) { + this[i] = value } - var idx = this.pools.indexOf(pool); - if (idx === -1) { - throw new Error('Cluster.removePool(): Pool not in cluster'); + } else { + var bytes = utf8ToBytes(value.toString()) + var len = bytes.length + for (i = start; i < end; i++) { + this[i] = bytes[i % len] } - - this.pools.splice(idx, 1); - this._unbindListeners(pool); - this._removeCapabilities(pool); - }; - Cluster.prototype.acquire = function (cap, cb) { // jshint maxstatements: 20, maxcomplexity: 8 - if (typeof cap === 'function') { - cb = cap; - cap = void 0; + } + + return this + } + + /** + * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. + * Added in Node 0.12. Only available in browsers that support ArrayBuffer. + */ + Buffer.prototype.toArrayBuffer = function toArrayBuffer () { + if (typeof Uint8Array !== 'undefined') { + if (Buffer.TYPED_ARRAY_SUPPORT) { + return (new Buffer(this)).buffer + } else { + var buf = new Uint8Array(this.length) + for (var i = 0, len = buf.length; i < len; i += 1) { + buf[i] = this[i] + } + return buf.buffer } - if (typeof cb !== 'function') { - this.emit('error', new Error('Cluster.acquire(): Callback is required')); - return; - } - if (this.ended) { - cb(new Error('Cluster.acquire(): Cluster is ended')); - return; - } - - var sources = this.pools; - if (cap) { - if (!this.caps[cap] || !this.caps[cap].length) { - cb(new Error('Cluster.acquire(): No pools can fulfil capability: ' + cap)); - return; + } else { + throw new TypeError('Buffer.toArrayBuffer not supported in this browser') + } + } + + // HELPER FUNCTIONS + // ================ + + var BP = Buffer.prototype + + /** + * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods + */ + Buffer._augment = function _augment (arr) { + arr.constructor = Buffer + arr._isBuffer = true + + // save reference to original Uint8Array set method before overwriting + arr._set = arr.set + + // deprecated, will be removed in node 0.13+ + arr.get = BP.get + arr.set = BP.set + + arr.write = BP.write + arr.toString = BP.toString + arr.toLocaleString = BP.toString + arr.toJSON = BP.toJSON + arr.equals = BP.equals + arr.compare = BP.compare + arr.indexOf = BP.indexOf + arr.copy = BP.copy + arr.slice = BP.slice + arr.readUIntLE = BP.readUIntLE + arr.readUIntBE = BP.readUIntBE + arr.readUInt8 = BP.readUInt8 + arr.readUInt16LE = BP.readUInt16LE + arr.readUInt16BE = BP.readUInt16BE + arr.readUInt32LE = BP.readUInt32LE + arr.readUInt32BE = BP.readUInt32BE + arr.readIntLE = BP.readIntLE + arr.readIntBE = BP.readIntBE + arr.readInt8 = BP.readInt8 + arr.readInt16LE = BP.readInt16LE + arr.readInt16BE = BP.readInt16BE + arr.readInt32LE = BP.readInt32LE + arr.readInt32BE = BP.readInt32BE + arr.readFloatLE = BP.readFloatLE + arr.readFloatBE = BP.readFloatBE + arr.readDoubleLE = BP.readDoubleLE + arr.readDoubleBE = BP.readDoubleBE + arr.writeUInt8 = BP.writeUInt8 + arr.writeUIntLE = BP.writeUIntLE + arr.writeUIntBE = BP.writeUIntBE + arr.writeUInt16LE = BP.writeUInt16LE + arr.writeUInt16BE = BP.writeUInt16BE + arr.writeUInt32LE = BP.writeUInt32LE + arr.writeUInt32BE = BP.writeUInt32BE + arr.writeIntLE = BP.writeIntLE + arr.writeIntBE = BP.writeIntBE + arr.writeInt8 = BP.writeInt8 + arr.writeInt16LE = BP.writeInt16LE + arr.writeInt16BE = BP.writeInt16BE + arr.writeInt32LE = BP.writeInt32LE + arr.writeInt32BE = BP.writeInt32BE + arr.writeFloatLE = BP.writeFloatLE + arr.writeFloatBE = BP.writeFloatBE + arr.writeDoubleLE = BP.writeDoubleLE + arr.writeDoubleBE = BP.writeDoubleBE + arr.fill = BP.fill + arr.inspect = BP.inspect + arr.toArrayBuffer = BP.toArrayBuffer + + return arr + } + + var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g + + function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str + } + + function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') + } + + function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) + } + + function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + var i = 0 + + for (; i < length; i++) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (leadSurrogate) { + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } else { + // valid surrogate pair + codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 + leadSurrogate = null } - sources = this.caps[cap]; - } - - var pool = sources.filter(function (pool) { - var stats = pool.stats(); - return stats.queued < stats.maxRequests; - }).sort(function (a, b) { - var statsA = a.stats(), - statsB = b.stats(); + } else { + // no lead yet - return (statsB.available - statsB.queued) - (statsA.available - statsA.queued); - })[0]; - - if (!pool) { - cb(new Error('Cluster.acquire(): No pools available')); - return; - } - - pool.acquire(function (err, res) { - if (err) { cb(err); return; } - this.sources.set(res, pool); - process.nextTick(cb.bind(null, null, res)); - }.bind(this)); - }; - Cluster.prototype.release = function (res) { - if (!this.sources.has(res)) { - var err = new Error('Cluster.release(): Unknown resource'); - err.res = res; - this.emit('error', err); - return; - } - var pool = this.sources.get(res); - this.sources.remove(res); - pool.release(res); - }; - Cluster.prototype.end = function (cb) { - if (this.ended) { - if (typeof cb === 'function') { - cb(new Error('Cluster.end(): Cluster is already ended')); + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else { + // valid lead + leadSurrogate = codePoint + continue } - return; + } + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = null } - this.ended = true; - - var count = this.pools.length, - errs = [ ]; - - this.pools.forEach(function (pool) { - pool.end(function (err, res) { - this.removePool(pool); - if (err) { errs.concat(err); } - count--; - if (count === 0 && typeof cb === 'function') { - cb(errs.length ? errs : null); - } - }.bind(this)); - }, this); - }; + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x200000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } - Cluster.prototype._addCapabilities = function (pool) { - if (!pool.capabilities || !Array.isArray(pool.capabilities)) { return; } - pool.capabilities.forEach(function (cap) { - if (typeof cap !== 'string') { return; } - this.caps[cap] = this.caps[cap] || [ ]; - this.caps[cap].push(pool); - }, this); - }; - Cluster.prototype._removeCapabilities = function (pool) { - if (!pool.capabilities || !Array.isArray(pool.capabilities)) { return; } - pool.capabilities.forEach(function (cap) { - if (typeof cap !== 'string' || !Array.isArray(this.caps[cap])) { return; } - var idx = this.caps[cap].indexOf(pool); - if (idx > -1) { this.caps[cap].splice(idx, 1); } - }, this); - }; - Cluster.prototype._bindListeners = function (pool) { - var onError, onWarn; + return bytes + } - onError = function (err) { - err.source = pool; - this.emit('error', err); - }.bind(this); - - onWarn = function (err) { - err.source = pool; - this.emit('warn', err); - }.bind(this); - - pool.on('error', onError); - pool.on('warn', onWarn); - - this.removeListeners.set(pool, function () { - pool.removeListener('error', onError); - pool.removeListener('warn', onWarn); - }); - }; - Cluster.prototype._unbindListeners = function (pool) { - this.removeListeners.get(pool)(); - this.removeListeners.remove(pool); - }; + function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; i++) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray + } + function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; i++) { + if ((units -= 2) < 0) break - module.exports = Cluster; + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) + return byteArray + } + + function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) + } + + function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; i++) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i + } + + function decodeUtf8Char (str) { + try { + return decodeURIComponent(str) + } catch (err) { + return String.fromCharCode(0xFFFD) // UTF 8 invalid char + } + } + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) /***/ }, -/* 96 */ +/* 89 */ /***/ function(module, exports, __webpack_require__) { - exports = module.exports = __webpack_require__(130); - exports.Stream = __webpack_require__(127); + exports = module.exports = __webpack_require__(122); + exports.Stream = __webpack_require__(120); exports.Readable = exports; - exports.Writable = __webpack_require__(131); - exports.Duplex = __webpack_require__(132); - exports.Transform = __webpack_require__(133); - exports.PassThrough = __webpack_require__(134); + exports.Writable = __webpack_require__(123); + exports.Duplex = __webpack_require__(124); + exports.Transform = __webpack_require__(125); + exports.PassThrough = __webpack_require__(126); /***/ }, -/* 97 */ +/* 90 */ /***/ function(module, exports, __webpack_require__) { @@ -10514,7 +11153,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.disable = disable; exports.enable = enable; exports.enabled = enabled; - exports.humanize = __webpack_require__(161); + exports.humanize = __webpack_require__(150); /** * The currently active debug mode names, and names to skip. @@ -10701,184 +11340,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 98 */ -/***/ function(module, exports, __webpack_require__) { - - var baseMerge = __webpack_require__(135), - createAssigner = __webpack_require__(85); - - /** - * Recursively merges own enumerable properties of the source object(s), that - * don't resolve to `undefined` into the destination object. Subsequent sources - * overwrite property assignments of previous sources. If `customizer` is - * provided it is invoked to produce the merged values of the destination and - * source properties. If `customizer` returns `undefined` merging is handled - * by the method instead. The `customizer` is bound to `thisArg` and invoked - * with five arguments; (objectValue, sourceValue, key, object, source). - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @param {Function} [customizer] The function to customize merging properties. - * @param {*} [thisArg] The `this` binding of `customizer`. - * @returns {Object} Returns `object`. - * @example - * - * var users = { - * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }] - * }; - * - * var ages = { - * 'data': [{ 'age': 36 }, { 'age': 40 }] - * }; - * - * _.merge(users, ages); - * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] } - * - * // using a customizer callback - * var object = { - * 'fruits': ['apple'], - * 'vegetables': ['beet'] - * }; - * - * var other = { - * 'fruits': ['banana'], - * 'vegetables': ['carrot'] - * }; - * - * _.merge(object, other, function(a, b) { - * return _.isArray(a) ? a.concat(b) : undefined; - * }); - * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } - */ - var merge = createAssigner(baseMerge); - - module.exports = merge; - - -/***/ }, -/* 99 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Copies the properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Object} [object={}] The object to copy properties to. - * @param {Array} props The property names to copy. - * @returns {Object} Returns `object`. - */ - function baseCopy(source, object, props) { - if (!props) { - props = object; - object = {}; - } - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - object[key] = source[key]; - } - return object; - } - - module.exports = baseCopy; - - -/***/ }, -/* 100 */ -/***/ function(module, exports, __webpack_require__) { - - var isLength = __webpack_require__(136), - isNative = __webpack_require__(137), - isObject = __webpack_require__(108), - shimKeys = __webpack_require__(138); - - /* Native method references for those with the same name as other `lodash` methods. */ - var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys; - - /** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys) - * for more details. - * - * @static - * @memberOf _ - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ - var keys = !nativeKeys ? shimKeys : function(object) { - if (object) { - var Ctor = object.constructor, - length = object.length; - } - if ((typeof Ctor == 'function' && Ctor.prototype === object) || - (typeof object != 'function' && (length && isLength(length)))) { - return shimKeys(object); - } - return isObject(object) ? nativeKeys(object) : []; - }; - - module.exports = keys; - - -/***/ }, -/* 101 */ -/***/ function(module, exports, __webpack_require__) { - - var isIndex = __webpack_require__(139), - isLength = __webpack_require__(136), - isObject = __webpack_require__(108); - - /** - * Checks if the provided arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. - */ - function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index; - if (type == 'number') { - var length = object.length, - prereq = isLength(length) && isIndex(index, length); - } else { - prereq = type == 'string' && index in object; - } - return prereq && object[index] === value; - } - - module.exports = isIterateeCall; - - -/***/ }, -/* 102 */ +/* 91 */ /***/ function(module, exports, __webpack_require__) { /** @@ -10906,15 +11368,15 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 103 */ +/* 92 */ /***/ function(module, exports, __webpack_require__) { - var baseMatches = __webpack_require__(141), - baseMatchesProperty = __webpack_require__(142), - baseProperty = __webpack_require__(122), - bindCallback = __webpack_require__(89), - identity = __webpack_require__(114), - isBindable = __webpack_require__(143); + var baseMatches = __webpack_require__(128), + baseMatchesProperty = __webpack_require__(129), + baseProperty = __webpack_require__(114), + bindCallback = __webpack_require__(61), + identity = __webpack_require__(107), + isBindable = __webpack_require__(130); /** * The base implementation of `_.callback` which supports specifying the @@ -10948,10 +11410,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 104 */ +/* 93 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {var isObject = __webpack_require__(108); + /* WEBPACK VAR INJECTION */(function(global) {var isObject = __webpack_require__(97); /** * The base implementation of `_.create` without support for assigning @@ -10978,11 +11440,11 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 105 */ +/* 94 */ /***/ function(module, exports, __webpack_require__) { - var baseFor = __webpack_require__(144), - keys = __webpack_require__(100); + var baseFor = __webpack_require__(131), + keys = __webpack_require__(101); /** * The base implementation of `_.forOwn` without support for callback @@ -11001,12 +11463,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 106 */ +/* 95 */ /***/ function(module, exports, __webpack_require__) { - var isLength = __webpack_require__(136), - isNative = __webpack_require__(137), - isObjectLike = __webpack_require__(145); + var isLength = __webpack_require__(132), + isNative = __webpack_require__(133), + isObjectLike = __webpack_require__(134); /** `Object#toString` result references. */ var arrayTag = '[object Array]'; @@ -11048,10 +11510,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 107 */ +/* 96 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {var isNative = __webpack_require__(137); + /* WEBPACK VAR INJECTION */(function(global) {var isNative = __webpack_require__(133); /** `Object#toString` result references. */ var funcTag = '[object Function]'; @@ -11105,7 +11567,7 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 108 */ +/* 97 */ /***/ function(module, exports, __webpack_require__) { /** @@ -11141,11 +11603,11 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 109 */ +/* 98 */ /***/ function(module, exports, __webpack_require__) { - var isLength = __webpack_require__(136), - isObjectLike = __webpack_require__(145); + var isLength = __webpack_require__(132), + isObjectLike = __webpack_require__(134); /** `Object#toString` result references. */ var argsTag = '[object Arguments]', @@ -11222,182 +11684,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 110 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [array=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ - function arrayCopy(source, array) { - var index = -1, - length = source.length; - - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; - } - return array; - } - - module.exports = arrayCopy; - - -/***/ }, -/* 111 */ -/***/ function(module, exports, __webpack_require__) { - - /** Used for native method references. */ - var objectProto = Object.prototype; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto.hasOwnProperty; - - /** - * Initializes an array clone. - * - * @private - * @param {Array} array The array to clone. - * @returns {Array} Returns the initialized clone. - */ - function initCloneArray(array) { - var length = array.length, - result = new array.constructor(length); - - // Add array properties assigned by `RegExp#exec`. - if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { - result.index = array.index; - result.input = array.input; - } - return result; - } - - module.exports = initCloneArray; - - -/***/ }, -/* 112 */ -/***/ function(module, exports, __webpack_require__) { - - var bufferClone = __webpack_require__(146); - - /** `Object#toString` result references. */ - var boolTag = '[object Boolean]', - dateTag = '[object Date]', - numberTag = '[object Number]', - regexpTag = '[object RegExp]', - stringTag = '[object String]'; - - var arrayBufferTag = '[object ArrayBuffer]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - - /** Used to match `RegExp` flags from their coerced string values. */ - var reFlags = /\w*$/; - - /** - * Initializes an object clone based on its `toStringTag`. - * - * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * - * @private - * @param {Object} object The object to clone. - * @param {string} tag The `toStringTag` of the object to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the initialized clone. - */ - function initCloneByTag(object, tag, isDeep) { - var Ctor = object.constructor; - switch (tag) { - case arrayBufferTag: - return bufferClone(object); - - case boolTag: - case dateTag: - return new Ctor(+object); - - case float32Tag: case float64Tag: - case int8Tag: case int16Tag: case int32Tag: - case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: - var buffer = object.buffer; - return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); - - case numberTag: - case stringTag: - return new Ctor(object); - - case regexpTag: - var result = new Ctor(object.source, reFlags.exec(object)); - result.lastIndex = object.lastIndex; - } - return result; - } - - module.exports = initCloneByTag; - - -/***/ }, -/* 113 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Initializes an object clone. - * - * @private - * @param {Object} object The object to clone. - * @returns {Object} Returns the initialized clone. - */ - function initCloneObject(object) { - var Ctor = object.constructor; - if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) { - Ctor = Object; - } - return new Ctor; - } - - module.exports = initCloneObject; - - -/***/ }, -/* 114 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * This method returns the first argument provided to it. - * - * @static - * @memberOf _ - * @category Utility - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'user': 'fred' }; - * _.identity(object) === object; - * // => true - */ - function identity(value) { - return value; - } - - module.exports = identity; - - -/***/ }, -/* 115 */ +/* 99 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {/*! https://mths.be/punycode v1.3.2 by @mathias */ @@ -11929,10 +12216,304 @@ return /******/ (function(modules) { // webpackBootstrap }(this)); - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(162)(module), (function() { return this; }()))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(151)(module), (function() { return this; }()))) /***/ }, -/* 116 */ +/* 100 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Copies the properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Object} [object={}] The object to copy properties to. + * @param {Array} props The property names to copy. + * @returns {Object} Returns `object`. + */ + function baseCopy(source, object, props) { + if (!props) { + props = object; + object = {}; + } + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + object[key] = source[key]; + } + return object; + } + + module.exports = baseCopy; + + +/***/ }, +/* 101 */ +/***/ function(module, exports, __webpack_require__) { + + var isLength = __webpack_require__(132), + isNative = __webpack_require__(133), + isObject = __webpack_require__(97), + shimKeys = __webpack_require__(135); + + /* Native method references for those with the same name as other `lodash` methods. */ + var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys; + + /** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys) + * for more details. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ + var keys = !nativeKeys ? shimKeys : function(object) { + if (object) { + var Ctor = object.constructor, + length = object.length; + } + if ((typeof Ctor == 'function' && Ctor.prototype === object) || + (typeof object != 'function' && (length && isLength(length)))) { + return shimKeys(object); + } + return isObject(object) ? nativeKeys(object) : []; + }; + + module.exports = keys; + + +/***/ }, +/* 102 */ +/***/ function(module, exports, __webpack_require__) { + + var isIndex = __webpack_require__(136), + isLength = __webpack_require__(132), + isObject = __webpack_require__(97); + + /** + * Checks if the provided arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + */ + function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number') { + var length = object.length, + prereq = isLength(length) && isIndex(index, length); + } else { + prereq = type == 'string' && index in object; + } + return prereq && object[index] === value; + } + + module.exports = isIterateeCall; + + +/***/ }, +/* 103 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ + function arrayCopy(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; + } + + module.exports = arrayCopy; + + +/***/ }, +/* 104 */ +/***/ function(module, exports, __webpack_require__) { + + /** Used for native method references. */ + var objectProto = Object.prototype; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ + function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add array properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; + } + + module.exports = initCloneArray; + + +/***/ }, +/* 105 */ +/***/ function(module, exports, __webpack_require__) { + + var bufferClone = __webpack_require__(137); + + /** `Object#toString` result references. */ + var boolTag = '[object Boolean]', + dateTag = '[object Date]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + stringTag = '[object String]'; + + var arrayBufferTag = '[object ArrayBuffer]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + + /** Used to match `RegExp` flags from their coerced string values. */ + var reFlags = /\w*$/; + + /** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return bufferClone(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: + var buffer = object.buffer; + return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + var result = new Ctor(object.source, reFlags.exec(object)); + result.lastIndex = object.lastIndex; + } + return result; + } + + module.exports = initCloneByTag; + + +/***/ }, +/* 106 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ + function initCloneObject(object) { + var Ctor = object.constructor; + if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) { + Ctor = Object; + } + return new Ctor; + } + + module.exports = initCloneObject; + + +/***/ }, +/* 107 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * This method returns the first argument provided to it. + * + * @static + * @memberOf _ + * @category Utility + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'user': 'fred' }; + * _.identity(object) === object; + * // => true + */ + function identity(value) { + return value; + } + + module.exports = identity; + + +/***/ }, +/* 108 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -11949,7 +12530,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 117 */ +/* 109 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -12011,11 +12592,11 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 118 */ +/* 110 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var ansiRegex = __webpack_require__(164)(); + var ansiRegex = __webpack_require__(160)(); module.exports = function (str) { return typeof str === 'string' ? str.replace(ansiRegex, '') : str; @@ -12023,17 +12604,17 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 119 */ +/* 111 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var ansiRegex = __webpack_require__(163); + var ansiRegex = __webpack_require__(161); var re = new RegExp(ansiRegex().source); // remove the `g` flag module.exports = re.test.bind(re); /***/ }, -/* 120 */ +/* 112 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; @@ -12080,20 +12661,20 @@ return /******/ (function(modules) { // webpackBootstrap return false; })(); - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 121 */ +/* 113 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - exports.decode = exports.parse = __webpack_require__(147); - exports.encode = exports.stringify = __webpack_require__(148); + exports.decode = exports.parse = __webpack_require__(140); + exports.encode = exports.stringify = __webpack_require__(141); /***/ }, -/* 122 */ +/* 114 */ /***/ function(module, exports, __webpack_require__) { /** @@ -12113,13 +12694,13 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 123 */ +/* 115 */ /***/ function(module, exports, __webpack_require__) { - var arrayMap = __webpack_require__(149), - baseCallback = __webpack_require__(103), - baseMap = __webpack_require__(150), - isArray = __webpack_require__(106); + var arrayMap = __webpack_require__(142), + baseCallback = __webpack_require__(92), + baseMap = __webpack_require__(143), + isArray = __webpack_require__(95); /** * Creates an array of values by running each element in `collection` through @@ -12183,13 +12764,13 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 124 */ +/* 116 */ /***/ function(module, exports, __webpack_require__) { - var isArguments = __webpack_require__(151), - isArray = __webpack_require__(106), - isLength = __webpack_require__(136), - isObjectLike = __webpack_require__(145); + var isArguments = __webpack_require__(144), + isArray = __webpack_require__(95), + isLength = __webpack_require__(132), + isObjectLike = __webpack_require__(134); /** * The base implementation of `_.flatten` with added support for restricting @@ -12234,10 +12815,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 125 */ +/* 117 */ /***/ function(module, exports, __webpack_require__) { - var toObject = __webpack_require__(152); + var toObject = __webpack_require__(145); /** * A specialized version of `_.pick` that picks `object` properties specified @@ -12268,10 +12849,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 126 */ +/* 118 */ /***/ function(module, exports, __webpack_require__) { - var baseForIn = __webpack_require__(153); + var baseForIn = __webpack_require__(146); /** * A specialized version of `_.pick` that picks `object` properties `predicate` @@ -12296,7 +12877,65 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 127 */ +/* 119 */ +/***/ function(module, exports, __webpack_require__) { + + var baseMerge = __webpack_require__(147), + createAssigner = __webpack_require__(58); + + /** + * Recursively merges own enumerable properties of the source object(s), that + * don't resolve to `undefined` into the destination object. Subsequent sources + * overwrite property assignments of previous sources. If `customizer` is + * provided it is invoked to produce the merged values of the destination and + * source properties. If `customizer` returns `undefined` merging is handled + * by the method instead. The `customizer` is bound to `thisArg` and invoked + * with five arguments; (objectValue, sourceValue, key, object, source). + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @param {Function} [customizer] The function to customize merging properties. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {Object} Returns `object`. + * @example + * + * var users = { + * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }] + * }; + * + * var ages = { + * 'data': [{ 'age': 36 }, { 'age': 40 }] + * }; + * + * _.merge(users, ages); + * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] } + * + * // using a customizer callback + * var object = { + * 'fruits': ['apple'], + * 'vegetables': ['beet'] + * }; + * + * var other = { + * 'fruits': ['banana'], + * 'vegetables': ['carrot'] + * }; + * + * _.merge(object, other, function(a, b) { + * return _.isArray(a) ? a.concat(b) : undefined; + * }); + * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } + */ + var merge = createAssigner(baseMerge); + + module.exports = merge; + + +/***/ }, +/* 120 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -12322,15 +12961,15 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Stream; - var EE = __webpack_require__(42).EventEmitter; - var inherits = __webpack_require__(186); + var EE = __webpack_require__(41).EventEmitter; + var inherits = __webpack_require__(44); inherits(Stream, EE); - Stream.Readable = __webpack_require__(174); - Stream.Writable = __webpack_require__(175); - Stream.Duplex = __webpack_require__(176); - Stream.Transform = __webpack_require__(177); - Stream.PassThrough = __webpack_require__(178); + Stream.Readable = __webpack_require__(89); + Stream.Writable = __webpack_require__(152); + Stream.Duplex = __webpack_require__(153); + Stream.Transform = __webpack_require__(154); + Stream.PassThrough = __webpack_require__(155); // Backwards-compat with node 0.4.x Stream.Stream = Stream; @@ -12429,10 +13068,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 128 */ +/* 121 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(Buffer) {var rng = __webpack_require__(154) + /* WEBPACK VAR INJECTION */(function(Buffer) {var rng = __webpack_require__(156) function error () { var m = [].slice.call(arguments).join(' ') @@ -12443,9 +13082,9 @@ return /******/ (function(modules) { // webpackBootstrap ].join('\n')) } - exports.createHash = __webpack_require__(155) + exports.createHash = __webpack_require__(157) - exports.createHmac = __webpack_require__(156) + exports.createHmac = __webpack_require__(158) exports.randomBytes = function(size, callback) { if (callback && callback.call) { @@ -12466,7 +13105,7 @@ return /******/ (function(modules) { // webpackBootstrap return ['sha1', 'sha256', 'sha512', 'md5', 'rmd160'] } - var p = __webpack_require__(157)(exports) + var p = __webpack_require__(159)(exports) exports.pbkdf2 = p.pbkdf2 exports.pbkdf2Sync = p.pbkdf2Sync @@ -12486,1431 +13125,10 @@ return /******/ (function(modules) { // webpackBootstrap } }) - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) /***/ }, -/* 129 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ - - var base64 = __webpack_require__(188) - var ieee754 = __webpack_require__(180) - var isArray = __webpack_require__(181) - - exports.Buffer = Buffer - exports.SlowBuffer = SlowBuffer - exports.INSPECT_MAX_BYTES = 50 - Buffer.poolSize = 8192 // not used by this implementation - - var kMaxLength = 0x3fffffff - var rootParent = {} - - /** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Note: - * - * - Implementation must support adding new properties to `Uint8Array` instances. - * Firefox 4-29 lacked support, fixed in Firefox 30+. - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - * - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will - * get the Object implementation, which is slower but will work correctly. - */ - Buffer.TYPED_ARRAY_SUPPORT = (function () { - try { - var buf = new ArrayBuffer(0) - var arr = new Uint8Array(buf) - arr.foo = function () { return 42 } - return arr.foo() === 42 && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } - })() - - /** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ - function Buffer (arg) { - if (!(this instanceof Buffer)) { - // Avoid going through an ArgumentsAdaptorTrampoline in the common case. - if (arguments.length > 1) return new Buffer(arg, arguments[1]) - return new Buffer(arg) - } - - this.length = 0 - this.parent = undefined - - // Common case. - if (typeof arg === 'number') { - return fromNumber(this, arg) - } - - // Slightly less common case. - if (typeof arg === 'string') { - return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') - } - - // Unusual. - return fromObject(this, arg) - } - - function fromNumber (that, length) { - that = allocate(that, length < 0 ? 0 : checked(length) | 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < length; i++) { - that[i] = 0 - } - } - return that - } - - function fromString (that, string, encoding) { - if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' - - // Assumption: byteLength() return value is always < kMaxLength. - var length = byteLength(string, encoding) | 0 - that = allocate(that, length) - - that.write(string, encoding) - return that - } - - function fromObject (that, object) { - if (Buffer.isBuffer(object)) return fromBuffer(that, object) - - if (isArray(object)) return fromArray(that, object) - - if (object == null) { - throw new TypeError('must start with number, buffer, array or string') - } - - if (typeof ArrayBuffer !== 'undefined' && object.buffer instanceof ArrayBuffer) { - return fromTypedArray(that, object) - } - - if (object.length) return fromArrayLike(that, object) - - return fromJsonObject(that, object) - } - - function fromBuffer (that, buffer) { - var length = checked(buffer.length) | 0 - that = allocate(that, length) - buffer.copy(that, 0, 0, length) - return that - } - - function fromArray (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that - } - - // Duplicate of fromArray() to keep fromArray() monomorphic. - function fromTypedArray (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - // Truncating the elements is probably not what people expect from typed - // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior - // of the old Buffer constructor. - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that - } - - function fromArrayLike (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that - } - - // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. - // Returns a zero-length buffer for inputs that don't conform to the spec. - function fromJsonObject (that, object) { - var array - var length = 0 - - if (object.type === 'Buffer' && isArray(object.data)) { - array = object.data - length = checked(array.length) | 0 - } - that = allocate(that, length) - - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that - } - - function allocate (that, length) { - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = Buffer._augment(new Uint8Array(length)) - } else { - // Fallback: Return an object instance of the Buffer class - that.length = length - that._isBuffer = true - } - - var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 - if (fromPool) that.parent = rootParent - - return that - } - - function checked (length) { - // Note: cannot use `length < kMaxLength` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= kMaxLength) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength.toString(16) + ' bytes') - } - return length | 0 - } - - function SlowBuffer (subject, encoding) { - if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) - - var buf = new Buffer(subject, encoding) - delete buf.parent - return buf - } - - Buffer.isBuffer = function isBuffer (b) { - return !!(b != null && b._isBuffer) - } - - Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - var i = 0 - var len = Math.min(x, y) - while (i < len) { - if (a[i] !== b[i]) break - - ++i - } - - if (i !== len) { - x = a[i] - y = b[i] - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 - } - - Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'raw': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } - } - - Buffer.concat = function concat (list, length) { - if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') - - if (list.length === 0) { - return new Buffer(0) - } else if (list.length === 1) { - return list[0] - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; i++) { - length += list[i].length - } - } - - var buf = new Buffer(length) - var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length - } - return buf - } - - function byteLength (string, encoding) { - if (typeof string !== 'string') string = String(string) - - if (string.length === 0) return 0 - - switch (encoding || 'utf8') { - case 'ascii': - case 'binary': - case 'raw': - return string.length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return string.length * 2 - case 'hex': - return string.length >>> 1 - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length - case 'base64': - return base64ToBytes(string).length - default: - return string.length - } - } - Buffer.byteLength = byteLength - - // pre-set for values that may exist in the future - Buffer.prototype.length = undefined - Buffer.prototype.parent = undefined - - // toString(encoding, start=0, end=buffer.length) - Buffer.prototype.toString = function toString (encoding, start, end) { - var loweredCase = false - - start = start | 0 - end = end === undefined || end === Infinity ? this.length : end | 0 - - if (!encoding) encoding = 'utf8' - if (start < 0) start = 0 - if (end > this.length) end = this.length - if (end <= start) return '' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'binary': - return binarySlice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } - } - - Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 - } - - Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' - } - - Buffer.prototype.compare = function compare (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return 0 - return Buffer.compare(this, b) - } - - Buffer.prototype.indexOf = function indexOf (val, byteOffset) { - if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff - else if (byteOffset < -0x80000000) byteOffset = -0x80000000 - byteOffset >>= 0 - - if (this.length === 0) return -1 - if (byteOffset >= this.length) return -1 - - // Negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) - - if (typeof val === 'string') { - if (val.length === 0) return -1 // special case: looking for empty string always fails - return String.prototype.indexOf.call(this, val, byteOffset) - } - if (Buffer.isBuffer(val)) { - return arrayIndexOf(this, val, byteOffset) - } - if (typeof val === 'number') { - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { - return Uint8Array.prototype.indexOf.call(this, val, byteOffset) - } - return arrayIndexOf(this, [ val ], byteOffset) - } - - function arrayIndexOf (arr, val, byteOffset) { - var foundIndex = -1 - for (var i = 0; byteOffset + i < arr.length; i++) { - if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex - } else { - foundIndex = -1 - } - } - return -1 - } - - throw new TypeError('val must be string, number or Buffer') - } - - // `get` will be removed in Node 0.13+ - Buffer.prototype.get = function get (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) - } - - // `set` will be removed in Node 0.13+ - Buffer.prototype.set = function set (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) - } - - function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - if (strLen % 2 !== 0) throw new Error('Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; i++) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) throw new Error('Invalid hex string') - buf[offset + i] = parsed - } - return i - } - - function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) - } - - function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) - } - - function binaryWrite (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) - } - - function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) - } - - function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) - } - - Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset | 0 - if (isFinite(length)) { - length = length | 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - // legacy write(string, encoding, offset, length) - remove in v0.13 - } else { - var swap = encoding - encoding = offset - offset = length | 0 - length = swap - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'binary': - return binaryWrite(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } - } - - Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } - } - - function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } - } - - function utf8Slice (buf, start, end) { - var res = '' - var tmp = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) - } - } - - return res + decodeUtf8Char(tmp) - } - - function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret - } - - function binarySlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]) - } - return ret - } - - function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; i++) { - out += toHex(buf[i]) - } - return out - } - - function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) - } - return res - } - - Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = Buffer._augment(this.subarray(start, end)) - } else { - var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start] - } - } - - if (newBuf.length) newBuf.parent = this.parent || this - - return newBuf - } - - /* - * Need to make sure that buffer isn't trying to write out of bounds. - */ - function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') - } - - Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val - } - - Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val - } - - Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] - } - - Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) - } - - Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] - } - - Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) - } - - Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) - } - - Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val - } - - Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val - } - - Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) - } - - Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val - } - - Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val - } - - Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) - } - - Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) - } - - Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) - } - - Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) - } - - Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) - } - - Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) - } - - function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') - } - - Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = value - return offset + 1 - } - - function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } - } - - Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 - } - - Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = value - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 - } - - function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } - } - - Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = value - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 - } - - Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = value - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 - } - - Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = value < 0 ? 1 : 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = value < 0 ? 1 : 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength - } - - Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - if (value < 0) value = 0xff + value + 1 - this[offset] = value - return offset + 1 - } - - Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 - } - - Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = value - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 - } - - Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 - } - - Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = value - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 - } - - function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') - if (offset < 0) throw new RangeError('index out of range') - } - - function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 - } - - Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) - } - - Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) - } - - function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 - } - - Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) - } - - Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) - } - - // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) - Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - - if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < len; i++) { - target[i + targetStart] = this[i + start] - } - } else { - target._set(this.subarray(start, start + len), targetStart) - } - - return len - } - - // fill(value, start=0, end=buffer.length) - Buffer.prototype.fill = function fill (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length - - if (end < start) throw new RangeError('end < start') - - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return - - if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') - if (end < 0 || end > this.length) throw new RangeError('end out of bounds') - - var i - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value - } - } else { - var bytes = utf8ToBytes(value.toString()) - var len = bytes.length - for (i = start; i < end; i++) { - this[i] = bytes[i % len] - } - } - - return this - } - - /** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ - Buffer.prototype.toArrayBuffer = function toArrayBuffer () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new TypeError('Buffer.toArrayBuffer not supported in this browser') - } - } - - // HELPER FUNCTIONS - // ================ - - var BP = Buffer.prototype - - /** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ - Buffer._augment = function _augment (arr) { - arr.constructor = Buffer - arr._isBuffer = true - - // save reference to original Uint8Array set method before overwriting - arr._set = arr.set - - // deprecated, will be removed in node 0.13+ - arr.get = BP.get - arr.set = BP.set - - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.equals = BP.equals - arr.compare = BP.compare - arr.indexOf = BP.indexOf - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUIntLE = BP.readUIntLE - arr.readUIntBE = BP.readUIntBE - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readIntLE = BP.readIntLE - arr.readIntBE = BP.readIntBE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUIntLE = BP.writeUIntLE - arr.writeUIntBE = BP.writeUIntBE - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeIntLE = BP.writeIntLE - arr.writeIntBE = BP.writeIntBE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer - - return arr - } - - var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g - - function base64clean (str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str - } - - function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') - } - - function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) - } - - function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - var i = 0 - - for (; i < length; i++) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (leadSurrogate) { - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } else { - // valid surrogate pair - codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 - leadSurrogate = null - } - } else { - // no lead yet - - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else { - // valid lead - leadSurrogate = codePoint - continue - } - } - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = null - } - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x200000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes - } - - function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; i++) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray - } - - function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; i++) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray - } - - function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) - } - - function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i - } - - function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) - -/***/ }, -/* 130 */ +/* 122 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. @@ -13937,17 +13155,17 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Readable; /**/ - var isArray = __webpack_require__(184); + var isArray = __webpack_require__(172); /**/ /**/ - var Buffer = __webpack_require__(129).Buffer; + var Buffer = __webpack_require__(88).Buffer; /**/ Readable.ReadableState = ReadableState; - var EE = __webpack_require__(42).EventEmitter; + var EE = __webpack_require__(41).EventEmitter; /**/ if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { @@ -13955,18 +13173,18 @@ return /******/ (function(modules) { // webpackBootstrap }; /**/ - var Stream = __webpack_require__(127); + var Stream = __webpack_require__(120); /**/ - var util = __webpack_require__(189); - util.inherits = __webpack_require__(46); + var util = __webpack_require__(176); + util.inherits = __webpack_require__(44); /**/ var StringDecoder; /**/ - var debug = __webpack_require__(158); + var debug = __webpack_require__(148); if (debug && debug.debuglog) { debug = debug.debuglog('stream'); } else { @@ -13978,7 +13196,7 @@ return /******/ (function(modules) { // webpackBootstrap util.inherits(Readable, Stream); function ReadableState(options, stream) { - var Duplex = __webpack_require__(132); + var Duplex = __webpack_require__(124); options = options || {}; @@ -14039,14 +13257,14 @@ return /******/ (function(modules) { // webpackBootstrap this.encoding = null; if (options.encoding) { if (!StringDecoder) - StringDecoder = __webpack_require__(185).StringDecoder; + StringDecoder = __webpack_require__(173).StringDecoder; this.decoder = new StringDecoder(options.encoding); this.encoding = options.encoding; } } function Readable(options) { - var Duplex = __webpack_require__(132); + var Duplex = __webpack_require__(124); if (!(this instanceof Readable)) return new Readable(options); @@ -14149,7 +13367,7 @@ return /******/ (function(modules) { // webpackBootstrap // backwards compatibility. Readable.prototype.setEncoding = function(enc) { if (!StringDecoder) - StringDecoder = __webpack_require__(185).StringDecoder; + StringDecoder = __webpack_require__(173).StringDecoder; this._readableState.decoder = new StringDecoder(enc); this._readableState.encoding = enc; return this; @@ -14865,10 +14083,10 @@ return /******/ (function(modules) { // webpackBootstrap return -1; } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 131 */ +/* 123 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. @@ -14899,18 +14117,18 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Writable; /**/ - var Buffer = __webpack_require__(129).Buffer; + var Buffer = __webpack_require__(88).Buffer; /**/ Writable.WritableState = WritableState; /**/ - var util = __webpack_require__(189); - util.inherits = __webpack_require__(46); + var util = __webpack_require__(176); + util.inherits = __webpack_require__(44); /**/ - var Stream = __webpack_require__(127); + var Stream = __webpack_require__(120); util.inherits(Writable, Stream); @@ -14921,7 +14139,7 @@ return /******/ (function(modules) { // webpackBootstrap } function WritableState(options, stream) { - var Duplex = __webpack_require__(132); + var Duplex = __webpack_require__(124); options = options || {}; @@ -15009,7 +14227,7 @@ return /******/ (function(modules) { // webpackBootstrap } function Writable(options) { - var Duplex = __webpack_require__(132); + var Duplex = __webpack_require__(124); // Writable ctor is applied to Duplexes, though they're not // instanceof Writable, they're instanceof Readable. @@ -15349,10 +14567,10 @@ return /******/ (function(modules) { // webpackBootstrap state.ended = true; } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 132 */ +/* 124 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. @@ -15393,12 +14611,12 @@ return /******/ (function(modules) { // webpackBootstrap /**/ - var util = __webpack_require__(189); - util.inherits = __webpack_require__(46); + var util = __webpack_require__(176); + util.inherits = __webpack_require__(44); /**/ - var Readable = __webpack_require__(130); - var Writable = __webpack_require__(131); + var Readable = __webpack_require__(122); + var Writable = __webpack_require__(123); util.inherits(Duplex, Readable); @@ -15445,10 +14663,10 @@ return /******/ (function(modules) { // webpackBootstrap } } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) /***/ }, -/* 133 */ +/* 125 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -15517,11 +14735,11 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = Transform; - var Duplex = __webpack_require__(132); + var Duplex = __webpack_require__(124); /**/ - var util = __webpack_require__(189); - util.inherits = __webpack_require__(46); + var util = __webpack_require__(176); + util.inherits = __webpack_require__(44); /**/ util.inherits(Transform, Duplex); @@ -15663,7 +14881,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 134 */ +/* 126 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -15693,11 +14911,11 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = PassThrough; - var Transform = __webpack_require__(133); + var Transform = __webpack_require__(125); /**/ - var util = __webpack_require__(189); - util.inherits = __webpack_require__(46); + var util = __webpack_require__(176); + util.inherits = __webpack_require__(44); /**/ util.inherits(PassThrough, Transform); @@ -15715,224 +14933,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 135 */ -/***/ function(module, exports, __webpack_require__) { - - var arrayEach = __webpack_require__(102), - baseForOwn = __webpack_require__(105), - baseMergeDeep = __webpack_require__(165), - isArray = __webpack_require__(106), - isLength = __webpack_require__(136), - isObjectLike = __webpack_require__(145), - isTypedArray = __webpack_require__(109); - - /** - * The base implementation of `_.merge` without support for argument juggling, - * multiple sources, and `this` binding `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {Function} [customizer] The function to customize merging properties. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates values with source counterparts. - * @returns {Object} Returns the destination object. - */ - function baseMerge(object, source, customizer, stackA, stackB) { - var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source)); - - (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { - if (isObjectLike(srcValue)) { - stackA || (stackA = []); - stackB || (stackB = []); - return baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB); - } - var value = object[key], - result = customizer ? customizer(value, srcValue, key, object, source) : undefined, - isCommon = typeof result == 'undefined'; - - if (isCommon) { - result = srcValue; - } - if ((isSrcArr || typeof result != 'undefined') && - (isCommon || (result === result ? result !== value : value === value))) { - object[key] = result; - } - }); - return object; - } - - module.exports = baseMerge; - - -/***/ }, -/* 136 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Used as the maximum length of an array-like value. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) - * for more details. - */ - var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; - - /** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is based on ES `ToLength`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength) - * for more details. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - */ - function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - - module.exports = isLength; - - -/***/ }, -/* 137 */ -/***/ function(module, exports, __webpack_require__) { - - var escapeRegExp = __webpack_require__(166), - isObjectLike = __webpack_require__(145); - - /** `Object#toString` result references. */ - var funcTag = '[object Function]'; - - /** Used to detect host constructors (Safari > 5). */ - var reHostCtor = /^\[object .+?Constructor\]$/; - - /** Used for native method references. */ - var objectProto = Object.prototype; - - /** Used to resolve the decompiled source of functions. */ - var fnToString = Function.prototype.toString; - - /** - * Used to resolve the `toStringTag` of values. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) - * for more details. - */ - var objToString = objectProto.toString; - - /** Used to detect if a method is native. */ - var reNative = RegExp('^' + - escapeRegExp(objToString) - .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' - ); - - /** - * Checks if `value` is a native function. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true - * - * _.isNative(_); - * // => false - */ - function isNative(value) { - if (value == null) { - return false; - } - if (objToString.call(value) == funcTag) { - return reNative.test(fnToString.call(value)); - } - return (isObjectLike(value) && reHostCtor.test(value)) || false; - } - - module.exports = isNative; - - -/***/ }, -/* 138 */ -/***/ function(module, exports, __webpack_require__) { - - var isArguments = __webpack_require__(151), - isArray = __webpack_require__(106), - isIndex = __webpack_require__(139), - isLength = __webpack_require__(136), - keysIn = __webpack_require__(167), - support = __webpack_require__(168); - - /** Used for native method references. */ - var objectProto = Object.prototype; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto.hasOwnProperty; - - /** - * A fallback implementation of `Object.keys` which creates an array of the - * own enumerable property names of `object`. - * - * @private - * @param {Object} object The object to inspect. - * @returns {Array} Returns the array of property names. - */ - function shimKeys(object) { - var props = keysIn(object), - propsLength = props.length, - length = propsLength && object.length; - - var allowIndexes = length && isLength(length) && - (isArray(object) || (support.nonEnumArgs && isArguments(object))); - - var index = -1, - result = []; - - while (++index < propsLength) { - var key = props[index]; - if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { - result.push(key); - } - } - return result; - } - - module.exports = shimKeys; - - -/***/ }, -/* 139 */ -/***/ function(module, exports, __webpack_require__) { - - /** - * Used as the maximum length of an array-like value. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) - * for more details. - */ - var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; - - /** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ - function isIndex(value, length) { - value = +value; - length = length == null ? MAX_SAFE_INTEGER : length; - return value > -1 && value % 1 == 0 && value < length; - } - - module.exports = isIndex; - - -/***/ }, -/* 140 */ +/* 127 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. @@ -16460,7 +15461,7 @@ return /******/ (function(modules) { // webpackBootstrap } exports.isPrimitive = isPrimitive; - exports.isBuffer = __webpack_require__(183); + exports.isBuffer = __webpack_require__(174); function objectToString(o) { return Object.prototype.toString.call(o); @@ -16504,7 +15505,7 @@ return /******/ (function(modules) { // webpackBootstrap * prototype. * @param {function} superCtor Constructor function to inherit prototype from. */ - exports.inherits = __webpack_require__(192); + exports.inherits = __webpack_require__(44); exports._extend = function(origin, add) { // Don't do anything if add isn't an object @@ -16522,15 +15523,15 @@ return /******/ (function(modules) { // webpackBootstrap return Object.prototype.hasOwnProperty.call(obj, prop); } - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(11))) + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(10))) /***/ }, -/* 141 */ +/* 128 */ /***/ function(module, exports, __webpack_require__) { - var baseIsMatch = __webpack_require__(169), - isStrictComparable = __webpack_require__(170), - keys = __webpack_require__(100); + var baseIsMatch = __webpack_require__(162), + isStrictComparable = __webpack_require__(163), + keys = __webpack_require__(101); /** Used for native method references. */ var objectProto = Object.prototype; @@ -16576,11 +15577,11 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 142 */ +/* 129 */ /***/ function(module, exports, __webpack_require__) { - var baseIsEqual = __webpack_require__(171), - isStrictComparable = __webpack_require__(170); + var baseIsEqual = __webpack_require__(164), + isStrictComparable = __webpack_require__(163); /** * The base implementation of `_.matchesProperty` which does not coerce `key` @@ -16606,12 +15607,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 143 */ +/* 130 */ /***/ function(module, exports, __webpack_require__) { - var baseSetData = __webpack_require__(172), - isNative = __webpack_require__(137), - support = __webpack_require__(168); + var baseSetData = __webpack_require__(165), + isNative = __webpack_require__(133), + support = __webpack_require__(166); /** Used to detect named functions. */ var reFuncName = /^\s*function[ \n\r\t]+\w/; @@ -16650,10 +15651,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 144 */ +/* 131 */ /***/ function(module, exports, __webpack_require__) { - var toObject = __webpack_require__(152); + var toObject = __webpack_require__(145); /** * The base implementation of `baseForIn` and `baseForOwn` which iterates @@ -16686,7 +15687,97 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 145 */ +/* 132 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Used as the maximum length of an array-like value. + * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) + * for more details. + */ + var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; + + /** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is based on ES `ToLength`. See the + * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength) + * for more details. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + */ + function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + } + + module.exports = isLength; + + +/***/ }, +/* 133 */ +/***/ function(module, exports, __webpack_require__) { + + var escapeRegExp = __webpack_require__(167), + isObjectLike = __webpack_require__(134); + + /** `Object#toString` result references. */ + var funcTag = '[object Function]'; + + /** Used to detect host constructors (Safari > 5). */ + var reHostCtor = /^\[object .+?Constructor\]$/; + + /** Used for native method references. */ + var objectProto = Object.prototype; + + /** Used to resolve the decompiled source of functions. */ + var fnToString = Function.prototype.toString; + + /** + * Used to resolve the `toStringTag` of values. + * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) + * for more details. + */ + var objToString = objectProto.toString; + + /** Used to detect if a method is native. */ + var reNative = RegExp('^' + + escapeRegExp(objToString) + .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + ); + + /** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ + function isNative(value) { + if (value == null) { + return false; + } + if (objToString.call(value) == funcTag) { + return reNative.test(fnToString.call(value)); + } + return (isObjectLike(value) && reHostCtor.test(value)) || false; + } + + module.exports = isNative; + + +/***/ }, +/* 134 */ /***/ function(module, exports, __webpack_require__) { /** @@ -16704,11 +15795,87 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 146 */ +/* 135 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {var constant = __webpack_require__(173), - isNative = __webpack_require__(137); + var isArguments = __webpack_require__(144), + isArray = __webpack_require__(95), + isIndex = __webpack_require__(136), + isLength = __webpack_require__(132), + keysIn = __webpack_require__(168), + support = __webpack_require__(166); + + /** Used for native method references. */ + var objectProto = Object.prototype; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** + * A fallback implementation of `Object.keys` which creates an array of the + * own enumerable property names of `object`. + * + * @private + * @param {Object} object The object to inspect. + * @returns {Array} Returns the array of property names. + */ + function shimKeys(object) { + var props = keysIn(object), + propsLength = props.length, + length = propsLength && object.length; + + var allowIndexes = length && isLength(length) && + (isArray(object) || (support.nonEnumArgs && isArguments(object))); + + var index = -1, + result = []; + + while (++index < propsLength) { + var key = props[index]; + if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { + result.push(key); + } + } + return result; + } + + module.exports = shimKeys; + + +/***/ }, +/* 136 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Used as the maximum length of an array-like value. + * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) + * for more details. + */ + var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; + + /** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ + function isIndex(value, length) { + value = +value; + length = length == null ? MAX_SAFE_INTEGER : length; + return value > -1 && value % 1 == 0 && value < length; + } + + module.exports = isIndex; + + +/***/ }, +/* 137 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {var constant = __webpack_require__(169), + isNative = __webpack_require__(133); /** Native method references. */ var ArrayBuffer = isNative(ArrayBuffer = global.ArrayBuffer) && ArrayBuffer, @@ -16766,7 +15933,136 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 147 */ +/* 138 */ +/***/ function(module, exports, __webpack_require__) { + + exports.read = function(buffer, offset, isLE, mLen, nBytes) { + var e, m, + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + nBits = -7, + i = isLE ? (nBytes - 1) : 0, + d = isLE ? -1 : 1, + s = buffer[offset + i]; + + i += d; + + e = s & ((1 << (-nBits)) - 1); + s >>= (-nBits); + nBits += eLen; + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); + + m = e & ((1 << (-nBits)) - 1); + e >>= (-nBits); + nBits += mLen; + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); + + if (e === 0) { + e = 1 - eBias; + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity); + } else { + m = m + Math.pow(2, mLen); + e = e - eBias; + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen); + }; + + exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c, + eLen = nBytes * 8 - mLen - 1, + eMax = (1 << eLen) - 1, + eBias = eMax >> 1, + rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), + i = isLE ? 0 : (nBytes - 1), + d = isLE ? 1 : -1, + s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; + + value = Math.abs(value); + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0; + e = eMax; + } else { + e = Math.floor(Math.log(value) / Math.LN2); + if (value * (c = Math.pow(2, -e)) < 1) { + e--; + c *= 2; + } + if (e + eBias >= 1) { + value += rt / c; + } else { + value += rt * Math.pow(2, 1 - eBias); + } + if (value * c >= 2) { + e++; + c /= 2; + } + + if (e + eBias >= eMax) { + m = 0; + e = eMax; + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen); + e = e + eBias; + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); + e = 0; + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); + + e = (e << mLen) | m; + eLen += mLen; + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); + + buffer[offset + i - d] |= s * 128; + }; + + +/***/ }, +/* 139 */ +/***/ function(module, exports, __webpack_require__) { + + + /** + * isArray + */ + + var isArray = Array.isArray; + + /** + * toString + */ + + var str = Object.prototype.toString; + + /** + * Whether or not the given `val` + * is an array. + * + * example: + * + * isArray([]); + * // > true + * isArray(arguments); + * // > false + * isArray(''); + * // > false + * + * @param {mixed} val + * @return {bool} + */ + + module.exports = isArray || function (val) { + return !! val && '[object Array]' == str.call(val); + }; + + +/***/ }, +/* 140 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -16852,7 +16148,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 148 */ +/* 141 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -16922,7 +16218,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 149 */ +/* 142 */ /***/ function(module, exports, __webpack_require__) { /** @@ -16949,10 +16245,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 150 */ +/* 143 */ /***/ function(module, exports, __webpack_require__) { - var baseEach = __webpack_require__(182); + var baseEach = __webpack_require__(170); /** * The base implementation of `_.map` without support for callback shorthands @@ -16975,11 +16271,11 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 151 */ +/* 144 */ /***/ function(module, exports, __webpack_require__) { - var isLength = __webpack_require__(136), - isObjectLike = __webpack_require__(145); + var isLength = __webpack_require__(132), + isObjectLike = __webpack_require__(134); /** `Object#toString` result references. */ var argsTag = '[object Arguments]'; @@ -17019,10 +16315,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 152 */ +/* 145 */ /***/ function(module, exports, __webpack_require__) { - var isObject = __webpack_require__(108); + var isObject = __webpack_require__(97); /** * Converts `value` to an object if it is not one. @@ -17039,11 +16335,11 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 153 */ +/* 146 */ /***/ function(module, exports, __webpack_require__) { - var baseFor = __webpack_require__(144), - keysIn = __webpack_require__(167); + var baseFor = __webpack_require__(131), + keysIn = __webpack_require__(168); /** * The base implementation of `_.forIn` without support for callback @@ -17062,625 +16358,194 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 154 */ +/* 147 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global, Buffer) {(function() { - var g = ('undefined' === typeof window ? global : window) || {} - _crypto = ( - g.crypto || g.msCrypto || __webpack_require__(179) - ) - module.exports = function(size) { - // Modern Browsers - if(_crypto.getRandomValues) { - var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array - /* This will not work in older browsers. - * See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues - */ - - _crypto.getRandomValues(bytes); - return bytes; + var arrayEach = __webpack_require__(91), + baseForOwn = __webpack_require__(94), + baseMergeDeep = __webpack_require__(171), + isArray = __webpack_require__(95), + isLength = __webpack_require__(132), + isObjectLike = __webpack_require__(134), + isTypedArray = __webpack_require__(98); + + /** + * The base implementation of `_.merge` without support for argument juggling, + * multiple sources, and `this` binding `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {Function} [customizer] The function to customize merging properties. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates values with source counterparts. + * @returns {Object} Returns the destination object. + */ + function baseMerge(object, source, customizer, stackA, stackB) { + var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source)); + + (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { + if (isObjectLike(srcValue)) { + stackA || (stackA = []); + stackB || (stackB = []); + return baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB); } - else if (_crypto.randomBytes) { - return _crypto.randomBytes(size) + var value = object[key], + result = customizer ? customizer(value, srcValue, key, object, source) : undefined, + isCommon = typeof result == 'undefined'; + + if (isCommon) { + result = srcValue; } - else - throw new Error( - 'secure random number generation not supported by this browser\n'+ - 'use chrome, FireFox or Internet Explorer 11' - ) - } - }()) - - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(129).Buffer)) - -/***/ }, -/* 155 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(200) - - var md5 = toConstructor(__webpack_require__(187)) - var rmd160 = toConstructor(__webpack_require__(202)) - - function toConstructor (fn) { - return function () { - var buffers = [] - var m= { - update: function (data, enc) { - if(!Buffer.isBuffer(data)) data = new Buffer(data, enc) - buffers.push(data) - return this - }, - digest: function (enc) { - var buf = Buffer.concat(buffers) - var r = fn(buf) - buffers = null - return enc ? r.toString(enc) : r - } + if ((isSrcArr || typeof result != 'undefined') && + (isCommon || (result === result ? result !== value : value === value))) { + object[key] = result; } - return m - } + }); + return object; } - module.exports = function (alg) { - if('md5' === alg) return new md5() - if('rmd160' === alg) return new rmd160() - return createHash(alg) - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) - -/***/ }, -/* 156 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(155) - - var zeroBuffer = new Buffer(128) - zeroBuffer.fill(0) - - module.exports = Hmac - - function Hmac (alg, key) { - if(!(this instanceof Hmac)) return new Hmac(alg, key) - this._opad = opad - this._alg = alg - - var blocksize = (alg === 'sha512') ? 128 : 64 - - key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key - - if(key.length > blocksize) { - key = createHash(alg).update(key).digest() - } else if(key.length < blocksize) { - key = Buffer.concat([key, zeroBuffer], blocksize) - } - - var ipad = this._ipad = new Buffer(blocksize) - var opad = this._opad = new Buffer(blocksize) - - for(var i = 0; i < blocksize; i++) { - ipad[i] = key[i] ^ 0x36 - opad[i] = key[i] ^ 0x5C - } - - this._hash = createHash(alg).update(ipad) - } - - Hmac.prototype.update = function (data, enc) { - this._hash.update(data, enc) - return this - } - - Hmac.prototype.digest = function (enc) { - var h = this._hash.digest() - return createHash(this._alg).update(this._opad).update(h).digest(enc) - } - - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) - -/***/ }, -/* 157 */ -/***/ function(module, exports, __webpack_require__) { - - var pbkdf2Export = __webpack_require__(201) - - module.exports = function (crypto, exports) { - exports = exports || {} - - var exported = pbkdf2Export(crypto) - - exports.pbkdf2 = exported.pbkdf2 - exports.pbkdf2Sync = exported.pbkdf2Sync - - return exports - } + module.exports = baseMerge; /***/ }, -/* 158 */ +/* 148 */ /***/ function(module, exports, __webpack_require__) { /* (ignored) */ /***/ }, -/* 159 */ +/* 149 */ /***/ function(module, exports, __webpack_require__) { - /** - * Copyright (c) 2013 Petka Antonov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions:

- * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - "use strict"; - function Deque(capacity) { - this._capacity = getCapacity(capacity); - this._length = 0; - this._front = 0; - if (isArray(capacity)) { - var len = capacity.length; - for (var i = 0; i < len; ++i) { - this[i] = capacity[i]; - } - this._length = len; - } - } + var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - Deque.prototype.toArray = function Deque$toArray() { - var len = this._length; - var ret = new Array(len); - var front = this._front; - var capacity = this._capacity; - for (var j = 0; j < len; ++j) { - ret[j] = this[(front + j) & (capacity - 1)]; - } - return ret; - }; + ;(function (exports) { + 'use strict'; - Deque.prototype.push = function Deque$push(item) { - var argsLength = arguments.length; - var length = this._length; - if (argsLength > 1) { - var capacity = this._capacity; - if (length + argsLength > capacity) { - for (var i = 0; i < argsLength; ++i) { - this._checkCapacity(length + 1); - var j = (this._front + length) & (this._capacity - 1); - this[j] = arguments[i]; - length++; - this._length = length; - } - return length; - } - else { - var j = this._front; - for (var i = 0; i < argsLength; ++i) { - this[(j + length) & (capacity - 1)] = arguments[i]; - j++; - } - this._length = length + argsLength; - return length + argsLength; - } + var Arr = (typeof Uint8Array !== 'undefined') + ? Uint8Array + : Array - } + var PLUS = '+'.charCodeAt(0) + var SLASH = '/'.charCodeAt(0) + var NUMBER = '0'.charCodeAt(0) + var LOWER = 'a'.charCodeAt(0) + var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) - if (argsLength === 0) return length; + function decode (elt) { + var code = elt.charCodeAt(0) + if (code === PLUS || + code === PLUS_URL_SAFE) + return 62 // '+' + if (code === SLASH || + code === SLASH_URL_SAFE) + return 63 // '/' + if (code < NUMBER) + return -1 //no match + if (code < NUMBER + 10) + return code - NUMBER + 26 + 26 + if (code < UPPER + 26) + return code - UPPER + if (code < LOWER + 26) + return code - LOWER + 26 + } - this._checkCapacity(length + 1); - var i = (this._front + length) & (this._capacity - 1); - this[i] = item; - this._length = length + 1; - return length + 1; - }; + function b64ToByteArray (b64) { + var i, j, l, tmp, placeHolders, arr - Deque.prototype.pop = function Deque$pop() { - var length = this._length; - if (length === 0) { - return void 0; - } - var i = (this._front + length - 1) & (this._capacity - 1); - var ret = this[i]; - this[i] = void 0; - this._length = length - 1; - return ret; - }; + if (b64.length % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } - Deque.prototype.shift = function Deque$shift() { - var length = this._length; - if (length === 0) { - return void 0; - } - var front = this._front; - var ret = this[front]; - this[front] = void 0; - this._front = (front + 1) & (this._capacity - 1); - this._length = length - 1; - return ret; - }; + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + var len = b64.length + placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - Deque.prototype.unshift = function Deque$unshift(item) { - var length = this._length; - var argsLength = arguments.length; + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(b64.length * 3 / 4 - placeHolders) + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? b64.length - 4 : b64.length - if (argsLength > 1) { - var capacity = this._capacity; - if (length + argsLength > capacity) { - for (var i = argsLength - 1; i >= 0; i--) { - this._checkCapacity(length + 1); - var capacity = this._capacity; - var j = (((( this._front - 1 ) & - ( capacity - 1) ) ^ capacity ) - capacity ); - this[j] = arguments[i]; - length++; - this._length = length; - this._front = j; - } - return length; - } - else { - var front = this._front; - for (var i = argsLength - 1; i >= 0; i--) { - var j = (((( front - 1 ) & - ( capacity - 1) ) ^ capacity ) - capacity ); - this[j] = arguments[i]; - front = j; - } - this._front = front; - this._length = length + argsLength; - return length + argsLength; - } - } + var L = 0 - if (argsLength === 0) return length; + function push (v) { + arr[L++] = v + } - this._checkCapacity(length + 1); - var capacity = this._capacity; - var i = (((( this._front - 1 ) & - ( capacity - 1) ) ^ capacity ) - capacity ); - this[i] = item; - this._length = length + 1; - this._front = i; - return length + 1; - }; + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) + push((tmp & 0xFF0000) >> 16) + push((tmp & 0xFF00) >> 8) + push(tmp & 0xFF) + } - Deque.prototype.peekBack = function Deque$peekBack() { - var length = this._length; - if (length === 0) { - return void 0; - } - var index = (this._front + length - 1) & (this._capacity - 1); - return this[index]; - }; + if (placeHolders === 2) { + tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) + push(tmp & 0xFF) + } else if (placeHolders === 1) { + tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) + push((tmp >> 8) & 0xFF) + push(tmp & 0xFF) + } - Deque.prototype.peekFront = function Deque$peekFront() { - if (this._length === 0) { - return void 0; - } - return this[this._front]; - }; + return arr + } - Deque.prototype.get = function Deque$get(index) { - var i = index; - if ((i !== (i | 0))) { - return void 0; - } - var len = this._length; - if (i < 0) { - i = i + len; - } - if (i < 0 || i >= len) { - return void 0; - } - return this[(this._front + i) & (this._capacity - 1)]; - }; + function uint8ToBase64 (uint8) { + var i, + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes + output = "", + temp, length - Deque.prototype.isEmpty = function Deque$isEmpty() { - return this._length === 0; - }; + function encode (num) { + return lookup.charAt(num) + } - Deque.prototype.clear = function Deque$clear() { - var len = this._length; - var front = this._front; - var capacity = this._capacity; - for (var j = 0; j < len; ++j) { - this[(front + j) & (capacity - 1)] = void 0; - } - this._length = 0; - this._front = 0; - }; + function tripletToBase64 (num) { + return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) + } - Deque.prototype.toString = function Deque$toString() { - return this.toArray().toString(); - }; + // go through the array every three bytes, we'll deal with trailing stuff later + for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { + temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output += tripletToBase64(temp) + } - Deque.prototype.valueOf = Deque.prototype.toString; - Deque.prototype.removeFront = Deque.prototype.shift; - Deque.prototype.removeBack = Deque.prototype.pop; - Deque.prototype.insertFront = Deque.prototype.unshift; - Deque.prototype.insertBack = Deque.prototype.push; - Deque.prototype.enqueue = Deque.prototype.push; - Deque.prototype.dequeue = Deque.prototype.shift; - Deque.prototype.toJSON = Deque.prototype.toArray; + // pad the end with zeros, but make sure to not forget the extra bytes + switch (extraBytes) { + case 1: + temp = uint8[uint8.length - 1] + output += encode(temp >> 2) + output += encode((temp << 4) & 0x3F) + output += '==' + break + case 2: + temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) + output += encode(temp >> 10) + output += encode((temp >> 4) & 0x3F) + output += encode((temp << 2) & 0x3F) + output += '=' + break + } - Object.defineProperty(Deque.prototype, "length", { - get: function() { - return this._length; - }, - set: function() { - throw new RangeError(""); - } - }); + return output + } - Deque.prototype._checkCapacity = function Deque$_checkCapacity(size) { - if (this._capacity < size) { - this._resizeTo(getCapacity(this._capacity * 1.5 + 16)); - } - }; - - Deque.prototype._resizeTo = function Deque$_resizeTo(capacity) { - var oldCapacity = this._capacity; - this._capacity = capacity; - var front = this._front; - var length = this._length; - if (front + length > oldCapacity) { - var moveItemsCount = (front + length) & (oldCapacity - 1); - arrayMove(this, 0, this, oldCapacity, moveItemsCount); - } - }; - - - var isArray = Array.isArray; - - function arrayMove(src, srcIndex, dst, dstIndex, len) { - for (var j = 0; j < len; ++j) { - dst[j + dstIndex] = src[j + srcIndex]; - src[j + srcIndex] = void 0; - } - } - - function pow2AtLeast(n) { - n = n >>> 0; - n = n - 1; - n = n | (n >> 1); - n = n | (n >> 2); - n = n | (n >> 4); - n = n | (n >> 8); - n = n | (n >> 16); - return n + 1; - } - - function getCapacity(capacity) { - if (typeof capacity !== "number") { - if (isArray(capacity)) { - capacity = capacity.length; - } - else { - return 16; - } - } - return pow2AtLeast( - Math.min( - Math.max(16, capacity), 1073741824) - ); - } - - module.exports = Deque; + exports.toByteArray = b64ToByteArray + exports.fromByteArray = uint8ToBase64 + }(false ? (this.base64js = {}) : exports)) /***/ }, -/* 160 */ -/***/ function(module, exports, __webpack_require__) { - - var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** - * HashMap - HashMap Class for JavaScript - * @author Ariel Flesler - * @version 2.0.3 - * Homepage: https://github.com/flesler/hashmap - */ - - (function(factory) { - if (true) { - // AMD. Register as an anonymous module. - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (typeof module === 'object') { - // Node js environment - var HashMap = module.exports = factory(); - // Keep it backwards compatible - HashMap.HashMap = HashMap; - } else { - // Browser globals (this is window) - this.HashMap = factory(); - } - }(function() { - - function HashMap(other) { - this.clear(); - switch (arguments.length) { - case 0: break; - case 1: this.copy(other); break; - default: multi(this, arguments); break; - } - } - - var proto = HashMap.prototype = { - constructor:HashMap, - - get:function(key) { - var data = this._data[this.hash(key)]; - return data && data[1]; - }, - - set:function(key, value) { - // Store original key as well (for iteration) - this._data[this.hash(key)] = [key, value]; - }, - - multi:function() { - multi(this, arguments); - }, - - copy:function(other) { - for (var key in other._data) { - this._data[key] = other._data[key]; - } - }, - - has:function(key) { - return this.hash(key) in this._data; - }, - - search:function(value) { - for (var key in this._data) { - if (this._data[key][1] === value) { - return this._data[key][0]; - } - } - - return null; - }, - - remove:function(key) { - delete this._data[this.hash(key)]; - }, - - type:function(key) { - var str = Object.prototype.toString.call(key); - var type = str.slice(8, -1).toLowerCase(); - // Some browsers yield DOMWindow for null and undefined, works fine on Node - if (type === 'domwindow' && !key) { - return key + ''; - } - return type; - }, - - keys:function() { - var keys = []; - this.forEach(function(value, key) { keys.push(key); }); - return keys; - }, - - values:function() { - var values = []; - this.forEach(function(value) { values.push(value); }); - return values; - }, - - count:function() { - return this.keys().length; - }, - - clear:function() { - // TODO: Would Object.create(null) make any difference - this._data = {}; - }, - - clone:function() { - return new HashMap(this); - }, - - hash:function(key) { - switch (this.type(key)) { - case 'undefined': - case 'null': - case 'boolean': - case 'number': - case 'regexp': - return key + ''; - - case 'date': - return '♣' + key.getTime(); - - case 'string': - return '♠' + key; - - case 'array': - var hashes = []; - for (var i = 0; i < key.length; i++) { - hashes[i] = this.hash(key[i]); - } - return '♥' + hashes.join('⁞'); - - default: - // TODO: Don't use expandos when Object.defineProperty is not available? - if (!key._hmuid_) { - key._hmuid_ = ++HashMap.uid; - hide(key, '_hmuid_'); - } - - return '♦' + key._hmuid_; - } - }, - - forEach:function(func, ctx) { - for (var key in this._data) { - var data = this._data[key]; - func.call(ctx || this, data[1], data[0]); - } - } - }; - - HashMap.uid = 0; - - //- Automatically add chaining to some methods - - for (var method in proto) { - // Skip constructor, valueOf, toString and any other built-in method - if (method === 'constructor' || !proto.hasOwnProperty(method)) { - continue; - } - var fn = proto[method]; - if (fn.toString().indexOf('return ') === -1) { - proto[method] = chain(fn); - } - } - - //- Utils - - function multi(map, args) { - for (var i = 0; i < args.length; i += 2) { - map.set(args[i], args[i+1]); - } - } - - function chain(fn) { - return function() { - fn.apply(this, arguments); - return this; - }; - } - - function hide(obj, prop) { - // Make non iterable if supported - if (Object.defineProperty) { - Object.defineProperty(obj, prop, {enumerable:false}); - } - } - - return HashMap; - })); - - -/***/ }, -/* 161 */ +/* 150 */ /***/ function(module, exports, __webpack_require__) { /** @@ -17809,7 +16674,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 162 */ +/* 151 */ /***/ function(module, exports, __webpack_require__) { module.exports = function(module) { @@ -17825,7 +16690,173 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 163 */ +/* 152 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(123) + + +/***/ }, +/* 153 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(124) + + +/***/ }, +/* 154 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(125) + + +/***/ }, +/* 155 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(126) + + +/***/ }, +/* 156 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global, Buffer) {(function() { + var g = ('undefined' === typeof window ? global : window) || {} + _crypto = ( + g.crypto || g.msCrypto || __webpack_require__(175) + ) + module.exports = function(size) { + // Modern Browsers + if(_crypto.getRandomValues) { + var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array + /* This will not work in older browsers. + * See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues + */ + + _crypto.getRandomValues(bytes); + return bytes; + } + else if (_crypto.randomBytes) { + return _crypto.randomBytes(size) + } + else + throw new Error( + 'secure random number generation not supported by this browser\n'+ + 'use chrome, FireFox or Internet Explorer 11' + ) + } + }()) + + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(88).Buffer)) + +/***/ }, +/* 157 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(182) + + var md5 = toConstructor(__webpack_require__(177)) + var rmd160 = toConstructor(__webpack_require__(184)) + + function toConstructor (fn) { + return function () { + var buffers = [] + var m= { + update: function (data, enc) { + if(!Buffer.isBuffer(data)) data = new Buffer(data, enc) + buffers.push(data) + return this + }, + digest: function (enc) { + var buf = Buffer.concat(buffers) + var r = fn(buf) + buffers = null + return enc ? r.toString(enc) : r + } + } + return m + } + } + + module.exports = function (alg) { + if('md5' === alg) return new md5() + if('rmd160' === alg) return new rmd160() + return createHash(alg) + } + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) + +/***/ }, +/* 158 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {var createHash = __webpack_require__(157) + + var zeroBuffer = new Buffer(128) + zeroBuffer.fill(0) + + module.exports = Hmac + + function Hmac (alg, key) { + if(!(this instanceof Hmac)) return new Hmac(alg, key) + this._opad = opad + this._alg = alg + + var blocksize = (alg === 'sha512') ? 128 : 64 + + key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key + + if(key.length > blocksize) { + key = createHash(alg).update(key).digest() + } else if(key.length < blocksize) { + key = Buffer.concat([key, zeroBuffer], blocksize) + } + + var ipad = this._ipad = new Buffer(blocksize) + var opad = this._opad = new Buffer(blocksize) + + for(var i = 0; i < blocksize; i++) { + ipad[i] = key[i] ^ 0x36 + opad[i] = key[i] ^ 0x5C + } + + this._hash = createHash(alg).update(ipad) + } + + Hmac.prototype.update = function (data, enc) { + this._hash.update(data, enc) + return this + } + + Hmac.prototype.digest = function (enc) { + var h = this._hash.digest() + return createHash(this._alg).update(this._opad).update(h).digest(enc) + } + + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) + +/***/ }, +/* 159 */ +/***/ function(module, exports, __webpack_require__) { + + var pbkdf2Export = __webpack_require__(183) + + module.exports = function (crypto, exports) { + exports = exports || {} + + var exported = pbkdf2Export(crypto) + + exports.pbkdf2 = exported.pbkdf2 + exports.pbkdf2Sync = exported.pbkdf2Sync + + return exports + } + + +/***/ }, +/* 160 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -17835,7 +16866,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 164 */ +/* 161 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -17845,126 +16876,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 165 */ +/* 162 */ /***/ function(module, exports, __webpack_require__) { - var arrayCopy = __webpack_require__(110), - isArguments = __webpack_require__(151), - isArray = __webpack_require__(106), - isLength = __webpack_require__(136), - isPlainObject = __webpack_require__(190), - isTypedArray = __webpack_require__(109), - toPlainObject = __webpack_require__(191); - - /** - * A specialized version of `baseMerge` for arrays and objects which performs - * deep merges and tracks traversed objects enabling objects with circular - * references to be merged. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {string} key The key of the value to merge. - * @param {Function} mergeFunc The function to merge values. - * @param {Function} [customizer] The function to customize merging properties. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates values with source counterparts. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ - function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) { - var length = stackA.length, - srcValue = source[key]; - - while (length--) { - if (stackA[length] == srcValue) { - object[key] = stackB[length]; - return; - } - } - var value = object[key], - result = customizer ? customizer(value, srcValue, key, object, source) : undefined, - isCommon = typeof result == 'undefined'; - - if (isCommon) { - result = srcValue; - if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) { - result = isArray(value) - ? value - : (value ? arrayCopy(value) : []); - } - else if (isPlainObject(srcValue) || isArguments(srcValue)) { - result = isArguments(value) - ? toPlainObject(value) - : (isPlainObject(value) ? value : {}); - } - else { - isCommon = false; - } - } - // Add the source value to the stack of traversed objects and associate - // it with its merged value. - stackA.push(srcValue); - stackB.push(result); - - if (isCommon) { - // Recursively merge objects and arrays (susceptible to call stack limits). - object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB); - } else if (result === result ? result !== value : value === value) { - object[key] = result; - } - } - - module.exports = baseMergeDeep; - - -/***/ }, -/* 166 */ -/***/ function(module, exports, __webpack_require__) { - - var baseToString = __webpack_require__(90); - - /** - * Used to match `RegExp` special characters. - * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special) - * for more details. - */ - var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, - reHasRegExpChars = RegExp(reRegExpChars.source); - - /** - * Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", - * "+", "(", ")", "[", "]", "{" and "}" in `string`. - * - * @static - * @memberOf _ - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. - * @example - * - * _.escapeRegExp('[lodash](https://lodash.com/)'); - * // => '\[lodash\]\(https://lodash\.com/\)' - */ - function escapeRegExp(string) { - string = baseToString(string); - return (string && reHasRegExpChars.test(string)) - ? string.replace(reRegExpChars, '\\$&') - : string; - } - - module.exports = escapeRegExp; - - -/***/ }, -/* 167 */ -/***/ function(module, exports, __webpack_require__) { - - var isArguments = __webpack_require__(151), - isArray = __webpack_require__(106), - isIndex = __webpack_require__(139), - isLength = __webpack_require__(136), - isObject = __webpack_require__(108), - support = __webpack_require__(168); + var baseIsEqual = __webpack_require__(164); /** Used for native method references. */ var objectProto = Object.prototype; @@ -17973,64 +16888,146 @@ return /******/ (function(modules) { // webpackBootstrap var hasOwnProperty = objectProto.hasOwnProperty; /** - * Creates an array of the own and inherited enumerable property names of `object`. + * The base implementation of `_.isMatch` without support for callback + * shorthands or `this` binding. * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @category Object + * @private * @param {Object} object The object to inspect. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + * @param {Array} props The source property names to match. + * @param {Array} values The source values to match. + * @param {Array} strictCompareFlags Strict comparison flags for source values. + * @param {Function} [customizer] The function to customize comparing objects. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ - function keysIn(object) { + function baseIsMatch(object, props, values, strictCompareFlags, customizer) { + var length = props.length; if (object == null) { - return []; + return !length; } - if (!isObject(object)) { - object = Object(object); - } - var length = object.length; - length = (length && isLength(length) && - (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0; - - var Ctor = object.constructor, - index = -1, - isProto = typeof Ctor == 'function' && Ctor.prototype === object, - result = Array(length), - skipIndexes = length > 0; + var index = -1, + noCustomizer = !customizer; while (++index < length) { - result[index] = (index + ''); - } - for (var key in object) { - if (!(skipIndexes && isIndex(key, length)) && - !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); + if ((noCustomizer && strictCompareFlags[index]) + ? values[index] !== object[props[index]] + : !hasOwnProperty.call(object, props[index]) + ) { + return false; } } - return result; + index = -1; + while (++index < length) { + var key = props[index]; + if (noCustomizer && strictCompareFlags[index]) { + var result = hasOwnProperty.call(object, key); + } else { + var objValue = object[key], + srcValue = values[index]; + + result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (typeof result == 'undefined') { + result = baseIsEqual(srcValue, objValue, customizer, true); + } + } + if (!result) { + return false; + } + } + return true; } - module.exports = keysIn; + module.exports = baseIsMatch; /***/ }, -/* 168 */ +/* 163 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {var isNative = __webpack_require__(137); + var isObject = __webpack_require__(97); + + /** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ + function isStrictComparable(value) { + return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value)); + } + + module.exports = isStrictComparable; + + +/***/ }, +/* 164 */ +/***/ function(module, exports, __webpack_require__) { + + var baseIsEqualDeep = __webpack_require__(178); + + /** + * The base implementation of `_.isEqual` without support for `this` binding + * `customizer` functions. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isWhere] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ + function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) { + // Exit early for identical values. + if (value === other) { + // Treat `+0` vs. `-0` as not equal. + return value !== 0 || (1 / value == 1 / other); + } + var valType = typeof value, + othType = typeof other; + + // Exit early for unlike primitive values. + if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') || + value == null || other == null) { + // Return `false` unless both values are `NaN`. + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB); + } + + module.exports = baseIsEqual; + + +/***/ }, +/* 165 */ +/***/ function(module, exports, __webpack_require__) { + + var identity = __webpack_require__(107), + metaMap = __webpack_require__(179); + + /** + * The base implementation of `setData` without support for hot loop detection. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; + }; + + module.exports = baseSetData; + + +/***/ }, +/* 166 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {var isNative = __webpack_require__(133); /** Used to detect functions containing a `this` reference. */ var reThis = /\bthis\b/; @@ -18109,10 +17106,53 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 169 */ +/* 167 */ /***/ function(module, exports, __webpack_require__) { - var baseIsEqual = __webpack_require__(171); + var baseToString = __webpack_require__(59); + + /** + * Used to match `RegExp` special characters. + * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special) + * for more details. + */ + var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, + reHasRegExpChars = RegExp(reRegExpChars.source); + + /** + * Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", + * "+", "(", ")", "[", "]", "{" and "}" in `string`. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example + * + * _.escapeRegExp('[lodash](https://lodash.com/)'); + * // => '\[lodash\]\(https://lodash\.com/\)' + */ + function escapeRegExp(string) { + string = baseToString(string); + return (string && reHasRegExpChars.test(string)) + ? string.replace(reRegExpChars, '\\$&') + : string; + } + + module.exports = escapeRegExp; + + +/***/ }, +/* 168 */ +/***/ function(module, exports, __webpack_require__) { + + var isArguments = __webpack_require__(144), + isArray = __webpack_require__(95), + isIndex = __webpack_require__(136), + isLength = __webpack_require__(132), + isObject = __webpack_require__(97), + support = __webpack_require__(166); /** Used for native method references. */ var objectProto = Object.prototype; @@ -18121,143 +17161,61 @@ return /******/ (function(modules) { // webpackBootstrap var hasOwnProperty = objectProto.hasOwnProperty; /** - * The base implementation of `_.isMatch` without support for callback - * shorthands or `this` binding. + * Creates an array of the own and inherited enumerable property names of `object`. * - * @private + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @category Object * @param {Object} object The object to inspect. - * @param {Array} props The source property names to match. - * @param {Array} values The source values to match. - * @param {Array} strictCompareFlags Strict comparison flags for source values. - * @param {Function} [customizer] The function to customize comparing objects. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ - function baseIsMatch(object, props, values, strictCompareFlags, customizer) { - var length = props.length; + function keysIn(object) { if (object == null) { - return !length; + return []; } - var index = -1, - noCustomizer = !customizer; + if (!isObject(object)) { + object = Object(object); + } + var length = object.length; + length = (length && isLength(length) && + (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0; + + var Ctor = object.constructor, + index = -1, + isProto = typeof Ctor == 'function' && Ctor.prototype === object, + result = Array(length), + skipIndexes = length > 0; while (++index < length) { - if ((noCustomizer && strictCompareFlags[index]) - ? values[index] !== object[props[index]] - : !hasOwnProperty.call(object, props[index]) - ) { - return false; + result[index] = (index + ''); + } + for (var key in object) { + if (!(skipIndexes && isIndex(key, length)) && + !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); } } - index = -1; - while (++index < length) { - var key = props[index]; - if (noCustomizer && strictCompareFlags[index]) { - var result = hasOwnProperty.call(object, key); - } else { - var objValue = object[key], - srcValue = values[index]; - - result = customizer ? customizer(objValue, srcValue, key) : undefined; - if (typeof result == 'undefined') { - result = baseIsEqual(srcValue, objValue, customizer, true); - } - } - if (!result) { - return false; - } - } - return true; + return result; } - module.exports = baseIsMatch; + module.exports = keysIn; /***/ }, -/* 170 */ -/***/ function(module, exports, __webpack_require__) { - - var isObject = __webpack_require__(108); - - /** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ - function isStrictComparable(value) { - return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value)); - } - - module.exports = isStrictComparable; - - -/***/ }, -/* 171 */ -/***/ function(module, exports, __webpack_require__) { - - var baseIsEqualDeep = __webpack_require__(193); - - /** - * The base implementation of `_.isEqual` without support for `this` binding - * `customizer` functions. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparing values. - * @param {boolean} [isWhere] Specify performing partial comparisons. - * @param {Array} [stackA] Tracks traversed `value` objects. - * @param {Array} [stackB] Tracks traversed `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ - function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) { - // Exit early for identical values. - if (value === other) { - // Treat `+0` vs. `-0` as not equal. - return value !== 0 || (1 / value == 1 / other); - } - var valType = typeof value, - othType = typeof other; - - // Exit early for unlike primitive values. - if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') || - value == null || other == null) { - // Return `false` unless both values are `NaN`. - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB); - } - - module.exports = baseIsEqual; - - -/***/ }, -/* 172 */ -/***/ function(module, exports, __webpack_require__) { - - var identity = __webpack_require__(114), - metaMap = __webpack_require__(194); - - /** - * The base implementation of `setData` without support for hot loop detection. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ - var baseSetData = !metaMap ? identity : function(func, data) { - metaMap.set(func, data); - return func; - }; - - module.exports = baseSetData; - - -/***/ }, -/* 173 */ +/* 169 */ /***/ function(module, exports, __webpack_require__) { /** @@ -18285,188 +17243,12 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 174 */ +/* 170 */ /***/ function(module, exports, __webpack_require__) { - exports = module.exports = __webpack_require__(195); - exports.Stream = __webpack_require__(127); - exports.Readable = exports; - exports.Writable = __webpack_require__(196); - exports.Duplex = __webpack_require__(197); - exports.Transform = __webpack_require__(198); - exports.PassThrough = __webpack_require__(199); - - -/***/ }, -/* 175 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(196) - - -/***/ }, -/* 176 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(197) - - -/***/ }, -/* 177 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(198) - - -/***/ }, -/* 178 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(199) - - -/***/ }, -/* 179 */ -/***/ function(module, exports, __webpack_require__) { - - /* (ignored) */ - -/***/ }, -/* 180 */ -/***/ function(module, exports, __webpack_require__) { - - exports.read = function(buffer, offset, isLE, mLen, nBytes) { - var e, m, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - nBits = -7, - i = isLE ? (nBytes - 1) : 0, - d = isLE ? -1 : 1, - s = buffer[offset + i]; - - i += d; - - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); - nBits += eLen; - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); - - m = e & ((1 << (-nBits)) - 1); - e >>= (-nBits); - nBits += mLen; - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); - - if (e === 0) { - e = 1 - eBias; - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity); - } else { - m = m + Math.pow(2, mLen); - e = e - eBias; - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen); - }; - - exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), - i = isLE ? 0 : (nBytes - 1), - d = isLE ? 1 : -1, - s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; - - value = Math.abs(value); - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0; - e = eMax; - } else { - e = Math.floor(Math.log(value) / Math.LN2); - if (value * (c = Math.pow(2, -e)) < 1) { - e--; - c *= 2; - } - if (e + eBias >= 1) { - value += rt / c; - } else { - value += rt * Math.pow(2, 1 - eBias); - } - if (value * c >= 2) { - e++; - c /= 2; - } - - if (e + eBias >= eMax) { - m = 0; - e = eMax; - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen); - e = e + eBias; - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); - e = 0; - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); - - e = (e << mLen) | m; - eLen += mLen; - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); - - buffer[offset + i - d] |= s * 128; - }; - - -/***/ }, -/* 181 */ -/***/ function(module, exports, __webpack_require__) { - - - /** - * isArray - */ - - var isArray = Array.isArray; - - /** - * toString - */ - - var str = Object.prototype.toString; - - /** - * Whether or not the given `val` - * is an array. - * - * example: - * - * isArray([]); - * // > true - * isArray(arguments); - * // > false - * isArray(''); - * // > false - * - * @param {mixed} val - * @return {bool} - */ - - module.exports = isArray || function (val) { - return !! val && '[object Array]' == str.call(val); - }; - - -/***/ }, -/* 182 */ -/***/ function(module, exports, __webpack_require__) { - - var baseForOwn = __webpack_require__(105), - isLength = __webpack_require__(136), - toObject = __webpack_require__(152); + var baseForOwn = __webpack_require__(94), + isLength = __webpack_require__(132), + toObject = __webpack_require__(145); /** * The base implementation of `_.forEach` without support for callback @@ -18497,18 +17279,80 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 183 */ +/* 171 */ /***/ function(module, exports, __webpack_require__) { - module.exports = function isBuffer(arg) { - return arg && typeof arg === 'object' - && typeof arg.copy === 'function' - && typeof arg.fill === 'function' - && typeof arg.readUInt8 === 'function'; + var arrayCopy = __webpack_require__(103), + isArguments = __webpack_require__(144), + isArray = __webpack_require__(95), + isLength = __webpack_require__(132), + isPlainObject = __webpack_require__(180), + isTypedArray = __webpack_require__(98), + toPlainObject = __webpack_require__(181); + + /** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize merging properties. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates values with source counterparts. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ + function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) { + var length = stackA.length, + srcValue = source[key]; + + while (length--) { + if (stackA[length] == srcValue) { + object[key] = stackB[length]; + return; + } + } + var value = object[key], + result = customizer ? customizer(value, srcValue, key, object, source) : undefined, + isCommon = typeof result == 'undefined'; + + if (isCommon) { + result = srcValue; + if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) { + result = isArray(value) + ? value + : (value ? arrayCopy(value) : []); + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + result = isArguments(value) + ? toPlainObject(value) + : (isPlainObject(value) ? value : {}); + } + else { + isCommon = false; + } + } + // Add the source value to the stack of traversed objects and associate + // it with its merged value. + stackA.push(srcValue); + stackB.push(result); + + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB); + } else if (result === result ? result !== value : value === value) { + object[key] = result; + } } + module.exports = baseMergeDeep; + + /***/ }, -/* 184 */ +/* 172 */ /***/ function(module, exports, __webpack_require__) { module.exports = Array.isArray || function (arr) { @@ -18517,7 +17361,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 185 */ +/* 173 */ /***/ function(module, exports, __webpack_require__) { // Copyright Joyent, Inc. and other Node contributors. @@ -18541,7 +17385,7 @@ return /******/ (function(modules) { // webpackBootstrap // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - var Buffer = __webpack_require__(129).Buffer; + var Buffer = __webpack_require__(88).Buffer; var isBufferEncoding = Buffer.isEncoding || function(encoding) { @@ -18744,36 +17588,137 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 186 */ +/* 174 */ /***/ function(module, exports, __webpack_require__) { - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; - } else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } + module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; } +/***/ }, +/* 175 */ +/***/ function(module, exports, __webpack_require__) { + + /* (ignored) */ /***/ }, -/* 187 */ +/* 176 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + function isArray(ar) { + return Array.isArray(ar); + } + exports.isArray = isArray; + + function isBoolean(arg) { + return typeof arg === 'boolean'; + } + exports.isBoolean = isBoolean; + + function isNull(arg) { + return arg === null; + } + exports.isNull = isNull; + + function isNullOrUndefined(arg) { + return arg == null; + } + exports.isNullOrUndefined = isNullOrUndefined; + + function isNumber(arg) { + return typeof arg === 'number'; + } + exports.isNumber = isNumber; + + function isString(arg) { + return typeof arg === 'string'; + } + exports.isString = isString; + + function isSymbol(arg) { + return typeof arg === 'symbol'; + } + exports.isSymbol = isSymbol; + + function isUndefined(arg) { + return arg === void 0; + } + exports.isUndefined = isUndefined; + + function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; + } + exports.isRegExp = isRegExp; + + function isObject(arg) { + return typeof arg === 'object' && arg !== null; + } + exports.isObject = isObject; + + function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; + } + exports.isDate = isDate; + + function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); + } + exports.isError = isError; + + function isFunction(arg) { + return typeof arg === 'function'; + } + exports.isFunction = isFunction; + + function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; + } + exports.isPrimitive = isPrimitive; + + function isBuffer(arg) { + return Buffer.isBuffer(arg); + } + exports.isBuffer = isBuffer; + + function objectToString(o) { + return Object.prototype.toString.call(o); + } + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) + +/***/ }, +/* 177 */ /***/ function(module, exports, __webpack_require__) { /* @@ -18785,7 +17730,7 @@ return /******/ (function(modules) { // webpackBootstrap * See http://pajhome.org.uk/crypt/md5 for more info. */ - var helpers = __webpack_require__(203); + var helpers = __webpack_require__(185); /* * Calculate the MD5 of an array of little-endian words, and a bit length @@ -18934,391 +17879,14 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 188 */ +/* 178 */ /***/ function(module, exports, __webpack_require__) { - var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - - ;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length - - var L = 0 - - function push (v) { - arr[L++] = v - } - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } - - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } - - return arr - } - - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length - - function encode (num) { - return lookup.charAt(num) - } - - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } - - return output - } - - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 - }(false ? (this.base64js = {}) : exports)) - - -/***/ }, -/* 189 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - // NOTE: These type checking functions intentionally don't use `instanceof` - // because it is fragile and can be easily faked with `Object.create()`. - function isArray(ar) { - return Array.isArray(ar); - } - exports.isArray = isArray; - - function isBoolean(arg) { - return typeof arg === 'boolean'; - } - exports.isBoolean = isBoolean; - - function isNull(arg) { - return arg === null; - } - exports.isNull = isNull; - - function isNullOrUndefined(arg) { - return arg == null; - } - exports.isNullOrUndefined = isNullOrUndefined; - - function isNumber(arg) { - return typeof arg === 'number'; - } - exports.isNumber = isNumber; - - function isString(arg) { - return typeof arg === 'string'; - } - exports.isString = isString; - - function isSymbol(arg) { - return typeof arg === 'symbol'; - } - exports.isSymbol = isSymbol; - - function isUndefined(arg) { - return arg === void 0; - } - exports.isUndefined = isUndefined; - - function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; - } - exports.isRegExp = isRegExp; - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - exports.isObject = isObject; - - function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; - } - exports.isDate = isDate; - - function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); - } - exports.isError = isError; - - function isFunction(arg) { - return typeof arg === 'function'; - } - exports.isFunction = isFunction; - - function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; - } - exports.isPrimitive = isPrimitive; - - function isBuffer(arg) { - return Buffer.isBuffer(arg); - } - exports.isBuffer = isBuffer; - - function objectToString(o) { - return Object.prototype.toString.call(o); - } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) - -/***/ }, -/* 190 */ -/***/ function(module, exports, __webpack_require__) { - - var isNative = __webpack_require__(137), - shimIsPlainObject = __webpack_require__(205); - - /** `Object#toString` result references. */ - var objectTag = '[object Object]'; - - /** Used for native method references. */ - var objectProto = Object.prototype; - - /** - * Used to resolve the `toStringTag` of values. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) - * for more details. - */ - var objToString = objectProto.toString; - - /** Native method references. */ - var getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf; - - /** - * Checks if `value` is a plain object, that is, an object created by the - * `Object` constructor or one with a `[[Prototype]]` of `null`. - * - * **Note:** This method assumes objects created by the `Object` constructor - * have no inherited enumerable properties. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * _.isPlainObject(new Foo); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true - * - * _.isPlainObject(Object.create(null)); - * // => true - */ - var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) { - if (!(value && objToString.call(value) == objectTag)) { - return false; - } - var valueOf = value.valueOf, - objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); - - return objProto - ? (value == objProto || getPrototypeOf(value) == objProto) - : shimIsPlainObject(value); - }; - - module.exports = isPlainObject; - - -/***/ }, -/* 191 */ -/***/ function(module, exports, __webpack_require__) { - - var baseCopy = __webpack_require__(99), - keysIn = __webpack_require__(167); - - /** - * Converts `value` to a plain object flattening inherited enumerable - * properties of `value` to own properties of the plain object. - * - * @static - * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @returns {Object} Returns the converted plain object. - * @example - * - * function Foo() { - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.assign({ 'a': 1 }, new Foo); - * // => { 'a': 1, 'b': 2 } - * - * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); - * // => { 'a': 1, 'b': 2, 'c': 3 } - */ - function toPlainObject(value) { - return baseCopy(value, keysIn(value)); - } - - module.exports = toPlainObject; - - -/***/ }, -/* 192 */ -/***/ function(module, exports, __webpack_require__) { - - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; - } else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } - } - - -/***/ }, -/* 193 */ -/***/ function(module, exports, __webpack_require__) { - - var equalArrays = __webpack_require__(207), - equalByTag = __webpack_require__(208), - equalObjects = __webpack_require__(209), - isArray = __webpack_require__(106), - isTypedArray = __webpack_require__(109); + var equalArrays = __webpack_require__(186), + equalByTag = __webpack_require__(187), + equalObjects = __webpack_require__(188), + isArray = __webpack_require__(95), + isTypedArray = __webpack_require__(98); /** `Object#toString` result references. */ var argsTag = '[object Arguments]', @@ -19418,10 +17986,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 194 */ +/* 179 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(global) {var isNative = __webpack_require__(137); + /* WEBPACK VAR INJECTION */(function(global) {var isNative = __webpack_require__(133); /** Native method references. */ var WeakMap = isNative(WeakMap = global.WeakMap) && WeakMap; @@ -19434,1812 +18002,112 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ }, -/* 195 */ +/* 180 */ /***/ function(module, exports, __webpack_require__) { - /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. + var isNative = __webpack_require__(133), + shimIsPlainObject = __webpack_require__(189); - module.exports = Readable; + /** `Object#toString` result references. */ + var objectTag = '[object Object]'; - /**/ - var isArray = __webpack_require__(214); - /**/ + /** Used for native method references. */ + var objectProto = Object.prototype; + /** + * Used to resolve the `toStringTag` of values. + * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) + * for more details. + */ + var objToString = objectProto.toString; - /**/ - var Buffer = __webpack_require__(129).Buffer; - /**/ + /** Native method references. */ + var getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf; - Readable.ReadableState = ReadableState; - - var EE = __webpack_require__(42).EventEmitter; - - /**/ - if (!EE.listenerCount) EE.listenerCount = function(emitter, type) { - return emitter.listeners(type).length; - }; - /**/ - - var Stream = __webpack_require__(127); - - /**/ - var util = __webpack_require__(215); - util.inherits = __webpack_require__(216); - /**/ - - var StringDecoder; - - - /**/ - var debug = __webpack_require__(204); - if (debug && debug.debuglog) { - debug = debug.debuglog('stream'); - } else { - debug = function () {}; - } - /**/ - - - util.inherits(Readable, Stream); - - function ReadableState(options, stream) { - var Duplex = __webpack_require__(197); - - options = options || {}; - - // the point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var defaultHwm = options.objectMode ? 16 : 16 * 1024; - this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; - - // cast to ints. - this.highWaterMark = ~~this.highWaterMark; - - this.buffer = []; - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; - - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true; - - // whenever we return null, then we set a flag to say - // that we're awaiting a 'readable' event emission. - this.needReadable = false; - this.emittedReadable = false; - this.readableListening = false; - - - // object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; - - if (stream instanceof Duplex) - this.objectMode = this.objectMode || !!options.readableObjectMode; - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - - // when piping, we only care about 'readable' events that happen - // after read()ing all the bytes and not getting any pushback. - this.ranOut = false; - - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; - - // if true, a maybeReadMore has been scheduled - this.readingMore = false; - - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) - StringDecoder = __webpack_require__(206).StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; + /** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * **Note:** This method assumes objects created by the `Object` constructor + * have no inherited enumerable properties. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ + var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) { + if (!(value && objToString.call(value) == objectTag)) { + return false; } - } + var valueOf = value.valueOf, + objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); - function Readable(options) { - var Duplex = __webpack_require__(197); - - if (!(this instanceof Readable)) - return new Readable(options); - - this._readableState = new ReadableState(options, this); - - // legacy - this.readable = true; - - Stream.call(this); - } - - // Manually shove something into the read() buffer. - // This returns true if the highWaterMark has not been hit yet, - // similar to how Writable.write() returns true if you should - // write() some more. - Readable.prototype.push = function(chunk, encoding) { - var state = this._readableState; - - if (util.isString(chunk) && !state.objectMode) { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = new Buffer(chunk, encoding); - encoding = ''; - } - } - - return readableAddChunk(this, state, chunk, encoding, false); + return objProto + ? (value == objProto || getPrototypeOf(value) == objProto) + : shimIsPlainObject(value); }; - // Unshift should *always* be something directly out of read() - Readable.prototype.unshift = function(chunk) { - var state = this._readableState; - return readableAddChunk(this, state, chunk, '', true); - }; - - function readableAddChunk(stream, state, chunk, encoding, addToFront) { - var er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (util.isNullOrUndefined(chunk)) { - state.reading = false; - if (!state.ended) - onEofChunk(stream, state); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (state.ended && !addToFront) { - var e = new Error('stream.push() after EOF'); - stream.emit('error', e); - } else if (state.endEmitted && addToFront) { - var e = new Error('stream.unshift() after end event'); - stream.emit('error', e); - } else { - if (state.decoder && !addToFront && !encoding) - chunk = state.decoder.write(chunk); - - if (!addToFront) - state.reading = false; - - // if we want the data now, just emit it. - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) - state.buffer.unshift(chunk); - else - state.buffer.push(chunk); - - if (state.needReadable) - emitReadable(stream); - } - - maybeReadMore(stream, state); - } - } else if (!addToFront) { - state.reading = false; - } - - return needMoreData(state); - } - - - - // if it's past the high water mark, we can push in some more. - // Also, if we have no data yet, we can stand some - // more bytes. This is to work around cases where hwm=0, - // such as the repl. Also, if the push() triggered a - // readable event, and the user called read(largeNumber) such that - // needReadable was set, then we ought to push more, so that another - // 'readable' event will be triggered. - function needMoreData(state) { - return !state.ended && - (state.needReadable || - state.length < state.highWaterMark || - state.length === 0); - } - - // backwards compatibility. - Readable.prototype.setEncoding = function(enc) { - if (!StringDecoder) - StringDecoder = __webpack_require__(206).StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; - }; - - // Don't raise the hwm > 128MB - var MAX_HWM = 0x800000; - function roundUpToNextPowerOf2(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 - n--; - for (var p = 1; p < 32; p <<= 1) n |= n >> p; - n++; - } - return n; - } - - function howMuchToRead(n, state) { - if (state.length === 0 && state.ended) - return 0; - - if (state.objectMode) - return n === 0 ? 0 : 1; - - if (isNaN(n) || util.isNull(n)) { - // only flow one buffer at a time - if (state.flowing && state.buffer.length) - return state.buffer[0].length; - else - return state.length; - } - - if (n <= 0) - return 0; - - // If we're asking for more than the target buffer level, - // then raise the water mark. Bump up to the next highest - // power of 2, to prevent increasing it excessively in tiny - // amounts. - if (n > state.highWaterMark) - state.highWaterMark = roundUpToNextPowerOf2(n); - - // don't have that much. return null, unless we've ended. - if (n > state.length) { - if (!state.ended) { - state.needReadable = true; - return 0; - } else - return state.length; - } - - return n; - } - - // you can override either this method, or the async _read(n) below. - Readable.prototype.read = function(n) { - debug('read', n); - var state = this._readableState; - var nOrig = n; - - if (!util.isNumber(n) || n > 0) - state.emittedReadable = false; - - // if we're doing read(0) to trigger a readable event, but we - // already have a bunch of data in the buffer, then just trigger - // the 'readable' event and move on. - if (n === 0 && - state.needReadable && - (state.length >= state.highWaterMark || state.ended)) { - debug('read: emitReadable', state.length, state.ended); - if (state.length === 0 && state.ended) - endReadable(this); - else - emitReadable(this); - return null; - } - - n = howMuchToRead(n, state); - - // if we've ended, and we're now clear, then finish it up. - if (n === 0 && state.ended) { - if (state.length === 0) - endReadable(this); - return null; - } - - // All the actual chunk generation logic needs to be - // *below* the call to _read. The reason is that in certain - // synthetic stream cases, such as passthrough streams, _read - // may be a completely synchronous operation which may change - // the state of the read buffer, providing enough data when - // before there was *not* enough. - // - // So, the steps are: - // 1. Figure out what the state of things will be after we do - // a read from the buffer. - // - // 2. If that resulting state will trigger a _read, then call _read. - // Note that this may be asynchronous, or synchronous. Yes, it is - // deeply ugly to write APIs this way, but that still doesn't mean - // that the Readable class should behave improperly, as streams are - // designed to be sync/async agnostic. - // Take note if the _read call is sync or async (ie, if the read call - // has returned yet), so that we know whether or not it's safe to emit - // 'readable' etc. - // - // 3. Actually pull the requested chunks out of the buffer and return. - - // if we need a readable event, then we need to do some reading. - var doRead = state.needReadable; - debug('need readable', doRead); - - // if we currently have less than the highWaterMark, then also read some - if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true; - debug('length less than watermark', doRead); - } - - // however, if we've ended, then there's no point, and if we're already - // reading, then it's unnecessary. - if (state.ended || state.reading) { - doRead = false; - debug('reading or ended', doRead); - } - - if (doRead) { - debug('do read'); - state.reading = true; - state.sync = true; - // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) - state.needReadable = true; - // call internal read method - this._read(state.highWaterMark); - state.sync = false; - } - - // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - if (doRead && !state.reading) - n = howMuchToRead(nOrig, state); - - var ret; - if (n > 0) - ret = fromList(n, state); - else - ret = null; - - if (util.isNull(ret)) { - state.needReadable = true; - n = 0; - } - - state.length -= n; - - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (state.length === 0 && !state.ended) - state.needReadable = true; - - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended && state.length === 0) - endReadable(this); - - if (!util.isNull(ret)) - this.emit('data', ret); - - return ret; - }; - - function chunkInvalid(state, chunk) { - var er = null; - if (!util.isBuffer(chunk) && - !util.isString(chunk) && - !util.isNullOrUndefined(chunk) && - !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; - } - - - function onEofChunk(stream, state) { - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) { - state.buffer.push(chunk); - state.length += state.objectMode ? 1 : chunk.length; - } - } - state.ended = true; - - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); - } - - // Don't emit readable right away in sync mode, because this can trigger - // another read() call => stack overflow. This way, it might trigger - // a nextTick recursion warning, but that's not so bad. - function emitReadable(stream) { - var state = stream._readableState; - state.needReadable = false; - if (!state.emittedReadable) { - debug('emitReadable', state.flowing); - state.emittedReadable = true; - if (state.sync) - process.nextTick(function() { - emitReadable_(stream); - }); - else - emitReadable_(stream); - } - } - - function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); - } - - - // at this point, the user has presumably seen the 'readable' event, - // and called read() to consume some data. that may have triggered - // in turn another _read(n) call, in which case reading = true if - // it's in progress. - // However, if we're not ended, or reading, and the length < hwm, - // then go ahead and try to read some more preemptively. - function maybeReadMore(stream, state) { - if (!state.readingMore) { - state.readingMore = true; - process.nextTick(function() { - maybeReadMore_(stream, state); - }); - } - } - - function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && - state.length < state.highWaterMark) { - debug('maybeReadMore read 0'); - stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break; - else - len = state.length; - } - state.readingMore = false; - } - - // abstract method. to be overridden in specific implementation classes. - // call cb(er, data) where data is <= n in length. - // for virtual (non-string, non-buffer) streams, "length" is somewhat - // arbitrary, and perhaps not very meaningful. - Readable.prototype._read = function(n) { - this.emit('error', new Error('not implemented')); - }; - - Readable.prototype.pipe = function(dest, pipeOpts) { - var src = this; - var state = this._readableState; - - switch (state.pipesCount) { - case 0: - state.pipes = dest; - break; - case 1: - state.pipes = [state.pipes, dest]; - break; - default: - state.pipes.push(dest); - break; - } - state.pipesCount += 1; - debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - - var doEnd = (!pipeOpts || pipeOpts.end !== false) && - dest !== process.stdout && - dest !== process.stderr; - - var endFn = doEnd ? onend : cleanup; - if (state.endEmitted) - process.nextTick(endFn); - else - src.once('end', endFn); - - dest.on('unpipe', onunpipe); - function onunpipe(readable) { - debug('onunpipe'); - if (readable === src) { - cleanup(); - } - } - - function onend() { - debug('onend'); - dest.end(); - } - - // when the dest drains, it reduces the awaitDrain counter - // on the source. This would be more elegant with a .once() - // handler in flow(), but adding and removing repeatedly is - // too slow. - var ondrain = pipeOnDrain(src); - dest.on('drain', ondrain); - - function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken - dest.removeListener('close', onclose); - dest.removeListener('finish', onfinish); - dest.removeListener('drain', ondrain); - dest.removeListener('error', onerror); - dest.removeListener('unpipe', onunpipe); - src.removeListener('end', onend); - src.removeListener('end', cleanup); - src.removeListener('data', ondata); - - // if the reader is waiting for a drain event from this - // specific writer, then it would cause it to never start - // flowing again. - // So, if this is awaiting a drain, then we just call it now. - // If we don't know, then assume that we are waiting for one. - if (state.awaitDrain && - (!dest._writableState || dest._writableState.needDrain)) - ondrain(); - } - - src.on('data', ondata); - function ondata(chunk) { - debug('ondata'); - var ret = dest.write(chunk); - if (false === ret) { - debug('false write response, pause', - src._readableState.awaitDrain); - src._readableState.awaitDrain++; - src.pause(); - } - } - - // if the dest has an error, then stop piping into it. - // however, don't suppress the throwing behavior for this. - function onerror(er) { - debug('onerror', er); - unpipe(); - dest.removeListener('error', onerror); - if (EE.listenerCount(dest, 'error') === 0) - dest.emit('error', er); - } - // This is a brutally ugly hack to make sure that our error handler - // is attached before any userland ones. NEVER DO THIS. - if (!dest._events || !dest._events.error) - dest.on('error', onerror); - else if (isArray(dest._events.error)) - dest._events.error.unshift(onerror); - else - dest._events.error = [onerror, dest._events.error]; - - - - // Both close and finish should trigger unpipe, but only once. - function onclose() { - dest.removeListener('finish', onfinish); - unpipe(); - } - dest.once('close', onclose); - function onfinish() { - debug('onfinish'); - dest.removeListener('close', onclose); - unpipe(); - } - dest.once('finish', onfinish); - - function unpipe() { - debug('unpipe'); - src.unpipe(dest); - } - - // tell the dest that it's being piped to - dest.emit('pipe', src); - - // start the flow if it hasn't been started already. - if (!state.flowing) { - debug('pipe resume'); - src.resume(); - } - - return dest; - }; - - function pipeOnDrain(src) { - return function() { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) - state.awaitDrain--; - if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) { - state.flowing = true; - flow(src); - } - }; - } - - - Readable.prototype.unpipe = function(dest) { - var state = this._readableState; - - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) - return this; - - // just one destination. most common case. - if (state.pipesCount === 1) { - // passed in one, but it's not the right one. - if (dest && dest !== state.pipes) - return this; - - if (!dest) - dest = state.pipes; - - // got a match. - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - if (dest) - dest.emit('unpipe', this); - return this; - } - - // slow case. multiple pipe destinations. - - if (!dest) { - // remove all. - var dests = state.pipes; - var len = state.pipesCount; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - - for (var i = 0; i < len; i++) - dests[i].emit('unpipe', this); - return this; - } - - // try to find the right one. - var i = indexOf(state.pipes, dest); - if (i === -1) - return this; - - state.pipes.splice(i, 1); - state.pipesCount -= 1; - if (state.pipesCount === 1) - state.pipes = state.pipes[0]; - - dest.emit('unpipe', this); - - return this; - }; - - // set up data events if they are asked for - // Ensure readable listeners eventually get something - Readable.prototype.on = function(ev, fn) { - var res = Stream.prototype.on.call(this, ev, fn); - - // If listening to data, and it has not explicitly been paused, - // then call resume to start the flow of data on the next tick. - if (ev === 'data' && false !== this._readableState.flowing) { - this.resume(); - } - - if (ev === 'readable' && this.readable) { - var state = this._readableState; - if (!state.readableListening) { - state.readableListening = true; - state.emittedReadable = false; - state.needReadable = true; - if (!state.reading) { - var self = this; - process.nextTick(function() { - debug('readable nexttick read 0'); - self.read(0); - }); - } else if (state.length) { - emitReadable(this, state); - } - } - } - - return res; - }; - Readable.prototype.addListener = Readable.prototype.on; - - // pause() and resume() are remnants of the legacy readable stream API - // If the user uses them, then switch into old mode. - Readable.prototype.resume = function() { - var state = this._readableState; - if (!state.flowing) { - debug('resume'); - state.flowing = true; - if (!state.reading) { - debug('resume read 0'); - this.read(0); - } - resume(this, state); - } - return this; - }; - - function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - process.nextTick(function() { - resume_(stream, state); - }); - } - } - - function resume_(stream, state) { - state.resumeScheduled = false; - stream.emit('resume'); - flow(stream); - if (state.flowing && !state.reading) - stream.read(0); - } - - Readable.prototype.pause = function() { - debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { - debug('pause'); - this._readableState.flowing = false; - this.emit('pause'); - } - return this; - }; - - function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - if (state.flowing) { - do { - var chunk = stream.read(); - } while (null !== chunk && state.flowing); - } - } - - // wrap an old-style stream as the async data source. - // This is *not* part of the readable stream interface. - // It is an ugly unfortunate mess of history. - Readable.prototype.wrap = function(stream) { - var state = this._readableState; - var paused = false; - - var self = this; - stream.on('end', function() { - debug('wrapped end'); - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) - self.push(chunk); - } - - self.push(null); - }); - - stream.on('data', function(chunk) { - debug('wrapped data'); - if (state.decoder) - chunk = state.decoder.write(chunk); - if (!chunk || !state.objectMode && !chunk.length) - return; - - var ret = self.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); - - // proxy all the other methods. - // important when wrapping filters and duplexes. - for (var i in stream) { - if (util.isFunction(stream[i]) && util.isUndefined(this[i])) { - this[i] = function(method) { return function() { - return stream[method].apply(stream, arguments); - }}(i); - } - } - - // proxy certain important events. - var events = ['error', 'close', 'destroy', 'pause', 'resume']; - forEach(events, function(ev) { - stream.on(ev, self.emit.bind(self, ev)); - }); - - // when we try to consume some more bytes, simply unpause the - // underlying stream. - self._read = function(n) { - debug('wrapped _read', n); - if (paused) { - paused = false; - stream.resume(); - } - }; - - return self; - }; - - - - // exposed for testing purposes only. - Readable._fromList = fromList; - - // Pluck off n bytes from an array of buffers. - // Length is the combined lengths of all the buffers in the list. - function fromList(n, state) { - var list = state.buffer; - var length = state.length; - var stringMode = !!state.decoder; - var objectMode = !!state.objectMode; - var ret; - - // nothing in the list, definitely empty. - if (list.length === 0) - return null; - - if (length === 0) - ret = null; - else if (objectMode) - ret = list.shift(); - else if (!n || n >= length) { - // read it all, truncate the array. - if (stringMode) - ret = list.join(''); - else - ret = Buffer.concat(list, length); - list.length = 0; - } else { - // read just some of it. - if (n < list[0].length) { - // just take a part of the first list item. - // slice is the same for buffers and strings. - var buf = list[0]; - ret = buf.slice(0, n); - list[0] = buf.slice(n); - } else if (n === list[0].length) { - // first list is a perfect match - ret = list.shift(); - } else { - // complex case. - // we have enough to cover it, but it spans past the first buffer. - if (stringMode) - ret = ''; - else - ret = new Buffer(n); - - var c = 0; - for (var i = 0, l = list.length; i < l && c < n; i++) { - var buf = list[0]; - var cpy = Math.min(n - c, buf.length); - - if (stringMode) - ret += buf.slice(0, cpy); - else - buf.copy(ret, c, 0, cpy); - - if (cpy < buf.length) - list[0] = buf.slice(cpy); - else - list.shift(); - - c += cpy; - } - } - } - - return ret; - } - - function endReadable(stream) { - var state = stream._readableState; - - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) - throw new Error('endReadable called on non-empty stream'); - - if (!state.endEmitted) { - state.ended = true; - process.nextTick(function() { - // Check that we didn't get one last unshift. - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); - } - }); - } - } - - function forEach (xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } - } - - function indexOf (xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; - } - return -1; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) - -/***/ }, -/* 196 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - // A bit simpler than readable streams. - // Implement an async ._write(chunk, cb), and it'll handle all - // the drain event emission and buffering. - - module.exports = Writable; - - /**/ - var Buffer = __webpack_require__(129).Buffer; - /**/ - - Writable.WritableState = WritableState; - - - /**/ - var util = __webpack_require__(215); - util.inherits = __webpack_require__(216); - /**/ - - var Stream = __webpack_require__(127); - - util.inherits(Writable, Stream); - - function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - } - - function WritableState(options, stream) { - var Duplex = __webpack_require__(197); - - options = options || {}; - - // the point at which write() starts returning false - // Note: 0 is a valid value, means that we always return false if - // the entire buffer is not flushed immediately on write() - var hwm = options.highWaterMark; - var defaultHwm = options.objectMode ? 16 : 16 * 1024; - this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; - - // object stream flag to indicate whether or not this stream - // contains buffers or objects. - this.objectMode = !!options.objectMode; - - if (stream instanceof Duplex) - this.objectMode = this.objectMode || !!options.writableObjectMode; - - // cast to ints. - this.highWaterMark = ~~this.highWaterMark; - - this.needDrain = false; - // at the start of calling end() - this.ending = false; - // when end() has been called, and returned - this.ended = false; - // when 'finish' is emitted - this.finished = false; - - // should we decode strings into buffers before passing to _write? - // this is here so that some node-core streams can optimize string - // handling at a lower level. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - - // not an actual buffer we keep track of, but a measurement - // of how much we're waiting to get pushed to some underlying - // socket or file. - this.length = 0; - - // a flag to see when we're in the middle of a write. - this.writing = false; - - // when true all writes will be buffered until .uncork() call - this.corked = 0; - - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true; - - // a flag to know if we're processing previously buffered items, which - // may call the _write() callback in the same tick, so that we don't - // end up in an overlapped onwrite situation. - this.bufferProcessing = false; - - // the callback that's passed to _write(chunk,cb) - this.onwrite = function(er) { - onwrite(stream, er); - }; - - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; - - // the amount that is being written when _write is called. - this.writelen = 0; - - this.buffer = []; - - // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; - - // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - this.prefinished = false; - - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; - } - - function Writable(options) { - var Duplex = __webpack_require__(197); - - // Writable ctor is applied to Duplexes, though they're not - // instanceof Writable, they're instanceof Readable. - if (!(this instanceof Writable) && !(this instanceof Duplex)) - return new Writable(options); - - this._writableState = new WritableState(options, this); - - // legacy. - this.writable = true; - - Stream.call(this); - } - - // Otherwise people can pipe Writable streams, which is just wrong. - Writable.prototype.pipe = function() { - this.emit('error', new Error('Cannot pipe. Not readable.')); - }; - - - function writeAfterEnd(stream, state, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - process.nextTick(function() { - cb(er); - }); - } - - // If we get something that is not a buffer, string, null, or undefined, - // and we're not in objectMode, then that's an error. - // Otherwise stream chunks are all considered to be of length=1, and the - // watermarks determine how many objects to keep in the buffer, rather than - // how many bytes or characters. - function validChunk(stream, state, chunk, cb) { - var valid = true; - if (!util.isBuffer(chunk) && - !util.isString(chunk) && - !util.isNullOrUndefined(chunk) && - !state.objectMode) { - var er = new TypeError('Invalid non-string/buffer chunk'); - stream.emit('error', er); - process.nextTick(function() { - cb(er); - }); - valid = false; - } - return valid; - } - - Writable.prototype.write = function(chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - - if (util.isFunction(encoding)) { - cb = encoding; - encoding = null; - } - - if (util.isBuffer(chunk)) - encoding = 'buffer'; - else if (!encoding) - encoding = state.defaultEncoding; - - if (!util.isFunction(cb)) - cb = function() {}; - - if (state.ended) - writeAfterEnd(this, state, cb); - else if (validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, chunk, encoding, cb); - } - - return ret; - }; - - Writable.prototype.cork = function() { - var state = this._writableState; - - state.corked++; - }; - - Writable.prototype.uncork = function() { - var state = this._writableState; - - if (state.corked) { - state.corked--; - - if (!state.writing && - !state.corked && - !state.finished && - !state.bufferProcessing && - state.buffer.length) - clearBuffer(this, state); - } - }; - - function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && - state.decodeStrings !== false && - util.isString(chunk)) { - chunk = new Buffer(chunk, encoding); - } - return chunk; - } - - // if we're already writing something, then just put this - // in the queue, and wait our turn. Otherwise, call _write - // If we return false, then we need a drain event, so set that flag. - function writeOrBuffer(stream, state, chunk, encoding, cb) { - chunk = decodeChunk(state, chunk, encoding); - if (util.isBuffer(chunk)) - encoding = 'buffer'; - var len = state.objectMode ? 1 : chunk.length; - - state.length += len; - - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. - if (!ret) - state.needDrain = true; - - if (state.writing || state.corked) - state.buffer.push(new WriteReq(chunk, encoding, cb)); - else - doWrite(stream, state, false, len, chunk, encoding, cb); - - return ret; - } - - function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len; - state.writecb = cb; - state.writing = true; - state.sync = true; - if (writev) - stream._writev(chunk, state.onwrite); - else - stream._write(chunk, encoding, state.onwrite); - state.sync = false; - } - - function onwriteError(stream, state, sync, er, cb) { - if (sync) - process.nextTick(function() { - state.pendingcb--; - cb(er); - }); - else { - state.pendingcb--; - cb(er); - } - - stream._writableState.errorEmitted = true; - stream.emit('error', er); - } - - function onwriteStateUpdate(state) { - state.writing = false; - state.writecb = null; - state.length -= state.writelen; - state.writelen = 0; - } - - function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; - - onwriteStateUpdate(state); - - if (er) - onwriteError(stream, state, sync, er, cb); - else { - // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(stream, state); - - if (!finished && - !state.corked && - !state.bufferProcessing && - state.buffer.length) { - clearBuffer(stream, state); - } - - if (sync) { - process.nextTick(function() { - afterWrite(stream, state, finished, cb); - }); - } else { - afterWrite(stream, state, finished, cb); - } - } - } - - function afterWrite(stream, state, finished, cb) { - if (!finished) - onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); - } - - // Must force callback to be called on nextTick, so that we don't - // emit 'drain' before the write() consumer gets the 'false' return - // value, and has a chance to attach a 'drain' listener. - function onwriteDrain(stream, state) { - if (state.length === 0 && state.needDrain) { - state.needDrain = false; - stream.emit('drain'); - } - } - - - // if there's something in the buffer waiting, then process it - function clearBuffer(stream, state) { - state.bufferProcessing = true; - - if (stream._writev && state.buffer.length > 1) { - // Fast case, write everything using _writev() - var cbs = []; - for (var c = 0; c < state.buffer.length; c++) - cbs.push(state.buffer[c].callback); - - // count the one we are adding, as well. - // TODO(isaacs) clean this up - state.pendingcb++; - doWrite(stream, state, true, state.length, state.buffer, '', function(err) { - for (var i = 0; i < cbs.length; i++) { - state.pendingcb--; - cbs[i](err); - } - }); - - // Clear buffer - state.buffer = []; - } else { - // Slow case, write chunks one-by-one - for (var c = 0; c < state.buffer.length; c++) { - var entry = state.buffer[c]; - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; - - doWrite(stream, state, false, len, chunk, encoding, cb); - - // if we didn't call the onwrite immediately, then - // it means that we need to wait until it does. - // also, that means that the chunk and cb are currently - // being processed, so move the buffer counter past them. - if (state.writing) { - c++; - break; - } - } - - if (c < state.buffer.length) - state.buffer = state.buffer.slice(c); - else - state.buffer.length = 0; - } - - state.bufferProcessing = false; - } - - Writable.prototype._write = function(chunk, encoding, cb) { - cb(new Error('not implemented')); - - }; - - Writable.prototype._writev = null; - - Writable.prototype.end = function(chunk, encoding, cb) { - var state = this._writableState; - - if (util.isFunction(chunk)) { - cb = chunk; - chunk = null; - encoding = null; - } else if (util.isFunction(encoding)) { - cb = encoding; - encoding = null; - } - - if (!util.isNullOrUndefined(chunk)) - this.write(chunk, encoding); - - // .end() fully uncorks - if (state.corked) { - state.corked = 1; - this.uncork(); - } - - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) - endWritable(this, state, cb); - }; - - - function needFinish(stream, state) { - return (state.ending && - state.length === 0 && - !state.finished && - !state.writing); - } - - function prefinish(stream, state) { - if (!state.prefinished) { - state.prefinished = true; - stream.emit('prefinish'); - } - } - - function finishMaybe(stream, state) { - var need = needFinish(stream, state); - if (need) { - if (state.pendingcb === 0) { - prefinish(stream, state); - state.finished = true; - stream.emit('finish'); - } else - prefinish(stream, state); - } - return need; - } - - function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) - process.nextTick(cb); - else - stream.once('finish', cb); - } - state.ended = true; - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) - -/***/ }, -/* 197 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - // a duplex stream is just a stream that is both readable and writable. - // Since JS doesn't have multiple prototypal inheritance, this class - // prototypally inherits from Readable, and then parasitically from - // Writable. - - module.exports = Duplex; - - /**/ - var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - } - /**/ - - - /**/ - var util = __webpack_require__(215); - util.inherits = __webpack_require__(216); - /**/ - - var Readable = __webpack_require__(195); - var Writable = __webpack_require__(196); - - util.inherits(Duplex, Readable); - - forEach(objectKeys(Writable.prototype), function(method) { - if (!Duplex.prototype[method]) - Duplex.prototype[method] = Writable.prototype[method]; - }); - - function Duplex(options) { - if (!(this instanceof Duplex)) - return new Duplex(options); - - Readable.call(this, options); - Writable.call(this, options); - - if (options && options.readable === false) - this.readable = false; - - if (options && options.writable === false) - this.writable = false; - - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) - this.allowHalfOpen = false; - - this.once('end', onend); - } - - // the no-half-open enforcer - function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) - return; - - // no more data can be written. - // But allow more writes to happen in this tick. - process.nextTick(this.end.bind(this)); - } - - function forEach (xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } - } - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(11))) - -/***/ }, -/* 198 */ -/***/ function(module, exports, __webpack_require__) { - - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - - // a transform stream is a readable/writable stream where you do - // something with the data. Sometimes it's called a "filter", - // but that's not a great name for it, since that implies a thing where - // some bits pass through, and others are simply ignored. (That would - // be a valid example of a transform, of course.) - // - // While the output is causally related to the input, it's not a - // necessarily symmetric or synchronous transformation. For example, - // a zlib stream might take multiple plain-text writes(), and then - // emit a single compressed chunk some time in the future. - // - // Here's how this works: - // - // The Transform stream has all the aspects of the readable and writable - // stream classes. When you write(chunk), that calls _write(chunk,cb) - // internally, and returns false if there's a lot of pending writes - // buffered up. When you call read(), that calls _read(n) until - // there's enough pending readable data buffered up. - // - // In a transform stream, the written data is placed in a buffer. When - // _read(n) is called, it transforms the queued up data, calling the - // buffered _write cb's as it consumes chunks. If consuming a single - // written chunk would result in multiple output chunks, then the first - // outputted bit calls the readcb, and subsequent chunks just go into - // the read buffer, and will cause it to emit 'readable' if necessary. - // - // This way, back-pressure is actually determined by the reading side, - // since _read has to be called to start processing a new chunk. However, - // a pathological inflate type of transform can cause excessive buffering - // here. For example, imagine a stream where every byte of input is - // interpreted as an integer from 0-255, and then results in that many - // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in - // 1kb of data being output. In this case, you could write a very small - // amount of input, and end up with a very large amount of output. In - // such a pathological inflating mechanism, there'd be no way to tell - // the system to stop doing the transform. A single 4MB write could - // cause the system to run out of memory. - // - // However, even in such a pathological case, only a single written chunk - // would be consumed, and then the rest would wait (un-transformed) until - // the results of the previous transformed chunk were consumed. - - module.exports = Transform; - - var Duplex = __webpack_require__(197); - - /**/ - var util = __webpack_require__(215); - util.inherits = __webpack_require__(216); - /**/ - - util.inherits(Transform, Duplex); - - - function TransformState(options, stream) { - this.afterTransform = function(er, data) { - return afterTransform(stream, er, data); - }; - - this.needTransform = false; - this.transforming = false; - this.writecb = null; - this.writechunk = null; - } - - function afterTransform(stream, er, data) { - var ts = stream._transformState; - ts.transforming = false; - - var cb = ts.writecb; - - if (!cb) - return stream.emit('error', new Error('no writecb in Transform class')); - - ts.writechunk = null; - ts.writecb = null; - - if (!util.isNullOrUndefined(data)) - stream.push(data); - - if (cb) - cb(er); - - var rs = stream._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - stream._read(rs.highWaterMark); - } - } - - - function Transform(options) { - if (!(this instanceof Transform)) - return new Transform(options); - - Duplex.call(this, options); - - this._transformState = new TransformState(options, this); - - // when the writable side finishes, then flush out anything remaining. - var stream = this; - - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; - - // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - this._readableState.sync = false; - - this.once('prefinish', function() { - if (util.isFunction(this._flush)) - this._flush(function(er) { - done(stream, er); - }); - else - done(stream); - }); - } - - Transform.prototype.push = function(chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); - }; - - // This is the part where you do stuff! - // override this function in implementation classes. - // 'chunk' is an input chunk. - // - // Call `push(newChunk)` to pass along transformed output - // to the readable side. You may call 'push' zero or more times. - // - // Call `cb(err)` when you are done with this chunk. If you pass - // an error, then that'll put the hurt on the whole operation. If you - // never call cb(), then you'll never get another chunk. - Transform.prototype._transform = function(chunk, encoding, cb) { - throw new Error('not implemented'); - }; - - Transform.prototype._write = function(chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || - rs.needReadable || - rs.length < rs.highWaterMark) - this._read(rs.highWaterMark); - } - }; - - // Doesn't matter what the args are here. - // _transform does all the work. - // That we got here means that the readable side wants more data. - Transform.prototype._read = function(n) { - var ts = this._transformState; - - if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; - } - }; - - - function done(stream, er) { - if (er) - return stream.emit('error', er); - - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - var ws = stream._writableState; - var ts = stream._transformState; - - if (ws.length) - throw new Error('calling transform done when ws.length != 0'); - - if (ts.transforming) - throw new Error('calling transform done when still transforming'); - - return stream.push(null); - } + module.exports = isPlainObject; /***/ }, -/* 199 */ +/* 181 */ /***/ function(module, exports, __webpack_require__) { - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. + var baseCopy = __webpack_require__(100), + keysIn = __webpack_require__(168); - // a passthrough stream. - // basically just the most minimal sort of Transform stream. - // Every written chunk gets output as-is. - - module.exports = PassThrough; - - var Transform = __webpack_require__(198); - - /**/ - var util = __webpack_require__(215); - util.inherits = __webpack_require__(216); - /**/ - - util.inherits(PassThrough, Transform); - - function PassThrough(options) { - if (!(this instanceof PassThrough)) - return new PassThrough(options); - - Transform.call(this, options); + /** + * Converts `value` to a plain object flattening inherited enumerable + * properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ + function toPlainObject(value) { + return baseCopy(value, keysIn(value)); } - PassThrough.prototype._transform = function(chunk, encoding, cb) { - cb(null, chunk); - }; + module.exports = toPlainObject; /***/ }, -/* 200 */ +/* 182 */ /***/ function(module, exports, __webpack_require__) { var exports = module.exports = function (alg) { @@ -21248,16 +18116,16 @@ return /******/ (function(modules) { // webpackBootstrap return new Alg() } - var Buffer = __webpack_require__(129).Buffer - var Hash = __webpack_require__(210)(Buffer) + var Buffer = __webpack_require__(88).Buffer + var Hash = __webpack_require__(190)(Buffer) - exports.sha1 = __webpack_require__(211)(Buffer, Hash) - exports.sha256 = __webpack_require__(212)(Buffer, Hash) - exports.sha512 = __webpack_require__(213)(Buffer, Hash) + exports.sha1 = __webpack_require__(191)(Buffer, Hash) + exports.sha256 = __webpack_require__(192)(Buffer, Hash) + exports.sha512 = __webpack_require__(193)(Buffer, Hash) /***/ }, -/* 201 */ +/* 183 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {module.exports = function(crypto) { @@ -21345,10 +18213,10 @@ return /******/ (function(modules) { // webpackBootstrap } } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) /***/ }, -/* 202 */ +/* 184 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) { @@ -21557,10 +18425,10 @@ return /******/ (function(modules) { // webpackBootstrap - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) /***/ }, -/* 203 */ +/* 185 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {var intSize = 4; @@ -21598,300 +18466,10 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = { hash: hash }; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(88).Buffer)) /***/ }, -/* 204 */ -/***/ function(module, exports, __webpack_require__) { - - /* (ignored) */ - -/***/ }, -/* 205 */ -/***/ function(module, exports, __webpack_require__) { - - var baseForIn = __webpack_require__(153), - isObjectLike = __webpack_require__(145); - - /** `Object#toString` result references. */ - var objectTag = '[object Object]'; - - /** Used for native method references. */ - var objectProto = Object.prototype; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto.hasOwnProperty; - - /** - * Used to resolve the `toStringTag` of values. - * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) - * for more details. - */ - var objToString = objectProto.toString; - - /** - * A fallback implementation of `_.isPlainObject` which checks if `value` - * is an object created by the `Object` constructor or has a `[[Prototype]]` - * of `null`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - */ - function shimIsPlainObject(value) { - var Ctor; - - // Exit early for non `Object` objects. - if (!(isObjectLike(value) && objToString.call(value) == objectTag) || - (!hasOwnProperty.call(value, 'constructor') && - (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) { - return false; - } - // IE < 9 iterates inherited properties before own properties. If the first - // iterated property is an object's own property then there are no inherited - // enumerable properties. - var result; - // In most environments an object's own properties are iterated before - // its inherited properties. If the last iterated property is an object's - // own property then there are no inherited enumerable properties. - baseForIn(value, function(subValue, key) { - result = key; - }); - return typeof result == 'undefined' || hasOwnProperty.call(value, result); - } - - module.exports = shimIsPlainObject; - - -/***/ }, -/* 206 */ -/***/ function(module, exports, __webpack_require__) { - - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - var Buffer = __webpack_require__(129).Buffer; - - var isBufferEncoding = Buffer.isEncoding - || function(encoding) { - switch (encoding && encoding.toLowerCase()) { - case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; - default: return false; - } - } - - - function assertEncoding(encoding) { - if (encoding && !isBufferEncoding(encoding)) { - throw new Error('Unknown encoding: ' + encoding); - } - } - - // StringDecoder provides an interface for efficiently splitting a series of - // buffers into a series of JS strings without breaking apart multi-byte - // characters. CESU-8 is handled as part of the UTF-8 encoding. - // - // @TODO Handling all encodings inside a single object makes it very difficult - // to reason about this code, so it should be split up in the future. - // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code - // points as used by CESU-8. - var StringDecoder = exports.StringDecoder = function(encoding) { - this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); - assertEncoding(encoding); - switch (this.encoding) { - case 'utf8': - // CESU-8 represents each of Surrogate Pair by 3-bytes - this.surrogateSize = 3; - break; - case 'ucs2': - case 'utf16le': - // UTF-16 represents each of Surrogate Pair by 2-bytes - this.surrogateSize = 2; - this.detectIncompleteChar = utf16DetectIncompleteChar; - break; - case 'base64': - // Base-64 stores 3 bytes in 4 chars, and pads the remainder. - this.surrogateSize = 3; - this.detectIncompleteChar = base64DetectIncompleteChar; - break; - default: - this.write = passThroughWrite; - return; - } - - // Enough space to store all bytes of a single character. UTF-8 needs 4 - // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). - this.charBuffer = new Buffer(6); - // Number of bytes received for the current incomplete multi-byte character. - this.charReceived = 0; - // Number of bytes expected for the current incomplete multi-byte character. - this.charLength = 0; - }; - - - // write decodes the given buffer and returns it as JS string that is - // guaranteed to not contain any partial multi-byte characters. Any partial - // character found at the end of the buffer is buffered up, and will be - // returned when calling write again with the remaining bytes. - // - // Note: Converting a Buffer containing an orphan surrogate to a String - // currently works, but converting a String to a Buffer (via `new Buffer`, or - // Buffer#write) will replace incomplete surrogates with the unicode - // replacement character. See https://codereview.chromium.org/121173009/ . - StringDecoder.prototype.write = function(buffer) { - var charStr = ''; - // if our last write ended with an incomplete multibyte character - while (this.charLength) { - // determine how many remaining bytes this buffer has to offer for this char - var available = (buffer.length >= this.charLength - this.charReceived) ? - this.charLength - this.charReceived : - buffer.length; - - // add the new bytes to the char buffer - buffer.copy(this.charBuffer, this.charReceived, 0, available); - this.charReceived += available; - - if (this.charReceived < this.charLength) { - // still not enough chars in this buffer? wait for more ... - return ''; - } - - // remove bytes belonging to the current character from the buffer - buffer = buffer.slice(available, buffer.length); - - // get the character that was split - charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); - - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - var charCode = charStr.charCodeAt(charStr.length - 1); - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - this.charLength += this.surrogateSize; - charStr = ''; - continue; - } - this.charReceived = this.charLength = 0; - - // if there are no more bytes in this buffer, just emit our char - if (buffer.length === 0) { - return charStr; - } - break; - } - - // determine and set charLength / charReceived - this.detectIncompleteChar(buffer); - - var end = buffer.length; - if (this.charLength) { - // buffer the incomplete character bytes we got - buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); - end -= this.charReceived; - } - - charStr += buffer.toString(this.encoding, 0, end); - - var end = charStr.length - 1; - var charCode = charStr.charCodeAt(end); - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - var size = this.surrogateSize; - this.charLength += size; - this.charReceived += size; - this.charBuffer.copy(this.charBuffer, size, 0, size); - buffer.copy(this.charBuffer, 0, 0, size); - return charStr.substring(0, end); - } - - // or just emit the charStr - return charStr; - }; - - // detectIncompleteChar determines if there is an incomplete UTF-8 character at - // the end of the given buffer. If so, it sets this.charLength to the byte - // length that character, and sets this.charReceived to the number of bytes - // that are available for this character. - StringDecoder.prototype.detectIncompleteChar = function(buffer) { - // determine how many bytes we have to check at the end of this buffer - var i = (buffer.length >= 3) ? 3 : buffer.length; - - // Figure out if one of the last i bytes of our buffer announces an - // incomplete char. - for (; i > 0; i--) { - var c = buffer[buffer.length - i]; - - // See http://en.wikipedia.org/wiki/UTF-8#Description - - // 110XXXXX - if (i == 1 && c >> 5 == 0x06) { - this.charLength = 2; - break; - } - - // 1110XXXX - if (i <= 2 && c >> 4 == 0x0E) { - this.charLength = 3; - break; - } - - // 11110XXX - if (i <= 3 && c >> 3 == 0x1E) { - this.charLength = 4; - break; - } - } - this.charReceived = i; - }; - - StringDecoder.prototype.end = function(buffer) { - var res = ''; - if (buffer && buffer.length) - res = this.write(buffer); - - if (this.charReceived) { - var cr = this.charReceived; - var buf = this.charBuffer; - var enc = this.encoding; - res += buf.slice(0, cr).toString(enc); - } - - return res; - }; - - function passThroughWrite(buffer) { - return buffer.toString(this.encoding); - } - - function utf16DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 2; - this.charLength = this.charReceived ? 2 : 0; - } - - function base64DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 3; - this.charLength = this.charReceived ? 3 : 0; - } - - -/***/ }, -/* 207 */ +/* 186 */ /***/ function(module, exports, __webpack_require__) { /** @@ -21951,7 +18529,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 208 */ +/* 187 */ /***/ function(module, exports, __webpack_require__) { /** `Object#toString` result references. */ @@ -22006,10 +18584,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 209 */ +/* 188 */ /***/ function(module, exports, __webpack_require__) { - var keys = __webpack_require__(100); + var keys = __webpack_require__(101); /** Used for native method references. */ var objectProto = Object.prototype; @@ -22084,7 +18662,64 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 210 */ +/* 189 */ +/***/ function(module, exports, __webpack_require__) { + + var baseForIn = __webpack_require__(146), + isObjectLike = __webpack_require__(134); + + /** `Object#toString` result references. */ + var objectTag = '[object Object]'; + + /** Used for native method references. */ + var objectProto = Object.prototype; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** + * Used to resolve the `toStringTag` of values. + * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) + * for more details. + */ + var objToString = objectProto.toString; + + /** + * A fallback implementation of `_.isPlainObject` which checks if `value` + * is an object created by the `Object` constructor or has a `[[Prototype]]` + * of `null`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + */ + function shimIsPlainObject(value) { + var Ctor; + + // Exit early for non `Object` objects. + if (!(isObjectLike(value) && objToString.call(value) == objectTag) || + (!hasOwnProperty.call(value, 'constructor') && + (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) { + return false; + } + // IE < 9 iterates inherited properties before own properties. If the first + // iterated property is an object's own property then there are no inherited + // enumerable properties. + var result; + // In most environments an object's own properties are iterated before + // its inherited properties. If the last iterated property is an object's + // own property then there are no inherited enumerable properties. + baseForIn(value, function(subValue, key) { + result = key; + }); + return typeof result == 'undefined' || hasOwnProperty.call(value, result); + } + + module.exports = shimIsPlainObject; + + +/***/ }, +/* 190 */ /***/ function(module, exports, __webpack_require__) { module.exports = function (Buffer) { @@ -22167,7 +18802,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 211 */ +/* 191 */ /***/ function(module, exports, __webpack_require__) { /* @@ -22179,7 +18814,7 @@ return /******/ (function(modules) { // webpackBootstrap * See http://pajhome.org.uk/crypt/md5 for details. */ - var inherits = __webpack_require__(140).inherits + var inherits = __webpack_require__(127).inherits module.exports = function (Buffer, Hash) { @@ -22311,7 +18946,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 212 */ +/* 192 */ /***/ function(module, exports, __webpack_require__) { @@ -22323,7 +18958,7 @@ return /******/ (function(modules) { // webpackBootstrap * */ - var inherits = __webpack_require__(140).inherits + var inherits = __webpack_require__(127).inherits module.exports = function (Buffer, Hash) { @@ -22464,10 +19099,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 213 */ +/* 193 */ /***/ function(module, exports, __webpack_require__) { - var inherits = __webpack_require__(140).inherits + var inherits = __webpack_require__(127).inherits module.exports = function (Buffer, Hash) { var K = [ @@ -22713,157 +19348,6 @@ return /******/ (function(modules) { // webpackBootstrap } -/***/ }, -/* 214 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; - }; - - -/***/ }, -/* 215 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - // NOTE: These type checking functions intentionally don't use `instanceof` - // because it is fragile and can be easily faked with `Object.create()`. - function isArray(ar) { - return Array.isArray(ar); - } - exports.isArray = isArray; - - function isBoolean(arg) { - return typeof arg === 'boolean'; - } - exports.isBoolean = isBoolean; - - function isNull(arg) { - return arg === null; - } - exports.isNull = isNull; - - function isNullOrUndefined(arg) { - return arg == null; - } - exports.isNullOrUndefined = isNullOrUndefined; - - function isNumber(arg) { - return typeof arg === 'number'; - } - exports.isNumber = isNumber; - - function isString(arg) { - return typeof arg === 'string'; - } - exports.isString = isString; - - function isSymbol(arg) { - return typeof arg === 'symbol'; - } - exports.isSymbol = isSymbol; - - function isUndefined(arg) { - return arg === void 0; - } - exports.isUndefined = isUndefined; - - function isRegExp(re) { - return isObject(re) && objectToString(re) === '[object RegExp]'; - } - exports.isRegExp = isRegExp; - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - exports.isObject = isObject; - - function isDate(d) { - return isObject(d) && objectToString(d) === '[object Date]'; - } - exports.isDate = isDate; - - function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); - } - exports.isError = isError; - - function isFunction(arg) { - return typeof arg === 'function'; - } - exports.isFunction = isFunction; - - function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; - } - exports.isPrimitive = isPrimitive; - - function isBuffer(arg) { - return Buffer.isBuffer(arg); - } - exports.isBuffer = isBuffer; - - function objectToString(o) { - return Object.prototype.toString.call(o); - } - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(129).Buffer)) - -/***/ }, -/* 216 */ -/***/ function(module, exports, __webpack_require__) { - - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; - } else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } - } - - /***/ } /******/ ]) }); diff --git a/lib/dialects/maria/index.js b/lib/dialects/maria/index.js index f0dfbd95..d5461398 100644 --- a/lib/dialects/maria/index.js +++ b/lib/dialects/maria/index.js @@ -21,6 +21,10 @@ assign(Client_MariaSQL.prototype, { driverName: 'mariasql', + _driver: function() { + return require('mariasql') + }, + // Get a raw connection, called by the `pool` whenever a new // connection needs to be added to the pool. acquireRawConnection: function() { diff --git a/lib/dialects/mysql/index.js b/lib/dialects/mysql/index.js index b392e979..abbc10f6 100644 --- a/lib/dialects/mysql/index.js +++ b/lib/dialects/mysql/index.js @@ -29,6 +29,10 @@ assign(Client_MySQL.prototype, { driverName: 'mysql', + _driver: function() { + return require('mysql') + }, + QueryCompiler: QueryCompiler, SchemaCompiler: SchemaCompiler, diff --git a/lib/dialects/mysql2/index.js b/lib/dialects/mysql2/index.js index 729aa248..5b268c30 100644 --- a/lib/dialects/mysql2/index.js +++ b/lib/dialects/mysql2/index.js @@ -25,6 +25,10 @@ assign(Client_MySQL2.prototype, { // The "dialect", for reference elsewhere. driverName: 'mysql2', + _driver: function() { + return require('mysql2') + }, + // Get a raw connection, called by the `pool` whenever a new // connection needs to be added to the pool. acquireRawConnection: function() { diff --git a/lib/dialects/oracle/index.js b/lib/dialects/oracle/index.js index 8170e595..90b04cff 100644 --- a/lib/dialects/oracle/index.js +++ b/lib/dialects/oracle/index.js @@ -35,6 +35,10 @@ assign(Client_Oracle.prototype, { driverName: 'oracle', + _driver: function() { + return require('oracle') + }, + Transaction: Transaction, Formatter: Formatter, diff --git a/lib/dialects/postgres/index.js b/lib/dialects/postgres/index.js index 8e00228e..a37d19c3 100644 --- a/lib/dialects/postgres/index.js +++ b/lib/dialects/postgres/index.js @@ -37,6 +37,10 @@ assign(Client_PG.prototype, { driverName: 'pg', + _driver: function() { + return require('pg') + }, + wrapIdentifier: function(value) { if (value === '*') return value; var matched = value.match(/(.*?)(\[[0-9]\])/); diff --git a/lib/dialects/sqlite3/index.js b/lib/dialects/sqlite3/index.js index 5337e2be..a323729a 100644 --- a/lib/dialects/sqlite3/index.js +++ b/lib/dialects/sqlite3/index.js @@ -28,6 +28,10 @@ assign(Client_SQLite3.prototype, { driverName: 'sqlite3', + _driver: function() { + return require('sqlite3') + }, + SchemaCompiler: SchemaCompiler, QueryCompiler: QueryCompiler, diff --git a/lib/dialects/strong-oracle/index.js b/lib/dialects/strong-oracle/index.js index 0fa52495..560221a6 100644 --- a/lib/dialects/strong-oracle/index.js +++ b/lib/dialects/strong-oracle/index.js @@ -11,13 +11,8 @@ function Client_StrongOracle() { } inherits(Client_StrongOracle, Client_Oracle); -Client_StrongOracle.prototype.initializeDriver = function() { - try { - this.driver = require(this.driverName)() - } catch (e) { - console.log(e) - helpers.exit('Knex: run\n$ npm install ' + this.driverName + ' --save') - } +Client_StrongOracle.prototype._driver = function() { + return require('strong-oracle')() } Client_StrongOracle.prototype.driverName = 'strong-oracle' diff --git a/lib/dialects/websql/transaction.js b/lib/dialects/websql/transaction.js index f6d72d2b..26132a60 100644 --- a/lib/dialects/websql/transaction.js +++ b/lib/dialects/websql/transaction.js @@ -19,7 +19,7 @@ function makeClient(trx, client) { var trxClient = Object.create(client.constructor.prototype) trxClient.config = client.config - trxClient.connectionSettings = connectionSettings + trxClient.connectionSettings = client.connectionSettings trxClient.transacting = true trxClient.on('query', function(arg) { diff --git a/package.json b/package.json index c54e3f34..ec509321 100644 --- a/package.json +++ b/package.json @@ -52,9 +52,8 @@ "webpack": "^1.8.9" }, "scripts": { - "tape": "tape ./test/tape/index.js", "build": "gulp build", - "plaintest": "mocha --check-leaks -t 10000 -b -R spec test/index.js && npm run tape", + "plaintest": "mocha --check-leaks -t 10000 -b -R spec test/index.js && node test/tape/index.js && gulp jshint", "test": "istanbul --config=test/.istanbul.yml cover _mocha -- --check-leaks -t 5000 -b -R spec test/index.js && npm run tape && npm run jshint", "coveralls": "cat ./test/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", "jshint": "gulp jshint", @@ -80,11 +79,19 @@ "web": "https://github.com/tgriesser" }, "browser": { - "pg-query-stream": false, "bluebird/js/main/promise": "./lib/util/bluebird.js", - "./lib/migrate/index.js": "./lib/migrate/index.web.js", - "./lib/bin/cli.js": "lodash/utility/noop", - "./lib/seed/index.js": "lodash/utility/noop" + "./lib/migrate/index.js": "lodash/utility/noop", + "./lib/bin/cli.js": "lodash/utility/noop", + "./lib/seed/index.js": "lodash/utility/noop", + "pool2": "lodash/utility/noop", + "mysql": false, + "mysql2": false, + "mariasql": false, + "pg": false, + "pg-query-stream":false, + "oracle": false, + "strong-oracle": false, + "sqlite3": false }, "files": [ "README.md", diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..5417c066 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e + +webpack=node_modules/.bin/webpack + +rm -rf tmp +mkdir tmp +rm -rf build +mkdir build + +cp -r lib tmp/lib +cp knex.js tmp + +node -p 'p=require("./package");p.main="lib";p.scripts=p.devDependencies=undefined;JSON.stringify(p,null,2)' > tmp/package.json + +$webpack --config scripts/webpack.config.js tmp build/knex.js + +rm -rf tmp \ No newline at end of file diff --git a/scripts/webpack.config.js b/scripts/webpack.config.js new file mode 100644 index 00000000..7f1d5d62 --- /dev/null +++ b/scripts/webpack.config.js @@ -0,0 +1,30 @@ +var webpack = require('webpack'); +var plugins = [] + +var externals = [{ + "bluebird": { + root: "Promise", + commonjs2: "bluebird", + commonjs: "bluebird", + amd: "bluebird" + }, + "lodash": { + root: "_", + commonjs2: "lodash", + commonjs: "lodash", + amd: "lodash" + } +}] + +module.exports = { + + output: { + library: 'Knex', + libraryTarget: 'umd' + }, + + externals: externals, + + plugins: plugins + +}; \ No newline at end of file