Giter VIP home page Giter VIP logo

_.m's Introduction

_.m

_.m is a port of Underscore.js to Objective-C. It strives to provide the fullest feature set possible in a way that is familiar to JavaScript developers (despite the differences between JavaScript and Objective-C).

To help achieve this vision, _.m uses SubjectiveScript.m to bring JavaScript-like syntax and features into Objective-C, and QUnit.m to port unit tests from JavaScript to Objective-C. You should check them out, too!

Full documentation can be found on the _.m Website

A Quick Taster

You can use familiar Underscore.js functions:

N* result = (N*) _.detect(AI(1, 2, 3), ^B(N* num){ return num.I * 2 == 4; });
equal(result.I, 2, @"found the first '2' and broke the loop");

and you can even use chaining:

A* lyrics = AO(
  @"I'm a lumberjack and I'm okay",
  @"I sleep all night and I work all day",
  @"He's a lumberjack and he's okay",
  @"He sleeps all night and he works all day"
);
O* counts = (O*) __(lyrics)
  .map(^(NSS* line, ...) { return line.split(@""); })
  .flatten(/* REQUIRED */ false )
  .reduce(^(O* hash, N* l, ... /* KEY, LIST */) {
    N* value = (N*) hash.getOrAdd(l, ^{ return N.I(0); });
    hash.set(l, N.I(value.I+1));
    return hash;
}, O.new).value();
ok(counts.get(@"a").I == 16 && counts.get(@"e").I == 10, @"counted all the letters in the song");

Installing

#Install From GitHub Source

#Install From CocoaPods

  • Install Ruby and CocoaPods
  • Configure a Podfile in the root directory of your XCode project. For example:
      platform :ios
      pod '_.m',                  '~> 0.1.1'
      pod 'SubjectiveScript.m',   '~> 0.1.1'
  • Install the pods from the Podfile 'pod install {YourProject}.xcodeproj'
  • Use the generated '{YourProject}.xcworkspace' file instead of '{YourProject}.xcodeproj'

_.m's People

Contributors

alfred-nsh avatar

Watchers

Martin Lübcke avatar Fredrik Andersson avatar James Cloos avatar Joseph Badran avatar  avatar  avatar

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.