Skip to content
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.

Commit

Permalink
Adds memos to the state (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc authored Mar 22, 2018
1 parent 7ae5250 commit de3fd33
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,16 @@ Client.prototype.publishersInfo = function (publishers, callback) {

Client.prototype.memo = function (who, args) {
let what
if (!this.memos) this.memos = []
if (this.memos.length > 5) this.memos.splice(0, this.memos.length - 5)

if (!this.state.memos) this.state.memos = []
if (this.state.memos.length > 10) this.state.memos.splice(0, this.state.memos.length - 10)
if (typeof args !== 'object') {
what = {reason: args}
} else {
what = args
}
this.memos.push(JSON.stringify({ who: who, what: what || {}, when: underscore.now() }))

this.state.memos.push(JSON.stringify({ who: who, what: what || {}, when: underscore.now() }))
this._log(who, args)
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bat-client",
"version": "2.1.1",
"version": "2.1.2",
"description": "An example of client code for the BAT.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit de3fd33

Please sign in to comment.