string-process-comma-separated
Advanced tools
Comparing version 2.0.9 to 2.0.10
/** | ||
* string-process-comma-separated | ||
* Extracts chunks from possibly comma or whatever-separated string | ||
* Version: 2.0.9 | ||
* Version: 2.0.10 | ||
* Author: Roy Revelt, Codsen Ltd | ||
@@ -20,3 +20,3 @@ * License: MIT | ||
var version$1 = "2.0.9"; | ||
var version$1 = "2.0.10"; | ||
@@ -23,0 +23,0 @@ var version = version$1; |
/** | ||
* string-process-comma-separated | ||
* Extracts chunks from possibly comma or whatever-separated string | ||
* Version: 2.0.9 | ||
* Version: 2.0.10 | ||
* Author: Roy Revelt, Codsen Ltd | ||
@@ -16,252 +16,220 @@ * License: MIT | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
var version$1 = "2.0.10"; | ||
return obj; | ||
} | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
const version = version$1; | ||
function processCommaSep(str, originalOpts) { | ||
// insurance: | ||
if (typeof str !== "string") { | ||
throw new Error(`string-process-comma-separated: [THROW_ID_01] input must be string! It was given as ${typeof str}, equal to:\n${JSON.stringify(str, null, 4)}`); | ||
} | ||
} | ||
return target; | ||
} | ||
var version$1 = "2.0.9"; | ||
var version = version$1; | ||
function processCommaSep(str, originalOpts) { // insurance: | ||
if (typeof str !== "string") { | ||
throw new Error("string-process-comma-separated: [THROW_ID_01] input must be string! It was given as " + typeof str + ", equal to:\n" + JSON.stringify(str, null, 4)); | ||
} else if (!str.length || !originalOpts || !originalOpts.cb && !originalOpts.errCb) { | ||
// if input str is empty or there are no callbacks, exit early | ||
return; | ||
} // opts preparation: | ||
var defaults = { | ||
from: 0, | ||
to: str.length, | ||
offset: 0, | ||
leadingWhitespaceOK: false, | ||
trailingWhitespaceOK: false, | ||
oneSpaceAfterCommaOK: false, | ||
innerWhitespaceAllowed: false, | ||
separator: ",", | ||
cb: null, | ||
errCb: null | ||
}; | ||
var opts = _objectSpread2(_objectSpread2({}, defaults), originalOpts); // patch from/to values, they might have been given as nulls etc. | ||
if (!Number.isInteger(originalOpts.from)) { | ||
opts.from = 0; | ||
} | ||
if (!Number.isInteger(originalOpts.to)) { | ||
opts.to = str.length; | ||
} | ||
if (!Number.isInteger(originalOpts.offset)) { | ||
opts.offset = 0; | ||
} // action: | ||
var chunkStartsAt = null; | ||
var whitespaceStartsAt = null; | ||
var firstNonwhitespaceNonseparatorCharFound = false; | ||
var separatorsArr = []; // needed to catch trailing separators | ||
var lastNonWhitespaceCharAt = null; | ||
var fixable = true; | ||
for (var i = opts.from; i < opts.to; i++) { // catch the last nonwhitespace char | ||
if (str[i].trim() && str[i] !== opts.separator) { | ||
lastNonWhitespaceCharAt = i; | ||
} // catch the beginning of a chunk | ||
if (chunkStartsAt === null && str[i].trim() && (!opts.separator || str[i] !== opts.separator)) { | ||
if (!firstNonwhitespaceNonseparatorCharFound) { | ||
firstNonwhitespaceNonseparatorCharFound = true; | ||
} // if there was only one separator up to now, wipe it | ||
if (separatorsArr.length) { | ||
if (separatorsArr.length > 1) { | ||
// eslint-disable-next-line no-loop-func | ||
separatorsArr.forEach(function (separatorsIdx, orderNumber) { | ||
if (orderNumber) { | ||
opts.errCb([[separatorsIdx + opts.offset, separatorsIdx + 1 + opts.offset]], "Remove separator.", fixable); | ||
else if (!str.length || | ||
!originalOpts || | ||
(!originalOpts.cb && !originalOpts.errCb)) { | ||
// if input str is empty or there are no callbacks, exit early | ||
return; | ||
} | ||
// opts preparation: | ||
const defaults = { | ||
from: 0, | ||
to: str.length, | ||
offset: 0, | ||
leadingWhitespaceOK: false, | ||
trailingWhitespaceOK: false, | ||
oneSpaceAfterCommaOK: false, | ||
innerWhitespaceAllowed: false, | ||
separator: ",", | ||
cb: null, | ||
errCb: null, | ||
}; | ||
const opts = { ...defaults, ...originalOpts }; | ||
// patch from/to values, they might have been given as nulls etc. | ||
if (!Number.isInteger(originalOpts.from)) { | ||
opts.from = 0; | ||
} | ||
if (!Number.isInteger(originalOpts.to)) { | ||
opts.to = str.length; | ||
} | ||
if (!Number.isInteger(originalOpts.offset)) { | ||
opts.offset = 0; | ||
} | ||
// action: | ||
let chunkStartsAt = null; | ||
let whitespaceStartsAt = null; | ||
let firstNonwhitespaceNonseparatorCharFound = false; | ||
let separatorsArr = []; // needed to catch trailing separators | ||
let lastNonWhitespaceCharAt = null; | ||
let fixable = true; | ||
for (let i = opts.from; i < opts.to; i++) { | ||
// catch the last nonwhitespace char | ||
if (str[i].trim() && str[i] !== opts.separator) { | ||
lastNonWhitespaceCharAt = i; | ||
} | ||
// catch the beginning of a chunk | ||
if (chunkStartsAt === null && | ||
str[i].trim() && | ||
(!opts.separator || str[i] !== opts.separator)) { | ||
if (!firstNonwhitespaceNonseparatorCharFound) { | ||
firstNonwhitespaceNonseparatorCharFound = true; | ||
} | ||
}); | ||
// if there was only one separator up to now, wipe it | ||
if (separatorsArr.length) { | ||
if (separatorsArr.length > 1) { | ||
// eslint-disable-next-line no-loop-func | ||
separatorsArr.forEach((separatorsIdx, orderNumber) => { | ||
if (orderNumber) { | ||
opts.errCb([ | ||
[ | ||
separatorsIdx + opts.offset, | ||
separatorsIdx + 1 + opts.offset, | ||
], | ||
], "Remove separator.", fixable); | ||
} | ||
}); | ||
} | ||
separatorsArr = []; | ||
} | ||
chunkStartsAt = i; | ||
} | ||
separatorsArr = []; | ||
} | ||
chunkStartsAt = i; | ||
} // catch the ending of a chunk | ||
if (Number.isInteger(chunkStartsAt) && (i > chunkStartsAt && opts.separator && str[i] === opts.separator || i + 1 === opts.to)) { | ||
str.slice(chunkStartsAt, i + 1 === opts.to && str[i] !== opts.separator && str[i].trim() ? i + 1 : i); // ping the cb | ||
if (typeof opts.cb === "function") { | ||
opts.cb(chunkStartsAt + opts.offset, (i + 1 === opts.to && str[i] !== opts.separator && str[i].trim() ? i + 1 : lastNonWhitespaceCharAt + 1) + opts.offset); | ||
} // reset | ||
chunkStartsAt = null; | ||
} // catch the beginning of a whitespace | ||
if (!str[i].trim() && whitespaceStartsAt === null) { | ||
whitespaceStartsAt = i; | ||
} // catch the ending of a whitespace | ||
if (whitespaceStartsAt !== null && (str[i].trim() || i + 1 === opts.to)) { | ||
if (whitespaceStartsAt === opts.from) { | ||
if (!opts.leadingWhitespaceOK && typeof opts.errCb === "function") { | ||
opts.errCb([[whitespaceStartsAt + opts.offset, (i + 1 === opts.to ? i + 1 : i) + opts.offset]], "Remove whitespace.", fixable); | ||
} // else - fine | ||
} else if (!str[i].trim() && i + 1 === opts.to) { | ||
// if it's trailing whitespace, we're on the last character | ||
// (right before opts.to) | ||
if (!opts.trailingWhitespaceOK && typeof opts.errCb === "function") { | ||
opts.errCb([[whitespaceStartsAt + opts.offset, i + 1 + opts.offset]], "Remove whitespace.", fixable); | ||
} // else - fine | ||
} else if ((!opts.oneSpaceAfterCommaOK || !(str[i].trim() && i > opts.from + 1 && str[i - 1] === " " && str[i - 2] === ",")) && (!opts.innerWhitespaceAllowed || !(firstNonwhitespaceNonseparatorCharFound && str[whitespaceStartsAt - 1] && str[i].trim() && str[i] !== opts.separator && str[whitespaceStartsAt - 1] !== opts.separator))) { // exclude single space after a comma, with condition that something | ||
// non-whitespacey follows | ||
// maybe opts.oneSpaceAfterCommaOK is on? | ||
var startingIdx = whitespaceStartsAt; | ||
var endingIdx = i; | ||
if (i + 1 === opts.to && str[i] !== opts.separator && !str[i].trim()) { | ||
endingIdx += 1; | ||
} // i + 1 === opts.to && str[i] !== opts.separator && str[i].trim() | ||
// ? i + 1 | ||
// : i; | ||
var whatToAdd = ""; | ||
if (opts.oneSpaceAfterCommaOK) { | ||
if (str[whitespaceStartsAt] === " " && str[whitespaceStartsAt - 1] === opts.separator) { | ||
// if first whitespace chunk's character is a space, leave it | ||
startingIdx += 1; | ||
} else if (str[whitespaceStartsAt] !== " ") { | ||
// if first whitespace chunk's character is not a space, | ||
// replace whole chunk with a space | ||
whatToAdd = " "; | ||
} | ||
// catch the ending of a chunk | ||
if (Number.isInteger(chunkStartsAt) && | ||
((i > chunkStartsAt && | ||
opts.separator && | ||
str[i] === opts.separator) || | ||
i + 1 === opts.to)) { | ||
str.slice(chunkStartsAt, i + 1 === opts.to && str[i] !== opts.separator && str[i].trim() | ||
? i + 1 | ||
: i); | ||
// ping the cb | ||
if (typeof opts.cb === "function") { | ||
opts.cb(chunkStartsAt + opts.offset, (i + 1 === opts.to && str[i] !== opts.separator && str[i].trim() | ||
? i + 1 | ||
: lastNonWhitespaceCharAt + 1) + opts.offset); | ||
} | ||
// reset | ||
chunkStartsAt = null; | ||
} | ||
var message = "Remove whitespace."; // What if there's a space in the middle of a value, for example, URL? | ||
// <input accept="abc,def ghi,jkl"> | ||
// ^ | ||
// here. | ||
// We identify it by checking, is there a separator in front. | ||
if (!opts.innerWhitespaceAllowed && firstNonwhitespaceNonseparatorCharFound && str[whitespaceStartsAt - 1] && str[i].trim() && str[i] !== opts.separator && str[whitespaceStartsAt - 1] !== opts.separator) { | ||
fixable = false; | ||
message = "Bad whitespace."; | ||
// catch the beginning of a whitespace | ||
if (!str[i].trim() && whitespaceStartsAt === null) { | ||
whitespaceStartsAt = i; | ||
} | ||
if (whatToAdd.length) { | ||
opts.errCb([[startingIdx + opts.offset, endingIdx + opts.offset, whatToAdd]], message, fixable); | ||
} else { | ||
opts.errCb([[startingIdx + opts.offset, endingIdx + opts.offset]], message, fixable); | ||
} // reset fixable | ||
fixable = true; | ||
} // reset | ||
whitespaceStartsAt = null; | ||
} // catch the separator | ||
if (str[i] === opts.separator) { | ||
if (!firstNonwhitespaceNonseparatorCharFound) { | ||
opts.errCb([[i + opts.offset, i + 1 + opts.offset]], "Remove separator.", fixable); | ||
} else { | ||
separatorsArr.push(i); | ||
} | ||
} // | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// BOTTOM RULES | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// catch the end of the string | ||
if (i + 1 === opts.to) { | ||
// eslint-disable-next-line no-loop-func | ||
separatorsArr.forEach(function (separatorsIdx) { | ||
opts.errCb([[separatorsIdx + opts.offset, separatorsIdx + 1 + opts.offset]], "Remove separator.", fixable); | ||
}); | ||
} // logging | ||
} | ||
// catch the ending of a whitespace | ||
if (whitespaceStartsAt !== null && (str[i].trim() || i + 1 === opts.to)) { | ||
if (whitespaceStartsAt === opts.from) { | ||
if (!opts.leadingWhitespaceOK && typeof opts.errCb === "function") { | ||
opts.errCb([ | ||
[ | ||
whitespaceStartsAt + opts.offset, | ||
(i + 1 === opts.to ? i + 1 : i) + opts.offset, | ||
], | ||
], "Remove whitespace.", fixable); | ||
} | ||
// else - fine | ||
} | ||
else if (!str[i].trim() && i + 1 === opts.to) { | ||
// if it's trailing whitespace, we're on the last character | ||
// (right before opts.to) | ||
if (!opts.trailingWhitespaceOK && typeof opts.errCb === "function") { | ||
opts.errCb([[whitespaceStartsAt + opts.offset, i + 1 + opts.offset]], "Remove whitespace.", fixable); | ||
} | ||
// else - fine | ||
} | ||
else if ((!opts.oneSpaceAfterCommaOK || | ||
!(str[i].trim() && | ||
i > opts.from + 1 && | ||
str[i - 1] === " " && | ||
str[i - 2] === ",")) && | ||
(!opts.innerWhitespaceAllowed || | ||
!(firstNonwhitespaceNonseparatorCharFound && | ||
str[whitespaceStartsAt - 1] && | ||
str[i].trim() && | ||
str[i] !== opts.separator && | ||
str[whitespaceStartsAt - 1] !== opts.separator))) { | ||
// exclude single space after a comma, with condition that something | ||
// non-whitespacey follows | ||
// maybe opts.oneSpaceAfterCommaOK is on? | ||
let startingIdx = whitespaceStartsAt; | ||
let endingIdx = i; | ||
if (i + 1 === opts.to && str[i] !== opts.separator && !str[i].trim()) { | ||
endingIdx += 1; | ||
} | ||
// i + 1 === opts.to && str[i] !== opts.separator && str[i].trim() | ||
// ? i + 1 | ||
// : i; | ||
let whatToAdd = ""; | ||
if (opts.oneSpaceAfterCommaOK) { | ||
if (str[whitespaceStartsAt] === " " && | ||
str[whitespaceStartsAt - 1] === opts.separator) { | ||
// if first whitespace chunk's character is a space, leave it | ||
startingIdx += 1; | ||
} | ||
else if (str[whitespaceStartsAt] !== " ") { | ||
// if first whitespace chunk's character is not a space, | ||
// replace whole chunk with a space | ||
whatToAdd = " "; | ||
} | ||
} | ||
let message = "Remove whitespace."; | ||
// What if there's a space in the middle of a value, for example, URL? | ||
// <input accept="abc,def ghi,jkl"> | ||
// ^ | ||
// here. | ||
// We identify it by checking, is there a separator in front. | ||
if (!opts.innerWhitespaceAllowed && | ||
firstNonwhitespaceNonseparatorCharFound && | ||
str[whitespaceStartsAt - 1] && | ||
str[i].trim() && | ||
str[i] !== opts.separator && | ||
str[whitespaceStartsAt - 1] !== opts.separator) { | ||
fixable = false; | ||
message = "Bad whitespace."; | ||
} | ||
if (whatToAdd.length) { | ||
opts.errCb([[startingIdx + opts.offset, endingIdx + opts.offset, whatToAdd]], message, fixable); | ||
} | ||
else { | ||
opts.errCb([[startingIdx + opts.offset, endingIdx + opts.offset]], message, fixable); | ||
} | ||
// reset fixable | ||
fixable = true; | ||
} | ||
// reset | ||
whitespaceStartsAt = null; | ||
} | ||
// catch the separator | ||
if (str[i] === opts.separator) { | ||
if (!firstNonwhitespaceNonseparatorCharFound) { | ||
opts.errCb([[i + opts.offset, i + 1 + opts.offset]], "Remove separator.", fixable); | ||
} | ||
else { | ||
separatorsArr.push(i); | ||
} | ||
} | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// BOTTOM RULES | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// | | ||
// catch the end of the string | ||
if (i + 1 === opts.to) { | ||
// eslint-disable-next-line no-loop-func | ||
separatorsArr.forEach((separatorsIdx) => { | ||
opts.errCb([[separatorsIdx + opts.offset, separatorsIdx + 1 + opts.offset]], "Remove separator.", fixable); | ||
}); | ||
} | ||
// logging | ||
} | ||
} | ||
@@ -268,0 +236,0 @@ |
/** | ||
* string-process-comma-separated | ||
* Extracts chunks from possibly comma or whatever-separated string | ||
* Version: 2.0.9 | ||
* Version: 2.0.10 | ||
* Author: Roy Revelt, Codsen Ltd | ||
@@ -10,3 +10,3 @@ * License: MIT | ||
var version$1 = "2.0.9"; | ||
var version$1 = "2.0.10"; | ||
@@ -13,0 +13,0 @@ const version = version$1; |
/** | ||
* string-process-comma-separated | ||
* Extracts chunks from possibly comma or whatever-separated string | ||
* Version: 2.0.9 | ||
* Version: 2.0.10 | ||
* Author: Roy Revelt, Codsen Ltd | ||
@@ -10,2 +10,2 @@ * License: MIT | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).stringProcessCommaSeparated={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function o(e){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?r(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}e.processCommaSep=function(e,t){if("string"!=typeof e)throw new Error("string-process-comma-separated: [THROW_ID_01] input must be string! It was given as "+typeof e+", equal to:\n"+JSON.stringify(e,null,4));if(e.length&&t&&(t.cb||t.errCb)){var r=o(o({},{from:0,to:e.length,offset:0,leadingWhitespaceOK:!1,trailingWhitespaceOK:!1,oneSpaceAfterCommaOK:!1,innerWhitespaceAllowed:!1,separator:",",cb:null,errCb:null}),t);Number.isInteger(t.from)||(r.from=0),Number.isInteger(t.to)||(r.to=e.length),Number.isInteger(t.offset)||(r.offset=0);for(var n=null,f=null,s=!1,a=[],i=null,p=!0,c=r.from;c<r.to;c++){if(e[c].trim()&&e[c]!==r.separator&&(i=c),null!==n||!e[c].trim()||r.separator&&e[c]===r.separator||(s||(s=!0),a.length&&(a.length>1&&a.forEach((function(e,t){t&&r.errCb([[e+r.offset,e+1+r.offset]],"Remove separator.",p)})),a=[]),n=c),Number.isInteger(n)&&(c>n&&r.separator&&e[c]===r.separator||c+1===r.to)&&(e.slice(n,c+1===r.to&&e[c]!==r.separator&&e[c].trim()?c+1:c),"function"==typeof r.cb&&r.cb(n+r.offset,(c+1===r.to&&e[c]!==r.separator&&e[c].trim()?c+1:i+1)+r.offset),n=null),e[c].trim()||null!==f||(f=c),null!==f&&(e[c].trim()||c+1===r.to)){if(f===r.from)r.leadingWhitespaceOK||"function"!=typeof r.errCb||r.errCb([[f+r.offset,(c+1===r.to?c+1:c)+r.offset]],"Remove whitespace.",p);else if(e[c].trim()||c+1!==r.to){if(!(r.oneSpaceAfterCommaOK&&e[c].trim()&&c>r.from+1&&" "===e[c-1]&&","===e[c-2]||r.innerWhitespaceAllowed&&s&&e[f-1]&&e[c].trim()&&e[c]!==r.separator&&e[f-1]!==r.separator)){var l=f,u=c;c+1!==r.to||e[c]===r.separator||e[c].trim()||(u+=1);var m="";r.oneSpaceAfterCommaOK&&(" "===e[f]&&e[f-1]===r.separator?l+=1:" "!==e[f]&&(m=" "));var b="Remove whitespace.";!r.innerWhitespaceAllowed&&s&&e[f-1]&&e[c].trim()&&e[c]!==r.separator&&e[f-1]!==r.separator&&(p=!1,b="Bad whitespace."),r.errCb(m.length?[[l+r.offset,u+r.offset,m]]:[[l+r.offset,u+r.offset]],b,p),p=!0}}else r.trailingWhitespaceOK||"function"!=typeof r.errCb||r.errCb([[f+r.offset,c+1+r.offset]],"Remove whitespace.",p);f=null}e[c]===r.separator&&(s?a.push(c):r.errCb([[c+r.offset,c+1+r.offset]],"Remove separator.",p)),c+1===r.to&&a.forEach((function(e){r.errCb([[e+r.offset,e+1+r.offset]],"Remove separator.",p)}))}}},e.version="2.0.9",Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).stringProcessCommaSeparated={})}(this,(function(e){"use strict";e.processCommaSep=function(e,t){if("string"!=typeof e)throw new Error(`string-process-comma-separated: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:\n${JSON.stringify(e,null,4)}`);if(!e.length||!t||!t.cb&&!t.errCb)return;const r={...{from:0,to:e.length,offset:0,leadingWhitespaceOK:!1,trailingWhitespaceOK:!1,oneSpaceAfterCommaOK:!1,innerWhitespaceAllowed:!1,separator:",",cb:null,errCb:null},...t};Number.isInteger(t.from)||(r.from=0),Number.isInteger(t.to)||(r.to=e.length),Number.isInteger(t.offset)||(r.offset=0);let o=null,s=null,f=!1,a=[],i=null,n=!0;for(let t=r.from;t<r.to;t++){if(e[t].trim()&&e[t]!==r.separator&&(i=t),null!==o||!e[t].trim()||r.separator&&e[t]===r.separator||(f||(f=!0),a.length&&(a.length>1&&a.forEach(((e,t)=>{t&&r.errCb([[e+r.offset,e+1+r.offset]],"Remove separator.",n)})),a=[]),o=t),Number.isInteger(o)&&(t>o&&r.separator&&e[t]===r.separator||t+1===r.to)&&(e.slice(o,t+1===r.to&&e[t]!==r.separator&&e[t].trim()?t+1:t),"function"==typeof r.cb&&r.cb(o+r.offset,(t+1===r.to&&e[t]!==r.separator&&e[t].trim()?t+1:i+1)+r.offset),o=null),e[t].trim()||null!==s||(s=t),null!==s&&(e[t].trim()||t+1===r.to)){if(s===r.from)r.leadingWhitespaceOK||"function"!=typeof r.errCb||r.errCb([[s+r.offset,(t+1===r.to?t+1:t)+r.offset]],"Remove whitespace.",n);else if(e[t].trim()||t+1!==r.to){if(!(r.oneSpaceAfterCommaOK&&e[t].trim()&&t>r.from+1&&" "===e[t-1]&&","===e[t-2]||r.innerWhitespaceAllowed&&f&&e[s-1]&&e[t].trim()&&e[t]!==r.separator&&e[s-1]!==r.separator)){let o=s,a=t;t+1!==r.to||e[t]===r.separator||e[t].trim()||(a+=1);let i="";r.oneSpaceAfterCommaOK&&(" "===e[s]&&e[s-1]===r.separator?o+=1:" "!==e[s]&&(i=" "));let l="Remove whitespace.";!r.innerWhitespaceAllowed&&f&&e[s-1]&&e[t].trim()&&e[t]!==r.separator&&e[s-1]!==r.separator&&(n=!1,l="Bad whitespace."),r.errCb(i.length?[[o+r.offset,a+r.offset,i]]:[[o+r.offset,a+r.offset]],l,n),n=!0}}else r.trailingWhitespaceOK||"function"!=typeof r.errCb||r.errCb([[s+r.offset,t+1+r.offset]],"Remove whitespace.",n);s=null}e[t]===r.separator&&(f?a.push(t):r.errCb([[t+r.offset,t+1+r.offset]],"Remove separator.",n)),t+1===r.to&&a.forEach((e=>{r.errCb([[e+r.offset,e+1+r.offset]],"Remove separator.",n)}))}},e.version="2.0.10",Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "string-process-comma-separated", | ||
"version": "2.0.9", | ||
"version": "2.0.10", | ||
"description": "Extracts chunks from possibly comma or whatever-separated string", | ||
@@ -99,3 +99,3 @@ "keywords": [ | ||
"@rollup/plugin-typescript": "^8.2.0", | ||
"@types/node": "^14.14.35", | ||
"@types/node": "^14.14.36", | ||
"@types/tap": "^14.10.3", | ||
@@ -105,4 +105,4 @@ "@typescript-eslint/eslint-plugin": "^4.19.0", | ||
"eslint": "^7.22.0", | ||
"lect": "^0.16.9", | ||
"rollup": "^2.42.3", | ||
"lect": "^0.16.10", | ||
"rollup": "^2.42.4", | ||
"rollup-plugin-ascii": "^0.0.3", | ||
@@ -109,0 +109,0 @@ "rollup-plugin-banner": "^0.2.1", |
Sorry, the diff of this file is not supported yet
582
40419