libhoney
Advanced tools
Comparing version 4.0.0 to 4.0.1
'use strict'; | ||
var superagent = require('superagent'); | ||
var require$$1 = require('url'); | ||
var require$$2 = require('path'); | ||
var events = require('events'); | ||
@@ -11,191 +9,77 @@ | ||
var superagent__default = /*#__PURE__*/_interopDefaultLegacy(superagent); | ||
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); | ||
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); | ||
var hasOwn = Object.prototype.hasOwnProperty; | ||
var toStr = Object.prototype.toString; | ||
var defineProperty = Object.defineProperty; | ||
var gOPD = Object.getOwnPropertyDescriptor; | ||
function normalize (strArray) { | ||
var resultArray = []; | ||
if (strArray.length === 0) { return ''; } | ||
var isArray = function isArray(arr) { | ||
if (typeof Array.isArray === 'function') { | ||
return Array.isArray(arr); | ||
} | ||
if (typeof strArray[0] !== 'string') { | ||
throw new TypeError('Url must be a string. Received ' + strArray[0]); | ||
} | ||
return toStr.call(arr) === '[object Array]'; | ||
}; | ||
// If the first part is a plain protocol, we combine it with the next part. | ||
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) { | ||
var first = strArray.shift(); | ||
strArray[0] = first + strArray[0]; | ||
} | ||
var isPlainObject = function isPlainObject(obj) { | ||
// There must be two or three slashes in the file protocol, two slashes in anything else. | ||
if (strArray[0].match(/^file:\/\/\//)) { | ||
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///'); | ||
} else { | ||
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://'); | ||
} | ||
if (!obj || toStr.call(obj) !== '[object Object]') { | ||
return false; | ||
} | ||
for (var i = 0; i < strArray.length; i++) { | ||
var component = strArray[i]; | ||
var hasOwnConstructor = hasOwn.call(obj, 'constructor'); | ||
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); | ||
// Not own constructor property must be Object | ||
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { | ||
return false; | ||
} | ||
if (typeof component !== 'string') { | ||
throw new TypeError('Url must be a string. Received ' + component); | ||
} | ||
// Own properties are enumerated firstly, so to speed up, | ||
// if last one is own, then all properties are own. | ||
var key; | ||
for (key in obj) { /**/ } | ||
if (component === '') { continue; } | ||
return typeof key === 'undefined' || hasOwn.call(obj, key); | ||
}; | ||
if (i > 0) { | ||
// Removing the starting slashes for each component but the first. | ||
component = component.replace(/^[\/]+/, ''); | ||
} | ||
if (i < strArray.length - 1) { | ||
// Removing the ending slashes for each component but the last. | ||
component = component.replace(/[\/]+$/, ''); | ||
} else { | ||
// For the last component we will combine multiple slashes to a single one. | ||
component = component.replace(/[\/]+$/, '/'); | ||
} | ||
// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target | ||
var setProperty = function setProperty(target, options) { | ||
if (defineProperty && options.name === '__proto__') { | ||
defineProperty(target, options.name, { | ||
enumerable: true, | ||
configurable: true, | ||
value: options.newValue, | ||
writable: true | ||
}); | ||
} else { | ||
target[options.name] = options.newValue; | ||
} | ||
}; | ||
resultArray.push(component); | ||
// Return undefined instead of __proto__ if '__proto__' is not an own property | ||
var getProperty = function getProperty(obj, name) { | ||
if (name === '__proto__') { | ||
if (!hasOwn.call(obj, name)) { | ||
return void 0; | ||
} else if (gOPD) { | ||
// In early versions of node, obj['__proto__'] is buggy when obj has | ||
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works. | ||
return gOPD(obj, name).value; | ||
} | ||
} | ||
} | ||
return obj[name]; | ||
}; | ||
var str = resultArray.join('/'); | ||
// Each input component is now separated by a single slash except the possible first plain protocol part. | ||
var extend$1 = function extend() { | ||
// remove trailing slash before parameters or hash | ||
str = str.replace(/\/(\?|&|#[^!])/g, '$1'); | ||
var options, name, src, copy, copyIsArray, clone; | ||
var target = arguments[0]; | ||
var i = 1; | ||
var length = arguments.length; | ||
var deep = false; | ||
// replace ? in parameters with & | ||
var parts = str.split('?'); | ||
str = parts.shift() + (parts.length > 0 ? '?': '') + parts.join('&'); | ||
// Handle a deep copy situation | ||
if (typeof target === 'boolean') { | ||
deep = target; | ||
target = arguments[1] || {}; | ||
// skip the boolean and the target | ||
i = 2; | ||
} | ||
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { | ||
target = {}; | ||
} | ||
return str; | ||
} | ||
for (; i < length; ++i) { | ||
options = arguments[i]; | ||
// Only deal with non-null/undefined values | ||
if (options != null) { | ||
// Extend the base object | ||
for (name in options) { | ||
src = getProperty(target, name); | ||
copy = getProperty(options, name); | ||
function urlJoin() { | ||
var input; | ||
// Prevent never-ending loop | ||
if (target !== copy) { | ||
// Recurse if we're merging plain objects or arrays | ||
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { | ||
if (copyIsArray) { | ||
copyIsArray = false; | ||
clone = src && isArray(src) ? src : []; | ||
} else { | ||
clone = src && isPlainObject(src) ? src : {}; | ||
} | ||
if (typeof arguments[0] === 'object') { | ||
input = arguments[0]; | ||
} else { | ||
input = [].slice.call(arguments); | ||
} | ||
// Never move original objects, clone them | ||
setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); | ||
return normalize(input); | ||
} | ||
// Don't bring in undefined values | ||
} else if (typeof copy !== 'undefined') { | ||
setProperty(target, { name: name, newValue: copy }); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// Return the modified object | ||
return target; | ||
}; | ||
/** | ||
* Copyright (C) 2014 yanni4night.com | ||
* index.js | ||
* | ||
* changelog | ||
* 2014-08-16[14:31:02]:authorized | ||
* 2014-08-19[14:05:43]:fixed crash when first piece is empty | ||
* 2014-11-16[21:15:06]:support windows \\ | ||
* | ||
* @author yanni4night@gmail.com | ||
* @version 0.1.2 | ||
* @since 0.1.0 | ||
*/ | ||
var extend = extend$1; | ||
var url = require$$1__default["default"]; | ||
var path = require$$2__default["default"]; | ||
/** | ||
* Join two or more url pieces into one. | ||
* | ||
* Only the protocol/port/host in the first piece is saved,but all the get parameters | ||
* will be saved. | ||
* | ||
* @param {String|Function}... Multiple url pieces in function or string type. | ||
* @return {String} The URL joined. | ||
*/ | ||
var urljoin = function urljoin() { | ||
//convert to Array | ||
var pieces = Array.prototype.slice.call(arguments); | ||
var query = {}; | ||
var first, paths; | ||
if (!pieces.length) { | ||
return ''; | ||
} else if (1 === pieces.length) { | ||
return pieces[0]; | ||
} | ||
paths = pieces.map(function(piece) { | ||
var pieceStr = 'function' === typeof piece ? piece() : String(piece || ''); | ||
if (!pieceStr) { | ||
return ''; | ||
} | ||
var parsed = url.parse(pieceStr, true); | ||
if (!first && parsed) { | ||
first = parsed; | ||
} | ||
extend(query, parsed.query); | ||
return parsed.pathname; | ||
}).filter(function(piece) { | ||
return !!piece; | ||
}); | ||
delete first.search; //we use query instead of search | ||
first.query = query; | ||
first.pathname = path.join.apply(path, paths).replace(new RegExp('\\' + path.sep, 'g'), '/'); | ||
return url.format(first); | ||
}; | ||
// Copyright 2016 Hound Technology, Inc. All rights reserved. | ||
const LIBHONEY_VERSION = "libhoney-js/4.0.0"; | ||
const LIBHONEY_VERSION = "libhoney-js/4.0.1"; | ||
const NODE_VERSION = `node/${process.version}`; | ||
@@ -516,3 +400,3 @@ | ||
eachPromise(batches, batch => { | ||
let url = urljoin(batch.apiHost, "/1/batch", batch.dataset); | ||
let url = urlJoin(batch.apiHost, "/1/batch", batch.dataset); | ||
let postReq = superagent__default["default"].post(url); | ||
@@ -519,0 +403,0 @@ |
'use strict'; | ||
var superagent = require('superagent'); | ||
var require$$1 = require('url'); | ||
var require$$2 = require('path'); | ||
var events = require('events'); | ||
@@ -11,209 +9,95 @@ | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n["default"] = e; | ||
return Object.freeze(n); | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { return e[k]; } | ||
}); | ||
} | ||
}); | ||
} | ||
n["default"] = e; | ||
return Object.freeze(n); | ||
} | ||
var superagent__default = /*#__PURE__*/_interopDefaultLegacy(superagent); | ||
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); | ||
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); | ||
var hasOwn = Object.prototype.hasOwnProperty; | ||
var toStr = Object.prototype.toString; | ||
var defineProperty = Object.defineProperty; | ||
var gOPD = Object.getOwnPropertyDescriptor; | ||
function normalize (strArray) { | ||
var resultArray = []; | ||
if (strArray.length === 0) { return ''; } | ||
var isArray = function isArray(arr) { | ||
if (typeof Array.isArray === 'function') { | ||
return Array.isArray(arr); | ||
} | ||
if (typeof strArray[0] !== 'string') { | ||
throw new TypeError('Url must be a string. Received ' + strArray[0]); | ||
} | ||
return toStr.call(arr) === '[object Array]'; | ||
}; | ||
// If the first part is a plain protocol, we combine it with the next part. | ||
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) { | ||
var first = strArray.shift(); | ||
strArray[0] = first + strArray[0]; | ||
} | ||
var isPlainObject = function isPlainObject(obj) { | ||
// There must be two or three slashes in the file protocol, two slashes in anything else. | ||
if (strArray[0].match(/^file:\/\/\//)) { | ||
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///'); | ||
} else { | ||
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://'); | ||
} | ||
if (!obj || toStr.call(obj) !== '[object Object]') { | ||
return false; | ||
} | ||
for (var i = 0; i < strArray.length; i++) { | ||
var component = strArray[i]; | ||
var hasOwnConstructor = hasOwn.call(obj, 'constructor'); | ||
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); | ||
// Not own constructor property must be Object | ||
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { | ||
return false; | ||
} | ||
if (typeof component !== 'string') { | ||
throw new TypeError('Url must be a string. Received ' + component); | ||
} | ||
// Own properties are enumerated firstly, so to speed up, | ||
// if last one is own, then all properties are own. | ||
var key; | ||
for (key in obj) { /**/ } | ||
if (component === '') { continue; } | ||
return typeof key === 'undefined' || hasOwn.call(obj, key); | ||
}; | ||
if (i > 0) { | ||
// Removing the starting slashes for each component but the first. | ||
component = component.replace(/^[\/]+/, ''); | ||
} | ||
if (i < strArray.length - 1) { | ||
// Removing the ending slashes for each component but the last. | ||
component = component.replace(/[\/]+$/, ''); | ||
} else { | ||
// For the last component we will combine multiple slashes to a single one. | ||
component = component.replace(/[\/]+$/, '/'); | ||
} | ||
// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target | ||
var setProperty = function setProperty(target, options) { | ||
if (defineProperty && options.name === '__proto__') { | ||
defineProperty(target, options.name, { | ||
enumerable: true, | ||
configurable: true, | ||
value: options.newValue, | ||
writable: true | ||
}); | ||
} else { | ||
target[options.name] = options.newValue; | ||
} | ||
}; | ||
resultArray.push(component); | ||
// Return undefined instead of __proto__ if '__proto__' is not an own property | ||
var getProperty = function getProperty(obj, name) { | ||
if (name === '__proto__') { | ||
if (!hasOwn.call(obj, name)) { | ||
return void 0; | ||
} else if (gOPD) { | ||
// In early versions of node, obj['__proto__'] is buggy when obj has | ||
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works. | ||
return gOPD(obj, name).value; | ||
} | ||
} | ||
} | ||
return obj[name]; | ||
}; | ||
var str = resultArray.join('/'); | ||
// Each input component is now separated by a single slash except the possible first plain protocol part. | ||
var extend$1 = function extend() { | ||
// remove trailing slash before parameters or hash | ||
str = str.replace(/\/(\?|&|#[^!])/g, '$1'); | ||
var options, name, src, copy, copyIsArray, clone; | ||
var target = arguments[0]; | ||
var i = 1; | ||
var length = arguments.length; | ||
var deep = false; | ||
// replace ? in parameters with & | ||
var parts = str.split('?'); | ||
str = parts.shift() + (parts.length > 0 ? '?': '') + parts.join('&'); | ||
// Handle a deep copy situation | ||
if (typeof target === 'boolean') { | ||
deep = target; | ||
target = arguments[1] || {}; | ||
// skip the boolean and the target | ||
i = 2; | ||
} | ||
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { | ||
target = {}; | ||
} | ||
return str; | ||
} | ||
for (; i < length; ++i) { | ||
options = arguments[i]; | ||
// Only deal with non-null/undefined values | ||
if (options != null) { | ||
// Extend the base object | ||
for (name in options) { | ||
src = getProperty(target, name); | ||
copy = getProperty(options, name); | ||
function urlJoin() { | ||
var input; | ||
// Prevent never-ending loop | ||
if (target !== copy) { | ||
// Recurse if we're merging plain objects or arrays | ||
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { | ||
if (copyIsArray) { | ||
copyIsArray = false; | ||
clone = src && isArray(src) ? src : []; | ||
} else { | ||
clone = src && isPlainObject(src) ? src : {}; | ||
} | ||
if (typeof arguments[0] === 'object') { | ||
input = arguments[0]; | ||
} else { | ||
input = [].slice.call(arguments); | ||
} | ||
// Never move original objects, clone them | ||
setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); | ||
return normalize(input); | ||
} | ||
// Don't bring in undefined values | ||
} else if (typeof copy !== 'undefined') { | ||
setProperty(target, { name: name, newValue: copy }); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// Return the modified object | ||
return target; | ||
}; | ||
/** | ||
* Copyright (C) 2014 yanni4night.com | ||
* index.js | ||
* | ||
* changelog | ||
* 2014-08-16[14:31:02]:authorized | ||
* 2014-08-19[14:05:43]:fixed crash when first piece is empty | ||
* 2014-11-16[21:15:06]:support windows \\ | ||
* | ||
* @author yanni4night@gmail.com | ||
* @version 0.1.2 | ||
* @since 0.1.0 | ||
*/ | ||
var extend = extend$1; | ||
var url = require$$1__default["default"]; | ||
var path = require$$2__default["default"]; | ||
/** | ||
* Join two or more url pieces into one. | ||
* | ||
* Only the protocol/port/host in the first piece is saved,but all the get parameters | ||
* will be saved. | ||
* | ||
* @param {String|Function}... Multiple url pieces in function or string type. | ||
* @return {String} The URL joined. | ||
*/ | ||
var urljoin = function urljoin() { | ||
//convert to Array | ||
var pieces = Array.prototype.slice.call(arguments); | ||
var query = {}; | ||
var first, paths; | ||
if (!pieces.length) { | ||
return ''; | ||
} else if (1 === pieces.length) { | ||
return pieces[0]; | ||
} | ||
paths = pieces.map(function(piece) { | ||
var pieceStr = 'function' === typeof piece ? piece() : String(piece || ''); | ||
if (!pieceStr) { | ||
return ''; | ||
} | ||
var parsed = url.parse(pieceStr, true); | ||
if (!first && parsed) { | ||
first = parsed; | ||
} | ||
extend(query, parsed.query); | ||
return parsed.pathname; | ||
}).filter(function(piece) { | ||
return !!piece; | ||
}); | ||
delete first.search; //we use query instead of search | ||
first.query = query; | ||
first.pathname = path.join.apply(path, paths).replace(new RegExp('\\' + path.sep, 'g'), '/'); | ||
return url.format(first); | ||
}; | ||
// Copyright 2016 Hound Technology, Inc. All rights reserved. | ||
const LIBHONEY_VERSION = "libhoney-js/4.0.0"; | ||
const LIBHONEY_VERSION = "libhoney-js/4.0.1"; | ||
const NODE_VERSION = `node/${process.version}`; | ||
@@ -534,3 +418,3 @@ | ||
eachPromise(batches, batch => { | ||
let url = urljoin(batch.apiHost, "/1/batch", batch.dataset); | ||
let url = urlJoin(batch.apiHost, "/1/batch", batch.dataset); | ||
let postReq = superagent__default["default"].post(url); | ||
@@ -537,0 +421,0 @@ |
import superagent from 'superagent'; | ||
import require$$1 from 'url'; | ||
import require$$2 from 'path'; | ||
import { EventEmitter } from 'events'; | ||
var hasOwn = Object.prototype.hasOwnProperty; | ||
var toStr = Object.prototype.toString; | ||
var defineProperty = Object.defineProperty; | ||
var gOPD = Object.getOwnPropertyDescriptor; | ||
function normalize (strArray) { | ||
var resultArray = []; | ||
if (strArray.length === 0) { return ''; } | ||
var isArray = function isArray(arr) { | ||
if (typeof Array.isArray === 'function') { | ||
return Array.isArray(arr); | ||
} | ||
if (typeof strArray[0] !== 'string') { | ||
throw new TypeError('Url must be a string. Received ' + strArray[0]); | ||
} | ||
return toStr.call(arr) === '[object Array]'; | ||
}; | ||
// If the first part is a plain protocol, we combine it with the next part. | ||
if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) { | ||
var first = strArray.shift(); | ||
strArray[0] = first + strArray[0]; | ||
} | ||
var isPlainObject = function isPlainObject(obj) { | ||
// There must be two or three slashes in the file protocol, two slashes in anything else. | ||
if (strArray[0].match(/^file:\/\/\//)) { | ||
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1:///'); | ||
} else { | ||
strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, '$1://'); | ||
} | ||
if (!obj || toStr.call(obj) !== '[object Object]') { | ||
return false; | ||
} | ||
for (var i = 0; i < strArray.length; i++) { | ||
var component = strArray[i]; | ||
var hasOwnConstructor = hasOwn.call(obj, 'constructor'); | ||
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); | ||
// Not own constructor property must be Object | ||
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { | ||
return false; | ||
} | ||
if (typeof component !== 'string') { | ||
throw new TypeError('Url must be a string. Received ' + component); | ||
} | ||
// Own properties are enumerated firstly, so to speed up, | ||
// if last one is own, then all properties are own. | ||
var key; | ||
for (key in obj) { /**/ } | ||
if (component === '') { continue; } | ||
return typeof key === 'undefined' || hasOwn.call(obj, key); | ||
}; | ||
if (i > 0) { | ||
// Removing the starting slashes for each component but the first. | ||
component = component.replace(/^[\/]+/, ''); | ||
} | ||
if (i < strArray.length - 1) { | ||
// Removing the ending slashes for each component but the last. | ||
component = component.replace(/[\/]+$/, ''); | ||
} else { | ||
// For the last component we will combine multiple slashes to a single one. | ||
component = component.replace(/[\/]+$/, '/'); | ||
} | ||
// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target | ||
var setProperty = function setProperty(target, options) { | ||
if (defineProperty && options.name === '__proto__') { | ||
defineProperty(target, options.name, { | ||
enumerable: true, | ||
configurable: true, | ||
value: options.newValue, | ||
writable: true | ||
}); | ||
} else { | ||
target[options.name] = options.newValue; | ||
} | ||
}; | ||
resultArray.push(component); | ||
// Return undefined instead of __proto__ if '__proto__' is not an own property | ||
var getProperty = function getProperty(obj, name) { | ||
if (name === '__proto__') { | ||
if (!hasOwn.call(obj, name)) { | ||
return void 0; | ||
} else if (gOPD) { | ||
// In early versions of node, obj['__proto__'] is buggy when obj has | ||
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works. | ||
return gOPD(obj, name).value; | ||
} | ||
} | ||
} | ||
return obj[name]; | ||
}; | ||
var str = resultArray.join('/'); | ||
// Each input component is now separated by a single slash except the possible first plain protocol part. | ||
var extend$1 = function extend() { | ||
// remove trailing slash before parameters or hash | ||
str = str.replace(/\/(\?|&|#[^!])/g, '$1'); | ||
var options, name, src, copy, copyIsArray, clone; | ||
var target = arguments[0]; | ||
var i = 1; | ||
var length = arguments.length; | ||
var deep = false; | ||
// replace ? in parameters with & | ||
var parts = str.split('?'); | ||
str = parts.shift() + (parts.length > 0 ? '?': '') + parts.join('&'); | ||
// Handle a deep copy situation | ||
if (typeof target === 'boolean') { | ||
deep = target; | ||
target = arguments[1] || {}; | ||
// skip the boolean and the target | ||
i = 2; | ||
} | ||
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) { | ||
target = {}; | ||
} | ||
return str; | ||
} | ||
for (; i < length; ++i) { | ||
options = arguments[i]; | ||
// Only deal with non-null/undefined values | ||
if (options != null) { | ||
// Extend the base object | ||
for (name in options) { | ||
src = getProperty(target, name); | ||
copy = getProperty(options, name); | ||
function urlJoin() { | ||
var input; | ||
// Prevent never-ending loop | ||
if (target !== copy) { | ||
// Recurse if we're merging plain objects or arrays | ||
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { | ||
if (copyIsArray) { | ||
copyIsArray = false; | ||
clone = src && isArray(src) ? src : []; | ||
} else { | ||
clone = src && isPlainObject(src) ? src : {}; | ||
} | ||
if (typeof arguments[0] === 'object') { | ||
input = arguments[0]; | ||
} else { | ||
input = [].slice.call(arguments); | ||
} | ||
// Never move original objects, clone them | ||
setProperty(target, { name: name, newValue: extend(deep, clone, copy) }); | ||
return normalize(input); | ||
} | ||
// Don't bring in undefined values | ||
} else if (typeof copy !== 'undefined') { | ||
setProperty(target, { name: name, newValue: copy }); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// Return the modified object | ||
return target; | ||
}; | ||
/** | ||
* Copyright (C) 2014 yanni4night.com | ||
* index.js | ||
* | ||
* changelog | ||
* 2014-08-16[14:31:02]:authorized | ||
* 2014-08-19[14:05:43]:fixed crash when first piece is empty | ||
* 2014-11-16[21:15:06]:support windows \\ | ||
* | ||
* @author yanni4night@gmail.com | ||
* @version 0.1.2 | ||
* @since 0.1.0 | ||
*/ | ||
var extend = extend$1; | ||
var url = require$$1; | ||
var path = require$$2; | ||
/** | ||
* Join two or more url pieces into one. | ||
* | ||
* Only the protocol/port/host in the first piece is saved,but all the get parameters | ||
* will be saved. | ||
* | ||
* @param {String|Function}... Multiple url pieces in function or string type. | ||
* @return {String} The URL joined. | ||
*/ | ||
var urljoin = function urljoin() { | ||
//convert to Array | ||
var pieces = Array.prototype.slice.call(arguments); | ||
var query = {}; | ||
var first, paths; | ||
if (!pieces.length) { | ||
return ''; | ||
} else if (1 === pieces.length) { | ||
return pieces[0]; | ||
} | ||
paths = pieces.map(function(piece) { | ||
var pieceStr = 'function' === typeof piece ? piece() : String(piece || ''); | ||
if (!pieceStr) { | ||
return ''; | ||
} | ||
var parsed = url.parse(pieceStr, true); | ||
if (!first && parsed) { | ||
first = parsed; | ||
} | ||
extend(query, parsed.query); | ||
return parsed.pathname; | ||
}).filter(function(piece) { | ||
return !!piece; | ||
}); | ||
delete first.search; //we use query instead of search | ||
first.query = query; | ||
first.pathname = path.join.apply(path, paths).replace(new RegExp('\\' + path.sep, 'g'), '/'); | ||
return url.format(first); | ||
}; | ||
// Copyright 2016 Hound Technology, Inc. All rights reserved. | ||
const LIBHONEY_VERSION = "libhoney-js/4.0.0"; | ||
const LIBHONEY_VERSION = "libhoney-js/4.0.1"; | ||
const NODE_VERSION = `node/${process.version}`; | ||
@@ -507,3 +393,3 @@ | ||
eachPromise(batches, batch => { | ||
let url = urljoin(batch.apiHost, "/1/batch", batch.dataset); | ||
let url = urlJoin(batch.apiHost, "/1/batch", batch.dataset); | ||
let postReq = superagent.post(url); | ||
@@ -510,0 +396,0 @@ |
{ | ||
"name": "libhoney", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": " Honeycomb.io Javascript library", | ||
@@ -38,6 +38,6 @@ "bugs": "https://github.com/honeycombio/libhoney-js/issues", | ||
"@babel/preset-env": "^7.4.2", | ||
"@rollup/plugin-commonjs": "^22.0.2", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^14.1.0", | ||
"@rollup/plugin-replace": "^4.0.0", | ||
"@rollup/plugin-commonjs": "^24.0.0", | ||
"@rollup/plugin-json": "^6.0.0", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"@rollup/plugin-replace": "^5.0.2", | ||
"babel-jest": "^29.0.3", | ||
@@ -56,3 +56,3 @@ "babel-polyfill": "^6.26.0", | ||
"superagent-proxy": "^3.0.0", | ||
"urljoin": "^0.1.5" | ||
"url-join": "^5.0.0" | ||
}, | ||
@@ -66,2 +66,3 @@ "resolutions": { | ||
], | ||
"transformIgnorePatterns": ["/node_modules/(?!url-join)"], | ||
"testPathIgnorePatterns": [ | ||
@@ -68,0 +69,0 @@ "dist/", |
139642
3657
+ Addedurl-join@^5.0.0
+ Addedurl-join@5.0.0(transitive)
- Removedurljoin@^0.1.5
- Removedextend@2.0.2(transitive)
- Removedurljoin@0.1.5(transitive)