Skip to content

ullas-cwt/underscore-java

 
 

Repository files navigation

underscore-java

Maven Central MIT License Build Status Coverage Status codecov.io CircleCI Codeship Status for javadev/underscore-java wercker status Build status Build Status Run Status Known Vulnerabilities Codacy Badge Sputnik Code Scene BCH compliance Quality Gate Quality Gate Scrutinizer Build Status Hits-of-Code Java Version

Join the chat at https://gitter.im/javadev/underscore-java

Requirements

Java 1.6 and later.

Installation

Include the following in your pom.xml for Maven:

<dependencies>
  <dependency>
    <groupId>com.github.javadev</groupId>
    <artifactId>underscore</artifactId>
    <version>1.48</version>
  </dependency>
  ...
</dependencies>

Gradle:

compile 'com.github.javadev:underscore:1.48'

Usage

U.chain(/* array | list | set | map | anything based on Iterable interface */)
    .filter(..)
    .map(..)
    ...
    .sortWith()
    .forEach(..);
U.chain(value1, value2, value3)...
U.range(0, 10)...

U.chain(1, 2, 3) // or java.util.Arrays.asList(1, 2, 3) or new Integer[] {1, 2, 3}
    .filter(v -> v > 1)
    // 2, 3
    .map(v -> v + 1)
    // 3, 4
    .sortWith((a, b) -> b.compareTo(a))
    // 4, 3
    .forEach(System.out::println);
    // 4, 3
    
U.formatXml("<a><b>data</b></a>");
    // <a>
    //    <b>data</b>
    // </a>

U.formatJson("{\"a\":{\"b\":\"data\"}}");
    // {
    //    "a": {
    //      "b": "data"
    //    }
    // }

Underscore-java is a java port of Underscore.js.

In addition to porting Underscore's functionality, Underscore-java includes matching unit tests.

For docs, license, tests, and downloads, see: http://javadev.github.io/underscore-java

Thanks to Jeremy Ashkenas and all contributors to Underscore.js.

Packages

No packages published

Languages

  • Java 87.1%
  • JavaScript 12.9%