1.1.1 • Published 8 years ago

underscore.lifted v1.1.1

Weekly downloads
1
License
ISC
Repository
-
Last release
8 years ago

underscore.lifted

Some simple functional helpers for underscore.

Example Usage

Simple if/else logic can be replaced with expressions:

Before:

a = f();
let res;

if (a > 100) {
  res = 'big number';
} else {
  res = 'small number';
}

After:

a = f();
const res = (
  _.lift(a > 100)
  .map(() => 'big number')
  .orElse(() => 'small number')
  .unlift()
);

Sure, you can use ternary operators for this. But with large expressions this can be harder to read. For example with react:

  render() {
    return (
      _.lift(this.props.property)
      .map((property) =>
        <div>
          <p>There's complicated information in here:</p>
          {property}
        </div>
      )
      .orElse(() =>
        <div />
      )
      .unlift()
    );
  }
1.1.1

8 years ago

1.1.0

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago