Skip to content

Commit

Permalink
Added combinators and updated roweis
Browse files Browse the repository at this point in the history
  • Loading branch information
raganwald committed Sep 16, 2010
1 parent 5a531e5 commit 1cb0fdb
Show file tree
Hide file tree
Showing 2 changed files with 277 additions and 103 deletions.
58 changes: 58 additions & 0 deletions lib/sammy.combinators.js
@@ -0,0 +1,58 @@
/*
The MIT License
Copyright (c) 2010 Reginald Braithwaite http://reginald.braythwayt.com
and Unspace Interactive http://unspace.ca
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

(function(undefined){

Sammy.Combinators = function (app) {

var aps = Array.prototype.slice,
noop = function () {};

// combinators

app.T = function( fn ) {
fn = typeof Functional != 'undefined' ? Functional.lambda( fn ) : fn;
return fn.apply( this, [this].concat(aps.call( arguments, 1 )) );
};

app.K = function( fn ) {
fn = typeof Functional != 'undefined' ? Functional.lambda( fn ) : fn;
fn.apply( this, [this].concat(aps.call( arguments, 1 )) );
return this;
};

// aliases

if ( app.tap === undefined ) {
app.tap = app.K;
}

if ( app.into === undefined ) {
app.into = app.T;
}

};

})();

0 comments on commit 1cb0fdb

Please sign in to comment.