@segment/loosely-validate-event
Advanced tools
Comparing version 1.0.0 to 1.1.0
1.1.0 / 2017-02-02 | ||
================== | ||
* add optional `type` argument | ||
1.0.0 / 2017-02-02 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -11,6 +11,7 @@ var type = require('component-type') | ||
function looselyValidateEvent (event) { | ||
function looselyValidateEvent (event, type) { | ||
validateGenericEvent(event) | ||
assert(event.type, 'You must pass an event type.') | ||
switch (event.type) { | ||
type = type || event.type | ||
assert(type, 'You must pass an event type.') | ||
switch (type) { | ||
case 'track': | ||
@@ -27,3 +28,3 @@ return validateTrackEvent(event) | ||
default: | ||
assert(0, 'Invalid event type: "' + event.type + '"') | ||
assert(0, 'Invalid event type: "' + type + '"') | ||
} | ||
@@ -30,0 +31,0 @@ } |
{ | ||
"name": "@segment/loosely-validate-event", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -39,2 +39,6 @@ var test = require('ava') | ||
}, AssertionError) | ||
t.throws(() => { | ||
validate({ type: '' }, null) | ||
}, AssertionError) | ||
}) | ||
@@ -66,6 +70,5 @@ | ||
validate({ | ||
type: 'track', | ||
event: 'Did Something', | ||
anonymousId: 'banana' | ||
}) | ||
}, 'track') | ||
}) | ||
@@ -72,0 +75,0 @@ |
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
130844
294
1