-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added fab.filter and fab.parse binary apps.
- Loading branch information
Showing
3 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
exports.summary = "Turns a function into a binary app that only sends responses that satisfy the function."; | ||
|
||
exports.app = function( fn ) { | ||
return function( app ) { | ||
return function() { | ||
var out = this; | ||
return app.call( function listener( obj ) { | ||
if ( !obj || fn.call( obj, obj ) ) { | ||
out = out.apply( this, arguments ); | ||
} | ||
|
||
return listener; | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var fab = { map: require( "./fab.map" ).app }; | ||
|
||
exports.summary = "A binary app that converts JSON responses into objects."; | ||
|
||
exports.app = fab.map( function( obj ) { | ||
var body = obj.body; | ||
if ( typeof body == "string" ) obj.body = JSON.parse( body ); | ||
return obj; | ||
}) |