Skip to main content
Module

x/rambda/sortBy-spec.ts

Faster and smaller alternative to Ramda
Go to Latest
File
import {sortBy} from 'rambda'
interface Input { a: number,}
describe('R.sortBy', () => { it('passing type to sort function', () => { function fn(x: any): number { return x.a } function fn2(x: Input): number { return x.a }
const input = [{a: 2}, {a: 1}, {a: 0}] const result = sortBy(fn, input) const curriedResult = sortBy(fn2)(input)
result // $ExpectType readonly { a: number; }[] curriedResult // $ExpectType readonly { a: number; }[] result[0].a // $ExpectType number }) it('passing type to sort function and list', () => { function fn(x: Input): number { return x.a }
const input: Input[] = [{a: 2}, {a: 1}, {a: 0}] const result = sortBy(fn, input) const curriedResult = sortBy(fn)(input)
result // $ExpectType readonly Input[] curriedResult // $ExpectType readonly Input[] result[0].a // $ExpectType number })})