diff --git a/dist/core/abstract-resume.js b/dist/core/abstract-resume.js index cca2655..b2227bf 100644 --- a/dist/core/abstract-resume.js +++ b/dist/core/abstract-resume.js @@ -79,7 +79,7 @@ Definition of the AbstractResume class. ignoreList = []; privateList = []; includePrivates = (opts != null ? opts["private"] : void 0) == null ? true : opts != null ? opts["private"] : void 0; - scrubbed = traverse(rep).map(function(x) { + scrubbed = traverse(rep).map(function() { if (!this.isLeaf) { if (this.node.ignore === true || this.node.ignore === 'true') { ignoreList.push(this.node); @@ -89,6 +89,11 @@ Definition of the AbstractResume class. this["delete"](); } } + if (_.isArray(this.node)) { + this.after(function() { + this.update(_.compact(this.node)); + }); + } }); return { scrubbed: scrubbed, diff --git a/src/core/abstract-resume.coffee b/src/core/abstract-resume.coffee index 86b0e0f..575f846 100644 --- a/src/core/abstract-resume.coffee +++ b/src/core/abstract-resume.coffee @@ -65,7 +65,7 @@ class AbstractResume privateList = [] includePrivates = if not opts?.private? then true else opts?.private - scrubbed = traverse( rep ).map ( x ) -> + scrubbed = traverse( rep ).map () -> # [^1] if !@isLeaf if @node.ignore == true || @node.ignore == 'true' ignoreList.push @node @@ -73,6 +73,10 @@ class AbstractResume else if (@node.private == true || @node.private == 'true') && !includePrivates privateList.push @node @delete() + if _.isArray(@node) # [^2] + @after () -> + @update _.compact this.node + return return scrubbed: scrubbed @@ -80,3 +84,15 @@ class AbstractResume privateList: privateList module.exports = AbstractResume + + +# [^1]: As of this writing, the NPM traverse library has a quirk when attempting +# to remove array elements directly using traverse's `this.remove`. See: +# +# https://github.com/substack/js-traverse/issues/48 +# +# [^2]: The workaround is to use traverse's 'this.delete' to nullify the value +# first, followed by removal with something like _.compact. +# +# https://github.com/substack/js-traverse/issues/48#issuecomment-142607200 +#