Skip to content
This repository was archived by the owner on May 8, 2021. It is now read-only.
This repository was archived by the owner on May 8, 2021. It is now read-only.

Feature request: Add Ramda-compatible composable export #4

@icopp

Description

@icopp

This would be similar to the existing export, except with the params flipped, curryable, and defaults split into another export:

import { composableGet as get, composableGetOr as getOr } from 'ts-get';

// these are the same statement
get(obj => obj.a.b.c, inputObject);
get(obj => obj.a.b.c)(inputObject);

// these are the same statement
getOr(defaultValue, obj => obj.a.b.c, inputObject);
getOr(defaultValue, obj => obj.a.b.c)(inputObject);
getOr(defaultValue)(obj => obj.a.b.c, inputObject);
getOr(defaultValue)(obj => obj.a.b.c)(inputObject);

This would allow use with Ramda for things like the following (real simple example):

import { pipe, equals } from 'ramda';
import { composableGet as get } from 'ts-get';

import { getMetadataForIndex } from './whatever-utils';

export function satisfiesCriteria(index: number, type: string): boolean {
    return pipe(
        getMetadataForIndex, // this is passed index
        get(metadata => metadata.a.b.c), // this is passed the output of getMetadataForIndex
        equals(type) // this is passed the output of get
    )(index);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions