Underscore.m

数据操作 DSL。「A DSL for Data Manipulation」

Underscore.m

About Underscore.m

Underscore.m is a small utility library to facilitate working with common data structures in Objective-C.
It tries to encourage chaining by eschewing the square bracket]]]]]].
It is inspired by the awesome underscore.js.

Real world example

// First, let's compose a twitter search request
NSURL *twitterSearch = [NSURL URLWithString:@"http://search.twitter.com/search.json?q=@SoundCloud&rpp=100"];

// ... then we fetch us some json ...
NSData *data = [NSData dataWithContentsOfURL:twitterSearch];

// ... and parse it.
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data
                                                     options:kNilOptions
                                                       error:NULL];

// This is where the fun starts!
NSArray *tweets = [json valueForKey:@"results"];

NSArray *processed = _array(tweets)
    // Let's make sure that we only operate on NSDictionaries, you never
    // know with these APIs ;-)
    .filter(Underscore.isDictionary)
    // Remove all tweets that are in English
    .reject(^BOOL (NSDictionary *tweet) {
        return [[tweet valueForKey:@"iso_language_code"] isEqualToString:@"en"];
    })
    // Create a simple string representation for every tweet
    .map(^NSString *(NSDictionary *tweet) {
        NSString *name = [tweet valueForKey:@"from_user_name"];
        NSString *text = [tweet valueForKey:@"text"];

        return [NSString stringWithFormat:@"%@: %@", name, text];
    })
    .unwrap;

Documentation

Documentation for Underscore.m can be found on the website.

Main metrics

Overview
Name With Ownerrobb/Underscore.m
Primary LanguageObjective-C
Program languageRuby (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2012-04-29 20:01:23
Pushed At2017-11-11 11:00:30
Last Commit At2013-08-09 00:29:47
Release Count5
Last Release Name0.3.0 (Posted on )
First Release Name0.0.1.pre.1 (Posted on )
用户参与
Stargazers Count1.5k
Watchers Count48
Fork Count98
Commits Count194
Has Issues Enabled
Issues Count45
Issue Open Count9
Pull Requests Count17
Pull Requests Open Count4
Pull Requests Close Count11
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private