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

@idigi/events

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idigi/events - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

3

package.json
{
"name": "@idigi/events",
"version": "1.0.11",
"version": "1.0.12",
"main": "src/index.js",
"type": "module",
"engines": {

@@ -7,0 +6,0 @@ "node": ">=12.14.1"

@@ -1,1 +0,1 @@

import lodash from"lodash";class Events{get eHandlers(){return this._eHandlers}get eStopped(){return this._eStopped}get eDefs(){return this._eDefs}constructor(s={}){this.CLASS="",this.info=Object(),this.statuses=Object(),this.dates=Object(),this._eHandlers={},this._eStopped=!1,this._eDefs=[{ev:"all"}];for(const[e,t]of Object.entries(s))this[Events._public.includes(e)?e:`_${e}`]=t}eResume(){this._eStopped=!1}eStop(){this._eStopped=!0}_eArgs(s){return s}async _eSync(s,e,t,...n){const i=e.shift();if(!i)return[];let o=[];try{const e=await i(this._eArgs(t),...n);Array.isArray(e)&&o.push(...e)}catch(e){console.error(`Error in "${s}" consumer`,e)}if(e.length){const i=await this._eSync(s,e,t,...n);Array.isArray(i)&&i.forEach(s=>null==o?void 0:o.push(s))}return o}async _emit(s,e,t,n,...i){if(!this._eHandlers[s].length)return;const o=await this._eSync(s,this._eHandlers[s].slice(0),Object.assign({_eName:s,_eNames:e},n),...i);Array.isArray(o)&&t.push(...o)}async emit(s,e={},...t){if(this._eStopped)return[];let n=[];const i=this._eNames([s,this._eDefs]),o=Date.now().toString();if(e._eFor)for(const s of i)await this._emit(s,i,n,Object.assign({_eId:o},e),t);else await Promise.all(i.map(s=>this._emit(s,i,n,Object.assign({_eId:o},e),t)));return n}async on(s,e){for(const t of this._eNames([s]))this._eHandlers[t].push(e)}_eNames(s){const e=[];for(const t of s)for(const{ev:s,reg:n}of Array.isArray(t)?t.map(s=>"object"==typeof s?s.ev?s:Object.assign(Object.assign({},s),{ev:Events.slugify(s.ev)}):{ev:Events.slugify(s)}):["object"==typeof t?t:{ev:Events.slugify(t)}])n&&e.push(...Object.keys(this._eHandlers).filter(s=>s.match(n))),s&&(e.push(s),this._eHandlers[s]||(this._eHandlers[s]=[]));return lodash.uniq(e)}static slugify(s,e="toLowerCase"){const t=lodash.kebabCase(s);return e?t[e]():t}slugify(s,e){return Events.slugify(s,e)}get name(){return this._name||this.CLASS}set name(s){this._name=s}get slug(){return this._slug||this.slugify(this._name||this.CLASS)}set slug(s){this._slug=this.slugify(s)}get tags(){return this._tags||(""!==this.slug?[this.slug]:[])}set tags(s){this._tags=lodash.uniq(s.map(s=>this.slugify(s)).filter(s=>""!=s))}toJson(s={ignores:"_toJsonIgnores|_eStopped|_eHandlers|_eDefs"}){const e=s.values||this;let t=e;if(Array.isArray(e)){t=[];for(let n of e)"object"==typeof n?t.push("function"==typeof n.toJson?n.toJson(Object.assign(Object.assign({},s),{values:n})):this.toJson(Object.assign(Object.assign({},s),{values:n}))):t.push(n)}else if("object"==typeof e){t={};for(let n of lodash.uniq((e._toJsonGets||[]).concat(Object.keys(e)))){let i=e[n];if(s.ignores&&n.match(new RegExp(s.ignores,"g"))||e._toJsonIgnores&&n.match(new RegExp(e._toJsonIgnores,"g")))continue;n.match(/^_/)&&void 0!==e[n.replace(/^_/,"")]&&(i=e[n=n.replace(/^_/,"")]);const o=(e._toJsonActions||{})[n]||{};this[o.action||"_toJsonObjAssign"]({v:i,k:n,re:t,opts:s,action:o,this:e})}}return t}_toJsonObjAssign(s){return s.v&&"object"==typeof s.v?"function"==typeof s.v.toJson?s.re[s.k]=s.v.toJson(Object.assign(Object.assign({},s.opts),{values:s.v})):s.re[s.k]=this.toJson(Object.assign(Object.assign({},s.opts),{values:s.v})):s.re[s.k]=s.v,s.re[s.k]||s.def||{}}_toJsonObjArray(s){if("object"==typeof s.v&&!Array.isArray(s.v)){const e=s.action.key||"key";s.re[s.k]=Object.entries(s.v).map(([t,n])=>{const i=this._toJsonObjAssign(Object.assign(Object.assign({},s),{re:{},k:t,v:n}));return"object"==typeof i&&(i[e]=i[e]||t),i})}}}Events._public=["CLASS","version","colors","statuses","info","i18n","name","slug","position","emoji","icon","pic","desc","type","kind","dates"];export default Events;module.exports = exports.default;
import lodash from "lodash";class Events{get eHandlers(){return this._eHandlers}get eStopped(){return this._eStopped}get eDefs(){return this._eDefs}constructor(s={}){this.CLASS="",this.info=Object(),this.statuses=Object(),this.dates=Object(),this._eHandlers={},this._eStopped=!1,this._eDefs=[{ev:"all"}];for(const[e,t]of Object.entries(s))this[Events._public.includes(e)?e:`_${e}`]=t}eResume(){this._eStopped=!1}eStop(){this._eStopped=!0}_eArgs(s){return s}async _eSync(s,e,t,...n){const i=e.shift();if(!i)return[];let o=[];try{const e=await i(this._eArgs(t),...n);Array.isArray(e)&&o.push(...e)}catch(e){console.error(`Error in "${s}" consumer`,e)}if(e.length){const i=await this._eSync(s,e,t,...n);Array.isArray(i)&&i.forEach(s=>null==o?void 0:o.push(s))}return o}async _emit(s,e,t,n,...i){if(!this._eHandlers[s].length)return;const o=await this._eSync(s,this._eHandlers[s].slice(0),Object.assign({_eName:s,_eNames:e},n),...i);Array.isArray(o)&&t.push(...o)}async emit(s,e={},...t){if(this._eStopped)return[];let n=[];const i=this._eNames([s,this._eDefs]),o=Date.now().toString();if(e._eFor)for(const s of i)await this._emit(s,i,n,Object.assign({_eId:o},e),t);else await Promise.all(i.map(s=>this._emit(s,i,n,Object.assign({_eId:o},e),t)));return n}async on(s,e){for(const t of this._eNames([s]))this._eHandlers[t].push(e)}_eNames(s){const e=[];for(const t of s)for(const{ev:s,reg:n}of Array.isArray(t)?t.map(s=>"object"==typeof s?s.ev?s:Object.assign(Object.assign({},s),{ev:Events.slugify(s.ev)}):{ev:Events.slugify(s)}):["object"==typeof t?t:{ev:Events.slugify(t)}])n&&e.push(...Object.keys(this._eHandlers).filter(s=>s.match(n))),s&&(e.push(s),this._eHandlers[s]||(this._eHandlers[s]=[]));return lodash.uniq(e)}static slugify(s,e="toLowerCase"){const t=lodash.kebabCase(s);return e?t[e]():t}slugify(s,e){return Events.slugify(s,e)}get name(){return this._name||this.CLASS}set name(s){this._name=s}get slug(){return this._slug||this.slugify(this._name||this.CLASS)}set slug(s){this._slug=this.slugify(s)}get tags(){return this._tags||(""!==this.slug?[this.slug]:[])}set tags(s){this._tags=lodash.uniq(s.map(s=>this.slugify(s)).filter(s=>""!=s))}toJson(s={ignores:"_toJsonIgnores|_eStopped|_eHandlers|_eDefs"}){const e=s.values||this;let t=e;if(Array.isArray(e)){t=[];for(let n of e)"object"==typeof n?t.push("function"==typeof n.toJson?n.toJson(Object.assign(Object.assign({},s),{values:n})):this.toJson(Object.assign(Object.assign({},s),{values:n}))):t.push(n)}else if("object"==typeof e){t={};for(let n of lodash.uniq((e._toJsonGets||[]).concat(Object.keys(e)))){let i=e[n];if(s.ignores&&n.match(new RegExp(s.ignores,"g"))||e._toJsonIgnores&&n.match(new RegExp(e._toJsonIgnores,"g")))continue;n.match(/^_/)&&void 0!==e[n.replace(/^_/,"")]&&(i=e[n=n.replace(/^_/,"")]);const o=(e._toJsonActions||{})[n]||{};this[o.action||"_toJsonObjAssign"]({v:i,k:n,re:t,opts:s,action:o,this:e})}}return t}_toJsonObjAssign(s){return s.v&&"object"==typeof s.v?"function"==typeof s.v.toJson?s.re[s.k]=s.v.toJson(Object.assign(Object.assign({},s.opts),{values:s.v})):s.re[s.k]=this.toJson(Object.assign(Object.assign({},s.opts),{values:s.v})):s.re[s.k]=s.v,s.re[s.k]||s.def||{}}_toJsonObjArray(s){if("object"==typeof s.v&&!Array.isArray(s.v)){const e=s.action.key||"key";s.re[s.k]=Object.entries(s.v).map(([t,n])=>{const i=this._toJsonObjAssign(Object.assign(Object.assign({},s),{re:{},k:t,v:n}));return"object"==typeof i&&(i[e]=i[e]||t),i})}}}Events._public=["CLASS","version","colors","statuses","info","i18n","name","slug","position","emoji","icon","pic","desc","type","kind","dates"];export default Events;module.exports = exports.default;
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