Last active
November 12, 2021 15:58
-
-
Save a21ns1g4ts/4e1da15f08a1f51198bc8b63a9c298ef to your computer and use it in GitHub Desktop.
Revisions
-
a21ns1g4ts revised this gist
Nov 12, 2021 . No changes.There are no files selected for viewing
-
a21ns1g4ts revised this gist
Jul 20, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -102,7 +102,7 @@ events = [ ] agents = [ {id: 0, name: "Escureto", type: "cat"}, {id: 1, name: "Digous", type: 'cat'}, {id: 2, name: "Atila Silva", type: 'person'} ] -
a21ns1g4ts revised this gist
Jul 3, 2020 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -96,13 +96,13 @@ function makeDog(obj = {}){ } events = [ {id: 0, name: "walk"}, {id: 1, name: "sleep"}, {id: 1, name: "fly"}, ] agents = [ {id: 0, name: "Escureto Mimoso", type: "cat"}, {id: 1, name: "Barte Lamarin", type: 'cat'}, {id: 2, name: "Atila Silva", type: 'person'} ] -
a21ns1g4ts revised this gist
Jul 3, 2020 . 2 changed files with 26 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,17 @@ <script lang="javascript"> const dog = makeDog( { name:"Laio", id: 1, } ); dog.walk() const person = makePerson(Person.find(2)) person.sleep() const cat = makeCat(Cat.find(1)) cat.walk() cat.fly() cat.sleep() </script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,31 +39,32 @@ const Event = { return events[id] } } const Agent = { find(id){ return agents[id] }, } const eventSender = Object.assign({ emitEvent(event , agent){ this.log(event , agent) } }, logable); const Person = Object.assign({ find(id){ let agent = Agent.find(id) if(agent.type === 'person') return agent } }, walkable) const Dog = Object.assign({} , walkable, sleepable) const Cat = Object.assign({ find(id){ let agent = Agent.find(id); if(agent.type === 'cat') return agent } @@ -74,7 +75,7 @@ const makePerson = function (obj = {}){ name: obj.name, id: obj.id, type: "person" }, Person, sleepable) } const makeCat = function(obj = {}){ @@ -92,7 +93,8 @@ function makeDog(obj = {}){ type: "dog" }, Dog, flyable) } events = [ {id : 0 , name: "walk" }, {id : 1 , name: "sleep" }, -
a21ns1g4ts revised this gist
Jul 3, 2020 . 2 changed files with 30 additions and 34 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,13 @@ <script src="zoologicMonitor.js"></script> <script lang="javascript"> const dog = makeDog( { name:"Laio" , id: 1 , } ); dog.fly(); const person = makePerson(Person.findPerson(2)); person.walk(); </script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,97 +1,96 @@ const walkable = { walk(){ eventSender.emitEvent(events[0], { name: this.name, id: this.id, type: this.type }) }, } const sleepable = { sleep(){ eventSender.emitEvent(events[1] , { name: this.name, id: this.id, type: this.type }) } } const flyable = { fly(){ eventSender.emitEvent(events[2] , { name: this.name, id: this.id, type: this.type }) }, } const logable = { log(event, agent){ console.log(` event: ${event.name}; event_id: ${event.id}; agent: ${agent.name}; agent_id: ${agent.id}; agent_type: ${agent.type}; `) } } const Event = { findEvent(id){ return events[id] } } const Agent = { findAgent(id){ return agents[id] }, } const Person = Object.assign({ findPerson(id){ let agent = Agent.findAgent(id) if(agent.type === 'person') return agent } }, walkable) const Dog = Object.assign({} , walkable) const eventSender = Object.assign({ emitEvent(event , agent){ this.log(event , agent) } }, logable); const Cat = Object.assign({ findCat(id){ let agent = Agent.findAgent(id); if(agent.type === 'cat') return agent } }, walkable, flyable, sleepable) const makePerson = function (obj = {}){ return Object.assign({ name: obj.name, id: obj.id, type: "person" }, Person) } const makeCat = function(obj = {}){ return Object.assign({ name : obj.name, id : obj.id, type : "cat" }, Cat) } function makeDog(obj = {}){ return Object.assign({ name: obj.name, id: obj.id, type: "dog" }, Dog, flyable) }; events = [ -
a21ns1g4ts renamed this gist
Jun 30, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
a21ns1g4ts revised this gist
Apr 18, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ <script src="zoologicMonitor.js"></script> <script lang="javascript"> const dog1 = makeDog( -
a21ns1g4ts created this gist
Dec 23, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <script src="catMonitor.js"></script> <script lang="javascript"> const dog1 = makeDog( { name:"Mark Pure object" , id: 1 , } ); dog1.fly(); const person1 = makePerson(Person.findPerson(2)); person1.walk(); </script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,107 @@ const walkable = { walk(){ eventSender.emitEvent(events[0] , { name: this.name , id: this.id , type: this.type }); }, } const sleepable = { sleep(){ eventSender.emitEvent(events[1] , { name: this.name , id: this.id , type: this.type }); } } const flyable = { fly(){ eventSender.emitEvent(events[2] , { name: this.name , id: this.id , type: this.type }); }, } const logable = { log(event , agent){ console.log(` event: ${event.name}; event_id: ${event.id}; agent: ${agent.name}; agent_id: ${agent.id}; agent_type: ${agent.type} `); } } const Event = { findEvent(id){ return events[id]; } } const Agent = { findAgent(id){ return agents[id]; }, } const Person = Object.assign({ findPerson(id){ let agent = Agent.findAgent(id); if(agent.type === 'person') return agent; } } , walkable) const Dog = Object.assign({} , walkable); const eventSender = Object.assign({ emitEvent(event , agent){ this.log(event , agent); } } , logable); const Cat = Object.assign({ findCat(id){ let agent = Agent.findAgent(id); if(agent.type === 'cat') return agent; } }, walkable , flyable, sleepable); const makePerson = function (obj = {}){ return Object.assign({ name: obj.name, id: obj.id, type: "person" }, Person ) } const makeCat = function(obj = {}){ return Object.assign({ name : obj.name, id : obj.id, type : "cat" }, Cat ); } function makeDog(obj = {}){ return Object.assign({ name: obj.name, id: obj.id, type: "dog" } , Dog , flyable) }; events = [ {id : 0 , name: "walk" }, {id : 1 , name: "sleep" }, {id : 1 , name: "fly" }, ] agents = [ {id:0 , name : "Escureto Mimoso" , type: "cat"}, {id:1 , name : "Barte Lamarin" , type: 'cat'}, {id:2 , name : "Atila Silva" , type: 'person'} ]