From 5503686e9e667dde6685f9e7c54e09fa0e11831b Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 23 Apr 2020 20:12:27 +0300 Subject: [PATCH] tweaking... Signed-off-by: Alex A. Naanou --- object.js | 18 +++++++++++++++--- package.json | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/object.js b/object.js index 71e8cde..bd5bca5 100755 --- a/object.js +++ b/object.js @@ -12,11 +12,20 @@ function(require){ var module={} // makes module AMD/node compatible... /*********************************************************************/ // Helpers... +var TAB_SIZE = +module.TAB_SIZE = 4 + // XXX is this the right place for this??? // ...when moving take care that ImageGrid's core.doc uses this... var normalizeIndent = module.normalizeIndent = -function(text){ +function(text, tab_size){ + text = TAB_SIZE > 0 ? + text.replace(/\t/g, + ' '.repeat(tab_size === undefined ? + tab_size + : TAB_SIZE)) + : text var lines = text.split(/\n/) var l = lines .reduce(function(l, e, i){ @@ -30,8 +39,11 @@ function(text){ }, -1) return lines .map(function(line, i){ - return i == 0 ? line : line.slice(l) }) - .join('\n') } + return i == 0 ? + line + : line.slice(l) }) + .join('\n') + .trim() } diff --git a/package.json b/package.json index f07293e..22e3b80 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-object", - "version": "2.2.0", + "version": "2.2.1", "description": "", "main": "object.js", "scripts": {