logo

Grimgrains

Unnamed repository; edit this file 'description' to name the repository.
commit: 904e46e5000f7e2abb406289d90296a5ca58280d
parent a28464fb19626ec5417ed8d4fc6c5fa38c900ec3
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Sun, 11 Mar 2018 10:18:36 +1300

Added cache to indental

Diffstat:

Mscripts/nodes/indental.js12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/scripts/nodes/indental.js b/scripts/nodes/indental.js @@ -10,13 +10,17 @@ function IndentalNode(id,rect) console.warn(`Missing /database/${this.id}.js`) return null; } - return new Parser(DATABASE[this.id]).result; + if(this.cache){ + return this.cache; + } + this.cache = parse(DATABASE[this.id]) + return this.cache; } - function Parser(data) + function parse(data) { - this.result = build(data.split("\n").map(liner)) - + return build(data.split("\n").map(liner)) + function build(lines) { // Assoc lines