at(index, xs) curry
入参
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
index | number | 是 | 可为负数 |
xs | Array<any> | - | - |
返回
ts
any | undefined;
示例
ts
import { at } from "./at";
describe("at", () => {
test("normal", () => {
const xs = [0, 1, 2, 3];
const first = at(0);
const x = first(xs);
expect(x).toBe(0);
expect(at(-1)(xs)).toBe(3);
expect(at(1)(xs)).toBe(1);
expect(at(-4)(xs)).toBe(0);
expect(at(-10)(xs)).toBe(undefined);
});
});