Skip to content

Instantly share code, notes, and snippets.

@fractalliter
Created April 13, 2019 13:24
Show Gist options
  • Save fractalliter/1c0d923fd011a8fc525c40681de3b28d to your computer and use it in GitHub Desktop.
Save fractalliter/1c0d923fd011a8fc525c40681de3b28d to your computer and use it in GitHub Desktop.
Emitter
const emitter = (object, property) => Object.keys(object).find(item => item === property.toString()) ? object[property].map(item => item()): console.log("No match found");
const myInfo = {
name: [()=>console.log("My name is Elias"), () => console.log("I am Developer")],
fname: [() => console.log("My family name is Rahmani")],
age: [() => console.log(`I am ${30}`)]
};
emitter(myInfo, "name");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment