MCPcopy
hub / github.com/esamattis/underscore.string / fn2method

Function fn2method

index.js:105–113  ·  view source on GitHub ↗
(key, fn)

Source from the content-addressed store, hash-verified

103};
104
105function fn2method(key, fn) {
106 if (typeof fn !== 'function') return;
107 s.prototype[key] = function() {
108 var args = [this._wrapped].concat(Array.prototype.slice.call(arguments));
109 var res = fn.apply(null, args);
110 // if the result is non-string stop the chain and return the value
111 return typeof res === 'string' ? new s(res) : res;
112 };
113}
114
115// Copy functions to instance methods for chaining
116for (var key in s) fn2method(key, s[key]);

Callers 2

index.jsFile · 0.85
prototype2methodFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…