@ephox/polaris
Advanced tools
Comparing version 5.0.3 to 6.0.0-alpha.0
@@ -9,2 +9,5 @@ # Changelog | ||
### Changed | ||
- Upgraded to Katamari 9.0, which is incompatible with Katamari 8.0 if used in the same bundle. | ||
## 5.0.2 - 2021-10-11 | ||
@@ -11,0 +14,0 @@ |
import * as Boundaries from '../array/Boundaries'; | ||
import * as Slice from '../array/Slice'; | ||
import * as Split from '../array/Split'; | ||
var boundAt = Boundaries.boundAt; | ||
var splitby = Split.splitby; | ||
var splitbyAdv = Split.splitbyAdv; | ||
var sliceby = Slice.sliceby; | ||
const boundAt = Boundaries.boundAt; | ||
const splitby = Split.splitby; | ||
const splitbyAdv = Split.splitbyAdv; | ||
const sliceby = Slice.sliceby; | ||
export { splitby, splitbyAdv, sliceby, boundAt }; | ||
//# sourceMappingURL=Arrays.js.map |
@@ -5,13 +5,13 @@ import * as Chars from '../pattern/Chars'; | ||
import * as Unsafe from '../pattern/Unsafe'; | ||
var safeword = Safe.word; | ||
var safetoken = Safe.token; | ||
var custom = Custom; | ||
var unsafeword = Unsafe.word; | ||
var unsafetoken = Unsafe.token; | ||
var sanitise = Safe.sanitise; | ||
var chars = Chars.chars; | ||
var wordbreak = Chars.wordbreak; | ||
var wordchar = Chars.wordchar; | ||
var punctuation = Chars.punctuation; | ||
const safeword = Safe.word; | ||
const safetoken = Safe.token; | ||
const custom = Custom; | ||
const unsafeword = Unsafe.word; | ||
const unsafetoken = Unsafe.token; | ||
const sanitise = Safe.sanitise; | ||
const chars = Chars.chars; | ||
const wordbreak = Chars.wordbreak; | ||
const wordchar = Chars.wordchar; | ||
const punctuation = Chars.punctuation; | ||
export { safeword, safetoken, custom, unsafeword, unsafetoken, sanitise, chars, wordbreak, wordchar, punctuation }; | ||
//# sourceMappingURL=Pattern.js.map |
@@ -5,9 +5,9 @@ import * as Generator from '../parray/Generator'; | ||
import * as Translate from '../parray/Translate'; | ||
var generate = Generator.make; | ||
var get = Query.get; | ||
var find = Query.find; | ||
var splits = Split.splits; | ||
var translate = Translate.translate; | ||
var sublist = Query.sublist; | ||
const generate = Generator.make; | ||
const get = Query.get; | ||
const find = Query.find; | ||
const splits = Split.splits; | ||
const translate = Translate.translate; | ||
const sublist = Query.sublist; | ||
export { generate, get, find, splits, translate, sublist }; | ||
//# sourceMappingURL=PositionArray.js.map |
@@ -60,7 +60,6 @@ /* | ||
*/ | ||
var link = function () { | ||
// eslint-disable-next-line max-len | ||
return /(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-+~=.,%()\/\w]*[-+~=%()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g; | ||
}; | ||
var autolink = function () { | ||
const link = () => | ||
// eslint-disable-next-line max-len | ||
/(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-+~=.,%()\/\w]*[-+~=%()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g; | ||
const autolink = () => { | ||
/* | ||
@@ -77,15 +76,13 @@ * Takes the link regex, and makes two additions: | ||
*/ | ||
var linksource = link().source; | ||
const linksource = link().source; | ||
return new RegExp('(' + linksource + ')[-.~*+=!&;:\'%@?#^${}(),]*', 'g'); | ||
}; | ||
var tokens = function (value, parameters) { | ||
return value.replace(/\{(\d+)\}/g, function (match, contents) { | ||
var index = parseInt(contents, 10); | ||
if (parameters[index] === undefined) { | ||
throw new Error('No value for token: ' + match + ' in translation: ' + value); | ||
} | ||
return parameters[index]; | ||
}); | ||
}; | ||
const tokens = (value, parameters) => value.replace(/\{(\d+)\}/g, (match, contents) => { | ||
const index = parseInt(contents, 10); | ||
if (parameters[index] === undefined) { | ||
throw new Error('No value for token: ' + match + ' in translation: ' + value); | ||
} | ||
return parameters[index]; | ||
}); | ||
export { tokens, link, autolink }; | ||
//# sourceMappingURL=Regexes.js.map |
import * as Find from '../search/Find'; | ||
import * as Sleuth from '../search/Sleuth'; | ||
var findall = Find.all; | ||
var findmany = Sleuth.search; | ||
const findall = Find.all; | ||
const findmany = Sleuth.search; | ||
export { findall, findmany }; | ||
//# sourceMappingURL=Search.js.map |
import { Adt } from '@ephox/katamari'; | ||
var adt = Adt.generate([ | ||
const adt = Adt.generate([ | ||
{ include: ['item'] }, | ||
@@ -7,11 +7,11 @@ { excludeWith: ['item'] }, | ||
]); | ||
var cata = function (subject, onInclude, onExcludeWith, onExcludeWithout) { | ||
const cata = (subject, onInclude, onExcludeWith, onExcludeWithout) => { | ||
return subject.fold(onInclude, onExcludeWith, onExcludeWithout); | ||
}; | ||
export var Splitting = { | ||
export const Splitting = { | ||
include: adt.include, | ||
excludeWith: adt.excludeWith, | ||
excludeWithout: adt.excludeWithout, | ||
cata: cata | ||
cata | ||
}; | ||
//# sourceMappingURL=Splitting.js.map |
import * as Sanitise from '../string/Sanitise'; | ||
import * as Split from '../string/Split'; | ||
var splits = Split.splits; | ||
var cssSanitise = Sanitise.css; | ||
const splits = Split.splits; | ||
const cssSanitise = Sanitise.css; | ||
export { cssSanitise, splits }; | ||
//# sourceMappingURL=Strings.js.map |
import * as WordOptions from '../words/Words'; | ||
var getWords = WordOptions.getWords; | ||
const getWords = WordOptions.getWords; | ||
export { getWords }; | ||
//# sourceMappingURL=Words.js.map |
import { Arr, Fun } from '@ephox/katamari'; | ||
var boundAt = function (xs, left, right, comparator) { | ||
var leftIndex = Arr.findIndex(xs, Fun.curry(comparator, left)); | ||
var first = leftIndex.getOr(0); | ||
var rightIndex = Arr.findIndex(xs, Fun.curry(comparator, right)); | ||
var last = rightIndex.map(function (rIndex) { | ||
const boundAt = (xs, left, right, comparator) => { | ||
const leftIndex = Arr.findIndex(xs, Fun.curry(comparator, left)); | ||
const first = leftIndex.getOr(0); | ||
const rightIndex = Arr.findIndex(xs, Fun.curry(comparator, right)); | ||
const last = rightIndex.map((rIndex) => { | ||
return rIndex + 1; | ||
@@ -8,0 +8,0 @@ }).getOr(xs.length); |
@@ -5,4 +5,4 @@ import { Arr } from '@ephox/katamari'; | ||
*/ | ||
var sliceby = function (list, pred) { | ||
var index = Arr.findIndex(list, pred).getOr(-1); | ||
const sliceby = (list, pred) => { | ||
const index = Arr.findIndex(list, pred).getOr(-1); | ||
return list.slice(0, index); | ||
@@ -9,0 +9,0 @@ }; |
@@ -6,4 +6,4 @@ import { Arr } from '@ephox/katamari'; | ||
*/ | ||
var splitby = function (xs, pred) { | ||
return splitbyAdv(xs, function (x) { | ||
const splitby = (xs, pred) => { | ||
return splitbyAdv(xs, (x) => { | ||
return pred(x) ? Splitting.excludeWithout(x) : Splitting.include(x); | ||
@@ -15,11 +15,11 @@ }); | ||
*/ | ||
var splitbyAdv = function (xs, pred) { | ||
var r = []; | ||
var part = []; | ||
Arr.each(xs, function (x) { | ||
var choice = pred(x); | ||
Splitting.cata(choice, function () { | ||
const splitbyAdv = (xs, pred) => { | ||
const r = []; | ||
let part = []; | ||
Arr.each(xs, (x) => { | ||
const choice = pred(x); | ||
Splitting.cata(choice, () => { | ||
// Include in the current sublist. | ||
part.push(x); | ||
}, function () { | ||
}, () => { | ||
// Stop the current sublist, create a new sublist containing just x, and then start the next sublist. | ||
@@ -31,3 +31,3 @@ if (part.length > 0) { | ||
part = []; | ||
}, function () { | ||
}, () => { | ||
// Stop the current sublist, and start the next sublist. | ||
@@ -34,0 +34,0 @@ if (part.length > 0) { |
@@ -9,11 +9,10 @@ import { Arr, Fun } from '@ephox/katamari'; | ||
*/ | ||
var make = function (xs, f, start) { | ||
if (start === void 0) { start = 0; } | ||
var init = { | ||
const make = (xs, f, start = 0) => { | ||
const init = { | ||
len: start, | ||
list: [] | ||
}; | ||
var r = Arr.foldl(xs, function (acc, item) { | ||
var value = f(item, acc.len); | ||
return value.fold(Fun.constant(acc), function (v) { | ||
const r = Arr.foldl(xs, (acc, item) => { | ||
const value = f(item, acc.len); | ||
return value.fold(Fun.constant(acc), (v) => { | ||
return { | ||
@@ -20,0 +19,0 @@ len: v.finish, |
@@ -5,3 +5,3 @@ import { Arr, Optional } from '@ephox/katamari'; | ||
*/ | ||
var inUnit = function (unit, position) { | ||
const inUnit = (unit, position) => { | ||
return position >= unit.start && position <= unit.finish; | ||
@@ -12,14 +12,14 @@ }; | ||
*/ | ||
var get = function (parray, offset) { | ||
return Arr.find(parray, function (x) { | ||
const get = (parray, offset) => { | ||
return Arr.find(parray, (x) => { | ||
return inUnit(x, offset); | ||
}); | ||
}; | ||
var startindex = function (parray, offset) { | ||
return Arr.findIndex(parray, function (unit) { | ||
const startindex = (parray, offset) => { | ||
return Arr.findIndex(parray, (unit) => { | ||
return unit.start === offset; | ||
}); | ||
}; | ||
var tryend = function (parray, finish) { | ||
var finishes = parray[parray.length - 1] && parray[parray.length - 1].finish === finish; | ||
const tryend = (parray, finish) => { | ||
const finishes = parray[parray.length - 1] && parray[parray.length - 1].finish === finish; | ||
return finishes ? parray.length + 1 : -1; | ||
@@ -30,12 +30,12 @@ }; | ||
*/ | ||
var sublist = function (parray, start, finish) { | ||
var first = startindex(parray, start); | ||
var rawlast = startindex(parray, finish); | ||
return first.bind(function (fIndex) { | ||
var last = rawlast.getOr(tryend(parray, finish)); | ||
const sublist = (parray, start, finish) => { | ||
const first = startindex(parray, start); | ||
const rawlast = startindex(parray, finish); | ||
return first.bind((fIndex) => { | ||
const last = rawlast.getOr(tryend(parray, finish)); | ||
return last > -1 ? Optional.some(parray.slice(fIndex, last)) : Optional.none(); | ||
}).getOr([]); | ||
}; | ||
var find = Arr.find; | ||
const find = Arr.find; | ||
export { get, find, inUnit, sublist }; | ||
//# sourceMappingURL=Query.js.map |
@@ -7,4 +7,4 @@ import { Arr } from '@ephox/katamari'; | ||
*/ | ||
var divide = function (unit, positions, subdivide) { | ||
var mini = subdivide(unit, positions); | ||
const divide = (unit, positions, subdivide) => { | ||
const mini = subdivide(unit, positions); | ||
return Translate.translate(mini, unit.start); | ||
@@ -15,8 +15,8 @@ }; | ||
*/ | ||
var splits = function (parray, positions, subdivide) { | ||
const splits = (parray, positions, subdivide) => { | ||
if (positions.length === 0) { | ||
return parray; | ||
} | ||
return Arr.bind(parray, function (unit) { | ||
var relevant = Arr.bind(positions, function (pos) { | ||
return Arr.bind(parray, (unit) => { | ||
const relevant = Arr.bind(positions, (pos) => { | ||
return Query.inUnit(unit, pos) ? [pos - unit.start] : []; | ||
@@ -23,0 +23,0 @@ }); |
@@ -1,7 +0,10 @@ | ||
import { __assign } from "tslib"; | ||
import { Arr } from '@ephox/katamari'; | ||
/** Adjust a PositionArray positions by an offset */ | ||
var translate = function (parray, offset) { | ||
return Arr.map(parray, function (unit) { | ||
return __assign(__assign({}, unit), { start: unit.start + offset, finish: unit.finish + offset }); | ||
const translate = (parray, offset) => { | ||
return Arr.map(parray, (unit) => { | ||
return { | ||
...unit, | ||
start: unit.start + offset, | ||
finish: unit.finish + offset | ||
}; | ||
}); | ||
@@ -8,0 +11,0 @@ }; |
@@ -12,10 +12,10 @@ import { Fun, Unicode } from '@ephox/katamari'; | ||
// \u00AD is a soft hyphen (SHY) character | ||
var charsStr = '\\w' + "'" + '\\-' + Unicode.softHyphen + '\\u0100-\\u017F\\u00C0-\\u00FF' + Unicode.zeroWidth + '\\u2018\\u2019'; | ||
var wordbreakStr = '[^' + charsStr + ']'; | ||
var wordcharStr = '[' + charsStr + ']'; | ||
var chars = Fun.constant(charsStr); | ||
var wordbreak = Fun.constant(wordbreakStr); | ||
var wordchar = Fun.constant(wordcharStr); | ||
var punctuation = Fun.constant(punctuationStr); | ||
const charsStr = '\\w' + `'` + '\\-' + Unicode.softHyphen + '\\u0100-\\u017F\\u00C0-\\u00FF' + Unicode.zeroWidth + '\\u2018\\u2019'; | ||
const wordbreakStr = '[^' + charsStr + ']'; | ||
const wordcharStr = '[' + charsStr + ']'; | ||
const chars = Fun.constant(charsStr); | ||
const wordbreak = Fun.constant(wordbreakStr); | ||
const wordchar = Fun.constant(wordcharStr); | ||
const punctuation = Fun.constant(punctuationStr); | ||
export { chars, punctuation, wordbreak, wordchar }; | ||
//# sourceMappingURL=Chars.js.map |
// tslint:disable-next-line:variable-name | ||
export var Custom = function (regex, prefix, suffix, flags) { | ||
var term = function () { | ||
export const Custom = (regex, prefix, suffix, flags) => { | ||
const term = () => { | ||
return new RegExp(regex, flags.getOr('g')); | ||
}; | ||
return { | ||
term: term, | ||
prefix: prefix, | ||
suffix: suffix | ||
term, | ||
prefix, | ||
suffix | ||
}; | ||
}; | ||
//# sourceMappingURL=Custom.js.map |
import { Regex } from '@ephox/katamari'; | ||
import * as Unsafe from './Unsafe'; | ||
/** Escapes regex characters in a string */ | ||
var sanitise = Regex.escape; | ||
var word = function (input) { | ||
var value = sanitise(input); | ||
const sanitise = Regex.escape; | ||
const word = (input) => { | ||
const value = sanitise(input); | ||
return Unsafe.word(value); | ||
}; | ||
var token = function (input) { | ||
var value = sanitise(input); | ||
const token = (input) => { | ||
const value = sanitise(input); | ||
return Unsafe.token(value); | ||
@@ -12,0 +12,0 @@ }; |
@@ -7,3 +7,3 @@ import { Fun, Optional } from '@ephox/katamari'; | ||
*/ | ||
var token = function (input) { | ||
const token = (input) => { | ||
return Custom(input, Fun.constant(0), Fun.constant(0), Optional.none()); | ||
@@ -16,9 +16,9 @@ }; | ||
*/ | ||
var word = function (input) { | ||
var regex = "((?:^'?)|(?:" + Chars.wordbreak() + "+'?))" + input + "((?:'?$)|(?:'?" + Chars.wordbreak() + '+))'; | ||
const word = (input) => { | ||
const regex = `((?:^'?)|(?:` + Chars.wordbreak() + `+'?))` + input + `((?:'?$)|(?:'?` + Chars.wordbreak() + '+))'; | ||
// ASSUMPTION: There are no groups in their input | ||
var prefix = function (match) { | ||
const prefix = (match) => { | ||
return match.length > 1 ? match[1].length : 0; | ||
}; | ||
var suffix = function (match) { | ||
const suffix = (match) => { | ||
return match.length > 2 ? match[2].length : 0; | ||
@@ -25,0 +25,0 @@ }; |
/** | ||
* Returns the offset pairs of all matches of pattern on the input string, adjusting for prefix and suffix offsets | ||
*/ | ||
var all = function (input, pattern) { | ||
var term = pattern.term(); | ||
var r = []; | ||
var match = term.exec(input); | ||
const all = (input, pattern) => { | ||
const term = pattern.term(); | ||
const r = []; | ||
let match = term.exec(input); | ||
while (match) { | ||
var start = match.index + pattern.prefix(match); | ||
var length_1 = match[0].length - pattern.prefix(match) - pattern.suffix(match); | ||
const start = match.index + pattern.prefix(match); | ||
const length = match[0].length - pattern.prefix(match) - pattern.suffix(match); | ||
r.push({ | ||
start: start, | ||
finish: start + length_1 | ||
start, | ||
finish: start + length | ||
}); | ||
term.lastIndex = start + length_1; | ||
term.lastIndex = start + length; | ||
match = term.exec(input); | ||
@@ -17,0 +17,0 @@ } |
@@ -1,7 +0,6 @@ | ||
import { __assign } from "tslib"; | ||
import { Arr } from '@ephox/katamari'; | ||
import * as Find from './Find'; | ||
var sort = function (array) { | ||
var r = Array.prototype.slice.call(array, 0); | ||
r.sort(function (a, b) { | ||
const sort = (array) => { | ||
const r = Array.prototype.slice.call(array, 0); | ||
r.sort((a, b) => { | ||
if (a.start < b.start) { | ||
@@ -24,7 +23,10 @@ return -1; | ||
*/ | ||
var search = function (text, targets) { | ||
var unsorted = Arr.bind(targets, function (t) { | ||
var results = Find.all(text, t.pattern); | ||
return Arr.map(results, function (r) { | ||
return __assign(__assign({}, t), r); | ||
const search = (text, targets) => { | ||
const unsorted = Arr.bind(targets, (t) => { | ||
const results = Find.all(text, t.pattern); | ||
return Arr.map(results, (r) => { | ||
return { | ||
...t, | ||
...r | ||
}; | ||
}); | ||
@@ -31,0 +33,0 @@ }); |
/** | ||
* Sanitises a string for use in a CSS class name | ||
*/ | ||
var css = function (str) { | ||
const css = (str) => { | ||
// special case; the first character must a letter. More strict than CSS, but easier to implement. | ||
var r = /^[a-zA-Z]/.test(str) ? '' : 'e'; | ||
const r = /^[a-zA-Z]/.test(str) ? '' : 'e'; | ||
// any non-word character becomes a hyphen | ||
var sanitised = str.replace(/[^\w]/gi, '-'); | ||
const sanitised = str.replace(/[^\w]/gi, '-'); | ||
return r + sanitised; | ||
@@ -10,0 +10,0 @@ }; |
@@ -5,11 +5,11 @@ import { Arr } from '@ephox/katamari'; | ||
*/ | ||
var splits = function (value, indices) { | ||
const splits = (value, indices) => { | ||
if (indices.length === 0) { | ||
return [value]; | ||
} | ||
var divisions = Arr.foldl(indices, function (acc, x) { | ||
const divisions = Arr.foldl(indices, (acc, x) => { | ||
if (x === 0) { | ||
return acc; | ||
} | ||
var part = value.substring(acc.prev, x); | ||
const part = value.substring(acc.prev, x); | ||
return { | ||
@@ -20,3 +20,3 @@ prev: x, | ||
}, { prev: 0, values: [] }); | ||
var lastPoint = indices[indices.length - 1]; | ||
const lastPoint = indices[indices.length - 1]; | ||
return lastPoint < value.length ? divisions.values.concat(value.substring(lastPoint)) : divisions.values; | ||
@@ -23,0 +23,0 @@ }; |
import { Arr } from '@ephox/katamari'; | ||
import * as UnicodeData from './UnicodeData'; | ||
var SETS = UnicodeData.SETS; | ||
var OTHER = UnicodeData.characterIndices.OTHER; | ||
var getType = function (char) { | ||
var type = OTHER; | ||
var setsLength = SETS.length; | ||
for (var j = 0; j < setsLength; ++j) { | ||
var set = SETS[j]; | ||
const SETS = UnicodeData.SETS; | ||
const OTHER = UnicodeData.characterIndices.OTHER; | ||
const getType = (char) => { | ||
let type = OTHER; | ||
const setsLength = SETS.length; | ||
for (let j = 0; j < setsLength; ++j) { | ||
const set = SETS[j]; | ||
if (set && set.test(char)) { | ||
@@ -17,5 +17,5 @@ type = j; | ||
}; | ||
var memoize = function (func) { | ||
var cache = {}; | ||
return function (char) { | ||
const memoize = (func) => { | ||
const cache = {}; | ||
return (char) => { | ||
if (cache[char]) { | ||
@@ -25,3 +25,3 @@ return cache[char]; | ||
else { | ||
var result = func(char); | ||
const result = func(char); | ||
cache[char] = result; | ||
@@ -32,4 +32,4 @@ return result; | ||
}; | ||
var classify = function (characters) { | ||
var memoized = memoize(getType); | ||
const classify = (characters) => { | ||
const memoized = memoize(getType); | ||
return Arr.map(characters, memoized); | ||
@@ -36,0 +36,0 @@ }; |
/* eslint-disable max-len */ | ||
var punctuationStr = '[!-#%-*,-\\/:;?@\\[-\\]_{}\u00A1\u00AB\u00B7\u00BB\u00BF;\u00B7\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1361-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u3008\u3009\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30\u2E31\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]'; | ||
var regExps = { | ||
const punctuationStr = '[!-#%-*,-\\/:;?@\\[-\\]_{}\u00A1\u00AB\u00B7\u00BB\u00BF;\u00B7\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1361-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u3008\u3009\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30\u2E31\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]'; | ||
const regExps = { | ||
aletter: '[A-Za-z\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F3\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u10A0-\u10C5\u10D0-\u10FA\u10FC\u1100-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1A00-\u1A16\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BC0-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u24B6-\u24E9\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2D00-\u2D25\u2D30-\u2D65\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u303B\u303C\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790\uA791\uA7A0-\uA7A9\uA7FA-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]', | ||
midnumlet: "[-'\\.\u2018\u2019\u2024\uFE52\uFF07\uFF0E]", | ||
midnumlet: `[-'\\.\u2018\u2019\u2024\uFE52\uFF07\uFF0E]`, | ||
midletter: '[:\u00B7\u00B7\u05F4\u2027\uFE13\uFE55\uFF1A]', | ||
@@ -19,3 +19,3 @@ midnum: '[±+*/,;;\u0589\u060C\u060D\u066C\u07F8\u2044\uFE10\uFE14\uFE50\uFE54\uFF0C\uFF1B]', | ||
/* eslint-enable max-len */ | ||
var characterIndices = { | ||
const characterIndices = { | ||
ALETTER: 0, | ||
@@ -40,3 +40,3 @@ MIDNUMLET: 1, | ||
// above. | ||
var SETS = [ | ||
const SETS = [ | ||
new RegExp(regExps.aletter), | ||
@@ -56,6 +56,6 @@ new RegExp(regExps.midnumlet), | ||
]; | ||
var EMPTY_STRING = ''; | ||
var PUNCTUATION = new RegExp('^' + regExps.punctuation + '$'); | ||
var WHITESPACE = /^\s+$/; | ||
const EMPTY_STRING = ''; | ||
const PUNCTUATION = new RegExp('^' + regExps.punctuation + '$'); | ||
const WHITESPACE = /^\s+$/; | ||
export { punctuationStr, characterIndices, SETS, EMPTY_STRING, PUNCTUATION, WHITESPACE }; | ||
//# sourceMappingURL=UnicodeData.js.map |
import { characterIndices as ci } from './UnicodeData'; | ||
var isWordBoundary = function (map, index) { | ||
var type = map[index]; | ||
var nextType = map[index + 1]; | ||
const isWordBoundary = (map, index) => { | ||
const type = map[index]; | ||
const nextType = map[index + 1]; | ||
if (index < 0 || (index > map.length - 1 && index !== 0)) { | ||
@@ -12,3 +12,3 @@ return false; | ||
} | ||
var nextNextType = map[index + 2]; | ||
const nextNextType = map[index + 2]; | ||
// WB6. Don't break letters across certain punctuation. | ||
@@ -20,3 +20,3 @@ if (type === ci.ALETTER && | ||
} | ||
var prevType = map[index - 1]; | ||
const prevType = map[index - 1]; | ||
// WB7. Don't break letters across certain punctuation. | ||
@@ -23,0 +23,0 @@ if ((type === ci.MIDLETTER || type === ci.MIDNUMLET || nextType === ci.AT) && |
@@ -1,2 +0,1 @@ | ||
import { __assign } from "tslib"; | ||
import { Unicode } from '@ephox/katamari'; | ||
@@ -6,8 +5,8 @@ import { classify } from './StringMapper'; | ||
import { isWordBoundary } from './WordBoundary'; | ||
var EMPTY_STRING = UnicodeData.EMPTY_STRING; | ||
var WHITESPACE = UnicodeData.WHITESPACE; | ||
var PUNCTUATION = UnicodeData.PUNCTUATION; | ||
var isProtocol = function (str) { return str === 'http' || str === 'https'; }; | ||
var findWordEnd = function (characters, startIndex) { | ||
var i; | ||
const EMPTY_STRING = UnicodeData.EMPTY_STRING; | ||
const WHITESPACE = UnicodeData.WHITESPACE; | ||
const PUNCTUATION = UnicodeData.PUNCTUATION; | ||
const isProtocol = (str) => str === 'http' || str === 'https'; | ||
const findWordEnd = (characters, startIndex) => { | ||
let i; | ||
for (i = startIndex; i < characters.length; i++) { | ||
@@ -20,13 +19,13 @@ if (WHITESPACE.test(characters[i])) { | ||
}; | ||
var findUrlEnd = function (characters, startIndex) { | ||
var endIndex = findWordEnd(characters, startIndex + 1); | ||
var peakedWord = characters.slice(startIndex + 1, endIndex).join(EMPTY_STRING); | ||
const findUrlEnd = (characters, startIndex) => { | ||
const endIndex = findWordEnd(characters, startIndex + 1); | ||
const peakedWord = characters.slice(startIndex + 1, endIndex).join(EMPTY_STRING); | ||
return peakedWord.substr(0, 3) === '://' ? endIndex : startIndex; | ||
}; | ||
var findWords = function (chars, sChars, characterMap, options) { | ||
var words = []; | ||
var word = []; | ||
const findWords = (chars, sChars, characterMap, options) => { | ||
const words = []; | ||
let word = []; | ||
// Loop through each character in the classification map and determine whether | ||
// it precedes a word boundary, building an array of distinct words as we go. | ||
for (var i = 0; i < characterMap.length; ++i) { | ||
for (let i = 0; i < characterMap.length; ++i) { | ||
// Append this character to the current word. | ||
@@ -37,11 +36,11 @@ word.push(chars[i]); | ||
if (isWordBoundary(characterMap, i)) { | ||
var ch = sChars[i]; | ||
const ch = sChars[i]; | ||
if ((options.includeWhitespace || !WHITESPACE.test(ch)) && | ||
(options.includePunctuation || !PUNCTUATION.test(ch))) { | ||
var startOfWord = i - word.length + 1; | ||
var endOfWord = i + 1; | ||
var str = sChars.slice(startOfWord, endOfWord).join(EMPTY_STRING); | ||
const startOfWord = i - word.length + 1; | ||
const endOfWord = i + 1; | ||
const str = sChars.slice(startOfWord, endOfWord).join(EMPTY_STRING); | ||
if (isProtocol(str)) { | ||
var endOfUrl = findUrlEnd(sChars, i); | ||
var url = chars.slice(endOfWord, endOfUrl); | ||
const endOfUrl = findUrlEnd(sChars, i); | ||
const url = chars.slice(endOfWord, endOfUrl); | ||
Array.prototype.push.apply(word, url); | ||
@@ -57,13 +56,16 @@ i = endOfUrl; | ||
}; | ||
var getDefaultOptions = function () { return ({ | ||
const getDefaultOptions = () => ({ | ||
includeWhitespace: false, | ||
includePunctuation: false | ||
}); }; | ||
var getWords = function (chars, extract, options) { | ||
options = __assign(__assign({}, getDefaultOptions()), options); | ||
var filteredChars = []; | ||
var extractedChars = []; | ||
}); | ||
const getWords = (chars, extract, options) => { | ||
options = { | ||
...getDefaultOptions(), | ||
...options | ||
}; | ||
const filteredChars = []; | ||
const extractedChars = []; | ||
// tslint:disable-next-line:prefer-for-of | ||
for (var i = 0; i < chars.length; i++) { | ||
var ch = extract(chars[i]); | ||
for (let i = 0; i < chars.length; i++) { | ||
const ch = extract(chars[i]); | ||
if (ch !== Unicode.zeroWidth) { | ||
@@ -74,3 +76,3 @@ filteredChars.push(chars[i]); | ||
} | ||
var characterMap = classify(extractedChars); | ||
const characterMap = classify(extractedChars); | ||
return findWords(filteredChars, extractedChars, characterMap, options); | ||
@@ -77,0 +79,0 @@ }; |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as Boundaries from 'ephox/polaris/array/Boundaries'; | ||
UnitTest.test('BoundariesTest', function () { | ||
var comparator = function (a, b) { | ||
UnitTest.test('BoundariesTest', () => { | ||
const comparator = (a, b) => { | ||
return a === b; | ||
}; | ||
var check = function (items, l, r, pred, expected) { | ||
const check = (items, l, r, pred, expected) => { | ||
assert.eq(Boundaries.boundAt(items, l, r, pred), expected); | ||
@@ -9,0 +9,0 @@ }; |
@@ -5,7 +5,7 @@ import { Assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as Arrays from 'ephox/polaris/api/Arrays'; | ||
var tArray = Testable.tArray, tNumber = Testable.tNumber; | ||
var is = function (a) { return function (b) { return a === b; }; }; | ||
UnitTest.test('sliceby: unit tests', function () { | ||
var check = function (expected, input, pred) { | ||
var actual = Arrays.sliceby(input, pred); | ||
const { tArray, tNumber } = Testable; | ||
const is = (a) => (b) => a === b; | ||
UnitTest.test('sliceby: unit tests', () => { | ||
const check = (expected, input, pred) => { | ||
const actual = Arrays.sliceby(input, pred); | ||
Assert.eq('sliceby', expected, actual, tArray(tNumber)); | ||
@@ -18,5 +18,5 @@ }; | ||
}); | ||
UnitTest.test('sliceby: property tests', function () { | ||
fc.assert(fc.property(fc.array(fc.nat()), fc.array(fc.nat()), function (a1, a2) { | ||
var input = a1.concat([-1]).concat(a2); | ||
UnitTest.test('sliceby: property tests', () => { | ||
fc.assert(fc.property(fc.array(fc.nat()), fc.array(fc.nat()), (a1, a2) => { | ||
const input = a1.concat([-1]).concat(a2); | ||
Assert.eq('sliceby', a1, Arrays.sliceby(input, is(-1)), tArray(tNumber)); | ||
@@ -23,0 +23,0 @@ })); |
@@ -5,5 +5,5 @@ import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Splitting } from 'ephox/polaris/api/Splitting'; | ||
UnitTest.test('api.Arrays.splitby', function () { | ||
var check = function (expected, input, pred) { | ||
var actual = Arrays.splitby(input, pred); | ||
UnitTest.test('api.Arrays.splitby', () => { | ||
const check = (expected, input, pred) => { | ||
const actual = Arrays.splitby(input, pred); | ||
assert.eq(expected, actual); | ||
@@ -14,6 +14,6 @@ }; | ||
check([[1, 2, 3]], [1, 2, 3], Fun.never); | ||
check([[1], [2, 3], [4, 5, 6], [7], [8]], [1, '|', 2, 3, '|', 4, 5, 6, '|', 7, '|', '|', 8], function (x) { | ||
check([[1], [2, 3], [4, 5, 6], [7], [8]], [1, '|', 2, 3, '|', 4, 5, 6, '|', 7, '|', '|', 8], (x) => { | ||
return x === '|'; | ||
}); | ||
var predicate = function (value) { | ||
const predicate = (value) => { | ||
if (value === 'x') { | ||
@@ -29,4 +29,4 @@ return Splitting.excludeWithout(value); | ||
}; | ||
var checkAdv = function (expected, input) { | ||
var actual = Arrays.splitbyAdv(input, predicate); | ||
const checkAdv = (expected, input) => { | ||
const actual = Arrays.splitbyAdv(input, predicate); | ||
assert.eq(expected, actual); | ||
@@ -33,0 +33,0 @@ }; |
@@ -6,10 +6,10 @@ import { UnitTest } from '@ephox/bedrock-client'; | ||
import * as Parrays from 'ephox/polaris/test/Parrays'; | ||
UnitTest.test('api.PositionArray.find', function () { | ||
var check = function (expected, input, value) { | ||
var pred = function (unit) { | ||
UnitTest.test('api.PositionArray.find', () => { | ||
const check = (expected, input, value) => { | ||
const pred = (unit) => { | ||
return unit.item === value; | ||
}; | ||
var parray = Parrays.make(input); | ||
var actual = PositionArray.find(parray, pred); | ||
KAssert.eqOptional('eq', expected, actual.map(function (x) { return x.item; })); | ||
const parray = Parrays.make(input); | ||
const actual = PositionArray.find(parray, pred); | ||
KAssert.eqOptional('eq', expected, actual.map((x) => x.item)); | ||
}; | ||
@@ -16,0 +16,0 @@ check(Optional.none(), [], null); |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
UnitTest.test('api.PositionArray.generate', function () { | ||
var generator = function (item, start) { | ||
var firstletter = item[0]; | ||
UnitTest.test('api.PositionArray.generate', () => { | ||
const generator = (item, start) => { | ||
const firstletter = item[0]; | ||
if (firstletter === 'a') { | ||
@@ -11,10 +11,10 @@ return Optional.none(); | ||
return Optional.some({ | ||
start: start, | ||
start, | ||
finish: start + item.length, | ||
item: item | ||
item | ||
}); | ||
}; | ||
var check = function (expected, input, start) { | ||
var result = PositionArray.generate(input, generator, start); | ||
assert.eq(expected, Arr.map(result, function (item) { | ||
const check = (expected, input, start) => { | ||
const result = PositionArray.generate(input, generator, start); | ||
assert.eq(expected, Arr.map(result, (item) => { | ||
return item.start + '->' + item.finish + '@ ' + item.item; | ||
@@ -21,0 +21,0 @@ })); |
@@ -6,7 +6,7 @@ import { UnitTest } from '@ephox/bedrock-client'; | ||
import * as Parrays from 'ephox/polaris/test/Parrays'; | ||
UnitTest.test('api.PositionArray.get', function () { | ||
var check = function (expected, input, offset) { | ||
var parray = Parrays.make(input); | ||
var actual = PositionArray.get(parray, offset); | ||
KAssert.eqOptional('eq', expected, actual.map(function (x) { return x.item; })); | ||
UnitTest.test('api.PositionArray.get', () => { | ||
const check = (expected, input, offset) => { | ||
const parray = Parrays.make(input); | ||
const actual = PositionArray.get(parray, offset); | ||
KAssert.eqOptional('eq', expected, actual.map((x) => x.item)); | ||
}; | ||
@@ -13,0 +13,0 @@ check(Optional.none(), [], 0); |
@@ -5,10 +5,10 @@ import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as Parrays from 'ephox/polaris/test/Parrays'; | ||
UnitTest.test('api.PositionArray.splits', function () { | ||
var subdivide = function (unit, positions) { | ||
var tokens = Strings.splits(unit.item, positions); | ||
UnitTest.test('api.PositionArray.splits', () => { | ||
const subdivide = (unit, positions) => { | ||
const tokens = Strings.splits(unit.item, positions); | ||
return Parrays.make(tokens); | ||
}; | ||
var check = function (expected, input, positions) { | ||
var parray = Parrays.make(input); | ||
var actual = PositionArray.splits(parray, positions, subdivide); | ||
const check = (expected, input, positions) => { | ||
const parray = Parrays.make(input); | ||
const actual = PositionArray.splits(parray, positions, subdivide); | ||
assert.eq(expected, Parrays.dump(actual)); | ||
@@ -15,0 +15,0 @@ }; |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
import * as Parrays from 'ephox/polaris/test/Parrays'; | ||
UnitTest.test('api.PositionArray.sublist', function () { | ||
var check = function (expected, input, start, finish) { | ||
var parray = Parrays.make(input); | ||
var actual = PositionArray.sublist(parray, start, finish); | ||
UnitTest.test('api.PositionArray.sublist', () => { | ||
const check = (expected, input, start, finish) => { | ||
const parray = Parrays.make(input); | ||
const actual = PositionArray.sublist(parray, start, finish); | ||
assert.eq(expected, Parrays.dump(actual)); | ||
@@ -9,0 +9,0 @@ }; |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
import * as Parrays from 'ephox/polaris/test/Parrays'; | ||
UnitTest.test('api.PositionArray.translate', function () { | ||
var check = function (expected, input, offset) { | ||
var initial = Parrays.make(input); | ||
var actual = PositionArray.translate(initial, offset); | ||
UnitTest.test('api.PositionArray.translate', () => { | ||
const check = (expected, input, offset) => { | ||
const initial = Parrays.make(input); | ||
const actual = PositionArray.translate(initial, offset); | ||
assert.eq(expected, Parrays.dump(actual)); | ||
@@ -9,0 +9,0 @@ }; |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr, Obj } from '@ephox/katamari'; | ||
import * as Regexes from 'ephox/polaris/api/Regexes'; | ||
UnitTest.test('RegexesTest', function () { | ||
var ephoxCases = [ | ||
UnitTest.test('RegexesTest', () => { | ||
const ephoxCases = [ | ||
'www.google.com.au', | ||
@@ -18,4 +18,4 @@ 'www.google.com.au:80', | ||
'https://icmobile4.rtp.raleigh.ibm.com/files/app#/file/d0f8ed3e-f6d2-4577-8989-fa21ac332a20', | ||
"https://www.google.com.aa/test.htm?$-_.+!*'()test,test;test:test@=&", | ||
"http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com?-.~_!$&'()*+,;=:%40:80%2f::::::@e#-.~_!$&'()*+,;=:%40:80%2f::::::@e", | ||
`https://www.google.com.aa/test.htm?$-_.+!*'()test,test;test:test@=&`, | ||
`http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com?-.~_!$&'()*+,;=:%40:80%2f::::::@e#-.~_!$&'()*+,;=:%40:80%2f::::::@e`, | ||
'http://xn--domain.com', | ||
@@ -27,3 +27,3 @@ 'www.google.ca/index.htm?id=/bla/bla', | ||
// More cases, http://formvalidation.io/validators/uri/ | ||
var mathiasBynens = [ | ||
const mathiasBynens = [ | ||
'http://foo.com/blah_blah', | ||
@@ -52,3 +52,3 @@ 'http://foo.com/blah_blah/', | ||
'http://foo.bar/?q=Test%20URL-encoded%20stuff', | ||
"http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", | ||
`http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com`, | ||
'http://1337.net', | ||
@@ -68,3 +68,3 @@ 'http://a.b-c.de', | ||
]; | ||
var validSchemes = [ | ||
const validSchemes = [ | ||
'h://foo.com', | ||
@@ -78,4 +78,4 @@ 'h1://foo.com', | ||
]; | ||
var trueCases = ephoxCases.concat(mathiasBynens).concat(validSchemes); | ||
var ephoxFalseCases = [ | ||
const trueCases = ephoxCases.concat(mathiasBynens).concat(validSchemes); | ||
const ephoxFalseCases = [ | ||
'I am not a link', | ||
@@ -96,3 +96,3 @@ '#hashtag', | ||
]; | ||
var mathiasBynensFalse = [ | ||
const mathiasBynensFalse = [ | ||
'http://', | ||
@@ -137,3 +137,3 @@ 'http://foo.bar?q=Spaces should be encoded', | ||
]; | ||
var invalidSchemes = [ | ||
const invalidSchemes = [ | ||
'1h://foo.com', | ||
@@ -148,5 +148,5 @@ '+h://foo.com', | ||
]; | ||
var falseCases = ephoxFalseCases.concat(mathiasBynensFalse).concat(invalidSchemes); | ||
Arr.each(trueCases, function (cs) { | ||
var matched = Regexes.link().exec(cs); | ||
const falseCases = ephoxFalseCases.concat(mathiasBynensFalse).concat(invalidSchemes); | ||
Arr.each(trueCases, (cs) => { | ||
const matched = Regexes.link().exec(cs); | ||
assert.eq(cs, matched !== null && matched[0], 'expected true but was false: ' + cs); | ||
@@ -156,3 +156,3 @@ if (matched !== null && matched.length > 1) { | ||
console.log('matched groups:'); | ||
Arr.each(matched, function (s, i) { | ||
Arr.each(matched, (s, i) => { | ||
// eslint-disable-next-line no-console | ||
@@ -164,7 +164,7 @@ console.log(i, s); | ||
}); | ||
Arr.each(falseCases, function (cs) { | ||
var match = Regexes.link().exec(cs); | ||
Arr.each(falseCases, (cs) => { | ||
const match = Regexes.link().exec(cs); | ||
assert.eq(false, match !== null && cs === match[0], 'expected false but was true: ' + cs); | ||
}); | ||
var autolinks = { | ||
const autolinks = { | ||
'http://google.com\\': 'http://google.com', | ||
@@ -241,6 +241,6 @@ // 'http://google.com-': 'http://google.com', // TODO: change Regexes so domain cant end in '-' | ||
// remember don't inline the module function execution, JS regexes have state! | ||
Obj.each(autolinks, function (v, k) { | ||
var match = Regexes.autolink().exec(k); | ||
Obj.each(autolinks, (v, k) => { | ||
const match = Regexes.autolink().exec(k); | ||
if (match !== null) { | ||
var url = match[1]; | ||
const url = match[1]; | ||
assert.eq(true, v === url, 'expected ' + v + ' but was "' + url + '"'); | ||
@@ -252,3 +252,3 @@ } | ||
}); | ||
var onlyWithPathLinks = { | ||
const onlyWithPathLinks = { | ||
'http://google.com': 'http://google.com', | ||
@@ -276,6 +276,6 @@ 'http://google.com.': 'http://google.com', | ||
}; | ||
Obj.each(onlyWithPathLinks, function (v, k) { | ||
var match = Regexes.link().exec(k); | ||
Obj.each(onlyWithPathLinks, (v, k) => { | ||
const match = Regexes.link().exec(k); | ||
if (match !== null) { | ||
var url = match[0]; | ||
const url = match[0]; | ||
assert.eq(true, v === url, 'expected ' + v + ' but was "' + url + '"'); | ||
@@ -282,0 +282,0 @@ } |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as Sanitise from 'ephox/polaris/string/Sanitise'; | ||
UnitTest.test('api.Sanitise.css', function () { | ||
var check = function (expected, input) { | ||
var actual = Sanitise.css(input); | ||
UnitTest.test('api.Sanitise.css', () => { | ||
const check = (expected, input) => { | ||
const actual = Sanitise.css(input); | ||
assert.eq(expected, actual); | ||
@@ -7,0 +7,0 @@ }; |
@@ -6,7 +6,7 @@ import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as Safe from 'ephox/polaris/pattern/Safe'; | ||
UnitTest.test('api.Search.findall (using api.Pattern)', function () { | ||
var checkAll = function (expected, input, pattern) { | ||
var actual = Search.findall(input, pattern); | ||
UnitTest.test('api.Search.findall (using api.Pattern)', () => { | ||
const checkAll = (expected, input, pattern) => { | ||
const actual = Search.findall(input, pattern); | ||
assert.eq(expected.length, actual.length); | ||
Arr.each(expected, function (exp, i) { | ||
Arr.each(expected, (exp, i) => { | ||
assert.eq(exp[0], actual[i].start); | ||
@@ -16,10 +16,10 @@ assert.eq(exp[1], actual[i].finish); | ||
}; | ||
var testData = function (pattern, name) { return ({ | ||
pattern: pattern, | ||
name: name | ||
}); }; | ||
var checkMany = function (expected, text, targets) { | ||
var actual = Search.findmany(text, targets); | ||
const testData = (pattern, name) => ({ | ||
pattern, | ||
name | ||
}); | ||
const checkMany = (expected, text, targets) => { | ||
const actual = Search.findmany(text, targets); | ||
assert.eq(expected.length, actual.length); | ||
Arr.each(expected, function (exp, i) { | ||
Arr.each(expected, (exp, i) => { | ||
assert.eq(exp[0], actual[i].start); | ||
@@ -35,4 +35,4 @@ assert.eq(exp[1], actual[i].finish); | ||
checkAll([], Unicode.zeroWidth + 'dog ', Pattern.safeword('dog')); | ||
checkAll([[3, 7], [10, 14]], "no it's i it's done.", Pattern.unsafetoken("it's")); | ||
checkAll([[0, 12]], "catastrophe'", Pattern.unsafetoken("catastrophe'")); | ||
checkAll([[3, 7], [10, 14]], `no it's i it's done.`, Pattern.unsafetoken(`it's`)); | ||
checkAll([[0, 12]], `catastrophe'`, Pattern.unsafetoken(`catastrophe'`)); | ||
checkAll([[0, 3]], 'sre', Pattern.unsafeword('sre')); | ||
@@ -48,4 +48,4 @@ checkAll([[0, 3]], 'sre ', Pattern.unsafeword('sre')); | ||
checkAll([['this '.length, 'this e'.length + Unicode.zeroWidth.length + 'nds'.length]], 'this e' + Unicode.zeroWidth + 'nds here', Pattern.unsafeword('e' + Unicode.zeroWidth + 'nds')); | ||
var prefix = Safe.sanitise('['); | ||
var suffix = Safe.sanitise(']'); | ||
const prefix = Safe.sanitise('['); | ||
const suffix = Safe.sanitise(']'); | ||
checkAll([[1, 5]], ' [wo] and more', Pattern.unsafetoken(prefix + '[^' + suffix + ']*' + suffix)); | ||
@@ -52,0 +52,0 @@ checkMany([], '', []); |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as Strings from 'ephox/polaris/api/Strings'; | ||
UnitTest.test('api.Strings.splits', function () { | ||
var check = function (expected, input, points) { | ||
var actual = Strings.splits(input, points); | ||
UnitTest.test('api.Strings.splits', () => { | ||
const check = (expected, input, points) => { | ||
const actual = Strings.splits(input, points); | ||
assert.eq(expected, actual); | ||
@@ -7,0 +7,0 @@ }; |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr } from '@ephox/katamari'; | ||
import { getWords } from 'ephox/polaris/words/Words'; | ||
UnitTest.test('api.Words.words', function () { | ||
var parseString = function (str) { return Arr.map(str.split(''), function (char) { return ({ char: char }); }); }; | ||
UnitTest.test('api.Words.words', () => { | ||
const parseString = (str) => Arr.map(str.split(''), (char) => ({ char })); | ||
// In order to simplify the assertions | ||
var simplifySets = function (charSets) { return Arr.map(charSets, function (set) { return Arr.map(set, function (char) { return char.char; }).join(''); }); }; | ||
var assertWords = function (expected, input, options) { | ||
var chars = parseString(input); | ||
var wordSets = getWords(chars, function (char) { return char.char; }, options); | ||
var actual = simplifySets(wordSets); | ||
const simplifySets = (charSets) => Arr.map(charSets, (set) => Arr.map(set, (char) => char.char).join('')); | ||
const assertWords = (expected, input, options) => { | ||
const chars = parseString(input); | ||
const wordSets = getWords(chars, (char) => char.char, options); | ||
const actual = simplifySets(wordSets); | ||
assert.eq(expected, actual); | ||
@@ -13,0 +13,0 @@ }; |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr } from '@ephox/katamari'; | ||
import * as Chars from 'ephox/polaris/pattern/Chars'; | ||
UnitTest.test('CharsTest', function () { | ||
var supported = ['fr', 'en_au', 'pt', 'it', 'nl', 'en_uk', 'pt_pt', 'de', 'nb', 'en_br', 'sv', 'da', 'en', 'es', 'en_gb', 'fi', 'en_us']; | ||
var extras = { | ||
UnitTest.test('CharsTest', () => { | ||
const supported = ['fr', 'en_au', 'pt', 'it', 'nl', 'en_uk', 'pt_pt', 'de', 'nb', 'en_br', 'sv', 'da', 'en', 'es', 'en_gb', 'fi', 'en_us']; | ||
const extras = { | ||
fr: { | ||
@@ -95,13 +95,13 @@ label: 'French language', | ||
}; | ||
var regex = new RegExp(Chars.wordchar(), ''); | ||
var checkAllKnown = function (label, str) { | ||
var chars = str.split(''); | ||
var breaks = Arr.filter(chars, function (c) { | ||
const regex = new RegExp(Chars.wordchar(), ''); | ||
const checkAllKnown = (label, str) => { | ||
const chars = str.split(''); | ||
const breaks = Arr.filter(chars, (c) => { | ||
return !regex.test(c); | ||
}); | ||
var leftovers = breaks.join('').trim(); | ||
const leftovers = breaks.join('').trim(); | ||
assert.eq(0, leftovers.length, 'Test: ' + label + '\nExpected all characters in: \n\n"' + str + '" to be known. \nUnknown: ' + leftovers); | ||
}; | ||
Arr.each(supported, function (code) { | ||
var info = extras[code]; | ||
Arr.each(supported, (code) => { | ||
const info = extras[code]; | ||
checkAllKnown(info.label, info.chars); | ||
@@ -108,0 +108,0 @@ }); |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as StringMapper from 'ephox/polaris/words/StringMapper'; | ||
import * as UnicodeData from 'ephox/polaris/words/UnicodeData'; | ||
UnitTest.test('Words.StringMapperTest', function () { | ||
var ci = UnicodeData.characterIndices; | ||
var ALETTER = ci.ALETTER; | ||
var MIDNUMLET = ci.MIDNUMLET; | ||
var MIDLETTER = ci.MIDLETTER; | ||
var MIDNUM = ci.MIDNUM; | ||
var NUMERIC = ci.NUMERIC; | ||
var CR = ci.CR; | ||
var LF = ci.LF; | ||
var NEWLINE = ci.NEWLINE; | ||
var EXTEND = ci.EXTEND; | ||
var FORMAT = ci.FORMAT; | ||
var KATAKANA = ci.KATAKANA; | ||
var EXTENDNUMLET = ci.EXTENDNUMLET; | ||
var OTHER = ci.OTHER; | ||
var AT = ci.AT; | ||
var classify = StringMapper.classify; | ||
var testClassify = function () { | ||
UnitTest.test('Words.StringMapperTest', () => { | ||
const ci = UnicodeData.characterIndices; | ||
const ALETTER = ci.ALETTER; | ||
const MIDNUMLET = ci.MIDNUMLET; | ||
const MIDLETTER = ci.MIDLETTER; | ||
const MIDNUM = ci.MIDNUM; | ||
const NUMERIC = ci.NUMERIC; | ||
const CR = ci.CR; | ||
const LF = ci.LF; | ||
const NEWLINE = ci.NEWLINE; | ||
const EXTEND = ci.EXTEND; | ||
const FORMAT = ci.FORMAT; | ||
const KATAKANA = ci.KATAKANA; | ||
const EXTENDNUMLET = ci.EXTENDNUMLET; | ||
const OTHER = ci.OTHER; | ||
const AT = ci.AT; | ||
const classify = StringMapper.classify; | ||
const testClassify = () => { | ||
assert.eq([ALETTER, ALETTER, ALETTER], classify('abc'.split(''))); | ||
assert.eq([ALETTER, ALETTER, ALETTER], classify('åäö'.split(''))); | ||
assert.eq([ALETTER, NUMERIC, ALETTER], classify('a2c'.split(''))); | ||
assert.eq([ALETTER, MIDNUMLET, ALETTER, ALETTER, OTHER, ALETTER, ALETTER, ALETTER, ALETTER, ALETTER], classify("a'la carte".split(''))); | ||
assert.eq([ALETTER, MIDNUMLET, ALETTER, ALETTER, OTHER, ALETTER, ALETTER, ALETTER, ALETTER, ALETTER], classify(`a'la carte`.split(''))); | ||
assert.eq([ALETTER, ALETTER, ALETTER, OTHER, LF, OTHER, ALETTER, ALETTER, ALETTER], classify('one \n two'.split(''))); | ||
@@ -27,0 +27,0 @@ assert.eq([NUMERIC, MIDNUM, NUMERIC, NUMERIC, NUMERIC, MIDNUMLET, NUMERIC, NUMERIC], classify('3,500.10'.split(''))); |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import * as StringMapper from 'ephox/polaris/words/StringMapper'; | ||
import * as WordBoundary from 'ephox/polaris/words/WordBoundary'; | ||
UnitTest.test('Words.WordBoundaryTest', function () { | ||
var iwb = function (str, index) { | ||
UnitTest.test('Words.WordBoundaryTest', () => { | ||
const iwb = (str, index) => { | ||
return WordBoundary.isWordBoundary(StringMapper.classify(str.split('')), index); | ||
}; | ||
var testWordBoundary = function () { | ||
const testWordBoundary = () => { | ||
// should not break between most characters | ||
@@ -14,3 +14,3 @@ assert.eq(false, iwb('abc', 1)); | ||
// should not break some punctuation | ||
assert.eq(false, iwb("can't", 2)); | ||
assert.eq(false, iwb(`can't`, 2)); | ||
assert.eq(false, iwb('can’t', 2)); | ||
@@ -17,0 +17,0 @@ assert.eq(false, iwb('foo.bar', 2)); |
import { Arr, Optional } from '@ephox/katamari'; | ||
import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
var generator = function (item, start) { | ||
const generator = (item, start) => { | ||
return Optional.some({ | ||
start: start, | ||
start, | ||
finish: start + item.length, | ||
item: item | ||
item | ||
}); | ||
}; | ||
var make = function (values) { | ||
return PositionArray.generate(values, generator); | ||
}; | ||
var dump = function (parray) { | ||
return Arr.map(parray, function (unit) { | ||
const make = (values) => PositionArray.generate(values, generator); | ||
const dump = (parray) => { | ||
return Arr.map(parray, (unit) => { | ||
return unit.start + '->' + unit.finish + '@ ' + unit.item; | ||
@@ -16,0 +14,0 @@ }); |
{ | ||
"name": "@ephox/polaris", | ||
"description": "This project does data manipulation on arrays and strings.", | ||
"version": "5.0.3", | ||
"version": "6.0.0-alpha.0", | ||
"repository": { | ||
@@ -22,11 +22,11 @@ "type": "git", | ||
"dependencies": { | ||
"@ephox/katamari": "^8.1.1", | ||
"@ephox/katamari": "^9.0.0-alpha.0", | ||
"tslib": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ephox/katamari-assertions": "^3.0.3" | ||
"@ephox/katamari-assertions": "^4.0.0-alpha.0" | ||
}, | ||
"scripts": { | ||
"prepublishOnly": "tsc -b", | ||
"test": "bedrock-auto -b phantomjs -d src/test/ts", | ||
"test": "bedrock-auto -b chrome-headless -d src/test/ts", | ||
"test-manual": "bedrock -d src/test/ts", | ||
@@ -40,3 +40,3 @@ "lint": "eslint --config ../../.eslintrc.json src/**/*.ts" | ||
"types": "./lib/main/ts/ephox/polaris/api/Main.d.ts", | ||
"gitHead": "4e954bfe34d4817c6e08997e24ec5c4580836c9f" | ||
"gitHead": "bf1fe8840917fd1d71c7682a7b39bb9b4c20a8d7" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
268328
2
+ Added@ephox/katamari@9.1.6(transitive)
- Removed@ephox/katamari@8.1.1(transitive)
- Removed@ephox/wrap-promise-polyfill@2.2.1(transitive)