@ephox/polaris
Advanced tools
Comparing version 3.0.53 to 4.0.1
@@ -1,2 +0,2 @@ | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
import { PRegExp } from '../pattern/Types'; | ||
@@ -7,3 +7,3 @@ declare type SafewordApi = (input: string) => PRegExp; | ||
declare const safetoken: SafeTokenApi; | ||
declare type CustomApi = (regex: string, prefix: (match: RegExpExecArray) => number, suffix: (match: RegExpExecArray) => number, flags: Option<string>) => PRegExp; | ||
declare type CustomApi = (regex: string, prefix: (match: RegExpExecArray) => number, suffix: (match: RegExpExecArray) => number, flags: Optional<string>) => PRegExp; | ||
declare const custom: CustomApi; | ||
@@ -10,0 +10,0 @@ declare type UnsafewordApi = (input: string) => PRegExp; |
@@ -1,8 +0,8 @@ | ||
import { Arr, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import { PRange } from '../pattern/Types'; | ||
declare type GenerateApi = <T, R extends { | ||
finish: () => number; | ||
}>(xs: T[], f: (x: T, offset: number) => Option<R>, start?: number) => R[]; | ||
finish: number; | ||
}>(xs: T[], f: (x: T, offset: number) => Optional<R>, start?: number) => R[]; | ||
declare const generate: GenerateApi; | ||
declare type GetApi = <T extends PRange>(parray: T[], offset: number) => Option<T>; | ||
declare type GetApi = <T extends PRange>(parray: T[], offset: number) => Optional<T>; | ||
declare const get: GetApi; | ||
@@ -9,0 +9,0 @@ declare type FindApi = typeof Arr.find; |
@@ -5,3 +5,3 @@ import { PRange, PRegExp } from '../pattern/Types'; | ||
declare type FindmanyApi = <T extends { | ||
pattern: () => PRegExp; | ||
pattern: PRegExp; | ||
}>(text: string, targets: T[]) => (T & PRange)[]; | ||
@@ -8,0 +8,0 @@ declare const findmany: FindmanyApi; |
@@ -1,2 +0,2 @@ | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
/** | ||
@@ -10,5 +10,5 @@ * Generate a PositionArray | ||
declare const make: <T, R extends { | ||
finish: () => number; | ||
}>(xs: T[], f: (x: T, offset: number) => Option<R>, start?: number) => R[]; | ||
finish: number; | ||
}>(xs: T[], f: (x: T, offset: number) => Optional<R>, start?: number) => R[]; | ||
export { make }; | ||
//# sourceMappingURL=Generator.d.ts.map |
@@ -19,3 +19,3 @@ import { Arr, Fun } from '@ephox/katamari'; | ||
return { | ||
len: v.finish(), | ||
len: v.finish, | ||
list: acc.list.concat([v]) | ||
@@ -22,0 +22,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { Arr, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import { PRange } from '../pattern/Types'; | ||
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
declare const get: <T extends PRange>(parray: T[], offset: number) => Option<T>; | ||
declare const get: <T extends PRange>(parray: T[], offset: number) => Optional<T>; | ||
/** | ||
@@ -13,0 +13,0 @@ * Extracts the pieces of the PositionArray that are bounded *exactly* on the start and finish offsets |
@@ -1,2 +0,2 @@ | ||
import { Arr, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
/** | ||
@@ -6,3 +6,3 @@ * Simple "is position within unit" utility function | ||
var inUnit = function (unit, position) { | ||
return position >= unit.start() && position <= unit.finish(); | ||
return position >= unit.start && position <= unit.finish; | ||
}; | ||
@@ -19,7 +19,7 @@ /** | ||
return Arr.findIndex(parray, function (unit) { | ||
return unit.start() === offset; | ||
return unit.start === offset; | ||
}); | ||
}; | ||
var tryend = function (parray, finish) { | ||
var finishes = parray[parray.length - 1] && parray[parray.length - 1].finish() === finish; | ||
var finishes = parray[parray.length - 1] && parray[parray.length - 1].finish === finish; | ||
return finishes ? parray.length + 1 : -1; | ||
@@ -35,3 +35,3 @@ }; | ||
var last = rawlast.getOr(tryend(parray, finish)); | ||
return last > -1 ? Option.some(parray.slice(fIndex, last)) : Option.none(); | ||
return last > -1 ? Optional.some(parray.slice(fIndex, last)) : Optional.none(); | ||
}).getOr([]); | ||
@@ -38,0 +38,0 @@ }; |
@@ -9,3 +9,3 @@ import { Arr } from '@ephox/katamari'; | ||
var mini = subdivide(unit, positions); | ||
return Translate.translate(mini, unit.start()); | ||
return Translate.translate(mini, unit.start); | ||
}; | ||
@@ -21,3 +21,3 @@ /** | ||
var relevant = Arr.bind(positions, function (pos) { | ||
return Query.inUnit(unit, pos) ? [pos - unit.start()] : []; | ||
return Query.inUnit(unit, pos) ? [pos - unit.start] : []; | ||
}); | ||
@@ -24,0 +24,0 @@ return relevant.length > 0 ? divide(unit, relevant, subdivide) : [unit]; |
import { __assign } from "tslib"; | ||
import { Arr, Fun } from '@ephox/katamari'; | ||
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: Fun.constant(unit.start() + offset), finish: Fun.constant(unit.finish() + offset) }); | ||
return __assign(__assign({}, unit), { start: unit.start + offset, finish: unit.finish + offset }); | ||
}); | ||
@@ -8,0 +8,0 @@ }; |
@@ -1,4 +0,4 @@ | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
import { PRegExp } from './Types'; | ||
export declare const Custom: (regex: string, prefix: (match: RegExpExecArray) => number, suffix: (match: RegExpExecArray) => number, flags: Option<string>) => PRegExp; | ||
export declare const Custom: (regex: string, prefix: PRegExp['prefix'], suffix: PRegExp['suffix'], flags: Optional<string>) => PRegExp; | ||
//# sourceMappingURL=Custom.d.ts.map |
@@ -7,5 +7,5 @@ export interface PRegExp { | ||
export interface PRange { | ||
readonly start: () => number; | ||
readonly finish: () => number; | ||
readonly start: number; | ||
readonly finish: number; | ||
} | ||
//# sourceMappingURL=Types.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { Fun, Option } from '@ephox/katamari'; | ||
import { Fun, Optional } from '@ephox/katamari'; | ||
import * as Chars from './Chars'; | ||
@@ -8,3 +8,3 @@ import { Custom } from './Custom'; | ||
var token = function (input) { | ||
return Custom(input, Fun.constant(0), Fun.constant(0), Option.none()); | ||
return Custom(input, Fun.constant(0), Fun.constant(0), Optional.none()); | ||
}; | ||
@@ -25,5 +25,5 @@ /** | ||
}; | ||
return Custom(regex, prefix, suffix, Option.none()); | ||
return Custom(regex, prefix, suffix, Optional.none()); | ||
}; | ||
export { token, word }; | ||
//# sourceMappingURL=Unsafe.js.map |
@@ -1,2 +0,2 @@ | ||
import { PRegExp, PRange } from '../pattern/Types'; | ||
import { PRange, PRegExp } from '../pattern/Types'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Returns the offset pairs of all matches of pattern on the input string, adjusting for prefix and suffix offsets |
@@ -1,2 +0,1 @@ | ||
import { Fun } from '@ephox/katamari'; | ||
/** | ||
@@ -11,8 +10,8 @@ * Returns the offset pairs of all matches of pattern on the input string, adjusting for prefix and suffix offsets | ||
var start = match.index + pattern.prefix(match); | ||
var length = match[0].length - pattern.prefix(match) - pattern.suffix(match); | ||
var length_1 = match[0].length - pattern.prefix(match) - pattern.suffix(match); | ||
r.push({ | ||
start: Fun.constant(start), | ||
finish: Fun.constant(start + length) | ||
start: start, | ||
finish: start + length_1 | ||
}); | ||
term.lastIndex = start + length; | ||
term.lastIndex = start + length_1; | ||
match = term.exec(input); | ||
@@ -19,0 +18,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { PRegExp, PRange } from '../pattern/Types'; | ||
import { PRange, PRegExp } from '../pattern/Types'; | ||
/** | ||
@@ -8,5 +8,5 @@ * For each target (pattern, ....), find the matching text (if there is any) and record the start and end offsets. | ||
declare const search: <T extends { | ||
pattern: () => PRegExp; | ||
pattern: PRegExp; | ||
}>(text: string, targets: T[]) => (T & PRange)[]; | ||
export { search }; | ||
//# sourceMappingURL=Sleuth.d.ts.map |
@@ -7,6 +7,6 @@ import { __assign } from "tslib"; | ||
r.sort(function (a, b) { | ||
if (a.start() < b.start()) { | ||
if (a.start < b.start) { | ||
return -1; | ||
} | ||
else if (b.start() < a.start()) { | ||
else if (b.start < a.start) { | ||
return 1; | ||
@@ -27,3 +27,3 @@ } | ||
var unsorted = Arr.bind(targets, function (t) { | ||
var results = Find.all(text, t.pattern()); | ||
var results = Find.all(text, t.pattern); | ||
return Arr.map(results, function (r) { | ||
@@ -30,0 +30,0 @@ return __assign(__assign({}, t), r); |
@@ -0,3 +1,3 @@ | ||
import { Arr } from '@ephox/katamari'; | ||
import * as UnicodeData from './UnicodeData'; | ||
import { Arr } from '@ephox/katamari'; | ||
var SETS = UnicodeData.SETS; | ||
@@ -4,0 +4,0 @@ var OTHER = UnicodeData.characterIndices.OTHER; |
import { Assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Testable } from '@ephox/dispute'; | ||
import * as fc from 'fast-check'; | ||
import * as Arrays from 'ephox/polaris/api/Arrays'; | ||
import * as fc from 'fast-check'; | ||
import { Testable } from '@ephox/dispute'; | ||
var tArray = Testable.tArray, tNumber = Testable.tNumber; | ||
@@ -6,0 +6,0 @@ var is = function (a) { return function (b) { return a === b; }; }; |
import { UnitTest } from '@ephox/bedrock-client'; | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
import { KAssert } from '@ephox/katamari-assertions'; | ||
@@ -9,17 +9,17 @@ import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
var pred = function (unit) { | ||
return unit.item() === value; | ||
return unit.item === value; | ||
}; | ||
var parray = Parrays.make(input); | ||
var actual = PositionArray.find(parray, pred); | ||
KAssert.eqOption('eq', expected, actual.map(function (x) { return x.item(); })); | ||
KAssert.eqOptional('eq', expected, actual.map(function (x) { return x.item; })); | ||
}; | ||
check(Option.none(), [], null); | ||
check(Option.some('a'), ['a'], 'a'); | ||
check(Option.some('a'), ['a'], 'a'); | ||
check(Option.none(), ['a'], 'b'); | ||
check(Option.some('cat'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'cat'); | ||
check(Option.some('tomorrow'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'tomorrow'); | ||
check(Option.none(), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'yesterday'); | ||
check(Option.some('this'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'this'); | ||
check(Optional.none(), [], null); | ||
check(Optional.some('a'), ['a'], 'a'); | ||
check(Optional.some('a'), ['a'], 'a'); | ||
check(Optional.none(), ['a'], 'b'); | ||
check(Optional.some('cat'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'cat'); | ||
check(Optional.some('tomorrow'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'tomorrow'); | ||
check(Optional.none(), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'yesterday'); | ||
check(Optional.some('this'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'this'); | ||
}); | ||
//# sourceMappingURL=ParrayFindTest.js.map |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr, Fun, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
@@ -8,8 +8,8 @@ UnitTest.test('api.PositionArray.generate', function () { | ||
if (firstletter === 'a') { | ||
return Option.none(); | ||
return Optional.none(); | ||
} | ||
return Option.some({ | ||
start: Fun.constant(start), | ||
finish: Fun.constant(start + item.length), | ||
item: Fun.constant(item) | ||
return Optional.some({ | ||
start: start, | ||
finish: start + item.length, | ||
item: item | ||
}); | ||
@@ -20,3 +20,3 @@ }; | ||
assert.eq(expected, Arr.map(result, function (item) { | ||
return item.start() + '->' + item.finish() + '@ ' + item.item(); | ||
return item.start + '->' + item.finish + '@ ' + item.item; | ||
})); | ||
@@ -23,0 +23,0 @@ }; |
import { UnitTest } from '@ephox/bedrock-client'; | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
import { KAssert } from '@ephox/katamari-assertions'; | ||
@@ -10,12 +10,12 @@ import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
var actual = PositionArray.get(parray, offset); | ||
KAssert.eqOption('eq', expected, actual.map(function (x) { return x.item(); })); | ||
KAssert.eqOptional('eq', expected, actual.map(function (x) { return x.item; })); | ||
}; | ||
check(Option.none(), [], 0); | ||
check(Option.some('a'), ['a'], 0); | ||
check(Option.some('a'), ['a'], 1); | ||
check(Option.none(), ['a'], 2); | ||
check(Option.some('cat'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'thiswasaca'.length); | ||
check(Option.some('tomorrow'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'thiswasacattodayandto'.length); | ||
check(Option.none(), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'thiswasacattodayandtomorrow-'.length); | ||
check(Optional.none(), [], 0); | ||
check(Optional.some('a'), ['a'], 0); | ||
check(Optional.some('a'), ['a'], 1); | ||
check(Optional.none(), ['a'], 2); | ||
check(Optional.some('cat'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'thiswasaca'.length); | ||
check(Optional.some('tomorrow'), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'thiswasacattodayandto'.length); | ||
check(Optional.none(), ['this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow'], 'thiswasacattodayandtomorrow-'.length); | ||
}); | ||
//# sourceMappingURL=ParrayGetTest.js.map |
@@ -7,3 +7,3 @@ import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
var subdivide = function (unit, positions) { | ||
var tokens = Strings.splits(unit.item(), positions); | ||
var tokens = Strings.splits(unit.item, positions); | ||
return Parrays.make(tokens); | ||
@@ -10,0 +10,0 @@ }; |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr, Obj } from '@ephox/katamari'; | ||
import * as Regexes from 'ephox/polaris/api/Regexes'; | ||
import { console } from '@ephox/dom-globals'; | ||
// tslint:disable no-console | ||
UnitTest.test('RegexesTest', function () { | ||
@@ -129,4 +127,6 @@ var ephoxCases = [ | ||
if (matched !== null && matched.length > 1) { | ||
// eslint-disable-next-line no-console | ||
console.log('matched groups:'); | ||
Arr.each(matched, function (s, i) { | ||
// eslint-disable-next-line no-console | ||
console.log(i, s); | ||
@@ -133,0 +133,0 @@ }); |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr, Struct, Unicode } from '@ephox/katamari'; | ||
import { Arr, Unicode } from '@ephox/katamari'; | ||
import * as Pattern from 'ephox/polaris/api/Pattern'; | ||
@@ -11,7 +11,10 @@ import * as Search from 'ephox/polaris/api/Search'; | ||
Arr.each(expected, function (exp, i) { | ||
assert.eq(exp[0], actual[i].start()); | ||
assert.eq(exp[1], actual[i].finish()); | ||
assert.eq(exp[0], actual[i].start); | ||
assert.eq(exp[1], actual[i].finish); | ||
}); | ||
}; | ||
var testData = Struct.immutable('pattern', 'name'); | ||
var testData = function (pattern, name) { return ({ | ||
pattern: pattern, | ||
name: name | ||
}); }; | ||
var checkMany = function (expected, text, targets) { | ||
@@ -21,5 +24,5 @@ var actual = Search.findmany(text, targets); | ||
Arr.each(expected, function (exp, i) { | ||
assert.eq(exp[0], actual[i].start()); | ||
assert.eq(exp[1], actual[i].finish()); | ||
assert.eq(exp[2], actual[i].name()); | ||
assert.eq(exp[0], actual[i].start); | ||
assert.eq(exp[1], actual[i].finish); | ||
assert.eq(exp[2], actual[i].name); | ||
}); | ||
@@ -26,0 +29,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { UnitTest, assert } from '@ephox/bedrock-client'; | ||
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr } from '@ephox/katamari'; | ||
@@ -3,0 +3,0 @@ import { getWords } from 'ephox/polaris/words/Words'; |
@@ -0,4 +1,4 @@ | ||
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr } from '@ephox/katamari'; | ||
import * as Chars from 'ephox/polaris/pattern/Chars'; | ||
import { UnitTest, assert } from '@ephox/bedrock-client'; | ||
UnitTest.test('CharsTest', function () { | ||
@@ -5,0 +5,0 @@ 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']; |
export interface PArrayTestItem { | ||
start: () => number; | ||
finish: () => number; | ||
item: () => string; | ||
start: number; | ||
finish: number; | ||
item: string; | ||
} | ||
@@ -6,0 +6,0 @@ declare const make: (values: string[]) => PArrayTestItem[]; |
@@ -1,8 +0,8 @@ | ||
import { Arr, Fun, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
var generator = function (item, start) { | ||
return Option.some({ | ||
start: Fun.constant(start), | ||
finish: Fun.constant(start + item.length), | ||
item: Fun.constant(item) | ||
return Optional.some({ | ||
start: start, | ||
finish: start + item.length, | ||
item: item | ||
}); | ||
@@ -15,3 +15,3 @@ }; | ||
return Arr.map(parray, function (unit) { | ||
return unit.start() + '->' + unit.finish() + '@ ' + unit.item(); | ||
return unit.start + '->' + unit.finish + '@ ' + unit.item; | ||
}); | ||
@@ -18,0 +18,0 @@ }; |
{ | ||
"name": "@ephox/polaris", | ||
"description": "This project does data manipulation on arrays and strings.", | ||
"version": "3.0.53", | ||
"version": "4.0.1", | ||
"repository": { | ||
@@ -21,8 +21,7 @@ "type": "git", | ||
"dependencies": { | ||
"@ephox/dom-globals": "^1.1.2", | ||
"@ephox/katamari": "^6.1.2", | ||
"tslib": "^1.9.3" | ||
"@ephox/katamari": "^7.0.1", | ||
"tslib": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ephox/katamari-assertions": "^1.0.9" | ||
"@ephox/katamari-assertions": "^2.0.1" | ||
}, | ||
@@ -40,3 +39,3 @@ "scripts": { | ||
"types": "./lib/main/ts/ephox/polaris/api/Main.d.ts", | ||
"gitHead": "435a2f4181db31048a2c8a917e8dcef313f97c55" | ||
"gitHead": "b76de3afeacc4b463eccd92dbaed249730e5feea" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
import * as Chars from '../pattern/Chars'; | ||
@@ -14,3 +14,3 @@ import { Custom } from '../pattern/Custom'; | ||
type CustomApi = (regex: string, prefix: (match: RegExpExecArray) => number, suffix: (match: RegExpExecArray) => number, flags: Option<string>) => PRegExp; | ||
type CustomApi = (regex: string, prefix: (match: RegExpExecArray) => number, suffix: (match: RegExpExecArray) => number, flags: Optional<string>) => PRegExp; | ||
const custom: CustomApi = Custom; | ||
@@ -17,0 +17,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Arr, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import * as Generator from '../parray/Generator'; | ||
@@ -8,6 +8,6 @@ import * as Query from '../parray/Query'; | ||
type GenerateApi = <T, R extends { finish: () => number }>(xs: T[], f: (x: T, offset: number) => Option<R>, start?: number) => R[]; | ||
type GenerateApi = <T, R extends { finish: number }>(xs: T[], f: (x: T, offset: number) => Optional<R>, start?: number) => R[]; | ||
const generate: GenerateApi = Generator.make; | ||
type GetApi = <T extends PRange>(parray: T[], offset: number) => Option<T>; | ||
type GetApi = <T extends PRange>(parray: T[], offset: number) => Optional<T>; | ||
const get: GetApi = Query.get; | ||
@@ -34,2 +34,2 @@ | ||
sublist | ||
}; | ||
}; |
@@ -8,3 +8,3 @@ import { PRange, PRegExp } from '../pattern/Types'; | ||
type FindmanyApi = <T extends { pattern: () => PRegExp }>(text: string, targets: T[]) => (T & PRange)[]; | ||
type FindmanyApi = <T extends { pattern: PRegExp }>(text: string, targets: T[]) => (T & PRange)[]; | ||
const findmany: FindmanyApi = Sleuth.search; | ||
@@ -15,2 +15,2 @@ | ||
findmany | ||
}; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { Arr, Fun, Option } from '@ephox/katamari'; | ||
import { Arr, Fun, Optional } from '@ephox/katamari'; | ||
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
const make = function <T, R extends { finish: () => number }> (xs: T[], f: (x: T, offset: number) => Option<R>, start: number = 0) { | ||
const make = function <T, R extends { finish: number }> (xs: T[], f: (x: T, offset: number) => Optional<R>, start: number = 0) { | ||
@@ -22,3 +22,3 @@ const init = { | ||
return { | ||
len: v.finish(), | ||
len: v.finish, | ||
list: acc.list.concat([ v ]) | ||
@@ -34,2 +34,2 @@ }; | ||
make | ||
}; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { Arr, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import { PRange } from '../pattern/Types'; | ||
@@ -8,3 +8,3 @@ | ||
const inUnit = function (unit: PRange, position: number) { | ||
return position >= unit.start() && position <= unit.finish(); | ||
return position >= unit.start && position <= unit.finish; | ||
}; | ||
@@ -23,3 +23,3 @@ | ||
return Arr.findIndex(parray, function (unit) { | ||
return unit.start() === offset; | ||
return unit.start === offset; | ||
}); | ||
@@ -29,3 +29,3 @@ }; | ||
const tryend = function (parray: PRange[], finish: number) { | ||
const finishes = parray[parray.length - 1] && parray[parray.length - 1].finish() === finish; | ||
const finishes = parray[parray.length - 1] && parray[parray.length - 1].finish === finish; | ||
return finishes ? parray.length + 1 : -1; | ||
@@ -40,5 +40,5 @@ }; | ||
const rawlast = startindex(parray, finish); | ||
return first.bind(function (fIndex): Option<T[]> { | ||
return first.bind(function (fIndex): Optional<T[]> { | ||
const last = rawlast.getOr(tryend(parray, finish)); | ||
return last > -1 ? Option.some(parray.slice(fIndex, last)) : Option.none(); | ||
return last > -1 ? Optional.some(parray.slice(fIndex, last)) : Optional.none(); | ||
}).getOr([]); | ||
@@ -56,2 +56,2 @@ }; | ||
sublist | ||
}; | ||
}; |
import { Arr } from '@ephox/katamari'; | ||
import { PRange } from '../pattern/Types'; | ||
import * as Query from './Query'; | ||
import * as Translate from './Translate'; | ||
import { PRange } from '../pattern/Types'; | ||
@@ -11,3 +11,3 @@ /** | ||
const mini = subdivide(unit, positions); | ||
return Translate.translate(mini, unit.start()); | ||
return Translate.translate(mini, unit.start); | ||
}; | ||
@@ -23,3 +23,3 @@ | ||
const relevant = Arr.bind(positions, function (pos) { | ||
return Query.inUnit(unit, pos) ? [ pos - unit.start() ] : []; | ||
return Query.inUnit(unit, pos) ? [ pos - unit.start ] : []; | ||
}); | ||
@@ -33,2 +33,2 @@ | ||
splits | ||
}; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { Arr, Fun } from '@ephox/katamari'; | ||
import { Arr } from '@ephox/katamari'; | ||
import { PRange } from '../pattern/Types'; | ||
@@ -9,4 +9,4 @@ | ||
...unit, | ||
start: Fun.constant(unit.start() + offset), | ||
finish: Fun.constant(unit.finish() + offset) | ||
start: unit.start + offset, | ||
finish: unit.finish + offset | ||
}; | ||
@@ -18,2 +18,2 @@ }); | ||
translate | ||
}; | ||
}; |
@@ -1,6 +0,6 @@ | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
import { PRegExp } from './Types'; | ||
// tslint:disable-next-line:variable-name | ||
export const Custom = function (regex: string, prefix: PRegExp['prefix'], suffix: PRegExp['suffix'], flags: Option<string>): PRegExp { | ||
export const Custom = function (regex: string, prefix: PRegExp['prefix'], suffix: PRegExp['suffix'], flags: Optional<string>): PRegExp { | ||
const term = function () { | ||
@@ -15,2 +15,2 @@ return new RegExp(regex, flags.getOr('g')); | ||
}; | ||
}; | ||
}; |
@@ -8,4 +8,4 @@ export interface PRegExp { | ||
export interface PRange { | ||
readonly start: () => number; | ||
readonly finish: () => number; | ||
readonly start: number; | ||
readonly finish: number; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Fun, Option } from '@ephox/katamari'; | ||
import { Fun, Optional } from '@ephox/katamari'; | ||
import * as Chars from './Chars'; | ||
@@ -9,3 +9,3 @@ import { Custom } from './Custom'; | ||
const token = function (input: string) { | ||
return Custom(input, Fun.constant(0), Fun.constant(0), Option.none()); | ||
return Custom(input, Fun.constant(0), Fun.constant(0), Optional.none()); | ||
}; | ||
@@ -30,3 +30,3 @@ | ||
return Custom(regex, prefix, suffix, Option.none()); | ||
return Custom(regex, prefix, suffix, Optional.none()); | ||
}; | ||
@@ -37,2 +37,2 @@ | ||
word | ||
}; | ||
}; |
@@ -1,3 +0,2 @@ | ||
import { Fun } from '@ephox/katamari'; | ||
import { PRegExp, PRange } from '../pattern/Types'; | ||
import { PRange, PRegExp } from '../pattern/Types'; | ||
@@ -15,4 +14,4 @@ /** | ||
r.push({ | ||
start: Fun.constant(start), | ||
finish: Fun.constant(start + length) | ||
start, | ||
finish: start + length | ||
}); | ||
@@ -27,2 +26,2 @@ term.lastIndex = start + length; | ||
all | ||
}; | ||
}; |
import { Arr } from '@ephox/katamari'; | ||
import { PRange, PRegExp } from '../pattern/Types'; | ||
import * as Find from './Find'; | ||
import { PRegExp, PRange } from '../pattern/Types'; | ||
@@ -8,5 +8,5 @@ const sort = function <T extends PRange> (array: T[]) { | ||
r.sort(function (a, b) { | ||
if (a.start() < b.start()) { | ||
if (a.start < b.start) { | ||
return -1; | ||
} else if (b.start() < a.start()) { | ||
} else if (b.start < a.start) { | ||
return 1; | ||
@@ -25,5 +25,5 @@ } else { | ||
*/ | ||
const search = function <T extends { pattern: () => PRegExp }> (text: string, targets: T[]) { | ||
const search = function <T extends { pattern: PRegExp }> (text: string, targets: T[]) { | ||
const unsorted = Arr.bind(targets, function (t) { | ||
const results = Find.all(text, t.pattern()); | ||
const results = Find.all(text, t.pattern); | ||
return Arr.map(results, function (r) { | ||
@@ -42,2 +42,2 @@ return { | ||
search | ||
}; | ||
}; |
@@ -0,3 +1,3 @@ | ||
import { Arr } from '@ephox/katamari'; | ||
import * as UnicodeData from './UnicodeData'; | ||
import { Arr } from '@ephox/katamari'; | ||
@@ -44,2 +44,2 @@ const SETS = UnicodeData.SETS; | ||
classify | ||
}; | ||
}; |
import { Assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Testable } from '@ephox/dispute'; | ||
import * as fc from 'fast-check'; | ||
import * as Arrays from 'ephox/polaris/api/Arrays'; | ||
import * as fc from 'fast-check'; | ||
import { Testable } from '@ephox/dispute'; | ||
@@ -6,0 +6,0 @@ const { tArray, tNumber } = Testable; |
import { UnitTest } from '@ephox/bedrock-client'; | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
import { KAssert } from '@ephox/katamari-assertions'; | ||
@@ -8,5 +8,5 @@ import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
UnitTest.test('api.PositionArray.find', function () { | ||
const check = function (expected: Option<string>, input: string[], value: string | null) { | ||
const check = function (expected: Optional<string>, input: string[], value: string | null) { | ||
const pred = function (unit: Parrays.PArrayTestItem) { | ||
return unit.item() === value; | ||
return unit.item === value; | ||
}; | ||
@@ -16,13 +16,13 @@ | ||
const actual = PositionArray.find(parray, pred); | ||
KAssert.eqOption('eq', expected, actual.map((x) => x.item())); | ||
KAssert.eqOptional('eq', expected, actual.map((x) => x.item)); | ||
}; | ||
check(Option.none(), [], null); | ||
check(Option.some('a'), [ 'a' ], 'a'); | ||
check(Option.some('a'), [ 'a' ], 'a'); | ||
check(Option.none(), [ 'a' ], 'b'); | ||
check(Option.some('cat'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'cat'); | ||
check(Option.some('tomorrow'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'tomorrow'); | ||
check(Option.none(), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'yesterday'); | ||
check(Option.some('this'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'this'); | ||
check(Optional.none(), [], null); | ||
check(Optional.some('a'), [ 'a' ], 'a'); | ||
check(Optional.some('a'), [ 'a' ], 'a'); | ||
check(Optional.none(), [ 'a' ], 'b'); | ||
check(Optional.some('cat'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'cat'); | ||
check(Optional.some('tomorrow'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'tomorrow'); | ||
check(Optional.none(), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'yesterday'); | ||
check(Optional.some('this'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'this'); | ||
}); |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr, Fun, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
@@ -7,9 +7,9 @@ import { PArrayTestItem } from '../../module/ephox/polaris/test/Parrays'; | ||
UnitTest.test('api.PositionArray.generate', function () { | ||
const generator = function (item: string, start: number): Option<PArrayTestItem> { | ||
const generator = function (item: string, start: number): Optional<PArrayTestItem> { | ||
const firstletter = item[0]; | ||
if (firstletter === 'a') { return Option.none(); } | ||
return Option.some({ | ||
start: Fun.constant(start), | ||
finish: Fun.constant(start + item.length), | ||
item: Fun.constant(item) | ||
if (firstletter === 'a') { return Optional.none(); } | ||
return Optional.some({ | ||
start, | ||
finish: start + item.length, | ||
item | ||
}); | ||
@@ -21,3 +21,3 @@ }; | ||
assert.eq(expected, Arr.map(result, function (item) { | ||
return item.start() + '->' + item.finish() + '@ ' + item.item(); | ||
return item.start + '->' + item.finish + '@ ' + item.item; | ||
})); | ||
@@ -24,0 +24,0 @@ }; |
import { UnitTest } from '@ephox/bedrock-client'; | ||
import { Option } from '@ephox/katamari'; | ||
import { Optional } from '@ephox/katamari'; | ||
import { KAssert } from '@ephox/katamari-assertions'; | ||
@@ -8,15 +8,15 @@ import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
UnitTest.test('api.PositionArray.get', function () { | ||
const check = function (expected: Option<string>, input: string[], offset: number) { | ||
const check = function (expected: Optional<string>, input: string[], offset: number) { | ||
const parray = Parrays.make(input); | ||
const actual = PositionArray.get(parray, offset); | ||
KAssert.eqOption('eq', expected, actual.map((x) => x.item())); | ||
KAssert.eqOptional('eq', expected, actual.map((x) => x.item)); | ||
}; | ||
check(Option.none(), [], 0); | ||
check(Option.some('a'), [ 'a' ], 0); | ||
check(Option.some('a'), [ 'a' ], 1); | ||
check(Option.none(), [ 'a' ], 2); | ||
check(Option.some('cat'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'thiswasaca'.length); | ||
check(Option.some('tomorrow'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'thiswasacattodayandto'.length); | ||
check(Option.none(), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'thiswasacattodayandtomorrow-'.length); | ||
check(Optional.none(), [], 0); | ||
check(Optional.some('a'), [ 'a' ], 0); | ||
check(Optional.some('a'), [ 'a' ], 1); | ||
check(Optional.none(), [ 'a' ], 2); | ||
check(Optional.some('cat'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'thiswasaca'.length); | ||
check(Optional.some('tomorrow'), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'thiswasacattodayandto'.length); | ||
check(Optional.none(), [ 'this', 'was', 'a', 'cat', 'today', 'and', 'tomorrow' ], 'thiswasacattodayandtomorrow-'.length); | ||
}); |
@@ -8,3 +8,3 @@ import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
const subdivide = function (unit: Parrays.PArrayTestItem, positions: number[]) { | ||
const tokens = Strings.splits(unit.item(), positions); | ||
const tokens = Strings.splits(unit.item, positions); | ||
return Parrays.make(tokens); | ||
@@ -11,0 +11,0 @@ }; |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr, Obj } from '@ephox/katamari'; | ||
import * as Regexes from 'ephox/polaris/api/Regexes'; | ||
import { console } from '@ephox/dom-globals'; | ||
// tslint:disable no-console | ||
UnitTest.test('RegexesTest', function () { | ||
@@ -138,4 +136,6 @@ const ephoxCases = [ | ||
if (matched !== null && matched.length > 1) { | ||
// eslint-disable-next-line no-console | ||
console.log('matched groups:'); | ||
Arr.each(matched, function (s, i) { | ||
// eslint-disable-next-line no-console | ||
console.log(i, s); | ||
@@ -142,0 +142,0 @@ }); |
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr, Struct, Unicode } from '@ephox/katamari'; | ||
import { Arr, Unicode } from '@ephox/katamari'; | ||
import * as Pattern from 'ephox/polaris/api/Pattern'; | ||
@@ -13,7 +13,10 @@ import * as Search from 'ephox/polaris/api/Search'; | ||
Arr.each(expected, function (exp, i) { | ||
assert.eq(exp[0], actual[i].start()); | ||
assert.eq(exp[1], actual[i].finish()); | ||
assert.eq(exp[0], actual[i].start); | ||
assert.eq(exp[1], actual[i].finish); | ||
}); | ||
}; | ||
const testData: (pattern: PRegExp, name: string) => { pattern: () => PRegExp; name: () => string } = Struct.immutable('pattern', 'name'); | ||
const testData = (pattern: PRegExp, name: string) => ({ | ||
pattern, | ||
name | ||
}); | ||
@@ -24,5 +27,5 @@ const checkMany = function (expected: [number, number, string][], text: string, targets: ReturnType<typeof testData>[]) { | ||
Arr.each(expected, function (exp, i) { | ||
assert.eq(exp[0], actual[i].start()); | ||
assert.eq(exp[1], actual[i].finish()); | ||
assert.eq(exp[2], actual[i].name()); | ||
assert.eq(exp[0], actual[i].start); | ||
assert.eq(exp[1], actual[i].finish); | ||
assert.eq(exp[2], actual[i].name); | ||
}); | ||
@@ -29,0 +32,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { UnitTest, assert } from '@ephox/bedrock-client'; | ||
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr } from '@ephox/katamari'; | ||
@@ -3,0 +3,0 @@ import { getWords, WordOptions } from 'ephox/polaris/words/Words'; |
@@ -0,4 +1,4 @@ | ||
import { assert, UnitTest } from '@ephox/bedrock-client'; | ||
import { Arr } from '@ephox/katamari'; | ||
import * as Chars from 'ephox/polaris/pattern/Chars'; | ||
import { UnitTest, assert } from '@ephox/bedrock-client'; | ||
@@ -5,0 +5,0 @@ UnitTest.test('CharsTest', function () { |
@@ -1,15 +0,15 @@ | ||
import { Arr, Fun, Option } from '@ephox/katamari'; | ||
import { Arr, Optional } from '@ephox/katamari'; | ||
import * as PositionArray from 'ephox/polaris/api/PositionArray'; | ||
export interface PArrayTestItem { | ||
start: () => number; | ||
finish: () => number; | ||
item: () => string; | ||
start: number; | ||
finish: number; | ||
item: string; | ||
} | ||
const generator = function (item: string, start: number) { | ||
return Option.some<PArrayTestItem>({ | ||
start: Fun.constant(start), | ||
finish: Fun.constant(start + item.length), | ||
item: Fun.constant(item) | ||
return Optional.some<PArrayTestItem>({ | ||
start, | ||
finish: start + item.length, | ||
item | ||
}); | ||
@@ -23,3 +23,3 @@ }; | ||
return Arr.map(parray, function (unit) { | ||
return unit.start() + '->' + unit.finish() + '@ ' + unit.item(); | ||
return unit.start + '->' + unit.finish + '@ ' + unit.item; | ||
}); | ||
@@ -26,0 +26,0 @@ }; |
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
2
3588
261022
+ Added@ephox/katamari@7.2.1(transitive)
- Removed@ephox/dom-globals@^1.1.2
- Removed@ephox/dom-globals@1.1.2(transitive)
- Removed@ephox/katamari@6.1.2(transitive)
- Removedtslib@1.14.1(transitive)
Updated@ephox/katamari@^7.0.1
Updatedtslib@^2.0.0