@ephox/polaris
Advanced tools
Comparing version 3.0.18 to 3.0.19
@@ -8,4 +8,4 @@ import { Splitting } from './Main'; | ||
declare const splitbyAdv: SplitByAdvApi; | ||
declare type SliceByApi = <T>(list: T[], pred: (x: T, i: number, xs: ReadonlyArray<T>) => boolean) => T[]; | ||
declare type SliceByApi = <T>(list: T[], pred: (x: T, i: number, xs: ArrayLike<T>) => boolean) => T[]; | ||
declare const sliceby: SliceByApi; | ||
export { splitby, splitbyAdv, sliceby, boundAt }; |
/** | ||
* Slice an array at the first item matched by the predicate | ||
*/ | ||
declare const sliceby: <T>(list: T[], pred: (x: T, i: number, xs: ReadonlyArray<T>) => boolean) => T[]; | ||
declare const sliceby: <T>(list: T[], pred: (x: T, i: number, xs: ArrayLike<T>) => boolean) => T[]; | ||
export { sliceby }; |
{ | ||
"name": "@ephox/polaris", | ||
"description": "This project does data manipulation on arrays and strings.", | ||
"version": "3.0.18", | ||
"version": "3.0.19", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -15,3 +15,3 @@ import * as Boundaries from '../array/Boundaries'; | ||
type SliceByApi = <T>(list: T[], pred: (x: T, i: number, xs: ReadonlyArray<T>) => boolean) => T[]; | ||
type SliceByApi = <T>(list: T[], pred: (x: T, i: number, xs: ArrayLike<T>) => boolean) => T[]; | ||
const sliceby: SliceByApi = Slice.sliceby; | ||
@@ -18,0 +18,0 @@ |
@@ -6,3 +6,3 @@ import { Arr } from '@ephox/katamari'; | ||
*/ | ||
const sliceby = function <T> (list: T[], pred: (x: T, i: number, xs: ReadonlyArray<T>) => boolean) { | ||
const sliceby = function <T> (list: T[], pred: (x: T, i: number, xs: ArrayLike<T>) => boolean) { | ||
const index = Arr.findIndex(list, pred).getOr(-1); | ||
@@ -9,0 +9,0 @@ return list.slice(0, index); |
@@ -5,3 +5,3 @@ import { assert, UnitTest } from '@ephox/bedrock'; | ||
UnitTest.test('api.Arrays.sliceby', function () { | ||
const check = function (expected: number[], input: number[], pred: (x: number, i: number, xs: ReadonlyArray<number>) => boolean) { | ||
const check = function (expected: number[], input: number[], pred: (x: number, i: number, xs: ArrayLike<number>) => boolean) { | ||
const actual = Arrays.sliceby(input, pred); | ||
@@ -8,0 +8,0 @@ assert.eq(expected, actual); |
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
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
215489