@elementary/proper
    TypeScript icon, indicating that this package has built-in type declarations

    0.6.1 • Public • Published

    Proper

    Play with Object Properties

    Read Docs

    Example

    Low Level API
    import { getProp } from '@elementary/proper';
     
    const dumas = {
      object: {
        deepObject: {
          musketeers: 3,
        },
      },
    };
     
    // With Map
    compose(
      map(map(getProp('musketeers'))),
      map(getProp('deepObject')),
      getProp('object'),
    )(dumas)
      .get()
      .get()
      .get(); //=> 3
     
    // With Chain
    compose(
      chain(getProp('musketeers')),
      chain(getProp('deepObject')),
      chain(getProp('object')),
    )(Maybe(dumas)).get(); //=> 3
    High Level API
    import { access } from '@elementary/proper';
     
    const dumas = {
      object: {
        deepObject: {
          musketeers: 3,
        },
      },
    };
     
    access('object.deepObject.musketeers')(dumas); //=> 3
    access('object.deepObject.samurais')(dumas); //=> null
    access('object.noObject.musketeers')(dumas); //=> null

    Also includes omit and pick functions from Ramda

    v 0.2.0

    first, last and range

    first([1, 2, 3]); //=> 1
    last([1, 2, 3]); //=> 3
    range(3, 8); //=> [3, 4, 5, 6, 7]

    v 0.2.1

    flatMap

    flatMap(x => x.concat(1), [[1, 2], [3, 4]]); //=>  [1, 2, 1, 3, 4, 1]

    binder

    Merge multiple functions to one

    binder()
      .add(flatMap(x => x.concat(1)))
      .add(first)
      .invoke([[1, 2], [3, 4]]);

    Install

    npm i @elementary/proper

    DownloadsWeekly Downloads

    2

    Version

    0.6.1

    License

    MIT

    Unpacked Size

    10.5 kB

    Total Files

    5

    Last publish

    Collaborators

    • rajatsharma