Comparing version 1.5.3-alpha.0 to 1.6.0-alpha.0
@@ -0,1 +1,9 @@ | ||
window['__REFFECTS_DEV_TOOLS__'] = { | ||
...window['__REFFECTS_DEV_TOOLS__'], | ||
toggleVerbosity () { | ||
verbosityOn = !verbosityOn; | ||
console.log('Verbosity ' + verbosityOn ? 'on' : 'off'); | ||
}, | ||
}; | ||
var verbosityOn = process.env.NODE_ENV === 'development'; | ||
@@ -171,6 +179,7 @@ | ||
const effects = { | ||
dispatch(eventId, payload = {}) { | ||
dispatch(event, payload = {}) { | ||
return { | ||
dispatch: { | ||
id: eventId, payload | ||
id: event.id ?? event, | ||
payload: event.payload ?? payload | ||
} | ||
@@ -177,0 +186,0 @@ }; |
@@ -5,2 +5,10 @@ 'use strict'; | ||
window['__REFFECTS_DEV_TOOLS__'] = { | ||
...window['__REFFECTS_DEV_TOOLS__'], | ||
toggleVerbosity () { | ||
verbosityOn = !verbosityOn; | ||
console.log('Verbosity ' + verbosityOn ? 'on' : 'off'); | ||
}, | ||
}; | ||
var verbosityOn = process.env.NODE_ENV === 'development'; | ||
@@ -176,6 +184,7 @@ | ||
const effects = { | ||
dispatch(eventId, payload = {}) { | ||
dispatch(event, payload = {}) { | ||
return { | ||
dispatch: { | ||
id: eventId, payload | ||
id: event.id ?? event, | ||
payload: event.payload ?? payload | ||
} | ||
@@ -182,0 +191,0 @@ }; |
@@ -7,2 +7,10 @@ (function (global, factory) { | ||
window['__REFFECTS_DEV_TOOLS__'] = { | ||
...window['__REFFECTS_DEV_TOOLS__'], | ||
toggleVerbosity () { | ||
verbosityOn = !verbosityOn; | ||
console.log('Verbosity ' + verbosityOn ? 'on' : 'off'); | ||
}, | ||
}; | ||
var verbosityOn = process.env.NODE_ENV === 'development'; | ||
@@ -178,6 +186,7 @@ | ||
const effects = { | ||
dispatch(eventId, payload = {}) { | ||
dispatch(event, payload = {}) { | ||
return { | ||
dispatch: { | ||
id: eventId, payload | ||
id: event.id ?? event, | ||
payload: event.payload ?? payload | ||
} | ||
@@ -184,0 +193,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).reffects={})}(this,(function(e){"use strict";var n="development"===process.env.NODE_ENV,t="development"===process.env.NODE_ENV&&"undefined"!=typeof window;const o={effects:{},coeffects:{},events:{}};let c={...o},i={};function f(e){w(e,"coeffect");const t=function(e){return O(e)?{id:e}:e}(e),o=g(t.id)(t.data);return function({id:e,data:t},o){n&&(console.groupCollapsed("Extracting values of coeffect: "+e),console.info("Coeffect id:",e),console.info("Coeffect data:",t||`The ${e} coeffect needs no data`),console.info("Extracted value:",o),console.groupEnd())}(t,o),o}function r(e){e&&Object.entries(e).forEach((function([e,t]){!function(e,t){n&&(console.groupCollapsed("Applying effect: "+e),console.info("Effect id:",e),console.info("Effect data:",t||`The ${e} effect needs no data`),console.groupEnd())}(e,t);v(e)(t)}))}function s(e){w(e,"event");const t=function(e){return O(e)?{id:e}:e}(e);!function({id:e,payload:t}){n&&(console.groupCollapsed("Dispatching event: "+e),console.info("EventId:",e),console.info("Payload:",t||`The ${e} event has no payload.`),console.groupEnd())}(t);const{id:o,payload:c}=t;r(_(o)(function(e){return e.reduce((function(e,n){return Object.assign({},e,f(n))}),{})}(i[o]),c))}function a(e){e.forEach(s)}function d(e){setTimeout((function(){s(e)}),e.milliseconds)}function l(e,n){if("development"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV)return e;if(!n.every(e=>void 0!==e))throw Error("Not defined coeffect.");return function(t,o){const c=n.map(e=>O(e)?e:e.id),i=Object.keys(t||{}).filter(e=>!c.includes(e));if(i.length>0)throw Error("Missing coeffects "+i.join(","));return e(t,o)}}function u(e,n,t=[]){y("events",e,l(n,t)),i[e]=t}function p(e,n){y("effects",e,n)}p("dispatch",s),p("dispatchMany",a),p("dispatchLater",d);const E={dispatch:(e,n={})=>({dispatch:{id:e,payload:n}}),dispatchMany:e=>({dispatchMany:e}),dispatchLater:({id:e,milliseconds:n,payload:t={}})=>({dispatchLater:{id:e,milliseconds:n,payload:t}})};function h(e,n){const t=c[e][n];if(!t)throw Error(`There is no handler called '${n}'.`);return t}function y(e,n,t){c[e][n]=t}function g(e){return h("coeffects",e)}function v(e){return h("effects",e)}function _(e){return h("events",e)}const b=Object.prototype.toString;function O(e){const n=typeof e;return"string"===n||"object"===n&&null!=e&&!Array.isArray(e)&&"[object String]"===b.call(e)}function w(e,n){const t={coeffect:"It must be an object with the following format `{ id: 'COEFFECT_ID', data: <Object | any> }`, or a string if no data is needed: 'EVENT_ID'",event:"It must be an object with the following format `{ id: 'EVENT_ID', payload: <Object | any> }`, or a string if no payload is needed: 'EVENT_ID'"};e||function(e){throw Error("Not defined "+e+".\n"+t[e])}(n),O(e)||null!=e.id||function(e){throw Error("Not valid "+e+".\n"+t[e])}(n)}t&&(window.__REFFECTS_DEV_TOOLS__={...window.__REFFECTS_DEV_TOOLS__,dispatch:s,dispatchMany:a}),e.clearHandlers=function(){c={...o},i={}},e.coeffect=function(e,n){return{id:e,data:n}},e.disableVerbosity=function(){n=!1},e.dispatch=s,e.dispatchLater=d,e.dispatchMany=a,e.effects=E,e.getCoeffectHandler=g,e.getEffectHandler=v,e.getEventHandler=_,e.registerCoeffectHandler=function(e,n){y("coeffects",e,n)},e.registerEffectHandler=p,e.registerEventHandler=u,e.registerEventsDelegation=function(e,n){e.forEach((function(e){u(e,(function(e,t){return{dispatch:{id:n,payload:t}}}))}))},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).reffects={})}(this,(function(e){"use strict";window.__REFFECTS_DEV_TOOLS__={...window.__REFFECTS_DEV_TOOLS__,toggleVerbosity(){n=!n,console.log("on")}};var n="development"===process.env.NODE_ENV,t="development"===process.env.NODE_ENV&&"undefined"!=typeof window;const o={effects:{},coeffects:{},events:{}};let c={...o},i={};function f(e){w(e,"coeffect");const t=function(e){return b(e)?{id:e}:e}(e),o=y(t.id)(t.data);return function({id:e,data:t},o){n&&(console.groupCollapsed("Extracting values of coeffect: "+e),console.info("Coeffect id:",e),console.info("Coeffect data:",t||`The ${e} coeffect needs no data`),console.info("Extracted value:",o),console.groupEnd())}(t,o),o}function r(e){e&&Object.entries(e).forEach((function([e,t]){!function(e,t){n&&(console.groupCollapsed("Applying effect: "+e),console.info("Effect id:",e),console.info("Effect data:",t||`The ${e} effect needs no data`),console.groupEnd())}(e,t);g(e)(t)}))}function s(e){w(e,"event");const t=function(e){return b(e)?{id:e}:e}(e);!function({id:e,payload:t}){n&&(console.groupCollapsed("Dispatching event: "+e),console.info("EventId:",e),console.info("Payload:",t||`The ${e} event has no payload.`),console.groupEnd())}(t);const{id:o,payload:c}=t;r(v(o)(function(e){return e.reduce((function(e,n){return Object.assign({},e,f(n))}),{})}(i[o]),c))}function d(e){e.forEach(s)}function a(e){setTimeout((function(){s(e)}),e.milliseconds)}function l(e,n){if("development"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV)return e;if(!n.every(e=>void 0!==e))throw Error("Not defined coeffect.");return function(t,o){const c=n.map(e=>b(e)?e:e.id),i=Object.keys(t||{}).filter(e=>!c.includes(e));if(i.length>0)throw Error("Missing coeffects "+i.join(","));return e(t,o)}}function u(e,n,t=[]){_("events",e,l(n,t)),i[e]=t}function p(e,n){_("effects",e,n)}p("dispatch",s),p("dispatchMany",d),p("dispatchLater",a);const E={dispatch:(e,n={})=>({dispatch:{id:e.id??e,payload:e.payload??n}}),dispatchMany:e=>({dispatchMany:e}),dispatchLater:({id:e,milliseconds:n,payload:t={}})=>({dispatchLater:{id:e,milliseconds:n,payload:t}})};function h(e,n){const t=c[e][n];if(!t)throw Error(`There is no handler called '${n}'.`);return t}function _(e,n,t){c[e][n]=t}function y(e){return h("coeffects",e)}function g(e){return h("effects",e)}function v(e){return h("events",e)}const O=Object.prototype.toString;function b(e){const n=typeof e;return"string"===n||"object"===n&&null!=e&&!Array.isArray(e)&&"[object String]"===O.call(e)}function w(e,n){const t={coeffect:"It must be an object with the following format `{ id: 'COEFFECT_ID', data: <Object | any> }`, or a string if no data is needed: 'EVENT_ID'",event:"It must be an object with the following format `{ id: 'EVENT_ID', payload: <Object | any> }`, or a string if no payload is needed: 'EVENT_ID'"};e||function(e){throw Error("Not defined "+e+".\n"+t[e])}(n),b(e)||null!=e.id||function(e){throw Error("Not valid "+e+".\n"+t[e])}(n)}t&&(window.__REFFECTS_DEV_TOOLS__={...window.__REFFECTS_DEV_TOOLS__,dispatch:s,dispatchMany:d}),e.clearHandlers=function(){c={...o},i={}},e.coeffect=function(e,n){return{id:e,data:n}},e.disableVerbosity=function(){n=!1},e.dispatch=s,e.dispatchLater=a,e.dispatchMany=d,e.effects=E,e.getCoeffectHandler=y,e.getEffectHandler=g,e.getEventHandler=v,e.registerCoeffectHandler=function(e,n){_("coeffects",e,n)},e.registerEffectHandler=p,e.registerEventHandler=u,e.registerEventsDelegation=function(e,n){e.forEach((function(e){u(e,(function(e,t){return{dispatch:{id:n,payload:t}}}))}))},Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "reffects", | ||
"version": "1.5.3-alpha.0", | ||
"version": "1.6.0-alpha.0", | ||
"description": "", | ||
@@ -31,3 +31,3 @@ "source": "src/index.js", | ||
}, | ||
"gitHead": "00bfa24d433729ae96620d1968ff3f7e3ffd6daf" | ||
"gitHead": "eec49b70d524ebcb64e4d03c251ca11569d2903e" | ||
} |
@@ -0,1 +1,9 @@ | ||
window['__REFFECTS_DEV_TOOLS__'] = { | ||
...window['__REFFECTS_DEV_TOOLS__'], | ||
toggleVerbosity () { | ||
verbosityOn = !verbosityOn; | ||
console.log('Verbosity ' + verbosityOn ? 'on' : 'off') | ||
}, | ||
}; | ||
var verbosityOn = process.env.NODE_ENV === 'development'; | ||
@@ -171,6 +179,7 @@ | ||
const effects = { | ||
dispatch(eventId, payload = {}) { | ||
dispatch(event, payload = {}) { | ||
return { | ||
dispatch: { | ||
id: eventId, payload | ||
id: event.id ?? event, | ||
payload: event.payload ?? payload | ||
} | ||
@@ -177,0 +186,0 @@ }; |
@@ -206,2 +206,8 @@ import * as reffects from '.'; | ||
}); | ||
expect(reffects.effects.dispatch({id: 'eventWithPayload', payload: {a: 1}})).toEqual({ | ||
dispatch: { id: 'eventWithPayload', payload: {a: 1} } | ||
}); | ||
expect(reffects.effects.dispatch({id: 'event'})).toEqual({ | ||
dispatch: { id: 'event', payload: {} } | ||
}); | ||
expect(reffects.effects.dispatch('anotherEvent', { a: 1 })).toEqual({ | ||
@@ -208,0 +214,0 @@ dispatch: { id: 'anotherEvent', payload: { a: 1} } |
Sorry, the diff of this file is not supported yet
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
71323
1482
1