Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot-event

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-event - npm Package Compare versions

Comparing version 3.0.7 to 3.0.8

optTest.js

11

dot.js

@@ -195,11 +195,16 @@ /*global Map Promise Set*/

var isFn = t === fnType,
var isFirst = i === 0,
isFn = t === fnType,
isLast = i === a.length - 1,
isStr = t === strType
if (isStr && (i == 0 || i < a.length - 1)) {
if (isStr && (isFirst || !isLast)) {
k.arr = k.arr.concat(opt.split(period))
}
if (!isFirst || (isFirst && !isStr)) {
o.opt = opt ? opt : o.opt
}
o.fn = isFn ? opt : o.fn
o.opt = opt ? opt : o.opt
}

@@ -206,0 +211,0 @@

@@ -9,158 +9,144 @@ /* eslint-env jest */

test("on empty", function() {
var called
describe("dot", function() {
test("on empty", function() {
var called
dot.on(function() {
called = true
})
dot.on(function() {
called = true
})
return dot().then(function() {
expect(called).toBe(true)
return dot().then(function() {
expect(called).toBe(true)
})
})
})
test("on props", function() {
var called
test("on props", function() {
var called
dot.on("a", "b.c", function() {
called = true
})
dot.on("a", "b.c", function() {
called = true
})
return dot("a.b.c").then(function() {
expect(called).toBe(true)
return dot("a.b.c").then(function() {
expect(called).toBe(true)
})
})
})
test("on args", function() {
var args
test("on args", function() {
var args
dot.on("a.b", "c", function(a) {
args = a
})
dot.on("a.b", "c", function(a) {
args = a
})
return dot("a.b.c", { test: true }).then(function() {
expect(args).toEqual({
dot: dot,
opt: { test: true },
prop: { arr: ["b", "c"], ns: "a", str: "b.c" },
return dot("a.b.c", { test: true }).then(function() {
expect(args).toEqual({
dot: dot,
opt: { test: true },
prop: { arr: ["b", "c"], ns: "a", str: "b.c" },
})
})
})
})
test("on before/after", function() {
var order = []
test("on before/after", function() {
var order = []
dot.on("after.a", "b", "c", function() {
order.push(3)
})
dot.on("after.a", "b", "c", function() {
order.push(3)
})
dot.on("a", "b", "c", function() {
order.push(2)
})
dot.on("a", "b", "c", function() {
order.push(2)
})
dot.on("before.a.b", "c", function() {
order.push(1)
})
dot.on("before.a.b", "c", function() {
order.push(1)
})
return dot("a.b.c").then(function() {
expect(order).toEqual([1, 2, 3])
return dot("a.b.c").then(function() {
expect(order).toEqual([1, 2, 3])
})
})
})
test("on cancel", function() {
var called
test("on cancel", function() {
var called
dot.on("before.a.b", "c", function(opt, sig) {
sig.cancel = true
})
dot.on("before.a.b", "c", function(opt, sig) {
sig.cancel = true
})
dot.on("a", "b", "c", function() {
called = true
})
dot.on("a", "b", "c", function() {
called = true
})
return dot("a.b.c").then(function() {
expect(called).not.toBe(true)
return dot("a.b.c").then(function() {
expect(called).not.toBe(true)
})
})
})
test("on value", function() {
dot.on("before.a.b", "c", function(opt, sig) {
sig.value = true
})
test("on value", function() {
dot.on("before.a.b", "c", function(opt, sig) {
sig.value = true
})
expect(dot("a.b.c")).toBe(true)
})
test("onAny empty", function() {
var called
dot.onAny(function() {
called = true
expect(dot("a.b.c")).toBe(true)
})
return dot("a.b.c").then(function() {
expect(called).toBe(true)
})
})
test("onAny empty", function() {
var called
test("onAny props", function() {
var called
dot.onAny(function() {
called = true
})
dot.onAny("a", function() {
called = true
return dot("a.b.c").then(function() {
expect(called).toBe(true)
})
})
return dot("a.b.c").then(function() {
expect(called).toBe(true)
})
})
test("onAny props", function() {
var called
test("onAny before/after", function() {
var order = []
dot.onAny("a", function() {
called = true
})
dot.onAny("after.a.b", function() {
order.push(3)
return dot("a.b.c").then(function() {
expect(called).toBe(true)
})
})
dot.onAny("a", function() {
order.push(2)
})
test("onAny before/after", function() {
var order = []
dot.onAny("before.a", function() {
order.push(1)
})
dot.onAny("after.a.b", function() {
order.push(3)
})
return dot("a.b.c").then(function() {
expect(order).toEqual([1, 2, 3])
})
})
dot.onAny("a", function() {
order.push(2)
})
test("off", function() {
var called
dot.onAny("before.a", function() {
order.push(1)
})
var off = dot.on("a", "b", "c", function() {
called = true
return dot("a.b.c").then(function() {
expect(order).toEqual([1, 2, 3])
})
})
off()
test("off", function() {
var called
return dot("a.b.c").then(function() {
expect(called).not.toBe(true)
})
})
var off = dot.on("a", "b", "c", function() {
called = true
})
test("no opts, multiple strings", function() {
var args
off()
dot.on("a.b", "c", function(a) {
args = a
})
return dot("a.b.c", "hi").then(function() {
expect(args).toEqual({
dot: dot,
opt: "hi",
prop: { arr: ["b", "c"], ns: "a", str: "b.c" },
return dot("a.b.c").then(function() {
expect(called).not.toBe(true)
})
})
})
{
"name": "dot-event",
"version": "3.0.7",
"version": "3.0.8",
"description": "Powerful event emitter",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc