@amplitude/utils
Advanced tools
Comparing version 1.5.3 to 1.5.4
@@ -8,5 +8,5 @@ /** | ||
private _promiseInProgress; | ||
addToQueue<T = any>(promiseGenerator: () => Promise<T>, limitInMs?: number): Promise<T>; | ||
addToQueue<T = any>(promiseGenerator: () => Promise<T>): Promise<T>; | ||
private _notifyUploadFinish; | ||
} | ||
//# sourceMappingURL=queue.d.ts.map |
@@ -16,4 +16,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
// or never expire, if limit is not set | ||
AsyncQueue.prototype.addToQueue = function (promiseGenerator, limitInMs) { | ||
if (limitInMs === void 0) { limitInMs = 0; } | ||
AsyncQueue.prototype.addToQueue = function (promiseGenerator) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -59,15 +58,4 @@ var _this = this; | ||
startPromise: startPromise, | ||
cancellingTimeout: null, | ||
}; | ||
_this._promiseQueue.push(queueObject); | ||
// If the limit exists, set a timeout to remove the callback and reject the promise | ||
if (limitInMs > 0) { | ||
queueObject.cancellingTimeout = setTimeout(function () { | ||
var callBackIndex = _this._promiseQueue.indexOf(queueObject); | ||
if (callBackIndex > -1) { | ||
_this._promiseQueue.splice(callBackIndex, 1); | ||
reject(new Error()); | ||
} | ||
}, limitInMs); | ||
} | ||
})]; | ||
@@ -84,6 +72,2 @@ case 1: return [2 /*return*/, _a.sent()]; | ||
if (oldestPromise !== undefined) { | ||
if (oldestPromise.cancellingTimeout !== null) { | ||
// Clear the timeout where we try to remove the callback and reject the promise. | ||
clearTimeout(oldestPromise.cancellingTimeout); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
@@ -90,0 +74,0 @@ oldestPromise.startPromise(); |
@@ -105,2 +105,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
}; | ||
case types_1.Status.Timeout: | ||
default: | ||
@@ -107,0 +108,0 @@ return { |
@@ -20,2 +20,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
} | ||
if (code === 408) { | ||
return types_1.Status.Timeout; | ||
} | ||
if (code >= 400 && code < 500) { | ||
@@ -22,0 +25,0 @@ return types_1.Status.Invalid; |
@@ -11,2 +11,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var hasUserId = event.user_id !== undefined; | ||
var hasEventProperties = event.event_properties !== undefined; | ||
if (!hasDeviceId && !hasUserId) { | ||
@@ -24,4 +25,8 @@ logger_1.logger.warn('Invalid event: expected at least one of device or user id'); | ||
} | ||
if (hasEventProperties && typeof event.event_properties !== 'object') { | ||
logger_1.logger.warn('Invalid event properties: expected event properties to be type object'); | ||
return false; | ||
} | ||
return true; | ||
}; | ||
//# sourceMappingURL=validate.js.map |
@@ -24,3 +24,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var e_1, _a; | ||
if (typeof property != 'string') | ||
if (typeof property !== 'string') | ||
return false; | ||
@@ -27,0 +27,0 @@ if (Array.isArray(value)) { |
@@ -8,5 +8,5 @@ /** | ||
private _promiseInProgress; | ||
addToQueue<T = any>(promiseGenerator: () => Promise<T>, limitInMs?: number): Promise<T>; | ||
addToQueue<T = any>(promiseGenerator: () => Promise<T>): Promise<T>; | ||
private _notifyUploadFinish; | ||
} | ||
//# sourceMappingURL=queue.d.ts.map |
@@ -14,4 +14,3 @@ import { __awaiter, __generator } from "tslib"; | ||
// or never expire, if limit is not set | ||
AsyncQueue.prototype.addToQueue = function (promiseGenerator, limitInMs) { | ||
if (limitInMs === void 0) { limitInMs = 0; } | ||
AsyncQueue.prototype.addToQueue = function (promiseGenerator) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -57,15 +56,4 @@ var _this = this; | ||
startPromise: startPromise, | ||
cancellingTimeout: null, | ||
}; | ||
_this._promiseQueue.push(queueObject); | ||
// If the limit exists, set a timeout to remove the callback and reject the promise | ||
if (limitInMs > 0) { | ||
queueObject.cancellingTimeout = setTimeout(function () { | ||
var callBackIndex = _this._promiseQueue.indexOf(queueObject); | ||
if (callBackIndex > -1) { | ||
_this._promiseQueue.splice(callBackIndex, 1); | ||
reject(new Error()); | ||
} | ||
}, limitInMs); | ||
} | ||
})]; | ||
@@ -82,6 +70,2 @@ case 1: return [2 /*return*/, _a.sent()]; | ||
if (oldestPromise !== undefined) { | ||
if (oldestPromise.cancellingTimeout !== null) { | ||
// Clear the timeout where we try to remove the callback and reject the promise. | ||
clearTimeout(oldestPromise.cancellingTimeout); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
@@ -88,0 +72,0 @@ oldestPromise.startPromise(); |
@@ -103,2 +103,3 @@ import { Status } from '@amplitude/types'; | ||
}; | ||
case Status.Timeout: | ||
default: | ||
@@ -105,0 +106,0 @@ return { |
@@ -18,2 +18,5 @@ import { Status } from '@amplitude/types'; | ||
} | ||
if (code === 408) { | ||
return Status.Timeout; | ||
} | ||
if (code >= 400 && code < 500) { | ||
@@ -20,0 +23,0 @@ return Status.Invalid; |
@@ -9,2 +9,3 @@ import { logger } from './logger'; | ||
var hasUserId = event.user_id !== undefined; | ||
var hasEventProperties = event.event_properties !== undefined; | ||
if (!hasDeviceId && !hasUserId) { | ||
@@ -22,4 +23,8 @@ logger.warn('Invalid event: expected at least one of device or user id'); | ||
} | ||
if (hasEventProperties && typeof event.event_properties !== 'object') { | ||
logger.warn('Invalid event properties: expected event properties to be type object'); | ||
return false; | ||
} | ||
return true; | ||
}; | ||
//# sourceMappingURL=validate.js.map |
@@ -22,3 +22,3 @@ import { __values } from "tslib"; | ||
var e_1, _a; | ||
if (typeof property != 'string') | ||
if (typeof property !== 'string') | ||
return false; | ||
@@ -25,0 +25,0 @@ if (Array.isArray(value)) { |
{ | ||
"name": "@amplitude/utils", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"description": "Utility functions for the Amplitude JavaScript SDK", | ||
@@ -19,7 +19,7 @@ "repository": "git://github.com/amplitude/Amplitude-Node.git", | ||
"dependencies": { | ||
"@amplitude/types": "^1.5.3", | ||
"@amplitude/types": "^1.5.4", | ||
"tslib": "^1.9.3" | ||
}, | ||
"devDependencies": { | ||
"@amplitude/eslint-config-typescript": "^1.3.0", | ||
"@amplitude/eslint-config-typescript": "^1.5.4", | ||
"@types/jest": "^26.0.14", | ||
@@ -52,3 +52,3 @@ "@types/jsdom": "^16.2.5", | ||
"sideEffects": false, | ||
"gitHead": "baa59364b3567af99438b3985a19d15ebba09378" | ||
"gitHead": "46fced588f3a644993cc693501ee8755c8a6d89a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
107864
1170
Updated@amplitude/types@^1.5.4