Skip to content

Instantly share code, notes, and snippets.

@ppeeou
Last active April 14, 2017 23:46
Show Gist options
  • Save ppeeou/3d4f96996921aa5dde4f0da144de4f33 to your computer and use it in GitHub Desktop.
Save ppeeou/3d4f96996921aa5dde4f0da144de4f33 to your computer and use it in GitHub Desktop.
pipeline 사용법
_.pipeline = function () {
var funs = arguments;
return function (seed) {
return _.reduce(funs, function (l, r) { return r(l); }
, seed);
}
};
var join = {
joined_at: function (body) {
return _.extend(body, { joined_at: new Date() });
},
greeting: function (member) {
console.log('member',member);
return member.name + "회원님 환영합니다.";
},
save : function(table,body){
console.log('table : ',table);
console.log('body : ',body);
return _.extend(body,{is_success:true})
//return db(table).insert(body);
}
};
join.user = _.pipeline(
join.joined_at,
_.partial(join.save,'users'),
join.greeting
)
join.company = _.pipeline(
join.joined_at,
_.partial(join.save,'companies'),
join.greeting
)
console.log(join.user({ name: 'jo', age: '20' }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment