UNPKG

@beenotung/tslib

Version:
30 lines 758 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withMethod = exports.bindMethods = void 0; /** * Created by beenotung on 6/21/17. */ /** * fix 'this' scope issue of the member methods when passed to other functions * @return original object * */ /* tslint:disable:ban-types */ function bindMethods(o) { Object.keys(o).forEach(x => { const f = o[x]; if (typeof f === 'function') { o[x] = f.bind(o); } }); return o; } exports.bindMethods = bindMethods; /* tslint:enable:ban-types */ /** * cast object to class with class methods * */ function withMethod(c, o) { return Object.assign(new c(), o); } exports.withMethod = withMethod; //# sourceMappingURL=class.js.map