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 0.6.1 to 0.7.0

5

dist/args.js

@@ -27,4 +27,3 @@ "use strict";

});
var propsArray = (0, _props.propsToArray)(matches.props);
matches.propsArray = propsArray.length ? propsArray : undefined;
matches.props = (0, _props.propsToArray)(matches.props);
return matches;

@@ -38,3 +37,3 @@ }

memo.op = arg;
} else if (!memo.props && typeof arg === "string") {
} else if (!memo.props && (typeof arg === "string" || Array.isArray(arg))) {
memo.props = arg;

@@ -41,0 +40,0 @@ } else if (!memo.fn && typeof arg === "function") {

34

dist/keys.js

@@ -23,9 +23,15 @@ "use strict";

prep = _ref$prep === void 0 ? "" : _ref$prep,
_ref$props = _ref.props,
props = _ref$props === void 0 ? "" : _ref$props;
props = _ref.props;
props = props.replace(_props.propVarRegex, "*");
return "".concat(prep, ":").concat(op, ":").concat(props);
return "".concat(prep, ":").concat(op, ":").concat(eventKeyProps(props));
}
function eventKeyProps(props) {
if (props) {
return props.join(".").replace(_props.propVarRegex, "*");
} else {
return "";
}
}
function buildKeys(args) {

@@ -45,4 +51,3 @@ args.prep = args.prep || args.state.prep;

var op = state.op,
props = state.props,
propsArray = state.propsArray;
props = state.props;
var keys = onKeys({

@@ -65,8 +70,8 @@ prep: prep,

if (props) {
for (var x = 0; x < propsArray.length - 1; x++) {
var newProps = propsArray.slice(0, x + 1);
for (var x = 0; x < props.length - 1; x++) {
var newProps = props.slice(0, x + 1);
var key = eventKey({
op: op,
prep: prep,
props: newProps.join(".")
props: newProps
});

@@ -99,4 +104,3 @@ keys.add(key);

var op = state.op,
props = state.props,
propsArray = state.propsArray;
props = state.props;
var keys = new Set([eventKey({

@@ -109,3 +113,3 @@ op: op,

if (!subscribe) {
var wild = wildProps(propsArray);
var wild = wildProps(props);

@@ -124,7 +128,7 @@ if (wild) {

function wildProps(propsArray) {
if (propsArray) {
return propsArray.slice(0, propsArray.length - 1).concat(["*"]).join(".");
function wildProps(props) {
if (props && props.length) {
return props.slice(0, props.length - 1).concat(["*"]);
}
}
//# sourceMappingURL=keys.js.map

@@ -25,3 +25,3 @@ "use strict";

options = state.options,
propsArray = state.propsArray;
props = state.props;

@@ -34,3 +34,3 @@ if (emit) {

options: options,
props: propsArray,
props: props,
signal: {}

@@ -45,3 +45,3 @@ }

options: options,
propsArray: propsArray
props: props
});

@@ -52,6 +52,6 @@ return (0, _objectSpread4.default)({}, newOptions, (0, _defineProperty2.default)({

listenArgs: args,
listenProps: propsArray,
listenProps: props.length ? props : undefined,
op: emitEvent ? emitEvent.op : undefined,
options: newOptions && Object.keys(newOptions).length ? newOptions : undefined,
props: emitEvent ? emitEvent.props : undefined,
props: emitEvent ? emitEvent.props.length ? emitEvent.props : undefined : undefined,
signal: emitEvent ? emitEvent.signal : undefined

@@ -66,8 +66,8 @@ }

options = _ref2.options,
propsArray = _ref2.propsArray;
props = _ref2.props;
if (emitEvent) {
var wildcardVar = (0, _props.propVar)({
emitPropsArray: emitEvent.props,
propsArray: propsArray
emitProps: emitEvent.props,
props: props
});

@@ -74,0 +74,0 @@ return Object.assign({}, emitEvent.options, options, wildcardVar);

@@ -45,6 +45,6 @@ "use strict";

function propVar(_ref) {
var emitPropsArray = _ref.emitPropsArray,
propsArray = _ref.propsArray;
var emitProps = _ref.emitProps,
props = _ref.props;
if (!propsArray) {
if (!props) {
return;

@@ -55,3 +55,3 @@ }

var _ref2 = propsArray.reduce(propVarReduce, undefined) || [],
var _ref2 = props.reduce(propVarReduce, undefined) || [],
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),

@@ -62,3 +62,3 @@ index = _ref3[0],

if (match) {
propVar[match[1]] = emitPropsArray[index];
propVar[match[1]] = emitProps[index];
}

@@ -65,0 +65,0 @@

@@ -10,9 +10,3 @@ // Helpers

const matches = args.reduce(matchArg, { events })
const propsArray = propsToArray(matches.props)
matches.propsArray = propsArray.length
? propsArray
: undefined
matches.props = propsToArray(matches.props)
return matches

@@ -30,3 +24,6 @@ }

memo.op = arg
} else if (!memo.props && typeof arg === "string") {
} else if (
!memo.props &&
(typeof arg === "string" || Array.isArray(arg))
) {
memo.props = arg

@@ -33,0 +30,0 @@ } else if (!memo.fn && typeof arg === "function") {

@@ -6,8 +6,15 @@ import { propVarRegex } from "./props"

prep = "",
props = "",
props,
} = {}) {
props = props.replace(propVarRegex, "*")
return `${prep}:${op}:${props}`
return `${prep}:${op}:${eventKeyProps(props)}`
}
function eventKeyProps(props) {
if (props) {
return props.join(".").replace(propVarRegex, "*")
} else {
return ""
}
}
export function buildKeys(args) {

@@ -24,3 +31,3 @@ args.prep = args.prep || args.state.prep

} = {}) {
const { op, props, propsArray } = state
const { op, props } = state
const keys = onKeys({

@@ -38,4 +45,4 @@ prep,

if (props) {
for (let x = 0; x < propsArray.length - 1; x++) {
const newProps = propsArray.slice(0, x + 1)
for (let x = 0; x < props.length - 1; x++) {
const newProps = props.slice(0, x + 1)

@@ -45,3 +52,3 @@ const key = eventKey({

prep,
props: newProps.join("."),
props: newProps,
})

@@ -69,7 +76,7 @@

} = {}) {
const { op, props, propsArray } = state
const { op, props } = state
const keys = new Set([eventKey({ op, prep, props })])
if (!subscribe) {
const wild = wildProps(propsArray)
const wild = wildProps(props)

@@ -84,9 +91,6 @@ if (wild) {

function wildProps(propsArray) {
if (propsArray) {
return propsArray
.slice(0, propsArray.length - 1)
.concat(["*"])
.join(".")
function wildProps(props) {
if (props && props.length) {
return props.slice(0, props.length - 1).concat(["*"])
}
}
import { propVar } from "./props"
export function buildPayload({ emit, opts = {}, state }) {
const { args, events, op, options, propsArray } = state
const { args, events, op, options, props } = state

@@ -13,3 +13,3 @@ if (emit) {

options,
props: propsArray,
props,
signal: {},

@@ -26,3 +26,3 @@ },

options,
propsArray,
props,
})

@@ -35,3 +35,3 @@

listenArgs: args,
listenProps: propsArray,
listenProps: props.length ? props : undefined,
op: emitEvent ? emitEvent.op : undefined,

@@ -42,3 +42,7 @@ options:

: undefined,
props: emitEvent ? emitEvent.props : undefined,
props: emitEvent
? emitEvent.props.length
? emitEvent.props
: undefined
: undefined,
signal: emitEvent ? emitEvent.signal : undefined,

@@ -51,7 +55,7 @@ },

function buildOptions({ emitEvent, options, propsArray }) {
function buildOptions({ emitEvent, options, props }) {
if (emitEvent) {
const wildcardVar = propVar({
emitPropsArray: emitEvent.props,
propsArray,
emitProps: emitEvent.props,
props,
})

@@ -58,0 +62,0 @@

@@ -28,4 +28,4 @@ // Constants

export function propVar({ emitPropsArray, propsArray }) {
if (!propsArray) {
export function propVar({ emitProps, props }) {
if (!props) {
return

@@ -36,6 +36,6 @@ }

const [index, match] =
propsArray.reduce(propVarReduce, undefined) || []
props.reduce(propVarReduce, undefined) || []
if (match) {
propVar[match[1]] = emitPropsArray[index]
propVar[match[1]] = emitProps[index]
}

@@ -42,0 +42,0 @@

@@ -15,3 +15,3 @@ {

],
"version": "0.6.1",
"version": "0.7.0",
"description": "Build beautiful and extensible eventing APIs",

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

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

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