kopia lustrzana https://github.com/backface/turtlestitch
Merge pull request #619 from cycomachead/split
Improvements to Split block for whitespace and line optionspull/3/merge
commit
f99962c161
12
threads.js
12
threads.js
|
@ -2159,15 +2159,17 @@ Process.prototype.reportTextSplit = function (string, delimiter) {
|
||||||
str,
|
str,
|
||||||
del;
|
del;
|
||||||
if (!contains(types, strType)) {
|
if (!contains(types, strType)) {
|
||||||
throw new Error('expecting a text instad of a ' + strType);
|
throw new Error('expecting text instead of a ' + strType);
|
||||||
}
|
}
|
||||||
if (!contains(types, delType)) {
|
if (!contains(types, delType)) {
|
||||||
throw new Error('expecting a text delimiter instad of a ' + delType);
|
throw new Error('expecting a text delimiter instead of a ' + delType);
|
||||||
}
|
}
|
||||||
str = (string || '').toString();
|
str = (string || '').toString();
|
||||||
switch (this.inputOption(delimiter)) {
|
switch (this.inputOption(delimiter)) {
|
||||||
case 'line':
|
case 'line':
|
||||||
del = '\r?\n';
|
// Unicode Compliant Line Splitting (Platform independent)
|
||||||
|
// http://www.unicode.org/reports/tr18/#Line_Boundaries
|
||||||
|
del = /\r\n|[\n\v\f\r\x85\u2028\u2029]/;
|
||||||
break;
|
break;
|
||||||
case 'tab':
|
case 'tab':
|
||||||
del = '\t';
|
del = '\t';
|
||||||
|
@ -2176,7 +2178,9 @@ Process.prototype.reportTextSplit = function (string, delimiter) {
|
||||||
del = '\r';
|
del = '\r';
|
||||||
break;
|
break;
|
||||||
case 'whitespace':
|
case 'whitespace':
|
||||||
return new List(str.trim().split(/[\t\r\n ]+/));
|
str = str.trim();
|
||||||
|
del = /\s+/;
|
||||||
|
break;
|
||||||
case 'letter':
|
case 'letter':
|
||||||
del = '';
|
del = '';
|
||||||
break;
|
break;
|
||||||
|
|
Ładowanie…
Reference in New Issue