Giter Site home page Giter Site logo

js.optional's Introduction

js.optional

Optionals for JS

Installation

Download the latest release from GitHub or from NPM

via npm:

$ npm install js.optional

then just require in node:

var Optional = require('js.optional');
var numberOptional = Optional.of(123);

API

  1. equals({*}) - Indicates whether some other object is "equal to" this Optional.
  2. filter({function}) - If a value is present, pass the Optional value to predicate function, return an Optional describing the value, otherwise return an empty Optional.
  3. isPresent() - If a value is present, return true if Optional value is not 'null' of 'undefined', otherwise return false.
  4. isPresent({function}) - If a value is present, invoke the specified consumer with the value, otherwise do nothing.
  5. map({function}) - If a value is present, apply the provided mapping function to it, and if the result is non-null, return an Optional describing the result. Otherwise return an empty Optional.
  6. orElse({*}) - Return the value if present, otherwise return other.
  7. orElseGet({Optional}) - Return the value if present, otherwise invoke 'other.get' and return the result of that invocation.

Static

  1. empty() - Returns an empty Optional.
  2. of() - Returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional.
  3. ofNullable() - Returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional.

Contributing

Found a bug or missing feature? Please open an issue!

Send your feedback. Send your pull requests. All contributions are appreciated!

License

js.optional may be freely distributed under the MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.