diff --git a/files/NEXT_VERSION_CHECKLIST.md b/files/NEXT_VERSION_CHECKLIST.md index ac8de235..0341a52c 100644 --- a/files/NEXT_VERSION_CHECKLIST.md +++ b/files/NEXT_VERSION_CHECKLIST.md @@ -1,6 +1,8 @@ +takelast https://github.com/selfrefactor/rambda/discussions/758 + --- ABOVE IS DONE --- @@ -123,6 +125,16 @@ assocpath --- bench against https://romgrk.com/posts/optimizing-javascript#3-avoid-arrayobject-methods --- +R.path with string path - check typehero notes +--- +let result = piped( + input, + split(`\n`), + map(trim), + filter(x => Boolean(x)), + +why cannot filter(boolean) be used +--- export const getTestData = (key: K) => { if (!TEST_DATA) return null diff --git a/files/index.d.ts b/files/index.d.ts index 549ac6ef..74af81ec 100644 --- a/files/index.d.ts +++ b/files/index.d.ts @@ -4005,10 +4005,7 @@ Notes: // @SINGLE_MARKER export function take(howMany: number, input: T[]): T[]; export function take(howMany: number, input: string): string; -export function take(howMany: number): { - (input: T[]): T[]; - (input: string): string; -}; +export function take(howMany: number) : (input: T[]) => T[]; /* Method: takeLast @@ -4035,10 +4032,8 @@ Notes: // @SINGLE_MARKER export function takeLast(howMany: number, input: T[]): T[]; export function takeLast(howMany: number, input: string): string; -export function takeLast(howMany: number): { - (input: T[]): T[]; - (input: string): string; -}; +export function takeLast(howMany: number) : (input: T[]) => T[]; + /* Method: tap diff --git a/source/takeLast-spec.ts b/source/takeLast-spec.ts index fccd6f11..dcbaeea1 100644 --- a/source/takeLast-spec.ts +++ b/source/takeLast-spec.ts @@ -1,4 +1,4 @@ -import {takeLast} from 'rambda' +import {filter, piped, takeLast} from 'rambda' const list = [1, 2, 3, 4] const str = 'foobar' @@ -15,6 +15,17 @@ describe('R.takeLast - array', () => { result // $ExpectType number[] }) + it('real case', () => { + let data = ['foo'] + let result = piped( + data, + filter( + x => x.length >= 100 + ), + takeLast(5), + ) + result // $ExpectType string[] + }) }) describe('R.takeLast - string', () => {