binders creates binders full of bound methods
Creates "binders" full of bound methods.
npm install binders
var binders = require'binders';// A test object with some values and functionsvar testObj =hello: "world"foo: "bar"thishello = val;thisfoo = val;return this;;// Create a bound object from the test objectvar boundObj = binderstestObj;boundObjwhatIsThis; // Returns `testObj`boundObjsetHello"everybody"; // testObj.hello === "everybody"boundObjhello; // `undefined`// Create a bound function from the test objectvar boundFoo = binderstestObj 'foo';boundFoo'baz'; // testObj.foo === 'baz'
A new object with all of the methods (and its prototype's methods, and prototype's prototype's, etc) where
this is bound to the original object. This is useful when you want to pass the methods of an object around without the actual object itself, but still have those methods act on their parent object.
You would want to do this with functional-style libraries, such as queue-flow:
var q = require'queue-flow';var l = require'lambda-js';var binder = require'binder';var http = require'http';httpget''var localQ = qns;reson'data' binderslocalQ'process' 'push';reson'end' binderslocalQ'process' 'close';localQ'process'reducel'sum, cur' 'sum+cur' q'continue' '';;q'continue' // Work on entire body of data here
Copyright (C) 2012 by David Ellis
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.