Sha256: 3ed1db4a30ffc14784a61b368aab4dd18cb943a7379f468cab5ced07f8535a5a
Contents?: true
Size: 970 Bytes
Versions: 100
Compression:
Stored size: 970 Bytes
Contents
/*! * Chai - addMethod utility * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com> * MIT Licensed */ /** * ### .addMethod (ctx, name, method) * * Adds a method to the prototype of an object. * * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) { * var obj = utils.flag(this, 'object'); * new chai.Assertion(obj).to.be.equal(str); * }); * * Can also be accessed directly from `chai.Assertion`. * * chai.Assertion.addMethod('foo', fn); * * Then can be used as any other assertion. * * expect(fooStr).to.be.foo('bar'); * * @param {Object} ctx object to which the method is added * @param {String} name of method to add * @param {Function} method function to be used for name * @name addMethod * @api public */ module.exports = function (ctx, name, method) { ctx[name] = function () { var result = method.apply(this, arguments); return result === undefined ? this : result; }; };
Version data entries
100 entries across 68 versions & 1 rubygems